Francium SDK
Javascript sdk of Francium lending pools and farming pools. Learn more about Francium.
NPM package
Farm
Get User Farm Positions
import { Connection, PublicKey } from '@solana/web3.js';
import FranciumSDK from 'francium-sdk';
const fr = new FranciumSDK({
connection: new Connection('https://free.rpcpool.com')
});
fr.getUserFormattedFarmPosition(new PublicKey('23fxxxxxxxxxxxxxxxxxxx'))
.then(result => {
console.log(result);
});
fr.getUserFarmPosition(new PublicKey('23fxxxxxxxxxxxxxxxxxxx'))
.then(result => {
console.log(result);
});
Get Farm Transactions
import { Connection, PublicKey } from '@solana/web3.js';
import FranciumSDK from 'francium-sdk';
const fr = new FranciumSDK({
connection: new Connection('https://free.rpcpool.com')
});
async function farm() {
const trxs = await fr.getFarmTransactions(
'SHDW-USDC',
'orca',
new PublicKey('23xxxxxxx'),
{
depositPcAmount: new BN(1000000),
depositCoinAmount: new BN(0),
borrowPcAmount: new BN(1000000),
borrowCoinAmount: new BN(0),
currentUserInfoAccount?: PublicKey
}
);
await fr.sendMultipleTransactions(trxs, wallet);
}
Get Farm Versioned Transactions
async function oneTxfarm() {
const versionedTrx = await fr.getOneFarmTransaction(
'RAY-USDC',
'raydium',
new PublicKey('23xxxxxxx'),
{
depositPcAmount: new BN(1000000),
depositCoinAmount: new BN(0),
borrowPcAmount: new BN(1000000),
borrowCoinAmount: new BN(0),
currentUserInfoAccount?: PublicKey
}
);
versionedTrx.sign([payer]);
fr.connection.sendTransaction(versionedTrx);
await fr.sendVersionedTransaction(versionedTrx, wallet);
}
getRepayTransactions
import { Connection, PublicKey } from '@solana/web3.js';
import FranciumSDK from 'francium-sdk';
const fr = new FranciumSDK({
connection: new Connection('https://free.rpcpool.com')
});
async function getRepayTransactions() {
const trxs = await fr.getRepayTransactions(
'SHDW-USDC',
'orca',
new PublicKey('23xxxxxxx'),
configs: {
amount0: BN;
amount1: BN;
// userPosition.userInfoPublicKey
currentUserInfoAccount: PublicKey;
}
);
// sign and send trxs
await fr.sendMultipleTransactions(trxs, wallet);
Get Close Position Transactions
import { Connection, PublicKey } from '@solana/web3.js';
import FranciumSDK from 'francium-sdk';
const fr = new FranciumSDK({
connection: new Connection('https://free.rpcpool.com')
});
async function close() {
const trxs = await fr.getClosePositionTransactions(
'SHDW-USDC',
'orca',
new PublicKey('23xxxxxxx'),
{
withdrawType: 2,
lpShares: BN,
currentUserInfoAccount: PublicKey
}
);
await fr.sendMultipleTransactions(trxs, wallet);
}
Get Farm Close Versioned Transactions
async function oneTxClose() {
const versionedTrx = await fr.getOneFarmClosedTransaction(
'RAY-USDC',
'raydium',
new PublicKey('23xxxxxxx'),
{
withdrawType: 2,
lpShares: BN,
currentUserInfoAccount: PublicKey
}
);
versionedTrx.sign([payer]);
fr.connection.sendTransaction(versionedTrx);
await fr.sendVersionedTransaction(versionedTrx, wallet);
}
Get Pool Info
async function getInfo() {
const farmPool = await fr.getFarmPoolTVL();
const lendingPool = await fr.getLendingPoolTVL();
}
Get Farm LP Info
fr.getFarmLPPriceInfo();
PDN Rebalance
import { Connection, PublicKey } from '@solana/web3.js';
import FranciumSDK from 'francium-sdk';
const fr = new FranciumSDK({
connection: new Connection('https://free.rpcpool.com')
});
async function rebalance() {
await fr.sendRebalanceTransactions(
new PublicKey('23xxxxxxx'),
targetPosition.userInfoPublicKey.toBase58(),
wallet,
);
}
async function getRebalanceInfo() {
const rebalanceInfo = await fr.getRebalanceInfo(
new PublicKey('23xxxxxxx'),
targetPosition.userInfoPublicKey.toBase58(),
);
console.log('rebalanceInfo: ', rebalanceInfo);
}
Lend
Get Lending Transaction
import { Connection, PublicKey } from '@solana/web3.js';
import FranciumSDK from 'francium-sdk';
const fr = new FranciumSDK({
connection: new Connection('https://free.rpcpool.com')
});
async function deposit() {
const { trx, signers } = await fr.getLendingDepositTransaction('USDC', new BN(1000000), new PublicKey('23fxxxxxxxxxxxxxxxxxxx'));
const { txid, response } = await fr.sendSingleTransaction(trx, wallet, signers);
console.log(txid, response);
}
async function withdraw() {
const rewardAmount = 1002232;
const tokenAmount = 0;
const { trx, signers } = await fr.getLendWithdrawTransaction('USDC', rewardAmount, tokenAmount, new PublicKey('23fxxxxxxxxxxxxxxxxxxx'));
const { txid, response } = await fr.sendSingleTransaction(trx, wallet, signers);
console.log(txid, response);
}
Get Lending Transaction V0
async function depositV0() {
const {trx, signers} = await sdk.getLendingDepositTransactionV0(
'USDC', new BN('1000000'), new PublicKey('23xxxxxxx'));
const { txid, response } = await sdk.sendVersionedTransaction(trx, wallet, signers);
}
async function withdrawV0() {
const rewardAmount = 1002232;
const tokenAmount = 0;
const {trx, signers} = await sdk.getLendingWithdrawTransactionV0(
'USDC', rewardAmount, tokenAmount, new PublicKey('23xxxxxxx'));
const { txid, response } = await sdk.sendVersionedTransaction(trx, wallet, signers);
}
Get User Lending Pool
user lending position, the totalAmount
is the token amount.
fr.getUserLendingPosition(new PublicKey('23fxxxxxxxxxxxxxxxxxxx'))
.then((res) => {
console.log(res);
})
Get Pool Info
fr.getLendingPoolInfo()
.then((res) => {
console.log(res);
});
add this to your webpack configuration
node: {
fs: "empty",
net: "empty",
tls: "empty",
}