pools
This document introduces the Queries and Transactions of pools module.
Queries
The Query submodule of pools module provides the logic to request information from the liquidity pools. It contains the following functions:
- Estimate Swap Exact Amount In
- Estimate Swap Exact Amount Out
- Num Pools
- Pool
- Pool Assets
- Pool Params
- Pools
- Spot Price
- Total Liquidity
- Total Share
# Estimate Swap Exact Amount In
Query the estimated result of the Swap Exact Amount In transaction. Note that the flags swap-route-pool and swap-route-denoms are required.
# Usage
imversed query pools estimate-swap-exact-amount-in <poolID> <sender> <tokenIn> [flags]
# Example
Query the amount of ATOM the sender would receive for swapping 1 OSMO in pool 1.
imversed query pools estimate-swap-exact-amount-in 1 osmo123nfq6m8f88m4g3sky570unsnk4zng4uqv7cm8 1000000uosmo --swap-route-pool-ids 1 --swap-route-denoms ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2
# Estimate Swap Exact Amount Out
Query the estimated result of the Swap Exact Amount Out transaction. Note that the flags swap-route-pool and swap-route-denoms are required.
# Usage
imversed query pools estimate-swap-exact-amount-out <poolID> <sender> <tokenOut> [flags]
# Example
Query the amount of OSMO the sender would require to swap 1 ATOM out of pool 1.
imversed query pools estimate-swap-exact-amount-out 1 osmo123nfq6m8f88m4g3sky570unsnk4zng4uqv7cm8 1000000ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 --swap-route-pool-ids 1 --swap-route-denoms aimv
# Num Pools
Query the number of active pools.
# Usage
imversed query pools num-pools
# Pool
Query the parameter and assets of a specific pool.
# Usage
imversed query pools pool <poolID> [flags]
# Example
Query parameters and assets from pool 1.
imversed query pools pool 1
# Pool Assets
Query the assets of a specific pool. This query is a reduced form of the Pool query.
# Usage
imversed query pools pool-assets <poolID> [flags]
Query the assets from pool 1.
# Example
imversed query pools pool-assets 1
# Pool Params
Query the parameters of a specific pool. This query is a reduced form of the Pool query.
# Usage
imversed query pools pool-params <poolID> [flags]
Query the parameters from pool 1.
# Example
imversed query pools pool-params 1
# Pools
Query parameters and assets of all active pools.
# Usage
imversed query pools pools
# Spot Price
Query the spot price of a pool asset based on a specific pool it is in.
# Usage
imversed query pools spot-price <poolID> <tokenInDenom> <tokenOutDenom> [flags]
# Example
Query the price of OSMO based on the price of ATOM in pool 1.
imversed query pools spot-price 1 aimv ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2
# Total Liquidity
Query the total liquidity of all active pools.
# Usage
imversed query pools total-liquidity
# Total Share
Query the total amount of GAMM shares of a specific pool.
# Usage
imversed query pools total-share <poolID> [flags]
# Example
Query the total amount of GAMM shares of pool 1.
imversed query pools total-share 1
Transactions
The Transaction submodule of pools module provides the logic to create and interact with the liquidity pools. It contains the following functions:
- Create Pool
- Join Pool
- Exit Pool
- Join Swap Extern Amount In
- Exit Swap Extern Amount Out
- Join Swap Share Amount Out
- Exit Swap Share Amount In
- Swap Exact Amount In
- Swap Exact Amount Out
# Create Pool
Create a new liquidity pool and provide the initial liquidity to it. Pool initialization parameters must be provided through a JSON file using the flag pool-file.
# Usage
imversed tx pools create-pool [flags]
The configuration file config.json must specify the following parameters.
{
"weights": [list weighted denoms],
"initial-deposit": [list of denoms with initial deposit amount],
"swap-fee": [swap fee in percentage],
"exit-fee": [exit fee in percentage],
"future-governor": [number of hours]
}
# Example
Create a new ATOM-OSMO liquidity pool with a swap and exit fee of 1%.
tx pools create-pool --pool-file ../public/config.json --from myKeyringWallet
The configuration file contains the following parameters.
{
"weights": "5uatom,5uosmo",
"initial-deposit": "100uatom,100uosmo",
"swap-fee": "0.01",
"exit-fee": "0.01",
"future-governor": "168h"
}
# Join Pool
Join a specific pool with a custom amount of tokens. Note that the flags pool-id, max-amounts-in and share-amount-out are required.
# Usage
imversed tx pools join-pool [flags]
# Example
Join pool 1 with 1 OSMO and the respective amount of ATOM, using myKeyringWallet.
imversed tx pools join-pool --pool-id 2 --max-amounts-in 1000000uosmo --max-amounts-in 1000000uion --share-amount-out 1000000 --from myKeyringWallet
# Exit Pool
Exit a specific pool with a custom amount of tokens. Note that the flags pool-id, min-amounts-out and share-amount-in are required.
# Usage
imversed tx pools exit-pool [flags]
# Example
Exit pool one with 1 OSMO and the respective amount of ATOM using myKeyringWallet.
imversed tx pools exit-pool --pool-id 1 --min-amounts-out 1000000uosmo --share-amount-in 1000000 --from myKeyringWallet
# Join Swap Extern Amount In
Note that the flags pool-id is required.
# Usage
imversed tx pools join-swap-extern-amount-in [token-in] [share-out-min-amount] [flags]
# Example
imversed tx pools join-swap-extern-amount-in 1000000uosmo 1000000 --pool-id 1 --from myKeyringWallet
# Exit Swap Extern Amount Out
Note that the flag pool-id is required.
# Usage
imversed tx pools exit-swap-extern-amount-out [token-out] [share-in-max-amount] [flags]
# Example
imversed tx pools exit-swap-extern-amount-out 1000000uosmo 1000000 --pool-id 1 --from myKeyringWallet
# Join Swap Share Amount Out
Note that the flag pool-id is required.
# Usage
imversed tx pools join-swap-share-amount-out [token-in-denom] [token-in-max-amount] [share-out-amount] [flags]
# Example
imversed tx pools join-swap-share-amount-out aimv 1000000 1000000 --pool-id 1 --from myKeyringWallet
# Exit Swap Share Amount In
Note that the flag pool-id is required.
# Usage
imversed tx pools exit-swap-share-amount-in [token-out-denom] [share-in-amount] [token-out-min-amount] [flags]
# Example
imversed tx pools exit-swap-share-amount-in aimv 1000000 1000000 --pool-id 1 --from myKeyringWallet
# Swap Exact Amount In
Swap an exact amount of tokens into a specific pool. Note that the flags swap-route-pool-ids and swap-route-denoms are required.
# Usage
imversed tx pools swap-exact-amount-in [token-in] [token-out-min-amount] [flags]
# Example
Swap 1 OSMO through pool 1 into at least 0.3 ATOM using MyKeyringWallet.
imversed tx pools swap-exact-amount-in 1000000uosmo 300000 --swap-route-pool-ids 1 --swap-route-denoms ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 --from MyKeyringWallet
# Swap Exact Amount Out
Swap an exact amount of tokens out of a specific pool. Note that the flags swap-route-pool-ids and swap-route-denoms are required.
# Usage
imversed tx pools swap-exact-amount-out [token-out] [token-out-max-amount] [flags]
# Example
Swap 1 ATOM through pool 1 into at most 2.5 OSMO using MyKeyringWallet.
imversed tx pools swap-exact-amount-out 1000000ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 250000 --swap-route-pool-ids 1 --swap-route-denoms aimv --from MyKeyringWallet