Hyperliquid leg
What each function of the Hyperliquid leg does, who may call it, when, and what it checks.
HyperliquidLeg. One code for every perp: the strategy’s short on Hyperliquid’s DEX 0, on HyperEVM, behind the member proxy and the kernel, whose code only its owner moves. The contract is the Hyperliquid account: its HyperCore account is created by its first Circle deposit, and it trades only through its own CoreWriter. No key outside this code can trade it or move its money: the one agent it may approve is the keyless referral’s, which no one holds a key for and whose one known signature sets DLTX’s referral code on the account, if its owner opted in, before its first order (no known feasible forgery of another admissible Hyperliquid action). The run’s execution key operates it within limits that survive that key’s compromise: IOC orders on the strategy’s perp only, within bands of its oracle and mark, under a leverage cap at both prices, with every action sent but not yet applied counted at its worst, and a daily growth budget; margin out of the account only under that cap; money only to the strategy’s other members. Every deposit of the key sets the account to Hyperliquid’s standard mode, the one whose reads it values. While it is unwinding or revoked, anyone may drive its unwind: one reduce-only close of the whole position at a band that widens over time, then the margin, HYPE for HyperCore’s fees, the pinned tokens’ sales and the USDC home. It reaches its hub, on Ethereum or Arbitrum, 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 perp position and nothing in flight. Its orders, sales and profile checks run in the route module (HyperliquidLegRoute), its unwind, readings and report in the unwind module (HyperliquidLegUnwind), its margin moves and keyless referral in the margin module (HyperliquidLegMargin), 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.
topUpHype
function topUpHype(uint256 amount) external payableSends HyperEVM HYPE (the leg’s, or brought with the call) to its HyperCore spot, where HyperCore’s transfers take their fee. It changes no holding, so it is not counted.
Who may call: The run’s execution key; anyone while the leg is unwinding or revoked.
When: In any state.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The HYPE, in wei. |
What it checks
- The key’s checks outside an unwind; a non-zero amount (
ZeroAmount).
send
function send(
uint8 k,
uint256 amount,
bool fast,
uint256 maxFee
) externalSends the leg’s USDC to member k, once it is ready, by a Circle burn only that member can complete. Circle’s fee is charged to the 24-hour fee budget, a share of the account’s value.
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 fee budget (OverFeeBudget).
order
function order(
bool isBuy,
uint64 sz,
bool reduceOnly,
uint128 cloid
) externalSends one IOC order on the strategy’s perp through the leg’s CoreWriter. A reduction (reduce-only) closes at most the whole position, within the reduce band of both the mark and the oracle, never waiting on a budget nor refused by what is in flight. Growth goes on the signed side only, never across zero nor on an isolated position, within the grow band of the stricter price, under the leverage cap at the mark and at the oracle with its worst fill and what is in flight counted, never across a mark-oracle gap over 20 bp, out of a 24-hour budget of one cap. No order size and no dollar minimum: the venue refuses an order under its own minimum. Every order, a reduction too, then counts in flight (inFlight): HyperCore applies it after its HyperEVM block, so the next cap check counts it at its worst until HyperCore’s clock has run 260 blocks past the latest one. No order names a builder.
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
isBuy | bool | True to buy. |
sz | uint64 | The size, 1e-8 of the perp’s unit, in whole size steps. |
reduceOnly | bool | True for a reduction. |
cloid | uint128 | The order’s client id. |
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). - Whole size steps, not zero (the size’s reason); the mark and the oracle read.
- A reduction: the side that shrinks the position (
NotGrowth), at most the position (OrderTooLarge). - Growth: not isolated (
Isolated), the signed side (NotGrowth), the cap (CapExceeded), the gap (MarkOracleGap), the budget (GrowthBudget); HyperCore’s clock read.
sellResidue
function sellResidue(uint256 i) externalSells pinned token i (HYPE above its fee reserve, or a USD stablecoin whole) for USDC on its spot market, IOC below its oracle by the spot band, in whole size steps.
Who may call: The run’s execution key; anyone while the leg is unwinding or revoked.
When: In any state, paced 20 blocks per token.
Parameters
| Name | Type | Description |
|---|---|---|
i | uint256 | The pinned token: 0 HYPE, 1 USDE, 2 USDT0, 3 USDH. |
What it checks
- The key’s checks outside an unwind; a pinned token (
BadAsset). - Worth Hyperliquid’s 10 USD at the limit (
BelowMinimum); not within 20 blocks of its last sale (TooEarly). - Not once the leg exited locally, until a new run (
NotAllowed): its spot balances are the local exit’s to send.
toMargin
function toMargin(uint256 amount) externalDeposits the leg’s USDC into its perp margin through Circle’s deposit wallet (the first one creates the HyperCore account), then sets the account to the standard mode (CoreWriter 16, disabled; a no-op once there), the one whose reads the leg values. It protects a position, so it goes even when HyperCore’s clock can’t be read (the move then reads as never settling until a later one is timed). Money in is never counted in flight; with the clock read, it times a reduction sent while it was not (inFlight).
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The USDC, 6 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).
fromMargin
function fromMargin(uint64 amount) externalBrings USDC from the perp margin back to the leg on HyperEVM: margin to spot for only what spot’s available USDC lacks, then spot to the leg. The margin moved keeps the account under the leverage cap at the mark and at the oracle with what is in flight counted (inFlight), and then joins it; with nothing to move from margin, spot comes home with no cap and nothing in flight, so stranded money always comes back. Needs HYPE on spot.
Who may call: The run’s execution key.
When: While the run goes.
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint64 | The USDC, 6 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). - Under the cap after it, what is in flight counted (
CapExceeded); HyperCore’s reads and its clock answer.
prime
function prime() externalPays the account’s first outgoing transfer fee (about 1 USDC), which fromMargin cannot on a fresh account: 1.2 USDC of margin to spot, then 0.05 USDC spot to the leg; the 1.2 USDC then counts in flight. Needs HYPE on spot.
Who may call: The run’s execution key.
When: While DEX 0 is flat.
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). - DEX 0 flat (
NotFlat); nothing in flight (InFlight).
prepareAndApproveReferral
function prepareAndApproveReferral(
bytes32 salt
) external returns (uint256 attempt, address agent)In one transaction: a new keyless referral attempt and the approval of its agent under the one agent name the leg ever uses, reserved for it (CoreWriter 9). The nonce is this block’s time in ms, the expiry ten minutes later; the attempt’s s is the leg’s own for the attempt and the key’s salt, so every attempt has a fresh agent, which no one holds a key for and no one knows before the key’s transaction is seen (so no one can claim it first). Anyone may then post the one action that agent has signed, setReferrer {code} at that nonce with no vault, its code the registry’s at the attempt, rebuilt from referralAttempt. The leg only submits the approval: whether HyperCore took it, and then the code, is read on Hyperliquid.
Who may call: The run’s execution key.
When: Only if the owner opted in, before the leg’s first order of any kind (perp or spot, by the key or by an unwind), once HyperCore knows the account; at most 3 attempts in the leg’s life.
Parameters
| Name | Type | Description |
|---|---|---|
salt | bytes32 | The key’s salt for the attempt: mixed into its s, so its agent is unknown until the transaction is seen. |
Returns
| Name | Type | Description |
|---|---|---|
attempt | uint256 | The attempt’s index, from 0. |
agent | address | Its agent. |
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 owner opted in (
ReferralNotOffered); no order ever sent, and a time a uint64 nonce and expiry can carry (ReferralClosed); fewer than 3 attempts so far (ReferralAttemptsUsed); HyperCore knows the account (NoCoreAccount); the agent recovered (else the library’sNoAgent). - The registry answers a valid referral code (
NoReferralCode).
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.
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).
applySetting
function applySetting(
uint8 key,
bytes32 value
) externalSets key to value for the owner, from the legs’ owner module (setSetting there): within the bounds of the leg’s creation, the leg’s other settings as they stand: the order bound within its range, the growth and reduce bands at least their floor and at most the order bound, the reduce band at most the ceiling of the perp’s maximum leverage, the fast fee cap and the fee budget within their caps, the leverage cap from 1x to its cap and at most the perp’s maximum leverage on Hyperliquid now. 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). - Within the bounds (
BadParams,Unsupported).
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.
receive
receive() external payableAccepts HYPE coming back from HyperCore; any other sender is refused.
Who may call: HyperCore’s HYPE system address only.
When: Always.
What it checks
- The sender is HyperCore’s HYPE system address (
NotAllowed).
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.
unwindStep
function unwindStep() externalOne step of the unwind: while the perp holds a position, one reduce-only IOC of the whole position at the close’s band; once flat, DEX 0’s withdrawable margin to spot, HYPE for HyperCore’s transfer fee when spot holds less than its reserve (at most three purchases each step of the spot band), spot USDC to the leg on HyperEVM, and the pinned tokens’ sales; then all the leg’s USDC above 1 USDC home to its hub (spot USDC at most 1 USDC is not moved either). Paced 20 blocks per kind. 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 a size, a price or a destination.
When: While the leg is unwinding or revoked.
What it checks
- Unwinding or revoked (
NotAllowed).
unwindStepAtMost
function unwindStepAtMost(uint64 maxSteps) externalThe same step as unwindStep, its close capped at maxSteps whole size steps of the perp: the order is the least of the position, the close’s value bound at the oracle and the cap. Paced 20 blocks by a kind of its own, apart from the whole close’s, so no capped close delays unwindStep; inside that pace a capped close larger in size steps than the last one goes at once, so a tiny close never holds back a larger one. A zero cap sends nothing and takes no pace. No dollar minimum: a capped part under Hyperliquid’s 10 USD minimum is sent and the venue refuses it; the whole remaining position goes however small. Once flat, the rest of the step runs as unwindStep’s, to the unwind’s end.
Who may call: Anyone: the cap only makes a close smaller, and the whole close is already anyone’s.
When: While the leg is unwinding or revoked.
Parameters
| Name | Type | Description |
|---|---|---|
maxSteps | uint64 | The most the close sends, in whole size steps of the perp (10^-szDecimals of the coin, a position’s unit, not an order’s 1e-8). |
What it checks
- Unwinding or revoked (
NotAllowed).
sendHome
function sendHome() externalSends the leg’s own HyperEVM USDC to its hub with no HyperCore read, so it goes even when the precompiles fail. A move between members, never counted.
Who may call: Anyone, by the unwind’s fixed rules: no caller chooses a size, a price or a destination.
When: While the leg is unwinding or revoked.
What it checks
- Unwinding or revoked (
NotAllowed).
report
function report() externalSends the leg’s report to its hub, by a finalized Circle message: its holdings, counters and status, every figure read in this block.
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.
localExit
function localExit() externalThe leg’s local exit: on HyperEVM its USDC and its HYPE to the owner its kernel holds now (LocalExitPaid, HYPE as token 0, given 100,000 gas: an owner that refuses it keeps it on the leg, where anyone’s topUpHype moves it to spot for the next call), each best-effort; on HyperCore, DEX 0’s withdrawable USDC to the leg’s own spot (no transfer fee there), sent on by a later call, and by CoreWriter sendAsset to the owner’s own HyperCore account the spot balances of USDC, HYPE and the three pinned stablecoins (LocalExitSent), together recorded as a move. Each is sent whole as read, but spot USDC, sent by the unwind’s rule for the account’s first transfer fee: a send that can’t pay it on top is dropped, so a read not fallen since the last send keeps that fee’s allowance (1.05 USDC) back, and a read under it unchanged since its own send is not sent again. A HyperCore send is an attempt: HyperCore applies it after the block or not at all, so exitReady() reads false until the move’s window passed, and a call after it reads the balances anew and sends what is still there (a dropped send is sent again). Confirmation is the balances read empty after the window, never the event. No bridge, no fee, nothing counted toward the hub. From then on, until the owner’s Allow (no run recorded meanwhile lifts it), the unwind moves no money of its own (no margin to spot, no purchase, no send, no sale, nothing home). Counted when anything left or was sent.
Who may call: Anyone: it pays only the owner, and its gate is DLTX’s absence; an owner with no HYPE on HyperEVM can be helped.
When: Once the leg is revoked, the registry stopped its group and exitReady() holds.
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). exitReady(), read with a fixed gas (NotAllowed;LowGas).
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).
Read-only
Views and constants: they change nothing, and anyone may read them.
limits
function limits(
) external view returns (uint16 orderBoundBp, uint16 fastFeeCapBp, uint16 feeBudgetBp, uint8 side, uint16 maxLeverageX100, uint16 growBoundBp, uint16 reduceBoundBp)The owner’s bounds as they stand (the referral’s opt-in is read from the signed configuration).
Returns
| Name | Type | Description |
|---|---|---|
orderBoundBp | uint16 | The widest any order may stray from its reference, bp. |
fastFeeCapBp | uint16 | The most a fast Circle transfer may pay, bp of its amount. |
feeBudgetBp | uint16 | The most Circle’s fees may take in any 24 hours, bp of the account’s value. |
side | uint8 | The leg’s side on its perp: 2, short. |
maxLeverageX100 | uint16 | The most leverage the account may carry, × 100. |
growBoundBp | uint16 | The band around the stricter price within which an order may grow the position, bp. |
reduceBoundBp | uint16 | The band around both prices within which an order may reduce it, bp. |
shortPart
function shortPart(
) external view returns (uint32 perp, bytes32 asset, uint8 szDecimals, bytes32 profile)The short’s part of the leg’s profile.
Returns
| Name | Type | Description |
|---|---|---|
perp | uint32 | Its DEX 0 perp. |
asset | bytes32 | Its id in a report. |
szDecimals | uint8 | The perp’s size decimals. |
profile | bytes32 | The profile followed. |
MEMBER_TYPE
function MEMBER_TYPE() external view returns (uint8)This implementation’s member type: 3, the Hyperliquid leg.
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. |
inFlight
function inFlight(
) external view returns (uint64 steps, uint64 px, uint64 debit, uint64 l1At, uint64 cutSteps, uint64 cutPx, uint64 cutL1At)What the leg sent HyperCore that its reading may not show yet, as the next action would see it: each half zero once HyperCore’s clock has run 260 blocks past its latest action. Every cap check counts it at its worst: the debit, and every step in flight filled at the worst limit of its side, with its fee, valued at the price read then; an action already applied is counted twice, which is only stricter.
Returns
| Name | Type | Description |
|---|---|---|
steps | uint64 | The growth orders’ size steps. |
px | uint64 | Their worst limit, in the mark’s unit: the lowest for a sale. |
debit | uint64 | The margin taken out of the perp account (fromMargin, prime), USD × 1e6. |
l1At | uint64 | HyperCore’s block at the latest growth order, margin out or prime; 0 none. |
cutSteps | uint64 | The reductions’ size steps. |
cutPx | uint64 | Their worst limit, in the mark’s unit: the highest for a buy. |
cutL1At | uint64 | HyperCore’s block at the latest reduction (the largest uint64 when its clock could not be read); 0 none. |
unwindBandBp
function unwindBandBp() external view returns (uint16)The band the unwind closes at now, bp: the narrower of the owner’s order bound and the perp’s maintenance ceiling, widened by itself every 6 hours from the unwind’s first close, to at most 10 %; 0 when the perp’s facts can’t be read (nothing is closed then).
owed
function owed() external view returns (uint256)Always 0: this leg holds no debt.
status
function status() external view returns (LegStatus memory)The leg’s standing as it reports it: its run, revoked, unwinding, settled (no position and no notional on DEX 0, a position that can’t be read counting as none while DEX 0 shows no notional, its account value at most 0.01, spot USDC and the leg’s USDC at most 1 USDC each, no move between HyperEVM and HyperCore in the last 3 HyperEVM blocks nor the last 50 HyperCore blocks, every residue dust or quarantined), quarantined (a pinned token unsellable now: under the 10 USD minimum at the band, unpriced, or unfilled after 3 offers at the widest band over 24 hours; spot USDC that can’t move), and 0 owed.
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: USD (DEX 0’s account value less the perp at its mark, plus spot USDC, plus the leg’s USDC on HyperEVM) and the short’s id with the perp’s signed size, both 18 decimals; its counters; the block; the block of its latest move; its count of operations. A HyperCore read that fails reverts.
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 between HyperEVM and HyperCore. |
ops | uint64 | Its count of operations that can change a holding. |
runAdmissible
function runAdmissible() external view returns (bool)Whether the leg may take a new run: no perp position or notional on the strategy’s perp, and nothing in flight (an order, a debit or a cut still settling). Its HYPE, spot tokens and cash never count. The leg reads it itself, with a fixed gas, before it records its owner’s run.
referralAttempts
function referralAttempts() external view returns (uint256)How many keyless referral attempts the leg made: at most 3.
referralAttempt
function referralAttempt(
uint256 i
) external view returns (address agent, uint64 nonce, uint64 expiresAfter, bytes32 s, bytes32 code)Attempt i, enough for anyone to rebuild its public signed action: its code, no vault, the signature (r, s, 27) with the construction’s fixed r (0x8c007052…f9496c25).
Parameters
| Name | Type | Description |
|---|---|---|
i | uint256 | The attempt’s index. |
Returns
| Name | Type | Description |
|---|---|---|
agent | address | Its agent, approved under the reserved referral name. |
nonce | uint64 | The action’s nonce, ms. |
expiresAfter | uint64 | The action’s expiry, ms: the nonce plus ten minutes. |
s | bytes32 | The signature’s s: low, never 0. |
code | bytes32 | The referral code the attempt signs, read from the registry when it was made. |
exitReady
function exitReady() external view returns (bool)Whether the leg is flat for its local exit: no position open (as runAdmissible: no position on the perp, no notional on DEX 0, nothing in flight) and no move of money between HyperEVM and HyperCore outstanding: none in the last 3 HyperEVM blocks nor the last 50 HyperCore blocks, a move recorded while HyperCore’s clock could not be read outstanding until a step times it. The local exit reads it by a call to itself, with a fixed gas.
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 ROUTE;
address public immutable UNWIND;
address public immutable MARGIN;
address public immutable LEG_OWNER;
bytes32 public immutable DEPLOYMENT;
uint256 public immutable CHAIN_ID;| Name | Description |
|---|---|
ROUTE | The route module (orders, sales, profile checks), its code hash and its deployment checked at deployment. |
UNWIND | The unwind module (unwind, readings, report), its code hash and its deployment checked at deployment. |
MARGIN | The margin module (the key’s moves of money between HyperEVM and HyperCore, the keyless referral, the local exit), 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. |
DEPLOYMENT | The hash of the facts this code was built from (its member type and HyperEVM’s USDC): 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);Setting key of this member is now value (at a leg: the owner’s profile switch at a leg on another chain than its hub).
Emitted by: applySetting, setSetting, setSettingSigned
Fields
| Name | Type | Description |
|---|---|---|
key | uint8 | The setting. |
value | bytes32 | The value. |
UnwindClose event
event UnwindClose(uint64 sz, uint64 limit, uint16 bandBp);The unwind’s close went.
Emitted by: unwindStep, unwindStepAtMost
Fields
| Name | Type | Description |
|---|---|---|
sz | uint64 | Its size, 1e-8. |
limit | uint64 | Its limit, 1e8. |
bandBp | uint16 | The band it was priced at. |
HypeBought event
event HypeBought(uint64 sz, uint64 limit, uint8 purchase);A HYPE purchase for HyperCore’s fees went.
Emitted by: unwindStep, unwindStepAtMost
Fields
| Name | Type | Description |
|---|---|---|
sz | uint64 | Its size, Core wei. |
limit | uint64 | Its limit, 1e8. |
purchase | uint8 | Its number in this band step. |
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, unwindStepAtMost, 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. |
RouteOrder event
event RouteOrder(
uint128 indexed cloid,
bool isBuy,
uint64 sz,
uint64 limit,
bool reduceOnly
);The key’s order went.
Emitted by: order
Fields
| Name | Type | Description |
|---|---|---|
cloid | uint128 · indexed | Its client id. |
isBuy | bool | Its side. |
sz | uint64 | Its size, 1e-8. |
limit | uint64 | Its limit price, 1e8. |
reduceOnly | bool | Whether a reduction. |
ResidueSale event
event ResidueSale(uint256 indexed token, uint64 sz, uint64 limit);A pinned token’s sale went.
Emitted by: sellResidue, unwindStep, unwindStepAtMost
Fields
| Name | Type | Description |
|---|---|---|
token | uint256 · indexed | Its index. |
sz | uint64 | Its size, the token’s wei. |
limit | uint64 | Its limit, 1e8. |
LocalExitSent event
event LocalExitSent(uint64 token, uint64 amount);The local exit sent HyperCore a sendAsset to the owner’s own HyperCore account: sent, not known to have landed.
Emitted by: localExit
Fields
| Name | Type | Description |
|---|---|---|
token | uint64 | The HyperCore token (0 USDC, 150 HYPE, 235 USDE, 268 USDT0, 360 USDH). |
amount | uint64 | What it sent, the token’s wei (8 decimals for USDC, DEX 0’s margin included). |
ReferralApprovalSubmitted event
event ReferralApprovalSubmitted(
uint256 indexed attempt,
address indexed agent,
uint64 nonce,
uint64 expiresAfter,
bytes32 s,
bytes32 code
);A keyless referral agent’s approval was submitted to HyperCore (not known to have landed).
Emitted by: prepareAndApproveReferral
Fields
| Name | Type | Description |
|---|---|---|
attempt | uint256 · indexed | The attempt’s index. |
agent | address · indexed | Its agent. |
nonce | uint64 | The signed action’s nonce, ms. |
expiresAfter | uint64 | Its expiry, ms. |
s | bytes32 | The signature’s s. |
code | bytes32 | The code its action sets. |
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 |
BadSize() | An order's size is not a whole number of the perp's size steps, or is zero. | — |
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, setSetting, setSettingSigned |
NoAgent() | The referral attempt's signature recovers no agent. | — |
PrecompileFailed(address) | A HyperCore read precompile failed or answered something it could not decode. | — |
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. | topUpHype, send, order, sellResidue, report, toMargin, fromMargin, prime, prepareAndApproveReferral |
NotAllowed() | The caller is not the one this function admits, or the state does not allow it. | receive, topUpHype, kernelInit, kernelUpgraded, kernelStop, kernelStopState, kernelGroup, announceReady, receiveLocal, stopFromHub, tellHub, localToHub, remoteToHub, order, sellResidue, inFlight, applySetting, unwindBandBp, unwindStep, unwindStepAtMost, sendHome, owed, status, holdings, report, runAdmissible, toMargin, fromMargin, prime, prepareAndApproveReferral, referralAttempts, referralAttempt, localExit, exitReady, receiveMint, 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. | topUpHype, send, order, sellResidue, report, toMargin, fromMargin, prime, prepareAndApproveReferral, setSetting, setSettingSigned |
Revoked() | Refused while the execution key is revoked. | topUpHype, send, order, sellResidue, report, toMargin, fromMargin, prime, prepareAndApproveReferral |
NoRun() | No run is recorded (or, at the hub, none is going). | topUpHype, send, stopStopped, order, sellResidue, report, toMargin, fromMargin, prime, prepareAndApproveReferral |
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. | — |
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. | send |
Reentrancy() | A call into this contract from inside one of its own. | topUpHype, send, kernelStop, receiveLocal, stopFromHub, stopStopped, handleReceiveFinalizedMessage, handleReceiveUnfinalizedMessage, order, sellResidue, applySetting, unwindStep, unwindStepAtMost, sendHome, report, toMargin, fromMargin, prime, prepareAndApproveReferral, localExit, receiveMint, allow, allowSigned, recordRun, recordRunByOwner, localExitToken |
Unsupported() | No function of this contract or its modules answers that call. | fallback, applySetting, setSetting, setSettingSigned |
ZeroAmount() | An amount of zero. | topUpHype, send |
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, report, recordRun, recordRunByOwner |
RunNotAdmitted() | The owner’s run is refused at this leg: a position is open here. | recordRun, recordRunByOwner |
BadDeployment() | At deployment: a USDC other than HyperEVM’s. | — |
BadParams() | The leg’s parameters out of bounds. | applySetting |
BadAsset() | Not a pinned token. | sellResidue |
TooEarly() | A pinned token’s sale within 20 blocks of its last. | — |
NotGrowth() | An order on the wrong side: a growth against the signed side or across zero, or a reduction that would grow. | order |
CapExceeded() | The leverage cap would be exceeded (at the mark or at the oracle). | order, fromMargin |
OrderTooLarge() | A reduction larger than the position. | order |
BelowMinimum() | A pinned token’s sale under Hyperliquid’s 10 USD minimum. | — |
MarkOracleGap() | The mark and the oracle are more than 20 bp apart: growth waits. | order |
GrowthBudget() | The 24-hour growth budget would be exceeded. | order |
Isolated() | The position is isolated: no growth. | order |
InFlight() | An action sent is still counted in flight (260 of HyperCore’s blocks after the latest): no prime. | prime |
NotFlat() | DEX 0 holds a position: no prime. | prime |
ReferralNotOffered() | The owner did not opt in to the keyless referral. | prepareAndApproveReferral |
ReferralClosed() | The leg sent a growth order already, or the time is past what a uint64 nonce and expiry can carry: no referral attempt, ever. | prepareAndApproveReferral |
ReferralAttemptsUsed() | The leg made its 3 referral attempts. | prepareAndApproveReferral |
NoReferralCode() | The registry holds no referral code, or its answer failed or is not a valid code: no attempt is made. | prepareAndApproveReferral |
NoCoreAccount() | HyperCore does not know the account yet: an approval would be dropped. | prepareAndApproveReferral |
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;
}