SelfPeggingAssetFactory

Git Source

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;

lpTokenBeacon

Beacon for the LPToken implementation.

address public lpTokenBeacon;

wlpTokenBeacon

Beacon for the WLPToken implementation.

address public wlpTokenBeacon;

constantExchangeRateProvider

Constant exchange rate provider.

ConstantExchangeRateProvider public constantExchangeRateProvider;

Functions

initialize

Initializes the StableSwap Application contract.

function initialize(
    address _governor,
    uint256 _mintFee,
    uint256 _swapFee,
    uint256 _redeemFee,
    uint256 _offPegFeeMultiplier,
    uint256 _A,
    address _selfPeggingAssetBeacon,
    address _lpTokenBeacon,
    address _wlpTokenBeacon,
    ConstantExchangeRateProvider _constantExchangeRateProvider
)
    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;

createPool

Create a new pool.

function createPool(CreatePoolArgument memory argument) external;

_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

NameTypeDescription
governoraddressis 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);

Parameters

NameTypeDescription
poolTokenaddressis the pool token created.
selfPeggingAssetaddress
wrappedPoolTokenaddress

MintFeeModified

This event is emitted when the mint fee is updated.

event MintFeeModified(uint256 mintFee);

Parameters

NameTypeDescription
mintFeeuint256is the new value of the mint fee.

SwapFeeModified

This event is emitted when the swap fee is updated.

event SwapFeeModified(uint256 swapFee);

Parameters

NameTypeDescription
swapFeeuint256is the new value of the swap fee.

RedeemFeeModified

This event is emitted when the redeem fee is updated.

event RedeemFeeModified(uint256 redeemFee);

Parameters

NameTypeDescription
redeemFeeuint256is 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

NameTypeDescription
offPegFeeMultiplieruint256is 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

NameTypeDescription
Auint256is the new value of the A parameter.

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

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
}