AAVE V3 leg
What each function of the AAVE V3 leg does, who may call it, when, and what it checks.
AaveV3Leg. One code for every AAVE V3 family market and every asset: the strategy’s long, an AAVE V3 position (its asset profile’s token supplied, USDC borrowed, or USDS converted to and from USDC at par by Sky’s PSM wrapper on the owner’s PSM debt route) held by this contract, behind the member proxy and the kernel, whose code only its owner moves. The market (its pool, its repay-with-collateral receiver, its sequencer feed, its rewards path, the widest price bound an owner may sign there, how a reserve’s withdrawable cash is read: the pool’s virtual accounting on AAVE 3.1 and later, the underlying the aToken holds on AAVE 3.0 and its forks, and the USDS route’s pair where it has one) is fixed when the code is deployed; the asset is the instance’s stored profile, fixed at the creation. The run’s execution key operates it within limits the owner signed: the health floor after every borrow, withdrawal and e-mode change; every sale of collateral bounded per call against the oracle’s rate-adjusted price and charged to a 24-hour loss budget; money only to the strategy’s other members. While it is unwinding or revoked, anyone may drive its unwind by fixed rules: the debt repaid first, then the collateral sold within a band and everything sent to the hub. On another chain than its hub it reaches the hub through Circle, and obeys the hub’s messages there. On another chain than its hub it also obeys its owner’s own signature, relayed by anyone (or the owner’s call there): Allow (bound to the leg’s count of stops) and its own settings, in force when set; the owner’s Stop reaches it through its kernel. It takes its owner’s run (its signed Run, beside its hub or not), only above the one it records and only with no debt. Its sales and profile checks run in the market module (AaveV3LegMarket), its unwind’s parts and the key’s repay in the unwind debt module (AaveV3LegUnwindDebt), its unwind’s steps, the move home and the key’s sends in the unwind residue module (AaveV3LegUnwindResidue), its readings, report, Circle mints, limits and borrow in the readings module (AaveV3LegReadings), its rewards path and the checks of its pool set and AAVE’s source in the rewards module (AaveV3LegRewards), the key’s lever and AAVE’s flash-loan callback in the lever module (AaveV3LegLever), the owner’s entries in the legs’ owner module (LegOwner, the module of every selector the others do not claim); its upgrades, the owner’s Stop and the transfer of its ownership are the kernel’s.
The other contracts, and every caller on one table, are on the overview.
The owner’s wallet, by signature
A message signed by the member’s owner, one wallet: an ECDSA signature on every chain or, on Ethereum only, ERC-1271 for a contract wallet. Anyone may submit the transaction; submitting it gives no power, the signature does.
allowSigned
function allowSigned(
OwnerMessages.Allow calldata m,
bytes calldata sig
) externalAs allow, by the owner’s signed Allow relayed by anyone.
Who may call: Anyone, relaying the owner’s signature.
When: After a stop.
Parameters
| Name | Type | Description |
|---|---|---|
m | OwnerMessages.Allow | The owner’s signed Allow, naming this member’s chain id and address. |
sig | bytes | The owner’s signature of m (EIP-712 domain “DLTX Owner”, version 1, no chain id). |
What it checks
- Named to this member on this chain (
NotNamed) at its owner generation (StaleGeneration), the deadline not passed (Expired), the owner’s signature: ECDSA, or ERC-1271 when the owner is a contract on this chain (NotOwner). - Its nonce above the last one used here (
StaleNonce); gaps are allowed, so using it voids every older one unused. runEpochthe run the leg records, 0 before any (WrongRun).- The leg’s count of stops is the message’s
stopCount(StaleStop).
setSettingSigned
function setSettingSigned(
OwnerMessages.SetSetting calldata m,
bytes calldata sig
) externalAs setSetting, by the owner’s signed SetSetting relayed by anyone.
Who may call: Anyone, relaying the owner’s signature.
When: Outside an unwind.
Parameters
| Name | Type | Description |
|---|---|---|
m | OwnerMessages.SetSetting | The owner’s signed SetSetting, naming this member’s chain id and address. |
sig | bytes | The owner’s signature of m (EIP-712 domain “DLTX Owner”, version 1, no chain id). |
What it checks
- Named to this member on this chain (
NotNamed) at its owner generation (StaleGeneration), the deadline not passed (Expired), the owner’s signature: ECDSA, or ERC-1271 when the owner is a contract on this chain (NotOwner). - Its nonce above the last one used here (
StaleNonce); gaps are allowed, so using it voids every older one unused. - Not unwinding (
Unwinding); a profile only at a leg on another chain than its hub (NotHere). - A key of this leg’s type (
Unsupported), the value within the bounds (BadParams; a profile,BadProfile).
The owner’s wallet
The member’s owner, one wallet (a Safe included), calling it directly, and nothing else.
allow
function allow(
uint64 runEpoch,
uint64 stopCount
) externalLifts this leg’s stop of its recorded run runEpoch: the execution key may act again at this leg; an unwind under way is left to clear itself. A telling of the stop still pending (tellHub) is dropped with it, so it can never name a later run. So is the local exit’s hold on the unwind’s own sends: the local exit was that stop’s. Only while the leg’s count of stops is still stopCount, so any stop since the Allow was made voids it. The same rule as the hub’s own allow, beside its hub or on another chain alike; it takes the next owner nonce.
Who may call: The owner’s wallet, on the leg’s chain.
When: After a stop.
Parameters
| Name | Type | Description |
|---|---|---|
runEpoch | uint64 | A run’s number. A leg records a run only from its owner’s Run (signed, or the owner’s call), only above the one it records; a stop never moves it. |
stopCount | uint64 | The leg’s count of stops the owner decided at (control().stopCount). |
What it checks
- The caller is the owner (
NotOwner). runEpochthe run the leg records, 0 before any (WrongRun).- The leg’s count of stops is
stopCount(StaleStop).
recordRunByOwner
function recordRunByOwner(
uint64 runEpoch,
uint64 group
) externalRecords run runEpoch in group at this leg, as the owner’s signed Run does. It takes no owner nonce: the run number is its own stream.
Who may call: The owner’s wallet, on the leg’s chain.
When: With no position open here.
Parameters
| Name | Type | Description |
|---|---|---|
runEpoch | uint64 | A run’s number. A leg records a run only from its owner’s Run (signed, or the owner’s call), only above the one it records; a stop never moves it. |
group | uint64 | An execution group, 0 to 15. |
What it checks
- The caller is the owner (
NotOwner). runEpochabove the run the leg records (StaleRun).- No position open here (
RunNotAdmitted: a debt at an AAVE leg; a perp position or something in flight at the Hyperliquid leg; idle tokens never count), the admission read given its gas (LowGas). - The registry has not stopped
group, nor failed to say it did not (GroupStopped).
setSetting
function setSetting(
uint8 key,
bytes32 value
) externalSets key of this leg to value, beside its hub or on another chain alike, checked against the bounds of the leg’s creation and its other settings as they stand, and in force from this call on. The Hyperliquid leg: its order bound (20), reduce band (21), growth band (22), fast fee cap (23), fee budget (24) and leverage cap (25). An AAVE V3 family leg: its health floor (10), oracle bound (11), daily loss budget (12), fast fee cap (13), debt conversions’ cap (14) and, on another chain than its hub, its profile (1: an open PROFILE entry of this chain’s registry with the underlying of the leg’s profile and the leg’s own section holding what it holds).
Who may call: The owner’s wallet, on the leg’s chain.
When: Outside an unwind.
Parameters
| Name | Type | Description |
|---|---|---|
key | uint8 | The setting (Settings). |
value | bytes32 | The new value: a bp, a leverage ×100, a health floor (1e18 = 1) or a profile’s registry entry id. |
What it checks
- The caller is the owner (
NotOwner). - Not unwinding (
Unwinding); a profile only at a leg on another chain than its hub (NotHere: beside its hub, the hub’s profile switch moves it). - A key of this leg’s type (
Unsupported), the value within the bounds (BadParams; a profile,BadProfile).
DLTX’s execution key
The execution key of the strategy’s group, read from its chain’s registry; the owner may revoke it on each contract of the strategy. It acts within the contract’s limits and can pay only the strategy’s own contracts, or the owner’s wallet from the hub.
supply
function supply(uint256 amount) externalSupplies amount of the profile’s asset to AAVE: the strategy’s collateral.
Who may call: The run’s execution key.
When: While the run goes, not paused.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The asset, in its own decimals. |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution). - Not paused by the key (
IsPaused).
withdraw
function withdraw(
address a,
uint256 amount
) externalWithdraws the asset or USDC from AAVE to the leg, the health factor left strictly above the floor plus a hundredth of it. While the leg is latched reduction-only, a withdrawal that lowers the health factor is refused.
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
a | address | The token: the profile’s asset or USDC. |
amount | uint256 | In its own decimals. |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution). - The asset is the profile’s or USDC (
BadAsset); the health factor afterwards strictly above the floor plus a hundredth of it (BelowHealthFloor). - Latched reduction-only: the health factor not lower afterwards (
ReductionOnly).
setEMode
function setEMode(uint8 category) externalSets the leg’s AAVE e-mode category, the health factor left strictly above the floor plus a hundredth of it.
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
category | uint8 | AAVE’s e-mode category (0 for none). |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution). - The health factor afterwards strictly above the floor plus a hundredth of it (
BelowHealthFloor).
pause
function pause(bool on) externalThe key’s own switch: while on, its supply and borrow are refused. It never stops protection, money between members, a sale or the unwind.
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
on | bool | True to pause. |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution).
send
function send(
uint8 k,
uint256 amount,
bool fast,
uint256 maxFee
) externalSends the leg’s USDC to member k, once it is ready: on this chain by a counted transfer, otherwise by a Circle burn only that member can complete. Circle’s fee is charged to the 24-hour loss budget.
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
k | uint8 | A link of this contract, by its index among its links (a leg’s link 0 is its hub; the hub’s links are its legs, 0 the first). |
amount | uint256 | The USDC to send, 6 decimals. |
fast | bool | Across chains: true for Circle’s fast transfer (confirmed, with a fee), false for a standard one (finalized, Circle’s minimum fee only). No effect on the same chain. |
maxFee | uint256 | For a fast transfer, the most Circle may take, 6 decimals; raised to Circle’s minimum. Not used for a standard one. |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution). - Not zero (
ZeroAmount), memberkready (NotReady). - Circle’s minimum fee at most 10 bp; a fast fee at most
maxFeeand the fast fee cap (FeeAboveCap); the loss budget not exceeded (OverBudget).
swap
function swap(
uint8 poolIndex,
bool assetToUsdc,
uint256 amountIn,
uint256 minOut
) external returns (uint256)Sells the asset for USDC, or USDC for the asset, on the pool of the owner’s set that poolIndex names, paid to the leg: minOut raised to the bound against the reference price (AAVE’s price × the wrapped asset’s rate, when it has one), the shortfall against AAVE’s price charged to the 24-hour loss budget. Returns what it received. While the leg is latched reduction-only it sells the asset only: a purchase is refused.
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
poolIndex | uint8 | The pool of the owner’s set to sell on (poolSet(), 0 first). |
assetToUsdc | bool | True to sell the asset for USDC. |
amountIn | uint256 | What to sell. |
minOut | uint256 | The least to receive: raised to the bound. |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution). - Prices fresh: the asset’s AAVE source answered within 25 hours and the sequencer up (
StalePrice). - At least the bound’s out (
SwapShort); the loss budget not exceeded (OverBudget). poolIndexwithin the set (NoPool).- Latched reduction-only: no purchase of the asset (
ReductionOnly).
repayWithCollateral
function repayWithCollateral(
uint8 poolIndex,
uint256 debt,
uint256 maxCollateral
) externalRepays debt USDC with at most maxCollateral of the aToken through the repay-with-collateral receiver, atomically, at the fee tier of the pool of the owner’s set that poolIndex names (the receiver’s router reaches that pool); on the PSM debt route the receiver sells the debt USDC it flash-loans to its pinned PSM wrapper for USDS (at par less the owner’s cap) and repays that, debt capped at the debt at par so that no USDS comes back. It is judged on what moved, measured afterwards, never on the offer: the collateral out (aToken and idle asset together) and the debt that fell, the health factor never lower. At a health factor above the floor, an ordinary repay: the shortfall of the value in (the debt repaid in USDC’s units at par and the cash handed back) against the reference within the owner’s bound, its shortfall against AAVE’s price charged to the loss budget. At a health factor at or below the floor (equality included), a protective repay: the collateral out, at AAVE’s price, at most the debt that fell (cash handed back excluded), at the debt token’s price, times the reserve’s liquidation bonus read on chain (e-mode off), the debt required to fall; its loss counted to the 24-hour budget but never refused by it; and the leg latched reduction-only (ReductionLatched) until the owner resets it.
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
poolIndex | uint8 | The pool of the owner’s set whose fee tier the receiver routes at (poolSet(), 0 first). |
debt | uint256 | The USDC debt to repay. |
maxCollateral | uint256 | The most aToken the receiver may pull: an offer, never the bound itself. |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution). debtabove zero (ZeroAmount);poolIndexwithin the set (NoPool); prices fresh (StalePrice).- Ordinary: the shortfall measured within the owner’s bound against the reference (
AboveBound); the loss budget (OverBudget). - Protective: the debt fell (
ZeroAmount); the collateral out within the liquidation bonus of the debt that fell, rounded toward refusal (AboveBound); no budget refusal. - The health factor not lower (
HealthFell). - On
PSM: the wrapper’s fee in at most the owner’sdebtCapBp, a halted wrapper refused (DebtRoute).
repay
function repay(uint256 amount) externalRepays the debt with the leg’s USDC, at most what it holds. On the PSM debt route the USDC is sold to Sky’s PSM wrapper for USDS first, never more than the debt needs beyond the USDS the leg holds, then every USDS the leg holds is repaid, at most the debt (a conversion’s dust swept in); any USDS left above the debt is bought back as USDC at par less the cap (left for the next repay or unwind step when the wrapper refuses it). What the conversions lost against par is charged to the 24-hour loss budget.
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The USDC, 6 decimals: capped at the leg’s own. |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution). - Something to repay (
ZeroAmount). - On
PSM: the wrapper’s fee in at most the owner’sdebtCapBp, a halted wrapper refused (DebtRoute), and the conversion at par less that cap, measured by balances (DebtRoute). - On
PSM: the conversions’ loss within the 24-hour loss budget (OverBudget).
collateralOff
function collateralOff(address asset) externalSwitches a reserve other than the asset off as the leg’s collateral. The floor is kept whenever a debt is left, and anyone’s switch never lowers the health factor while there is a debt. Counted only when it switched one off.
Who may call: The run’s execution key; anyone while the leg is unwinding or revoked.
When: In any state.
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The reserve to switch off. |
What it checks
- The key’s checks outside an unwind; not the asset (
BadAsset); the floor (BelowHealthFloor); not lower (HealthFell).
borrow
function borrow(uint256 amount) externalBorrows amount of USDC from AAVE, the health factor left strictly above the floor plus a hundredth of it (a repay at or below the floor is protective, so the key never brings the leg there itself). On the PSM debt route it borrows USDS instead, at the par of amount plus the wrapper’s fee out, and buys exactly amount USDC with it from Sky’s PSM wrapper: the leg holds USDC whatever its debt, and no USDS but a conversion’s dust. What the conversion lost against par is charged to the 24-hour loss budget, as the key’s sales are.
Who may call: The run’s execution key.
When: While the run goes, not paused.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The USDC, 6 decimals: what the leg holds afterwards whatever the route. |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution). - Not latched reduction-only (
ReductionOnly). - Not paused (
IsPaused); the health factor afterwards strictly above the floor plus a hundredth of it (BelowHealthFloor). - On
PSM: the wrapper’s fee out at most the owner’sdebtCapBp, a halted wrapper refused (DebtRoute), and the conversion at par less that cap, measured by balances (DebtRoute). - On
PSM: the conversion’s loss within the 24-hour loss budget (OverBudget).
claimRewards
function claimRewards() externalClaims AAVE’s rewards on the leg’s positions, to the leg. Counted as an operation only when the leg gained.
Who may call: The run’s execution key; anyone while the leg is unwinding or revoked.
When: On a market with a rewards path.
What it checks
- A rewards path (
NoRewards); the key’s checks outside an unwind (NotExecution,NoRun).
claimMerkl
function claimMerkl(
address[] calldata tokens,
uint256[] calldata amounts,
bytes32[][] calldata proofs
) externalClaims Merkl’s rewards for the leg, to the leg (every user named is the leg), of the reward and USDC only. Counted only when the leg gained.
Who may call: The run’s execution key; anyone while the leg is unwinding or revoked.
When: On a market with a rewards path.
Parameters
| Name | Type | Description |
|---|---|---|
tokens | address[] | Merkl’s reward tokens: the reward or USDC. |
amounts | uint256[] | The cumulative amounts in Merkl’s tree. |
proofs | bytes32[][] | Their proofs. |
What it checks
- A rewards path (
NoRewards); the key’s checks outside an unwind; each token the reward or USDC (BadAsset).
swapReward
function swapReward(
uint256 amountIn,
uint256 minOut
) external returns (uint256)Sells the reward for USDC on its pinned pool, at least its feed’s price less 1 %; while unwinding or revoked, also within a band of the feed (the reward’s 1 % bound less the pool’s fee, at most 50 bp). The key’s sale is charged to the 24-hour loss budget of the equity before it. Returns the USDC received.
Who may call: The run’s execution key; anyone while the leg is unwinding or revoked.
When: On a market with a rewards path, the reward reserve not collateral.
Parameters
| Name | Type | Description |
|---|---|---|
amountIn | uint256 | The reward to sell; type(uint256).max for everything held, idle and supplied. |
minOut | uint256 | The least USDC: raised to the floor. |
What it checks
- A rewards path (
NoRewards); the key’s checks outside an unwind. - The reward reserve not collateral (
RewardCollateralOn); its feed fresh within 25 hours and the sequencer up (StalePrice); the pool inside the band (PoolOffOracle); at least the floor out (SwapShort); a withdrawal of the reward never lowering the health factor (HealthFell); the key’s loss within the budget (OverBudget).
lever
function lever(
uint8 poolIndex,
uint256 quantity,
uint256 loan,
uint256 debt,
uint256 maxIn
) externalLevers the long in one transaction: loan USDC flash-loaned from the leg’s pool to the leg itself; in the pool’s callback, exactly quantity of the asset bought on the pool of the owner’s set that poolIndex names for at most maxIn USDC (the loan and the leg’s own USDC), supplied, and debt borrowed by the leg for itself in the debt token’s units (on the PSM debt route, the USDS that buys back the loan’s USDC at the PSM wrapper, at par less the owner’s cap); the pool then pulls back the loan and its premium. Afterwards, in the units the pool accounts in: the aToken’s scaled balance up by at least quantity, the debt’s by at most debt, the leg’s own USDC down by at most maxIn less the loan plus the premium. The equity it lost is charged once to the 24-hour loss budget, against the equity read before the loan, and the health floor is kept.
Who may call: The run’s execution key.
When: While the run goes, the key’s pause off.
Parameters
| Name | Type | Description |
|---|---|---|
poolIndex | uint8 | The pool of the owner’s set the asset is bought on (poolSet(), 0 first). |
quantity | uint256 | The asset bought and supplied, exactly, in its own decimals. |
loan | uint256 | The USDC flash-loaned. |
debt | uint256 | The debt opened, in the debt token’s units: USDC, or USDS on the PSM debt route. |
maxIn | uint256 | The most USDC the buy may spend: the loan and the leg’s own USDC. |
What it checks
- Not unwinding (
Unwinding), not revoked (Revoked), a run recorded (NoRun), and the caller the registry’s key for the run’s group (NotExecution). - Not paused (
IsPaused); onPSM, the wrapper’s fee out at most the owner’sdebtCapBp(DebtRoute). - Not latched reduction-only (
ReductionOnly). quantity,loananddebtabove zero andmaxInat least the loan (ZeroAmount);poolIndexwithin the set (NoPool).maxInwithin the oracle bound onquantity, the bound a purchase byswapis held to (AboveBound); prices fresh (StalePrice).- The leg’s own USDC at least
maxInless the loan plus the premium (BadParams). - Exactly
quantitybought (SwapShort); the callback run once, and the deltas above (NotAllowed); the loss budget (OverBudget); the health factor strictly above the floor plus a hundredth of it (BelowHealthFloor). - A cap, a borrow or a liquidity refusal by the pool reverts the whole call.
The kernel
The contract’s own kernel, running in the contract: it calls these hooks itself (at the creation, after an upgrade, for the owner’s Stop and a transfer of ownership) and refuses them from anyone else.
kernelInit
function kernelInit(bytes calldata data) externalInitialises the member once, from what the builder hands it (MemberInit): the kind must name this logic’s member type at this member’s place and on this chain, the member’s address must be the one the kind’s addresses give it, and the links are every other member in the kind’s order (a leg’s first its hub). Then the member type checks its own section of the profile on this chain and its parameters, and stores them. A leg on a chain other than its hub’s announces itself at once to every member on another chain. Any refusal reverts the whole creation.
Who may call: The member’s kernel, in the builder’s creating transaction.
When: Once, at the creation.
Parameters
| Name | Type | Description |
|---|---|---|
data | bytes | The builder’s MemberInit, abi-encoded. |
What it checks
- The member is initialised by its kernel (
NotAllowed), which initialises it once. - The kind’s member at this place is this logic’s type, the hub at place 0 and a leg elsewhere (
WrongMember), on this chain, the chain this code was built for (WrongChain). - Every address is the kind’s, 2 to 5 members, none zero, none twice (
BadLinks). - The member type’s own section of the profile and its parameters (
BadProfile,BadParams, and its own reasons).
kernelUpgraded
function kernelUpgraded(uint32) externalRuns once after the member’s kernel moved it to this logic: a leg has nothing to move.
Who may call: The member’s kernel, in the call that applies the upgrade.
When: After an upgrade.
Parameters
| Name | Type | Description |
|---|---|---|
| — | uint32 | Unnamed in the code: not used. |
What it checks
- The member is initialised (
NotAllowed).
kernelStop
function kernelStop() externalStops the member’s recorded run for the owner’s Stop: the hub as by any stop (revoked, its unwind begun, every leg told, the fee raise not yet applied dropped), a leg as the escape hatch does (revoked, its unwind begun unless it already was, its hub told, a failure kept pending for tellHub), a leg with no run recorded at run 0. Either raises the member’s count of stops, which the kernel requires. The run never moves.
Who may call: The member’s kernel, applying the owner’s Stop, signed or called.
When: While the member is not stopped.
What it checks
- The member is initialised (
NotAllowed). - The member is not revoked (
AlreadyStopped), so no relayed Stop is a no-op.
kernelTransferred
function kernelTransferred() externalRuns once an ownership transfer applied, with the new owner in place: a leg keeps nothing of its owner’s to drop.
Who may call: The member’s kernel, in the call that applies the transfer.
When: After a transfer.
What it checks
- The member is initialised (
NotAllowed).
Another contract of the strategy
The strategy’s hub or one of its legs, on the same chain: the contracts that make one strategy, and nothing else.
applySetting
function applySetting(
uint8 key,
bytes32 value
) externalSets key to value for the owner, from the legs’ owner module (setSetting there), beside its hub or on another chain alike: checked here against the bounds as they stand (checkSetting) and in force from this call on.
Who may call: The leg itself, for its owner module.
When: When the owner sets it.
Parameters
| Name | Type | Description |
|---|---|---|
key | uint8 | The setting. |
value | bytes32 | The value. |
What it checks
- The caller is the leg itself (
NotAllowed); not unwinding (Unwinding). - Within the bounds (
BadParams,Unsupported).
receiveLocal
function receiveLocal(uint256 amount) externalPulls amount of USDC that another member on this chain allowed, and counts it as received from that member. The hub books it as a move between members, never as capital.
Who may call: Another member of the strategy on this chain, from inside its own send.
When: In every state.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The USDC to pull, 6 decimals. |
What it checks
- The caller is one of this contract’s links, on this chain (
BadMessage).
stopFromHub
function stopFromHub(uint8 by) externalStops the run this leg records, whatever run the hub names (a leg and its hub may be one run apart: the leg learns its run from its owner): the execution key revoked, the unwind begun, its count of stops raised. At a leg already stopped it does nothing.
Who may call: This leg’s hub, when it lives on this chain.
When: When the hub stops, and at each step of its unwind for a leg neither unwinding nor stopped.
Parameters
| Name | Type | Description |
|---|---|---|
by | uint8 | Who stopped the run: 1 the owner, 2 the escape hatch, 3 another member of the strategy. |
What it checks
- This is a leg whose hub is on this chain, and the caller is that hub (
NotAllowed).
switchProfile
function switchProfile(bytes calldata profile) externalSwitches the leg’s section to profile’s, for the owner’s profile switch (from the hub on this chain, or from the legs’ owner module on another chain than its hub): checked as at the creation (AAVE’s price source and the pegged feeds included) and stored, its asset, aToken, decimals and holding unchanged, and the owner’s oracle bound still at least the new section’s floor.
Who may call: The leg’s hub on this chain, or the leg itself for its owner module.
When: When the owner switches it.
Parameters
| Name | Type | Description |
|---|---|---|
profile | bytes | The profile entry’s data. |
What it checks
- The caller is the leg’s hub on this chain or the leg itself (
NotAllowed); from the hub, the hub’s owner and owner generation the leg’s own (OwnersDiffer); not unwinding (Unwinding). - The same asset, aToken, decimals and holding, and the section valid (
BadProfile). - The oracle bound at least the new floor (
BadParams).
Circle’s message transmitter
Circle’s CCTP MessageTransmitterV2 on that chain, delivering a message Circle attested from another contract of the same strategy on another chain.
handleReceiveFinalizedMessage
function handleReceiveFinalizedMessage(
uint32 sourceDomain,
bytes32 sender,
uint32 finality,
bytes calldata body
) external returns (bool)Receives a message from another member on another chain: READY marks it ready; STOP (at a leg) from its hub, of any run, stops the recorded run, never moving the leg’s run, and changes nothing at a leg already stopped; at the hub, a leg’s stop of the current run or a later one stops the strategy; REPORT (to the hub) stores the leg’s report. No message carries a run. Returns true.
Who may call: Circle’s message transmitter, delivering an attested message; anyone may relay it there.
When: In every state.
Parameters
| Name | Type | Description |
|---|---|---|
sourceDomain | uint32 | The message’s chain, as its Circle domain: it must be the sending member’s own. |
sender | bytes32 | The sending member, as a word. |
finality | uint32 | The finality Circle attested the message at: 2000 finalized, 1000 confirmed. |
body | bytes | The message: its tag (READY, STOP or REPORT), the sender’s code version and its fields. |
What it checks
- The caller is Circle’s transmitter, and the sender is a link of this contract on another chain, on its own domain (
BadMessage). READYandREPORTneed finalized;STOPis taken at any finality: a stop is only ever safer (BadMessage).STOPto a leg only from its hub;REPORTonly to the hub, a report of this version’s layout with at most 16 holdings (BadMessage).- Any other message reverts (
BadMessage).
handleReceiveUnfinalizedMessage
function handleReceiveUnfinalizedMessage(
uint32 sourceDomain,
bytes32 sender,
uint32,
bytes calldata body
) external returns (bool)The same as handleReceiveFinalizedMessage for a message Circle attested before finality: only a STOP is accepted then.
Who may call: Circle’s message transmitter.
When: In every state.
Parameters
| Name | Type | Description |
|---|---|---|
sourceDomain | uint32 | The message’s chain, as its Circle domain: it must be the sending member’s own. |
sender | bytes32 | The sending member, as a word. |
| — | uint32 | Unnamed in the code: not used. |
body | bytes | The message: its tag (READY, STOP or REPORT), the sender’s code version and its fields. |
What it checks
- As
handleReceiveFinalizedMessage, every kind butSTOPrefused (BadMessage).
Anyone
Any address. These functions take no recipient and act only as the code allows: they move nothing anywhere the owner did not choose.
fallback
fallback() externalRuns a function this contract does not declare itself: the member type’s own modules’ (each listed on this page), by DELEGATECALL in this contract’s storage. Any other call reverts (Unsupported).
Who may call: Anyone: each function it reaches checks its own caller.
When: Always.
announceReady
function announceReady(uint8 k) externalResends this leg’s READY to member k on another chain, at finalized. Until it arrives that member sends this leg no money.
Who may call: Anyone.
When: In any state. The hub never announces itself (a leg’s hub can always receive), and refuses (NotAllowed).
Parameters
| Name | Type | Description |
|---|---|---|
k | uint8 | A link of this contract, by its index among its links (a leg’s link 0 is its hub; the hub’s links are its legs, 0 the first). |
What it checks
- This is a leg, and link
kexists and lives on another chain (NotAllowed). - Circle accepts the message (it reverts as Circle does).
stopStopped
function stopStopped() externalThe escape hatch: once the registry stopped this contract’s group (DLTX’s check-ins stopped for 7 days), or the registry fails to answer, anyone stops the run here and its unwind begins; the leg then tells its hub, a failure kept pending for tellHub. A leg stopped already is left as it is: the hatch never restarts an unwind that ended.
Who may call: Anyone.
When: Once stopped(group) is true on this chain’s registry, or the registry’s read fails or answers neither 0 nor 1, with a run recorded.
What it checks
- A run is recorded (
NoRun) and the registry says its group is stopped (GroupNotStopped).
tellHub
function tellHub() externalTells the hub of a stop it was not yet told of (a stop by the escape hatch or by the owner’s Stop whose telling failed): on the hub’s chain by a call, else by a fast Circle message.
Who may call: Anyone.
When: While a telling is pending.
What it checks
- This is a leg with a telling pending (
NotAllowed). - It reverts as the hub or Circle does.
unwindRepay
function unwindRepay(
uint8 source,
uint256 debtChunk
) externalOne of the unwind’s debt sources as a transaction of its own, reverting on its own failure: 1 the leg’s USDC (on the PSM debt route, its idle USDS first), 2 its aUSDC, 3 up to debtChunk of the debt with its collateral through the receiver, 4 up to debtChunk by a sale of collateral within the band, capped at what AAVE lets go. Sources 3 and 4 repay only the debt the leg’s own cash leaves (its USDC, its idle USDS at par, its aUSDC the reserve can pay out), refused while that cash covers it all. The receiver’s offer is the bound’s collateral for the chunk, or the liquidation bonus’s at a health factor at or below the floor, where the protective rule replaces the band, capped at what the leg could release once the chunk is repaid (the receiver withdraws the whole offer before it sells). Nothing else moves: no withdrawal once the debt is gone, no USDC home, the unwind never ended here; unwindStep does that cleanup. Counted.
Who may call: Anyone, by the unwind’s fixed rules.
When: While the leg is unwinding or revoked.
Parameters
| Name | Type | Description |
|---|---|---|
source | uint8 | The source: 1 the leg’s USDC, 2 its aUSDC, 3 collateral through the receiver, 4 collateral sold. |
debtChunk | uint256 | Sources 3 and 4: the most debt repaid; 0 for all. Ignored by 1 and 2. |
What it checks
- Unwinding or revoked (
NotAllowed); a source 1 to 4 (Unsupported). - The debt token’s balance fell, and for sources 3 and 4 the leg’s cash leaves a debt (
ZeroAmount). - The source’s own bounds, each a revert:
PoolOffOracleandBandCrossedaround the receiver (ordinary),AboveBoundandHealthFell(protective),NoLiquidity,SwapShort,StalePrice,DebtRoute.
unwindStep
function unwindStep(
uint256 debtChunk,
uint256 assetChunk
) externalOne step of the unwind, each part run on its own and a failing part logged: the reward’s collateral off and the reward sold; the debt repaid from the leg’s own USDC, from its aUSDC, then with its collateral through the receiver (the pool’s price inside the band before and after; at a health factor at or below the floor, the protective rule instead: the liquidation bonus alone, no band, the health factor never lower, no latch), else by a sale within the band; once no debt is left the collateral and the aUSDC withdrawn and the asset sold within the band; then the leg’s USDC home to the hub, all but what still repays the debt. On the PSM debt route every repay converts USDC to USDS first by the same wrapper and cap; while the route is closed (the wrapper halted, or its fee above the cap) every repay fails alike, the collateral stays supplied and nothing is quarantined, and the unwind goes on once it opens; the asset and aUSDC count as attempted (toward quarantine) only at a step that leaves no debt. On PSM USDS left above the debt is bought back as USDC. The unwind ends, Unwound, at the step that leaves the leg settled.
Who may call: Anyone, by the unwind’s fixed rules: no caller chooses where money goes or at what price.
When: While the leg is unwinding or revoked.
Parameters
| Name | Type | Description |
|---|---|---|
debtChunk | uint256 | The most debt repaid in this step; 0 for all. |
assetChunk | uint256 | The most asset sold in this step; 0 for all. |
What it checks
- Unwinding or revoked (
NotAllowed); with reward work, the gas its parts need (GasTooLow).
sendHome
function sendHome() externalSends the leg’s own USDC to its hub, all but what still repays its debt; never reverts on Circle (what fails waits). A move between members, never counted.
Who may call: Anyone, by the unwind’s fixed rules: no caller chooses where money goes or at what price.
When: While the leg is unwinding or revoked.
What it checks
- Unwinding or revoked (
NotAllowed).
localExit
function localExit() externalThe leg’s local exit: everything it holds on its chain to the owner its kernel holds now, as it is, each token whole and best-effort (a refused transfer leaves that token, never the others): USDC, aUSDC, the asset and its aToken, the reward and its aToken where the profile has a rewards path, USDS where the deployment has it, each LocalExitPaid. No bridge, no fee, nothing counted toward the hub, which still settles only on a fresh report from the leg (or the owner’s releaseDebtReserve()). The unwind need not have ended; from then on, until the owner’s Allow (no run recorded meanwhile lifts it), it sends nothing home, and a late arrival is paid by the next call. Counted when anything left.
Who may call: Anyone: it pays only the owner, and its gate is DLTX’s absence; an owner with no gas on the leg’s chain can be helped.
When: Once the leg is revoked, the registry stopped its group and no debt is left. While the group runs it is shut, so a quarantine the owner alone could bring about never takes the long fee-free.
What it checks
- The leg revoked (
NotAllowed). - The registry stopped the group of the run the leg recorded when it was revoked (a run recorded since, while the stop holds, moves it not), by the escape hatch’s own read: a failed or malformed read counts as stopped (
GroupNotStopped;LowGaswhen the caller left too little gas). - No debt, by
exitReady()read with a fixed gas (NotAllowed;LowGas).
report
function report() externalSends the leg’s report to its hub: its holdings, counters and status, every figure read in this block; on the hub’s chain by a call, else by a finalized Circle message.
Who may call: The run’s execution key while the leg runs (a run recorded, neither unwinding nor revoked); anyone otherwise.
When: In every state, the caller as who says.
What it checks
- While the leg runs, the caller is the run’s execution key (
NotExecution): no other report can take the place of the one a valuation reads. - It reverts as the hub or Circle does.
receiveMint
function receiveMint(
bytes calldata message,
bytes calldata attestation
) externalCompletes a Circle mint bound to the leg and counts it: a burn by a member as received from it, any other uncounted, the leg’s cash (ReceivedFromOutside).
Who may call: Anyone relaying Circle’s attested message.
When: In every state.
Parameters
| Name | Type | Description |
|---|---|---|
message | bytes | Circle’s message. |
attestation | bytes | Circle’s attestation of it. |
What it checks
- As the hub’s
receiveMint(BadMessage).
recordRun
function recordRun(
OwnerMessages.Run calldata r,
bytes32 configHash,
bytes calldata sig
) externalRecords the owner’s run at this leg: run r.runEpoch in its execution group r.group. The owner signs one Run for every leg of the strategy (a strategy’s first run within its creation’s own signature, Create(configHash, Run)), relayed to each leg by anyone. A refusal reverts and uses nothing, so the same message can be relayed again. A run never lifts a stop: a leg still stopped stays so, and tells its hub a stop of the run it now records; its local exit keeps the group of the run it was stopped in and its hold on the unwind’s own sends until the owner’s Allow.
Who may call: Anyone, relaying the owner’s signature.
When: With no position open here, once the hub started the run (by its creation, or the owner’s addition of capital to an empty strategy).
Parameters
| Name | Type | Description |
|---|---|---|
r | OwnerMessages.Run | The owner’s Run: the strategy’s hub, every leg with its chain id and owner generation, the run, its group and a deadline. |
configHash | bytes32 | Zero for a Run signed on its own; the configuration’s hash for the creation’s signature. |
sig | bytes | The owner’s signature (EIP-712 domain “DLTX Owner”, version 1, no chain id). |
What it checks
- The deadline not passed (
Expired). - Exactly one item names this leg on this chain (
NotNamed,NamedTwice), at its owner generation (StaleGeneration). r.runEpochabove the run the leg records (StaleRun): any step up, so a leg that missed a run catches up at once, and a replay is refused.- No position open here (
RunNotAdmitted: a debt at an AAVE leg; a perp position or something in flight at the Hyperliquid leg; idle tokens never count), the admission read given its gas (LowGas). - The registry has not stopped
group, nor failed to say it did not (GroupStopped). - The owner’s signature over
Run, or overCreate(configHash, Run)whenconfigHashis not zero: ECDSA, or ERC-1271 when the owner is a contract on this chain (NotOwner).
localExitToken
function localExitToken(address token) externalA leg’s local exit of one named token: the leg’s whole balance of token, any ERC-20 on its chain, to the owner the leg’s kernel holds now, best-effort (a balance that can’t be read or a transfer the token refuses pays nothing, never a revert), LocalExitPaid. One transfer per call; once flat the leg’s position needs no token, so none is refused beyond the gate. From then on, until the owner’s Allow (no run recorded meanwhile lifts it), the leg’s unwind moves no money of its own. Counted when it paid.
Who may call: Anyone: it pays only the owner, and its gate is DLTX’s absence.
When: Once the leg is revoked, the registry stopped its group, and the leg is flat by its type’s exitReady().
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The ERC-20. |
What it checks
- The leg revoked (
NotAllowed). - The registry stopped the group of the run the leg recorded when it was revoked (a run recorded since, while the stop holds, moves it not), by the escape hatch’s own read: a failed or malformed read counts as stopped (
GroupNotStopped;LowGaswhen the caller left too little gas). - The leg’s
exitReady(), read by a call to itself with a fixed gas: a read that fails is not ready (NotAllowed;LowGas).
The contract itself
Called only by the contract on itself, from inside one of its own functions, so that one part can fail without undoing the rest; refused from anyone else.
localToHub
function localToHub(uint256 amount) externalThe same-chain half of a leg’s counted move to its hub, run as a call on itself so that its failure stays inside the move that tried it.
Who may call: This contract itself.
When: From inside a move home.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The USDC to move, 6 decimals. |
What it checks
- The caller is this contract (
NotAllowed).
remoteToHub
function remoteToHub(
uint256 amount,
uint256 fee
) externalThe cross-chain half of a leg’s counted move to its hub: the USDC approval and Circle’s burn, run as a call on itself so that a token refusing either (paused, an address blocked) fails only the move, leaves no allowance and undoes nothing else its caller did, such as an unwind’s close.
Who may call: This contract itself.
When: From inside a move home.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The USDC to burn, 6 decimals. |
fee | uint256 | Circle’s minimum fee on it, 6 decimals. |
What it checks
- The caller is this contract (
NotAllowed).
unwindPart
function unwindPart(
uint8 part,
uint256 arg
) externalOne part of unwindStep, so that it can fail on its own.
Who may call: The leg itself, from its unwind step.
When: While unwinding or revoked.
Parameters
| Name | Type | Description |
|---|---|---|
part | uint8 | The part: 1 to 7, or 10. |
arg | uint256 | Its chunk; 0 for all. |
What it checks
- The caller is the leg (
NotAllowed); a known part (Unsupported); each part’s own bounds (PoolOffOracle,BandCrossed,SwapShort,HealthFell,NoLiquidity,StalePrice,DebtRoute).
usdsBack
function usdsBack() externalBuys back as USDC the leg’s USDS above its debt, as many whole USDC units as it buys at Sky’s PSM wrapper’s fee out, held to par less the owner’s cap; nothing with the fee out above the cap or halted. Run by the leg’s own repay and unwind as a call on itself, so that a refused conversion or fee read fails alone and leaves the USDS for the next call.
Who may call: The leg itself.
When: On the PSM debt route, once the debt is gone.
What it checks
- The caller is the leg (
NotAllowed); the conversion at par less the cap.
toDebtFor
function toDebtFor(
uint256 amount,
uint256 short
) external returns (uint256 loss)Sells at most amount of the leg’s USDC to Sky’s PSM wrapper for USDS, never more than buys short USDS at the wrapper’s fee in, held to par; returns its loss against par. Run by the leg’s repay as a call on itself, so that a refused conversion or fee read fails alone and the USDS the leg holds still repays.
Who may call: The leg itself.
When: On the PSM debt route, while USDS is owed beyond the USDS the leg holds.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The most USDC to sell, 6 decimals. |
short | uint256 | The USDS the debt needs beyond what the leg holds, 18 decimals. |
What it checks
- The caller is the leg (
NotAllowed); the fee in within the owner’s cap (DebtRoute); the conversion at par.
rewardPart
function rewardPart(uint8 part) externalAn unwind’s reward part: 9 turns the reward reserve off as collateral, 8 sells the reward held within its band. Nothing without a rewards path.
Who may call: The leg itself, from its unwind step.
When: While unwinding or revoked.
Parameters
| Name | Type | Description |
|---|---|---|
part | uint8 | 8 the reward’s sale, 9 its collateral off. |
What it checks
- The caller is the leg, unwinding or revoked (
NotAllowed); a known part (Unsupported).
Callbacks
Called back by a protocol in the middle of the contract’s own operation, and refused from anyone else.
uniswapV3SwapCallback
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata
) externalPays the pool during this leg’s own swap, once: what it is owed of the token the swap’s direction pays (the asset or USDC on the pool of the set the sale names, the reward on the reward’s pool), at most the swap’s input; a swap that filled nothing is owed and paid nothing.
Who may call: The Uniswap V3 pool this leg is swapping on at that moment; no other pool, even one of the set.
When: Only inside the leg’s own swap, before that pool has been paid.
Parameters
| Name | Type | Description |
|---|---|---|
amount0Delta | int256 | What the pool is owed of its token0 (positive) or pays (negative). |
amount1Delta | int256 | The same for its token1. |
| — | bytes | Unnamed in the code: not used. |
What it checks
- The leg is swapping, the caller is that swap’s pool, it is owed nothing of the other token and at most the input of the one the swap pays, and it was not paid yet (
NotAllowed).
executeOperation
function executeOperation(
address asset,
uint256 amount,
uint256 premium,
address initiator,
bytes calldata params
) external returns (bool)AAVE’s flash-loan callback during this leg’s own lever: buys exactly the lever’s quantity, supplies it, borrows the lever’s debt for the leg itself (on the PSM debt route, buying back the loan’s USDC with it at the wrapper) and approves the loan and its premium back to the pool. Returns true.
Who may call: The leg’s AAVE pool, for a flash loan the leg itself started.
When: Only inside the leg’s own lever, once.
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The flash-loaned asset: USDC. |
amount | uint256 | The amount lent: the lever’s loan. |
premium | uint256 | The pool’s premium on it. |
initiator | address | Who started the flash loan: the leg. |
params | bytes | The lever’s pool index, quantity, loan, debt and most input, as the lever encoded them. |
What it checks
- The caller is the leg’s pool, a lever is under way (its phase cleared before any call out), the initiator is the leg, the asset USDC and the amount the lever’s loan (
NotAllowed).
Read-only
Views and constants: they change nothing, and anyone may read them.
checkSetting
function checkSetting(
uint8 key,
bytes32 value
) external viewWhether value is within the bounds of the leg’s creation for setting key: the health floor 1.05 to 3 (1e18 = 1); the oracle bound at least the section’s floor, at most the market’s ceiling and above every pool’s fee in the set; the daily loss budget and the fast fee cap within their caps; the debt conversions’ cap 0 on the direct route, at most its ceiling on the PSM route; the reduction-only latch 0 alone (its reset), and only at a health factor at or above the floor. Reverts otherwise; every change of a setting, and the profile switch for the oracle bound, is held to it.
Parameters
| Name | Type | Description |
|---|---|---|
key | uint8 | The setting (Settings, 10 to 15). |
value | bytes32 | The value. |
What it checks
- Within the bounds (
BadParams); the latch’s reset at a health factor at or above the floor (BelowHealthFloor); a key of this type (Unsupported).
limits
function limits(
) external view returns (uint64 healthFloor, uint16 oracleBoundBp, uint16 dailyLossBp, uint16 fastFeeCapBp, bool paused)The owner’s bounds as they stand, and the key’s pause.
Returns
| Name | Type | Description |
|---|---|---|
healthFloor | uint64 | The least health factor the key may leave, 1e18 = 1. |
oracleBoundBp | uint16 | The widest a sale may stray from the reference price, bp. |
dailyLossBp | uint16 | The most value sales and Circle’s fees may lose in any 24 hours, bp of the equity before. |
fastFeeCapBp | uint16 | The most a fast Circle transfer may pay, bp of its amount. |
paused | bool | The key’s pause. |
MEMBER_TYPE
function MEMBER_TYPE() external view returns (uint8)This deployment’s member type: 2 on Arbitrum, 4 on Ethereum.
kernelStopState
function kernelStopState() external view returns (uint64 runEpoch, uint64 stopCount)The member’s recorded run and its count of stops, read by its kernel before and after the owner’s Stop.
Returns
| Name | Type | Description |
|---|---|---|
runEpoch | uint64 | The run the member records. |
stopCount | uint64 | The member’s count of stops. |
kernelGroup
function kernelGroup() external view returns (uint64)The group of the member’s recorded run, read by its kernel before a migration applies: a member migrates only from a run recorded in a group the successor registry keys.
Who may call: The member’s kernel only; refused from outside (Reserved).
ready
function ready(uint8 k) external view returns (bool)Whether link k can receive money from this contract: a leg’s hub at once, a member on this chain once its code is there, a member on another chain once its finalized READY arrived.
Parameters
| Name | Type | Description |
|---|---|---|
k | uint8 | A link of this contract, by its index among its links (a leg’s link 0 is its hub; the hub’s links are its legs, 0 the first). |
memberInfo
function memberInfo(
) external view returns (address owner, address registry, uint32 number, uint8 memberType, address[] memory links, uint32[] memory linkDomains)What this contract is, fixed at its creation.
Returns
| Name | Type | Description |
|---|---|---|
owner | address | The owner’s wallet, as the member’s kernel holds it. |
registry | address | This chain’s registry, as the member’s kernel holds it. |
number | uint32 | The release number the member runs. |
memberType | uint8 | Its member type. |
links | address[] | Every other member, in the kind’s order (a leg’s first is its hub). |
linkDomains | uint32[] | Each link’s chain, as its Circle domain. |
control
function control(
) external view returns (uint64 runEpoch, uint64 group, bool runActive, bool revoked, bool unwinding, uint64 unwindStartedAt, uint64 stopCount)Who may operate this contract and the run it follows.
Returns
| Name | Type | Description |
|---|---|---|
runEpoch | uint64 | The latest run recorded: the hub’s runs in order; at a leg, the latest run of its owner’s. |
group | uint64 | That run’s execution group. |
runActive | bool | At the hub: the run is going. |
revoked | bool | The execution key may not act; lifted only by the owner (its Allow). |
unwinding | bool | Anyone may drive the unwind; it clears itself once settled. |
unwindStartedAt | uint64 | When the current or last unwind began. |
stopCount | uint64 | The count of stops: every stop raises it. An owner’s Allow names the count it was made at. |
counters
function counters(
) external view returns (uint256[MAX_MEMBERS - 1] memory sentTo, uint256[MAX_MEMBERS - 1] memory receivedFrom, uint256[MAX_MEMBERS - 1] memory feesFrom)The USDC this contract sent to, received from, and paid Circle on what came from, each link, ever. Each pair of members counts the same money twice, once at each end: while they disagree, money is in flight.
Returns
| Name | Type | Description |
|---|---|---|
sentTo | uint256[MAX_MEMBERS - 1] | Gross USDC sent to each link. |
receivedFrom | uint256[MAX_MEMBERS - 1] | Gross USDC received from each link. |
feesFrom | uint256[MAX_MEMBERS - 1] | Circle’s fee on what each link sent here. |
exitReady
function exitReady() external view returns (bool)Whether the leg is flat for its local exit: no debt (as runAdmissible). The local exit reads it by a call to itself, with a fixed gas.
owed
function owed() external view returns (uint256)The USDC the leg needs from its hub to repay its debt: nothing while its own USDC and aUSDC cover the debt, else the debt with headroom (10 bp and 1 USDC) less what it holds. The debt reads in USDC’s units at par whatever its token (a USDS debt rounded up to the next USDC unit): a conversion’s fee is never counted as debt. The hub’s unwind sends it.
status
function status() external view returns (LegStatus memory)The leg’s standing as it reports it: its run, revoked, unwinding, settled (no debt, the asset worth under 0.01 USD, USDC, aUSDC and, on the PSM debt route, idle USDS at par together under 0.01, the reward under its dust; aUSDC, USDS, the reward and the asset each quarantined instead once the unwind attempted it 3 times over 24 hours or more, its balance never lower, while the leg is unwinding or revoked), quarantined, and what it owes. A debt is never quarantined: while the debt route is closed (debtRouteClosed) the leg reads unsettled, not quarantined, until the route opens again.
holdings
function holdings(
) external view returns (Holding[] memory h, uint256[MAX_MEMBERS - 1] memory sent, uint256[MAX_MEMBERS - 1] memory received, uint64 observationBlock, uint64 lastMoveBlock, uint64 ops)What the leg holds and moved, read now: the collateral as the profile’s holding (aToken and idle asset, 18 decimals) and USD (its own USDC and aUSDC less the debt, 18 decimals; on the PSM debt route its idle USDS and its USDS debt at par); its counters; the block; the block of its latest move; its count of operations. The hub’s snapshot reads it.
Returns
| Name | Type | Description |
|---|---|---|
h | Holding[] | Its two holdings. |
sent | uint256[MAX_MEMBERS - 1] | USDC sent to each link, ever. |
received | uint256[MAX_MEMBERS - 1] | USDC received from each link, ever. |
observationBlock | uint64 | The block of the reading. |
lastMoveBlock | uint64 | The block of its latest move to or from its venue. |
ops | uint64 | Its count of operations that can change a holding. |
assetProfile
function assetProfile(
) external view returns (bytes32 id, address asset, uint8 decimals, address aAsset, bool assetIsToken0, bytes32 holdingAsset, uint16 minBoundBp, address rateFeed, uint32 rateMaxAge)The instance’s stored asset profile (the asset is read here, never from the code).
Returns
| Name | Type | Description |
|---|---|---|
id | bytes32 | The profile id. |
asset | address | The collateral token. |
decimals | uint8 | Its decimals. |
aAsset | address | AAVE’s aToken for it. |
assetIsToken0 | bool | Whether the asset is every asset / USDC pool’s token0. |
holdingAsset | bytes32 | The long’s id in a report. |
minBoundBp | uint16 | The least oracle bound an owner may sign. |
rateFeed | address | A wrapped asset’s rate feed; zero for none. |
rateMaxAge | uint32 | Its freshness, seconds. |
poolSet
function poolSet() external view returns (address[] memory pools, uint24[] memory fees)The owner’s pool set, in its order, fixed at creation: the only Uniswap V3 pools the leg’s sales of its asset use. A sale and a repay with collateral name one by its index; the unwind, which anyone drives, uses the first.
Returns
| Name | Type | Description |
|---|---|---|
pools | address[] | The pools. |
fees | uint24[] | Each one’s fee tier (500 = 0.05 %). |
debtRoute
function debtRoute(
) external view returns (uint8 route, address debtToken, address converter, uint16 capBp)The owner’s debt route, fixed for the leg’s life: what it borrows and how that reaches USDC, which the hub and every sale settle in.
Returns
| Name | Type | Description |
|---|---|---|
route | uint8 | 0 DIRECT (USDC borrowed as it is) or 1 PSM (USDS borrowed, converted to and from USDC at par by Sky’s PSM wrapper). |
debtToken | address | The token borrowed: USDC, or USDS on PSM. |
converter | address | Sky’s PSM wrapper on PSM; zero on DIRECT. |
capBp | uint16 | The most each conversion may lose against par, bp (zero on DIRECT, at most 50). |
debtRouteClosed
function debtRouteClosed() external view returns (bool)Whether the debt route is closed now: on PSM, Sky’s PSM wrapper halted or its fee either way above the owner’s cap, so that every conversion, and every repay of the debt, is refused alike until it opens again (Sky sets the wrapper’s fees and halts). Never on DIRECT. A closed route quarantines nothing: the debt is no residue, and the unwind goes on when the route opens.
runAdmissible
function runAdmissible() external view returns (bool)Whether the leg may take a new run: no debt. Its asset, aTokens, rewards and cash never count. The leg reads it itself, with a fixed gas, before it records its owner’s run.
reductionOnly
function reductionOnly() external view returns (bool)Whether the leg is latched reduction-only: set by every protective repay of the key, cleared only by the owner’s reset (setting AAVE_REDUCTION_ONLY to 0, at a health factor at or above the floor). While latched the key may repay, supply, sell the asset and reduce the debt; it may not borrow, lever, buy the asset or withdraw against the health factor.
rewardPins
function rewardPins(
) external view returns (address[2] memory sources, address reward, address aReward, address pool, address feed, uint256 maxAge, uint256 boundBp)This market’s rewards path; zero for one without.
Returns
| Name | Type | Description |
|---|---|---|
sources | address[2] | AAVE’s rewards controller and Merkl’s distributor. |
reward | address | The reward token. |
aReward | address | Its aToken. |
pool | address | Its Uniswap V3 pool against USDC. |
feed | address | Its USD price feed. |
maxAge | uint256 | The feed’s freshness, seconds. |
boundBp | uint256 | The most a sale may lose against the feed, bp. |
peggedLive
function peggedLive(
address source,
uint256 pa,
address assetToPeg,
address pegToBase
) external view returns (bool)Whether a pegged price source of AAVE’s oracle (an adapter answering asset / peg × peg / USD, such as WBTC / BTC × BTC / USD, without rounds of its own) is live as the profile names it: the adapter’s ASSET_TO_PEG() and PEG_TO_BASE() exactly assetToPeg and pegToBase, in that order (each getter under a gas cap, one word read); each of the two Chainlink feeds fresh under its own age, read from its own round (the rate within 25 hours, the USD price within this market’s pegToBaseMaxAge); and their product the oracle’s answer within 1 bp. False on a market that accepts no pegged source, or for zero feeds. The leg asks it of itself, under a gas cap, before every sale’s bound and at a profile’s acceptance, for a profile that names pegged feeds.
Parameters
| Name | Type | Description |
|---|---|---|
source | address | The adapter, as AAVE’s oracle names it for the asset. |
pa | uint256 | The oracle’s price of the asset, 8 decimals. |
assetToPeg | address | The profile’s feed of the asset’s rate to its peg (Chainlink WBTC / BTC). |
pegToBase | address | The profile’s feed of the peg in USD (the market’s Chainlink BTC / USD). |
checkSource
function checkSource(
address asset,
address assetToPeg,
address pegToBase
) external viewChecks AAVE’s price source for a profile’s asset as the profile names its kind, else reverts BadProfile: a source and a positive price; the pegged feeds both set or both zero, and set only on a market that accepts pegged sources; with them, the adapter’s two feeds exactly those two, in that order; without them, a source with rounds of its own. The market module’s profile check asks it of the leg at the creation.
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The profile’s long asset. |
assetToPeg | address | The profile’s pegged source’s rate feed, zero for a source with rounds. |
pegToBase | address | The profile’s pegged source’s USD feed, zero for a source with rounds. |
checkPools
function checkPools(
address asset,
address[4] calldata pools,
uint256 boundBp
) external view returns (uint256 n, uint24[4] memory fees)The owner’s pool set for asset, checked on this chain: 1 to 4 pools first, zero after them, none twice; each a contract answering its fee tier and the receiver’s router’s factory’s Uniswap V3 pool for the asset and USDC at its own fee tier, that fee under the owner’s bound. Reverts BadParams otherwise. Answers the set’s size and each pool’s fee tier, on the bare implementation too.
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The profile’s asset. |
pools | address[4] | The pool set as the owner signed it. |
boundBp | uint256 | The owner’s oracle bound, bp: every pool’s fee must be under it. |
Returns
| Name | Type | Description |
|---|---|---|
n | uint256 | The set’s size. |
fees | uint24[4] | Each pool’s fee tier, zero past the set. |
kernelLinks
function kernelLinks(
) external view returns (IKernelLogic.Link[] memory links, bool oneChain)The member’s strategy, read by its kernel before an ownership transfer applies: its links in the kind’s order, each on its chain, and whether every link lives on this chain (the new owner may then sign by ERC-1271).
Returns
| Name | Type | Description |
|---|---|---|
links | IKernelLogic.Link[] | Every other member, in the kind’s order, each as its chain id and address. |
oneChain | bool | Whether every member lives on this chain. |
lastOwnerNonce
function lastOwnerNonce() external view returns (uint64)The highest owner nonce used at this member; 0 none yet.
Constants
Values compiled in, or set once when the contract is deployed (immutable).
address public immutable MARKET;
address public immutable UNWIND_DEBT;
address public immutable UNWIND_RESIDUE;
address public immutable READINGS;
address public immutable REWARDS;
address public immutable LEG_OWNER;
address public immutable LEVER;
bytes32 public immutable DEPLOYMENT;
uint256 public immutable CHAIN_ID;| Name | Description |
|---|---|
MARKET | The market module (sales, profile checks), its code hash and its deployment checked at deployment. |
UNWIND_DEBT | The unwind debt module (the permissionless unwind’s parts, the key’s repay), its code hash and its deployment checked at deployment. |
UNWIND_RESIDUE | The unwind residue module (the permissionless unwind’s steps, the move home, the local exit, the key’s sends), its code hash and its deployment checked at deployment. |
READINGS | The readings module (the readings for the hub, the report, Circle’s mints, the views of the profile, the limits and the key’s borrow), its code hash and its deployment checked at deployment. |
REWARDS | The rewards module (the rewards path and its view, the checks of the pool set and of AAVE’s source), its code hash and its deployment checked at deployment. |
LEG_OWNER | The legs’ owner module (the owner’s run, Allow and the leg’s settings, by call or signature), its code hash checked at deployment: the module of every selector no other module claims. |
LEVER | The lever module (the key’s lever and AAVE’s flash-loan callback), its code hash and its deployment checked at deployment. |
DEPLOYMENT | The hash of the market facts this code was built from: the leg accepts only modules built from the same. |
CHAIN_ID | The chain this code was built for: a member runs it only there, and its initialisation refuses any other (WrongChain). |
Events
SettingApplied event
event SettingApplied(uint8 key, bytes32 value);An owner’s setting applied at the leg.
Emitted by: applySetting, setSetting, setSettingSigned
Fields
| Name | Type | Description |
|---|---|---|
key | uint8 | The setting. |
value | bytes32 | The value. |
ReadySent event
event ReadySent(uint8 indexed link);This leg’s READY went to link link.
Emitted by: kernelInit, announceReady
Fields
| Name | Type | Description |
|---|---|---|
link | uint8 · indexed | The link concerned, by its index. |
ReadyPending event
event ReadyPending(uint8 indexed link);Circle refused this leg’s READY to link link: announceReady resends it.
Emitted by: kernelInit, announceReady
Fields
| Name | Type | Description |
|---|---|---|
link | uint8 · indexed | The link concerned, by its index. |
LinkReady event
event LinkReady(uint8 indexed link);Link link’s finalized READY arrived: it may now receive money from this contract.
Emitted by: handleReceiveFinalizedMessage, handleReceiveUnfinalizedMessage
Fields
| Name | Type | Description |
|---|---|---|
link | uint8 · indexed | The link concerned, by its index. |
Sent event
event Sent(uint8 indexed link, uint256 amount, uint256 maxFee, uint32 finality);USDC went to link link: on this chain by a counted transfer (maxFee and finality 0), else by a Circle burn only that link can complete.
Emitted by: send, localToHub, remoteToHub
Fields
| Name | Type | Description |
|---|---|---|
link | uint8 · indexed | The link concerned, by its index. |
amount | uint256 | The USDC sent, gross. |
maxFee | uint256 | The most Circle may take. |
finality | uint32 | Circle’s finality: 1000 fast (confirmed), 2000 standard (finalized), 0 on this chain. |
ReceivedFromLink event
event ReceivedFromLink(uint8 indexed link, uint256 amount, uint256 fee);USDC from link link arrived and was counted.
Emitted by: receiveLocal, receiveMint
Fields
| Name | Type | Description |
|---|---|---|
link | uint8 · indexed | The link concerned, by its index. |
amount | uint256 | The USDC, gross. |
fee | uint256 | Circle’s fee taken on it (0 on this chain). |
ReceivedFromOutside event
event ReceivedFromOutside(address indexed from, uint32 sourceDomain, uint256 amount);A Circle mint from a burn of no member arrived, net of Circle’s fee. Nothing is booked for it: at a leg it is the leg’s cash like any USDC it holds (the strategy’s, profit above the mark), at the hub it is the owner’s capital at the next sync (CapitalIn).
Emitted by: receiveMint
Fields
| Name | Type | Description |
|---|---|---|
from | address · indexed | Who burned it, on its chain. |
sourceDomain | uint32 | Its chain, as its Circle domain. |
amount | uint256 | The USDC that arrived, net of Circle’s fee. |
ReportSent event
event ReportSent(uint64 seq);This leg sent its report to its hub.
Emitted by: report
Fields
| Name | Type | Description |
|---|---|---|
seq | uint64 | The report’s sequence number. |
RunRecorded event
event RunRecorded(uint64 indexed runEpoch, uint64 group);This leg recorded its owner’s run.
Emitted by: recordRun, recordRunByOwner
Fields
| Name | Type | Description |
|---|---|---|
runEpoch | uint64 · indexed | A run’s number. A leg records a run only from its owner’s Run (signed, or the owner’s call), only above the one it records; a stop never moves it. |
group | uint64 | The run’s execution group. |
Stopped event
event Stopped(uint64 indexed runEpoch, uint8 by);The run stopped here: the execution key revoked, the unwind begun.
Emitted by: kernelStop, stopFromHub, stopStopped, handleReceiveFinalizedMessage, handleReceiveUnfinalizedMessage
Fields
| Name | Type | Description |
|---|---|---|
runEpoch | uint64 · indexed | A run’s number. A leg records a run only from its owner’s Run (signed, or the owner’s call), only above the one it records; a stop never moves it. |
by | uint8 | Who stopped the run: 1 the owner, 2 the escape hatch, 3 another member of the strategy. |
ExecutionAllowed event
event ExecutionAllowed(uint64 indexed runEpoch);The owner’s Allow at this member, the hub or a leg alike: the execution key may act here again.
Emitted by: allow, allowSigned
Fields
| Name | Type | Description |
|---|---|---|
runEpoch | uint64 · indexed | A run’s number. A leg records a run only from its owner’s Run (signed, or the owner’s call), only above the one it records; a stop never moves it. |
Unwound event
event Unwound(uint64 indexed runEpoch);The unwind ended here: this contract is settled. The stop stays until the owner allows execution.
Emitted by: unwindStep, sendHome
Fields
| Name | Type | Description |
|---|---|---|
runEpoch | uint64 · indexed | A run’s number. A leg records a run only from its owner’s Run (signed, or the owner’s call), only above the one it records; a stop never moves it. |
HubToldPending event
event HubToldPending();Telling the hub of a stop failed: tellHub retries it.
Emitted by: kernelStop, stopStopped, tellHub, recordRun, recordRunByOwner
HubTold event
event HubTold();The hub was told of this leg’s stop.
Emitted by: kernelStop, stopStopped, tellHub, recordRun, recordRunByOwner
LocalExitPaid event
event LocalExitPaid(address token, uint256 amount);A leg’s local exit paid a token to the owner on the leg’s chain: no bridge, no fee, nothing counted toward the hub.
Emitted by: localExit, localExitToken
Fields
| Name | Type | Description |
|---|---|---|
token | address | The token; 0 for the chain’s native coin (HYPE on HyperEVM). |
amount | uint256 | What it paid, the token’s units. |
Swapped event
event Swapped(bool assetToUsdc, uint256 amountIn, uint256 amountOut, uint256 lossUsd);A sale of the asset (or a purchase of it) on a pool of the owner’s set.
Emitted by: swap, unwindPart, unwindRepay
Fields
| Name | Type | Description |
|---|---|---|
assetToUsdc | bool | True for a sale of the asset. |
amountIn | uint256 | What it paid. |
amountOut | uint256 | What it received. |
lossUsd | uint256 | Its shortfall against AAVE’s price, USD 8 decimals. |
RepaidWithCollateral event
event RepaidWithCollateral(uint256 debtRepaid, uint256 collateralOut, uint256 lossUsd);Debt repaid with collateral through the receiver.
Emitted by: repayWithCollateral, unwindPart, unwindRepay
Fields
| Name | Type | Description |
|---|---|---|
debtRepaid | uint256 | The debt repaid, in its token’s units (USDC, or USDS on the PSM debt route). |
collateralOut | uint256 | The collateral that left. |
lossUsd | uint256 | Its shortfall against AAVE’s price, USD 8 decimals. |
Levered event
event Levered(
uint256 quantity,
uint256 loan,
uint256 debt,
uint256 usdcSpent,
uint256 lossUsd
);The long levered in one call.
Emitted by: lever
Fields
| Name | Type | Description |
|---|---|---|
quantity | uint256 | The asset bought and supplied. |
loan | uint256 | The USDC flash-loaned. |
debt | uint256 | The debt opened, in its token’s units (USDC, or USDS on the PSM debt route). |
usdcSpent | uint256 | How much the leg’s own USDC fell across the whole lever, never below zero. |
lossUsd | uint256 | The equity it lost, USD 8 decimals. |
UnwindPartFailed event
event UnwindPartFailed(uint8 part, bytes reason);An unwind part failed; the next step retries it.
Emitted by: unwindStep
Fields
| Name | Type | Description |
|---|---|---|
part | uint8 | The part. |
reason | bytes | Its revert data. |
RewardClaimed event
event RewardClaimed(uint8 source, uint256 gained);Rewards were claimed.
Emitted by: claimRewards, claimMerkl
Fields
| Name | Type | Description |
|---|---|---|
source | uint8 | 1 AAVE, 2 Merkl. |
gained | uint256 | What the leg gained (reward and USDC units). |
RewardSwapped event
event RewardSwapped(uint256 rewardIn, uint256 usdcOut, uint256 lossUsd);The reward was sold for USDC.
Emitted by: rewardPart, swapReward
Fields
| Name | Type | Description |
|---|---|---|
rewardIn | uint256 | The reward paid. |
usdcOut | uint256 | The USDC received. |
lossUsd | uint256 | Its shortfall against the feed, USD 8 decimals. |
Paused event
event Paused(bool paused);The key paused or unpaused its supply and borrow.
Emitted by: pause
Fields
| Name | Type | Description |
|---|---|---|
paused | bool | Whether paused. |
ReductionLatched event
event ReductionLatched();A protective repay of the key latched the leg reduction-only, until the owner’s reset.
Emitted by: repayWithCollateral, unwindPart, unwindRepay
ProfileSwitched event
event ProfileSwitched(bytes32 profile);The leg’s section switched, from its hub.
Emitted by: switchProfile
Fields
| Name | Type | Description |
|---|---|---|
profile | bytes32 | The profile’s registry entry id. |
Errors
A call that fails reverts with one of these, so a block explorer or a simulation shows which rule refused it.
| Error | When | Raised by |
|---|---|---|
BadMessage() | A message, a mint or a report refused: its sender, chain, finality, kind, layout or amount. | receiveLocal, handleReceiveFinalizedMessage, handleReceiveUnfinalizedMessage, receiveMint |
LowGas() | The caller left too little gas for a registry read (30,000 gas and its margin): the whole call reverts, so a starved read never opens the hatch or forgives a fee. | — |
NoKey() | The registry has no execution key for the group: no run starts in it and no member moves into it, since nobody could protect it. | — |
GroupStopped() | The registry has stopped the run’s group, or failed to say it did not. | — |
BadProfile() | The asset profile is refused for this contract. | kernelInit, switchProfile, checkSource, setSetting, setSettingSigned |
StalePrice() | A price is stale, or the sequencer is down. | swap, repayWithCollateral, unwindPart, unwindRepay, rewardPart, swapReward, lever |
BadRound() | A price source answered a round that is not usable: no answer, zero or negative, or unfinished. | — |
SequencerDown() | The chain's sequencer feed reports it down, or back up too recently for prices to be trusted. | — |
NotNamed() | The signed message does not name this member on this chain. | — |
StaleNonce() | The signed message's nonce is not above the last one this member used. | — |
Expired() | The signed message's deadline has passed. | — |
NotOwner() | The caller is not the owner’s wallet. | allow, recordRunByOwner, setSetting |
StaleGeneration() | The signed message names an owner generation other than the current one: the owner changed since. | — |
NotHere() | A leg beside its hub takes its profile from its hub’s profile switch, not at the leg. | setSetting, setSettingSigned |
NamedTwice() | Two items of the owner’s Run name this leg on this chain. | recordRun |
StaleRun() | The run is not above the one this leg records. | recordRun, recordRunByOwner |
BadLinks() | The links at creation: none, more than 4, a zero, a repeat, this contract, or the hub’s chain misstated. | kernelInit |
WrongMember() | The kind does not name this logic’s member type at this member’s place. | kernelInit |
WrongChain() | The kind places this member on another chain, or this code was built for another chain. | kernelInit |
NotExecution() | The caller is not the execution key of the run’s group. | supply, withdraw, setEMode, pause, send, swap, repayWithCollateral, repay, collateralOff, report, borrow, claimRewards, claimMerkl, swapReward, lever |
NotAllowed() | The caller is not the one this function admits, or the state does not allow it. | applySetting, send, limits, uniswapV3SwapCallback, kernelInit, kernelUpgraded, kernelStop, kernelStopState, kernelGroup, announceReady, receiveLocal, stopFromHub, tellHub, localToHub, remoteToHub, swap, repayWithCollateral, switchProfile, unwindPart, unwindRepay, repay, unwindStep, collateralOff, sendHome, localExit, exitReady, owed, status, holdings, report, receiveMint, borrow, usdsBack, runAdmissible, toDebtFor, reductionOnly, rewardPart, claimRewards, claimMerkl, swapReward, rewardPins, peggedLive, checkSource, checkPools, lever, executeOperation, allow, allowSigned, recordRun, recordRunByOwner, localExitToken, setSetting, setSettingSigned, kernelLinks, kernelTransferred, lastOwnerNonce |
NotReady() | The link cannot receive yet: its code is not there, or its finalized READY has not arrived. | send |
Unwinding() | Refused while unwinding: the execution key may not act. | applySetting, supply, withdraw, setEMode, pause, send, swap, repayWithCollateral, switchProfile, repay, collateralOff, report, borrow, claimRewards, claimMerkl, swapReward, lever, setSetting, setSettingSigned |
Revoked() | Refused while the execution key is revoked. | supply, withdraw, setEMode, pause, send, swap, repayWithCollateral, repay, collateralOff, report, borrow, claimRewards, claimMerkl, swapReward, lever |
NoRun() | No run is recorded (or, at the hub, none is going). | supply, withdraw, setEMode, pause, send, stopStopped, swap, repayWithCollateral, repay, collateralOff, report, borrow, claimRewards, claimMerkl, swapReward, lever |
WrongRun() | The owner’s Allow names another run than the one the member records. | allow, allowSigned |
StaleStop() | The owner’s Allow names another count of stops than the member’s: a stop since it was made voids it. | allow, allowSigned |
OwnersDiffer() | A member the profile switch reaches has another owner or owner generation than the member sending it: members change owners one by one. | switchProfile |
AlreadyStopped() | The member is already stopped: the owner’s Stop is refused there. | kernelStop |
GroupNotStopped() | The escape hatch is shut: the registry answered that this group is not stopped (a read that fails, or answers malformed, reads as stopped). | stopStopped, localExit, localExitToken |
FeeAboveCap() | Circle’s minimum fee is above 10 bp of the amount, or a fast transfer’s fee above its cap. | send |
OverFeeBudget() | Circle’s fees of the last two UTC days, this one included, would exceed the daily fee budget. | — |
Reentrancy() | A call into this contract from inside one of its own. | applySetting, supply, withdraw, setEMode, send, kernelStop, receiveLocal, stopFromHub, stopStopped, handleReceiveFinalizedMessage, handleReceiveUnfinalizedMessage, swap, repayWithCollateral, switchProfile, unwindRepay, repay, unwindStep, collateralOff, sendHome, localExit, report, receiveMint, borrow, claimRewards, claimMerkl, swapReward, lever, allow, allowSigned, recordRun, recordRunByOwner, localExitToken |
Unsupported() | No function of this contract or its modules answers that call. | checkSetting, applySetting, fallback, kernelInit, unwindPart, unwindRepay, rewardPart, setSetting, setSettingSigned |
ZeroAmount() | An amount of zero. | send, swap, repayWithCollateral, unwindPart, unwindRepay, repay, rewardPart, swapReward, lever |
GasTooLow() | Less gas left than a tried message, a part or an action needs: the call reverts rather than skipping it. | kernelInit, kernelStop, announceReady, stopStopped, tellHub, unwindStep, report, recordRun, recordRunByOwner |
RunNotAdmitted() | The owner’s run is refused at this leg: a position is open here. | recordRun, recordRunByOwner |
BadDeployment() | At deployment: the market’s facts refused (member type and chain, sequencer, the cash read its type needs, addresses, the bound’s ceiling, AAVE’s answers, the receiver’s pool, a partial rewards path, a partial USDS route’s pair or one whose wrapper, USDS reserve or receiver does not match). | — |
BadAsset() | A token that is not the profile’s asset or USDC (or, for collateralOff, the asset itself). | withdraw, collateralOff, claimMerkl |
BadParams() | The leg’s parameters, or a health floor, out of bounds. | checkSetting, applySetting, kernelInit, checkPools, lever |
BelowHealthFloor() | The health factor afterwards would not be strictly above the floor plus a hundredth of it (the key’s own actions), or is below the floor (the latch’s reset). | checkSetting, applySetting, withdraw, setEMode, kernelInit, collateralOff, borrow, rewardPart, lever |
HealthFell() | The health factor afterwards is lower than before. | repayWithCollateral, unwindPart, unwindRepay, collateralOff, rewardPart, swapReward |
AboveBound() | A repay with collateral beyond its bound: the owner’s bound against the reference, or, protective, the liquidation bonus of the debt that fell. | repayWithCollateral, unwindPart, unwindRepay, lever |
OverBudget() | The 24-hour loss budget would be exceeded. | send, swap, repayWithCollateral, unwindPart, unwindRepay, repay, borrow, rewardPart, swapReward, lever |
SwapShort() | A sale received less than its bound. | swap, unwindPart, unwindRepay, rewardPart, swapReward, executeOperation |
RewardCollateralOn() | The reward reserve is still collateral: switch it off first. | rewardPart, swapReward |
PoolOffOracle() | The pool’s price is already beyond the band: the sale waits. | unwindPart, unwindRepay, rewardPart, swapReward |
BandCrossed() | The receiver’s swap left the pool’s price beyond the band. | unwindPart, unwindRepay |
NoRewards() | This market has no rewards path. | claimRewards, claimMerkl, swapReward |
IsPaused() | The key paused its supply and borrow. | supply, borrow, lever |
NoLiquidity() | AAVE’s reserve holds nothing to withdraw now. | unwindPart, unwindRepay |
NoPool() | The pool index is past the owner’s pool set. | swap, repayWithCollateral, unwindPart, unwindRepay, lever, executeOperation |
NoRoute() | A debt route the leg does not know, or PSM on a market without the USDS route’s pair. | kernelInit |
DebtRoute() | A conversion of the debt refused: Sky’s PSM wrapper halted, its fee above the owner’s cap, or what it gave short of par less that cap. | repayWithCollateral, unwindPart, unwindRepay, repay, borrow, usdsBack, toDebtFor, lever, executeOperation |
ReductionOnly() | Refused while the leg is latched reduction-only: a borrow, a lever, a purchase of the asset, or a withdrawal that lowers the health factor. | withdraw, swap, borrow, lever |
BadModule() | At deployment: a module whose code hash or deployment is not the pinned one. | the deployment (constructor) |
Types
LegStatus struct
A leg’s standing, as it reports it and as the hub reads it: the run it last recorded, revoked, unwinding, settled (debts repaid, assets home, nothing in flight, residue dust or quarantined), quarantined (part of its residue cannot be sold now), and the USDC it needs from the hub to repay its debt. A leg’s report (LegReport) carries it beside its holdings and its counters.
struct LegStatus {
uint64 runEpoch;
bool revoked;
bool unwinding;
bool settled;
bool quarantined;
uint256 owed;
}Holding struct
One holding in a leg’s reading: an asset id (keccak256("dltx.asset.USD"), a profile’s holding, a short’s id) and a signed quantity in 18 decimals.
struct Holding {
bytes32 asset;
int256 quantity;
}