Getter method for a list of pools that holds _from and _to coins.
Returns: pool list (DynArray[address, 1000]).
Input
Type
Description
_from
address
Address of coin to be sent
_to
address
Address of coin to be received
Source code
@view@externaldeffind_pools_for_coins(_from:address,_to:address)->DynArray[address,1000]:""" @notice Find all pools that contain the input pair @param _from Address of coin to be sent @param _to Address of coin to be received @return Pool addresses """pools_found:DynArray[address,1000]=empty(DynArray[address,1000])pool:address=empty(address)registry:address=empty(address)forregistry_indexinrange(MAX_REGISTRIES):registry=self.get_registry[registry_index]ifregistry==empty(address):breakforjinrange(0,65536):pool=RegistryHandler(registry).find_pool_for_coins(_from,_to,j)ifpool==empty(address):breakpools_found.append(pool)returnpools_found
Getter method for a pool that holds two coins (even if the pool is a metapool). The index in the query returns the index of the list of pools containing the two coins.
Returns: pool (address).
Input
Type
Description
_from
address
Address of coin to be sent
_to
address
Address of coin to be received
i
uint256
Index of the pool to return
Source code
@view@externaldeffind_pool_for_coins(_from:address,_to:address,i:uint256=0)->address:""" @notice Find the ith available pool containing the input pair @param _from Address of coin to be sent @param _to Address of coin to be received @param i Index of the pool to return @return Pool address """pools_found:uint256=0pool:address=empty(address)registry:address=empty(address)forregistry_indexinrange(MAX_REGISTRIES):registry=self.get_registry[registry_index]ifregistry==empty(address):breakforjinrange(0,65536):pool=RegistryHandler(registry).find_pool_for_coins(_from,_to,j)ifpool==empty(address):breakpools_found+=1ifpools_found>i:returnpoolreturnpool
Getter for the total number of pools of all registries registered in the metaregistry.
Returns: number of pools (uint256).
Source code
@external@viewdefpool_count()->uint256:""" @notice Return the total number of pools tracked by the metaregistry @return uint256 The number of pools in the metaregistry """total_pools:uint256=0foriinrange(MAX_REGISTRIES):ifi==self.registry_length:breakhandler:address=self.get_registry[i]total_pools+=RegistryHandler(handler).pool_count()returntotal_pools
@external@viewdefpool_list(_index:uint256)->address:""" @notice Return the pool at a given index in the metaregistry @param _index The index of the pool in the metaregistry @return The address of the pool at the given index """pools_skip:uint256=0foriinrange(MAX_REGISTRIES):ifi==self.registry_length:breakhandler:address=self.get_registry[i]count:uint256=RegistryHandler(handler).pool_count()if_index-pools_skip<count:returnRegistryHandler(handler).pool_list(_index-pools_skip)pools_skip+=countreturnempty(address)
@external@viewdefget_pool_name(_pool:address,_handler_id:uint256=0)->String[64]:""" @notice Get the given name for a pool @param _pool Pool address @return The name of a pool """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_pool_name(_pool)
Getter method to check if a pool is a metapool. Metapools are pools that pair a coin to a base pool comprising of multiple coins.
Returns: true or false (bool).
Example
An example is the LUSD-3CRV pool which pairs Liquity'sLUSD against 3CRV, where 3CRV is a liquidity pool token that represents a share of a pool containing DAI, USDC and USDT.
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefis_meta(_pool:address,_handler_id:uint256=0)->bool:""" @notice Verify `_pool` is a metapool @param _pool Pool address @param _handler_id id of registry handler @return True if `_pool` is a metapool """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).is_meta(_pool)
Getter for the base pool of a metapool. If there is no base pool, it will return ZERO_ADDRESS.
Returns: base pool (address).
Example
In the case of the LUSD-3CRV pool example, the pool containing 3CRV underlying coins is the base pool of the LUSD-3CRV pool, which is the 3pool.
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_base_pool(_pool:address,_handler_id:uint256=0)->address:""" @notice Get the base pool for a given factory metapool @dev Will return empty(address) if pool is not a metapool @param _pool Metapool address @param _handler_id id of registry handler @return Address of base pool """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_base_pool(_pool)
Getter for the fees that a Curve pool charges per swap. The fee data returned varies depending on the type of pool:
StableSwap pools: Use a single fee parameter.
CryptoSwap pools: Use multiple fee parameters due to their dynamic fee structure.
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_fees(_pool:address,_handler_id:uint256=0)->uint256[10]:""" @notice Get pool fees @dev Fees are expressed as integers @param _pool Pool address @param _handler_id id of registry handler @return Pool fee as uint256 with 1e10 precision Admin fee as 1e10 percentage of pool fee Mid fee Out fee 6 blank spots for future use cases """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_fees(_pool)
For Stableswap, the getter returns the fee per swap and the admin_fee percentage. For the 3pool, it shows that the pool charges 1 basis point per swap, 50% of which goes to the DAO.
For CryptoSwap, the getter returns: fee, admin_fee percentage, mid_fee and out_fee. The fee is the dynamic fee charged per swap, and depends on the mid_fee (fee when the CryptoSwap pool is pegged) and the out_fee. To understand the dynamic fee algorithm, the reader is pointed to the CryptoSwap Paper.
@external@viewdefget_pool_params(_pool:address,_handler_id:uint256=0)->uint256[MAX_POOL_PARAMS]:""" @notice Get the parameters of a pool @param _pool Pool address @param _handler_id id of registry handler @return Pool parameters """registry_handler:address=self._get_registry_handlers_from_pool(_pool)[_handler_id]returnRegistryHandler(registry_handler).get_pool_params(_pool)
For StableSwap, the getter returns the pool's amplification coefficient (A).
@external@viewdefget_lp_token(_pool:address,_handler_id:uint256=0)->address:""" @notice Get the address of the LP token of a pool @param _pool Pool address @param _handler_id id of registry handler @return Address of the LP token """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_lp_token(_pool)
Getter for the asset type of a pool. 0 = USD, 1 = ETH, 2 = BTC, 3 = Other, 4 = CryptoPool token. The asset type is a property of StableSwaps, and is not enforced in CryptoSwap pools (which always return 4).
Returns: asset type id (uint256).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_pool_asset_type(_pool:address,_handler_id:uint256=0)->uint256:""" @notice Query the asset type of `_pool` @param _pool Pool Address @return The asset type as an unstripped string @dev 0 : USD, 1: ETH, 2: BTC, 3: Other, 4: CryptoSwap """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_pool_asset_type(_pool)
Getter for the liquidity pool associated with a LP token.
Returns: liquidity pool (address).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_pool_from_lp_token(_token:address,_handler_id:uint256=0)->address:""" @notice Get the pool associated with an LP token @param _token LP token address @return Pool address """returnself._get_pool_from_lp_token(_token)
Getter for a token's virtual price. The virtual price of any pool begins with 1, and increases as the pool accrues fees. This number constantly increases for StableSwap pools, unless the pool's amplification coefficient changes. For CryptoSwap pools, there are moments when the virtual price can go down (admin fee claims, changes to pool's parameters).
Returns: virtual price of the lp token (uint256).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_virtual_price_from_lp_token(_token:address,_handler_id:uint256=0)->uint256:""" @notice Get the virtual price of a pool LP token @param _token LP token address @param _handler_id id of registry handler @return uint256 Virtual price """pool:address=self._get_pool_from_lp_token(_token)registry_handler:address=self._get_registry_handlers_from_pool(pool)[_handler_id]returnRegistryHandler(registry_handler).get_virtual_price_from_lp_token(_token)
Method to check if a pool is in the MetaRegistry using get_n_coins.
Returns: true or false (bool).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefis_registered(_pool:address,_handler_id:uint256=0)->bool:""" @notice Check if a pool is in the metaregistry using get_n_coins @param _pool The address of the pool @param _handler_id id of registry handler @return A bool corresponding to whether the pool belongs or not """returnself._get_registry_handlers_from_pool(_pool)[_handler_id]!=empty(address)
@external@viewdefget_gauge(_pool:address,gauge_idx:uint256=0,_handler_id:uint256=0)->address:""" @notice Get a single liquidity gauge contract associated with a pool @param _pool Pool address @param gauge_idx Index of gauge to return @param _handler_id id of registry handler @return Address of gauge """registry_handler:RegistryHandler=RegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id])handler_output:address[10]=registry_handler.get_gauges(_pool)[0]returnhandler_output[gauge_idx]
Getter for the gauge type of the gauge associated with a liquidity pool.
Returns: gauge type (int128).
Input
Type
Description
_pool
address
Address of the pool
gauge_idx
uint256
Index of gauge to return; defaults to 0
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_gauge_type(_pool:address,gauge_idx:uint256=0,_handler_id:uint256=0)->int128:""" @notice Get gauge_type of a single liquidity gauge contract associated with a pool @param _pool Pool address @param gauge_idx Index of gauge to return @param _handler_id id of registry handler @return Address of gauge """registry_handler:RegistryHandler=RegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id])handler_output:int128[10]=registry_handler.get_gauges(_pool)[1]returnhandler_output[gauge_idx]
Getter method for the coins in a pool. If the pool is a metapool, it then returns the LP token of the base pool, and not the underlying coins.
Retuns: coin addresses (address[MAX_COINS]).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_coins(_pool:address,_handler_id:uint256=0)->address[MAX_COINS]:""" @notice Get the coins within a pool @dev For metapools, these are the wrapped coin addresses @param _pool Pool address @param _handler_id id of registry handler @return List of coin addresses """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_coins(_pool)
@external@viewdefget_n_coins(_pool:address,_handler_id:uint256=0)->uint256:""" @notice Get the number of coins in a pool @dev For metapools, it is tokens + wrapping/lending token (no underlying) @param _pool Pool address @return Number of coins """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_n_coins(_pool)
Getter for the decimals of the coins that are returned by get_coins. When querying for metapools, this method returns the decimals of the metapool token and the LP token of the basepool.
Returns: number of decimals (uint256[MAX_COINS]).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_decimals(_pool:address,_handler_id:uint256=0)->uint256[MAX_COINS]:""" @notice Get decimal places for each coin within a pool @dev For metapools, these are the wrapped coin decimal places @param _pool Pool address @param _handler_id id of registry handler @return uint256 list of decimals """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_decimals(_pool)
>>>MetaRegistry.get_decimals("0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7")18,6,6,0,0,0,0,0# decimals of DAI, USDT, USDC>>>MetaRegistry.get_decimals("0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA")18,18,0,0,0,0,0,0# decimals of LUSD, 3CRV
Getter for the balance of each coin within a pool. When querying for metapools, this method returns the balances of the metapool token and the LP token of the basepool. To also fetch the underlying balances of the basepool, see get_underlying_balances.
Returns: balances (uint256[MAX_COINS]).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_balances(_pool:address,_handler_id:uint256=0)->uint256[MAX_COINS]:""" @notice Get balances for each coin within a pool @dev For metapools, these are the wrapped coin balances @param _pool Pool address @param _handler_id id of registry handler @return uint256 list of balances """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_balances(_pool)
Getter for the underlying coins in a metapool. For non-metapools it returns the same value as get_coins.
Returns: underlying coins (address[MAX_COINS]).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_underlying_coins(_pool:address,_handler_id:uint256=0)->address[MAX_COINS]:""" @notice Get the underlying coins within a pool @dev For non-metapools, returns the same value as `get_coins` @param _pool Pool address @param _handler_id id of registry handler @return List of coin addresses """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_underlying_coins(_pool)
Getter method for the total number of underlying coins in a pool. For non-metapools it returns the same value as get_n_coins.
Returns: number of underlying coins (uin256).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_n_underlying_coins(_pool:address,_handler_id:uint256=0)->uint256:""" @notice Get the number of underlying coins in a pool @dev For non-metapools, returns the same as get_n_coins @param _pool Pool address @return Number of coins """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_n_underlying_coins(_pool)
Getter method for the decimal of each underlying coin within a pool.
Returns: number of decimals (uint256[MAX_COINS]).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_underlying_decimals(_pool:address,_handler_id:uint256=0)->uint256[MAX_COINS]:""" @notice Get decimal places for each underlying coin within a pool @dev For non-metapools, returns the same value as `get_decimals` @param _pool Pool address @param _handler_id id of registry handler @return uint256 list of decimals """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_underlying_decimals(_pool)
>>>MetaRegistry.get_decimals("0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA")18,18,6,6,0,0,0,0# decimals of LUSD, DAI, USDC, USDT
Getter method for a pool's balances of the underlying coins which are returned by get_underlying_coins.
Returns: balances (uint256[MAX_COINS]).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_underlying_balances(_pool:address,_handler_id:uint256=0)->uint256[MAX_COINS]:""" @notice Get balances for each underlying coin within a pool @dev For non-metapools, returns the same value as `get_balances` @param _pool Pool address @param _handler_id id of registry handler @return uint256 List of underlying balances """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_underlying_balances(_pool)
>>>MetaRegistry.get_balances("0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA")4362795413803847111710482,7574850164613791626778647,7282723353910,4888387736171,0,0,0,0# balances of LUSD, DAI, USDC, USDT
Getter for the pool's admin balances. The balances represent the balances per coin, and retain the coin's precision.
Returns: admin balances (uint256[MAX_COINS]).
Input
Type
Description
_pool
address
Address of the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@external@viewdefget_admin_balances(_pool:address,_handler_id:uint256=0)->uint256[MAX_COINS]:""" @notice Get the current admin balances (uncollected fees) for a pool @dev _handler_id < 1 if pool is registry in one handler, more than 0 otherwise @param _pool Pool address @param _handler_id id of registry handler @return List of uint256 admin balances """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_admin_balances(_pool)
>>>MetaRegistry.get_admin_balances("0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7")1590779934844205413773,3866051363,5204415383,0,0,0,0,0# admin balances of DAI, USDC, USDT>>>MetaRegistry.get_admin_balances("0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA")574625025164093926144,321761837541842998875,0,0,0,0,0,0# admin balances of LUSD, 3CRV
Getter method which converts coin addresses to indices for use with pool methods.
Returns: from index (int128), to index (int128) and whether the market is underlying or not (bool).
Input
Type
Description
_pool
address
Address of the pool
_from
address
Coin address to be used as i within the pool
_to
address
Coin address to be used as j within the pool
_handler_id
uint256
ID of the RegistryHandler; defaults to 0
Source code
@view@externaldefget_coin_indices(_pool:address,_from:address,_to:address,_handler_id:uint256=0)->(int128,int128,bool):""" @notice Convert coin addresses to indices for use with pool methods @param _pool Pool address @param _from Coin address to be used as `i` within a pool @param _to Coin address to be used as `j` within a pool @param _handler_id id of registry handler @return from index, to index, is the market underlying ? """returnRegistryHandler(self._get_registry_handlers_from_pool(_pool)[_handler_id]).get_coin_indices(_pool,_from,_to)
>>>MetaRegistry.metaregistry.get_coin_indices("0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7","0x6B175474E89094C44Da98b954EedeAC495271d0F","0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")0,1,false# DAI is coin index0, USDC is coin index1 and no underlying coins>>>MetaRegistry.metaregistry.get_coin_indices("0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA","0x5f98805A4E8be255a32880FDeC7F6728C6568bA0","0xdAC17F958D2ee523a2206206994597C13D831ec7")0,3,false# LUSD is coin index0, USDT is coin index3 and underlying
@internal@viewdef_get_registry_handlers_from_pool(_pool:address)->address[MAX_REGISTRIES]:""" @notice Get registry handler that handles the registry api for a pool @dev sometimes a factory pool can be registered in a manual registry because of this, we always take the last registry a pool is registered in and not the first, as manual registries are first and factories come later @param _pool address of the pool @return registry_handlers: address[MAX_REGISTRIES] """pool_registry_handler:address[MAX_REGISTRIES]=empty(address[MAX_REGISTRIES])c:uint256=0foriinrange(MAX_REGISTRIES):ifi==self.registry_length:breakhandler:address=self.get_registry[i]ifRegistryHandler(handler).is_registered(_pool):pool_registry_handler[c]=handlerc+=1ifpool_registry_handler[0]==empty(address):raise("no registry")returnpool_registry_handler@external@viewdefget_registry_handlers_from_pool(_pool:address)->address[MAX_REGISTRIES]:""" @notice Get the registry handlers associated with a pool @param _pool Pool address @return List of registry handlers """returnself._get_registry_handlers_from_pool(_pool)
Getter for the registry associated with a registry handler.
Returns: base registry (address).
Input
Type
Description
registry_handler
address
RegistryHandler contract
Source code
@external@viewdefget_base_registry(registry_handler:address)->address:""" @notice Get the registry associated with a registry handler @param registry_handler Registry Handler address @return Address of base registry """returnRegistryHandler(registry_handler).base_registry()
This function is only callable by the owner of the contract.
Function to add a registry handler to the MetaRegistry.
Input
Type
Description
_registry_handler
address
RegistryHandler address to add
Source code
@externaldefadd_registry_handler(_registry_handler:address):""" @notice Adds a registry from the address provider entry @param _registry_handler Address of the handler contract """assertmsg.sender==self.owner# dev: only ownerself._update_single_registry(self.registry_length,_registry_handler)@internaldef_update_single_registry(_index:uint256,_registry_handler:address):assert_index<=self.registry_lengthif_index==self.registry_length:self.registry_length+=1self.get_registry[_index]=_registry_handler
This function is only callable by the owner of the contract.
Function to update the RegistryHandler for a already existing one.
Input
Type
Description
_index
uint256
index of registry according to get_registry
registry_handler
address
address of the new handler contract
Source code
@externaldefupdate_registry_handler(_index:uint256,_registry_handler:address):""" @notice Updates the contract used to handle a registry @param _index The index of the registry in get_registry @param _registry_handler Address of the new handler contract """assertmsg.sender==self.owner# dev: only ownerassert_index<self.registry_lengthself._update_single_registry(_index,_registry_handler)@internaldef_update_single_registry(_index:uint256,_registry_handler:address):assert_index<=self.registry_lengthif_index==self.registry_length:self.registry_length+=1self.get_registry[_index]=_registry_handler