1.0.21 • Published 2 years ago
rainfi-test v1.0.21
Create a pool example
import { RainFi } from "rainfi-test";
import {signAndSend, loadEnv} from "your-utils"
import { Connection, LAMPORTS_PER_SOL } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
const loanToValue = 50 // 50% of the floor price of the NFT
const amount = 100 // pool size = 100 SOL
const dynamicInterest = 1 // Enable dynamic interest or not
const interestRate = (!dynamicInterest && loanInterest * 100) || 0
// If dynamicInterest is used, we set the interest rate, else we set to 0 since program will overwrite
const maxAmount = 100 // Max amount that can be used per loan
const loanDuration = 14 // In days
const compound = true // Compound interest or not, put the profit back in the pool or not
const instruction = await RainFi.instructions.createPool(
connection,
publicKey!,
{
loanToValue: loanToValue,
maxAmount: maxAmount,
interestType: dynamicInterest,
interestRate: interestRate,
maxDuration: loanDuration,
compound: compound,
amount: amount,
}
)
await signAndSend(connection, publicKey, [instruction]!)
Borrow example
import { RainFi } from "rainfi-test";
import {signAndSend, loadEnv} from "your-utils"
import { Connection, LAMPORTS_PER_SOL } from "@solana/web3.js";
const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
// Dump all pools available
const poolAvailable = await RainFi.utils.getAllPoolAvailable(connection)
// Select the pool
const pool = poolAvailable[0]
const duration = 3 // The duration of the loan in DAYS
//Instruction will most likely require more compute unit than the standard of 200k CU. So we ask for more.
const increaseCuIx = ComputeBudgetProgram.requestUnits({
units: 400000,
additionalFee: 0,
});
//Create the borrow instruction
const instruction = await RainFi.instructions.borrow(
connection,
publicKey!,
{
nft_address: "Eb89RFb5MZh4QWaae7m3pMQf5S1eNwUvoaYcpiDGdBfE", // NFT mint address that you want to collateralize
pool_owner: pool.owner, // The owner of the pool
duration: duration, // The duration of the loan in DAYS
}
)
await signAndSend(connection, wallet.publicKey, [instruction]!)
1.0.21
2 years ago
1.0.20
2 years ago
1.0.19
2 years ago
1.0.18
2 years ago
1.0.17
2 years ago
1.0.16
2 years ago
1.0.15
2 years ago
1.0.14
2 years ago
1.0.13
2 years ago
1.0.12
2 years ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago