npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mercurial-finance/francium-sdk

v1.4.3

Published

francium sdk

Downloads

10,787

Readme

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')
});

// Will fetch the LP price info on chain and return equity value.
fr.getUserFormattedFarmPosition(new PublicKey('23fxxxxxxxxxxxxxxxxxxx'))
  .then(result => {
    console.log(result);
    // [{
    //   id: 'ORCA-USDC[Orca Aquafarm]',
    //   lpAmount: BN,
    //   lpShares: BN,
    //   lpDecimals: 6,
    //   userInfoPublicKey: PublicKey,
    //   borrowed: [{
    //     symbol: 'USDC',
    //     amount: BN
    //   }],
    //   totalPositionValue: 10,
    //   debtValue: 6,
    //   equityValue: 4
    // }]
  });

// Only return the amount.
fr.getUserFarmPosition(new PublicKey('23fxxxxxxxxxxxxxxxxxxx'))
  .then(result => {
    console.log(result);
    // [{
    //   id: 'ORCA-USDC[Orca Aquafarm]',
    //   lpAmount: BN,
    //   lpShares: BN,
    //   lpDecimals: 6,
    //   userInfoPublicKey: PublicKey,
    //   borrowed: [{
    //     symbol: 'USDC',
    //     amount: BN
    //   }]
    // }]
  });

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() {
  // supply 1 USDC, borrow 1 USDC
  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),
      // Needed when adjust
      currentUserInfoAccount?: PublicKey
    }
  );

  // sign and send trxs
  await fr.sendMultipleTransactions(trxs, wallet);
}

Get Farm Versioned Transactions

async function oneTxfarm() {
  // supply 1 USDC, borrow 1 USDC
  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),
      // Needed when adjust
      currentUserInfoAccount?: PublicKey
    }
  );

  // If there is Keypair
  versionedTrx.sign([payer]);
  fr.connection.sendTransaction(versionedTrx);

  // if the wallet supports Versioned Transaction
  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() {
  // supply 1 USDC, borrow 1 USDC
  const trxs = await fr.getClosePositionTransactions(
    'SHDW-USDC',
    'orca',
    new PublicKey('23xxxxxxx'),
    {
      // 0: swap to PC token
      // 1: swap to Coin Token
      // 2: minimize trading 
      withdrawType: 2,

      // userPosition.lpShares
      lpShares: BN,

      // userPosition.userInfoPublicKey
      currentUserInfoAccount: PublicKey 
    }
  );

  // sign and send trxs
  await fr.sendMultipleTransactions(trxs, wallet);
}

Get Farm Close Versioned Transactions

async function oneTxClose() {
  // supply 1 USDC, borrow 1 USDC
  const versionedTrx = await fr.getOneFarmClosedTransaction(
    'RAY-USDC',
    'raydium',
    new PublicKey('23xxxxxxx'),
    {
      // 0: swap to PC token
      // 1: swap to Coin Token
      // 2: minimize trading 
      withdrawType: 2,

      // userPosition.lpShares
      lpShares: BN,

      // userPosition.userInfoPublicKey
      currentUserInfoAccount: PublicKey 
    }
  );

  // If there is Keypair
  versionedTrx.sign([payer]);
  fr.connection.sendTransaction(versionedTrx);

  // if the wallet supports Versioned Transaction
  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(), // the userInfoPublicKey string of the target positio, which could be accessible from fr.getUserFarmPosition
    wallet,
  );
}

// get rebalance Info
async function getRebalanceInfo() {
  const rebalanceInfo = await fr.getRebalanceInfo(
    new PublicKey('23xxxxxxx'),
    targetPosition.userInfoPublicKey.toBase58(), // the userInfoPublicKey string of the target positio, which could be accessible from fr.getUserFarmPosition
  );
  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() {
  // You can get this value by getUserLendingPosition method
  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);
      // [
      //   {   
      //     balancePosition: 0,
      //     pool: "USDC",
      //     rewardPosition: 41354540149,
      //     scale: 6,
      //     totalAmount: 50386.25041249344,
      //     totalPosition: 41354540149,
      //   }
      // ]
  })

Get Pool Info

fr.getLendingPoolInfo()
  .then((res) => {
    console.log(res);
    // [
    //   {
    //     pool: 'USDC',
    //     scale: 6,
    //     avaliableAmount: BN,
    //     borrowedAmount: BN,
    //     totalAmount: BN,
    //     utilization: 0.9,
    //     totalShareMintSupply: BN,
    //     apr: 8.36,
    //     apy: 8.72,
    //   }
    // ]
  });

add this to your webpack configuration

node: {
  fs: "empty",
  net: "empty",
  tls: "empty",
}