kriya-sdk-v2
v1.0.1
Published
Kriya SDK to access the Kriya DeFi protocols suite.
Downloads
4
Readme
Kriya V2 Typescript SDK
Install
npm i kriya-sdk-v2
Usage
Create an instance of KriyaSDK
for ease of use to make calls to individual modules.
Kriya SDK
1. Intialize KriyaDex Sdk
import { KriyaSDK } from 'kriya-sdk-v2';
const rpcEndpoint = "https://fullnode.mainnet.sui.io:443"
const kriyaSdk = new KriyaSDK(rpcEndpoint, isMainnet); // isMainnet- true or false
2. Create individual module provider
const poolModule = kriyaSdk.Pool(this);
const farmModdule = kriyaSdk.Farm(this);
const rpcClient = kriyaSdk.rpcClient(this);
3. Call Modules API
poolModule.addLiquidity(...args); // add liquidity to pool
const claimedCoin = farmModdule.claimTx(...args); // claim staked lp
const object = rpcClient.fetchOwnedObjects(..args); // wrapper class for sui rpc client
Test Samples
1. Add Liquidity
const txb = new TransactionBlock();
const rpcEndpoint = "https://fullnode.mainnet.sui.io:443"
const kriyaSdk = new KriyaSDK(rpcEndpoint, true);
const pool: PoolParams = {
objectId: "0x5af4976b871fa1813362f352fa4cada3883a96191bb7212db1bd5d13685ae305",
tokenXType: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN",
tokenYType: "0x2::sui::SUI"
}
// coinsXlist,coinsYlist -> { objectId: string; balance: bigint }[]
let CoinX = getExactCoinByAmount(pool.tokenXType, coinsXlist, BigInt(2*1e6), txb);
let CoinY = getExactCoinByAmount(pool.tokenYType, coinsYlist, BigInt(2*1e9), txb);
kriyaSdk.Pool.addLiquidity(
pool,
BigInt(1 *1e6), // amount of tokenX
BigInt(1*1e9), // amount of tokenY
BigInt(1), // min amount tokenX
BigInt(1), // min amount tokenY
CoinX,
CoinY,
txb,
userAdress // user address to transfer retured object
);