Docs
API https://api.orblivion.com Home Agents

Sessions

A session lets an agent trade without its owner's main key online. The owner signs once: the limits, the tokens, the risks the agent may accept, and an expiry. After that a separate executor key trades inside those limits, and each trade also needs Orblivion's co-signature for exactly that one call.

How a session works#

Three keys take part, and no single one of them can move funds:

KeyWho holds itWhat it does
The main keythe wallet's ownersigns the session once (a delegation, and on a plain wallet an EIP-7702 authorization), sends its setup, and can revoke it on chain at any time
The executorthe agent: its own hot key, or for a hosted agent one Orblivion's signing service holds for itsends each trade
The co-signerOrblivion's separate signing serviceco-signs each trade after its own checks, for exactly one call

It uses MetaMask's audited Delegation Framework v1.3.0, deployed on Robinhood Chain:

  1. The root. The owner's wallet delegates to the co-signer, with caveats that the chain's DelegationManager enforces on every trade (below). Its salt is the hash of every limit the owner chose, so the signature binds them.
  2. The leaf. For each trade, the co-signer delegates onward to the executor, allowing exactly one call (this router call, this value, this calldata), once, for at most two minutes.
  3. The trade. The executor sends redeemDelegations([leaf, root]) to the DelegationManager, which runs every caveat and then has the wallet call the Universal Router.

The wallet must run MetaMask's EIP7702StatelessDeleGator v1.3.0 for this. A plain wallet (an EOA) gets it through an EIP-7702 authorization (below). The key stays the owner: the wallet keeps working as before, and one authorization to address 0 resets it.

What the owner signs#

The root's caveats#

CaveatEnforces, on chain
AllowedTargetsthe Universal Router is the only contract the session can call
AllowedMethodsonly execute(bytes,bytes[],uint256)
ValueLteat most this much ETH per trade (the per-trade cap, in wei at the grant's ETH price)
NativeTokenPeriodTransferat most this much ETH per 24-hour window (sessions that trade ETH)
Timestampnothing after the expiry
LimitedCallsat most this many trades
Redeemeronly the executor can redeem

The binding#

The root's salt is the hash of the session's limits, its binding. Every new grant is version 4, which binds:

  • the wallet, the executor and the expiry;
  • the tokens, and each token's per-trade cap in its smallest unit;
  • the dollar caps per trade and per day, and the number of trades;
  • the risk terms (below): the severe risks the session may trade with;
  • the fees it may pay (fees, see Fees);
  • a random nonce.

The SDKs rebuild the binding from what the owner asked for and refuse a grant whose binding, caps or caveats differ (GRANT_BINDING, GRANT_LIMITS, GRANT_CAPS, CAVEAT_*), before anything is signed. They price each token's cap themselves and refuse one more than 2% (plus the token's own fees) away from their own price. They also refuse a grant that names any co-signer other than the one they pin.

The authorization, on a plain wallet#

A plain wallet needs its code set to EIP7702StatelessDeleGator v1.3.0. This changes the wallet's code, which is the owner's decision: the SDKs do it only with allow7702: true (TypeScript) or allow_7702=True (Python), and otherwise refuse with CONSENT_REQUIRED. There are two ways it happens:

HowWhen it works
The first trade carries itthe grant signs an EIP-7702 authorization for the wallet's nonce at the grant, and the executor's first trade carries it as a type-4 transaction: the main key sends nothingonly while the wallet sends nothing before that trade. Any transaction from the wallet first (the setup below, a gas top-up for a hosted agent's executor, anything else) moves its nonce on, and the authorization can never be used. Granting again doesn't help: the new session's setup moves the nonce again.
The wallet sets it itselfone type-4 transaction from the wallet to itself, with an authorization to EIP7702StatelessDeleGator at its nonce + 1, sent straight to the sequenceralways. Once it is mined, the session needs no authorization at all, whatever the wallet sends later.

From SDK 0.1.1, sessions.setup(grant) does the second for you: on a plain wallet whose grant signed the authorization, its first transaction sets the wallet's code, and then it sends the setup. wallet.delegateCode() (TypeScript) or wallet.delegate_code() (Python), also from 0.1.1, does it on its own, at any time; on a wallet that already runs the DeleGator it does nothing.

await owner.wallet.delegateCode()   // from 0.1.1: one transaction from the wallet to itself; resetCode() undoes it

A session trade sent from a wallet that can't run the session's code (a plain wallet whose stored authorization is for another nonce, or that has none) is refused with SESSION_CODE before anything is co-signed, so it uses none of the session's trades or caps. Its fix says what to do: set the code, then trade again. The session itself stays as it is. A hosted agent isn't switched on or resumed while its wallet is in that state, and one that meets it while running pauses with the same SESSION_CODE reason.

With the 0.1.0 SDKs (orblivion 0.1.0, @orblivion/sdk 0.1.0): delegate_code and delegateCode arrive from 0.1.1, and sessions.setup sets a plain wallet's code only from 0.1.1. Sign the same transaction with the main key's account, send it straight to the sequencer, and wait for it to be mined before the wallet sends anything else (the setup included). owner.sequencer_url (Python) is the sequencer's URL; the TypeScript client has it as owner.sequencerUrl from 0.1.1, and on 0.1.0 it is the SDK's own SEQUENCER_URL constant (in its constants):

import { CHAIN_ID, STATELESS_DELEGATOR } from '@orblivion/sdk'

const account = privateKeyToAccount(OWNER_KEY)               // the main key, as the owner's client uses it
const n = await owner.rpc.nonce(account.address, 'pending')
const authorization = await account.signAuthorization({ address: STATELESS_DELEGATOR, chainId: CHAIN_ID, nonce: n + 1 })
const raw = await account.signTransaction({
  type: 'eip7702', chainId: CHAIN_ID, nonce: n, to: account.address, value: 0n, data: '0x',
  gas: 120_000n, maxFeePerGas: (await owner.rpc.gasPrice()) * 2n, maxPriorityFeePerGas: 0n,
  authorizationList: [authorization],
})
const hash = await owner.rpc.sendRaw(raw, owner.sequencerUrl)   // the sequencer, not a public RPC
await owner.rpc.waitReceipt(hash)

The setup, for token inputs#

ERC-20 tokens leave the wallet only through Permit2, so a session that sells a token needs a setup the main key sends: approve(Permit2, budget) and Permit2.approve(token, router, budget, expiry), each exactly the session's budget (by default setup_budget_usd, one day's limit). A curve session's setup is each input's approval to its curve instead, at most every trade at its cap. What is left of that budget caps what the session can spend of each ERC-20 on chain: trades spend it down, and the owner tops it up, at most to one day's cap again. ETH needs no setup. On a plain wallet, sessions.setup sets the wallet's code first from SDK 0.1.1; with 0.1.0, set it yourself first (above).

The setup, later#

Orblivion relays the grant's own setup for 30 minutes after the grant. After that, or after a restart, ask for it again: POST /api/v1/live/session/setup with session_id (the wallet's key, an active session) builds the setup as it stands now, from the session's own budgets, tokens and curves against the wallet's allowances, leaves out what is already in place, and is relayed for another 30 minutes. Its answer carries the roots the owner signed, so the SDKs hold every step to them.

From SDK 0.1.1, sessions.setup_steps(session_id) (Python) and sessions.setupSteps({ sessionId }) (TypeScript) fetch, check and send it. With the session's Grant (grant= / grant:) each step is held to the grant's own checks, and a plain wallet's code is set first as setup does; without it, each step is held to what the wallet signed: its root's tokens, per-trade caps and trades, the curves of its signed curve roots, and each budget at most setup_budget_usd (default the session's max_day_usd) at the price its signed cap implies. Both SDKs hold sessions.setup to the grant's own checks too, which a curve session or a token by address now passes.

await owner.sessions.setupSteps({ sessionId: grant.sessionId, grant })   // from 0.1.1

The budget, and topping it up#

The setup approves each ERC-20 the session sells once: Permit2 may move at most the session's budget of it, and only the Uniswap router may spend that, until the session ends. Every sale of the token spends it down, and nothing refills it on its own. The daily limit starts again every 24 hours; the budget doesn't. So once a hosted agent has spent its budget, it pauses with SESSION_BUDGET even though its daily limit has room again.

A top-up sets it back. POST /api/v1/live/session/top-up with session_id (the wallet's key, an active session) answers, for each of the session's ERC-20s, what is left on chain, its cap, what the session sold of it in the last 24 hours and when it runs out at that pace. For each token short of its cap it also answers the transactions that set the cap again:

  • Permit2.approve(token, router, cap, the session's end): the router's allowance, set to the cap whatever was left. It resets the allowance: it never adds to what is left;
  • token.approve(Permit2, cap), only when the token's own approval to Permit2 is short too (each sale spends both).

The cap is one day's cap at most, and never more than the budget the grant set. One day's cap is the per-trade cap the wallet signed (in the token's units, at the grant's price) times max_day_usd / max_trade_usd, rounded down. The expiry is never past the session's end. Why a day: if both of the session's keys were ever stolen, the approval left outstanding is the most of a token they could take on chain, so a top-up never lets that be more than one day's cap, however long the session runs. A top-up changes nothing else: no new session, nothing new for the session to sign.

It is one transaction from your own wallet. A wallet that runs EIP7702StatelessDeleGator (a session's wallet does once its setup is sent) makes both approvals in one call to itself, all or nothing: the answer's batch. The SDKs and the trading wallet send that. The agents page sends it as one batch from MetaMask's smart account, and as one or two approvals from a wallet that can't batch. The answer is simulated against your wallet's state, and /live/submit relays it for 30 minutes, and only while the session is active.

Which session, checked on your side. Every client holds a top-up to one session the wallet signed, never to the session Orblivion names alone (Orblivion's word is what a compromised server could change):

  • The SDKs (from 0.1.4) send a top-up only when it is pinned to the session: its Grant, its revocation record (revocationRecord(grant), grant.revocation_record(): keep it with the wallet's key, it holds no secret; a bot that restarts keeps its pin this way) or the root's hash. The answer's root, binding and end must be that session's. With the hash alone, which can't tell a token the session trades on its own curve, only the core tokens the SDK pins are topped up. A dry run without a pin checks everything else and says it wasn't pinned.
  • The agents page and the trading wallet take the newest session this browser signed for the agent's executor, as Orblivion's signing service attests it; Orblivion's session id must name exactly that one. An older session of the same agent, another agent's session, or one this browser didn't sign is refused (the trading wallet needs the root it kept; the agents page, without one, takes only a session at the limits and length you chose there).
  • The root is read on chain: disabledDelegations on every RPC the client has. A revoked root is refused, and so is one any RPC can't read.

Then each step's token, spender, amount and expiry are taken from its own calldata and held to what the wallet signed: the root carries the wallet's own signature, its salt is the hash of the binding, the cap comes from that binding, the spender is the pinned Permit2 or router, and the expiry is at most the session's end. The answer's own numbers are never used. The batch is built on your side and compared byte for byte, and the allowances are read back afterwards. With the session's Grant, the steps are also held to the grant's own budget. Then resume an agent paused for its budget (the agents page and the trading wallet read it again and resume it for you).

const r = await owner.sessions.topUp({ sessionId: grant.sessionId, grant })   // from 0.1.4
// or, after a restart: topUp({ sessionId, record }) with the record you kept
console.log(r.nothingToTopUp, r.caps, r.after, r.confirmed)
await owner.hosted.resume(agentId)                                             // if it paused SESSION_BUDGET

One allowance per wallet and token. Permit2 keeps one allowance for each wallet, token and router, so every live session of a wallet that sells the same token spends the same one, and the last cap set holds for all of them: a setup or a top-up of one session sets the others' too, up to its own cap and until its own end. A top-up while another active session of the wallet sells the same token is refused (SESSION_BUDGET_SHARED, naming that session) unless you confirm it naming them (confirm_shared; the SDKs' confirmShared / confirm_shared). The simplest is one live session per wallet and token: stop the agent you no longer use and revoke its session first. An allowance above a session's own cap shows on its dashboard as set by its setup or by the other session, not as "running low".

At most one day's cap per confirmed top-up. A top-up resets to one day's cap; a second one later lets the session spend up to another day's cap. So a second top-up within 24 hours of the last asks you again: Orblivion answers TOPUP_AGAIN (when the last one landed on chain or was relayed, and what it set) unless the request says again: true, the SDKs refuse one their client sent in the last 24 hours unless you pass again, and the agents page and the trading wallet keep the last one they sent (from the moment it goes out, so one the chain spends at once still counts) and show it before you confirm another. Orblivion counts one as landed when the chain shows an approval since it was built, or the wallet has sent a transaction since. The trading wallet always shows what it would set, decoded from the calls, and signs only once you confirm exactly that.

The same numbers are on a hosted agent's dashboard, for its owner only: what is left of each budget and how long it lasts at its pace. It warns under 25% of the cap or under a day of the session's recent spend, with a Top up budget button on the agents page and in the trading wallet. A session ending within five minutes isn't topped up (SESSION_EXPIRY): grant a new one.

Grant a session#

import { CHAIN_ID, STATELESS_DELEGATOR, createOrblivionClient } from '@orblivion/sdk'
import { privateKeyToAccount } from 'viem/accounts'

const account = privateKeyToAccount(OWNER_KEY)
const owner = createOrblivionClient({ account })                                     // the main key
const executor = createOrblivionClient({ account: privateKeyToAccount(AGENT_KEY) })   // the agent's hot key

const grant = await owner.sessions.grant({
  executor: executor.address,
  maxTradeUsd: 20, maxDayUsd: 60, maxTrades: 50, hours: 24,
  allow7702: true,                 // the owner's consent to set the wallet's code
})
// SDK 0.1.0 only: a plain wallet's code, set by the wallet itself before the setup (from 0.1.1, setup does it)
if ((await owner.rpc.code(account.address)) === '0x') {
  const n = await owner.rpc.nonce(account.address, 'pending')
  const authorization = await account.signAuthorization({ address: STATELESS_DELEGATOR, chainId: CHAIN_ID, nonce: n + 1 })
  const raw = await account.signTransaction({ type: 'eip7702', chainId: CHAIN_ID, nonce: n, to: account.address, value: 0n,
    data: '0x', gas: 120_000n, maxFeePerGas: (await owner.rpc.gasPrice()) * 2n, maxPriorityFeePerGas: 0n, authorizationList: [authorization] })
  await owner.rpc.waitReceipt(await owner.rpc.sendRaw(raw, owner.sequencerUrl))   // the sequencer
}
await owner.sessions.setup(grant)  // the setup for a token it sells, such as USDG, and from 0.1.1 a plain wallet's code

const t = await executor.sessions.trade({ sessionId: grant.sessionId, session: grant, sell: 'ETH', buy: 'USDG', amountUsd: 5 })
console.log(t)

Over the API, a grant takes two calls to POST /api/v1/live/session/grant.

1. Start it, with the main key's API key:

FieldDefaultMeaning
walletrequiredthe owner's wallet (the key's)
executorrequiredthe executor's address; not the wallet, not the co-signer
tokens["ETH", "USDG"]the tokens the session may trade: core symbols or addresses, at least two
max_trade_usd25the most one trade may spend: at least $1.01, a cent over the $1 minimum order, as the co-signer counts USDG at Chainlink's USD, at times a hair over $1 (sessions granted earlier keep theirs); recommended at most $1,000 (past it, accept_risks names BEYOND_DEFAULTS)
max_slippage_bpsnone (300)the most slippage any of the session's trades may ask, signed in its binding: Orblivion's engine holds every trade's slippage to it; the co-signer holds the slippage a trade states to it, and its own price floor follows it past 300 (under 300 its floor stays at 3% under its own price). 1 to 9,999; past 300, accept_risks names BEYOND_DEFAULTS
max_day_usd100the most per 24 hours; from max_trade_usd to 100 times it
max_trades50from 1 to 10,000
expires_in_s86400from 60 seconds to 30 days; at most 24 hours when a token has no Chainlink feed (ORBIO, and any token by address whose price reference isn't one), counted from when the co-signer registers the session. ORBIO's may run longer when accept_risks names BEYOND_DEFAULTS and the co-signer reads its reference pool's TWAP at registration and on every trade; a token by address's may not. ORBIO's mark still holds: after a move of about 10% one side waits until you renew
setup_budget_usdmax_day_usdthe ERC-20 budget the setup approves; spent by trades, then topped up to at most one day's cap
accept_risksnonethe session's risk terms

The answer is a pending session and everything the main key signs: sign.delegation (the EIP-712 typed_data, its digest, the delegation_hash and the binding), sign.authorization for a plain wallet, sign.curve_roots for curve tokens, the setup steps, caveats with what each means, the limits, risk_terms, on_chain_bounds, exposure (approvals the wallet has outside the session, which it should revoke) and not_enforced_on_chain.

2. Switch it on: the same route with session_id, delegation_signature, and authorization_signature (plain wallets) and curve_root_signatures ({delegation_hash: signature}, curve tokens). Orblivion recovers each signature, the co-signer registers the root after checking it against the binding itself, and the session is active.

Trade in a session#

POST /api/v1/live/session/trade with the executor's (or the wallet's) API key:

JSON
{"session_id": "ses_...", "token_in": "ETH", "token_out": "USDG", "notional_usd": 5}

It also takes amount_in, slippage_bps, min_amount_out, route_id and fund. It doesn't take a fee or risk terms: those are the binding's, and a request that names other accept_risks is refused (SESSION_TERMS).

Orblivion checks the session (each a checks entry, and a refusal with that code when it fails):

CheckRefuses when
SESSION_PENDING, SESSION_REVOKED, SESSION_EXPIRED, SESSION_EXPIRYthe session isn't switched on yet, was revoked, or has ended or is about to (409)
SESSION_BOUNDthe stored binding doesn't hash to the root's salt (409)
SESSION_TOKENSa token outside the session
SESSION_TRADES_LEFTthe session's trades are used up
SESSION_MAX_TRADE, SESSION_MAX_DAYover the per-trade cap, or the 24-hour cap counting every co-signed trade, sent or not
SESSION_TARGET, SESSION_RECIPIENTSthe swap isn't a router execute, or pays anyone but the wallet, the router or the fee recipient
SESSION_SETUPa token input without the setup in place
SESSION_CODEwith fund: false (a trade to send): the wallet doesn't run EIP7702StatelessDeleGator and the session's stored authorization can't set it (above); checked before anything is planned or co-signed (409)

Then the co-signer checks the trade again on its own and co-signs the leaf. The answer carries the executor's transaction (tx: redeemDelegations to the DelegationManager, type 4 when it carries a plain wallet's authorization), the leaf with its caveats, the decoded execution and swap, its simulation, spend (last_24h_usd, remaining_24h_usd, trades_used, trades_left) and the disclosures. ready is true when it can be sent as it is. The executor signs it and sends it through POST /api/v1/live/submit.

From SDK 0.1.1, a dry run's result says so too: its ready is Orblivion's, and each check Orblivion failed (a SESSION_CODE the real trade would be refused for, say) is added to its checks, so a dry run never reads clean when the trade can't be sent.

The leaf lasts at most two minutes, once (LEAF_EXPIRY, LEAF_ONCE). Its expiry is enforced on chain against block time, so the SDKs read it against the executor's own clock and, when that reads it out of bounds, against the chain's clock over the executor's own RPC (from 0.1.1): an executor whose clock is off by half a minute or more still trades, and the result's CLOCK check says by how much. The bound itself doesn't move: two minutes and 30 seconds of block time at most. Orblivion likewise reads the co-signer's leaf against its own clock when the leaf arrives, so a slow read before the co-signer was asked doesn't refuse a leaf it already counted.

A token still on its Pons curve trades in a session too, through more roots the owner signs at the grant: a curve root, and one fee root for each token its trades pay the fee in. Each trade is one redeemDelegations of two redemptions, which land together or not at all. The fee is paid in the pair (ORBIO or ETH, which outrank the token; see which token pays the fee), so an ORBIO-paired token needs one fee root, in ORBIO: a buy redeems the fee and then the curve call, and a sale the curve call and then the fee, exactly floor(min_out × bps / 10,000) of the sale's guaranteed minimum. The SDKs and the co-signer refuse any other set of roots (CURVE_ROOT_SET).

What the co-signer enforces#

The co-signer is a separate service from the API, with its own key, its own price readings and its own records. It takes structured requests only, never a raw digest, and before each leaf it checks the trade with the Python SDK's own decoder and rules, not the API's code:

  • the call is the pinned Universal Router's execute, and every recipient is the wallet or the router, except exactly one fee payment to the fee recipient, of a fee the binding allows for the leaf's class, which the co-signer reads itself from the leaf's two tokens;
  • that fee is in the token and on the side the fee currency rule gives, and in its place: from the input right after the router receives it and before any swap, or from the output after the last swap (FEE_TOKEN, FEE_SIDE, FEE_ORDER);
  • nothing is left in the router, the tokens and hooks are allowed, and the minimum output is above zero;
  • the minimum output is at most max(slippage, 300 bps) under the input's value at its own Chainlink reading, or, for a token without a feed, at most 1,000 bps (plus the curve's fee and creator tax) under the price the owner signed. With no fresh reading it refuses (PRICE_UNAVAILABLE);
  • the per-trade, per-24-hour and trade-count caps, which it counts itself by root;
  • the risks reported for the trade are all accepted by the binding.

Anything else is refused and logged. Its operator can freeze it outright, and then it signs nothing.

Risk terms#

An agent can't accept risks on its owner's behalf. In a session, accept_risks is set at the grant and bound into the root's salt:

JSON
{"wallet": "0x...", "executor": "0x...", "max_trade_usd": 20, "max_trades": 10,
 "accept_risks": ["HIGH_PRICE_IMPACT"]}
  • Every trade takes its terms from the binding, never from the request. Neither a prompt-injected agent nor a stolen executor key can widen them.
  • The fees follow the binding (below).
  • Sessions granted before binding version 3 keep working with the strictest reading of what was signed: no risk accepted, and schedule 1's 10 bps. Such a session trades an Orbio agent or Pons token only when its owner listed it in allow_unverified at the grant, and never a token Orblivion has no record of (TOKEN_UNVERIFIED).

Fees#

A version 4 binding names the fees the session may pay:

JSON
"fees": {"major_max_bps": 25, "major_min_bps": 10, "other_bps": 50}

Any other value is refused.

  • A trade is major when both of its tokens are majors, and other otherwise (see Fees and gas). The co-signer reads each leaf's class itself, from the leaf's two tokens and its own on-chain stock check, and ignores the server's.
  • A major leaf pays one of the pinned tiers between major_min_bps and major_max_bps: the wallet's volume tier, from 0.25% down to 0.10%.
  • An other leaf pays exactly other_bps.
  • A curve token is always other, so a curve session's fee root caps its fee transfers at other_bps.
  • The SDKs, the relay and the co-signer each check the fee against the binding.

Sessions granted before schedule 2 (binding versions 1 to 3) keep schedule 1's one fee, 10 bps, on every leaf until they expire.

Limits#

LimitValueEnforced by
ETH per tradethe per-trade cap at the grant's ETH pricethe chain (ValueLte)
ETH per 24-hour windowthe day cap, in fixed windows from the grantthe chain (NativeTokenPeriodTransfer)
ERC-20swhat is left of the budget the setup approved; a top-up sets it back to at most one day's capthe chain (Permit2)
Number of trades, expiry, target, method, redeemeras signedthe chain
Dollars per trade and per 24 hoursas signedOrblivion and the co-signer, each counting
A new session's dollars per tradeat least $1.01, a cent over the $1 minimum order: the co-signer counts USDG at Chainlink's USD, at times a hair over $1 (sessions granted earlier keep theirs)Orblivion, at the grant and when a hosted agent attaches it
Recipient and minimum outputthe co-signed leaf's exact callthe chain, through the leaf
Priceat most max(slippage, 300 bps) under its own referencethe co-signer
A leafone exact call, at most two minutes, oncethe chain
Session length30 days; 24 hours with a token without a Chainlink feed (ORBIO: longer with BEYOND_DEFAULTS)Orblivion and the co-signer

The grant's not_enforced_on_chain lists what the chain alone doesn't bind: the output's recipient and the minimum output (the co-signed leaf binds them), the dollar cap per day for anything but ETH, the ERC-20 amount per trade, and which tokens are bought.

Revoking#

POST /api/v1/live/session/revoke with session_id (the wallet's key):

  • At once, at Orblivion: the co-signer co-signs nothing more for the session. A leaf already issued still works, once, until its two minutes run out.
  • On chain, the answer's on_chain steps for the main key to send: disableDelegation(root), which makes the DelegationManager refuse every later redemption, and the setup's approvals (and any curve allowances) back to 0. The answer also shows the session as Orblivion reports it (executor, delegation_hash, curve_roots); they come from the same answer as the steps, so only a client that kept the session's revocation record can check them. With reset_code: true it also describes the authorization that resets the wallet's code, sent after those steps: its nonces count past them (after_steps). The SDKs' wallet.reset_code() signs it when it is sent, at the wallet's nonce then.

The on-chain part needs nothing from Orblivion once you hold the session's complete, current revocation record (below). The record has the root the wallet signed, the chain says what is left, and the wallet's key alone sends the steps. Without the record, only Orblivion holds the signed root (and, once the session has traded, its transactions' data). From SDK 0.1.3 (orblivion 0.1.3 on PyPI, @orblivion/sdk 0.1.3 on npm), the SDKs build those steps themselves from that record, so a revoke ends the session on chain even when Orblivion's API is down or answers wrongly. SDKs up to 0.1.2 take them from Orblivion's answer, so with those a revoke on chain needs the API to answer; resetting the wallet's code needs nothing from Orblivion in any SDK.

import { revocationRecord } from '@orblivion/sdk'

const record = revocationRecord(grant)                                // at the grant: keep it with the wallet's key
await owner.sessions.revoke({ sessionId: grant.sessionId, record })    // the chain first, from the record, then Orblivion
await owner.sessions.disableOnchain(record)                            // the chain only: no call to Orblivion at all

The revocation record#

The record is JSON: the session's id, wallet, executor, co-signer and expiry; every root the wallet signed for the session, each with the wallet's signature and its hash (a curve session's curve and fee roots too); the limits the main root's salt binds; and what the setup approved (each ERC-20 to Permit2, Permit2's allowance for the Universal Router, a curve session's curve approvals). It holds no secret: a root is useless without the executor's key and Orblivion's co-signature. Store it next to the wallet's key, where nobody else can edit it: the SDK can't detect a root or approval removed from it, or an older session's record put in its place. The starter bot writes it into session.json, the AI agent guide into agent.json.

revoke with the record, and disable_onchain (disableOnchain):

  1. Check the record before anything is built from it. The checks prove that each part is this wallet's and exactly what it signed, not that the record is complete or current:
    RuleWhat it holds
    RECORD_FORMATa version 1 revocation record for Robinhood Chain and the pinned DelegationManager; from JSON text, whole numbers only (at most 2^53 - 1)
    RECORD_WALLETit is this client's wallet's
    RECORD_ROOTevery root is from the wallet, delegated to the record's co-signer, with its own hash
    RECORD_SIGNATUREevery root's signature recovers to the wallet
    RECORD_REDEEMERevery root's only redeemer is the record's executor
    RECORD_BINDINGthe main root's salt is the hash of the record's limits, and they name the same wallet, executor and expiry
    RECORD_CURVE_ROOTeach curve or fee root's salt binds it to the main root
    RECORD_SETUPevery approval it resets follows from what the wallet signed, to the pinned Permit2 and router
    RECORD_SESSION(revoke) the record's session_id is the one asked for. It compares an unsigned label: nothing the wallet signed binds it
  2. Read the chain on every RPC the client has (two by default), each on its own: DelegationManager.disabledDelegations(hash) for every root, the approval to Permit2 and Permit2's allowance for the router of every non-ETH token the main root's limits name (not only the record's setup list), and the curve allowances (every one the record's curve roots imply, not only its setup list). A root counts as disabled only when every RPC says so: one that says live, or fails, makes it live, and its disable is sent. An allowance is the largest any RPC reports, and one that can't be read counts as left. When no RPC answers, nothing is sent and it raises. The reads trust the RPCs: if every RPC agrees on a wrong answer, the outcome can be wrong; with fewer than two RPC host names it is never confirmed. The sends (step 3) take nothing from one RPC alone, so one RPC that answers wrongly can't keep a step from landing while another answers right.
  3. Send the steps, built here in the server's own shapes, straight to the sequencer, not through Orblivion's relay, each on its own: first disableDelegation of each root still live, then approve(Permit2, 0) where an approval is left, Permit2.lockdown where the router's allowance is live, a curve's approval back to 0. Each is checked on its own as Orblivion's would be, against the off switch's own gas cap (0.01 ETH a step, or max_gas_wei when that is higher), and sized from the largest gas estimate any RPC gives, plus 30%, at least 150,000 gas for a disable (one takes about 94,000 to 100,000 on Robinhood Chain); a step none of them can estimate is sent at a fixed gas, and the chain decides. It is signed at each RPC's pending nonce, lowest first, and at each RPC's gas price, highest first (a nonce the sequencer refuses isn't tried at another price), until the sequencer takes it or six tries are refused (a step pays the block's base fee, not its maximum); the balance an RPC reads never stops it, and its receipt is the first any RPC shows. One that fails (a paused token's approve, say), or that its own checks refuse at every price, is reported in its status, and the others still go.
  4. Ask Orblivion (revoke only), after the steps were sent, so a compromised Orblivion learns of the revoke only once the root's disable has gone out. Anything going wrong there, or no answer within a deadline (api_timeout_s, apiTimeoutMs), is api_error (apiError), and changes nothing on chain. A root its answer names that the wallet signed and that binds to the main root's salt is disabled too (at most 32 of its disables are looked at). A dry run (dry_run=True, dryRun: true) signs and sends nothing and doesn't ask Orblivion at all: its status is not_asked.
  5. Read it back on every RPC: on_chain (onChain) status is confirmed only when every root and approval in the record (and any Orblivion named that bind to it) reads done at the latest block of every RPC, read on at least two different RPC hosts, with Orblivion's answer naming no other root as the session's. Otherwise it is unconfirmed, with detail saying why. Run it again to retry: it starts from the chain's state. Two URLs of one host (a trailing dot, an IP address written another way) count once; two different names for one machine still count as two. from_record (fromRecord) says what the record alone reads, without what Orblivion's answer adds: when only Orblivion's answer keeps the outcome unconfirmed, a rerun won't change it, and disable_onchain (disableOnchain) gives the record's own answer. Don't take the record's word when Orblivion's answer carries a root your wallet signed that still reads live: then the record is most likely an older session's. The SDKs don't: such a root keeps from_record unconfirmed too, and is listed in signed_live (signedLive). A hostile Orblivion can't make one up, but the wallet's signature doesn't say which of the wallet's sessions a root is, so the SDKs disable it only when asked: disable_signed=True (disableSigned: true).

With revoke, Orblivion's own on-chain steps are compared with the record, never sent: api_steps (apiSteps) counts the ones that are the record's own and lists any extra (a disable of a root the wallet's signatures don't tie to this session, an approval it doesn't call for) and any missing (a root of the record its answer doesn't disable, a step that failed here that it left out). Its answer comes after the record's steps went out, so it no longer needs the resets they made.

Without a record, revoke asks Orblivion first (so even a dry run revokes the session there: Orblivion's answer is the only source of its steps) and sends its steps, each checked as before and all checked before any is signed, straight to the sequencer. It refuses a type-4 step, one that would carry an EIP-7702 authorization (REVOKE_TYPE), and a disable of any root that isn't this session's as Orblivion's answer shows it: signed by this wallet, delegated to the pinned co-signer, its only redeemer the session's executor, its hash one of the answer's (REVOKE_ROOT). The result says server_built (serverBuilt). Orblivion's answer chose the roots on_chain reads back, so "confirmed" there would only be Orblivion's word: the status is at best server_reported. An answer that doesn't show the session (a server from before it did) has its disable refused: pass the record.

The emergency switch: reset the wallet's code#

wallet.reset_code() (resetCode()) makes the wallet a plain account again: one type 4 transaction from the wallet to itself, with an EIP-7702 authorization to address 0, sent straight to the sequencer. It needs nothing from Orblivion and no record, in every SDK.

await owner.wallet.resetCode()

Measured on a local fork of Robinhood Chain:

After reset_code
A session's tradecan't run: the DelegationManager runs a redemption through the wallet's code, and there is none. A redemption Orblivion had already co-signed reverted when the executor sent it, and the wallet's balances didn't change. Orblivion refuses new session trades (SESSION_CODE).
An authorization signed earlier (the grant's)can't set the code again: its nonce has passed.
The session at Orblivionstill active, but Orblivion refuses its trades (SESSION_CODE), and a co-signature couldn't run.
The session's root on chainnot disabled.
The approvalsleft as they were: the ERC-20 approval to Permit2 and Permit2's allowance for the router. Only the wallet's own transactions can use them: the router pulls from whoever calls it, and Permit2 lets only the approved spender move them, so another address's Permit2.transferFrom and router PERMIT2_TRANSFER_FROM both reverted.
Setting the code again(delegate_code(), a later session's setup, or any wallet app that delegates the account to EIP7702StatelessDeleGator again) brings back every root not disabled, until it expires: the session traded again.

So reset the code when you want no session to run at all, at once, with the wallet's key alone, and revoke as well: disable_onchain(record) works from a plain wallet too.

If a key is stolen#

StolenWhat the thief can move
The executor keynothing beyond trades the co-signer co-signs: each leaf is one exact call, once, for two minutes, paying the wallet. The executor's own ETH (its gas money) is exposed.
The co-signer's keynothing: only the executor can redeem.
Bothper 24-hour window, at most min(ETH per trade × trades left, the day cap) of ETH, plus what is left of each ERC-20 budget (one day's cap at most, for a session granted with the default budget or topped up), to any recipient and at any price, until the expiry or a revoke. The windows are fixed from the grant, so up to twice the day cap can move across a window boundary. A curve session adds trades on that token's own curve, always paying the wallet but at any price, up to its curve approval.
The main keyeverything in the wallet. A session doesn't change that.

Plainly: without the value guard, no contract checks the recipient or the minimum output of a Universal Router swap. The co-signer's leaf binds them, so the executor key alone gets nothing. With both keys stolen, the root's caveats are the bound. So keep sessions short and caps small, keep the executor's gas money small, and revoke on any suspicion.

The value guard#

New, and not yet independently audited. Off unless you ask for it. It adds one caveat to the root: Orblivion's ValueGuardEnforcer, at 0x378d3bcb146c3f52dc9f3860637546453adcbc45. On every trade it reads the wallet's balances of the session's tokens before and after, values the change at their Chainlink feeds, and reverts unless the wallet got back at least the value that left it, less your tolerance (1% to 10%, 3% by default, fees included). An optional dollar budget caps what the whole session may lose. So with both session keys stolen, a trade that pays someone else, swaps through a pushed pool or buys a token outside the session reverts on chain, whoever sends it.

Python
grant = owner.sessions.grant(executor=executor.address, max_trade_usd=20, max_day_usd=60, max_trades=50, hours=24,
                             value_guard=True)
# or value_guard={"max_loss_bps": 200, "max_total_loss_usd": 25}

In TypeScript it is valueGuard: true (or { maxLossBps, maxTotalLossUsd }), and a hosted agent's session takes it too. On the agents page and in the trading wallet it is a checkbox on the session form, offered once its contract is on Robinhood Chain.

Before anything is signed, the SDKs and the pages refuse a guarded session when:

CodeWhy
VALUE_GUARD_FEEDa session token has no pinned Chainlink feed. Today: ETH, WETH, USDG, cbBTC, NVDA and SPY; not ORBIO, a token on its curve or a token by address
VALUE_GUARD_CODEits contract isn't at that address on this chain
VALUE_GUARD_EXPOSUREthe Uniswap router can still pull another pinned token from the wallet through Permit2. The guard counts only the session's tokens, so close those allowances first: the pages offer one transaction that only takes allowances away
CAVEAT_VALUE_GUARDthe root Orblivion built doesn't end with exactly the guard you asked for, or carries one you didn't

What it doesn't do:

  • It trusts Chainlink. A feed lags the market a little, and one older than a day and ten minutes refuses the trade rather than pricing it.
  • Without a budget, each trade may lose up to the tolerance.
  • It covers this session's root only: another session or a curve session on the same wallet without it is outside it.
  • VALUE_GUARD_EXPOSURE reads the pinned tokens only, once, at the grant: a router allowance on a token by address, or one you give the router later (say, trading in Uniswap's app), lets the router pull that token outside what the guard counts.
  • Closing an exposed allowance stops anything else that spends that token through the router, your other agents included, until it is approved again.
  • It costs about 86,000 more gas a trade.

Costs#

A session trade costs more gas than a direct one: about 557k gas against 207k, roughly two cents at today's prices, because the DelegationManager checks every caveat. The first trade from a plain wallet adds a little for the authorization; setting the code from the wallet itself instead is one small transaction the main key pays for. The executor pays the gas of the trades.