The NaviSDK Client provides a set of tools for interacting with sui blockchain networks, specifically designed for handling transactions, accounts, and smart contracts in a streamlined and efficient manner. This documentation covers the setup, account management, and transaction handling within the NaviSDK ecosystem.
Getting Started
Installation
Before you can use the NaviSDK Client, you need to set up your project environment.
npm i navi-sdk
Creating and Managing Accounts
Creating a Default Account
When you initialize client, you will need a mnemonic phrase or we will generate a new one for you.
1 mnemonic for 1 client
We will never save user's mnemonic phrase
constmnemonic=''; // Use an existing mnemonic or leave empty to generate a new oneconstclient=newNAVISDKClient({mnemonic, networkType:"mainnet", numberOfAccounts:5});
account1.createAccountCap() //Account1 will create an Account Cap
Get Specific Account Address
account1.getPublicKey() //oraccount1.address
Get Objs and Coin Info
We have prepare a token type for Sui/NAVX/vSui/USDT/USDC/WETH/CETUS/haSui
import {Sui, NAVX, vSui, USDT, USDC, WETH, CETUS, haSui} from'navi-sdk/dist/address';account.getAllCoins() //Return all Objects that account has//Get all objs for this type of tokenaccount.getCoins(coinType ="0x2::sui::SUI")//Or you may import token address from addressaccount.getCoins(coinType = Sui)
import { USDC } from'navi-sdk/dist/address'client.getPoolInfo(USDC)//Leave it empty to get all poolinfo
Get Current Health Factor
account.getHealthFactor() //Return this account's health factorclient.getHealthFactor(address); //You may check any address
Predict new Health Factor by taking a supply/borrow action
client.getDynamicHealthFactor(address,USDC, supplyBalanceChange:100000, borrowBalanceChange: 0, is_increase: true)//supplyBalanceChange and borrowBalanceChange needs to be an integer with token decimals//Change is_increase to false if it's decrease
Supply/Withdraw/Borrow/Repay
You may Simply input 'NAVX' as a string or NAVX as a type imported from address.ts.
Current These Pools are supported: Sui | NAVX | vSui | USDC | USDT | WETH | CETUS | haSui