1ī¸Lending Core

The core entry of NAVI Protocol.

As a developer, your primary interactions with the NAVI Protocol will occur through the functions within the lending_core::incentive_v2 module. This module acts as the gateway for all write transactions, including deposits, withdrawals, borrowing, repayment, liquidations, and reward claims

Entry Functions

entry_deposit

This function allows a user to deposit a specified amount of a certain coin type into a lending pool. The deposit amount is then added to the pool's balance, and the deposit event is emitted.

public entry fun entry_deposit<CoinType>(
        clock: &Clock,
        storage: &mut Storage,
        pool: &mut Pool<CoinType>,
        asset: u8,
        deposit_coin: Coin<CoinType>,
        amount: u64,
        incentive_v1: &mut IncentiveV1,
        incentive_v2: &mut Incentive,
        ctx: &mut TxContext
    ) {}

example: https://suivision.xyz/txblock/5x5oAmbCq3CetnG6BrGBtSf9H3S7qhChvqcS7jphQp6o?tab=Overview

entry_withdraw

This function allows a user to withdraw a specified amount from a lending pool. The withdrawal amount is deducted from the pool's balance, and the withdrawal event is emitted.

public entry fun entry_withdraw<CoinType>(
        clock: &Clock,
        oracle: &PriceOracle,
        storage: &mut Storage,
        pool: &mut Pool<CoinType>,
        asset: u8,
        amount: u64,
        incentive_v1: &mut IncentiveV1,
        incentive_v2: &mut Incentive,
        ctx: &mut TxContext
    ) {}

example: https://suivision.xyz/txblock/9PmcTv7GYHQ7ECz4VFpGtYPVv64ny12fn5yeFjgFqZZS?tab=Overview

entry_borrow

This function allows a user to borrow a specified amount from a lending pool. The borrowed amount is deducted from the pool's balance, and the borrow event is emitted.

public entry fun entry_borrow<CoinType>(
        clock: &Clock,
        oracle: &PriceOracle,
        storage: &mut Storage,
        pool: &mut Pool<CoinType>,
        asset: u8,
        amount: u64,
        incentive: &mut Incentive,
        ctx: &mut TxContext
    ) {}

example: https://suivision.xyz/txblock/8rbib4Nc5WK8CeMSdqDKCHWjKsDKjzX3YJP95VvVW9zA?tab=Overview

entry_repay

This function allows a user to repay a specified amount of a loan. The repayment amount is added to the pool's balance, and the repay event is emitted.

public entry fun entry_repay<CoinType>(
  clock: &Clock,
  oracle: &PriceOracle,
  storage: &mut Storage,
  pool: &mut Pool<CoinType>,
  asset: u8,
  repay_coin: Coin<CoinType>,
  amount: u64,
  incentive: &mut Incentive,
  ctx: &mut TxContext
) {}

example: https://suivision.xyz/txblock/6uNqkQUK5WBALuaTwdv31ZfqzVTCqAqAX56gwqq5LoPS?tab=Overview

claim_reward

This function allows users to claim rewards of a specified pool. Rewards are given from the bonus pool and and the claim reward event is emitted.

public entry fun claim_reward<T>(
clock: &Clock, 
incentive: &mut Incentive,
funds_pool: &mut IncentiveFundsPool<T>, 
storage: &mut Storage, 
asset_id: u8, 
option: u8, 
ctx: &mut TxContext
) {}

entry_liquidation

This function is used to liquidate a loan when a borrower's collateral is insufficient to cover their debt. The liquidation process involves repaying the debt, and any excess amount is returned to the sender. The liquidation call event is emitted.

public entry fun entry_liquidation<DebtCoinType, CollateralCoinType>(
        clock: &Clock,
        oracle: &PriceOracle,
        storage: &mut Storage,
        debt_asset: u8,
        debt_pool: &mut Pool<DebtCoinType>,
        debt_coin: Coin<DebtCoinType>,
        collateral_asset: u8,
        collateral_pool: &mut Pool<CollateralCoinType>,
        liquidate_user: address,
        liquidate_amount: u64,
        incentive_v1: &mut IncentiveV1,
        incentive_v2: &mut Incentive,
        ctx: &mut TxContext
    ) {}

Non-entry Functions

deposit_with_account_cap

This function allows a user to deposit a specified amount of a certain coin type into a lending pool with an account cap. The deposit amount is then added to the pool's balance, and the deposit event is emitted.

public fun deposit_with_account_cap<T>(
clock: &Clock, 
storage: &mut Storage,
pool: &mut Pool<T>, 
asset: u8,
deposit_coin: Coin<CoinType>,
incentive_v1: &mut IncentiveV1,
incentive_v2: &mut Incentive,
account_cap: &AccountCap
) {}

withdraw

This function allows other contracts to withdraw a specified amount from a lending pool. Balance object will be returned. The withdrawal amount is deducted from the pool's balance, and the withdrawal event is emitted.

public fun withdraw<CoinType>(
        clock: &Clock,
        oracle: &PriceOracle,
        storage: &mut Storage,
        pool: &mut Pool<CoinType>,
        asset: u8,
        amount: u64,
        incentive_v1: &mut IncentiveV1,
        incentive_v2: &mut Incentive,
        ctx: &mut TxContext
    ): Balance<CoinType> {}

withdraw_with_account_cap

This function allows users to withdraw a specified amount from a lending pool with an account cap. Balance object will be returned. The withdrawal amount is deducted from the pool's balance, and the withdrawal event is emitted.

public fun withdraw_with_account_cap<CoinType>(
        clock: &Clock,
        oracle: &PriceOracle,
        storage: &mut Storage,
        pool: &mut Pool<CoinType>,
        asset: u8,
        amount: u64,
        incentive_v1: &mut IncentiveV1,
        incentive_v2: &mut Incentive,
        account_cap: &AccountCap
    ): Balance<CoinType> {}

borrow

This function allows other contracts to borrow a specified amount from a lending pool. Balance object will be returned. The borrowed amount is deducted from the pool's balance, and the borrow event is emitted.

public fun borrow<CoinType>(
        clock: &Clock,
        oracle: &PriceOracle,
        storage: &mut Storage,
        pool: &mut Pool<CoinType>,
        asset: u8,
        amount: u64,
        incentive: &mut Incentive,
        ctx: &mut TxContext
    ): Balance<CoinType> {}

borrow_with_account_cap

This function allows other contracts to borrow a specified amount from a lending pool with an account cap. Balance object will be returned. The borrowed amount is deducted from the pool's balance, and the borrow event is emitted.

public fun borrow_with_account_cap<CoinType>(
        clock: &Clock,
        oracle: &PriceOracle,
        storage: &mut Storage,
        pool: &mut Pool<CoinType>,
        asset: u8,
        amount: u64,
        incentive: &mut Incentive,
        account_cap: &AccountCap
    ): Balance<CoinType> {}

repay

This function allows other contracts to repay a specified amount of a loan. Balance object will be returned. The repayment amount is added to the pool's balance, and the repay event is emitted.

public fun repay<CoinType>(
        clock: &Clock,
        oracle: &PriceOracle,
        storage: &mut Storage,
        pool: &mut Pool<CoinType>,
        asset: u8,
        repay_coin: Coin<CoinType>,
        amount: u64,
        incentive: &mut Incentive,
        ctx: &mut TxContext
    ): Balance<CoinType> {}

repay_with_account_cap

This function allows other contracts to repay a specified amount of a loan with an account cap. Balance object will be returned. The repayment amount is added to the pool's balance, and the repay event is emitted.

public fun repay_with_account_cap<CoinType>(
        clock: &Clock,
        oracle: &PriceOracle,
        storage: &mut Storage,
        pool: &mut Pool<CoinType>,
        asset: u8,
        repay_coin: Coin<CoinType>,
        amount: u64,
        incentive: &mut Incentive,
        account_cap: &AccountCap
    ): Balance<CoinType> {}

claim_reward_non_entry

This function allows users to claim rewards of a specified amount. Rewards are given from the bonus pool and and the claim reward event is emitted. Balance object will be returned.

public fun claim_reward_non_entry<T>(
clock: &Clock, 
incentive: &mut Incentive,
funds_pool: &mut IncentiveFundsPool<T>, 
storage: &mut Storage, 
asset_id: u8, 
option: u8, 
ctx: &mut TxContext) Balance<T> {}

claim_reward_with_account_cap

This function allows users to claim rewards of a specified amount with an account cap. Rewards are given from the bonus pool and and the claim reward event is emitted. Balance object will be returned.

public fun claim_reward_with_account_cap<T>(
clock: &Clock, 
incentive: &mut Incentive,
funds_pool: &mut IncentiveFundsPool<T>, 
storage: &mut Storage, 
asset_id: u8, 
option: u8, 
account_cap: &AccountCap
ctx: &mut TxContext) Balance<T> {}

Last updated