The StableSwap-NG Factory allows the permissionless deployment of up to eight-coin plain pools and metapools, as well as gauges. Liquidity pool and LP token share the same contract.
This function is only callable by the admin of the contract.
Function to add a new asset type.
Input
Type
Description
_id
uint8
Asset type ID
_name
String[10]
Name of the new asset type
Source code
asset_types:public(HashMap[uint8,String[20]])@externaldefadd_asset_type(_id:uint8,_name:String[10]):""" @notice Admin only method that adds a new asset type. @param _id asset type id. @param _name Name of the asset type. """assertmsg.sender==self.admin# dev: admin onlyself.asset_types[_id]=_name
StableSwap pools also allow the deployment of metapools (an asset paired against a base pool). When deploying a new Factory, the existing base pools must be manually added to the contract for them to be used for metapools.
Limitations when adding new base pools:
Rebasing tokens are not allowed in the base pool.
Do not add a base pool that contains native tokens (e.g., ETH).
This function is only callable by the admin of the contract.
Function to add a new base pool.
Input
Type
Description
_base_pool
address
Pool address to add as a base pool
_base_lp_token
address
LP token address of the pool
_asset_types
DynArray[uint8, MAX_COINS]
Array of asset types of the pool
_n_coins
uint256
Number of coins in the base pool
Source code
@externaldefadd_base_pool(_base_pool:address,_base_lp_token:address,_asset_types:DynArray[uint8,MAX_COINS],_n_coins:uint256,):""" @notice Add a base pool to the registry, which may be used in factory metapools @dev 1. Only callable by admin 2. Rebasing tokens are not allowed in the base pool. 3. Do not add base pool which contains native tokens (e.g. ETH). 4. As much as possible: use standard ERC20 tokens. Should you choose to deviate from these recommendations, audits are advised. @param _base_pool Pool address to add @param _asset_types Asset type for pool, as an integer """assertmsg.sender==self.admin# dev: admin-only functionassert2notin_asset_types# dev: rebasing tokens cannot be in base poolassertlen(self.base_pool_data[_base_pool].coins)==0# dev: pool existsassert_n_coins<MAX_COINS# dev: base pool can only have (MAX_COINS - 1) coins.# add pool to pool_listlength:uint256=self.base_pool_countself.base_pool_list[length]=_base_poolself.base_pool_count=length+1self.base_pool_data[_base_pool].lp_token=_base_lp_tokenself.base_pool_data[_base_pool].n_coins=_n_coinsself.base_pool_data[_base_pool].asset_types=_asset_typesdecimals:uint256=0coins:DynArray[address,MAX_COINS]=empty(DynArray[address,MAX_COINS])coin:address=empty(address)foriinrange(MAX_COINS):ifi==_n_coins:breakcoin=CurvePool(_base_pool).coins(i)assertcoin!=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE# dev: native token is not supportedself.base_pool_data[_base_pool].coins.append(coin)self.base_pool_assets[coin]=Truedecimals+=(ERC20(coin).decimals()<<i*8)self.base_pool_data[_base_pool].decimals=decimalslogBasePoolAdded(_base_pool)