🌊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

{
  "fee_collector_addr": "mantra1...",
  "farm_manager_addr": "mantra1...",
  "pool_creation_fee": {
    "denom": "uom",
    "amount": "1000000000"
  }
}
KeyTypeDescription

fee_collector_addr

String

The fee collector contract address.

farm_manager_addr

String

The farm manager contract address.

pool_creation_fee

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.

{
  "create_pool": {
    "asset_denoms": [
      "uom",
      "uusdc"
    ],
    "asset_decimals": [
      6,
      6
    ],
    "pool_fees": {
      "protocol_fee": {
        "share": "0.001"
      },
      "swap_fee": {
        "share": "0.002"
      },
      "burn_fee": {
        "share": "0"
      },
      "extra_fees": [
        {
          "share": "0.001"
        }
      ]
    },
    "pool_type": "constant_product",
    "pool_identifier": "uom.uusdy.pool"
  }
}
KeyTypeDescription

asset_denoms

Vec<String>

The asset denoms for the pool.

asset_decimals

Vec<u8>

The decimals for the given asset denoms, provided in the same order as asset_denoms.

pool_fees

PoolFee

The fees for the pool.

pool_type

PoolType

The type of pool to create. It can be either constant product or stableswap.

pool_identifier

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.

{
  "provide_liquidity": {
    "slippage_tolerance": "0.01",
    "max_spread": "0.1",
    "receiver": "mantra1...",
    "pool_identifier": "uom.uusdy.pool",
    "unlocking_duration": 2678400,
    "lock_position_identifier": "lp.lock.identifier"
  }
}
KeyTypeDescription

slippage_tolerance

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.

max_spread

Option<Decimal>

The decimals for the given asset denoms, provided in the same order as asset_denoms. The maximum allowable spread between the bid and ask prices for the pool. When provided, if the spread exceeds this value, the liquidity provision will not be executed.

receiver

Option<String>

The receiver of the LP.

pool_identifier

String

The identifier for the pool to provide liquidity for.

unlocking_duration

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.

lock_position_identifier

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

{
  "swap": {
    "ask_asset_denom": "uusdc",
    "belief_price": "0.5",
    "max_spread": "5000",
    "receiver": "mantra1...",
    "pool_identifier": "uom.uusdy.pool"
  }
}
KeyTypeDescription

ask_asset_denom

String

The return asset of the swap.

belief_price

Option<Decimal>

The belief price of the swap.

max_spread

Option<Decimal>

The maximum spread to incur when performing the swap. If the spread exceeds this value, the swap will not be executed.

receiver

Option<String>

The recipient of the output tokens. If not provided, the tokens will be sent to the sender of the message.

pool_identifier

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.

{
  "withdraw_liquidity": {
    "pool_identifier": "uom.uusdy.pool"
  }
}
KeyTypeDescription

pool_identifier

String

The identifier for the pool to withdraw from.

ExecuteSwapOperations

Execute multiple [SwapOperations] to allow for multi-hop swaps.

{
  "execute_swap_operations": {
    "operations": [
      {
        "mantra_swap": {
          "token_in_denom": "uluna",
          "token_out_denom": "uom",
          "pool_identifier": "uluna_uom_pool"
        }
      },
      {
        "mantra_swap": {
          "token_in_denom": "uom",
          "token_out_denom": "uusdc",
          "pool_identifier": "uom.uusdy.pool"
        }
      }
    ],
    "minimum_receive": "1000000",
    "receiver": "mantra1...",
    "max_spread": "0.1"
  }
}
KeyTypeDescription

operations

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 [MessageInfo].

minimum_receive

Option<Uint128>

The minimum amount of the output (i.e., final swap operation token) required for the message to succeed.

receiver

Option<String>

The (optional) recipient of the output tokens. If left unspecified, tokens will be sent to the sender of the message.

max_spread

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.

{
  "update_config": {
    "fee_collector_addr": "mantra1...",
    "pool_creation_fee": {
      "denom": "uom",
      "amount": "1000000000"
    },
    "feature_toggle": {
      "withdrawals_enabled": true,
      "deposits_enabled": true,
      "swaps_enabled": true
    }
  }
}
KeyTypeDescription

fee_collector_addr

Option<String>

The new fee collector contract address.

pool_creation_fee

Option<Coin>

The new fee that must be paid when a pool is created.

feature_toggle

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.

{
  "update_ownership": {
    "transfer_ownership": {
      "new_owner": "mantra1...",
      "expiry": {
        "at_height": "424242424242"
      }
    }
  }
}
KeyTypeDescription

new_owner

String

The new owner proposed,

expiry

Option<Expiration>

Optional expiration time parameter.

QueryMsg

Config

Returns the configuration of the contract.

{
  "config": {}
}

AssetDecimals

Retrieves the decimals for the given asset in a specific pool.

{
  "asset_decimals": {
    "pool_identifier": "om-usdc-1",
    "denom": "uom"
  }
}

Simulation

Simulates a swap.

{
  "simulation": {
    "offer_asset": {
      "denom": "uom",
      "amount": "1000000"
    },
    "ask_asset_denom": "uusdc",
    "pool_identifier": "om-usdc-1"
  }
}

ReverseSimulation

Simulates a reverse swap.

{
  "reverse_simulation": {
    "ask_asset": {
      "denom": "uusdc",
      "amount": "990000"
    },
    "offer_asset_denom": "uom",
    "pool_identifier": "om-usdc-1"
  }
}

SimulateSwapOperations

Simulates swap operations.

{
  "simulate_swap_operations": {
    "offer_amount": "1000000",
    "operations": [
      {
        "mantra_swap": {
          "token_in_denom": "uom",
          "token_out_denom": "uusdc",
          "pool_identifier": "om-usdc-1"
        }
      },
      {
        "mantra_swap": {
          "token_in_denom": "uusdc",
          "token_out_denom": "uatom",
          "pool_identifier": "usdc-atom-1"
        }
      }
    ]
  }
}

ReverseSimulateSwapOperations

Simulates reverse swap operations.

{
  "reverse_simulate_swap_operations": {
    "ask_amount": "980000",
    "operations": [
      {
        "mantra_swap": {
          "token_in_denom": "uom",
          "token_out_denom": "uusdc",
          "pool_identifier": "om-usdc-1"
        }
      },
      {
        "mantra_swap": {
          "token_in_denom": "uusdc",
          "token_out_denom": "uatom",
          "pool_identifier": "usdc-atom-1"
        }
      }
    ]
  }
}

Pools

Retrieves the pool information for the given pool identifier or all pools.

{
  "pools": {
    "pool_identifier": "om-usdc-1",
    "start_after": null,
    "limit": 10
  }
}

Ownership

Returns the ownership of the contract.

Note: This is a cw_ownable query.

{
  "ownership": {}
}

MigrateMsg

Message to migrate the contract to a new code ID.

{}

Last updated