yarn add @ratio-finance/vault-sdk
import { RatioLendingProgram } from "@ratio-finance/vault-sdk";
const lendingProgram = RatioLendingProgram.getInstance(conn);
await lendingProgram.init();
const raydiumUsdtUsdcKey = "As3EGgLtUVpdNpE6WCKauyNRrCCwcQ57trWQ3wyRXDa6";
const depositTx = await lendingProgram.depositLP(
USER_KEYPAIR.publicKey, // UserPublicKey : PublicKey
raydiumUsdtUsdcKey, // CollateralMint: PublicKey
0.1 // DepositAmount: number (must be uiAmount)
);
const depositTxHash = await sendAndConfirmTransaction(
conn,
depositTx,
[USER_KEYPAIR]
);
console.log(`deposit is done successfully. txHash = ${depositTxHash}`);
let withdrawTx = await lendingProgram.withdrawLP(
USER_KEYPAIR.publicKey, // UserPublicKey : PublicKey
raydiumUsdtUsdcKey, // CollateralMint : PublicKey
0.05 // WithdrawAmount : Number (uiAmount)
);
let harvestTx = await lendingProgram.harvest(
USER_KEYPAIR.publicKey, // UserPublicKey : PublicKey
raydiumUsdtUsdcKey // CollateralMint: PublicKey
);
let mintTx = await lendingProgram.mintUSDr(
USER_KEYPAIR.publicKey, // UserPublicKey : PublicKey
raydiumUsdtUsdcKey, // CollateralMint: PublicKey
0.05 // MintAmount: Number (uiAmount)
);
let repayTx = await lendingProgram.repayUSDr(
USER_KEYPAIR.publicKey, // UserPublicKey : PublicKey
raydiumUsdtUsdcKey, // CollateralMint: PublicKey
0.04 // RepayAmount: Number (uiAmount)
);
5. Get Yield Farming Reward (Get pending reward from Yield Farming)
const rewardAmount = await lendingProgram.getYieldFarmingReward(
USER_KEYPAIR.publicKey,
raydiumUsdtUsdcKey
);
6. Get RATIO Apr Reward (If the pool has RATIO emission, user will get RATIO reward)
const ratioRewardAmount = await lendingProgram.getRatioRewards(
USER_KEYPAIR.publicKey,
raydiumUsdtUsdcKey
);