Overview
HyperCore users can send and receive assets via atomic swaps through a modified HTLC deployed on HyperEVM. The key enhancement is HyperCore-native settlement on redemption: whenredeem() is called, the contract routes funds directly to the redeemer’s HyperCore spot account via the CoreWriter precompile — no separate bridge or withdrawal step is needed.
Network details
| Network | Chain ID |
|---|---|
| HyperEVM Mainnet | 999 |
| HyperEVM Testnet | 998 |
CoreWriter precompile
The CoreWriter precompile at0x3333333333333333333333333333333333333333 enables the HTLC to trigger HyperCore L1 actions directly from HyperEVM. It is used for two purposes:
- Inbound (X → HyperCore): After
redeem()is called, the contract callsspotSendvia CoreWriter to credit the asset directly to the redeemer’s HyperCore spot balance. - Outbound (HyperCore → X): Before initiating the HTLC, the user calls
sendRawActionvia CoreWriter to move assets from their HyperCore spot account to HyperEVM.
For a deeper look at how HyperEVM interacts with HyperCore — including available precompile actions, L1 state reads, and block timing — see the official Hyperliquid docs on interacting with HyperCore.
Contract architecture
Garden uses Hashed Time Lock Contracts (HTLCs) for atomic swaps. The HyperCore HTLC shares the same interface as the standard EVM HTLC, with theredeem function modified to auto-settle into HyperCore spot.
Initiate
Redeem
Refund
Instant refund
Core functions
Initiate
Locks ERC20 tokens (e.g. USDC) in the contract on HyperEVM. Two modes are supported:Direct initiation
Signature-based initiation (gasless)
With gasless initiation, the user signs an EIP-712
Initiate message off-chain and hands it to the solver. The solver calls initiateWithSignature on the user’s behalf — the user pays no gas for HTLC initiation.Redeem
The redeem function is modified from the standard EVM HTLC to settle funds directly into the redeemer’s HyperCore spot account.- Verifies the secret against the stored SHA-256 hash.
- Transfers the token to its system address (
0x2000...0000), triggering a HyperCore deposit. - Calls
spotSend(redeemer, tokenIndex, amount)via the CoreWriter precompile — the asset lands in the redeemer’s HyperCore spot balance.
The HyperCore
spotSend transaction hash is treated as the final settlement proof. No additional signing or bridging is required after redemption.Refund
Allows the initiator to reclaim locked tokens after the timelock has expired. For HyperCore swaps, the modifiedrefund() routes funds back to the initiator’s HyperCore spot account — no manual bridging back is needed.
- Verifies the timelock has expired.
- Transfers the token to its system address (
0x2000...0000), triggering a HyperCore deposit. - Calls
spotSend(initiator, tokenIndex, amount)via the CoreWriter precompile — the asset is returned directly to the initiator’s HyperCore spot balance.
Uses absolute block numbers for the timelock, consistent with the standard EVM HTLC.
Instant refund
Allows the swap to be cancelled before the timelock expires, provided the redeemer consents via an EIP-712 signature.Requires the redeemer’s signature to prevent unauthorized cancellations. This ensures both parties consent before the settlement window expires.
EIP-712 signing
Initiation domain
For gasless initiation, the user signs an EIP-712Initiate message:
Instant refund digest
Event logging
Both state transitions and the final HyperCore settlement emit standard events for off-chain monitoring:Order ID generation
Chain ID inclusion prevents cross-chain replay attacks, while the parameter combination ensures each order is uniquely identifiable.