Skip to main content

Providing/Withdrawing Liquidity

Overview​

You add liquidity to a pool with provide_liquidity and receive LP tokens for your share. You get your share of the pool back, including the swap fees it earned, by returning the LP tokens with withdraw_liquidity. Swap fees are not paid out separately: the liquidity providers' part of each fee stays in the pool and raises the value of every LP token.

How you send tokens depends on their type:

  • Native tokens (uluna, untrn, IBC and tokenfactory denoms) are attached to the message as funds.
  • CW20 tokens must first be approved with increase_allowance so the pool can transfer them from your wallet.
  • Native LP tokens (factory/<pool address>/astroport/share) are attached to withdraw_liquidity as funds.
  • CW20 LP tokens (a terra1.../neutron1... contract) are sent to the pool with a CW20 send that embeds withdraw_liquidity.

The pool's pair query tells you its assets and its liquidity_token. The examples use the Terra LUNA/USDC pool terra1v3lqxl0eyte9x3nhdgcj8hwvjq76aupnnzz0yll8mxs5cckc29pqvg2scu, whose LP token is the CW20 terra1s275y73lfupag0g03nglxaedfnsw5z4m5zc9wk66guy503zuw5ss889tlx. See Swapping for the CosmJS client setup.

Providing Liquidity​

increase_allowance (CW20 assets only)​

If one of the assets is a CW20 token, allow the pool to spend it first. Execute this on the CW20 token contract:


_6
{
_6
"increase_allowance": {
_6
"spender": "terra1...pool",
_6
"amount": "1000000"
_6
}
_6
}

Approve only what you are about to deposit. Skip this step for native assets.

provide_liquidity​

Execute on the pool. assets lists each asset and the amount to deposit, in base units.


_24
{
_24
"provide_liquidity": {
_24
"assets": [
_24
{
_24
"info": {
_24
"native_token": {
_24
"denom": "uluna"
_24
}
_24
},
_24
"amount": "25812000"
_24
},
_24
{
_24
"info": {
_24
"native_token": {
_24
"denom": "ibc/2C962DAB9F57FE0921435426AE75196009FAA1981BF86991203C8411F8980FDB"
_24
}
_24
},
_24
"amount": "1000000"
_24
}
_24
],
_24
"slippage_tolerance": "0.01",
_24
"auto_stake": false
_24
}
_24
}

ParameterTypeDescription
assetsVec<Asset>The assets and amounts to deposit
slippage_toleranceOption<Decimal>How far the deposit ratio may differ from the pool's ratio (default 0.005, max 0.5)
auto_stakeOption<bool>Stake the minted LP tokens in the Incentives contract in the same transaction
receiverOption<String>Recipient of the LP tokens, if not the sender
min_lp_to_receiveOption<Uint128>Fail if fewer LP tokens would be minted. Supported by current pool versions

Attach every native asset in assets as funds, with exactly the amounts in the message:


_27
const pool = "terra1v3lqxl0eyte9x3nhdgcj8hwvjq76aupnnzz0yll8mxs5cckc29pqvg2scu";
_27
const usdc = "ibc/2C962DAB9F57FE0921435426AE75196009FAA1981BF86991203C8411F8980FDB";
_27
_27
const lunaAmount = "25812000";
_27
const usdcAmount = "1000000";
_27
_27
const result = await signingClient.execute(
_27
sender,
_27
pool,
_27
{
_27
provide_liquidity: {
_27
assets: [
_27
{ info: { native_token: { denom: "uluna" } }, amount: lunaAmount },
_27
{ info: { native_token: { denom: usdc } }, amount: usdcAmount },
_27
],
_27
slippage_tolerance: "0.01",
_27
auto_stake: false,
_27
},
_27
},
_27
"auto",
_27
"",
_27
// funds: native assets, sorted by denom
_27
[
_27
{ denom: usdc, amount: usdcAmount },
_27
{ denom: "uluna", amount: lunaAmount },
_27
]
_27
);

Cosmos SDK transactions expect the funds list sorted by denom (ibc/... sorts before uluna).

Choosing the Amounts​

Deposit in the pool's current ratio. Read the balances with the pool query:


_3
{
_3
"pool": {}
_3
}


_13
{
_13
"assets": [
_13
{
_13
"info": { "native_token": { "denom": "uluna" } },
_13
"amount": "189487604110"
_13
},
_13
{
_13
"info": { "native_token": { "denom": "ibc/2C962DAB9F57FE0921435426AE75196009FAA1981BF86991203C8411F8980FDB" } },
_13
"amount": "7341290743"
_13
}
_13
],
_13
"total_share": "34453629166"
_13
}

For 1 USDC (1000000), the matching LUNA amount is 1000000 * 189487604110 / 7341290743 = 25811210 (rounded down), so a deposit of about 25.81 LUNA. In constant product pools, a deposit whose ratio differs from the pool's by more than slippage_tolerance fails. Stableswap and PCL pools accept unbalanced deposits but charge a fee on the imbalanced part. Current pool versions also answer simulate_provide with the LP amount a deposit would mint.

The first deposit into an empty pool sets its price, so make it at the market price. Current pool versions keep a small amount of LP tokens from the first deposit locked in the pool.

Withdrawing Liquidity​

withdraw_liquidity burns your LP tokens and returns your share of every asset in the pool. Optional min_assets_to_receive makes the withdrawal fail if you would receive less of any asset.

To see what you would get back, query share with an LP amount (all pool versions) or simulate_withdraw (current versions):


_5
{
_5
"share": {
_5
"amount": "1000000"
_5
}
_5
}

If your LP tokens are staked in Incentives, unstake them first: see Staking/Unstaking LP Tokens.

Native LP Tokens​

Attach the LP tokens to withdraw_liquidity on the pool:


_3
{
_3
"withdraw_liquidity": {}
_3
}


_10
const lpDenom = "factory/neutron1...pool/astroport/share";
_10
_10
await signingClient.execute(
_10
sender,
_10
"neutron1...pool",
_10
{ withdraw_liquidity: {} },
_10
"auto",
_10
"",
_10
[{ denom: lpDenom, amount: "1000000" }]
_10
);

CW20 LP Tokens​

Send the LP tokens to the pool with a send on the LP token contract. The msg is the base64 encoding of {"withdraw_liquidity":{}}.


_7
{
_7
"send": {
_7
"contract": "terra1v3lqxl0eyte9x3nhdgcj8hwvjq76aupnnzz0yll8mxs5cckc29pqvg2scu",
_7
"amount": "1000000",
_7
"msg": "eyJ3aXRoZHJhd19saXF1aWRpdHkiOnt9fQ=="
_7
}
_7
}


_16
import { toBinary } from "@cosmjs/cosmwasm-stargate";
_16
_16
const lpToken = "terra1s275y73lfupag0g03nglxaedfnsw5z4m5zc9wk66guy503zuw5ss889tlx";
_16
_16
await signingClient.execute(
_16
sender,
_16
lpToken, // the LP token contract
_16
{
_16
send: {
_16
contract: pool,
_16
amount: "1000000",
_16
msg: toBinary({ withdraw_liquidity: {} }),
_16
},
_16
},
_16
"auto"
_16
);

Withdraw-only (Exit-only) Pools​

Six Neutron pools drained on 2026-09-22 were refilled with the returned assets and migrated to astroport-pair-exit-only. They accept balanced withdrawals only:

  • withdraw_liquidity pays your share of every asset the pool holds, rounded down, and burns your LP tokens. min_assets_to_receive is enforced.
  • One-sided withdrawals (naming assets), deposits and swaps are refused.
  • Only the pair, pool, share and simulate_withdraw queries work.
  • LP tokens staked in Incentives must be unstaked first.
PoolAddressLP token
dATOM/USDCneutron1nfns3ck2ykrs0fknckrzd9728cyf77devuzernhwcwrdxw7ssk2s3tjf8rnative
NTRN/USDCneutron18c8qejysp4hgcfuxdpj4wf29mevzwllz5yh8uayjxamwtrs0n9fshq9vtvnative
dATOM/ATOMneutron1yem82r0wf837lfkwvcu2zxlyds5qrzwkz8alvmg0apyrjthk64gqeq2e98native
USDC/DYDXneutron1j4xpv03fw664mvntlhqnzp5hjqk2nfw00vrgx9qlq97rxc9fu3lqvmszl2CW20
wstETH/WETHneutron1yw0a7nxa8jdgzmdsme4gwxhj76n44z305qgwrzvlfavgna9epcys3k9m2fCW20
axlUSDC/USDCneutron1ns2tcunrlrk5yk62fpl74ycazanceyfmmq7dlj6sq8n0rnkuvk7szstkyxCW20

Withdraw from them exactly as above: attach native LP tokens to withdraw_liquidity {}, or send CW20 LP tokens with {"withdraw_liquidity":{}}.