Skip to main content
The Pool Manager is a contract that handles liquidity pools in the MANTRA DEX. It facilitates the creation and management of different pool types, liquidity provision, swaps, and multi-hop operations across pools. Pool creation is permissionless (a fee is required to prevent spam). Multiple pools can exist for the same asset pair, each with a unique identifier.

Pool types

There are two pool types: constant product (XYK) and stableswap.

XYK Pool

The XYK pool uses a constant product invariant: XY=kXY = k Where X and Y are the reserves for each token, and k is constant. XY=k=(X+Δx)(Y−Δy)XY = k = (X + \Delta x)(Y - \Delta y) To determine the ask asset amount (\Delta y) given the offered asset (\Delta x): Δy=fracYDeltaxX+Deltax\Delta y = \\frac{Y\\Delta x}{X + \\Delta x} The spread between executed and expected trade is: spread=(YDeltax/X)−(YDeltax/(X+Deltax))spread = (Y\\Delta x/X) - (Y\\Delta x/(X + \\Delta x))

Stableswap

Implements the StableSwap curve described by Curve: https://curve.fi/files/stableswap-paper.pdf. Supports 2–4 assets and is designed for low slippage stable-asset trading.

Instantiate

ExecuteMsg

CreatePool

Creates a new pool with assets, decimals, fees, pool type, and identifier. Pool identifiers:
  • Auto-assigned pools get prefix p. (e.g. p.1)
  • Custom identifiers get prefix o. (e.g. o.my_pool)
Pool identifiers are immutable on-chain strings. Existing pools created before the rebranding may still reference legacy denom names (e.g. uom) in their identifiers.

XYK example

Stableswap example

ProvideLiquidity

Provides liquidity to a pool. If lock_position_identifier is set, LP tokens are locked in the farm manager for the specified duration; otherwise they are sent to the receiver.
It’s only possible to lock an LP position for the same user providing liquidity (not on behalf of another user).

Swap

Swaps an offer asset to an ask asset in a specific pool. Offer amount is provided in info.funds.

WithdrawLiquidity

Withdraws liquidity from a pool. LP tokens must be sent with the transaction.

ExecuteSwapOperations

Executes multiple swap operations (multi-hop). Routes are computed off-chain.

UpdateConfig

UpdateOwnership (::cw_ownable)

This is a cw_ownable message.

QueryMsg

Config

AssetDecimals

Simulation

ReverseSimulation

SimulateSwapOperations / ReverseSimulateSwapOperations

See legacy examples in _tmp_gitbook/mantra-smart-contracts/mantra-swap/pool-manager.md (ported here verbatim in structure).

Pools

Ownership (::cw_ownable)

This is a cw_ownable query.

MigrateMsg