Guides
Basket trading for governance
How the root key enables, freezes, and tunes validator basket trading — what each knob bounds, the worst-case loss formula, how to read a fund's trading status, and the playbook for a suspected rogue trader key.
This guide is for whoever holds the chain's root (sudo) key or sits on its
multisig. It covers the AdminUtils calls that control
basket trading (introduced in runtime v461),
what each one bounds, and what to do when a validator's trader key looks
compromised. The staker view is in
Basket trading for stakers;
the original on-chain surface is in the v461 release notes.
All of these calls are root-only. Submit them as the sudo key with
btcli call ... --sudo, or through the sudo multisig with --multisig
(see "Any call, including sudo" in Multisig).
The --dry-run tx-global shows the composed call and fee without submitting.
The basket-trading-status read and the basket error descriptions need
the SDK release that ships with runtime v461. Trading is live on
testnet and not on mainnet yet: install the pinned release candidate
and add -n test to the commands below (11.3.0rc46 shipped a broken
btcli; rc47 fixes it). Once the runtime reaches mainnet, install the
stable release that ships with it (11.3.0 or later).
pip install "bittensor==11.3.0rc47"The knobs
| Call | Storage it writes | Default | Bounds |
|---|---|---|---|
sudo_set_basket_trading_enabled(enabled) | BasketTradingEnabled | false at genesis; the spec 468 upgrade sets it true once | Whether any fund may trade at all. |
sudo_set_basket_trading_frozen(hotkey, frozen) | BasketTradingFrozen[hotkey] | not frozen | Whether one fund may trade. |
sudo_set_basket_daily_turnover_cap(cap) | BasketDailyTurnoverCap | 6553 (10%) | TAO a fund can push through per burst and per refill period. |
sudo_set_basket_trade_max_slippage_bps(bps) | BasketTradeMaxSlippageBps | 200 (2%) | Per-leg band from the configured price reference; 1..=10000. |
sudo_set_basket_trade_refill_blocks(blocks) | BasketTradeRefillBlocks | 7200 | Blocks to refill the turnover bucket and decay destination flow; zero rejected. |
sudo_set_basket_trade_price_reference(reference) | BasketTradePriceReference | StrictestEmaAndSpot | Legacy EMA/spot band, or governance-selected SpotOnly. |
sudo_set_basket_liquidity_cap(cap) | BasketLiquidityCap | 6553 (10%) | How much of any one pool a fund may hold. |
sudo_set_basket_claim_dust(row_cap_rao, row_bps, slice_rao, forfeit_cap_rao) | BasketClaimRowDustCapTao, BasketClaimRowDustBps, BasketClaimSliceDustTao, BasketClaimForfeitCapTao | 1_000_000_000 (1 TAO), 10 (0.1%), 100_000 (0.0001 TAO), 10_000_000 (0.01 TAO) | Root claims do not sell a fund row worth less than min(row_cap, row_bps × anchored NAV), nor a row where the claimant's own slice is worth less than slice — but only if that slice is worth at most forfeit_cap — all at the anchored (fast-EMA-capped) mark, which decides dust only; skipped slices stay in the fund for the remaining holders. Zero turns the respective skip off; a zero cap turns every skip off. |
cap values are u16-normalized: 65535 is 100%, 6553 is 10%, 16383 is
25%. Zero is rejected with ValueNotInBounds (the dust floors accept zero,
which turns a skip off). The band accepts 1..=10000 basis points, and the
refill period must be nonzero. Each call emits an event (BasketTradingToggled,
BasketTradingFrozenSet, BasketDailyTurnoverCapSet, BasketLiquidityCapSet,
BasketTradeMaxSlippageBpsSet, BasketTradeRefillBlocksSet,
BasketTradePriceReferenceSet, BasketClaimDustSet).
Enable trading
Trading launches off. Turning it on is a one-line network-wide switch:
btcli call AdminUtils.sudo_set_basket_trading_enabled --args '{"enabled": true}' \
--sudo -w sudo_keyWhile it is off, every swap_basket fails with BasketTradingDisabled.
Deposits, claims, and dividend accrual are not affected by this switch in
either direction.
Freeze one fund
btcli call AdminUtils.sudo_set_basket_trading_frozen \
--args '{"hotkey": "5F...validator", "frozen": true}' --sudo -w sudo_keyA frozen fund keeps accruing dividends, accepting deposits, and paying
claims; only swap_basket is refused, with BasketTradingFrozen. The
freeze follows the fund if the validator swaps its hotkey. Unfreeze with
"frozen": false.
Tune the turnover cap
BasketDailyTurnoverCap is the capacity of each fund's turnover bucket
as a share of its NAV. Every trade takes the TAO through its middle out of
the bucket; the bucket refills at capacity / BasketTradeRefillBlocks per
block, so it is full again after one configured period (one day by default),
and its level is clamped to one capacity.
The cap therefore bounds two things at once: the most a fund can move in a
burst (one capacity, at any instant) and the most it can move per day
sustained (about one capacity).
btcli call AdminUtils.sudo_set_basket_daily_turnover_cap --args '{"cap": 6553}' \
--sudo -w sudo_keyA change applies to every fund's next trade: the bucket's capacity is recomputed from the new cap and current NAV, and the stored level is clamped down if it now exceeds it.
Tune the trade band, reference, and refill period
The storage defaults take effect with the runtime upgrade and preserve existing trading behavior: a 200-bps (2%) band measured from the strictest of slow EMA, fast EMA, and spot, and a 7200-block refill period. No sudo call is required to retain them. To opt into a 5% band measured from spot only, make both calls in this order:
btcli call AdminUtils.sudo_set_basket_trade_max_slippage_bps \
--args '{"bps": 500}' --sudo -w sudo_key
btcli call AdminUtils.sudo_set_basket_trade_price_reference \
--args '{"reference": "SpotOnly"}' --sudo -w sudo_keyStrictestEmaAndSpot is the default reference: sell floor from the maximum of
slow EMA, fast EMA, and spot; buy ceiling from their minimum. That mode requires
both moving prices. Spot-only mode does not. It removes the EMA anchors, so a
manipulated spot price within the band can be traded against; selecting it is a
deliberate governance decision rather than an upgrade default.
To change the refill period independently:
btcli call AdminUtils.sudo_set_basket_trade_refill_blocks \
--args '{"blocks": 7200}' --sudo -w sudo_keyTune the concentration cap
The concentration cap is not changed by the trade-band runtime upgrade. To
raise it from an on-chain value of 7865 / 65535 (about 12%) to approximately
15%, use 9830, because 9830 / 65535 ≈ 15.00%:
btcli call AdminUtils.sudo_set_basket_concentration_cap \
--args '{"cap": 9830}' --sudo -w sudo_keyIn polkadot.js Apps, use Developer → Extrinsics → sudo.sudo and select
adminUtils.sudoSetBasketConcentrationCap(9830) as the wrapped call.
Tune the liquidity cap
BasketLiquidityCap is the largest share of a subnet's alpha reserve a fund
may hold after a buy. It is the rule that bounds the thin-pool drain:
buying a small pool in band-sized slices while a counterparty sells alpha
back between slices passes the price band, the turnover budget, and the 1/16
concentration cap, yet the fund's NAV falls by roughly the TAO it spends,
because realizable value is capped by the pool's TAO reserve no matter how
much of the pool the fund owns.
btcli call AdminUtils.sudo_set_basket_liquidity_cap --args '{"cap": 6553}' \
--sudo -w sudo_keyRaise it if funds legitimately need larger positions in mid-depth pools (today's largest funds, about 12,500 τ, are barely constrained: 10% of a median mainnet pool is about 700 τ, about one 1/16 slice). Lower it to tighten the per-pool value at risk.
What the knobs bound
Think of a stolen trader key with a willing counterparty. With liquidity cap
L and turnover cap C (both as fractions), and the configurable price band:
- Per pool. The most a drain can extract from a pool with TAO reserve
Ris aboutR × L² / (1 + L). AtL = 10%that is about 0.9% ofR, or about 9% of the TAO the fund spent on that pool. - Per unit of turnover. About
L / (1 + L)(drain) plus up to twice the configured band for the two legs, plus AMM fees and each slice's price impact. At the 10% liquidity cap and default 2% band, the first two terms alone are about 13% of the TAO traded. If governance selects a 5% band, they are about 19% instead. - Per burst and per refill period. The bucket holds one capacity, so the
most that can be traded at any instant is
Cof NAV, and aboutCper configured refill period sustained. The 7200-block default corresponds to about one capacity per day. - What the reference changes. Spot-only mode re-anchors each leg to the
spot left by the previous leg, so the legacy fast-EMA protection against
chained same-block legs does not apply. A multi-slice manipulation still pays
AMM fees and price impact on every slice, and the liquidity and turnover caps
still bound accumulation and throughput.
StrictestEmaAndSpotretains the legacy moving-price constraints and their missing-EMA requirements. The budget and the concentration cap are measured against a guarded NAV (each holding at the lower of its realizable value and its slow-moving-price value), so a same-block pump of a held pool cannot enlarge the bucket or admit an oversize buy.
Lowering L shrinks the first term almost quadratically; lowering C
shrinks the daily total linearly. These are bounds for a stolen key, not
costs of honest trading, which pays only AMM fees and its own price impact.
Reading a fund's status
basket-trading-status shows the gates
and the bucket for one validator, as a trade at the current block would see
them:
btcli query basket-trading-status --hotkey 5F...validator -n test| Field | Meaning |
|---|---|
enabled | The network-wide gate. |
frozen | Whether this fund is frozen. |
budget_tao | Bucket capacity: BasketDailyTurnoverCap of current NAV. |
remaining_tao | What the bucket holds now — the largest trade this block would accept. |
used_tao | budget_tao − remaining_tao. |
refill_per_block_tao | budget_tao / refill_blocks. |
refill_blocks | Blocks for an empty bucket to fill (BasketTradeRefillBlocks, 7200 by default). |
The raw storage is readable too: BasketTradeBucket[hotkey] is
(tao_available, last_refill_block), and a missing row means a full bucket.
Holdings are in validator-basket; the
fund's trades are BasketSwapped events (hotkey, origin_netuid,
destination_netuid, alpha_sold, tao_mid, alpha_bought).
import bittensor as bt
async with bt.Subtensor("finney") as client:
status = await client.read("basket_trading_status", hotkey_ss58=HOTKEY)
enabled = await client.query(bt.storage.SubtensorModule.BasketTradingEnabled)
bucket = await client.query(bt.storage.SubtensorModule.BasketTradeBucket, [HOTKEY])
events = await client.query(bt.storage.System.Events, block=BLOCK) # look for BasketSwappedPlaybook: a suspected rogue trader key
Freeze first, investigate second. A freeze costs the validator nothing but the ability to trade, and it stops the clock on every bound above.
- Freeze the hotkey.
sudo_set_basket_trading_frozen(hotkey, true). Confirm withbasket-trading-status(frozen: True). - Read what happened. Pull the fund's
BasketSwappedevents for the window in question and its holdings before and after (validator-basket,validator-basket-summary). Signs of a drain: many small buys into one thin subnet, each near the band, with the fund's holding on that subnet approachingBasketLiquidityCapof the pool's alpha reserve. - Check the scope. If several funds show the same pattern, or the
pattern is a new one the caps do not stop, flip the network-wide switch
off:
sudo_set_basket_trading_enabled(false). Then tightenBasketLiquidityCaporBasketDailyTurnoverCapbefore turning it back on. - Tell the validator. The fix on their side is to revoke the
BasketTradingproxy from the coldkey (btcli proxy remove ... --proxy-type BasketTrading) and grant a fresh trader key. The coldkey itself was never at risk from the trader key: aBasketTradingdelegate can only callswap_basket. - Unfreeze once the grant is rotated:
sudo_set_basket_trading_frozen(hotkey, false).
Stakers who dislike what they see do not need governance: they can move their root stake to another validator at any time (Basket trading for stakers).
Reference
- Guides: Basket trading, Basket trading for stakers
- Calls:
AdminUtils.sudo_set_basket_trading_enabled(106),sudo_set_basket_trading_frozen(107),sudo_set_basket_daily_turnover_cap(108),sudo_set_basket_liquidity_cap(109),sudo_set_basket_concentration_cap(105),sudo_set_basket_trade_max_slippage_bps(122),sudo_set_basket_trade_refill_blocks(123),sudo_set_basket_trade_price_reference(124) - Release: v461 — Basket Trading