返回 Skill 列表
extension
分类: 开发与工程无需 API Key

suilend

当用户询问关于Suilend、Suilend借贷、Suilend借款,或者希望在Sui上与Suilend集成时,应使用此技能。涵盖借贷市场、储备金、义务、存款、借款、提款、还款、清算、cTokens以及流动性挖矿奖励。

person作者: jakexiaohubgithub

Suilend Protocol on Sui

Suilend is a lending/borrowing protocol on Sui. Users deposit assets to earn interest and receive cTokens (receipt tokens), then use cTokens as collateral in obligations to borrow other assets. The protocol uses Pyth oracle price feeds and supports isolated assets, rate limiting, and liquidity mining rewards.

Package IDs

| Package | Original ID | Description | |---------|------------|-------------| | Core | 0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf | Lending market, reserves, obligations, liquidity mining |

Source Files

Decompiled Move source (latest, v16):

  • packages/mainnet_most_used/0x34/171e8092d831c1cb71d70b04389f9a0fec8af56f69e760b58d613d764c6945/decompiled_modules/

Architecture

  • LendingMarket<T>: Shared object holding all reserves, obligations, rate limiter, and fee config. Parameterized by market type (e.g., MAIN_POOL).
  • Reserve<T>: Per-asset market with available liquidity, cToken supply, borrow amounts, interest rates, oracle prices, and reward managers.
  • Obligation<T>: Per-user position tracking deposits (cTokens) and borrows. Up to 5 borrows per obligation. Health determined by LTV ratios.
  • CToken<T0, T1>: Receipt token for deposits. T0 = market type, T1 = underlying asset type.
  • ObligationOwnerCap<T>: Capability granting permission to borrow/withdraw from an obligation.
  • LendingMarketOwnerCap<T>: Admin capability for managing the lending market.
  • ReserveConfig: Per-reserve parameters (LTV, liquidation bonus, interest rate curve, deposit/borrow limits, fees).
  • Decimal: 18-decimal fixed-point math (u256, scale 1e18).

Key Design: cToken Model

  1. User deposits asset -> receives cTokens (exchange rate appreciates with interest)
  2. User deposits cTokens into obligation as collateral
  3. User borrows against collateral (subject to LTV limits)
  4. Interest accrues continuously via compound interest on cumulative borrow rate

Constants

  • Decimal precision: 1e18 (u256)
  • Max borrows per obligation: 5
  • Health check: weighted_borrowed_value_usd <= allowed_borrow_value_usd (healthy)
  • Liquidatable: weighted_borrowed_value_usd > unhealthy_borrow_value_usd
  • Prices from Pyth oracle feeds

Key Modules

| Module | Purpose | |--------|---------| | lending_market | Core entry points: deposit, borrow, repay, withdraw, liquidate, claim rewards | | obligation | Obligation struct, deposits/borrows tracking, health checks | | reserve | Reserve state, cToken exchange rates, interest, price feeds | | reserve_config | ReserveConfig: LTV, fees, interest rate curve, limits | | decimal | 18-decimal fixed-point math | | liquidity_mining | Pool rewards and user reward tracking | | staker | SUI staking integration for reserves | | oracles | Pyth price feed integration | | rate_limiter | Rate limiting for outflows |

Common Integration Patterns

Deposit Liquidity and Mint cTokens

let ctokens = lending_market::deposit_liquidity_and_mint_ctokens<MAIN_POOL, USDC>(
    lending_market,     // &mut LendingMarket<MAIN_POOL>
    reserve_index,      // u64
    clock,              // &Clock
    usdc_coin,          // Coin<USDC>
    ctx
);
// Returns: Coin<CToken<MAIN_POOL, USDC>>

Create Obligation

let obligation_cap = lending_market::create_obligation<MAIN_POOL>(lending_market, ctx);
// Returns: ObligationOwnerCap<MAIN_POOL>

Deposit cTokens as Collateral

lending_market::deposit_ctokens_into_obligation<MAIN_POOL, USDC>(
    lending_market, reserve_index, &obligation_cap, clock, ctokens, ctx
);

Borrow

let borrowed_coin = lending_market::borrow<MAIN_POOL, SUI>(
    lending_market, reserve_index, &obligation_cap, clock, amount, ctx
);

Repay

lending_market::repay<MAIN_POOL, SUI>(
    lending_market, reserve_index, obligation_id, clock, &mut coin, ctx
);

Withdraw cTokens from Obligation

let ctokens = lending_market::withdraw_ctokens<MAIN_POOL, USDC>(
    lending_market, reserve_index, &obligation_cap, clock, amount, ctx
);

Redeem cTokens for Underlying

let coin = lending_market::redeem_ctokens_and_withdraw_liquidity<MAIN_POOL, USDC>(
    lending_market, reserve_index, clock, ctokens, option::none(), ctx
);

Liquidate

let (ctokens, exemption) = lending_market::liquidate<MAIN_POOL, REPAY_COIN, WITHDRAW_COIN>(
    lending_market, obligation_id, repay_reserve_idx, withdraw_reserve_idx,
    clock, &mut repay_coin, ctx
);

Claim Rewards

let reward_coin = lending_market::claim_rewards<MAIN_POOL, REWARD_TOKEN>(
    lending_market, &obligation_cap, clock,
    reserve_index, reward_index, is_deposit_reward, ctx
);

Query Obligation Health

let obligation = lending_market::obligation<MAIN_POOL>(lending_market, obligation_id);
let is_healthy = obligation::is_healthy(obligation);
let is_liquidatable = obligation::is_liquidatable(obligation);
let deposited_usd = obligation::deposited_value_usd(obligation);
let borrowed_usd = obligation::weighted_borrowed_value_usd(obligation);

Related Skills

  • pyth -- Oracle price feeds used by Suilend reserves
  • sui-framework -- Core Sui types (Coin, Balance, Clock)