Transactions

add-stake-limit

Stake TAO with a limit price (slippage protection).

View as Markdown

Same as add_stake except the TAO-to-alpha swap only executes while the pool price stays within the limit. With allow_partial the call stakes as much as fits under the limit and leaves the rest in the free balance; without it the whole call fails once the limit would be breached. Like add_stake, the amount must be at least the chain minimum of 0.002 TAO plus the swap fee (AmountTooLow). Prefer this over plain add_stake for large amounts or thin pools, where the swap itself moves the price.

SignerOriginPalletWraps
coldkeysigned account (pallet role may apply)SubtensorModuleSubtensorModule.add_stake_limit

Parameters

ParameterTypeRequiredDescription
hotkey_ss58stringyesHotkey the stake is added to (the validator you are backing).
netuidintegeryesSubnet the stake lives on (netuid 0 is the root network).
amount_taonumber | "all"yesHow much of the coldkey's free balance to stake.
limit_price_raointegeryesWorst pool price you will accept for the swap. The call fails (or fills partially when allow-partial is set) instead of executing beyond this price.
allow_partialbooleannoExecute whatever portion fits within the limit price and drop the remainder, instead of failing the whole call when the limit would be breached.

Address parameters (--hotkey, --coldkey, --dest, ...) accept a raw ss58 address, an address-book or proxy-book name, or a local wallet/hotkey name.

CLI

Preview with --dry-run (shows fee, effects, and policy result without submitting), then submit:

btcli tx add-stake-limit \
  --hotkey <ss58|name> \
  --netuid <int> \
  --amount-tao <amount|all> \
  --limit-price-rao <int> --dry-run
btcli tx add-stake-limit \
  --hotkey <ss58|name> \
  --netuid <int> \
  --amount-tao <amount|all> \
  --limit-price-rao <int> -w my_coldkey

Python

import bittensor as bt
from bittensor.wallet import Wallet

wallet = Wallet(name="my_coldkey", hotkey="my_hotkey")
intent = bt.AddStakeLimit(hotkey_ss58="5F...", netuid=1, amount_tao=1.0, limit_price_rao=0)

sub = bt.Subtensor()
plan = sub.plan(intent, wallet)   # fee, effects, policy — no submission
result = sub.execute(intent, wallet)
if not result.success:
    print(result.error.code, result.error.remediation)

(bt.Subtensor is also the async client — async with bt.Subtensor() as client: — see The client.) Or build the intent by op name, as an agent would:

result = sub.execute_tool("add_stake_limit", {...}, wallet)

On-chain implementation

SubtensorModule.add_stake_limitpallets/subtensor/src/macros/dispatches.rs#L1393:

#[pallet::call_index(88)]
#[pallet::weight(<T as crate::pallet::Config>::WeightInfo::add_stake_limit())]
pub fn add_stake_limit(
    origin: OriginFor<T>,
    hotkey: T::AccountId,
    netuid: NetUid,
    amount_staked: TaoBalance,
    limit_price: TaoBalance,
    allow_partial: bool,
) -> DispatchResult {
    Self::do_add_stake_limit(
        origin,
        hotkey,
        netuid,
        amount_staked,
        limit_price,
        allow_partial,
    )
    .map(|_| ())
}

Delegates to do_add_stake_limit.

Every file is browsable under /code exactly as built into the runtime, or as plain text under /code/raw/<path> (index: /code/index.json).