HyperStrategy
Contract:
HyperStrategy.sol(HyperEVM) Implements:CCIPReceiver,CCIPSender
Overview
HyperStrategy is the strategy-execution contract deployed on HyperEVM. It serves as the bridge endpoint between Ethereum Mainnet (via CCIP) and HyperCore (via system contracts). It does not hold long-term positions — funds pass through to HyperCore's HLP pool.
Responsibilities
| Function | Description |
|---|---|
| CCIP Receiver | Receives USDC + encoded instructions from KingsVault on Ethereum. |
| CCIP Sender | Sends settlement reports and withdrawal funds back to Ethereum. |
| CoreWriter Caller | Sends HyperCore actions (deposit to HLP, withdraw from HLP, spot send). |
| L1Read Consumer | Reads HyperCore state (vault equity, spot balance) via precompile. |
Core Interactions
Writing to HyperCore (CoreWriter)
All actions sent via ICoreWriter(0x3333333333333333333333333333333333333333).sendRawAction(data).
Data Encoding:
- Byte 1: Version =
1 - Bytes 2-4: Action ID (big-endian uint24)
- Remaining: ABI-encoded payload
| Action ID | Name | Payload | Usage |
|---|---|---|---|
| 2 | Vault Transfer | (address vaultAddr, bool isDeposit, uint64 amount) |
Deposit to / withdraw from HLP |
| 6 | Spot Send | (address destAddr, uint64 amount, uint64 nonce) |
Bridge Core spot balance back to EVM |
Reading from HyperCore (L1Read Precompile)
Precompile address: 0x0000000000000000000000000000000000000800
| Query | Data Returned | Usage |
|---|---|---|
vaultEquity |
HLP vault equity for the strategy's address | NAV calculation |
spotBalance |
USDC spot balance on Core | NAV calculation |
| Oracle prices | Real-time price feeds | Price verification (if needed) |
Gas Cost: 2000 + 65 * (input_len + output_len)
Invalid Input
Querying an invalid asset or vault address will revert and consume all provided gas.
Inbound Flow (ETH → HyperEVM → HyperCore)
| Step | Action | Function |
|---|---|---|
| 1 | Receive CCIP message. | _ccipReceive(any2EvmMessage) |
| 2 | Decode instruction. | abi.decode(message.data) → "PUSH_TO_CORE" |
| 3 | Convert precision. | Adjust USDC amount for Core format (uint64). |
| 4 | Build payload. | Action ID 2: (vaultAddr, isDeposit=true, amount) |
| 5 | Prepend header. | 0x01000002 + ABI-encoded payload |
| 6 | Send to Core. | ICoreWriter(0x33...33).sendRawAction(data) |
Outbound Flow: Settlement Report
| Step | Action | Function |
|---|---|---|
| 1 | Query HLP equity. | L1Read precompile 0x800 |
| 2 | Query spot balance. | L1Read precompile 0x800 |
| 3 | Query EVM idle. | USDC.balanceOf(address(this)) |
| 4 | Sum total. | total = vaultEquity + spotBalance + evm_idle |
| 5 | Build CCIP message. | abi.encode(total) + ETH chain selector |
| 6 | Send to Ethereum. | router.ccipSend(ethChainSelector, message) |
Outbound Flow: Withdrawal
| Step | Action | Header |
|---|---|---|
| 1 | Withdraw from HLP. | Action 2: 0x01000002 — isDeposit=false |
| 2 | Wait for Core settlement. | HLP equity ↓, spot balance ↑ |
| 3 | Bridge spot to EVM. | Action 6: 0x01000006 — send to system address |
| 4 | Receive ERC-20 USDC on EVM. | System triggers USDC.transfer(strategy, amount) |
| 5 | Send via CCIP to ETH. | router.ccipSend(ethChainSelector, message) |
Delay Mechanism
CoreWriter imposes an on-chain delay (several seconds) for:
- Order actions
- Vault transfers (Action 2)
This prevents bots from exploiting HyperEVM to bypass L1 mempool ordering. Actions appear twice in the L1 explorer: first as "Enqueuing", then as "Executing".
Price Conversion
Raw values from L1Read precompiles must be converted:
| Type | Formula |
|---|---|
| Perps | Price = RawValue / 10^(6 - szDecimals) |
| Spot | Price = RawValue / 10^(8 - base_asset_szDecimals) |
Security Considerations
- CCIP Validation: Must verify
sourceChainSelectorandsenderto prevent forged messages. - No Automatic Safety Checks: HyperCore does not verify that the system address has sufficient supply or that the target is a valid ERC-20. Developer must validate.
- Precision Dust: When transferring between EVM (higher precision) and Core, fractional remainders are burned. This applies to HYPE and all spot tokens.
- System Address Format: Must use exact format:
0x20+ big-endian token index for general tokens,0x2222...2222for HYPE. - Asset Binding Required: Before any transfers, the ERC-20 contract must be linked to HyperCore via
requestEvmContract→finalizeEvmContract.