SelfPeggingAssetFactory
Inherits: UUPSUpgradeable, OwnableUpgradeable
Author: Nuts Finance Developer
The StableSwap Application provides an interface for users to interact with StableSwap pool contracts
The StableSwap Application contract allows users to mint pool tokens, swap between different tokens, and redeem pool tokens to underlying tokens. This contract should never store assets.
State Variables
governor
This is the account that has governor control over the protocol.
address public governor;
mintFee
Default mint fee for the pool.
uint256 public mintFee;
swapFee
Default swap fee for the pool.
uint256 public swapFee;
redeemFee
Default redeem fee for the pool.
uint256 public redeemFee;
offPegFeeMultiplier
Default off peg fee multiplier for the pool.
uint256 public offPegFeeMultiplier;
A
Default A parameter for the pool.
uint256 public A;
selfPeggingAssetBeacon
Beacon for the SelfPeggingAsset implementation.
address public selfPeggingAssetBeacon;
spaTokenBeacon
Beacon for the SPAToken implementation.
address public spaTokenBeacon;
wspaTokenBeacon
Beacon for the WSPAToken implementation.
address public wspaTokenBeacon;
rampAControllerBeacon
Beacon for the RampAController implementation.
address public rampAControllerBeacon;
constantExchangeRateProvider
Constant exchange rate provider.
address public constantExchangeRateProvider;
keeperImplementation
address public keeperImplementation;
minRampTime
Minimum ramp time for the A parameter.
uint256 public minRampTime;
exchangeRateFeeFactor
The exchange rate fee factor.
uint256 public exchangeRateFeeFactor;
bufferPercent
The buffer percent for the SPAToken.
uint256 public bufferPercent;
Functions
constructor
constructor();
initialize
Initializes the StableSwap Application contract.
function initialize(InitializeArgument memory argument) public initializer;
setGovernor
Set the govenance address.
function setGovernor(address _governor) external onlyOwner;
setMintFee
Set the mint fee.
function setMintFee(uint256 _mintFee) external onlyOwner;
setSwapFee
Set the swap fee.
function setSwapFee(uint256 _swapFee) external onlyOwner;
setRedeemFee
Set the redeem fee.
function setRedeemFee(uint256 _redeemFee) external onlyOwner;
setOffPegFeeMultiplier
Set the off peg fee multiplier.
function setOffPegFeeMultiplier(uint256 _offPegFeeMultiplier) external onlyOwner;
setA
Set the A parameter.
function setA(uint256 _A) external onlyOwner;
setMinRampTime
Set the minimum ramp time.
function setMinRampTime(uint256 _minRampTime) external onlyOwner;
setExchangeRateFeeFactor
Set the exchange rate fee factor.
function setExchangeRateFeeFactor(uint256 _exchangeRateFeeFactor) external onlyOwner;
setBufferPercent
Set the buffer percentage.
function setBufferPercent(uint256 _bufferPercent) external onlyOwner;
setKeeperImplementation
Set the keeper implementation.
function setKeeperImplementation(address _keeperImplementation) external onlyOwner;
createPool
Create a new pool.
function createPool(CreatePoolArgument memory argument)
external
returns (WSPAToken wspaToken, Keeper keeper, ParameterRegistry parameterRegistry);
_authorizeUpgrade
Authorisation to upgrade the implementation of the contract.
function _authorizeUpgrade(address) internal override onlyOwner;
Events
GovernorModified
This event is emitted when the governor is modified.
event GovernorModified(address governor);
Parameters
Name | Type | Description |
---|---|---|
governor | address | is the new value of the governor. |
PoolCreated
This event is emitted when a new pool is created.
event PoolCreated(
address poolToken,
address selfPeggingAsset,
address wrappedPoolToken,
address rampAController,
address parameterRegistry,
address keeper
);
Parameters
Name | Type | Description |
---|---|---|
poolToken | address | is the pool token created. |
selfPeggingAsset | address | is the self pegging asset created. |
wrappedPoolToken | address | is the wrapped pool token created. |
rampAController | address | is the ramp A controller created. |
parameterRegistry | address | is the parameter registry created. |
keeper | address | is the keeper created. |
MintFeeModified
This event is emitted when the mint fee is updated.
event MintFeeModified(uint256 mintFee);
Parameters
Name | Type | Description |
---|---|---|
mintFee | uint256 | is the new value of the mint fee. |
SwapFeeModified
This event is emitted when the swap fee is updated.
event SwapFeeModified(uint256 swapFee);
Parameters
Name | Type | Description |
---|---|---|
swapFee | uint256 | is the new value of the swap fee. |
RedeemFeeModified
This event is emitted when the redeem fee is updated.
event RedeemFeeModified(uint256 redeemFee);
Parameters
Name | Type | Description |
---|---|---|
redeemFee | uint256 | is the new value of the redeem fee. |
OffPegFeeMultiplierModified
This event is emitted when the off peg fee multiplier is updated.
event OffPegFeeMultiplierModified(uint256 offPegFeeMultiplier);
Parameters
Name | Type | Description |
---|---|---|
offPegFeeMultiplier | uint256 | is the new value of the off peg fee multiplier. |
AModified
This event is emitted when the A parameter is updated.
event AModified(uint256 A);
Parameters
Name | Type | Description |
---|---|---|
A | uint256 | is the new value of the A parameter. |
ExchangeRateFeeFactorModified
This event is emitted when the exchange rate fee factor is updated.
event ExchangeRateFeeFactorModified(uint256 exchangeRateFeeFactor);
Parameters
Name | Type | Description |
---|---|---|
exchangeRateFeeFactor | uint256 | is the new value of the exchange rate fee factor. |
MinRampTimeUpdated
This event is emitted when the min ramp time is updated.
event MinRampTimeUpdated(uint256 minRampTime);
Parameters
Name | Type | Description |
---|---|---|
minRampTime | uint256 | is the new value of the min ramp time. |
BufferPercentUpdated
This event is emitted when the buffer percent is updated.
event BufferPercentUpdated(uint256 bufferPercent);
Parameters
Name | Type | Description |
---|---|---|
bufferPercent | uint256 | is the new value of the buffer percent. |
KeeperImplementationUpdated
This event is emitted when the keeper contract implementation is updated.
event KeeperImplementationUpdated(address keeperImplementation);
Parameters
Name | Type | Description |
---|---|---|
keeperImplementation | address | is the new address of keeper implementation. |
Errors
InvalidAddress
Error thrown when the address is invalid
error InvalidAddress();
InvalidValue
Error thrown when the value is invalid
error InvalidValue();
InvalidOracle
Error thrown when the oracle is invalid
error InvalidOracle();
InvalidFunctionSig
Error thrown when the function signature is invalid
error InvalidFunctionSig();
Structs
InitializeArgument
Parameters for initailizing the factory
struct InitializeArgument {
address owner;
address governor;
uint256 mintFee;
uint256 swapFee;
uint256 redeemFee;
uint256 offPegFeeMultiplier;
uint256 A;
uint256 minRampTime;
address selfPeggingAssetBeacon;
address spaTokenBeacon;
address wspaTokenBeacon;
address rampAControllerBeacon;
address keeperImplementation;
address constantExchangeRateProvider;
uint256 exchangeRateFeeFactor;
uint256 bufferPercent;
}
CreatePoolArgument
Parameters for creating a new pool
struct CreatePoolArgument {
address tokenA;
address tokenB;
TokenType tokenAType;
address tokenAOracle;
bytes tokenARateFunctionSig;
bytes tokenADecimalsFunctionSig;
TokenType tokenBType;
address tokenBOracle;
bytes tokenBRateFunctionSig;
bytes tokenBDecimalsFunctionSig;
}
Enums
TokenType
Token type enum
enum TokenType {
Standard,
Oracle,
Rebasing,
ERC4626
}