1๏ธLending Core

The core entry of NAVI Protocol.

As a developer, your primary interactions with the NAVI Protocol will take place through the functions within the lending_core::incentive_v3 module. This module serves as the entry point for all write transactions, including deposits, withdrawals, borrowing, repayment, liquidations, and reward claims

Entry Functions

entry_deposit

circle-info

This function allows a user to deposit a specified amount of a given coin type into a lending pool. The deposit amount is added to the pool's balance, and a 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_v2: &mut IncentiveV2,
    incentive_v3: &mut Incentive,
    ctx: &mut TxContext
) {}

entry_withdraw_v2

circle-info

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 a withdrawal event is emitted.

entry_borrow_v2

circle-info

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 a borrow event is emitted.

entry_repay

circle-info

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

claim_reward_entry

circle-info

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

entry_liquidation_v2

circle-info

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

Non-entry Functions

deposit_with_account_cap

circle-info

This function is similar to a standard deposit but includes an account cap limitation. The deposit amount is added to the pool's balance, and a deposit event is emitted.

withdraw_v2

circle-info

This function allows other contracts to withdraw a specified amount from a lending pool. The balance object is returned, and a withdrawal event is emitted.

withdraw_with_account_cap_v2

circle-info

This function is similar to a standard withdraw but includes an account cap limitation. The balance object is returned, and a withdrawal event is emitted.

borrow_v2

circle-info

This function allows other contracts to borrow a specified amount from a lending pool. The balance object is returned, and a borrow event is emitted.

borrow_with_account_cap_v2

circle-info

This function is similar to a standard borrow but includes an account cap limitation. The balance object is returned, and the borrow event is emitted.

repay

circle-info

This function allows other contracts to repay a specified amount of a loan. The balance object is returned, and a repay event is emitted.

repay_with_account_cap

circle-info

This function is similar to a standard repay but includes an account cap limitation. The balance object is returned, and a repay event is emitted.

claim_reward

circle-info

Quick Reward Claiming Using the SDK

We recommend using the SDK to claim rewards because the SDK will automatically claim all available rewards and perform off-chain indexing to optimize gas usage.

SDK Benefits:

  • Off-chain indexing: Retrieves relevant rules without incurring on-chain gas costs.

  • Optimized filtering: Selects only the necessary rule IDs before executing on-chain transactions.

For users who want to implement customized and native reward claiming, we provide the following instructions:

Step-by-Step Process

  1. Retrieve Claimable Rewards

  • Use get_user_claimable_rewards to fetch claimable reward information.

  • Parse the response using parse_claimable_rewardsto determine RewardCoinType, coin_types, and rule_ids

get_user_claimable_rewards

circle-info

This function retrieves the claimable rewards for a user, returning detailed reward information.

parse_claimable_rewards

circle-info

This function parses the claimable rewards to return the asset coin types, reward coin types, user total rewards, user claimed rewards, and rule ids.

  • The coin_types are derived from the asset tokens involved.

  • The rule_ids are extracted from the parsed claimable rewards.

  1. Execute

claim_reward

claim_reward_with_account_cap

circle-info

This function is similar to a standard claim rewards but includes an account cap limitation. Rewards are distributed from the bonus pool, and a claim reward event is emitted.

  • Sample: Provide the appropriate parameters:

Full Claim Contract Demo

example: https://suivision.xyz/txblock/5Nr7nkQg8GGLepEPVRmZ2CamkUgsSoNMqDyhNGbVqjjWarrow-up-right

Last updated