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/farming-sdk

v1.0.17

Published

<p align="center"> <img align="center" src="https://app.meteora.ag/icons/logo.svg" width="180" height="180" /> </p> <br>

Downloads

6,350

Readme

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 @coral-xyz/anchor @solana/web3.js @solana/spl-token @solana/spl-token-registry
  1. Initialize PoolFarmImpl instance
import { PoolFarmImpl } from "@mercurial-finance/farming-sdk";
import { Wallet, AnchorProvider } from "@coral-xyz/anchor";
import { Connection, PublicKey, Keypair } from "@solana/web3.js";

// 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 USDC_acUSDC_POOL = new PublicKey(
  "6ZLKLjMd2KzH7PPHCXUPgbMAtdTT37VgTtdeXWLoJppr"
); // Pool Address can get from https://docs.meteora.ag/dynamic-pools-integration/dynamic-pool-api/pool-info

const farmingPools = await PoolFarmImpl.getFarmAddressesByPoolAddress(
  USDC_acUSDC_POOL
);
// farmingPools is an array (A pool can have multiple farms)
const farmingPool = farmingPools[0];
const farm = await PoolFarmImpl.create(
  mainnetConnection,
  farmingPool.farmAddress
);
  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);
  • Claim
const claimTx = await farm.claim(mockWallet.publicKey); // Web3 Transaction Object
const claimResult = await provider.sendAndConfirm(claimTx); // Transaction hash
  • Unstake
const unStakeTx = await farm.withdraw(mockWallet.publicKey, farmBalance); // Web3 Transaction Object
const unstakeResult = await provider.sendAndConfirm(depositTx); // Transaction hash