TrussDocs

Architecture

Tracked sub-accounts

How tracked sub-accounts hold only registered tokens, price each with an on-chain oracle, and check every swap and loan against their policies.

A tracked sub-account holds tokens on the vault's own chain and values them itself, from on-chain prices. Nobody reports its value. It holds only registered tokens, and it acts only through modules, whose every action is measured and checked against oracle prices.

Key points

  • A tracked sub-account values only registered tokens, each priced through an adapter on the vault's price oracle.
  • Every swap and loan runs through a module, and the sub-account measures what left and arrived.
  • An action that loses more than its tolerance, or that needs a stale price, is refused.
  • A stale price on any held token makes the whole vault's NAV stale until it recovers.

The asset registry

The asset registry lists the tokens each tracked sub-account may hold. USDC is registered for every sub-account. The VaultAdmin registers another token with registerAsset, which waits the CRITICAL tier and needs a working price adapter first. How many tokens one sub-account, and all of them together, may register is fixed at deployment.

Removing a token takes two immediate steps, held by vault managers and the VaultAdmin. initiateDeregistration stops the sub-account adding to it, though a withdrawal from a lending venue into it still works. finalizeDeregistration completes once the sub-account holds none of it.

A token sent straight to the sub-account is never counted in NAV. The VaultAdmin can send it out with rescueTokens.

Oracles

Each vault's price oracle points every asset to an adapter and its parameters. Adapters hold no state, so every vault on a network shares them.

AdapterWhat it prices
ChainlinkA token with one USD price feed
Chainlink crossA token priced through two feeds, such as WBTC/BTC times BTC/USD
ERC-4626Lending venue shares, at the venue's own conversion, times the price of its asset
Coinbase equityA tokenized stock; see Tokenized stocks

Binding an adapter to an asset waits CRITICAL; removing one is immediate. Both are the VaultAdmin's.

When is a price stale?

A price is stale when its answer is zero or negative, carried over from an earlier round, dated in the future, or older than the asset's heartbeat plus 90 seconds. On Base, every price is also stale while the sequencer is down and for an hour after. A missing adapter reads as stale.

A stale price on a held token makes the vault's NAV stale. Settlement, instant withdrawals and fee changes wait; requests, cancellations and claims still work. An action needs fresh prices for its own two tokens only.

Modules

A vault manager, the VaultAdmin, or a trader the sub-account names calls executeModule. The swap module trades one token for another through a router. The lending module supplies to, and withdraws from, an ERC-4626 venue whose shares are registered. Modules hold nothing between calls. The VaultAdmin adds a module after CRITICAL, and removes one at once when the sub-account holds nothing but USDC.

How an action is checked

  1. The sub-account checks the shape: one token in, one registered token out, no more than it holds, and no call to the vault's contracts. The policy checks the tolerance against its ceiling.
  2. The module runs the trade, and the sub-account takes back everything the module holds of either token.
  3. The sub-account measures what it spent and received from its own balances, at oracle prices. If value out is below value in less the tolerance, it refuses with OutcomeBelowTolerance.
  4. The policy meters the action against its rate limits, and the sub-account books the new balances.

Each swap policy's tolerance ceiling is fixed when it is created, with no factory cap. The factory caps the lending ceiling. The committed preprod Base config uses 1% and 0.01%.

What the checks do not catch

A fresh price is not proof of a fair one, and small losses within tolerance add up. A venue that hides a loss in its conversion rate is valued at that rate until the position is withdrawn. Reviewing each asset and venue before it is admitted covers these.

Where to read more

PageWhat it covers
Rate limitsThe buckets each action draws on
Sub-account policiesWhere each policy is called
NAV parametersHow NAV is put together
Onboard an assetAdding a token after launch