add_stake_limit

Call v233 → current #88

Adds stake with a price limit for slippage protection.

View calls on chain

Click items to navigate. Pan and zoom to explore.

Used by: stakersdelegatorswalletsexchanges

The Big Picture

Staking converts TAO to Alpha at the current exchange rate. For large stakes, this conversion can move the price against you (slippage). add_stake_limit lets you set a maximum price - your transaction only executes if you get that rate or better. This is essential for large stakeholders who can't afford to pay inflated rates.

Why This Matters

If you're staking 10,000 TAO, even 1% slippage costs you 100 TAO. The limit price protects you - if the rate moves too far, your transaction fails instead of executing at a bad price. You keep your TAO and can try again later.

Example Scenario

You want to stake 1000 TAO to subnet 3, but only if Alpha is 1.0 or better (1 TAO = 1 Alpha). Call add_stake_limit(hotkey, netuid=3, amount=1000 TAO, limit_price=1.0, allow_partial=false). If Alpha rate is 0.98, you get 1020 Alpha (better than limit). If rate is 1.05 (worse), transaction fails and your TAO stays liquid.

Common Questions

What's allow_partial for?
If true, you'll get as much Alpha as possible at your limit price, even if it's less than the full amount. If false, it's all-or-nothing.
How do I know what limit price to set?
Check current Alpha price, add a buffer for acceptable slippage. If Alpha is 1.0 and you accept 2% slippage, set limit_price=1.02.
Is the limit checked at submission or execution?
At execution. Price can change between submission and inclusion in a block. Your limit protects you from changes during that window.

Use Cases

  • Stake large amounts without excessive slippage
  • Protect against front-running or price manipulation
  • Execute limit orders for staking operations
  • DCA staking with price protection

From Chain Metadata

Adds stake to a hotkey on a subnet with a price limit. This extrinsic allows to specify the limit price for alpha token at which or better (lower) the staking should execute. In case if slippage occurs and the price shall move beyond the limit price, the staking order may execute only partially or not execute at all.

Input Parameters

#NameTypeDescription
0
hotkey
AccountId Hot wallet address (active operations) (hex -> SS58)
1
netuid
u16 Subnet/network identifier (0-65535)
2
amount_staked
u64 amount_staked (u64) (RAO -> TAO (/ 10^9))
3
limit_price
u64 limit_price (u64) (RAO -> TAO (/ 10^9))
4
allow_partial
bool allow_partial (bool)

Permissions

Origin
Signed
Required Role
Authorization Checks
  • Coldkey must be associated with the target hotkey

Requirements

  • Coldkey has sufficient balance
  • Hotkey is registered on subnet
  • Current price meets limit requirement

Effects

Events Emitted

Postconditions

  • Stake added at price <= limit_price
  • May partially fill if allow_partial is true

Side Effects

  • Fill-or-kill if allow_partial is false

Possible Errors

Code Examples

import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";

const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });

// Build add_stake_limit call
const hotkey = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
const netuid = 1;
const amount_staked = 1_000_000_000n;
const limit_price = 0;
const allow_partial = true;

const call = api.tx[stringCamelCase("SubtensorModule")][stringCamelCase("add_stake_limit")](
  hotkey,
  netuid,
  amount_staked,
  limit_price,
  allow_partial
);

On-Chain Activity

Usage Frequency
●●●●●○ Core 1M–10M extrinsics

Primary protocol calls

#13 most used call

Success Rate Reliable

80–95% of submissions succeed

As of block 7,429,232

Runtime Info

View Source
Pallet Index
7
Call Index
88
First Version
v233
Current Version
v393