remove_liquidity
Burn LP shares to withdraw your proportional share of the pool’s base and quote reserves.
Supports slippage guards via min_base_amount
and min_quote_amount
. Emits a LiquidityRemovedEvent
.
Arguments
#[derive(AnchorSerialize, AnchorDeserialize, Clone)]
pub struct RemoveLiquidityArgs {
pub lp_amount: u64, // LP tokens to burn
pub min_base_amount: u64, // minimum base you must receive
pub min_quote_amount: u64, // minimum quote you must receive
}
Required Accounts
0
config
["global_config"]
(PDA)
1
user
✅
2
base_mint
Owner == SPL Token program
3
quote_mint
Owner == SPL Token program
4
pool
✅
["pool", base_mint, quote_mint]
, bump = pool.bump
; pool.state == 1
; pool.base_mint == base_mint
; pool.quote_mint == quote_mint
5
lp_mint
✅
["lp_mint", pool]
; lp_mint == pool.lp_mint
6
base_vault
✅
["vault", pool, base_mint]
; key == pool.base_vault
; owner == pool
; mint == base_mint
7
quote_vault
✅
["vault", pool, quote_mint]
; key == pool.quote_vault
; owner == pool
; mint == quote_mint
8
user_base_account
✅
mint == base_mint
; owner == user
9
user_quote_account
✅
mint == quote_mint
; owner == user
10
user_lp_account
✅
mint == lp_mint
; owner == user
; amount ≥ args.lp_amount
11
token_program
Must equal SPL Token program ID
12
system_program
Event
#[event]
pub struct LiquidityRemovedEvent {
pub pool: Pubkey,
pub provider: Pubkey,
pub lp_tokens_burned: u64,
pub base_amount: u64,
pub quote_amount: u64,
pub total_lp_supply: u64,
pub base_reserve_after: u64,
pub quote_reserve_after: u64,
pub timestamp: i64,
}
Last updated