Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mercurial-finance/farming-sdk

Package Overview
Dependencies
Maintainers
4
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mercurial-finance/farming-sdk

  • 1.0.4
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

Meteora Pool Farm SDK


Getting started

NPM: https://www.npmjs.com/package/@mercurial-finance/farming-sdk

SDK: https://github.com/MeteoraAg/reward-pool

Discord: https://discord.com/channels/841152225564950528/864859354335412224


Install

  1. Install deps
npm i @mercurial-finance/farming-sdk @project-serum/anchor @solana/web3.js @solana/spl-token @solana/spl-token-registry
  1. Initialize AmmImpl instance
import PoolFarmImpl from "@mercurial-finance/farming-sdk";
import { PublicKey } from "@solana/web3.js";
import { Wallet, AnchorProvider } from "@project-serum/anchor";

// Connection, Wallet, and AnchorProvider to interact with the network
const mainnetConnection = new Connection("https://api.mainnet-beta.solana.com");
const mockWallet = new Wallet(new Keypair());
const provider = new AnchorProvider(mainnetConnection, mockWallet, {
  commitment: "confirmed",
});
// Alternatively, to use Solana Wallet Adapter

const farmingPools = await PoolFarmImpl.getFarmAddressesByPoolAddress(
  MAINNET_POOL.USDC_USDT // Pool Address can get from https://docs.meteora.ag/dynamic-pools-integration/dynamic-pool-api/pool-info
);
// farmingPools is an array (A pool can have multiple farms)
const farmingPool = farmingPools[0];
const farm = await PoolFarmImpl.create(connection, farmingPool);
  1. To interact with the PoolFarmImpl
  • Stake
// https://station.jup.ag/blog/jupiter-token-list-api#endpoints
const tokenList = await fetch('https://token.jup.ag/all').then(res => res.json());
const USDC = tokenList.find(token => token.address === <USDC_ADDRESS>);
const USDT = tokenList.find(token => token.address === <USDT_ADDRESS>);
// Get pool lp balance from `@mercurial-finance/dynamic-amm-sdk` package
const pool = await AmmImpl.create(connection, MAINNET_POOL.USDC_USDT, USDC, USDT);
const lpBalance = await pool.getUserBalance(mockWallet.publicKey);

const stakeTx = await farm.deposit(mockWallet.publicKey, lpBalance); // Web3 Transaction Object
const stakeResult = await provider.sendAndConfirm(stakeTx); // Transaction hash
  • Check staked balance
const farmBalance = await farm.getUserBalance(mockWallet.publicKey);
  • Unstake
const unStakeTx = await farm.withdraw(mockWallet.publicKey, farmBalance); // Web3 Transaction Object
const unstakeResult = await provider.sendAndConfirm(depositTx); // Transaction hash

FAQs

Package last updated on 03 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc