Skip to content

Docs

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_RUN, TW_DEPOSIT_MAX_BLOCKS_PER_TICK (4000), TW_DEPOSIT_TICK_BUDGET_SEC (60)The deposit watcher's dry run; per tick it reads consecutive 200-block chunks (never above the eth_getLogs ceiling) until the block cap or the time budget, committing the checkpoint after each chunk
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 (4000; old name TW_VAULT_EVENTS_MAX_BLOCKS), TW_VAULT_EVENTS_MAX_SPAN (200 blocks per eth_getLogs: the public Base Sepolia node's limit, a larger span needs a paid RPC; halved to 100 on -32005; a 413 for one address is halved once, then the chunk is left unscanned and retried next run), TW_VAULT_EVENTS_START_BLOCK, TW_VAULT_EVENTS_REVERTS (1; 0 turns the revert block scan off), TW_VAULT_EVENTS_REVERT_BLOCKS_PER_TICK (150; blocks the revert scan reads per run on its own stored block torii_vault_reverts, one eth_getBlockByNumber each; it does not limit the event range), TW_VAULT_EVENTS_REVERT_BACKFILL_MAX_BLOCKS (2000; the first revert backfill of a vault reads at most this many blocks before the revert cursor, older attempts from before the scan existed are not reconstructed), TW_VAULT_EVENTS_REVERT_BUDGET_SEC (60; the revert scan stops cleanly after this many seconds and resumes next run), TW_GETLOGS_MAX_ADDRESSES (20; addresses per eth_getLogs call; a 413 halves the address list first), TW_GETLOGS_MAX_SPAN (200; blocks per eth_getLogs call in every Torii chain read, deposit-watch included; the public node's limit; capped at 200 whatever the value unless TW_GETLOGS_ALLOW_LARGE_SPAN=1, set only with a paid RPC; every other span or chunk value is clamped to it)The 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_IDEMPOTENCY_TTL_SECDefault 900. An Idempotency-Key row still in_flight after this many seconds belonged to a call that crashed: the next retry takes it over instead of being told idempotency_in_flight forever. Checked on read, no sweep, no new column. Finished rows are never reclaimed
TW_HALL_SNAPSHOT_STMT_TIMEOUT_MSSession statement timeout of the Hall snapshot worker (nw_tw_hall_snapshot, run on Chuncheon every 2 min), default 30000. The worker fills nw_tw_hall_snapshot; the Hall routes only read it (pending until the first pass, stale after 10 min). No dry-run env: --once --dry-run on the command line
TW_HALL_SNAPSHOT_KEEP_GOOD_SECHall snapshot worker: an agent whose record cannot be built this pass keeps its last good stored row (flagged degraded, with that row's own computed_at) while the row is younger than this many seconds, default 3600; after that the honest record_error row replaces it
TW_APPROVAL_ENABLEDDefault on (1). Clause 6: a relayed execute-call or hl-order above the reconfirm line (the owner's approval_above_usdc, else the TW_RECONFIRM_* default) is held until the owner decides; at the line it passes, above it it waits. Off: nothing is held and clause 6 reads stored_pending
TW_RECONFIRM_BUDGET_PCT, TW_RECONFIRM_USDThe default "one owner tap" line when the owner set none: the smaller of this percent of the budget (25) and this many USD (1000). Set either to 0 or empty to turn the default off (then no line unless the owner sets one). An owner-set approval_above_usdc always wins. The limits view shows approval_source: owner or default
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_KEEPER_MARK_DRY_RUN (1), TW_KEEPER_MARK_SIGNER (cdp; dev only against a local node), TW_KEEPER_MARK_DEV_KEY (hardhat rehearsal only), TW_KEEPER_MARK_MIN_DELTA_BPS (50), TW_KEEPER_MARK_MAX_AGE_SEC (3600), TW_KEEPER_MARK_MAX (50 mandates per tick), TW_KEEPER_MARK_SCOPE (allhl_native
TW_SETTLE_GRACE_ENABLEDThe API only (default 0). 1 makes the close-all plan skip the owner stop() step, and stop-call return the reason instead of calldata, between endsAt and endsAt plus one day. The deployed vault lets the owner stop at any time, so keep it 0 until the factory with SettleGraceActive is redeployed; switch it on together with that redeploy
TW_TEST_VENUE_TARGETSComma-separated addresses of the test venue contract ToriiMandateTarget. Empty (default): the test-venue exit adapter is inert. Set only on a local rig
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); triggered mandates closed per tick (20; the trigger is checked for every candidate, and more triggered mandates than this exits 1)
TW_MANDATE_FACTORY_V2_ADDRESSLeg money (needs TW_HL_LEG_ENABLED and TW_LEG_FUNDING=test). The v2 vault factory (ToriiMandateFactoryV2). Unset or malformed: the create-call answers configured: false while funding is on. Receipts and the event sweep match both factories
TW_LEG_FUNDINGDefault off (off | test; anything else is off). Phase T leg money: the vault funds the owner's Hyperliquid account through a keeper fundLeg and a house-lent HL testnet mirror, and gets the money back. Off: no v2 create-call, no /money, /hl-leg/return-call (POST), /hl-leg/return (404 tw_feature_disabled), no mandate_money tool, the mover and reconcile do nothing, the keeper adds no in-flight term. Needs TW_HL_LEG_ENABLED
TW_GAS_DRIP_ENABLEDDefault off. The one switch for POST /torii/gas/drip and the torii_gas_drip MCP tool: a little Base Sepolia test ETH from the house funding wallet to the caller's own wallet, the first drip for any signed-in session owner (no mandate needed), and for key callers only an account that owns a draft, signed or working mandate or is the designated agent of a signed or working one (else not_eligible, reason no_mandate_yet; the 7-day top-up always needs a mandate). Off: the route answers status: disabled and the tool is not listed. On: tools/list shows it in the torii and full profiles. On Base mainnet it is always disabled; no variable overrides that (the chain id is a constant and is checked against the RPC). Needs the table: python -m svc.db.schema.apply_tw_gas_drip_schema
TW_GAS_DRIP_ETH (0.002), TW_GAS_DRIP_MIN_BALANCE_ETH (0.0005), TW_GAS_DRIP_DAILY_MAX (50), TW_GAS_DRIP_DAILY_ETH_MAX (0.1), TW_GAS_DRIP_ALERT_ETH (reserve + one drip + 0.0001 gas buffer, i.e. 0.0521), TW_GAS_DRIP_RESERVE_ETH (0.05), TW_GAS_DRIP_FUNDER_WALLET (the CDP admin account)Gas drip tuning. Amount per drip; the balance under which a wallet gets one; drips and ETH per UTC day for the whole deployment (over either: capped); the funding balance left after a drip under which (and on every funding_low cap), once a UTC day, an alert row is written (nw_tw_alert_log, kind gas_drip_funding_low), the ops Telegram channel gets a message (notify_ops_summary: needs NW_NOTIFY_OPS_CHAT_ID and NW_NOTIFY_TG_BOT_TOKEN) and a WARNING is logged; the reserve the funding account keeps (a drip that would leave less than it, after the drip and a gas margin, answers capped with reason funding_low, so drips never eat the keeper's gas when the funder is the admin account); the name of the CDP account that pays. Per address: one drip, one more at least 7 days later when the balance is under 0.0001 ETH, never a third; two addresses per account
TW_TEST_LEG_GATEWAYThe TestLegGateway on Base Sepolia. The create-call pins it as the vault's legGateway from this variable only, never from a request
TW_HL_TEST_POOL_ADDRESSThe house pool's PUBLIC address (a value, not a secret). Read by the API (the return-call destination), the reconcile worker and the mover; when the mover also holds the key it must be that key's address (pool_address_mismatch otherwise)
TW_HL_TEST_POOL_KEYSecret, never printed or logged. Raw 32-byte key of the house pool: signs the pool's usdSend on Hyperliquid TESTNET and tops up gains on Base Sepolia. Chuncheon only (/etc/nightwatch/tw-leg.env, mover unit). Refused when TW_HL_NETWORK=mainnet
TW_LEG_MIN_USDCDefault 6. Smallest first deposit of a v2 vault with a leg (tw_leg_min_deposit below it) and smallest first funding
TW_LEG_INFLIGHT_MAX_SECDefault 120 (Phase T). A fund or return row that has not moved for this long: the keeper withholds the mark (leg_transfer_stuck)
TW_LEG_RETURN_FALLBACK_SECDefault 86400. A closed mandate whose owner has not returned the leg money after this long is returned at the last good equity
TW_LEG_MOVER_DRY_RUN (1), TW_LEG_MOVER_SEC (30, loop mode), TW_LEG_MOVER_MAX (20 mandates a tick), TW_LEG_KEEPER_SIGNER (falls back to TW_KEEPER_MARK_SIGNER, cdp; dev only against a local node)The leg mover (nw-tw-leg-mover)
TW_LEG_RECONCILE_DRY_RUN (1), TW_LEG_RECONCILE_SEC (300, loop mode)The leg reconcile (nw-tw-leg-reconcile)
(clause 6 on hl-order)POST /torii/mandates/{id}/hl-order holds an open above the mandate's reconfirm line (approval_above_usdc, or the TW_RECONFIRM_* default) (HTTP 202, pending_approval) whenever TW_HL_LEG_ENABLED is on, with or without TW_LEG_FUNDING; it is switched off only by TW_APPROVAL_ENABLED=0
TW_HL_LEG_ENABLEDDefault off. The one switch for the HL leg (a mandate trades in the owner's own Hyperliquid account; spec 2.2). Off: the five hl-leg / hl-order routes answer 404 tw_feature_disabled, the MCP tool mandate_hl_order is not listed and a call is an unknown tool, the Trade door has no extra check, the keeper marks vault balance only, the stop line uses the house-relay adapter. On (1, true, yes, on): needs TW_HL_LEG_SEED and the schema (python -m svc.db.schema.apply_tw_hl_leg_schema). Set on the API host and on Chuncheon (keeper mark and stop line). Read on every request
TW_HL_LEG_AUTO_RELEASEDefault on (0 / false / off / no turns it off). One Hyperliquid account has one leg, and a mandate that has ended (stopped, settled, cancelled) does not keep it: taking a mandate to an ended status releases a leg that never placed an order in the same transaction; approve-call and bind release a leg held by an ended mandate of the same owner and carry on (a live holder is refused with its AI's name and status in fields); the stop-line worker's tick (torii_stop_line, Chuncheon) sweeps every bound leg of an ended mandate and releases it once the owner's account is read flat (never while the stop line still owes its close, or test leg money is out). Every release writes a keeper hl_leg_unbound note with the reason. The sweep sends no order, so TW_STOP_LINE_DRY_RUN does not stop it; TW_LEG_SWEEP_MAX (50) bounds one tick. Needs TW_HL_LEG_ENABLED. Check: python scripts/ops/check_leg_invariants.py (read only, exit 1 on a violation)
TW_HL_LEG_SEEDSecret, never printed, never in a doc, chat or commit. Exactly 64 hex characters (32 random bytes; a leading 0x is allowed). Anything else is refused. The per-mandate Hyperliquid trade key is derived from it with HKDF-SHA256 and the mandate's public id and is never stored. With the flag on and no seed: the routes answer 503 not_configured, the stop-line worker refuses to start (exit 1) and a live close fails without guessing. Changing it orphans every bound leg (their approved keys no longer match): do not rotate it while a leg is live. Set on the API host and on Chuncheon (stop line)
TW_HL_NETWORKtestnet (default) or mainnet: which Hyperliquid the HL leg reads and signs for. The Trade door and the relay keep their own NW_TORII_MAINNET. HL-native worth marks record it (payload.network); only marks of the current network arm the floor or trigger the stop line. With mainnet, TW_LEG_FUNDING=test makes the hl-leg routes answer 503 not_configured
NW_FORGE_SIGNAL_PUBLISH_ENABLEDDefault off. Forge's switch for operator signal publishing (POST /forge/vaults/{id}/signals, MCP forge_signal_publish). Off: every call answers 503 flag_off and writes nothing. Read on every request. It is a Forge flag, listed here because door 3 depends on it
NW_FORGE_SIGNAL_PUBLISH_RATE_PER_HOURDefault 60, minimum 1. The most signals one vault may publish in an hour; past it, 429 rate_limited with retry_at
TW_HOUSE_RUNNER_USER_IDThe user id of the house runner account. No default: unset, the runner worker exits 0 and does nothing, door 2 reports paper and the adopt draft names no agent. Set (with TW_HL_LEG_ENABLED on and TW_HL_NETWORK=testnet), door 2 reports testnet
TW_HOUSE_RUNNER_KEYSecret, never printed. The runner's agent key (scope tx); needed only for a live pass. Without it a signal is recorded skipped_no_runner_key
TW_HOUSE_FOLLOW_DRY_RUNDefault 1 (dry): the worker records dry_ verdicts and places nothing. 0 places orders through each mandate's HL leg. Timeouts and limits: TW_HOUSE_FOLLOW_STMT_TIMEOUT_MS (30000), TW_HOUSE_FOLLOW_LOCK_TIMEOUT_MS (5000), TW_HOUSE_FOLLOW_MAX_SIGNALS (20 per mandate per pass)
TW_KEEPER_HL_DEXES (,xyz), TW_KEEPER_HL_EXIT_BPS (15), TW_KEEPER_HL_MAX_AGE_SEC (120)HL leg worth: the perp dexs read (empty name = main), the exit allowance in basis points of open position value, and how old a Hyperliquid answer may be before the mark is withheld
TW_HL_LEG_MAX_OPEN_NOTIONAL_MULTDefault 2. The most open notional the HL leg may carry, as a multiple of the mandate's daily cap; checked on every opening hl-order against the positions on the owner's account. Positions carry over days, so the daily cap alone does not bound them
TW_STOP_LINE_TRANSIENT_PAGE_TICKS (10)A stop-line close that stays transient (Hyperliquid unreachable, partly filled) for this many ticks in a row makes the worker exit 1 so the unit pages; one tick is TW_STOP_LINE_SEC seconds (default 30), so ten ticks are about five minutes
TW_HL_SLIPPAGE_PCTAggressive-price band of the leg's IOC orders as a fraction, default 0.05; a value outside 0 to 0.5 is ignored. Stop-line closes do not use it: they start at 5 % and widen to 10 % and 15 % on each no-fill retry (CLOSE_BAND_STEPS, constant in code)
TW_HL_NATIVE_MARK_MAX_AGE_SECDefault 1200 (about three keeper intervals of 300 s plus margin). An opening hl-order on an HL-native mandate (no vault) is refused wrong_status when Torii's newest check of the owner's Hyperliquid account (the newest armed mark, or the leg's last good read when newer) is older than this. Set on the API host
TW_HL_INFO_URL, TW_HL_EXCHANGE_URLTest and local-rig only: point the HL leg at a fake Hyperliquid server. Honoured only for a loopback host (127.0.0.1, localhost); any other value is ignored. Never set in production
TW_PUBLIC_WEB_BASE, TW_PUBLIC_API_BASEThe two public base URLs Torii puts in what it hands out, never the request Host. Web (TW_PUBLIC_WEB_BASE, else NW_PUBLIC_SITE_URL when set, default https://toriiwallet.com): the owner alert links. API (TW_PUBLIC_API_BASE, default https://api.nightwatchprotocol.com; NW_API_BASE is not read, it belongs to the workers and the record anchor): the URLs inside GET /torii/door and GET /torii/skill.md. docs in the door stays https://toriiwallet.com/llms.txt. Only https:// values are accepted; anything else is ignored and the default applies
NW_PUBLIC_SITE_URL, NW_PUBLIC_API_BASE, TW_PUBLIC_WEB_BASE (skill-doc hosts)The hosts the generated skill docs print, read at call time, https:// only, default is today's URL. NW_PUBLIC_SITE_URL (default https://nightwatchprotocol.com) and NW_PUBLIC_API_BASE (default https://api.nightwatchprotocol.com) feed /build/skill.md and /hive/skill.md (svc/common/public_urls.py) and the docs_nw link in the Torii door and skill. TW_PUBLIC_WEB_BASE also sets the toriiwallet.com URLs in /torii/skill.md, the door and the agent_connect hints (the NW_PUBLIC_SITE_URL fallback is not used there). The Torii API base stays TW_PUBLIC_API_BASE (above). Never the request Host
TW_POLL_SECONDS, TW_CONFIRMATIONS (default 2; every chain-log ingest, the poller, page loads, POST /vault and POST /vault-tx, reads to head minus this; a failed head read ingests nothing), TW_CHUNK_BLOCKS (200, deposit-watch; the public node's eth_getLogs limit), TW_START_LOOKBACKChain reader pacing
TW_DEPOSIT_ADDR_BATCH (50), TW_DEPOSIT_BACKFILL_LOOKBACK (2000 blocks), TW_BLOCK_SECONDS (2), TW_REORG_WINDOW_SECONDS (3600), TW_REORG_RECHECK_MAX (50)Deposit watcher: addresses per eth_getLogs filter; how far back a late-registered address is scanned once; the block time used to estimate its registration block; how long a confirmed deposit is re-checked for a reorg, and how many per poll
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
TW_ARBITRUM_ENABLEDDefault off. USDC on Arbitrum: GET /tw/money/arbitrum answers 404 arbitrum_disabled while off; when on, POST /tw/money/send/prepare with the Arbitrum chain_id is served by the house relay on Arbitrum (the owner signs, the relay pays the network cost). Off stops new sends and moves only: a move already on its way keeps going and stays readable (GET /tw/money/arbitrum/move/{id}, /moves). As designed, not on today
TW_ARBITRUM_NETWORK (arbitrum or arbitrum-sepolia; default pairs with the Base money door), TW_ARBITRUM_RPC_URL (default the network's public RPC)Which Arbitrum, and where it is read
TW_ARB_RELAY_DAILY_WEI (0.002 ETH), TW_ARB_RELAY_MIN_BALANCE_WEI (0.0003 ETH), TW_ARB_RELAY_USER_DAILY_CAP (20), TW_ARB_RELAY_EST_WEI_PER_TXThe Arbitrum relay's daily network-cost cap, the balance below which it refuses (503 relay_low_balance), sends per account per day, and the cost counted for a send without a receipt yet
TW_ARB_FEE_RECEIVER_ARBITRUM, TW_ARB_FEE_RECEIVER_ARBITRUM_SEPOLIAWhere a USDC fee for an Arbitrum send goes; unset = the relay wallet
TW_ARB_MOVE_ENABLED, TW_ARB_FORWARDER_ADDRESS_ARBITRUM, TW_ARB_FORWARDER_ADDRESS_ARBITRUM_SEPOLIADefault off / unset. Move to Base: one signature on Arbitrum, the USDC arrives at the same address on Base in about 20 minutes, no fee. The move contract is set per network and is used only when it reports this network's USDC and Base as its destination; else 503 move_not_ready. Also 503 until python -m svc.db.schema.apply_tw_arb_moves --apply has run
TW_ARB_MOVE_MIN_USDC (1), TW_ARB_MOVE_MAX_USDC (1000), TW_ARB_MOVE_USER_DAILY_CAP (5), TW_ARB_MOVE_DELAY_ALERT_MIN (45)Move limits, and when a move counts as slow (the owner sees "Taking longer than usual", ops gets an hourly alert)
TW_ARB_SETTLE_KILLEmergency stop for the Chuncheon worker svc/worker/tw_arb_settle.py: nothing is settled while it is 1. The feature switches never stop settling

Analytics (frontend build)#

NameWhat it switches
NEXT_PUBLIC_TW_GA_IDThe Google Analytics 4 measurement ID (G-...) of the Torii Wallet web stream. A build-time variable: it is read when the frontend is built, so a change needs a new build and deploy. Empty or unset: the GA4 tag is not rendered. Used only under /tw, with no cross-domain linking to NightWatch
NEXT_PUBLIC_TW_CLARITY_IDThe Microsoft Clarity project ID of Torii Wallet. A build-time variable, same as above. Empty or unset: the Clarity tag is not rendered. Used only under /tw

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
(no flag)Per-wallet caches on the Trade door, per API process: the account read behind /tw/trade/me and /positions (5 s, single-flight, dropped after an order or close) and the Hyperliquid account type (10 min). Request bodies on /tw/* writes above 64 KB get 413 tw_body_too_large
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_PCTSlippage the Trade door sizes and paper-fills for, as a fraction: 0.05 (default) is 5 %. Allowed 0.0001 to 0.05; anything else (or a non-number, or 5 meant as percent) is ignored with a log line and 0.05 is used. Read on every request. The browser's own signed price band is the screen's constant, not this value
NW_TORII_REDUCE_ONLY_CAP_EXEMPTWhether reduce-only closes use the daily budget
NW_TORII_DEXThe perp dex the Trade door lists and accepts coins for (<dex>:<SYMBOL>). Default xyz; 1 to 16 lower-case letters or digits, anything else is ignored with a log line. Read on every request
NW_TORII_MAINNET, NW_TORII_ORDER_TYPES_V2, NW_TORII_DEX_TRANSFER_ENABLEDNetwork, order types, dex transfer
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
NW_TORII_AGENT_SLOT_NAMEOptional. The approved agent's slot name (nw- plus 8 lowercase hex characters; anything else is ignored). When set, GET /torii/agent/status returns it as slot_name and the approval card signs under that name, so a rotated agent key replaces the old agent instead of opening a second slot

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
NEXT_PUBLIC_TW_NETWORKbase-sepolia (default) | base; the 2026-11-05 mainnet switch. Build-time
NEXT_PUBLIC_CDP_NETWORKRemoved 2026-10-30. No longer read. The embedded wallet default send chain and label come from NEXT_PUBLIC_TW_NETWORK when it is set; when it is unset they stay Base 8453 / "Base" as before (defaultSendChainId in walletSignerPure.js) (walletSigner, walletSignerPure, cdpWallet, WalletLoginClient)
NEXT_PUBLIC_TW_CHECKOUTCheckout sheet. Default on: a ?draft= entry to /tw/agents/new ends on one receipt-style sheet (what you pay for, amount, pay with, fee in Cherry, terms, one button). 0 restores the previous confirm screen (limits form, consent card). Build-time, so a change needs a redeploy
NEXT_PUBLIC_TW_INTUITIONCheckout sheet market read. Default off: one sentence about the market a listing trades with two linked facts, above the Terms row. Needs NW_CHECKOUT_INTUITION on the API and the nw-checkout-intuition worker. Build-time. Runbook: CHECKOUT_INTUITION in the NightWatch ops notes (internal)
NEXT_PUBLIC_TW_WALLET2_TRANSFER_PERPSNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. On, and only in live mode with a signed-in session and a wallet address, the Transfer screen really moves the person's own USDC between Crypto perps and Stock perps (both ways, free, one wallet signature, then checked against the balances). Every other pair, Deposit, Withdraw and Claim stay inert. wallet2 has no production mount: its only live mode is the preview page with no query (or ?live=1), so the move also needs the preview owner gate below to have allowed the page (the live runner checks the gate again itself and refuses otherwise). NEXT_PUBLIC_TW_WALLET2_PREVIEW=1 alone never enables this
NEXT_PUBLIC_TW_WALLET2_TRANSFER_OUTNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Independent of NEXT_PUBLIC_TW_WALLET2_TRANSFER_PERPS. On, and only in live mode with a signed-in session, a wallet address, the preview owner gate allowing the page and trading switched on for the wallet, the Transfer screen really moves the person's own USDC out of the exchange (the DEX) to Wallet (the place once called Funding: the dollar coins at the wallet's own address): Crypto perps to Wallet (one wallet signature) and Stock perps to Wallet (two signatures: first the move to Crypto perps, then the withdrawal, run as one action). The withdrawal is the exchange's own withdrawal (the same code as the Withdraw sheet in the older wallet) and goes only to the signed-in wallet's own address, as USDC on Arbitrum One; the exchange keeps a fixed 1 USDC fee out of the amount, the smallest amount is 2 USDC, Torii charges nothing; the screen says so in one line (it leaves the DEX, the exchange charges its 1 USDC per withdrawal, Torii charges nothing) and the button reads "Withdraw $X to Wallet". A move between Crypto perps and Stock perps stays inside the DEX and is free. Money and the From / To lists group the places alike: Wallet alone, then DEX (Stock perps, Crypto perps, Spot & ETFs, all held at the exchange), then Invested (With agents, In vaults). Torii never sends a signed step twice: an unclear answer is only read again (every 5 seconds for 2 minutes while the popup is open, then once per popup open or per Check again). A move that stopped after its first step says so (the money is in Crypto perps). Money's Wallet row shows the withdrawal on its way ("Arriving · $X", with Check again) until it arrived. Fixture scenes (transfer-out, transfer-out-two, transfer-out-transit, transfer-out-halfway) never sign. NEXT_PUBLIC_TW_WALLET2_PREVIEW=1 alone never enables this
NEXT_PUBLIC_TW_WALLET2_TRANSFER_OUT_CCTPNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. It changes only the route of NEXT_PUBLIC_TW_WALLET2_TRANSFER_OUT and does nothing without it; off, the move out of the DEX to Wallet is exactly the older route above. On (together with _TRANSFER_OUT), Crypto perps / Stock perps to Wallet uses Circle CCTP from the exchange straight to the signed-in wallet's own address, with Circle's automatic forwarding (no gas needed on the destination): the exchange action sendToEvmWithData from the main perp balance, one owner signature (Stock perps first moves the money to Crypto perps, free, so two signatures). Destinations, in one table in app/(torii-wallet)/_wallet2/transfer/cctpPure.mjs (CCTP domain, chain, USDC contract from Circle's own docs): Base (domain 6, the default), Arbitrum (3), Polygon (7), Optimism (2), Ethereum (0); nothing else. The screen has no chain field: the Arrives line shows the coin chip "USDC · Base", and pressing it opens the five, each with its own live fee. The fee is read live from Circle's CoreDepositWallet on HyperEVM (calculateCrossChainWithdrawalFee(true, domain), through the HyperEVM RPC the repo already uses) when To is Wallet, when the list opens, and again immediately before signing; it is never typed in. A read that fails or is above 5 USDC (0 is allowed) means the move is not offered ("We could not read the Circle CCTP fee just now." with Try again); a fee that changed between the screen and the signature stops the run before anything is signed and the screen shows the new figure. The fee is taken out of the amount sent (You send, "Circle CCTP fee" with a tip saying it is Circle's CCTP fee taken out of the amount sent and that Torii receives none of it, Arrives = amount minus fee); the smallest amount is 1 USDC and it must be more than the fee; Torii charges nothing; the helper line names the live fee per withdrawal ("This leaves the DEX. Circle CCTP charges $X per withdrawal; Torii charges nothing."); the older route keeps "Exchange fee". A destination whose live fee is at least 3x the lowest live fee in the list carries a second line "Higher fee" in the list, and when it is the chosen one a notice under Arrives says so from the live values ("<chain> costs <fee> per withdrawal. <cheapest chain> costs <fee>."; a tie for cheapest names the default); nothing is shown while any fee is still being read, nothing is blocked and there is no extra step. The destination is part of the plan and of the stored run: a resumed run checks arrival on the chain it was sent to. The run is the same state machine as the older route (per-leg state kept before signing, an unclear step is only read again, never re-sent; "Arriving" on Money until the USDC on that chain rose by the expected amount, less one cent). Fixture scenes (transfer-out-cctp, -cctp-nofee, -cctp-menu, -cctp-signing, -cctp-two, -cctp-two-half, money-arriving-cctp, money-arrived) never sign. The Wallet place also counts USDC on Optimism and Ethereum (and Deposit lists them), so money sent there shows
NEXT_PUBLIC_TW_WALLET2_WITHDRAWNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, the Withdraw screen and Money's Withdraw button are exactly as before ("Opens soon"). On, in live mode behind the preview owner gate, Withdraw sends USDC on Base only from the Wallet address to an outside address the person types, through the existing house gas relay (POST /tw/money/send/prepare {to, amount, chain_id: 8453, from_address}, POST /tw/money/send/submit {send_id, signature, fee_signature?}, GET /tw/money/send/{id}; no backend change). The person signs one EIP-3009 TransferWithAuthorization with the built-in wallet (and a second one for the fee when the server quotes a USDC fee); the relay pays the gas. The cost shown is exactly the server's quote: "Cost · N Cherry" when it charges Cherry, "Fee · X USDC" when it charges USDC, "Free" when none; the amount typed arrives whole. The quote is asked for once the address and amount are complete (after a short pause in typing); each quote holds its Cherry on the server until it is used, replaced by the next quote, or lapses (15 minutes). A quote that cannot be read disables the button with "We could not get the cost just now." and Try again; every refusal code of the relay maps to one plain English line. The address must be 0x and 40 hex characters (mixed case must carry a valid checksum), never the zero address or the person's own; it is read back in full in the confirm dialog. More than the Wallet's Base USDC is refused on screen ("$X is on Base. Other chains open soon."). The run (transfer/wdRunPure.mjs, stored under tw2_xferwd:<address> without any signature) is planned -> signing -> submitted -> sending -> done / failed / unclear: kept before signing and again before the one submit; the only repeat is the relay's own relay_busy answer (same signature, at most twice); a submit that may have gone out is only read again through GET status (every 3 s for up to 2 minutes, then Check again), never posted again; a reload reads a stored run once. Confirmed: back to Money, a toast, the balances read again. Failed: "The money did not move.", and "Your N Cherry were returned." only when the server's status says failed for a Cherry-paid send. One run at a time across the perps move, the move out of the DEX and Withdraw (transfer/exclusivePure.mjs). Fixture scenes (withdraw-base, -usdc, -noquote, -badaddr, -short, -confirm, -sending, -failed, -unclear, withdraw-soon, money-withdrawn) never sign. The relay itself must be on for Base mainnet (NW_GAS_RELAY_ENABLED, NW_GAS_RELAY_NETWORK=base); its minimum (NW_GAS_RELAY_MIN_USDC, default 0.5), per-send maximum and daily counts are the server's.
NEXT_PUBLIC_TW_WALLET2_TRANSFER_INNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, the Transfer screen is exactly as before (moving money out of Wallet "opens soon"). On, in live mode behind the preview owner gate, Transfer from Wallet to Crypto perps deposits USDC from the Wallet address on a source chain into the person's own perps account through the house deposit relay (POST /tw/money/deposit/prepare {chain_id, amount, from_address}, POST /tw/money/deposit/submit {deposit_id, signature, fee_signature?}, GET /tw/money/deposit/{id}; every field name of these lives in one adapter, app/(torii-wallet)/_wallet2/transfer/depApiPure.mjs). Source chains: a static list in transfer/depPlanPure.mjs (DEPOSIT_CHAINS, Arbitrum only for now; Base is one more line), less any chain the server answers chain_not_supported for (remembered for the session); the From line shows the coin chip "USDC · Arbitrum" and opens the list of chains with their balances, the others (and USDT on BNB Chain) "Opens soon". The default chain is the one holding enough USDC, the lowest Circle CCTP fee first. The person signs one EIP-3009 ReceiveWithAuthorization with the built-in wallet (a second authorization only when the quote's cost is USDC); before signing the client checks the message is from the session address, for exactly the amount typed, on that chain's USDC (the CCTP table's own contract), and that Arrives = amount minus the Circle CCTP fee, that fee at most 5 USDC and less than the amount; anything else is refused without signing. Lines: You send, Circle CCTP fee (Circle's, taken from the amount sent; Torii receives none of it), Arrives (in Crypto perps), Cost (Torii) exactly as quoted (Cherry or USDC on top, or Free); button "Deposit $X to Crypto perps". The smallest amount is 5 USDC (or the larger detail.min of amount_below_min). Quotes are asked for after a pause in typing, never on a timer (each holds its Cherry on the server); a quote that cannot be read disables the button with "We could not get the cost just now." and Try again; every refusal code maps to one plain English line. The run (transfer/depRunPure.mjs, stored under tw2_xferin:<address> without any signature): kept before signing and before the one submit (relay_busy is the only repeat), GET status every 5 s for up to 2 minutes, then only on popup open or Check again; an unclear submit is never re-sent; burned means on its way (back to Money, "Arriving · $X" on Crypto perps), and arrival is read from the exchange's own ledger or the Crypto perps balance for the session address (Arrives within one cent). With NEXT_PUBLIC_TW_WALLET2_TRANSFER_PERPS=1 too, Wallet to Stock perps is the same deposit then the existing free move Crypto perps to Stock perps ("1 of 2 / 2 of 2"); a second step that did not go (or an arrival seen only after a reload or Check again) stops half-way with the money in Crypto perps and a Continue button. One run at a time across all runners (transfer/exclusivePure.mjs). Fixture scenes (transfer-in, -in-usdc, -in-chains, -in-min, -in-noquote, -in-signing, -in-two, -in-failed, -in-unclear, -in-halfway, -in-soon, money-arriving-in, money-arrived-in) never sign. The relay itself must be on for the chain on the server.
NEXT_PUBLIC_TW_WALLET2_SECURITYNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, the Security tab and its screens are exactly as before (every action "Opens soon"). On, in live mode behind the preview owner gate, three Security actions open their own screens (app/(torii-wallet)/_wallet2/security/), with the same helpers and routes as the older screens and no backend change; nothing moves money. Signed-in devices: the list from GET /auth/sessions (lib/useDevices), "Sign out" per row (POST /auth/sessions/{id}/end; this device asks first and signs out here too) and "Sign out other devices" (POST /auth/sessions/end-others, asks first). My order limits: per order, per day and leverage from GET /tw/trade/me, saved with PUT /tw/trade/limits (all three sent; blank = the default); the bounds are the server's (order and day up to the house limit, leverage 1x up to the exchange maximum) and a refusal is shown as one plain line; an answer that never came is read again, never sent again. Export wallet key: the same warning, then the wallet provider's own secure copy frame (createEvmKeyExportIframe, as the NightWatch account page); the key goes from that frame to the clipboard and never enters the page, so it is never read, logged or stored. Offered only for the built-in wallet open in this browser; a server-kept or linked wallet says so. The 2-step check and changing the sign-in email stay "Opens soon" (no enrolment or email-change flow exists yet). Fixture scenes (sec-devices, -confirm, -error, -failed, sec-limits, -refused, sec-export, -key, -waiting, -server) read and send nothing
NEXT_PUBLIC_TW_WALLET2_PREVIEWNew wallet popup preview page, build-time. Default off: /wallet-preview (and /tw/wallet-preview, which is what toriiwallet.com/wallet-preview maps to) answer 404. Only 1 turns the page on, and then it opens only through the owner gate: on a local dev host (localhost, 127.0.0.1, [::1]), or for a signed-in account of that origin whose email, as the API answers GET /auth/me with that session, hashes to an entry of NEXT_PUBLIC_TW_WALLET2_PREVIEW_ALLOW. Everyone else gets a plain "Not found" page (no title naming a preview, no further request; the fixture scenes, the popup and the transfer runner are never loaded). The page is noindex, nofollow. With no query (or ?live=1) the page is the real popup on the visitor's own signed-in account; signed out it shows a Sign in screen whose button opens the existing Torii sign-in on the Money page (/money on the Torii host), after which the person comes back to the page. Fixture scenes need an explicit ?scene=. Both are gated alike. Code: app/(torii-wallet)/_wallet2/gate/
NEXT_PUBLIC_TW_WALLET2_PREVIEW_OPENThe preview owner gate's open switch, build-time. Default off; only 1 turns it on, and only together with NEXT_PUBLIC_TW_WALLET2_PREVIEW=1. On, the account check is skipped: anyone who knows the URL can open the fixture scenes and ?live=1, which shows only that visitor's own data when signed in (signed out: a sentence, no call) and, with NEXT_PUBLIC_TW_WALLET2_TRANSFER_PERPS=1, lets a signed-in visitor move their own USDC between Crypto perps and Stock perps. The page stays noindex, nofollow. Remove the variable (and redeploy) to restore the owner-only lock; no code change
NEXT_PUBLIC_TW_WALLET2_PREVIEW_ALLOWThe preview owner gate's allow list, build-time. Comma list of lowercase hex SHA-256 hashes of lowercase(trim(email)); no email or user id is ever put in the bundle. Empty or missing: nobody passes by this path (local dev hosts still do). Entries that are not 64 hex digits are ignored. Make one entry with node scripts/wallet2_allow_hash.mjs in frontend/: it reads ONE email from stdin (type it and press Enter, or redirect a file; never pass it as an argument) and prints only the hash. The check runs in the browser, so it hides the preview; it does not protect data: every read and move still uses the visitor's own session and is authorised by the API
NEXT_PUBLIC_TW_WALLET2_FRONTThe new wallet's front-door switch, build-time. Default off; only 1 turns it on. Off, nothing changes anywhere: no rewrite or redirect is added, /money is the old Money page and the internal route /tw/wallet2 answers the branded 404. On: /money (/tw/money on a host that is not a Torii host) is served by the new wallet as a full page inside the Torii header, menu and footer (a rewrite: the address stays /money); ?sheet=send opens it on Withdraw, ?sheet=receive and ?sheet=fund on Deposit, ?w=<screen> on that screen (money, earnings, approve, allowed, security, withdraw, deposit, transfer, activity, account). The old sub-paths answer a 307 (temporary, so switching back leaves nothing cached): /deposit to /money?w=deposit (with ?mandate= unchanged: that agent's Fund sheet), /wallet to /money, /?panel=send to /money?w=withdraw, /?panel=receive to /money?w=deposit, /?panel=approve to /money?w=approve. The home / stays the home. The internal route /wallet2 is never linked and never redirected by the server; opened directly, the page moves itself to /money. On that page the preview's allow list does not apply: any signed-in Torii user passes the wallet's gate (flag on, the official address, a sign-in on this origin); each live section still needs its own NEXT_PUBLIC_TW_WALLET2_* flag, and the API checks the session on every call. Signed out, the page shows the wallet's Sign in, which opens the Torii sign-in sheet on the same page (/money#signin opens it at once). /wallet-preview keeps its own owner gate. Table and tests: frontend/app/(torii-wallet)/_wallet2/front/routesPure.mjs, tests/wallet2_front.test.mjs
NEXT_PUBLIC_TW_WALLET2_ACTIONSNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, Sign out (Account), Approve and Decline (an Approve detail) and Stop (Allowed) are exactly as before ("Opens soon" for a real person). On, in live mode behind the preview owner gate, three account actions are real, each the same client call as the older screens and none of them moves money or asks for a signature. Sign out: the Torii shell's own sign-out steps, in its order (clear the sign-in token, the agent key and the gas-drip and wallet-bind marks; end this origin's server session once with POST /auth/logout; tell every hook; drop the built-in wallet session), then the popup closes; no confirm, as in the shell. The stored wallet2 runs (tw2_xfer:, tw2_xferout:, tw2_xferwd: + address) are kept: each loads only for its own wallet address, so another account on the browser never sees it and the same account finds its unfinished move again. Decline (any waiting request) and Approve (a held order only): POST /torii/mandates/{id}/approvals/{approval_id} {decision} with the owner session. Approve lets the agent place that one order, once, for a limited time; the detail says so ("It allows" / "It cannot"). Decline asks once ("Decline this request?") and records the refusal; nothing is built. Approving a money move stays "Opens soon" (it lets the agent move money); its Decline is real. Stop an agent: only for a mandate with no vault, POST /torii/mandates/{id}/stop, after one confirm: the agent can place no new orders, it can still close open positions, the positions and the money stay in the person's own account, and it cannot be undone. A mandate with a vault is stopped from the owner's wallet (a signature), so its Stop stays "Opens soon" with one line saying so. Every answer is sent at most once (a second press waits for the first; an item answered once is never sent again); a refusal shows one plain line (no codes) and the list is read again after every answer. Code: app/(torii-wallet)/_wallet2/actions/. Fixture scenes (approve-order-decline, approve-order-error, approve-done, allowed-stop, allowed-stop-error) never send. NEXT_PUBLIC_TW_WALLET2_PREVIEW=1 alone never enables this
NEXT_PUBLIC_TW_WALLET2_CLAIMNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, the Earnings and Claim screens are exactly as before (Claim, Claim all and Ways to earn Open are "Opens soon"). On, in live mode behind the preview owner gate, Earnings shows each kind with how it is paid (_wallet2/earnings/claimPure.mjs PAYOUT): a promo pool row (one per pool, from GET /promo/my_accruals) is claimed with the person's own sign-in, POST /promo/claim {pool_id, wallet_address} (the address is the person's own built-in wallet address, only for a pool on an EVM chain the server checks; any other pool is "Opens soon" with the reason). The server locks every unclaimed accrual of that pool into one claim (requested); NightWatch then pays the pool's own token from a custody wallet and records the hash (paid). Nothing is signed and nothing is charged. Cherry Credit earnings (tasks, answers, tips, signal readers, referrals) and a vault operator's fees (paid by the vault settler's claimFees()) say "Paid automatically" and have no Claim button. After a claim the accruals are read again, the row moves to "Earned · claimed" and the toast names the amount in the pool's token (coins, never Cherry Credit). The claim run (_wallet2/earnings/claimRun.mjs, stored under tw2.claim.v1:<address>: pool, token, amount, state, time) is one claim at a time per wallet; a claim with no answer is "Not confirmed yet" and is never sent again, only checked against GET /promo/my_accruals (Check again). Ways to earn open the NightWatch pages the old screens link to: /hive?seat=work, /hive, /account?tab=earn (absolute on a Torii host). Fixture scenes earnings-v2, -sending, -unclear, -failed, -done, -noclaim, -empty, -soon never send.
NEXT_PUBLIC_TW_WALLET2_ACTIVITYNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, Earnings' "See all activity" link is exactly as before (drawn in the fixture preview only, it opens nothing) and no Activity code is loaded. On, the link opens Activity: a read-only list of what happened to this wallet's money, newest first, grouped by day, with the filters All / Moves / Sends / Cherry and "Show more" (20 rows at a time; no automatic loading, no polling). Three sources, each read once when the screen opens (again only on Refresh, or Try again for the one that failed), each failing on its own as "Could not load just now": the exchange's own ledger of the wallet address (userNonFundingLedgerUpdates through (site)/torii/hl.js fetchLedgerUpdates, the last 90 days, at most 200 newest lines: deposits, withdrawals with the exchange fee, moves between the places at the exchange, sends to and from other accounts, vault moves; trades are not listed), the Cherry Credit ledger (GET /cherries/ledger?limit=200), and what this browser kept (the older Send panel's recent sends and the Withdraw run in flight; there is no server list of relay sends). A row opens its detail: status, time, from / to, the whole address, the transaction hash with a link to the chain's public explorer, and each fee in its own unit (the Torii cost of a relay send from the Cherry ledger lines of that send). Amounts of different units are never added; a figure that could not be read shows a dash. Fixture scenes (activity, activity-loading, -failed, -empty, -cherry, -detail, -detail-fee) read nothing. Code: app/(torii-wallet)/_wallet2/activity/
NEXT_PUBLIC_TW_WALLET2_CHERRYNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, the Cherry Credit and Obsidian Cherry screens are exactly as before (Buy Cherry and Buy Obsidian Cherry drawn "Opens soon"). On, in live mode behind the preview owner gate, three actions run on the existing gas-free paths of the NightWatch Cherry screen (no backend change), each only when GET /obsidian/config read at that moment says it is open on the Base mainnet pool (chain_id 8453, testnet false); otherwise its door is drawn "Opens soon": Buy Cherry Credit with USDC (POST /cherries/topup/usdc/prepare {payer, usdc} then POST /cherries/topup/usdc {request_id, signature}; one EIP-3009 ReceiveWithAuthorization on Base USDC; minimum 5 USDC; server switch NW_CHERRY_TOPUP_USDC_ENABLED, topups.usdc), Buy Obsidian Cherry (GET /obsidian/quote?usd=, POST /obsidian/buy/sponsored/prepare for the server's network fee in USDC, two authorizations, POST /obsidian/buy/sponsored, GET /obsidian/buy/sponsored/{id}; the server's net minimum rules.sponsored.min_net_usdc_units; server switch NW_OBSIDIAN_SPONSOR_ENABLED), and Convert Obsidian Cherry into Cherry Credit (POST /obsidian/topup/prepare {owner, amount} then POST /obsidian/topup; one ReceiveWithAuthorization on the pool's Obsidian Cherry token; minimum 100; server switch NW_OBSIDIAN_TOPUP_SPONSORED, topups.obsidian). Torii's relayer pays the gas; the person needs no ETH. The price is asked for only when the person presses Get price (each prepare writes a server request row) and shown as the server answered it, with its expiry ("Good until HH:MM") or the time it was read; the server's typed data is checked against the config (pool, network, coin contract, signer, amount) before it is shown and again before it is signed. Redeem (Obsidian Cherry to USDC at the redemption price) stays "Opens soon": PrimaryPool.redeem is a transaction from the person's own wallet with their own gas. The Obsidian Cherry page shows the buy price, the redemption price and their difference from GET /obsidian/state as facts of that read (only for the Base mainnet pool). The run (cherry/cherryRunPure.mjs, stored under tw2_cherry:<address> without any signature) is planned -> signing -> submitted -> verifying -> done / failed / unclear: kept before signing and before the one post; never posted again (Check again and a reload only read); done only when the person's own figures show it (a new obsidian_convert credit on GET /cherries/ledger for the Cherry Credit actions, a higher Obsidian Cherry balance for the buy after the server's succeeded). It refuses while a transfer or Withdraw run of the same wallet is stored unfinished (it reads those stores and changes nothing of theirs). Fixture scenes (cherry-credit*, obsidian-buy*, obsidian-convert*, place-cherry-live, place-obsidian-live) never sign
NEXT_PUBLIC_TW_WALLET2_INVESTEDNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, the In vaults and With agents places are exactly as before (read-only rows). On, each Torii Vault row of In vaults opens the vault, and each agent row of With agents opens the agent (fixture scenes invest-vault* and invest-agent* never sign or send). In live mode, behind the preview owner gate, with the signed-in account's wallet checked to be this wallet on mainnet (GET /tw/trade/me), the vault screen reads the vault's terms (GET /torii/vaults/{id}/terms) and the vault itself on its chain (the same read as the older vault page), and runs the older vault page's four calls from the built-in wallet only, with the same helpers and inputs (no backend change): Deposit (approve exactly the amount only when the allowance is short, then deposit(amount, self): "Step 1 of 2", "Step 2 of 2"), Request withdrawal (requestWithdrawTo(shares, lots, self): shares worth at least 5 USDC at today's price, or all free shares; a holding under 5 USDC only whole), Cancel (cancelWithdraw(id), only the wallet's own request before it is priced) and Claim (claim(self), only when money is booked for the wallet). Each call is checked first as the account (eth_call), then signed and sent by lib/toriiVaultClient.sendBuiltIn (the one send lock, the nonce check and the kept signed transaction of lib/vaultEmbeddedTx.mjs); when the account holds too little HYPE that helper asks the existing gas top-up POST /torii/gas/drip/hyperevm first (server switch TW_GAS_DRIP_HYPEREVM_999_ENABLED, Cherry price NW_GAS_FEE_MULTIPLIER_HYPEREVM, shown as "Cost · N Cherry" from GET /prices; unread with no HYPE disables the button with Try again). A deposit from an account with no HYPE is refused before the send by the shared deposit rule (lib/toriiVaultPure.depositBlockText), as on the older page. The rules are shown before the button: smallest deposit, what you get, smallest request, when it arrives (priced within about 20 minutes, then paid to Wallet by itself), the performance fee, Torii fee none, the cost. The run (invested/vaultRunPure.mjs, stored under tw2_invest:<address> without any signature) is planned -> signing -> sent -> verifying -> done / failed / halfway / unclear; it is planned again from a fresh read before the first signature, kept before each signature, and a step is done only when the vault's own state shows it; a step that may have gone out is only read again (Check again), never sent again; a deposit that stopped after its first step says so (the vault may take the USDC; the USDC is still in Wallet). The agent screen stops an agent with no vault through the older Stop sheet's call (POST /torii/mandates/{id}/stop, owner only, once per press, then GET /torii/mandates/{id} until it reads stopped). An agent with its own vault, and Add money, stay "Opens soon" with a link to the agent page. Code: app/(torii-wallet)/_wallet2/invested/
NEXT_PUBLIC_TW_WALLET2_AUTOLOCKNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, the Security tab and the signed-out screen are exactly as before and the lock clock (autolock/AutoLock.js, autolock/lockLive.js) is never loaded. On, the Security tab gains "Lock when away" (Off / 15 min / 1 hour, default Off, kept in this browser only) and the signed-out screen gains "This is a shared computer" (sets 15 min). Locking closes the built-in wallet's session on this device (the shared resetEmbeddedWalletConnection helper); the Torii sign-in stays, so balances and activity stay visible, and the next send asks for the emailed code. Nothing is locked while a money run of the wallet is unfinished. Live behind the preview owner gate.
NEXT_PUBLIC_TW_WALLET2_ARBITRUMNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. Off, nothing changes (no entry, the live chunk arbitrum/ArbGate.js / arbitrum/arbLive.js is never loaded). On, in live mode behind the preview owner gate with the account's wallet checked to be this wallet on mainnet, the Wallet screen shows "USDC on Arbitrum": Send to another address (the house relay POST /tw/money/send/prepare, /submit, GET /tw/money/send/{id} with the Arbitrum chain id) and Move to Base at the same address (POST /tw/money/arbitrum/move/prepare, /submit, GET /tw/money/arbitrum/move/{id}), the old money screen's backend unchanged and still governed by its own server switches (GET /tw/money/arbitrum: send_enabled, move_enabled). At least 5 USDC per move (the server's own move minimum when higher); the cost is the server's quote; a typed address that is a known contract or holds contract code on Arbitrum is refused; nothing is signed before the confirm dialog (amount, address, network, cost, arrives). Moving to Crypto perps is the existing Transfer (NEXT_PUBLIC_TW_WALLET2_TRANSFER_IN). Fixture scenes arbitrum* never sign. Code: app/(torii-wallet)/_wallet2/arbitrum/
NEXT_PUBLIC_TW_WALLET2_NETWORKSNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. On, the Wallet screen shows "Every network": a read-only list of what the same address holds on Base, Arbitrum, Polygon, Optimism and Ethereum (USDC and the network's own coin, the old money screen's reads). A read that fails is shown as unknown with Try again, never 0. Nothing is signed. Code: app/(torii-wallet)/_wallet2/networks/
NEXT_PUBLIC_TW_WALLET2_SEND_COINSNew wallet popup (wallet2), build-time. Default off; only 1 turns it on. On, in live mode behind the preview owner gate with the account's wallet checked, the Wallet screen shows "Send ETH": the wallet's ETH on Base to an address the person types, one transaction from the built-in wallet (cdpBridge.sendTransaction, as the old money screen's Send), the network fee estimated and paid in ETH. The 5-dollar minimum is checked at the exchange's ETH mid price (one public read); without a price, a fee or the address check nothing can be sent. A known contract or an address with contract code on Base is refused. Fixture scenes coin-send* never send. Code: app/(torii-wallet)/_wallet2/coins/

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.

BNB Smart Chain gas drip (spot vault, built-in account)#

Per chain, <id> is 97 or 56. Both chains are OFF unless their own flag is set.

NameDefault 97 / 56Meaning
TW_GAS_DRIP_BSC_<id>_ENABLEDoff / offSwitch for that chain
TW_GAS_DRIP_BSC_<id>_SIGNERcdp:nightwatch-bsc-gas-drip-testnet / cdp:nightwatch-bsc-gas-dripDrip wallet: cdp:<account name> or env:<VAR>
TW_GAS_DRIP_BSC_<id>_AMOUNT_BNB0.01 / 0.002BNB per drip
TW_GAS_DRIP_BSC_<id>_MIN_BALANCE_BNB0.003 / 0.0007No drip at or above this balance
TW_GAS_DRIP_BSC_<id>_PER_ADDRESS_DAILY_MAX3 / 2Drips per address per UTC day
TW_GAS_DRIP_BSC_<id>_PER_ACCOUNT_DAILY_MAX3 / 2Drips per person per UTC day
TW_GAS_DRIP_BSC_<id>_DAILY_MAX / _DAILY_BNB_MAX100, 1 / 30, 0.06Chain-wide daily count and BNB
TW_GAS_DRIP_BSC_<id>_RESERVE_BNB / _ALERT_BNB0.05, 0.2 / 0.01, 0.05Drips stop below the reserve; ops alert below the alert level
TW_GAS_DRIP_BSC_<id>_MONEY_OUT_WEEKLY_PER_PERSON2 / 2Money-out (cancel, withdraw) drips per person per 7 days
TW_GAS_DRIP_BSC_<id>_RPC_URLpublic node of that chainPer chain; NW_BSC_RPC_URL is not used
NW_GAS_MONEY_OUT_MIN_VAULT_USD / _USDC / _OBSIDIAN_CHERRY5 / 5 / 100Smallest sponsored money-out action per asset (or the whole remaining amount, taking it to exactly 0)
NW_GAS_MONEY_OUT_DAILY_CAP3Sponsored money-out actions per account per chain per UTC day
NW_GAS_FEE_BASE_UNIT_CHERRYBase erc20 price (2)Sponsored-gas base unit; Base x1, Arbitrum x2, BSC x3