๐ญFactory
White Whale's factory contract is used to create pair (pool) contracts. Pools are comprised of two tokens, which can be either native, ibc or cw20 tokens. Once a pool is created it's stored in state, meaning the factory acts as a pool registry, which can be queried for reference. Note that the pool factory is permissioned, meaning the messages can only be executed by the owner of the contract.
Create a pair
Creating a pair (pool) can be done via the create_pair
message. Note that for creating pools with native or ibc tokens, add_native_token_decimals
should be called in advance with a small amount of the desired asset (say one micro unit). This is used to whitelist native/ibc tokens, allowing pools to be created with those.
The code for the Factory contract can be found here.
The following are the messages that can be executed on the factory:
Instantiate
Instantiates the pool factory.
Key | Type | Description |
---|---|---|
| u64 | Code id for the pair/pool contract |
| u64 | Code id for the stableswap 3pool contract |
| u64 | Code id for the token contract |
| String | Address of the fee collector contract |
Migrate
Migrates the pool factory.
ExecuteMsg
Add Native Token Decimals
Used to validate native or ibc tokens, adding them to a whitelist so pools can be created with them. Along with this message, a small amount of the token should be transferred.
Note: This should be called before a pool with the given native/ibc token can be created.
Key | Type | Description |
---|---|---|
| String | denom of the native/ibc asset |
| u8 | Decimal places for that asset |
Create pair
Creates a pool with the given assets and pool fees. If the pool already exists, the transaction will fail.
Key | Type | Description |
---|---|---|
| [AssetInfo; 2] | Information about the two assets to create the pair with |
| PoolFee | Pool fees for the given pair |
| PairType | The variant of pair to create, it can be ConstantProduct or StableSwap |
| bool | If true, the pair will use the token factory to create the LP token. If false, it will use a cw20 token instead |
Create trio
Creates a pool with the 3 assets. If the pool already exists, the transaction will fail.
Key | Type | Description |
---|---|---|
| [AssetInfo; 3] | Information about the two assets to create the pair with |
| PoolFee | Pool fees for the given pair |
| u64 | Amplification factor to use for the 3 pool. This affects the swap curve, see https://curve.fi/files/stableswap-paper.pdf for more details |
| bool | If true, the pair will use the token factory to create the LP token. If false, it will use a cw20 token instead |
Migrate pair
Migrates a pool with the given address to the desired code id.
Key | Type | Description |
---|---|---|
| String | Pair contract address to be migrated |
| Option<u64> | Code id for the pair contract to be migrated to |
Migrate trio
Migrates a trio pool with the given address to the desired code id.
Key | Type | Description |
---|---|---|
| String | Trio contract address to be migrated |
| Option<u64> | Code id for the pair contract to be migrated to |
Remove pair
Removes a pair for the pool registry. Note that the pool will still live on the blockchain, this action though will make it invisible to the factory, meaning it will be orphan by the protocol. This action could be used in case a pool is no longer desired, e.g. if a pool was set up incorrectly (and can't be fixed by updating the config). Ideally, this should only be done after the pool's liquidity has been withdrawn or migrated.
Key | Type | Description |
---|---|---|
| [AssetInfo; 2] | Asset infos of the Pair contract to be removed from the factory registry |
Remove trio
Removes a trio for the pool registry. Note that the pool will still live on the blockchain, this action though will make it invisible to the factory, meaning it will be orphan by the protocol. This action could be used in case a pool is no longer desired, e.g. if a pool was set up incorrectly (and can't be fixed by updating the config). Ideally, this should only be done after the pool's liquidity has been withdrawn or migrated.
Key | Type | Description |
---|---|---|
| [AssetInfo; 3] | Asset infos of the Trio contract to be removed from the factory registry |
Update config
Updates the configuration of the factory.
Key | Type | Description |
---|---|---|
| Option<String> | New owner of the contract |
| Option<String> | New fee collector address |
| Option<u64> | New code id for the token contract, used by the pair contract to create LP tokens from |
| Option<u64> | New code id for the pair contract, used by the factory to create pools from |
| Option<u64> | New code id for the trio contract, used by the factory to create pools from |
Update pair config
Updates the configuration of the pair created by the factory.
Key | Type | Description |
---|---|---|
| String | Pair contract address to update the config |
| Option<String> | New owner address |
| Option<String> | New fee collector address |
| Option<PoolFee> | New pool fees |
| Option<FeatureToggle> | New feature toggle options for the pool |
Update trio config
Updates the configuration of the trio created by the factory.
Key | Type | Description |
---|---|---|
| String | Trio contract address to update the config |
| Option<String> | New owner address |
| Option<String> | New fee collector address |
| Option<PoolFee> | New pool fees |
| Option<FeatureToggle> | New feature toggle options for the pool |
| Option<RampAmp> | New settings for the amplification factor |
Queries
Config
Retrieves the configuration of the factory.
Native token decimals
Retrieves the native token decimals for the given denom
.
Key | Type | Description |
---|---|---|
| String | Native or IBC denom to query decimals for |
Pair
Retrieves pool information for a given pair.
Key | Type | Description |
---|---|---|
| [AssetInfo; 2] | Asset info for the pair to retrieve info about |
Pairs
Retrieves multiple pool informations. Considering the pool registry can get extensive, pagination is possible. The default limit for the query is 10
, while the maximum is 30
.
Key | Type | Description |
---|---|---|
| Option<[AssetInfo; 2]> | Asset infos to start fetching from (when pagination is needed) |
| Option<u32> | How many items to fetch at once. Default is |
Trio
Retrieves pool information for a given trio.
Key | Type | Description |
---|---|---|
| [AssetInfo; 3] | Asset info for the trio to retrieve info about |
Trios
Retrieves multiple trio pool informations. Considering the pool registry can get extensive, pagination is possible. The default limit for the query is 10
, while the maximum is 30
.
Key | Type | Description |
---|---|---|
| Option<[AssetInfo; 3]> | Asset infos to start fetching from (when pagination is needed) |
| Option<u32> | How many items to fetch at once. Default is |
Last updated