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

@orca-so/aquafarm

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orca-so/aquafarm - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

9

dist/instructions.d.ts
import { u64 } from "@solana/spl-token";
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
export declare enum INSTRUCTIONS {
InitGlobalFarm = 0,
InitUserFarm = 1,
ConvertTokens = 2,
RevertTokens = 3,
Harvest = 4,
RemoveRewards = 5,
SetEmissionsPerSecond = 6
}
export declare function constructInitGlobalFarmIx(globalFarmStatePubkey: PublicKey, baseTokenMintPubkey: PublicKey, globalBaseTokenVaultPubkey: PublicKey, rewardTokenVaultPubkey: PublicKey, farmTokenMintPubkey: PublicKey, emissionsAuthorityPubkey: PublicKey, removeRewardsAuthorityPubkey: PublicKey, emissionsPerSecondNumerator: u64, emissionsPerSecondDenominator: u64, nonce: number, aquafarmProgramId: PublicKey): TransactionInstruction;

@@ -4,0 +13,0 @@ export declare function constructInitUserFarmIx(globalFarmStatePubkey: PublicKey, userFarmStatePubkey: PublicKey, ownerPubkey: PublicKey, aquafarmProgramId: PublicKey): TransactionInstruction;

27

dist/instructions.js

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.constructRemoveRewardsIx = exports.constructSetEmissionsPerSecondIx = exports.constructHarvestIx = exports.constructRevertTokensIx = exports.constructConvertTokensIx = exports.constructInitUserFarmIx = exports.constructInitGlobalFarmIx = void 0;
exports.constructRemoveRewardsIx = exports.constructSetEmissionsPerSecondIx = exports.constructHarvestIx = exports.constructRevertTokensIx = exports.constructConvertTokensIx = exports.constructInitUserFarmIx = exports.constructInitGlobalFarmIx = exports.INSTRUCTIONS = void 0;
const spl_token_1 = require("@solana/spl-token");

@@ -12,3 +12,12 @@ const web3_js_1 = require("@solana/web3.js");

const buffer_layout_1 = __importDefault(require("buffer-layout"));
const instructions_1 = require("./utils/instructions");
var INSTRUCTIONS;
(function (INSTRUCTIONS) {
INSTRUCTIONS[INSTRUCTIONS["InitGlobalFarm"] = 0] = "InitGlobalFarm";
INSTRUCTIONS[INSTRUCTIONS["InitUserFarm"] = 1] = "InitUserFarm";
INSTRUCTIONS[INSTRUCTIONS["ConvertTokens"] = 2] = "ConvertTokens";
INSTRUCTIONS[INSTRUCTIONS["RevertTokens"] = 3] = "RevertTokens";
INSTRUCTIONS[INSTRUCTIONS["Harvest"] = 4] = "Harvest";
INSTRUCTIONS[INSTRUCTIONS["RemoveRewards"] = 5] = "RemoveRewards";
INSTRUCTIONS[INSTRUCTIONS["SetEmissionsPerSecond"] = 6] = "SetEmissionsPerSecond";
})(INSTRUCTIONS = exports.INSTRUCTIONS || (exports.INSTRUCTIONS = {}));
function constructInitGlobalFarmIx(globalFarmStatePubkey, baseTokenMintPubkey, globalBaseTokenVaultPubkey, rewardTokenVaultPubkey, farmTokenMintPubkey, emissionsAuthorityPubkey, removeRewardsAuthorityPubkey, emissionsPerSecondNumerator, emissionsPerSecondDenominator, nonce, aquafarmProgramId) {

@@ -30,3 +39,3 @@ const keys = [

data: layout_1.generateBufferData(layout_1.INIT_GLOBAL_FARM_DATA_LAYOUT, {
instruction: instructions_1.INSTRUCTIONS.InitGlobalFarm,
instruction: INSTRUCTIONS.InitGlobalFarm,
nonce,

@@ -69,3 +78,3 @@ tokenProgramId: spl_token_1.TOKEN_PROGRAM_ID.toBuffer(),

data: layout_1.generateBufferData(layout_1.INIT_USER_FARM_DATA_LAYOUT, {
instruction: instructions_1.INSTRUCTIONS.InitUserFarm,
instruction: INSTRUCTIONS.InitUserFarm,
}), // Initialize user farm instruction

@@ -144,3 +153,3 @@ });

]), {
instruction: instructions_1.INSTRUCTIONS.ConvertTokens,
instruction: INSTRUCTIONS.ConvertTokens,
amountToConvert: amountToConvert.toBuffer(), // The time period over which to distribute: 2 weeks

@@ -220,3 +229,3 @@ }),

]), {
instruction: instructions_1.INSTRUCTIONS.RevertTokens,
instruction: INSTRUCTIONS.RevertTokens,
amountToRevert: amountToRevert.toBuffer(),

@@ -273,3 +282,3 @@ }),

data: layout_1.generateBufferData(buffer_layout_1.default.struct([buffer_layout_1.default.u8("instruction")]), {
instruction: instructions_1.INSTRUCTIONS.Harvest,
instruction: INSTRUCTIONS.Harvest,
}),

@@ -299,3 +308,3 @@ });

]), {
instruction: instructions_1.INSTRUCTIONS.SetEmissionsPerSecond,
instruction: INSTRUCTIONS.SetEmissionsPerSecond,
emissionsPerSecondNumerator: layout_1.u64ToBuffer(numerator),

@@ -346,3 +355,3 @@ emissionsPerSecondDenominator: layout_1.u64ToBuffer(denominator),

]), {
instruction: instructions_1.INSTRUCTIONS.RemoveRewards,
instruction: INSTRUCTIONS.RemoveRewards,
amountToRemove: amountToConvert.toBuffer(), // The time period over which to distribute: 2 weeks

@@ -349,0 +358,0 @@ }),

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

import { Signer, TransactionInstruction } from "@solana/web3.js";
import { u64 } from "@solana/spl-token";
import { PublicKey, Signer, TransactionInstruction } from "@solana/web3.js";
import Decimal from "decimal.js";

@@ -11,4 +12,5 @@ import GlobalFarm from "./GlobalFarm";

globalFarm: GlobalFarm;
programId: PublicKey;
userFarm: UserFarm | null;
constructor(globalFarm: GlobalFarm, userFarm: UserFarm | null);
constructor(globalFarm: GlobalFarm, programId: PublicKey, userFarm: UserFarm | null);
/**

@@ -22,2 +24,6 @@ * @param totalLiquidity The total amount of liquidity in the pool, in USD

isUserFarmInitialized(): boolean;
constructInitUserFarmIx(owner: PublicKey): TransactionInstruction;
constructConvertTokensIx(userTransferAuthority: PublicKey, userBaseTokenAccountPubkey: PublicKey, userFarmTokenAccountPubkey: PublicKey, userRewardTokenAccountPubkey: PublicKey, amount: u64): TransactionInstruction;
constructRevertTokensIx(userBurnAuthority: PublicKey, userBaseTokenAccountPubkey: PublicKey, userFarmTokenAccountPubkey: PublicKey, userRewardTokenAccountPubkey: PublicKey, amount: u64): TransactionInstruction;
constructHarvestIx(userRewardTokenAccountPubkey: PublicKey): TransactionInstruction;
}

@@ -7,5 +7,9 @@ "use strict";

const decimal_js_1 = __importDefault(require("decimal.js"));
const __1 = require("..");
const instructions_1 = require("../instructions");
const UserFarm_1 = require("./UserFarm");
class Aquafarm {
constructor(globalFarm, userFarm) {
constructor(globalFarm, programId, userFarm) {
this.globalFarm = globalFarm;
this.programId = programId;
this.userFarm = userFarm;

@@ -36,4 +40,26 @@ }

}
constructInitUserFarmIx(owner) {
const userFarmAddress = UserFarm_1.getUserFarmAddress(this.globalFarm.publicKey, owner, this.programId)[0];
return instructions_1.constructInitUserFarmIx(this.globalFarm.publicKey, userFarmAddress, owner, this.programId);
}
constructConvertTokensIx(userTransferAuthority, userBaseTokenAccountPubkey, userFarmTokenAccountPubkey, userRewardTokenAccountPubkey, amount) {
if (!this.userFarm) {
return null;
}
return instructions_1.constructConvertTokensIx(this.userFarm.owner, userTransferAuthority, userBaseTokenAccountPubkey, userFarmTokenAccountPubkey, userRewardTokenAccountPubkey, this.globalFarm.baseTokenVault, this.globalFarm.farmTokenMint, this.globalFarm.publicKey, this.userFarm.publicKey, this.globalFarm.rewardTokenVault, this.globalFarm.authority, this.programId, amount);
}
constructRevertTokensIx(userBurnAuthority, userBaseTokenAccountPubkey, userFarmTokenAccountPubkey, userRewardTokenAccountPubkey, amount) {
if (!this.userFarm) {
return null;
}
return __1.constructRevertTokensIx(this.userFarm.owner, userBurnAuthority, userBaseTokenAccountPubkey, userFarmTokenAccountPubkey, userRewardTokenAccountPubkey, this.globalFarm.baseTokenVault, this.globalFarm.farmTokenMint, this.globalFarm.publicKey, this.userFarm.publicKey, this.globalFarm.rewardTokenVault, this.globalFarm.authority, this.programId, amount);
}
constructHarvestIx(userRewardTokenAccountPubkey) {
if (!this.userFarm) {
return null;
}
return instructions_1.constructHarvestIx(this.userFarm.owner, userRewardTokenAccountPubkey, this.globalFarm.baseTokenVault, this.globalFarm.publicKey, this.userFarm.publicKey, this.globalFarm.rewardTokenVault, this.globalFarm.authority, this.programId);
}
}
exports.default = Aquafarm;
//# sourceMappingURL=Aquafarm.js.map

@@ -7,2 +7,3 @@ import { PublicKey } from "@solana/web3.js";

isInitialized: boolean;
authority: PublicKey;
nonce: number;

@@ -23,2 +24,3 @@ tokenProgramId: PublicKey;

isInitialized: boolean;
authority: PublicKey;
nonce: number;

@@ -25,0 +27,0 @@ tokenProgramId: PublicKey;

@@ -19,2 +19,3 @@ "use strict";

this.tokenProgramId = params.publicKey;
this.authority = params.authority;
this.nonce = params.nonce;

@@ -37,2 +38,3 @@ this.emissionsAuthority = params.emissionsAuthority;

isInitialized: this.isInitialized,
authority: this.authority.toBase58(),
nonce: this.nonce,

@@ -39,0 +41,0 @@ tokenProgramId: this.tokenProgramId.toBase58(),

@@ -13,3 +13,3 @@ /// <reference types="node" />

*/
export declare function fetchGlobalFarms(connection: ConnectionInternal, farmPubkeys: PublicKey[]): Promise<GlobalFarm[]>;
export declare function fetchGlobalFarms(connection: ConnectionInternal, farmPubkeys: PublicKey[], programId: PublicKey): Promise<GlobalFarm[]>;
/**

@@ -16,0 +16,0 @@ *

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -16,3 +35,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

exports.fetchUserFarms = exports.fetchGlobalFarms = exports.fetchBatchedAccountInfos = void 0;
const GlobalFarm_1 = __importDefault(require("../models/GlobalFarm"));
const GlobalFarm_1 = __importStar(require("../models/GlobalFarm"));
const layout_1 = require("../utils/layout");

@@ -48,3 +67,3 @@ const UserFarm_1 = __importDefault(require("../models/UserFarm"));

*/
function fetchGlobalFarms(connection, farmPubkeys) {
function fetchGlobalFarms(connection, farmPubkeys, programId) {
return __awaiter(this, void 0, void 0, function* () {

@@ -57,3 +76,6 @@ const accountInfos = yield fetchBatchedAccountInfos(connection, farmPubkeys);

const decoded = layout_1.decodeGlobalFarmBuffer(accountInfo);
return new GlobalFarm_1.default(Object.assign(Object.assign({}, decoded), { publicKey: farmPubkeys[i] }));
const publicKey = farmPubkeys[i];
const authority = GlobalFarm_1.getAuthorityAndNonce(publicKey, programId)[0];
return new GlobalFarm_1.default(Object.assign(Object.assign({}, decoded), { publicKey,
authority }));
});

@@ -60,0 +82,0 @@ });

{
"name": "@orca-so/aquafarm",
"version": "0.0.3",
"version": "0.0.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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