返回 Skill 列表
extension
分类: AI Agent 能力无需 API Key

alphafi

当用户询问关于AlphaFi、AlphaFi金库、AlphaFi收益、ALPHA代币质押、Sui上的自动复利金库,或者希望与AlphaFi集成时,应使用此技能。涵盖Cetus CLMM金库、Navi借贷金库、Bluefin永续合约金库、ALPHA代币质押池、基于收据的仓位以及自动复利策略。

person作者: jakexiaohubgithub

AlphaFi on Sui

AlphaFi is a yield optimization protocol on Sui that provides auto-compounding vaults built on top of other DeFi protocols. Users deposit assets into strategy-specific pools, receive xToken shares tracked by Receipt NFTs, and earn auto-compounded yields. Strategies include Cetus CLMM concentrated liquidity, Navi lending, Bluefin perps liquidity, and ALPHA token staking.

Package IDs

| Package | Original ID | Description | |---------|------------|-------------| | Core (Cetus + Navi + ALPHA) | 0x9bbd650b8442abb082c20f3bc95a9434a8d47b4bef98b0832dab57c1a8ba7123 | Cetus CLMM vaults, Navi lending vaults, ALPHA staking pool, distributor | | Bluefin Vaults | 0x066648edaf473d6cc14b7ab46f56b673be4e44f9c940f70b6bacd7848808859b | Bluefin-based concentrated liquidity vaults | | AlphaLend | 0x45564ea956f9b25890a5c1c3a199c8d86aabd5291b34723fb662283419ee2f4d | Single-asset leveraged lending loop vaults |

Source Files

Decompiled Move source:

  • Core (v29): packages/mainnet_most_used/0xa9/8ddf10b9eebf500c7e9a7ffd30358928b4617df6e179b817efebea1fff604e/decompiled_modules/
  • Bluefin (v21): packages/mainnet_most_used/0x57/69fdace205e2a37375b8bc46f839c20780c136f036d227f5a09ab5bd206908/decompiled_modules/
  • AlphaLend (v5): packages/mainnet_most_used/0xa5/3b109f1a9ec129cd194cc82108d911feae2da45758619ab06559692d56bc7d/decompiled_modules/

Architecture

  • Pool<T0, T1> (Cetus/Bluefin): Shared object for a CLMM pair vault. Tracks xTokenSupply (u128), tokensInvested (u128 liquidity), per-type acc_rewards_per_xtoken, and deposit/withdrawal fees.
  • Pool<T0> (Navi/ALPHA): Single-asset pool for lending or staking. Tracks xTokenSupply (u64), tokensInvested (u64), and rewards.
  • Receipt: Owned NFT representing a user's position in a pool. Contains xTokenBalance, last_acc_reward_per_xtoken for pending reward calculation, and pool_id. For ALPHA pool, also has locked_balance (LinkedTable of lock timestamps to xToken amounts) and unlocked_xtokens.
  • Investor<T0, T1>: Shared object that manages the actual Cetus/Bluefin position (tick range, balances, Cetus Position stored as dynamic field). Handles auto-compounding, rebalancing, and fee collection.
  • Distributor: Shared object that manages ALPHA token emission, pool reward allocation, fee wallets, and airdrop distribution. Contains an Allocator for per-pool reward scheduling.
  • ALPHA token: 0xfe3afec26c59e874f3c1d60b8203cb3852d2bb2aa415df9548b8d688e6683f93::alpha::ALPHA

Key Design: xToken Share Model

  • Deposits mint xTokens proportional to: deposited_value * 1e36 / exchange_rate
  • Withdrawals burn xTokens and return: xTokens * exchange_rate / 1e36
  • Exchange rate: tokensInvested * 1e36 / xTokenSupply (1e36 precision)
  • Rewards accumulate via acc_rewards_per_xtoken (1e36 precision per xToken)

Constants

  • Exchange rate precision: 1e36 (1_000_000_000_000_000_000_000_000_000_000_000_000)
  • Fee denominator: 10000 (basis points)
  • ALPHA pool default instant_withdraw_fee: 5000 (50%)
  • ALPHA pool lock period: 100 days (8_640_000_000 ms)
  • Version object required for all operations

Key Modules

| Module | Purpose | |--------|---------| | alphafi_cetus_pool | Pool<T0,T1> for Cetus CLMM: deposit, withdraw, claim rewards | | alphafi_cetus_investor | Investor<T0,T1>: manages Cetus position, auto-compound, rebalance | | alphafi_navi_pool | Pool<T0> for Navi lending: deposit, withdraw, reward claiming | | alphafi_navi_investor | Investor<T0>: manages Navi lending position, auto-compound | | alphapool | Pool<T0> for ALPHA staking with lock periods and airdrops | | alphafi_bluefin_type_1_pool | Pool<T0,T1> for Bluefin: deposit, withdraw | | alphafi_bluefin_type_1_investor | Investor for Bluefin positions | | distributor | ALPHA emission, reward allocation, fee wallets, airdrop | | allocator | Per-pool reward scheduling and distribution | | converter | Internal swap helper (uses Cetus pools) |

Common Integration Patterns

Deposit to Cetus Vault (get Receipt)

// Returns Option<Receipt> - new or updated
let receipt_opt = alphafi_cetus_pool::deposit<CoinA, CoinB>(
    version,           // &Version
    option::none(),    // Option<Receipt> (none for new, some for existing)
    pool,              // &mut Pool<CoinA, CoinB>
    coin_a,            // Coin<CoinA>
    coin_b,            // Coin<CoinB>
    distributor,       // &mut Distributor
    investor,          // &mut Investor<CoinA, CoinB>
    cetus_global_config,
    cetus_rewarder_vault,
    cetus_pool_b_sui,  // Cetus pool for reward swap
    cetus_pool_cetus_sui,
    cetus_pool_a_b,    // The actual Cetus CLMM pool
    clock,
    ctx
);
// Transfer receipt to sender
alphafi_cetus_pool::transfer_receipt(version, receipt_opt, ctx);

Withdraw from Cetus Vault

let receipt_opt = alphafi_cetus_pool::withdraw<CoinA, CoinB>(
    version,
    receipt,           // Receipt (consumed)
    alpha_receipt_opt, // Option<alphapool::Receipt> for ALPHA rewards
    pool,
    alpha_pool,        // &mut alphapool::Pool<ALPHA>
    distributor,
    investor,
    xtoken_amount,     // u128 amount of xTokens to withdraw
    cetus_global_config, cetus_pool_a_b,
    clock, ctx
);

Deposit to Navi Vault

let receipt_opt = alphafi_navi_pool::deposit<CoinType>(
    version,
    option::none(),    // Option<Receipt>
    pool,              // &mut Pool<CoinType>
    coin,              // Coin<CoinType>
    investor,          // &mut Investor<CoinType>
    distributor,
    navi_oracle,       // &PriceOracle
    navi_storage,      // &mut Storage
    navi_pool,         // &mut navi::Pool<CoinType>
    asset_id,          // u8 (Navi asset index)
    navi_incentive_v3, navi_incentive_v2,
    clock, ctx
);

Deposit ALPHA to Staking Pool

// Deposits are locked for ~100 days; early withdraw incurs 50% fee
alphapool::user_deposit(
    version,
    option::none(),    // Option<Receipt> (none for new)
    alpha_pool,        // &mut Pool<ALPHA>
    distributor,
    alpha_coin,        // Coin<ALPHA>
    clock, ctx
);

Withdraw ALPHA from Staking Pool

// instant_withdraw = true: withdraw locked balance with fee penalty
// instant_withdraw = false: only withdraw unlocked balance
alphapool::user_withdraw(
    version,
    receipt,           // Receipt (consumed)
    alpha_pool,        // &mut Pool<ALPHA>
    distributor,
    xtoken_amount,     // u64
    clock,
    instant_withdraw,  // bool
    ctx
);

Claim ALPHA Airdrop

alphapool::claim_airdrop(
    version, receipt, alpha_pool, distributor, clock, ctx
);

Related Skills

  • cetus -- Cetus CLMM pools (underlying DEX for Cetus vaults)
  • navi -- Navi Protocol lending (underlying for Navi vaults)
  • bluefin -- Bluefin perps (underlying for Bluefin vaults)
  • sui-framework -- Core Sui types (Coin, Balance, Clock)