LogoNAVI Protocol SDKS

Lending Module

The Lending Module provides comprehensive lending protocol functionality, including deposit, withdrawal, borrowing, repayment, liquidation, reward claiming, and oracle price updates.

Core Features

  • Deposit and Withdrawal: Deposit and withdraw from lending pools
  • Borrowing and Repayment: Borrow from and repay to lending pools
  • Liquidation Functionality: Liquidate unhealthy accounts
  • Reward Management: Claim lending rewards
  • Health Factor Monitoring: Monitor account health status
  • Oracle Updates: Update price oracles

Configuration Options

env

Environment setting, defaults to 'prod'. Different environments have different contracts.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient({
  configs: {
    lending: {
      env: 'prod',
    }
  }
})

API Reference

getPools

Get information about all available lending pools.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const pools = await walletClient.lending.getPools({
  cacheTime: 60 * 1000 // Cache for 60 seconds
})

Result Example

[{
  id: 19,
  coinType: '0x2::sui::SUI',
  suiCoinType: '0x2::sui::SUI',
  symbol: 'SUI',
  decimals: 9,
  ...
}]

getPool

Get information about a specific lending pool.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const pool = await walletClient.lending.getPool('0x2::sui::SUI', {
  cacheTime: 60 * 1000
})

deposit

Deposit into a lending pool.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const result = await walletClient.module('lending').deposit(
  '0x2::sui::SUI', // Asset identifier
  1000000000, // Deposit amount
  { 
    dryRun: false,
    accountCap: '0x123...' // Optional account cap
  }
)

withdraw

Withdraw from a lending pool.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const result = await walletClient.lending.withdraw(
  '0x2::sui::SUI', // Asset identifier
  1000000000, // Withdrawal amount
  { 
    dryRun: false,
    disableUpdateOracle: false, // Whether to disable oracle updates
    accountCap: '0x123...' // Optional account cap
  }
)

borrow

Borrow from a lending pool.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const result = await walletClient.lending.borrow(
  '0x2::sui::SUI', // Asset identifier
  1000000000, // Borrow amount
  { 
    dryRun: false,
    accountCap: '0x123...' // Optional account cap
  }
)

repay

Repay to a lending pool.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const result = await walletClient.lending.repay(
  '0x2::sui::SUI', // Asset identifier
  1000000000, // Repayment amount
  { 
    dryRun: false,
    accountCap: '0x123...' // Optional account cap
  }
)

getHealthFactor

Get the current account's health factor.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const healthFactor = await walletClient.lending.getHealthFactor()
console.log('Health Factor:', healthFactor)

liquidate

Liquidate unhealthy accounts.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const result = await walletClient.lending.liquidate(
  'SUI', // Asset identifier for debt payment
  1000000000, // Debt payment amount
  'USDC', // Asset identifier for liquidated collateral
  '0x123...', // Address of the account being liquidated
  { dryRun: false }
)

getAvailableRewards

Get the user's available lending rewards.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const rewards = await walletClient.lending.getAvailableRewards({
  cacheTime: 60 * 1000
})

Result Example

[{
  assetId: 19,
  amount: '1000000000',
  symbol: 'SUI',
  ...
}]

getClaimedRewardHistory

Get the user's claimed reward history.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const history = await walletClient.lending.getClaimedRewardHistory({
  page: 1,
  size: 10,
  cacheTime: 60 * 1000
})

Result Example

{
  "data": [
    {
      "type": "claim",
      "status": "success",
      "coinChanges": [
        {
          "symbol": "SUI",
          "amount": "1000000"
        }
      ],
      "timestamp": "1751358720243",
      "digest": "BVpGDpt9nmb1TkTnh65QmqedXt2gYqkVMhhkBE1uraWG"
    }
  ],
  "cursor": "next_page_cursor"
}

claimAllRewards

Claim all available lending rewards.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const result = await walletClient.lending.claimAllRewards({
  dryRun: false,
  accountCap: '0x123...' // Optional account capability
})

updateOracle

Update oracle prices.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const result = await walletClient.lending.updateOracle({
  dryRun: false,
})

getLendingState

Get the user's lending state.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const lendingState = await walletClient.lending.getLendingState({
  cacheTime: 60 * 1000
})

Result Example

[{
  assetId: 19,
  borrowBalance: '1979162',
  supplyBalance: '0',
  pool: {
    coinType: '375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT',
    id: 19,
    ...
  }
}]

createAccountCap

Create an account capability for the lending protocol.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
const result = await walletClient.lending.createAccountCap({
  dryRun: false
})

migrateBetweenSupplyPTB

Migrate assets between different supply pools.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'
import { Transaction } from '@mysten/sui/transactions'

const walletClient = new WalletClient()
const tx = new Transaction()

await walletClient.lending.migrateBetweenSupplyPTB(
  tx,
  '0x960b531667636f39e85867775f52f6b1f220a058c4de786905bdf761e06a56bb::usdy::USDY', // Source asset
  '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN', // Target asset
  {
    amount: 1000000, // Migration amount (optional, defaults to full balance)
    slippage: 0.002 // Slippage tolerance (optional, defaults to 0.005)
  }
)

const result = await walletClient.signExecuteTransaction({
  transaction: tx
})

migrateBetweenBorrowPTB

Migrate debt between different borrowing pools.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'
import { Transaction } from '@mysten/sui/transactions'

const walletClient = new WalletClient()
const tx = new Transaction()

await walletClient.lending.migrateBetweenBorrowPTB(
  tx,
  '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN', // Source debt asset
  '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN', // Target debt asset
  {
    amount: 1000000, // Migration amount (optional, defaults to full debt)
    slippage: 0.002 // Slippage tolerance (optional, defaults to 0.005)
  }
)

const result = await walletClient.signExecuteTransaction({
  transaction: tx
})

migrateBalanceToSupplyPTB

Migrate wallet balance to a specified supply pool, automatically swapping if asset types are different.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'
import { Transaction } from '@mysten/sui/transactions'

const walletClient = new WalletClient()
const tx = new Transaction()

await walletClient.lending.migrateBalanceToSupplyPTB(
  tx,
  '0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT', // Asset type in wallet
  '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN', // Target supply pool asset
  {
    amount: 1000000000, // Migration amount (optional, defaults to full balance)
    slippage: 0.002 // Slippage tolerance (optional, defaults to 0.005)
  }
)

const result = await walletClient.signExecuteTransaction({
  transaction: tx
})

Events

lending:deposit-success

Event triggered when deposit is successful.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
walletClient.events.on('lending:deposit-success', (data) => {
  console.log('Deposit successful:', {
    identifier: data.identifier,
    amount: data.amount
  })
})

lending:withdraw-success

Event triggered when withdrawal is successful.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
walletClient.events.on('lending:withdraw-success', (data) => {
  console.log('Withdrawal successful:', {
    identifier: data.identifier,
    amount: data.amount
  })
})

lending:borrow-success

Event triggered when borrowing is successful.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
walletClient.events.on('lending:borrow-success', (data) => {
  console.log('Borrowing successful:', {
    identifier: data.identifier,
    amount: data.amount
  })
})

lending:repay-success

Event triggered when repayment is successful.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
walletClient.events.on('lending:repay-success', (data) => {
  console.log('Repayment successful:', {
    identifier: data.identifier,
    amount: data.amount
  })
})

lending:liquidate-success

Event triggered when liquidation is successful.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
walletClient.events.on('lending:liquidate-success', (data) => {
  console.log('Liquidation successful:', {
    payIdentifier: data.payIdentifier,
    payAmount: data.payAmount,
    collateralIdentifier: data.collateralIdentifier,
    liquidationAddress: data.liquidationAddress
  })
})

lending:claim-rewards-success

Event triggered when reward claiming is successful.

Usage Example

import { WalletClient } from '@naviprotocol/wallet-client'

const walletClient = new WalletClient()
walletClient.events.on('lending:claim-rewards-success', (data) => {
  console.log('Reward claiming successful:', {
    rewards: data.rewards
  })
})