🌊Pool Manager
The Pool Manager is a contract that handles liquidity pools in the MANTRA DEX. It allows for the creation and management of various types of liquidity pools, including constant product and stable swap pools and more. The contract facilitates liquidity provision, token swaps, and multi-hop operations across different pools.
The Pool Manager enables permissionless creation of liquidity pools, requiring a fee to prevent spam. It supports multiple pools for the same asset pair, each with a unique identifier. Users can provide liquidity, perform swaps, and execute multi-hop operations across different pools. The contract manages pool creation, liquidity provision and withdrawal, swaps, and maintains swap routes for efficient token exchanges.
Instantiate
Instantiates an instance of the pool manager contract
Key | Type | Description |
---|---|---|
| String | The fee collector contract address. |
| String | The farm manager contract address. |
| Coin | How much it costs to create a pool. |
ExecuteMsg
CreatePool
Creates a new pool with the provided assets, their decimals for calculation fees, pool type and the identifier for a pool.
Creation of pools in the pool manager is permissionless, but a fee must be paid to create a pool which is specified in the contract configuration.
All pools and their information are stored in the pool manager contract on the POOLS
map, and any amount of pools with any variation of assets can be created.
For example, two or more pools with the assets uom
and uusdc
can be created at anytime with different pool identifiers. A good example is two pools, same assets different pool types (stableswap vs constant product) however any variation is possible.
Key | Type | Description |
---|---|---|
| Vec<String> | The asset denoms for the pool. |
| Vec<u8> | The decimals for the given asset denoms, provided in the same order as |
| PoolFee | The fees for the pool. |
| PoolType | The type of pool to create. It can be either constant product or stableswap. |
| Option<String> | The identifier for the pool. If not set, a number (pool counter) will be assigned as pool id. |
ProvideLiquidity
Provides liquidity to the pool specified by the pool_identifier
. Liquidity balances are stored on a per-pool basis in order to not double count the assets of other pools with the same assets.
If lock_position_identifier
is provided, the LP tokens will be locked in the farm manager for the specified duration.
Otherwise, the LP tokens will be sent to the receiver address.
The amount of liquidity to be provided is determined by the amount of assets provided in info.funds
. If only one asset is provided then a single sided liquidity provision will be attempted.
Key | Type | Description |
---|---|---|
| Option<Decimal> | A percentage value representing the acceptable slippage for the operation. When provided, if the slippage exceeds this value, the liquidity provision will not be executed. |
| Option<Decimal> | The decimals for the given asset denoms, provided in the same order as |
| Option<String> | The receiver of the LP. |
| String | The identifier for the pool to provide liquidity for. |
| Option<u64> | The amount of time in seconds to unlock tokens if taking part on the farms. If not passed, the tokens will not be locked and the LP tokens will be returned to the user. |
| Option<String> | The identifier of the position to lock the LP tokens in the farm manager, if any. |
Swap
Swaps an offer asset to another asset in the pool specified by the pool_identifier
. By providing a pool identifier when performing a swap, only the desired asset need be specified in the swap message The amount to be swapped is provided in info.funds
Key | Type | Description |
---|---|---|
| String | The return asset of the swap. |
| Option<Decimal> | The belief price of the swap. |
| Option<Decimal> | The maximum spread to incur when performing the swap. If the spread exceeds this value, the swap will not be executed. |
| Option<String> | The recipient of the output tokens. If not provided, the tokens will be sent to the sender of the message. |
| String | The identifier for the pool to swap in. |
WithdrawLiquidity
Withdraws liquidity from the pool specified by the pool_identifier
. A withdrawal of liquidity will result in the burning of any LP tokens that are returned as a part of the withdrawal. The LP token should be sent in the transaction.
Key | Type | Description |
---|---|---|
| String | The identifier for the pool to withdraw from. |
ExecuteSwapOperations
Execute multiple [SwapOperations
] to allow for multi-hop swaps.
Key | Type | Description |
---|---|---|
| Vec<SwapOperation> | The operations that should be performed in sequence. The amount in each swap will be the output from the previous swap. The first swap will use whatever funds are sent in the [ |
| Option<Uint128> | The minimum amount of the output (i.e., final swap operation token) required for the message to succeed. |
| Option<String> | The (optional) recipient of the output tokens. If left unspecified, tokens will be sent to the sender of the message. |
| Option<Decimal> | The (optional) maximum spread to incur when performing any swap. Maximum 50%. If left unspecified, it will use the default max spread value from the contract. |
UpdateConfig
Updates the configuration of the contract. If a field is not specified (i.e., set to None
), it will not be modified.
Key | Type | Description |
---|---|---|
| Option<String> | The new fee collector contract address. |
| Option<Coin> | The new fee that must be paid when a pool is created. |
| Option<FeatureToggle> | The new feature toggles of the contract, allowing fine-tuned control over which operations are allowed. |
UpdateOwnership(::cw_ownable::Action)
Implements cw_ownable
. Updates the contract's ownership. ::cw_ownable::Action
can be TransferOwnership
, AcceptOwnership
and RenounceOwnership
.
Note: This is a cw_ownable
message.
Propose to transfer the contract's ownership to another account, optionally with an expiry time. Can only be called by the contract's current owner. Any existing pending ownership transfer is overwritten.
Key | Type | Description |
---|---|---|
| String | The new owner proposed, |
| Option<Expiration> | Optional expiration time parameter. |
QueryMsg
Config
Returns the configuration of the contract.
AssetDecimals
Retrieves the decimals for the given asset in a specific pool.
Simulation
Simulates a swap.
ReverseSimulation
Simulates a reverse swap.
SimulateSwapOperations
Simulates swap operations.
ReverseSimulateSwapOperations
Simulates reverse swap operations.
Pools
Retrieves the pool information for the given pool identifier or all pools.
Ownership
Returns the ownership of the contract.
Note: This is a cw_ownable
query.
MigrateMsg
Message to migrate the contract to a new code ID.
Last updated