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

@quarryprotocol/quarry-sdk

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@quarryprotocol/quarry-sdk - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

dist/idls/quarry_registry.d.ts

8

dist/constants.d.ts

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

};
/**
* Recipient of protocol fees.
*/
export declare const QUARRY_FEE_TO: PublicKey;
/**
* Sets the protocol fees.
*/
export declare const QUARRY_FEE_SETTER: PublicKey;
//# sourceMappingURL=constants.d.ts.map

10

dist/constants.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QUARRY_IDLS = exports.QUARRY_ADDRESSES = void 0;
exports.QUARRY_FEE_SETTER = exports.QUARRY_FEE_TO = exports.QUARRY_IDLS = exports.QUARRY_ADDRESSES = void 0;
const web3_js_1 = require("@solana/web3.js");

@@ -16,2 +16,10 @@ const quarry_mine_1 = require("./idls/quarry_mine");

};
/**
* Recipient of protocol fees.
*/
exports.QUARRY_FEE_TO = new web3_js_1.PublicKey("4MMZH3ih1aSty2nx4MC3kSR94Zb55XsXnqb5jfEcyHWQ");
/**
* Sets the protocol fees.
*/
exports.QUARRY_FEE_SETTER = new web3_js_1.PublicKey("4MMZH3ih1aSty2nx4MC3kSR94Zb55XsXnqb5jfEcyHWQ");
//# sourceMappingURL=constants.js.map

195

dist/idls/quarry_mine.d.ts

@@ -39,7 +39,2 @@ export declare type QuarryMineIDL = {

{
name: "mintWrapperProgram";
isMut: false;
isSigner: false;
},
{
name: "mintWrapper";

@@ -68,2 +63,60 @@ isMut: false;

{
name: "setPauseAuthority";
accounts: [
{
name: "auth";
accounts: [
{
name: "authority";
isMut: false;
isSigner: true;
},
{
name: "rewarder";
isMut: true;
isSigner: false;
}
];
},
{
name: "pauseAuthority";
isMut: false;
isSigner: false;
}
];
args: [];
},
{
name: "pause";
accounts: [
{
name: "pauseAuthority";
isMut: false;
isSigner: true;
},
{
name: "rewarder";
isMut: true;
isSigner: false;
}
];
args: [];
},
{
name: "unpause";
accounts: [
{
name: "pauseAuthority";
isMut: false;
isSigner: true;
},
{
name: "rewarder";
isMut: true;
isSigner: false;
}
];
args: [];
},
{
name: "transferAuthority";

@@ -106,3 +159,3 @@ accounts: [

{
name: "setDailyRewards";
name: "setAnnualRewards";
accounts: [

@@ -295,2 +348,7 @@ {

{
name: "rewarder";
isMut: false;
isSigner: false;
},
{
name: "systemProgram";

@@ -512,6 +570,6 @@ isMut: false;

{
name: "unusedStubClaimRewards";
name: "extractFees";
accounts: [
{
name: "mintWrapper";
name: "rewarder";
isMut: false;

@@ -521,8 +579,3 @@ isSigner: false;

{
name: "mintWrapperProgram";
isMut: false;
isSigner: false;
},
{
name: "minter";
name: "claimFeeTokenAccount";
isMut: true;

@@ -532,3 +585,3 @@ isSigner: false;

{
name: "rewardsTokenMint";
name: "feeToTokenAccount";
isMut: true;

@@ -538,55 +591,5 @@ isSigner: false;

{
name: "rewardsTokenAccount";
isMut: true;
name: "tokenProgram";
isMut: false;
isSigner: false;
},
{
name: "claimFeeTokenAccount";
isMut: true;
isSigner: false;
},
{
name: "stake";
accounts: [
{
name: "authority";
isMut: false;
isSigner: true;
},
{
name: "miner";
isMut: true;
isSigner: false;
},
{
name: "quarry";
isMut: true;
isSigner: false;
},
{
name: "minerVault";
isMut: true;
isSigner: false;
},
{
name: "tokenAccount";
isMut: true;
isSigner: false;
},
{
name: "tokenProgram";
isMut: false;
isSigner: false;
},
{
name: "rewarder";
isMut: false;
isSigner: false;
},
{
name: "clock";
isMut: false;
isSigner: false;
}
];
}

@@ -624,3 +627,3 @@ ];

{
name: "dailyRewardsRate";
name: "annualRewardsRate";
type: "u64";

@@ -633,6 +636,2 @@ },

{
name: "mintWrapperProgram";
type: "publicKey";
},
{
name: "mintWrapper";

@@ -652,2 +651,10 @@ type: "publicKey";

type: "u64";
},
{
name: "pauseAuthority";
type: "publicKey";
},
{
name: "isPaused";
type: "bool";
}

@@ -675,2 +682,6 @@ ];

{
name: "index";
type: "u16";
},
{
name: "tokenMintDecimals";

@@ -689,6 +700,6 @@ type: "u8";

name: "rewardsPerTokenStored";
type: "u64";
type: "u128";
},
{
name: "dailyRewardsRate";
name: "annualRewardsRate";
type: "u64";

@@ -734,3 +745,3 @@ },

name: "rewardsPerTokenPaid";
type: "u64";
type: "u128";
},

@@ -863,3 +874,3 @@ {

{
name: "RewarderDailyRewardsUpdateEvent";
name: "RewarderAnnualRewardsUpdateEvent";
fields: [

@@ -878,3 +889,3 @@ {

name: "timestamp";
type: "u64";
type: "i64";
index: false;

@@ -895,3 +906,3 @@ }

type: "publicKey";
index: true;
index: false;
},

@@ -929,3 +940,3 @@ {

{
name: "dailyRewardsRate";
name: "annualRewardsRate";
type: "u64";

@@ -941,3 +952,3 @@ index: false;

name: "timestamp";
type: "u64";
type: "i64";
index: false;

@@ -993,2 +1004,12 @@ }

msg: "Invalid max claim fee.";
},
{
code: 309;
name: "MaxAnnualRewardsRateExceeded";
msg: "Max annual rewards rate exceeded.";
},
{
code: 310;
name: "Paused";
msg: "Rewarder is paused.";
}

@@ -1062,3 +1083,17 @@ ];

};
MaxAnnualRewardsRateExceeded: {
code: 309;
name: "MaxAnnualRewardsRateExceeded";
msg: "Max annual rewards rate exceeded.";
} & {
name: "MaxAnnualRewardsRateExceeded";
};
Paused: {
code: 310;
name: "Paused";
msg: "Rewarder is paused.";
} & {
name: "Paused";
};
};
//# sourceMappingURL=quarry_mine.d.ts.map

@@ -43,7 +43,2 @@ "use strict";

{
name: "mintWrapperProgram",
isMut: false,
isSigner: false,
},
{
name: "mintWrapper",

@@ -72,2 +67,60 @@ isMut: false,

{
name: "setPauseAuthority",
accounts: [
{
name: "auth",
accounts: [
{
name: "authority",
isMut: false,
isSigner: true,
},
{
name: "rewarder",
isMut: true,
isSigner: false,
},
],
},
{
name: "pauseAuthority",
isMut: false,
isSigner: false,
},
],
args: [],
},
{
name: "pause",
accounts: [
{
name: "pauseAuthority",
isMut: false,
isSigner: true,
},
{
name: "rewarder",
isMut: true,
isSigner: false,
},
],
args: [],
},
{
name: "unpause",
accounts: [
{
name: "pauseAuthority",
isMut: false,
isSigner: true,
},
{
name: "rewarder",
isMut: true,
isSigner: false,
},
],
args: [],
},
{
name: "transferAuthority",

@@ -110,3 +163,3 @@ accounts: [

{
name: "setDailyRewards",
name: "setAnnualRewards",
accounts: [

@@ -299,2 +352,7 @@ {

{
name: "rewarder",
isMut: false,
isSigner: false,
},
{
name: "systemProgram",

@@ -516,6 +574,6 @@ isMut: false,

{
name: "unusedStubClaimRewards",
name: "extractFees",
accounts: [
{
name: "mintWrapper",
name: "rewarder",
isMut: false,

@@ -525,8 +583,3 @@ isSigner: false,

{
name: "mintWrapperProgram",
isMut: false,
isSigner: false,
},
{
name: "minter",
name: "claimFeeTokenAccount",
isMut: true,

@@ -536,3 +589,3 @@ isSigner: false,

{
name: "rewardsTokenMint",
name: "feeToTokenAccount",
isMut: true,

@@ -542,56 +595,6 @@ isSigner: false,

{
name: "rewardsTokenAccount",
isMut: true,
name: "tokenProgram",
isMut: false,
isSigner: false,
},
{
name: "claimFeeTokenAccount",
isMut: true,
isSigner: false,
},
{
name: "stake",
accounts: [
{
name: "authority",
isMut: false,
isSigner: true,
},
{
name: "miner",
isMut: true,
isSigner: false,
},
{
name: "quarry",
isMut: true,
isSigner: false,
},
{
name: "minerVault",
isMut: true,
isSigner: false,
},
{
name: "tokenAccount",
isMut: true,
isSigner: false,
},
{
name: "tokenProgram",
isMut: false,
isSigner: false,
},
{
name: "rewarder",
isMut: false,
isSigner: false,
},
{
name: "clock",
isMut: false,
isSigner: false,
},
],
},
],

@@ -628,3 +631,3 @@ args: [],

{
name: "dailyRewardsRate",
name: "annualRewardsRate",
type: "u64",

@@ -637,6 +640,2 @@ },

{
name: "mintWrapperProgram",
type: "publicKey",
},
{
name: "mintWrapper",

@@ -657,2 +656,10 @@ type: "publicKey",

},
{
name: "pauseAuthority",
type: "publicKey",
},
{
name: "isPaused",
type: "bool",
},
],

@@ -679,2 +686,6 @@ },

{
name: "index",
type: "u16",
},
{
name: "tokenMintDecimals",

@@ -693,6 +704,6 @@ type: "u8",

name: "rewardsPerTokenStored",
type: "u64",
type: "u128",
},
{
name: "dailyRewardsRate",
name: "annualRewardsRate",
type: "u64",

@@ -738,3 +749,3 @@ },

name: "rewardsPerTokenPaid",
type: "u64",
type: "u128",
},

@@ -867,3 +878,3 @@ {

{
name: "RewarderDailyRewardsUpdateEvent",
name: "RewarderAnnualRewardsUpdateEvent",
fields: [

@@ -882,3 +893,3 @@ {

name: "timestamp",
type: "u64",
type: "i64",
index: false,

@@ -899,3 +910,3 @@ },

type: "publicKey",
index: true,
index: false,
},

@@ -933,3 +944,3 @@ {

{
name: "dailyRewardsRate",
name: "annualRewardsRate",
type: "u64",

@@ -945,3 +956,3 @@ index: false,

name: "timestamp",
type: "u64",
type: "i64",
index: false,

@@ -998,5 +1009,15 @@ },

},
{
code: 309,
name: "MaxAnnualRewardsRateExceeded",
msg: "Max annual rewards rate exceeded.",
},
{
code: 310,
name: "Paused",
msg: "Rewarder is paused.",
},
],
};
exports.QuarryMineErrors = anchor_contrib_1.generateErrorMap(exports.QuarryMineJSON);
exports.QuarryMineErrors = (0, anchor_contrib_1.generateErrorMap)(exports.QuarryMineJSON);
//# sourceMappingURL=quarry_mine.js.map

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

};
exports.QuarryMintWrapperErrors = anchor_contrib_1.generateErrorMap(exports.QuarryMintWrapperJSON);
exports.QuarryMintWrapperErrors = (0, anchor_contrib_1.generateErrorMap)(exports.QuarryMintWrapperJSON);
//# sourceMappingURL=quarry_mint_wrapper.js.map

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

provider,
addresses: lodash_1.mapValues(this.programs, (v) => v.programId),
addresses: (0, lodash_1.mapValues)(this.programs, (v) => v.programId),
});

@@ -56,6 +56,6 @@ }

const allAddresses = Object.assign(Object.assign({}, constants_1.QUARRY_ADDRESSES), addresses);
const programs = lodash_1.mapValues(constants_1.QUARRY_ADDRESSES, (_, programName) => {
const programs = (0, lodash_1.mapValues)(constants_1.QUARRY_ADDRESSES, (_, programName) => {
const address = allAddresses[programName];
const idl = constants_1.QUARRY_IDLS[programName];
tiny_invariant_1.default(idl, `Unknown IDL: ${programName}`);
(0, tiny_invariant_1.default)(idl, `Unknown IDL: ${programName}`);
const anchorProvider = new anchor_1.Provider(provider.sendConnection, provider.wallet, confirmOptions !== null && confirmOptions !== void 0 ? confirmOptions : solana_contrib_1.DEFAULT_PROVIDER_OPTIONS);

@@ -62,0 +62,0 @@ return new anchor_1.Program(idl, address, anchorProvider);

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

return __awaiter(this, void 0, void 0, function* () {
const [rewarderKey, bump] = yield pda_1.findRewarderAddress(baseKP.publicKey, this.program.programId);
const mintWrapperData = yield this.sdk.programs.MintWrapper.account.mintWrapper.fetch(mintWrapper);
const { address: claimFeeTokenAccount, instruction: createATAInstruction } = yield token_utils_1.getOrCreateATA({
const [rewarderKey, bump] = yield (0, pda_1.findRewarderAddress)(baseKP.publicKey, this.program.programId);
const mintWrapperDataRaw = yield this.provider.getAccountInfo(mintWrapper);
if (!mintWrapperDataRaw) {
throw new Error(`mint wrapper does not exist at ${mintWrapper.toString()}`);
}
const mintWrapperData = this.sdk.programs.MintWrapper.coder.accounts.decode("MintWrapper", mintWrapperDataRaw.accountInfo.data);
const { address: claimFeeTokenAccount, instruction: createATAInstruction } = yield (0, token_utils_1.getOrCreateATA)({
provider: this.provider,

@@ -50,3 +54,2 @@ mint: mintWrapperData.tokenMint,

mintWrapper,
mintWrapperProgram: this.sdk.programs.MintWrapper.programId,
rewardsTokenMint: mintWrapperData.tokenMint,

@@ -53,0 +56,0 @@ claimFeeTokenAccount,

@@ -9,3 +9,3 @@ import type { Provider } from "@saberhq/solana-contrib";

import type { PendingMiner } from "./types";
declare type MineUserStakeAccounts = Parameters<MineProgram["instruction"]["unusedStubClaimRewards"]["accounts"]>[0]["stake"];
declare type MineUserStakeAccounts = Parameters<MineProgram["instruction"]["claimRewards"]["accounts"]>[0]["stake"];
export declare class MinerWrapper {

@@ -12,0 +12,0 @@ readonly quarry: QuarryWrapper;

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

minerVault: this.tokenVaultKey,
rewarder: this.quarry.quarryData.rewarderKey,
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,

@@ -102,3 +103,3 @@ tokenMint: this.quarry.token.mintAccount,

return __awaiter(this, void 0, void 0, function* () {
return yield token_utils_1.getOrCreateATA({
return yield (0, token_utils_1.getOrCreateATA)({
provider: this.provider,

@@ -154,3 +155,3 @@ mint: this.quarry.token.mintAccount,

const instructions = [];
const { address: rewardsTokenAccount, instruction: ataInstruction } = yield token_utils_1.getOrCreateATA({
const { address: rewardsTokenAccount, instruction: ataInstruction } = yield (0, token_utils_1.getOrCreateATA)({
provider: this.provider,

@@ -163,7 +164,6 @@ mint: this.quarry.rewarderData.rewardsTokenMint,

}
const [minter] = yield pda_1.findMinterAddress(this.quarry.rewarderData.mintWrapper, this.quarry.quarryData.rewarderKey, this.sdk.mintWrapper.program.programId);
const [minter] = yield (0, pda_1.findMinterAddress)(this.quarry.rewarderData.mintWrapper, this.quarry.quarryData.rewarderKey, this.sdk.mintWrapper.program.programId);
const ix = this.quarry.program.instruction.claimRewards({
accounts: {
mintWrapper: this.quarry.rewarderData.mintWrapper,
mintWrapperProgram: this.quarry.rewarderData.mintWrapperProgram,
minter,

@@ -173,2 +173,3 @@ rewardsTokenMint: this.quarry.rewarderData.rewardsTokenMint,

stake: this.userStakeAccounts,
mintWrapperProgram: this.sdk.programs.MintWrapper.programId,
claimFeeTokenAccount: this.quarry.rewarderData.claimFeeTokenAccount,

@@ -175,0 +176,0 @@ },

@@ -7,7 +7,6 @@ import BN from "bn.js";

readonly lastCheckpointTs: BN;
readonly rewardsRatePerSecond: BN;
readonly annualRewardsRate: BN;
readonly rewardsPerTokenStored: BN;
readonly tokenDecimals: BN;
readonly totalTokensDeposited: BN;
constructor(famineTs: BN, lastCheckpointTs: BN, rewardsRatePerSecond: BN, rewardsPerTokenStored: BN, tokenDecimals: BN, totalTokensDeposited: BN);
constructor(famineTs: BN, lastCheckpointTs: BN, annualRewardsRate: BN, rewardsPerTokenStored: BN, totalTokensDeposited: BN);
/**

@@ -28,4 +27,3 @@ * Calculates the amount of tokens that this user can receive.

calculateRewardsEarned(currentTs: BN, tokensDeposited: BN, rewardsPerTokenPaid: BN, rewardsEarned: BN): BN;
private decimalPrecision;
}
//# sourceMappingURL=payroll.d.ts.map

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

exports.Payroll = exports.BASE_TEN = exports.ZERO = void 0;
const token_utils_1 = require("@saberhq/token-utils");
const bn_js_1 = __importDefault(require("bn.js"));

@@ -12,8 +13,7 @@ exports.ZERO = new bn_js_1.default(0);

class Payroll {
constructor(famineTs, lastCheckpointTs, rewardsRatePerSecond, rewardsPerTokenStored, tokenDecimals, totalTokensDeposited) {
constructor(famineTs, lastCheckpointTs, annualRewardsRate, rewardsPerTokenStored, totalTokensDeposited) {
this.famineTs = famineTs;
this.lastCheckpointTs = lastCheckpointTs;
this.rewardsRatePerSecond = rewardsRatePerSecond;
this.annualRewardsRate = annualRewardsRate;
this.rewardsPerTokenStored = rewardsPerTokenStored;
this.tokenDecimals = tokenDecimals;
this.totalTokensDeposited = totalTokensDeposited;

@@ -32,7 +32,8 @@ }

const timeWorked = bn_js_1.default.max(exports.ZERO, lastTimeRewardsApplicable.sub(this.lastCheckpointTs));
const reward = timeWorked.mul(this.rewardsRatePerSecond);
const preciseReward = reward
.mul(this.decimalPrecision())
const reward = timeWorked
.mul(new bn_js_1.default(token_utils_1.MAX_U64.toString()))
.mul(this.annualRewardsRate)
.div(new bn_js_1.default(365 * 86400))
.div(this.totalTokensDeposited);
return this.rewardsPerTokenStored.add(preciseReward);
return this.rewardsPerTokenStored.add(reward);
}

@@ -51,10 +52,7 @@ /**

.mul(netNewRewards)
.div(this.decimalPrecision());
.div(new bn_js_1.default(token_utils_1.MAX_U64.toString()));
return earnedRewards.add(rewardsEarned);
}
decimalPrecision() {
return exports.BASE_TEN.pow(this.tokenDecimals);
}
}
exports.Payroll = Payroll;
//# sourceMappingURL=payroll.js.map

@@ -70,9 +70,10 @@ import type { Provider } from "@saberhq/solana-contrib";

/**
* Get the computed rewards rate of the quarry
* Get the computed rewards rate of the quarry.
*
* You probably don't want this. You want quarryData.dailyRewardsRate.
* This is used for tests, so you probably don't want this.
* You want quarryData.annualRewardsRate.
*
* @returns dailyRewardsRate
* @returns annualRewardsRate
*/
computeDailyRewardsRate(): u64;
computeAnnualRewardsRate(): u64;
/**

@@ -79,0 +80,0 @@ * Get the public key of the miner assocaited with the authority account

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

const web3_js_1 = require("@solana/web3.js");
const BN = require("bn.js");
const miner_1 = require("./miner");

@@ -71,9 +70,10 @@ const payroll_1 = require("./payroll");

/**
* Get the computed rewards rate of the quarry
* Get the computed rewards rate of the quarry.
*
* You probably don't want this. You want quarryData.dailyRewardsRate.
* This is used for tests, so you probably don't want this.
* You want quarryData.annualRewardsRate.
*
* @returns dailyRewardsRate
* @returns annualRewardsRate
*/
computeDailyRewardsRate() {
computeAnnualRewardsRate() {
const rewarder = this.rewarderData;

@@ -84,3 +84,3 @@ const totalRewardsShares = rewarder.totalRewardsShares;

}
const numerator = rewarder.dailyRewardsRate.mul(this.quarryData.rewardsShare);
const numerator = rewarder.annualRewardsRate.mul(this.quarryData.rewardsShare);
return numerator.div(totalRewardsShares);

@@ -95,3 +95,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
const [key] = yield pda_1.findMinerAddress(this.key, authority, this.program.programId);
const [key] = yield (0, pda_1.findMinerAddress)(this.key, authority, this.program.programId);
return key;

@@ -118,7 +118,7 @@ });

const miner = yield this.getMinerAddress(authority);
const stakedTokenATA = yield token_utils_1.getATAAddress({
const stakedTokenATA = yield (0, token_utils_1.getATAAddress)({
mint: this.quarryData.tokenMintKey,
owner: authority,
});
const tokenVaultKey = yield token_utils_1.getATAAddress({
const tokenVaultKey = yield (0, token_utils_1.getATAAddress)({
mint: this.quarryData.tokenMintKey,

@@ -168,4 +168,4 @@ owner: miner,

return __awaiter(this, void 0, void 0, function* () {
const [miner, bump] = yield pda_1.findMinerAddress(this.key, authority, this.program.programId);
const { address: minerVault, instruction: createATATX } = yield token_utils_1.getOrCreateATA({
const [miner, bump] = yield (0, pda_1.findMinerAddress)(this.key, authority, this.program.programId);
const { address: minerVault, instruction: createATATX } = yield (0, token_utils_1.getOrCreateATA)({
provider: this.provider,

@@ -175,3 +175,3 @@ mint: this.quarryData.tokenMintKey,

});
const stakedTokenATA = yield token_utils_1.getATAAddress({
const stakedTokenATA = yield (0, token_utils_1.getATAAddress)({
mint: this.quarryData.tokenMintKey,

@@ -193,3 +193,3 @@ owner: authority,

const data = this.quarryData;
return new payroll_1.Payroll(data.famineTs, data.lastUpdateTs, data.dailyRewardsRate, data.rewardsPerTokenStored, new BN(data.tokenMintDecimals), data.totalTokensDeposited);
return new payroll_1.Payroll(data.famineTs, data.lastUpdateTs, data.annualRewardsRate, data.rewardsPerTokenStored, data.totalTokensDeposited);
}

@@ -196,0 +196,0 @@ }

@@ -48,3 +48,3 @@ import type { TransactionEnvelope } from "@saberhq/solana-contrib";

*/
setDailyRewards(newDailyRate: u64, mints: PublicKey[]): Promise<TransactionEnvelope>;
setAnnualRewards(newAnnualRate: u64, mints: PublicKey[]): Promise<TransactionEnvelope>;
/**

@@ -51,0 +51,0 @@ * Synchronizes quarry rewards.

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

return __awaiter(this, void 0, void 0, function* () {
const [quarryKey] = yield pda_1.findQuarryAddress(this.rewarderKey, mint, this.program.programId);
const [quarryKey] = yield (0, pda_1.findQuarryAddress)(this.rewarderKey, mint, this.program.programId);
return quarryKey;

@@ -68,3 +68,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
const [quarryKey, bump] = yield pda_1.findQuarryAddress(this.rewarderKey, token.mintAccount, this.program.programId);
const [quarryKey, bump] = yield (0, pda_1.findQuarryAddress)(this.rewarderKey, token.mintAccount, this.program.programId);
const ix = this.program.instruction.createQuarry(bump, {

@@ -94,7 +94,7 @@ accounts: {

*/
setDailyRewards(newDailyRate, mints) {
setAnnualRewards(newAnnualRate, mints) {
return __awaiter(this, void 0, void 0, function* () {
const authority = this.program.provider.wallet.publicKey;
const tx = yield this.syncQuarryRewards(mints);
tx.instructions.unshift(this.program.instruction.setDailyRewards(newDailyRate, {
tx.instructions.unshift(this.program.instruction.setAnnualRewards(newAnnualRate, {
accounts: {

@@ -101,0 +101,0 @@ auth: {

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

return __awaiter(this, void 0, void 0, function* () {
const [mintWrapper, nonce] = yield pda_1.findMintWrapperAddress(baseKP.publicKey, this.program.programId);
const [mintWrapper, nonce] = yield (0, pda_1.findMintWrapperAddress)(baseKP.publicKey, this.program.programId);
return {

@@ -64,3 +64,3 @@ mintWrapper,

const { mintWrapper, tx: initMintProxyTX } = yield this.newWrapper(Object.assign(Object.assign({}, newWrapperArgs), { tokenMint: mintKP.publicKey }));
const initMintTX = yield token_utils_1.createInitMintInstructions({
const initMintTX = yield (0, token_utils_1.createInitMintInstructions)({
provider,

@@ -86,3 +86,3 @@ mintAuthority: mintWrapper,

return __awaiter(this, void 0, void 0, function* () {
const [minterAddress] = yield pda_1.findMinterAddress(wrapper, authority, this.program.programId);
const [minterAddress] = yield (0, pda_1.findMinterAddress)(wrapper, authority, this.program.programId);
const accountInfo = yield this.program.provider.connection.getAccountInfo(minterAddress);

@@ -97,3 +97,3 @@ if (!accountInfo) {

return __awaiter(this, void 0, void 0, function* () {
const [minter, bump] = yield pda_1.findMinterAddress(wrapper, authority, this.program.programId);
const [minter, bump] = yield (0, pda_1.findMinterAddress)(wrapper, authority, this.program.programId);
return this.sdk.newTx([

@@ -132,3 +132,3 @@ this.program.instruction.newMinter(bump, {

return __awaiter(this, void 0, void 0, function* () {
const [minter] = yield pda_1.findMinterAddress(wrapper, authority, this.program.programId);
const [minter] = yield (0, pda_1.findMinterAddress)(wrapper, authority, this.program.programId);
return this.sdk.newTx([

@@ -135,0 +135,0 @@ this.program.instruction.minterUpdate(allowance, {

{
"name": "@quarryprotocol/quarry-sdk",
"version": "0.2.0",
"version": "1.0.0",
"description": "Quarry Protocol SDK",
"main": "dist/index.js",
"repository": "git@github.com:QuarryProtocol/quarry.git",
"author": "Larry Jarry <larry@quarry.so>",
"author": "Quarry Protocol <team@quarry.so>",
"bugs": {
"url": "https://github.com/QuarryProtocol/quarry/issues",
"email": "team@quarry.so"
},
"license": "AGPL-3.0",

@@ -22,6 +26,6 @@ "scripts": {

"@project-serum/common": "^0.0.1-beta.3",
"@saberhq/chai-solana": "^0.14.2",
"@saberhq/eslint-config": "^0.14.1",
"@saberhq/chai-solana": "^0.16.0",
"@saberhq/eslint-config": "^0.16.0",
"@types/mocha": "^9.0.0",
"@types/node": "^16.7.1",
"@types/node": "^16.7.10",
"eslint": "^7.32.0",

@@ -37,5 +41,5 @@ "husky": "^7.0.2",

"@project-serum/anchor": "^0.13.2",
"@saberhq/anchor-contrib": "^0.14.0",
"@saberhq/solana-contrib": "^0.14.2",
"@saberhq/token-utils": "^0.14.2",
"@saberhq/anchor-contrib": "^0.16.0",
"@saberhq/solana-contrib": "^0.16.0",
"@saberhq/token-utils": "^0.16.0",
"@solana/web3.js": "^1.24.1",

@@ -42,0 +46,0 @@ "bn.js": "^5.2.0"

@@ -26,7 +26,8 @@ # ⛏ Quarry

| Package | Description | Version | Docs |
| :--------------------------- | :---------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------- |
| `quarry-mint-wrapper` | Mints tokens to authorized accounts | [![Crates.io](https://img.shields.io/crates/v/quarry-mint-wrapper?color=blue)](https://crates.io/crates/quarry-mint-wrapper) | [![Docs.rs](https://docs.rs/quarry-mint-wrapper/badge.svg)](https://docs.rs/quarry-mint-wrapper) |
| `quarry-mine` | Distributes liquidity mining rewards to token stakers | ![crates](https://img.shields.io/crates/v/quarry-mine?color=blue) | [![Docs.rs](https://docs.rs/quarry-mine/badge.svg)](https://docs.rs/quarry-mine) |
| `@quarryprotocol/quarry-sdk` | TypeScript SDK for Quarry | [![npm](https://img.shields.io/npm/v/@quarryprotocol/quarry-sdk.svg?color=blue)](https://www.npmjs.com/package/@quarryprotocol/quarry-sdk) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://docs.quarry.so/ts/) |
| Package | Description | Version | Docs |
| :--------------------------- | :---------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------------------------------------------- |
| `quarry-mint-wrapper` | Mints tokens to authorized accounts | [![Crates.io](https://img.shields.io/crates/v/quarry-mint-wrapper)](https://crates.io/crates/quarry-mint-wrapper) | [![Docs.rs](https://docs.rs/quarry-mint-wrapper/badge.svg)](https://docs.rs/quarry-mint-wrapper) |
| `quarry-mine` | Distributes liquidity mining rewards to token stakers | [![crates](https://img.shields.io/crates/v/quarry-mine)](https://crates.io/crates/quarry-mine) | [![Docs.rs](https://docs.rs/quarry-mine/badge.svg)](https://docs.rs/quarry-mine) |
| `quarry-registry` | Registry to index all quarries of a rewarder. | [![crates](https://img.shields.io/crates/v/quarry-registry)](https://crates.io/crates/quarry-registry) | [![Docs.rs](https://docs.rs/quarry-registry/badge.svg)](https://docs.rs/quarry-registry) |
| `@quarryprotocol/quarry-sdk` | TypeScript SDK for Quarry | [![npm](https://img.shields.io/npm/v/@quarryprotocol/quarry-sdk.svg)](https://www.npmjs.com/package/@quarryprotocol/quarry-sdk) | [![Docs](https://img.shields.io/badge/docs-typedoc-blue)](https://docs.quarry.so/ts/) |

@@ -33,0 +34,0 @@ ## Documentation

@@ -22,1 +22,15 @@ import { PublicKey } from "@solana/web3.js";

};
/**
* Recipient of protocol fees.
*/
export const QUARRY_FEE_TO = new PublicKey(
"4MMZH3ih1aSty2nx4MC3kSR94Zb55XsXnqb5jfEcyHWQ"
);
/**
* Sets the protocol fees.
*/
export const QUARRY_FEE_SETTER = new PublicKey(
"4MMZH3ih1aSty2nx4MC3kSR94Zb55XsXnqb5jfEcyHWQ"
);

@@ -41,7 +41,2 @@ import { generateErrorMap } from "@saberhq/anchor-contrib";

{
name: "mintWrapperProgram";
isMut: false;
isSigner: false;
},
{
name: "mintWrapper";

@@ -70,2 +65,60 @@ isMut: false;

{
name: "setPauseAuthority";
accounts: [
{
name: "auth";
accounts: [
{
name: "authority";
isMut: false;
isSigner: true;
},
{
name: "rewarder";
isMut: true;
isSigner: false;
}
];
},
{
name: "pauseAuthority";
isMut: false;
isSigner: false;
}
];
args: [];
},
{
name: "pause";
accounts: [
{
name: "pauseAuthority";
isMut: false;
isSigner: true;
},
{
name: "rewarder";
isMut: true;
isSigner: false;
}
];
args: [];
},
{
name: "unpause";
accounts: [
{
name: "pauseAuthority";
isMut: false;
isSigner: true;
},
{
name: "rewarder";
isMut: true;
isSigner: false;
}
];
args: [];
},
{
name: "transferAuthority";

@@ -108,3 +161,3 @@ accounts: [

{
name: "setDailyRewards";
name: "setAnnualRewards";
accounts: [

@@ -297,2 +350,7 @@ {

{
name: "rewarder";
isMut: false;
isSigner: false;
},
{
name: "systemProgram";

@@ -514,6 +572,6 @@ isMut: false;

{
name: "unusedStubClaimRewards";
name: "extractFees";
accounts: [
{
name: "mintWrapper";
name: "rewarder";
isMut: false;

@@ -523,8 +581,3 @@ isSigner: false;

{
name: "mintWrapperProgram";
isMut: false;
isSigner: false;
},
{
name: "minter";
name: "claimFeeTokenAccount";
isMut: true;

@@ -534,3 +587,3 @@ isSigner: false;

{
name: "rewardsTokenMint";
name: "feeToTokenAccount";
isMut: true;

@@ -540,55 +593,5 @@ isSigner: false;

{
name: "rewardsTokenAccount";
isMut: true;
name: "tokenProgram";
isMut: false;
isSigner: false;
},
{
name: "claimFeeTokenAccount";
isMut: true;
isSigner: false;
},
{
name: "stake";
accounts: [
{
name: "authority";
isMut: false;
isSigner: true;
},
{
name: "miner";
isMut: true;
isSigner: false;
},
{
name: "quarry";
isMut: true;
isSigner: false;
},
{
name: "minerVault";
isMut: true;
isSigner: false;
},
{
name: "tokenAccount";
isMut: true;
isSigner: false;
},
{
name: "tokenProgram";
isMut: false;
isSigner: false;
},
{
name: "rewarder";
isMut: false;
isSigner: false;
},
{
name: "clock";
isMut: false;
isSigner: false;
}
];
}

@@ -626,3 +629,3 @@ ];

{
name: "dailyRewardsRate";
name: "annualRewardsRate";
type: "u64";

@@ -635,6 +638,2 @@ },

{
name: "mintWrapperProgram";
type: "publicKey";
},
{
name: "mintWrapper";

@@ -654,2 +653,10 @@ type: "publicKey";

type: "u64";
},
{
name: "pauseAuthority";
type: "publicKey";
},
{
name: "isPaused";
type: "bool";
}

@@ -677,2 +684,6 @@ ];

{
name: "index";
type: "u16";
},
{
name: "tokenMintDecimals";

@@ -691,6 +702,6 @@ type: "u8";

name: "rewardsPerTokenStored";
type: "u64";
type: "u128";
},
{
name: "dailyRewardsRate";
name: "annualRewardsRate";
type: "u64";

@@ -736,3 +747,3 @@ },

name: "rewardsPerTokenPaid";
type: "u64";
type: "u128";
},

@@ -865,3 +876,3 @@ {

{
name: "RewarderDailyRewardsUpdateEvent";
name: "RewarderAnnualRewardsUpdateEvent";
fields: [

@@ -880,3 +891,3 @@ {

name: "timestamp";
type: "u64";
type: "i64";
index: false;

@@ -897,3 +908,3 @@ }

type: "publicKey";
index: true;
index: false;
},

@@ -931,3 +942,3 @@ {

{
name: "dailyRewardsRate";
name: "annualRewardsRate";
type: "u64";

@@ -943,3 +954,3 @@ index: false;

name: "timestamp";
type: "u64";
type: "i64";
index: false;

@@ -995,2 +1006,12 @@ }

msg: "Invalid max claim fee.";
},
{
code: 309;
name: "MaxAnnualRewardsRateExceeded";
msg: "Max annual rewards rate exceeded.";
},
{
code: 310;
name: "Paused";
msg: "Rewarder is paused.";
}

@@ -1037,7 +1058,2 @@ ];

{
name: "mintWrapperProgram",
isMut: false,
isSigner: false,
},
{
name: "mintWrapper",

@@ -1066,2 +1082,60 @@ isMut: false,

{
name: "setPauseAuthority",
accounts: [
{
name: "auth",
accounts: [
{
name: "authority",
isMut: false,
isSigner: true,
},
{
name: "rewarder",
isMut: true,
isSigner: false,
},
],
},
{
name: "pauseAuthority",
isMut: false,
isSigner: false,
},
],
args: [],
},
{
name: "pause",
accounts: [
{
name: "pauseAuthority",
isMut: false,
isSigner: true,
},
{
name: "rewarder",
isMut: true,
isSigner: false,
},
],
args: [],
},
{
name: "unpause",
accounts: [
{
name: "pauseAuthority",
isMut: false,
isSigner: true,
},
{
name: "rewarder",
isMut: true,
isSigner: false,
},
],
args: [],
},
{
name: "transferAuthority",

@@ -1104,3 +1178,3 @@ accounts: [

{
name: "setDailyRewards",
name: "setAnnualRewards",
accounts: [

@@ -1293,2 +1367,7 @@ {

{
name: "rewarder",
isMut: false,
isSigner: false,
},
{
name: "systemProgram",

@@ -1510,6 +1589,6 @@ isMut: false,

{
name: "unusedStubClaimRewards",
name: "extractFees",
accounts: [
{
name: "mintWrapper",
name: "rewarder",
isMut: false,

@@ -1519,8 +1598,3 @@ isSigner: false,

{
name: "mintWrapperProgram",
isMut: false,
isSigner: false,
},
{
name: "minter",
name: "claimFeeTokenAccount",
isMut: true,

@@ -1530,3 +1604,3 @@ isSigner: false,

{
name: "rewardsTokenMint",
name: "feeToTokenAccount",
isMut: true,

@@ -1536,56 +1610,6 @@ isSigner: false,

{
name: "rewardsTokenAccount",
isMut: true,
name: "tokenProgram",
isMut: false,
isSigner: false,
},
{
name: "claimFeeTokenAccount",
isMut: true,
isSigner: false,
},
{
name: "stake",
accounts: [
{
name: "authority",
isMut: false,
isSigner: true,
},
{
name: "miner",
isMut: true,
isSigner: false,
},
{
name: "quarry",
isMut: true,
isSigner: false,
},
{
name: "minerVault",
isMut: true,
isSigner: false,
},
{
name: "tokenAccount",
isMut: true,
isSigner: false,
},
{
name: "tokenProgram",
isMut: false,
isSigner: false,
},
{
name: "rewarder",
isMut: false,
isSigner: false,
},
{
name: "clock",
isMut: false,
isSigner: false,
},
],
},
],

@@ -1622,3 +1646,3 @@ args: [],

{
name: "dailyRewardsRate",
name: "annualRewardsRate",
type: "u64",

@@ -1631,6 +1655,2 @@ },

{
name: "mintWrapperProgram",
type: "publicKey",
},
{
name: "mintWrapper",

@@ -1651,2 +1671,10 @@ type: "publicKey",

},
{
name: "pauseAuthority",
type: "publicKey",
},
{
name: "isPaused",
type: "bool",
},
],

@@ -1673,2 +1701,6 @@ },

{
name: "index",
type: "u16",
},
{
name: "tokenMintDecimals",

@@ -1687,6 +1719,6 @@ type: "u8",

name: "rewardsPerTokenStored",
type: "u64",
type: "u128",
},
{
name: "dailyRewardsRate",
name: "annualRewardsRate",
type: "u64",

@@ -1732,3 +1764,3 @@ },

name: "rewardsPerTokenPaid",
type: "u64",
type: "u128",
},

@@ -1861,3 +1893,3 @@ {

{
name: "RewarderDailyRewardsUpdateEvent",
name: "RewarderAnnualRewardsUpdateEvent",
fields: [

@@ -1876,3 +1908,3 @@ {

name: "timestamp",
type: "u64",
type: "i64",
index: false,

@@ -1893,3 +1925,3 @@ },

type: "publicKey",
index: true,
index: false,
},

@@ -1927,3 +1959,3 @@ {

{
name: "dailyRewardsRate",
name: "annualRewardsRate",
type: "u64",

@@ -1939,3 +1971,3 @@ index: false,

name: "timestamp",
type: "u64",
type: "i64",
index: false,

@@ -1992,4 +2024,14 @@ },

},
{
code: 309,
name: "MaxAnnualRewardsRateExceeded",
msg: "Max annual rewards rate exceeded.",
},
{
code: 310,
name: "Paused",
msg: "Rewarder is paused.",
},
],
};
export const QuarryMineErrors = generateErrorMap(QuarryMineJSON);

@@ -6,2 +6,3 @@ import type { Provider, TransactionEnvelope } from "@saberhq/solana-contrib";

import type { MintWrapperData } from "../../programs";
import type { MineProgram } from "../../programs/mine";

@@ -39,5 +40,14 @@ import type { QuarrySDK } from "../../sdk";

);
const mintWrapperDataRaw = await this.provider.getAccountInfo(mintWrapper);
if (!mintWrapperDataRaw) {
throw new Error(
`mint wrapper does not exist at ${mintWrapper.toString()}`
);
}
const mintWrapperData =
await this.sdk.programs.MintWrapper.account.mintWrapper.fetch(
mintWrapper
this.sdk.programs.MintWrapper.coder.accounts.decode<MintWrapperData>(
"MintWrapper",
mintWrapperDataRaw.accountInfo.data
);

@@ -66,3 +76,2 @@

mintWrapper,
mintWrapperProgram: this.sdk.programs.MintWrapper.programId,
rewardsTokenMint: mintWrapperData.tokenMint,

@@ -69,0 +78,0 @@ claimFeeTokenAccount,

@@ -16,3 +16,3 @@ import type { Provider } from "@saberhq/solana-contrib";

type MineUserStakeAccounts = Parameters<
MineProgram["instruction"]["unusedStubClaimRewards"]["accounts"]
MineProgram["instruction"]["claimRewards"]["accounts"]
>[0]["stake"];

@@ -70,2 +70,3 @@

minerVault: this.tokenVaultKey,
rewarder: this.quarry.quarryData.rewarderKey,
tokenProgram: TOKEN_PROGRAM_ID,

@@ -183,3 +184,2 @@ tokenMint: this.quarry.token.mintAccount,

mintWrapper: this.quarry.rewarderData.mintWrapper,
mintWrapperProgram: this.quarry.rewarderData.mintWrapperProgram,
minter,

@@ -189,2 +189,3 @@ rewardsTokenMint: this.quarry.rewarderData.rewardsTokenMint,

stake: this.userStakeAccounts,
mintWrapperProgram: this.sdk.programs.MintWrapper.programId,
claimFeeTokenAccount: this.quarry.rewarderData.claimFeeTokenAccount,

@@ -191,0 +192,0 @@ },

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

import { MAX_U64 } from "@saberhq/token-utils";
import BN from "bn.js";

@@ -10,5 +11,4 @@

public readonly lastCheckpointTs: BN,
public readonly rewardsRatePerSecond: BN,
public readonly annualRewardsRate: BN,
public readonly rewardsPerTokenStored: BN,
public readonly tokenDecimals: BN,
public readonly totalTokensDeposited: BN

@@ -32,8 +32,8 @@ ) {}

);
const reward = timeWorked.mul(this.rewardsRatePerSecond);
const preciseReward = reward
.mul(this.decimalPrecision())
const reward = timeWorked
.mul(new BN(MAX_U64.toString()))
.mul(this.annualRewardsRate)
.div(new BN(365 * 86_400))
.div(this.totalTokensDeposited);
return this.rewardsPerTokenStored.add(preciseReward);
return this.rewardsPerTokenStored.add(reward);
}

@@ -59,9 +59,5 @@

.mul(netNewRewards)
.div(this.decimalPrecision());
.div(new BN(MAX_U64.toString()));
return earnedRewards.add(rewardsEarned);
}
private decimalPrecision(): BN {
return BASE_TEN.pow(this.tokenDecimals);
}
}

@@ -8,3 +8,2 @@ import type { Provider } from "@saberhq/solana-contrib";

import { SYSVAR_CLOCK_PUBKEY } from "@solana/web3.js";
import BN = require("bn.js");

@@ -86,9 +85,10 @@ import type {

/**
* Get the computed rewards rate of the quarry
* Get the computed rewards rate of the quarry.
*
* You probably don't want this. You want quarryData.dailyRewardsRate.
* This is used for tests, so you probably don't want this.
* You want quarryData.annualRewardsRate.
*
* @returns dailyRewardsRate
* @returns annualRewardsRate
*/
public computeDailyRewardsRate(): u64 {
public computeAnnualRewardsRate(): u64 {
const rewarder = this.rewarderData;

@@ -99,3 +99,3 @@ const totalRewardsShares = rewarder.totalRewardsShares;

}
const numerator = rewarder.dailyRewardsRate.mul(
const numerator = rewarder.annualRewardsRate.mul(
this.quarryData.rewardsShare

@@ -246,5 +246,4 @@ );

data.lastUpdateTs,
data.dailyRewardsRate,
data.annualRewardsRate,
data.rewardsPerTokenStored,
new BN(data.tokenMintDecimals),
data.totalTokensDeposited

@@ -251,0 +250,0 @@ );

@@ -106,4 +106,4 @@ import type { TransactionEnvelope } from "@saberhq/solana-contrib";

*/
public async setDailyRewards(
newDailyRate: u64,
public async setAnnualRewards(
newAnnualRate: u64,
mints: PublicKey[]

@@ -114,3 +114,3 @@ ): Promise<TransactionEnvelope> {

tx.instructions.unshift(
this.program.instruction.setDailyRewards(newDailyRate, {
this.program.instruction.setAnnualRewards(newAnnualRate, {
accounts: {

@@ -117,0 +117,0 @@ auth: {

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

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

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

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

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