Skip to main content
Settlement lets an approved settler, through its executor, use the deposit contract’s tokens atomically: one token leaves the deposit contract, the executor performs its onchain logic, and the expected token returns to the deposit contract.

Flow

  1. Discover deposit contracts and assets through OMS registry endpoints, especially GET /registry/vaults.
  2. Build and sign a settlement init request.
  3. Submit POST /settlement/init.
  4. Read the approval from the POST /settlement/init response. To recover it, the settler calls GET /settlement/signatures/{user_id} with its own public key and token.
  5. The settler’s executor calls executeAtomicSettlement(...) on the deposit contract.
  6. Reconcile the deposit contract Settled event and OMS inventory/account events.

Raw init

Settlement request amounts are base-10 integer strings in 18-decimal units, without a 0x prefix. Use the live OMS reference for exact current wrappers. Populate signature with the Ed25519 signature bytes over compact inner, in the field order shown, before sending. nonce is required; settler and expires_at are always part of the signed bytes, as null when unset.
inner.nonce is the settlement nonce, required and signed. It must not be below the next settlement nonce for that (user, sub_account, chain) or collide with an in-flight lock, and the deposit contract accepts a nonce at or above settlementCounts(user, account), then sets that counter to nonce + 1. The outer nonce is deprecated; if you send it, it must equal inner.nonce. expires_at, when set, is in unix nanoseconds; the request is refused after it. max_fee bounds the rebalancing fee the outgoing leg may reserve, as a base-10 string in 18-decimal units of asset_out; null accepts whatever the protocol reserves. It is part of the signed payload from protocol_version 3 on ("max_fee":null when unset), so an older layout cannot carry one. A request priced above its bound is rejected before any lock with code FEE_ABOVE_MAXIMUM.

tpluspy

Approval delivery

POST /settlement/init returns an approval object on success. Before retrying, fetch approvals as the named settler (the account owner if the request omitted settler). Use the REST response or the signatures endpoint as the public integration path. For a synchronous fill, the maker acting as settler receives the approval on /sync/pending-fills.

Onchain execution

The caller must be one of the executor addresses registered for the settler id. The deposit contract verifies expiry, settler approval, executor binding, settlement nonce, and the settlement approval signature. It sets the counter to the signed nonce plus one, transfers tokenOut to the executor, and calls:
After the callback returns expectedAmountIn, the deposit contract pulls that exact amount of tokenIn from the executor with transferFrom. The executor must approve the deposit contract for at least the returned tokenIn amount before or during callback execution.
To execute several approved settlements in one transaction, call executeBatchSettlements(requests, data, settler) instead. Each request pairs an order with its approval signature, the deposit contract nets the token transfers across the batch, and it calls onAtomicSettlement once per settlement with the matching data entry.