Skip to content

Torii Wallet flags and environment#

Names only. Values live in the process environment of the host that needs them. Never paste a value into a doc, a chat or a commit.

Wallet (API host)#

NameWhat it switches
TW_DOOR_ENABLEDDefault off. The one switch for the bot door: GET /torii/door, GET /torii/skill.md, GET /torii/mcp-tools and the mandate_* tools on /mcp?profile=full. Off: the three routes answer 404 like a missing path, the tools are not listed and a call to one is refused as not available. On (1, true, yes, on): all open. Read on every request, so it needs a restart of the API process, not a code change. The owner routes under /torii/mandates are not behind it
TW_MANDATE_FACTORY_ADDRESSThe vault factory. While unset, create-call answers configured: false and no vault exists
TW_USDC_ADDRESSUSDC address when it is not in deployments/base-sepolia.json. The deposit watcher falls back to the built-in Base Sepolia USDC (with a logged warning) when neither exists
TW_RPC_URLThe RPC the chain reader and receipt checks use
TW_BEST_WAY_INJSON {"chain","asset"} that fills a missing destination in deposit routes
TW_BUDGET_ENFORCEDefault off. On: a paid read over the agent's daily Cherry budget is refused (mandate_budget_exceeded)
TW_ALERTS_DRY_RUNDefault on (1): the alerts worker counts and sends nothing
TW_DEPOSIT_WATCH_DRY_RUNThe deposit watcher's dry run
TW_VAULT_POLL_DRY_RUN, TW_VAULT_POLL_SEC, TW_VAULT_POLL_MAXThe per-mandate vault poller (nw_tw_vault_poll). Dry run is on by default
TW_VAULT_EVENTS_DRY_RUN, TW_VAULT_EVENTS_SEC, TW_VAULT_EVENTS_MAX_BLOCKS_PER_TICK (20000; old name TW_VAULT_EVENTS_MAX_BLOCKS), TW_VAULT_EVENTS_MAX_SPAN (2000 blocks per eth_getLogs, halved to 100 on 413 / -32005), TW_VAULT_EVENTS_START_BLOCKThe factory-wide event sweep (torii_vault_events), run on Chuncheon, not on Render. Dry run (1) is the default: it reads and counts, writes nothing and does not move its stored block
TW_WORKER_SCHEMA_ENSUREDefault off. The four Chuncheon workers send no DDL; a missing table makes them log one line and exit 2. 1 runs the look-first ensure at start (testing only). Apply the schema as a job: python -m svc.common.schema_ensure torii_agent_wallet
TW_WORKER_STATEMENT_TIMEOUT_MS, TW_WORKER_LOCK_TIMEOUT_MSWorker DB session limits (20000, 5000). A tick that hits one is skipped, exit 0
TW_APPROVAL_ENABLEDDefault on (1). Clause 6: a relayed execute-call above the mandate's approval amount is held until the owner decides. Off: nothing is held and clause 6 reads stored_pending
TW_APPROVAL_TTL_HOURS, TW_APPROVAL_MAX_OPENHow long a pending or approved approval item stays good (24), and how many pending items one mandate may hold (10). Past the limit the agent is refused with rate_limited
TW_STOP_LINE_DRY_RUN, TW_STOP_LINE_SEC, TW_STOP_LINE_MAXThe stop-line keeper (python -m svc.worker.torii_stop_line --once, run on Chuncheon). Dry run is on by default (1): it reads positions and reports in its log what it would close; it sends no order and writes no row. Clause 7 reads stored_pending while it is on. 0 closes for real, with the relay's own key (NW_TORII_AGENT_KEY, NW_TORII_ACCOUNT_ADDRESS) and reduce-only orders only. Seconds between ticks (30); mandates per tick (20)
TW_POLL_SECONDS, TW_CONFIRMATIONS, TW_CHUNK_BLOCKS, TW_START_LOOKBACKChain reader pacing
TW_LINKS_FROM_NWNightWatch to wallet links
NW_PAYMASTER_URL, NW_PAYMASTER_KEY, NW_PAYMASTER_METHODGas sponsorship (Coinbase paymaster, Base only). Fail-closed when the URL is unset. Not on today

Trading side (API host)#

NameWhat it switches
NW_TORII_LIVE_ENABLEDMaster switch for live orders. Default off
NW_TW_TRADE_LIVEMaster switch for live orders from the Trade door. Default off: every order is paper. Also needs NW_TORII_MAINNET on. A verified close of a live position works with it off
NW_TW_TRADE_ALLOWLISTComma list of 0x wallets or uid:<id> allowed to trade live. Required for live: with NW_TW_TRADE_LIVE on, an empty, blank or commas-only value means nobody trades live (everyone stays on paper). There is no wildcard; * matches nothing
NW_TW_TRADE_RATE_PER_MIN, NW_TW_TRADE_RATE_PER_HOURPer-wallet throttle on POST /tw/trade/order and /close together (default 10 a minute, 60 an hour, kept per API process). Past it: 429 tw_rate_limited with Retry-After
NW_TRUST_CF_HEADERSDefault off. When 1, the KR gate on live opening orders trusts the CF-IPCountry header (needs NW_TG_KR_GATE_ENABLED too, and a proxied Cloudflare edge with the origin locked to Cloudflare). Off: the gate does nothing for Trade and the log says so once
NW_TORII_CLIENT_SIGN_ENABLEDThe owner signs each order in the browser (sign_mode: client)
NW_TORII_BUILDER_ADDRESS, NW_TORII_BUILDER_FEE, NW_TORII_MAX_BUILDER_FEE_PCTThe builder address and fee (0.1%) and its ceiling
NW_TORII_BUILDER_APPROVAL_ENABLED, NW_TORII_AGENT_APPROVAL_ENABLEDOn-chain approvals for the builder fee and for the order agent key
NW_TORII_MAX_ORDER_USD, NW_TORII_MAX_DAILY_USD, NW_TORII_MAX_CLOSE_USDPer-order, per-day and close caps
NW_TORII_BEARER_DEFAULT_CAP_USD, NW_TORII_BEARER_MAX_DAILY_USD, NW_TORII_BEARER_MAX_CLOSE_USDCaps for the signed-in (bearer) path
NW_TORII_SLIPPAGE_PCT, NW_TORII_REDUCE_ONLY_CAP_EXEMPTSlippage; whether reduce-only closes use the daily budget
NW_TORII_MAINNET, NW_TORII_ORDER_TYPES_V2, NW_TORII_DEX, NW_TORII_DEX_TRANSFER_ENABLEDNetwork, order types, dex selection
NW_TORII_OWN_MODE, NW_TORII_OWN_PAPER_WORKEROwn-account link and the paper worker
NW_TORII_ALLOWLIST, NW_TORII_ACCOUNT_ADDRESS, NW_TORII_AGENT_KEYAllowlist and account; the agent key is a secret held only on the server

Deploy script (the machine that deploys)#

NameNeeded for
CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRETBroadcast deploys with the CDP server wallet

Frontend#

NameMeaning
NEXT_PUBLIC_API_BASE, NEXT_PUBLIC_API_URLThe API base the pages call
NEXT_PUBLIC_TW_HOSTSComma list of hosts that serve the wallet at the site root. Default toriiwallet.com,www.toriiwallet.com. On these hosts /x is rewritten to /tw/x, www. redirects to the apex (308), canonical URLs drop /tw. Build-time (baked into the middleware and pages), so a change needs a redeploy

Parked#

TW_TUSD_RESERVE_ADDRESS, TW_TUSD_TOKEN_ADDRESS, TW_TUSD_RPC_URL belong to the parked Torii dollar. They are not part of the product.