Haedal on Sui
Haedal is a liquid staking and DEX protocol on Sui. Its core product is haSUI -- a liquid staking token representing staked SUI that accrues validator rewards automatically. Haedal also operates oracle-driven market maker pools (PMM/HMM) and a DEX aggregator router that routes swaps across multiple Sui DEXes.
Package IDs
| Package | Original ID | Latest Version ID | Description |
|---------|------------|-------------------|-------------|
| Liquid Staking (haSUI) | 0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d | 0x19e6ea7f5ced4f090e20da794cc80349a03e638940ddb95155a4e301f5f4967c (v7) | Core staking, hasui token, config, vault, interface entry points |
| DEX Router | 0xeffc8ae61f439bb34c9b905ff8f29ec56873dcedf81c7123ff2f1f67c45ec302 | 0x40e457bc65a398d2db7026881358fcb7cfa2f1bb052bca41f46c55a1103f2d6f (v18) | Haedal swap adapter for Cetus, DeepBookV3, Turbos, FlowX, Kriya, etc. |
| PMM Router | 0x43811be4677f5a5de7bf2dac740c10abddfaa524aee6b18e910eeadda8a2f6ae | 0xe450c157978058fc23078941924ad91bfe3022db6243ffa432f7209ad5bc9889 (v20) | Haedal PMM swap wrappers (oracle_driven_pool v1), aggregator adapters |
| HMM v2 Router | 0x368d13376443a8051b22b42a9125f6a3bc836422bb2d9c4a53984b8d6624c326 | 0x2e227a3cbc6715518b18ed339d2f967153674b7b257da114ca62c72b2011258a (v15) | Haedal HMM v2 swap wrappers (oracle_driven_pool v2), aggregator adapters |
| HMM/haSUI Aggregator | 0xc9337637c28d901b471dde1bae9f4427044c0be72a4bc652daa029e64965088b | 0x0c347031c6731ef63ea4e5f402f844c312f7ab02a72a857f73fc7d105d0a1495 (v4) | Router-integrated haSUI swap, HMM swap, haWAL swap adapters |
| PMM Aggregator v2 | 0x3239061b389dcc35be021bb13d174da82fafcc87bf3d8e176e6c62619311a90c | 0x6cc001bc430cb1fcb0379bed1ffd0668f35728b362caf0d5f9d9701975b2096a (v11) | PMM swap with additional DEX adapters (Bluefin, Momentum, Obric) |
| PMM Aggregator v3 | 0x6257c58feabffe3e1fa17c6a287b999405fbcfc0f3fb389783f481c514aec0ca | 0x5aafdf9cfa7c5c4dc78b309d7ebe4882904265e516f903a66fd33466dc4d616c (v2) | PMM swap returning remainder coin, additional DEX adapters |
| LSD Swap Adapters | 0x48393b16be854688f6c54ba562530e278f154ba1f49edc267402ec75e4bff105 | same (v1) | Aggregator adapters for haSUI LSD, Aftermath, AlphaFi, Scallop, Volo, SpringSUI |
Source Files
Decompiled Move source locations (relative to repo root):
- Liquid Staking:
packages/mainnet_most_used/0x19/e6ea7f5ced4f090e20da794cc80349a03e638940ddb95155a4e301f5f4967c/decompiled_modules/ - DEX Router:
packages/mainnet_most_used/0x40/e457bc65a398d2db7026881358fcb7cfa2f1bb052bca41f46c55a1103f2d6f/decompiled_modules/ - PMM Router:
packages/mainnet_most_used/0xe4/50c157978058fc23078941924ad91bfe3022db6243ffa432f7209ad5bc9889/decompiled_modules/ - HMM v2 Router:
packages/mainnet_most_used/0x2e/227a3cbc6715518b18ed339d2f967153674b7b257da114ca62c72b2011258a/decompiled_modules/ - HMM/haSUI Aggregator:
packages/mainnet_most_used/0x0c/347031c6731ef63ea4e5f402f844c312f7ab02a72a857f73fc7d105d0a1495/decompiled_modules/ - LSD Adapters:
packages/mainnet_most_used/0x48/393b16be854688f6c54ba562530e278f154ba1f49edc267402ec75e4bff105/decompiled_modules/
Architecture
- Staking (shared object): Central liquid staking contract. Holds SUI vaults, manages validator delegation, mints/burns haSUI via a TreasuryCap. Tracks total_staked, total_rewards, exchange rate between SUI and haSUI.
- HASUI: Fungible coin type (
0xbde4...::hasui::HASUI) with 9 decimals. Supply is controlled by the Staking object's TreasuryCap. - UnstakeTicket: Owned object representing a delayed unstake request. Contains claim_epoch and sui_amount; must wait 1-2 epochs to claim.
- Vault<T>: Internal balance wrapper used for SUI vault management (sui_vault, claim_sui_vault, protocol_sui_vault, service_sui_vault).
- StakingConfig: Stores fee parameters (deposit_fee, reward_fee, service_fee, withdraw_time_limit, validator_count).
- oracle_driven_pool::Pool<T0, T1>: PMM pools from external packages (
0xa0e3b0...for v1,0x9525de...for v2). Uses Pyth price oracles for pricing. - Exchange Rate:
total_sui * 1_000_000 / stsui_supply. 1 haSUI is always worth >= 1 SUI as rewards accrue.
Key Modules
| Module | Package | Purpose |
|--------|---------|---------|
| staking | Liquid Staking | Core staking logic: request_stake_coin, request_unstake_instant_coin, request_unstake_delay, claim_v2, exchange rate queries |
| hasui | Liquid Staking | HASUI coin type definition (OTW pattern) |
| interface | Liquid Staking | Entry point wrappers: request_stake, request_unstake_instant_v2, request_unstake_delay, claim_v2 |
| config | Liquid Staking | StakingConfig struct and fee getters |
| vault | Liquid Staking | Internal balance vault operations |
| haedal | DEX Router | SUI-to-haSUI swap (swap_a2b) and haSUI-to-SUI swap (swap_b2a) via staking |
| cetus | DEX Router | Cetus CLMM swap adapter with flash swap support |
| deepbookv3 | DEX Router | DeepBook V3 swap adapter |
| haedalpmm | PMM Router | PMM swap via oracle_driven_pool v1 (sell_base_coin / sell_quote_coin) |
| haedal_hmm_v2 | HMM v2 Router | HMM v2 swap via oracle_driven_pool v2 |
| haedal_hmm | HMM Aggregator | HMM swap integrated with router SwapContext |
| hasui | HMM Aggregator | haSUI swap integrated with router SwapContext |
| hawal | HMM Aggregator | haWAL (WAL liquid staking) swap via router |
| haedal_lsd | LSD Adapters | LSD swap adapter for haSUI staking/unstaking |
Common Integration Patterns
Stake SUI to get haSUI
// Entry function: deposits SUI, receives haSUI
// validator can be @0x0 to let protocol choose
public entry fun request_stake(
system_state: &mut SuiSystemState,
staking: &mut Staking,
sui_coin: Coin<SUI>,
validator: address,
ctx: &mut TxContext
)
// Programmable version returning haSUI coin
let hasui_coin = staking::request_stake_coin(
system_state, staking, sui_coin, @0x0, ctx
);
Unstake haSUI to SUI (instant)
// Instant unstake: burns haSUI, returns SUI immediately (with service fee)
public entry fun request_unstake_instant_v2(
system_state: &mut SuiSystemState,
staking: &mut Staking,
hasui_coin: Coin<HASUI>,
ctx: &mut TxContext
)
// Programmable version
let sui_coin = staking::request_unstake_instant_coin(
system_state, staking, hasui_coin, ctx
);
Unstake haSUI to SUI (delayed, no fee)
// Delayed unstake: burns haSUI, creates UnstakeTicket claimable after 1-2 epochs
staking::request_unstake_delay(staking, clock, hasui_coin, ctx);
// Claim after epoch passes
staking::claim_v2(system_state, staking, unstake_ticket, ctx);
PMM Swap (oracle-driven)
// Swap base to quote via Haedal PMM (uses Pyth price feeds)
let coin_out = haedalpmm::swap_a2b<TokenA, TokenB>(
pool, // &mut oracle_driven_pool::Pool<T0, T1>
price_info_a, // &PriceInfoObject (Pyth)
price_info_b, // &PriceInfoObject (Pyth)
coin_in, // Coin<T0>
clock, // &Clock
ctx
);
// HMM v2 variant (single price oracle)
let coin_out = haedal_hmm_v2::swap_a2b<T0, T1>(
pool, price_info, coin_in, clock, ctx
);
Query Exchange Rate
// Get haSUI/SUI exchange rate (scaled by 1_000_000)
let rate = staking::get_exchange_rate(staking);
// Convert SUI amount to haSUI amount
let hasui_amount = staking::get_stsui_by_sui(staking, sui_amount);
// Convert haSUI amount to SUI amount
let sui_amount = staking::get_sui_by_stsui(staking, hasui_amount);
Important Types
0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI-- the haSUI coin type0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::staking::Staking-- shared staking object0xa0e3b011012b80af4957afa30e556486eb3da0a7d96eeb733cf16ccd3aec32e0::oracle_driven_pool::Pool<T0, T1>-- PMM v1 pool0x9525dec11fb79eaef17138ee0352dedf4ee817bc44893a9465e7bb217b45761::oracle_driven_pool::Pool<T0, T1>-- HMM v2 pool0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price_info::PriceInfoObject-- Pyth price feed
Related Skills
sui-framework-- Core Sui types (Coin, Balance, SUI, TxContext)cetus-- Cetus CLMM pools (used by Haedal DEX router)deepbook-- DeepBook CLOB (used by Haedal DEX router)turbos-- Turbos CLMM (used by Haedal DEX router)pyth-- Pyth oracle price feeds (used by PMM/HMM pools)flowx-- FlowX DEX (used by Haedal DEX router)kriya-- Kriya DEX (used by Haedal DEX router)
微信扫一扫