remove_liquidity
Call v290 â current #2Removes an entire liquidity position and claims accrued fees.
View calls on chainCall Workflow
This diagram shows the call execution flow: starting with remove_liquidity, passing through validation
(signature, nonce, mortality, fee payment), then pre-dispatch checks, followed by dispatch which emits events: LiquidityRemoved and modifies storage: Positions, Ticks, CurrentLiquidity, TickIndexBitmapWords, and finally post-dispatch where ExtrinsicSuccess is emitted and fees are settled.
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.
Click items to navigate. Pan and zoom to explore.
Used by: stakersdeveloperswallets
The Big Picture
Closes position entirely, returning assets plus accumulated fees.
Use Cases
- Exit position
- Claim accumulated fees
From Chain Metadata
Remove liquidity from a specific position. Parameters: origin: The origin of the transaction netuid: Subnet ID position_id: ID of the position to remove Emits `Event::LiquidityRemoved` on success
Input Parameters
| # | Name | Type | Description |
|---|---|---|---|
| 0 | hotkey | AccountId | hotkey: Account address (32 bytes, SS58-encoded) (hex -> SS58) |
| 1 | netuid | u16 NetUid | netuid: Subnet ID (u16, 0-65535) |
| 2 | position_id | PositionId | position_id: AMM position identifier |
Permissions
Origin
Unknown
Required Role
Permission data inferred from metadata. May be incomplete.
Requirements
- Position exists for caller
- Position ID is valid
Effects
Events Emitted
Storage Modified
Postconditions
- Position deleted
- TAO/Alpha returned
- Fees paid out
Side Effects
- Emits LiquidityRemoved event
- Updates tick state
Code Examples
// ----------------------------------------------------------------------
// HEADS UP: 1 arg below has a complex type with no usable default.
// Look for `undefined as any` and replace it with real value
// before running â the snippet compiles, but will fail at runtime as-is.
// ----------------------------------------------------------------------
import { createClient, Binary } from "polkadot-api";
import { getWsProvider } from "polkadot-api/ws";
import { sub } from "@polkadot-api/descriptors"; // generated by: npx papi add sub -w wss://entrypoint-finney.opentensor.ai:443
const client = createClient(getWsProvider("wss://entrypoint-finney.opentensor.ai:443"));
const api = client.getTypedApi(sub);
// Build remove_liquidity call (typed, named args)
const hotkey = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const netuid = 1;
const position_id = undefined as any /* PositionId â replace with real value */;
const tx = api.tx.Swap.remove_liquidity({
hotkey,
netuid,
position_id,
});On-Chain Activity
Usage Frequency
ââââââ Low 1Kâ10K extrinsics
Infrequent
#49 most used call
Success Rate Near-certain
Over 95% of submissions succeed
As of block 7,429,232
Runtime Info
View Source- Pallet Index
- 28
- Call Index
- 2
- First Version
- v290
- Current Version
- v411