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 - npm Package Compare versions

Comparing version 1.0.2 to 1.0.4

README.md

14

dist/index.d.ts

@@ -743,5 +743,18 @@ import { IdlAccounts, BN } from '@coral-xyz/anchor';

private constructor();
static create(connection: Connection, farm: PublicKey, opt?: {
cluster?: Cluster;
}): Promise<PoolFarmImpl>;
static createMultiple(connection: Connection, farmList: Array<PublicKey>, opt?: {
cluster?: Cluster;
}): Promise<PoolFarmImpl[]>;
static getFarmAddressesByPoolAddress(poolAddress: PublicKey, cluster?: Cluster): Promise<{
farmAddress: PublicKey;
APY: string;
expired: boolean;
}[]>;
static getFarmAddressesByLp(lpAddress: PublicKey, cluster?: Cluster): Promise<{
farmAddress: PublicKey;
APY: string;
expired: boolean;
}[]>;
static getUserBalances(connection: Connection, owner: PublicKey, farmMints: Array<PublicKey>): Promise<Map<string, BN>>;

@@ -751,2 +764,3 @@ static claimAll(connection: Connection, owner: PublicKey, farmMints: Array<PublicKey>, opt?: {

}): Promise<Transaction[]>;
getUserBalance(owner: PublicKey): Promise<BN>;
getUserPda(owner: PublicKey): PublicKey;

@@ -753,0 +767,0 @@ getUserState(owner: PublicKey): Promise<{

127

dist/index.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;

@@ -56,3 +56,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;

// src/farming-idl.ts
var _nodefetch = require('node-fetch'); var _nodefetch2 = _interopRequireDefault(_nodefetch);
// src/idl/farming-idl.ts
var IDL = {

@@ -788,6 +791,59 @@ version: "0.2.0",

// src/utils.ts
// src/constant.ts
var _spltokenregistry = require('@solana/spl-token-registry');
var FARM_PROGRAM_ID = new (0, _web3js.PublicKey)(
"FarmuwXPWXvefWUeqFAa5w6rifLkq5X6E8bimYvrhCB1"
);
var AMM_PROGRAM_ID = new (0, _web3js.PublicKey)(
"Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB"
);
var SIMULATION_USER = new (0, _web3js.PublicKey)(
"HrY9qR5TiB2xPzzvbBu5KrBorMfYGQXh9osXydz4jy9s"
);
var DEVNET_COIN = [
{
chainId: _spltokenregistry.ENV.Devnet,
address: "So11111111111111111111111111111111111111112",
decimals: 9,
name: "Wrapped SOL",
symbol: "SOL",
logoURI: "https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png",
extensions: {
coingeckoId: "solana",
serumV3Usdc: "9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT",
serumV3Usdt: "HWHvQhFmJB3NUcu1aihKmrKegfVxBEHzwVX6yZCKEsi1",
website: "https://solana.com/"
}
},
{
chainId: _spltokenregistry.ENV.Devnet,
address: "zVzi5VAf4qMEwzv7NXECVx5v2pQ7xnqVVjCXZwS9XzA",
decimals: 6,
name: "USD Coin",
symbol: "USDC",
logoURI: "https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png",
extensions: {
coingeckoId: "usd-coin",
serumV3Usdt: "77quYg4MGneUdjgXCunt9GgM1usmrxKY31twEy3WHwcS",
website: "https://www.centre.io/"
}
},
{
chainId: _spltokenregistry.ENV.Devnet,
address: "9NGDi2tZtNmCCp8SVLKNuGjuWAVwNF3Vap5tT8km5er9",
decimals: 9,
name: "USDT",
symbol: "USDT",
logoURI: "https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB/logo.svg",
tags: ["stablecoin"],
extensions: {
coingeckoId: "tether",
serumV3Usdc: "77quYg4MGneUdjgXCunt9GgM1usmrxKY31twEy3WHwcS",
website: "https://tether.to/"
}
}
];
// src/utils.ts
var getFarmProgram = (connection) => {

@@ -802,5 +858,8 @@ const provider = new (0, _anchor.AnchorProvider)(

};
var SIMULATION_USER = new (0, _web3js.PublicKey)(
"HrY9qR5TiB2xPzzvbBu5KrBorMfYGQXh9osXydz4jy9s"
);
var getFarmInfo = (cluster) => __async(void 0, null, function* () {
const data = yield _nodefetch2.default.call(void 0,
cluster === "devnet" ? process.env.DEVNET_FARM_API : process.env.MAINNET_FARM_API
).then((res) => res.json());
return data;
});
var parseLogs = (eventParser, logs) => {

@@ -883,2 +942,16 @@ if (!logs.length)

}
static create(connection, farm, opt) {
return __async(this, null, function* () {
var _a;
const cluster = (_a = opt == null ? void 0 : opt.cluster) != null ? _a : "mainnet-beta";
const { program } = getFarmProgram(connection);
const eventParser = new (0, _anchor.EventParser)(FARM_PROGRAM_ID, program.coder);
const poolState = yield program.account.pool.fetchNullable(farm);
if (!poolState)
throw new Error("No pool state found");
return new _PoolFarmImpl(farm, program, eventParser, poolState, {
cluster
});
});
}
static createMultiple(connection, farmList, opt) {

@@ -899,2 +972,32 @@ return __async(this, null, function* () {

}
static getFarmAddressesByPoolAddress(poolAddress, cluster) {
return __async(this, null, function* () {
const apiData = yield getFarmInfo(cluster);
const farms = apiData.filter(
(farm) => farm.pool_address === poolAddress.toBase58()
);
if (!farms.length)
throw new Error("No pool address found ");
return farms.map((farm) => ({
farmAddress: new (0, _web3js.PublicKey)(farm.farming_pool),
APY: farm.farming_apy,
expired: farm.farm_expire
}));
});
}
static getFarmAddressesByLp(lpAddress, cluster) {
return __async(this, null, function* () {
const apiData = yield getFarmInfo(cluster);
const farms = apiData.filter(
(farm) => farm.lp_mint === lpAddress.toBase58()
);
if (!farms.length)
throw new Error("No pool address found ");
return farms.map((farm) => ({
farmAddress: new (0, _web3js.PublicKey)(farm.farming_pool),
APY: farm.farming_apy,
expired: farm.farm_expire
}));
});
}
static getUserBalances(connection, owner, farmMints) {

@@ -957,2 +1060,14 @@ return __async(this, null, function* () {

}
getUserBalance(owner) {
return __async(this, null, function* () {
const [userStakingAddress] = _web3js.PublicKey.findProgramAddressSync(
[owner.toBuffer(), this.address.toBuffer()],
FARM_PROGRAM_ID
);
const userState = yield this.program.account.user.fetchNullable(
userStakingAddress
);
return userState.balanceStaked;
});
}
getUserPda(owner) {

@@ -959,0 +1074,0 @@ const [userPda] = _web3js.PublicKey.findProgramAddressSync(

14

package.json
{
"name": "@mercurial-finance/farming-sdk",
"version": "1.0.2",
"version": "1.0.4",
"description": "",

@@ -13,3 +13,3 @@ "main": "./dist/index.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "jest ./src/tests/*.test.ts --runInBand --setupFiles dotenv/config",
"build": "tsup"

@@ -21,4 +21,8 @@ },

"devDependencies": {
"@mercurial-finance/dynamic-amm-sdk": "^0.4.7",
"@types/jest": "^29.5.3",
"jest": "^29.6.2",
"ts-jest": "^29.1.1",
"tsup": "^7.1.0",
"typescript": "^5.0.4"
"typescript": "^4.7.2"
},

@@ -28,3 +32,5 @@ "dependencies": {

"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "~1.77.3"
"@solana/spl-token-registry": "^0.2.4574",
"@solana/web3.js": "~1.77.3",
"node-fetch": "^2.6.12"
},

@@ -31,0 +37,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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