đŸĻIncentive_v2

The core entry of Navi Protocol.

As a developer, your primary interactions with the Navi Protocol should be conducted through the functions contained within the incentive_v2 module. This module serves as the gateway for all write transactions, including deposit, withdrawal, borrowing, repayment, liquidation, and reward claim processes.

The functions within this module are categorized into two types: entry and non-entry calls.

Entry Functions:

  • Invoke the underlying base function.

  • Directly return the token object to the function sender.

Non-Entry Functions:

  • Also invoke the underlying base function.

  • Return the token object without handling it.

  • The caller, typically a developer or transaction builder, is required to manage the token object. Failing to do so will result in the transaction being reverted.

  • These functions offer greater flexibility for developers, enhancing interoperability and compatibility with other protocols.

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.

// lending protocol entry function
    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 repay<CoinType>(
  clock: &Clock,
  oracle: &PriceOracle,
  storage: &mut Storage,
  pool: &mut Pool<CoinType>,
  asset: u8,
  repay_coin: Coin<CoinType>,
  amount: u64,
  ctx: &mut TxContext
) {}

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

Claim_reward

This functio allows users to claim rewards of a specified amount. 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 collateral is also sold to cover the debt, and any remaining collateral is returned to the treasury. 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

withdraw

This function allows other contracts 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 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> {}

borrow

This function allows other contracts 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 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> {}

repay

This function allows other contracts 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 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> {}

Last updated