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_allowanceso the pool can transfer them from your wallet. - Native LP tokens (
factory/<pool address>/astroport/share) are attached towithdraw_liquidityas funds. - CW20 LP tokens (a
terra1.../neutron1...contract) are sent to the pool with a CW20sendthat embedswithdraw_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}
| Parameter | Type | Description |
|---|---|---|
assets | Vec<Asset> | The assets and amounts to deposit |
slippage_tolerance | Option<Decimal> | How far the deposit ratio may differ from the pool's ratio (default 0.005, max 0.5) |
auto_stake | Option<bool> | Stake the minted LP tokens in the Incentives contract in the same transaction |
receiver | Option<String> | Recipient of the LP tokens, if not the sender |
min_lp_to_receive | Option<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:
_27const pool = "terra1v3lqxl0eyte9x3nhdgcj8hwvjq76aupnnzz0yll8mxs5cckc29pqvg2scu";_27const usdc = "ibc/2C962DAB9F57FE0921435426AE75196009FAA1981BF86991203C8411F8980FDB";_27_27const lunaAmount = "25812000";_27const usdcAmount = "1000000";_27_27const 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}
_10const lpDenom = "factory/neutron1...pool/astroport/share";_10_10await 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}
_16import { toBinary } from "@cosmjs/cosmwasm-stargate";_16_16const lpToken = "terra1s275y73lfupag0g03nglxaedfnsw5z4m5zc9wk66guy503zuw5ss889tlx";_16_16await 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_liquiditypays your share of every asset the pool holds, rounded down, and burns your LP tokens.min_assets_to_receiveis enforced.- One-sided withdrawals (naming
assets), deposits and swaps are refused. - Only the
pair,pool,shareandsimulate_withdrawqueries work. - LP tokens staked in Incentives must be unstaked first.
| Pool | Address | LP token |
|---|---|---|
| dATOM/USDC | neutron1nfns3ck2ykrs0fknckrzd9728cyf77devuzernhwcwrdxw7ssk2s3tjf8r | native |
| NTRN/USDC | neutron18c8qejysp4hgcfuxdpj4wf29mevzwllz5yh8uayjxamwtrs0n9fshq9vtv | native |
| dATOM/ATOM | neutron1yem82r0wf837lfkwvcu2zxlyds5qrzwkz8alvmg0apyrjthk64gqeq2e98 | native |
| USDC/DYDX | neutron1j4xpv03fw664mvntlhqnzp5hjqk2nfw00vrgx9qlq97rxc9fu3lqvmszl2 | CW20 |
| wstETH/WETH | neutron1yw0a7nxa8jdgzmdsme4gwxhj76n44z305qgwrzvlfavgna9epcys3k9m2f | CW20 |
| axlUSDC/USDC | neutron1ns2tcunrlrk5yk62fpl74ycazanceyfmmq7dlj6sq8n0rnkuvk7szstkyx | CW20 |
Withdraw from them exactly as above: attach native LP tokens to withdraw_liquidity {}, or send CW20 LP tokens with {"withdraw_liquidity":{}}.