Liquidity
Control LP tokens or position NFTs and recover their underlying assets.
On this page
Return shape
Every account snapshot includes block, holdings and liabilities. Use actual venue data, with owners bound to the Credit Account. Optional public actions must be declared in the definition; a schema-supported capability does not mean every integration offers it.
{
block: context.block, holdings: [], liabilities: [],
positions: [{
position_id: "15", market_id: "MON-USDC-LP", owner: context.account,
assets: [
{ asset: native_mon, amount: 1_000_000_000_000_000_000n },
{ asset: usdc, amount: 2_000_000n },
],
liability: 0n, recoverable_value: 3_800_000n,
liquidity: 1_000n, rewards: [],
}],
}For position NFTs, verify account ownership and any staking custody. Underlying asset amounts, fees and rewards must be recoverable under the admitted exit rules.
Capabilities
| Capability | Parameters | Purpose |
|---|---|---|
| add_liquidity | market_id, amounts_in: [{ asset_id, amount_in }], min_liquidity_out, optional tick_lower + tick_upper | Add protected liquidity. |
| remove_liquidity | position_id, liquidity_in, min_amounts_out: [{ asset_id, min_amount_out }] | Remove with minimum underlying receipts. |
| stake_lp / unstake_lp | position_id, optional amount | Move the LP position through approved staking custody. |
| claim_rewards / collect_fees | position_id | Collect approved assets into the account. |
Asset IDs must be unique. Concentrated-liquidity ticks must be supplied together and tick_lower must be less than tick_upper.
Add liquidity
termbook.open({
action: {
"use_case": "liquidity",
"capability": "add_liquidity",
"params": {
"market_id": "MON-USDC-LP",
"amounts_in": [
{
"asset_id": "MON",
"amount_in": 1000000000000000000n
},
{
"asset_id": "USDC",
"amount_in": 2000000n
}
],
"min_liquidity_out": 1000n
}
},
});Exit requirements
Unstake if necessary, remove liquidity, collect fees and rewards, then convert holdings into the settlement asset. The reader must value the actual underlying inventory and exclude inaccessible or unpriced rewards.