Overview
MeltHub is the central contract deployed on HyperEVM. It handles:
- Receiving cross-chain bridge messages from
MeltBridgevia LayerZero - Minting wrapped
MeltAssettokens - Same-chain wrap/unwrap operations
- Routing tokens to HyperCore via precompiles
- Fee collection and management
OApp (LayerZero), Pausable, ReentrancyGuard
Constructor
| Parameter | Description |
|---|---|
_lzEndpoint | LayerZero endpoint address on HyperEVM |
_owner | Contract owner (admin operations) |
_feeCollector | Address that receives collected fees |
Token Registration
MeltFactory during deployment.
sourceEid_= 0 for same-chain tokensfeeBps_must be ≤MAX_FEE_BPS(1000 = 10%)- Emits
TokenRegistered
Same-Chain Operations
wrap
sourceEid == 0).
- Transfers original tokens from caller
- Deducts fee, mints wrapped tokens
- Returns amount after fee
unwrap
Cross-Chain Bridge
Inbound (_lzReceive)
Automatically called by LayerZero when a bridge message arrives fromMeltBridge:
- Decodes payload:
(originalToken, recipient, amount, toCore) - Looks up token config
- Deducts fee, mints wrapped tokens
- If
toCore == true: routes to HyperCore via_bridgeToCore()
bridgeOut
MeltBridge to release locked originals.
Requires msg.value for LayerZero gas fees. Use quoteBridgeOut to estimate.
quoteBridgeOut
HyperCore Integration
setCoreConfig
coreIndexId_— HIP-1 token index on HyperCoredecimalDiff_— EVM decimals minus Core decimals (for amount conversion)
Admin Functions
| Function | Description |
|---|---|
setFee(configKey, feeBps) | Update fee for a token |
pauseToken(configKey) | Pause a specific token |
unpauseToken(configKey) | Unpause a specific token |
pause() / unpause() | Pause/unpause entire hub |
setFeeCollector(address) | Update fee collector address |
collectFees(wrappedToken) | Withdraw accumulated fees |
Events
| Event | Emitted When |
|---|---|
TokenRegistered | New token pair registered |
Wrapped | Same-chain wrap executed |
Unwrapped | Same-chain unwrap executed |
BridgedIn | Cross-chain bridge received |
BridgedOut | Cross-chain bridge sent |
BridgedToCore | Token routed to HyperCore |
FeeUpdated | Token fee changed |
FeesCollected | Fees withdrawn |
Errors
| Error | Cause |
|---|---|
TokenNotRegistered | Operating on unregistered token |
TokenPaused | Token operations are paused |
InvalidFee | Fee exceeds MAX_FEE_BPS (10%) |
InvalidSourceChain | Wrong sourceEid for operation |
CoreNotConfigured | HyperCore config missing |
CoreUserNotActivated | Recipient doesn’t exist on HyperCore |
