🖱ī¸API Interface

NAVISDKClient(mnemonic: string, networkType: string, wordLength: number, numberOfAccounts: number)

Input:

  • mnemonic - optional - The mnemonic phrase to use for account generation. If not provided, a new mnemonic will be generated.

  • networkType - optional - The network type to use. Defaults to "mainnet".

  • wordLength - optional - The length of the mnemonic phrase to generate. Defaults to 12

  • numberOfAccounts - optional - The number of accounts to generate. Defaults to 10.

Return: naviSDKClient

const client = new NAVISDKClient({mnemonic: "", networkType: "mainnet", wordLength: 12, numberOfAccounts: 5}); 

Client Get All Accounts

getAllAccounts()

Return: A list of accounts that client has

const accounts = client.getAllAccounts()

Client Get Mnemonic

getMnemonic()

Return: Mnemonic of the client

const mnemonic = client.getMnemonic()

Get Pool Info

getPoolInfo(coinType: CoinInfo)

Input:

  • coinType - required - Pre-defined coin data type

Sui/vSui/NAVX/USDC/USDT/WETH/CETUS/haSui, you may import these from 'navi-sdk/dist/address'

Return: A Promise that resolves to the pool information.

import {USDC, Sui} from 'navi-sdk/dist/address';
client.getPoolInfo(USDC);

Get Pool Reserves & Get Pool Reserve Detail

getReserves()

Return: Json - All reserves information

getReserveDetail(coinType: CoinInfo)

Input:

  • coinType - rquired Specific coin type

Return: Json - Specific reserve information

client.getReserves()
client.getReserveDetail(Sui)

Get Health Factor

getHealthFactor(address: string)

Input:

  • address - required - string, this can be any address

Return: Number of health Factor

const hf = client.getHealthFactor(address: string) //This address can be any address

Get Dynamic Health Factor

getDynamicHealthFactor(address: string, coinType: CoinInfo, estimateSupply: number, estimateBorrow: number, is_increase: boolean = true)

Input:

  • address - required - any address you want to check

  • coinType - required - CoinInfo Data Type

  • estimateSupply - required - The estimated supply value.

  • estimateBorrow - required - The estimated borrow value.

  • is_increase - required - A boolean indicating whether to increase the dynamic health factor.

Return: A Promise that resolves to the dynamic health factor.

const hf = client.getDynamicHealthFactor(accounts[0].address, coinType: USDC, estimateSupply: 500000, estimateBorrow: 0, is_increase: boolean = true) 

Get All Navi Portfolios

getAllNaviPortfolios()

Return: A promise that resolves to an array of results for each account.

const allPortfolios = client.getAllNaviPortfolios()

Get All Balances

getAllBalances()

Return: A record containing the balances of each coin of all accounts.

const allBalances = client.getAllBalances()

Accounts

Public Attributes

  • account.address

  • account.client

  • account.keypair

Select Specific Account

const account = client.accounts[0]

const account5 = client.accounts[5]

Get Account Wallet Balance

getWalletBalance(ifPrettyPrint: boolean = true)

Input:

  • ifPrettyPrint - optional - Console print fancy format of account's balance

Return: A Promise that resolves to an object containing the balance of each coin in the wallet.

const personalBalance = account.getWalletBalance(ifPrettyPrint: boolean = true)

Get Account Navi Portfolio Balance

getNAVIPortfolio(ifPrettyPrint: boolean = true)

Input:

  • ifPrettyPrint - optional - Console print fancy format of account's portfolio

Return: A Promise that resolves to a Map containing the borrow and supply balances for each reserve.

const personalPortfolio = account.getNAVIPortfolio(ifPrettyPrint: boolean = true)

Get Account Health Factor

getHealthFactor()

Input:

  • address - optional - If leave empty, return use the account address

Return: The health factor as a number.

const accountHF = account.getHealthFactor();

Get Account Specific Coin

getCoins(coinType: any)

Input:

  • coinType - optional - You may pass in CoinInfo data Type or any string of coin Address, default is Sui address

Return: A Promise that resolves to the retrieved coin objects.

const coinA = account.getCoins(coinType: any = "0x2::sui::SUI")
const coinB = account.getCoins(USDC)

Get Account All Coins

getAllCoins(ifPrettyPrint: boolean = true)

Input:

  • ifPrettyPrint - optional - if print out fancy foramt of coins

Return: A Promise that resolves to the data containing all the coins owned by the account.

const allCoins = account.getAllCoins(ifPrettyPrint: boolean = true)

Create account Cap

createAccountCap()

Result: Will create an accountCap object and transfer it the tx initializer

account.createAccountCap()

Send Token to Single or Multiple recipients

sendCoin(coinType: any, recipient: string, amount: number)

sendCoinToMany(coinType: any, recipient: string[], amounts: number[])

Input:

  • coinType - required - Can pass in either CoinInfo Data Type or string of coin address

  • recipient - requried - String of recipient address

  • amount - required - Amount of coin send out

account.sendCoinToMany(NAVX, [address1, address2], [1e9, 2e9])
account.sendCoin("0x2::sui::SUI", address1, 1e9)

Transfer Objs to single or multiple recipients

transferObjs(object: string, recipient: string)

transferObjsToMany(objects: string[], recipient: string[])

Input:

  • object - required - ObjectId of the object

  • recipient - requried - String of recipient address

account.transferObjsToMany(['0x11', '0x12'], [address1, address2])
account.transferObjs('0x111', address1)

Interactions with Navi Protocol

Deposit

depositToNavi(coinType: CoinInfo, amount: number)

Input:

  • coinType - required - Must pass in Pre-defined CoinInfo Type

  • amount -required - Amount to deposit in

import {USDC, Sui} from 'navi-sdk/dist/address';
account.depositToNavi(Sui, 1e9)

Deposit with Account Cap

depositToNaviWithAccountCap(coinType: CoinInfo, amount: number, accountCapAddress: string)

Input:

  • coinType - required - Must pass in Pre-defined CoinInfo Type

  • amount -required - Amount to deposit in

  • accountCapAddress - requierd - String of address of owned account cap

account.depositToNaviWithAccountCap(Sui, 1e9, addr1)

Withdraw

withdraw(coinType: CoinInfo, amount: number)

Input:

  • coinType - required - Must pass in Pre-defined CoinInfo Type

  • amount -required - Amount to withdraw

account.withdraw(USDC, 1e6)

Withdraw With Account Cap

withdrawWithAccountCap(coinType: CoinInfo, amount: number, accountCapAddress: string

Input:

  • coinType - required - Must pass in Pre-defined CoinInfo Type

  • amount -required - Amount to withdraw

  • accountCapAddress - requierd - String of address of owned account cap

account.withdrawWithAccountCap(Sui, 1e9, addr1)

Borrow

borrow(coinType: CoinInfo, borrowAmount: number)

Input:

  • coinType - required - Must pass in Pre-defined CoinInfo Type

  • borrowAmount- required - Amount to borrow

account.borrow(USDC, 1e6)

Repay

repay(coinType: CoinInfo, repayAmount: number)

Input:

  • coinType - required - Must pass in Pre-defined CoinInfo Type

  • repayAmount - required - Amount to repay

account.repay(Sui, 1e9)

Last updated