Patterns
A contract that touches HyperCore stays solvent by recording an intent, sending the action, and settling only on HyperCore state that visibly moved.
On the HyperEVM, a HyperCore refusal never reverts your transaction. An action can be refused after the EVM transaction succeeded, reads are a block old when it lands, leaving HyperCore is charged on the other side, and past HyperCore state cannot be re-read.
One tokenised lending vault that already persisted intent, acted, then verified next block was still exploitable four ways under attack on testnet. One needed no HyperCore failure, only two users redeeming. The patterns below survived.
Intent now, settlement in a later block
Section titled “Intent now, settlement in a later block”Each HyperCore write becomes a state machine spanning blocks:
block N record intent (amount, snapshot, block number); send the CoreWriter actionblock > N read HyperCore through a precompile; if the position grew past the cumulative figure, settle (mint, credit, release)block >= N+5 if still not credited, mark failed; the depositor can pull the funds backblock > N+1200 a pending intent can only fail, never settleSay a user deposits in block 100. From block 101 the vault reads HyperCore, minting once the position grows past the cumulative figure. If nothing has moved by block 105, the intent can be marked failed; after block 1,300 it can never settle.
The contract never treats its own EVM success as evidence. Only HyperCore state, read later, moves the books.
The numbers
Section titled “The numbers”| Parameter | Value | Why |
|---|---|---|
| Grace before failing an intent | 5 blocks | an action landing late is not an action dropped |
| Settle window | 1,200 blocks | bounds interest slack behind a stale intent |
| Deposits in flight | 1 | same-block intents share a snapshot |
| Minimum deposit in one design | 0.1 USDC (1e7 at 8 decimals) |
below this, accrued interest can exceed the deposit inside the window |
| Precompile gas cap | about 2 x 2000 + 65 * (in + out) |
contains a bad input’s all-gas burn |
| Floor step, HyperCore to HyperEVM | 10^abs(evmExtraWeiDecimals); 100 for USDC |
non-round amounts are rejected |
| HyperCore-side reserve | at least 200k gas x the base fee, in HYPE or the token | the crossing fee comes out of HyperCore |
Accounting that survives refusal
Section titled “Accounting that survives refusal”- Intent, then reconcile. Record the amount, block number and comparison snapshot before sending; decide in a later block from a HyperCore read. The EVM receipt, the
RawActionlog and a successful status say nothing about the outcome. - Mint only what HyperCore credited:
0x811 supply.valuefor a lending position,0x801for a spot balance. Never the amount the user claims, and never0x812 balance, which includes the protocol’s retained buffer (46.57 USDC abovetotalSupplied - totalBorrowedwhen measured). - One deposit in flight, cumulative accounting. Same-block intents share a snapshot, so verified separately both pass when only one was funded. Settle against a cumulative figure (
accountedAssetsin one design) that every earlier settlement has raised; “verify next block” is necessary, not sufficient. - Reserve before you price a redemption. Two redeemers, one pot. No HyperCore failure, no adversary, no dropped action. If a request burns shares and fixes a claim but leaves assets untouched, the next redeemer divides the same assets by fewer shares: with 100 shares on 100 assets, the first redeemer of 50 shares is owed 50 and the second 100; so add every open claim to a reserved figure and price off assets net of it.
- Prove the position fell before paying out. Checking only the spot balance can pay a redeemer with a new depositor’s money when a withdraw was refused and a deposit arrived. Check the lending position fell by the withdrawn amount, allowing for accrual at the reserve’s advertised rate.
- Grace, then fail, then refund. After a fixed wait, let anyone mark the intent failed, with a permissionless path for the depositor to pull funds out of the contract’s HyperCore balance. Otherwise a refused supply strands the money in the vault’s HyperCore spot balance.
Operating rules
Section titled “Operating rules”| Rule | How, and why |
|---|---|
| Floor before bridging | With a negative offset, interest accruing at 8 decimals means a full USDC balance almost never qualifies: floor, send, leave the dust. One mainnet operator supplied 1 EVM wei less than it had bridged (moving assets) |
| Keep a HyperCore-side reserve for bridge gas | In HYPE or the token: “withdraw everything, then bridge everything” cannot work |
| Cap gas on every read | One function with an explicit cap and an output-length check, plus a non-reverting variant for loops and expected failures such as 0x811 before a first supply (precompiles) |
| Confirm from the outside | Poll the explorer’s userDetails for the typed action and its error, or the info API for the effect (userFills by cloid, ledger updates). Record it: the explorer keeps only the last 300 actions per user (CoreWriter) |
| Span blocks for setup | The sender must exist on HyperCore before its EVM block: deploy, activate or fund on HyperCore, set the abstraction mode (action 16, before any position), then send the first working action |
| Sample forward | Precompiles answer only at the latest block: store any rate, index or price you will later need to justify when you see it. A logger started late has lost the history for good |
| Prefer the deterministic leg | A split into Long and Short (action 17) mints a bounded, fully collateralised position and landed in its own block on testnet; a naked perp leg can fill at a moved price or not at all. As legs are not atomic, build split-and-quote before paired perp hedging |
Where the patterns stop
Section titled “Where the patterns stop”- Attribution is still open. A HyperCore spot send to a contract has no EVM-visible sender, so someone must name the receiver; under these patterns they cannot mint unbacked shares but can credit the wrong address. A fix needs a depositor attestation or a HyperCore sub-account per depositor.
- A principal ledger is not a solvency gate. Gating payouts on the cumulative deposit figure rejected an honest full redemption whose claim included accrued interest. Use it to check mints, not payouts.
- Not every design fits. Anything needing an all-or-nothing HyperCore outcome in one transaction has no pattern here (one transaction).
- Testnet hides duration bugs. The unstaking queue drains in about 5 minutes on testnet against 7 days on mainnet, so queue logic that looks right there is wrong in production.
For a tokenised lending vault built on these patterns, see composable credit.