add_liquidity

Call v290 → current #1

Adds liquidity to a subnet 's pool within a specified price range.

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: stakersdevelopersanalytics

The Big Picture

Users provide TAO/Alpha in price ranges to enable swaps and earn fees.

Use Cases

  • Earn swap fees
  • Provide concentrated liquidity

From Chain Metadata

Add liquidity to a specific price range for a subnet. Parameters: origin: The origin of the transaction netuid: Subnet ID tick_low: Lower bound of the price range tick_high: Upper bound of the price range liquidity: Amount of liquidity to add Emits `Event::LiquidityAdded` on success

Part of: Concentrated Liquidity

Input Parameters

#NameTypeDescription
0
hotkey
AccountId hotkey: Account address (32 bytes, SS58-encoded) (hex -> SS58)
1
netuid
u16 NetUidnetuid: Subnet ID (u16, 0-65535)
2
tick_low
TickIndex tick_low: Tick index (AMM) (price = 1.0001^tick)
3
tick_high
TickIndex tick_high: Tick index (AMM) (price = 1.0001^tick)
4
liquidity
u64 liquidity (u64)

Permissions

Origin
Unknown
Required Role

Permission data inferred from metadata. May be incomplete.

Requirements

  • V3 mode enabled
  • Sufficient TAO/Alpha balance
  • Valid tick range
  • Liquidity >= MinimumLiquidity

Effects

Events Emitted

Postconditions

  • Position created
  • Balances decreased
  • Pool liquidity increased

Side Effects

  • Emits LiquidityAdded event
  • Updates tick state

Code Examples

// ----------------------------------------------------------------------
// HEADS UP: 2 args below have a complex type with no usable default.
// Look for `undefined as any` and replace them with real values
// 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 add_liquidity call (typed, named args)
const hotkey = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const netuid = 1;
const tick_low = undefined as any /* TickIndex — replace with real value */;
const tick_high = undefined as any /* TickIndex — replace with real value */;
const liquidity = 1_000_000_000n;

const tx = api.tx.Swap.add_liquidity({
  hotkey,
  netuid,
  tick_low,
  tick_high,
  liquidity,
});

On-Chain Activity

Usage Frequency
●●●○○○ Moderate 10K–100K extrinsics

Occasional use

#42 most used call

Success Rate Reliable

80–95% of submissions succeed

As of block 7,429,232

Runtime Info

View Source
Pallet Index
28
Call Index
1
First Version
v290
Current Version
v411