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

@staratlas/claim-stake

Package Overview
Dependencies
Maintainers
4
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@staratlas/claim-stake - npm Package Compare versions

Comparing version 0.2.8 to 0.2.10

dist/test/claimStake.test.d.ts

1

dist/src/claimStakeVars.d.ts

@@ -5,2 +5,3 @@ import { Account, DecodedAccountData } from '@staratlas/data-source';

import { KeyedAccountInfo, PublicKey } from '@solana/web3.js';
export declare const REWARD_MULTIPLIER = 1000000;
export declare function claimStakeVarsEquals(claimStakeVarsAccount1: ClaimStakeVarsAccount, claimStakeVarsAccount2: ClaimStakeVarsAccount): boolean;

@@ -7,0 +8,0 @@ export declare class ClaimStakeVars implements Account {

15

dist/src/claimStakeVars.js

@@ -13,5 +13,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ClaimStakeVars = exports.claimStakeVarsEquals = void 0;
exports.ClaimStakeVars = exports.claimStakeVarsEquals = exports.REWARD_MULTIPLIER = void 0;
const data_source_1 = require("@staratlas/data-source");
const web3_js_1 = require("@solana/web3.js");
exports.REWARD_MULTIPLIER = 1000000;
function claimStakeVarsEquals(claimStakeVarsAccount1, claimStakeVarsAccount2) {

@@ -49,11 +50,13 @@ return (claimStakeVarsAccount1.armsMaxReserve.eq(claimStakeVarsAccount2.armsMaxReserve) &&

ClaimStakeVars.MIN_DATA_SIZE = 8 + // discriminator
1 + // Version
32 + // Claim Stake Mint
8 + // Fuel Reward Rate per second
8 + // Arms reward rate per second
8 + // Food reward rate per second
8 + // Toolkit reward rate per second
8 + // Fuel reward rate
8 + // Arms reward rate
8 + // Food reward rate
8 + // Toolkit reward rate
8 + // Fuel max reserve
8 + // Food max reserve
8 + // Arms max reserve
8; // Toolkit max reserve
8 + // Toolkit max reserve
1; // Bump
ClaimStakeVars = ClaimStakeVars_1 = __decorate([

@@ -60,0 +63,0 @@ (0, data_source_1.staticImplements)(),

@@ -18,10 +18,9 @@ "use strict";

return (claimStaking1.claimStakesInEscrow.eq(claimStaking2.claimStakesInEscrow) &&
claimStaking1.armsToPay.eq(claimStaking2.armsToPay) &&
claimStaking1.factionId === claimStaking2.factionId &&
claimStaking1.foodToPay.eq(claimStaking2.foodToPay) &&
claimStaking1.fuelToPay.eq(claimStaking2.fuelToPay) &&
claimStaking1.mint.equals(claimStaking2.mint) &&
claimStaking1.owner.equals(claimStaking2.owner) &&
claimStaking1.toolkitToPay.eq(claimStaking2.toolkitToPay) &&
claimStaking1.totalRewardsPaid.eq(claimStaking2.totalRewardsPaid));
// claimStaking1.armsToPay.eq(claimStaking2.armsToPay) &&
// claimStaking1.factionId === claimStaking2.factionId &&
// claimStaking1.foodToPay.eq(claimStaking2.foodToPay) &&
// claimStaking1.fuelToPay.eq(claimStaking2.fuelToPay) &&
// claimStaking1.mint.equals(claimStaking2.mint) &&
// claimStaking1.owner.equals(claimStaking2.owner) &&
claimStaking1.toolkitToPay.eq(claimStaking2.toolkitToPay));
}

@@ -33,4 +32,3 @@ exports.claimStakingAccountEquals = claimStakingAccountEquals;

claimStaking1.mint.equals(claimStaking2.mint) &&
claimStaking1.owner.equals(claimStaking2.owner) &&
claimStaking1.totalRewardsPaid < claimStaking2.totalRewardsPaid);
claimStaking1.owner.equals(claimStaking2.owner));
}

@@ -61,13 +59,20 @@ exports.claimStakingAccountEqualsAfterHarvest = claimStakingAccountEqualsAfterHarvest;

ClaimStaking.ACCOUNT_NAME = 'claimStaking';
ClaimStaking.MIN_DATA_SIZE = 8 + // discriminator
32 + // owner
32 + // mint
8 + // last harvest timestamp
8 + // Number of stakes in escrow
8 + // Fuel to pay at harvest
8 + // Food to pay at harvest
8 + // Arms to pay at harvest
8 + // Toolkits to pay at harvest
ClaimStaking.MIN_DATA_SIZE = 8 + //discriminator
1 + //Version
1 + // Faction ID
32 + // owner pubkey
32 + // Mint
8 + // Timestamp
8 + // Claim Stake quantity
8 + // Fuel to pay
8 + // Food to pay
8 + // Arms to pay
8 + // Toolkit to pay
8 + // Total fuel paid
8 + // Total food paid
8 + // Total arms paid
8 + // Total toolkit paid
8 + // Staked at timestamp
8; // Total rewards paid
8 + // Total time paid
1; // Bump
ClaimStaking = ClaimStaking_1 = __decorate([

@@ -74,0 +79,0 @@ (0, data_source_1.staticImplements)(),

import { ClaimStake as ClaimStakeIDL } from './idl/claim_stake';
import { AnchorTypes, ExtractArrayType, ListenProgram, ProgramMethods } from '@staratlas/data-source';
import { Coder } from '@project-serum/anchor';
import { Coder, Provider } from '@project-serum/anchor';
import { ClaimStakeVars } from './claimStakeVars';
import { ClaimStaking } from './claimStaking';
import { GlobalVars } from './globalVars';
import { PublicKey } from '@solana/web3.js';
export type { ClaimStake as ClaimStakeIDL } from './idl/claim_stake';
export { IDL as CLAIM_STAKE_IDL } from './idl/claim_stake';
export type { ClaimStakeLogs as ClaimStakeLogsIDL } from './idl/claim_stake_logs';
export { IDL as CLAIM_STAKE_LOGS_IDL } from './idl/claim_stake_logs';
export declare type ClaimStakeAccountsArray = ExtractArrayType<ClaimStakeIDL['accounts']>['name'];

@@ -37,3 +36,4 @@ export declare type ClaimStakeIDLProgram = ProgramMethods<ClaimStakeIDL>;

constructor(program: ClaimStakeIDLProgram);
static buildProgram(programId: PublicKey, provider?: Provider, coder?: Coder): ClaimStakeIDLProgram;
}
//# sourceMappingURL=constants.d.ts.map
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClaimStakeProgram = exports.CLAIM_STAKE_LOGS_IDL = exports.CLAIM_STAKE_IDL = void 0;
exports.ClaimStakeProgram = exports.CLAIM_STAKE_IDL = void 0;
const claim_stake_1 = require("./idl/claim_stake");
const data_source_1 = require("@staratlas/data-source");
const anchor_1 = require("@project-serum/anchor");
const claimStakeVars_1 = require("./claimStakeVars");
const claimStaking_1 = require("./claimStaking");
const globalVars_1 = require("./globalVars");
var claim_stake_1 = require("./idl/claim_stake");
Object.defineProperty(exports, "CLAIM_STAKE_IDL", { enumerable: true, get: function () { return claim_stake_1.IDL; } });
var claim_stake_logs_1 = require("./idl/claim_stake_logs");
Object.defineProperty(exports, "CLAIM_STAKE_LOGS_IDL", { enumerable: true, get: function () { return claim_stake_logs_1.IDL; } });
class ClaimStakeProgram extends data_source_1.ListenProgram {
var claim_stake_2 = require("./idl/claim_stake");
Object.defineProperty(exports, "CLAIM_STAKE_IDL", { enumerable: true, get: function () { return claim_stake_2.IDL; } });
let ClaimStakeProgram = class ClaimStakeProgram extends data_source_1.ListenProgram {
constructor(program) {

@@ -20,4 +29,11 @@ super(program, {

}
}
static buildProgram(programId, provider, coder) {
return new anchor_1.Program(claim_stake_1.IDL, programId, provider, coder);
}
};
ClaimStakeProgram = __decorate([
(0, data_source_1.staticImplements)(),
__metadata("design:paramtypes", [Object])
], ClaimStakeProgram);
exports.ClaimStakeProgram = ClaimStakeProgram;
//# sourceMappingURL=constants.js.map

@@ -568,3 +568,9 @@ export declare type ClaimStake = {

{
name: 'version';
docs: ['Account version'];
type: 'u8';
},
{
name: 'claimStakeMint';
docs: ['Mint Pubkey'];
type: 'publicKey';

@@ -574,2 +580,5 @@ },

name: 'fuelRewardRatePerSecond';
docs: [
'Amount of fuel emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision'
];
type: 'u64';

@@ -579,2 +588,5 @@ },

name: 'armsRewardRatePerSecond';
docs: [
'Amount of arms emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision'
];
type: 'u64';

@@ -584,2 +596,5 @@ },

name: 'foodRewardRatePerSecond';
docs: [
'Amount of food emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision'
];
type: 'u64';

@@ -589,2 +604,5 @@ },

name: 'toolkitRewardRatePerSecond';
docs: [
'Amount of toolkit emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied my [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision'
];
type: 'u64';

@@ -594,2 +612,5 @@ },

name: 'fuelMaxReserve';
docs: [
'Max reserve of fuel of claim stake of [claim_stake_mint] // stored in tokens'
];
type: 'u64';

@@ -599,2 +620,5 @@ },

name: 'foodMaxReserve';
docs: [
'Max reserve of food of claim stake of [claim_stake_mint] // stored in tokens'
];
type: 'u64';

@@ -604,2 +628,5 @@ },

name: 'armsMaxReserve';
docs: [
'Max reserve of arms of claim stake of [claim_stake_mint] // stored in tokens'
];
type: 'u64';

@@ -609,2 +636,5 @@ },

name: 'toolkitMaxReserve';
docs: [
'Max reserve of toolkits of claim stake of [claim_stake_mint] // stored in tokens'
];
type: 'u64';

@@ -625,4 +655,5 @@ },

{
name: 'owner';
type: 'publicKey';
name: 'version';
docs: ['Account version'];
type: 'u8';
},

@@ -634,2 +665,6 @@ {

{
name: 'owner';
type: 'publicKey';
},
{
name: 'mint';

@@ -640,2 +675,3 @@ type: 'publicKey';

name: 'lastHarvestTimestamp';
docs: ['Timestamp of last harvest ix call'];
type: 'i64';

@@ -645,2 +681,3 @@ },

name: 'claimStakesInEscrow';
docs: ['Amount deposited - to be returned on withdraw'];
type: 'u64';

@@ -650,2 +687,5 @@ },

name: 'fuelToPay';
docs: [
'Fuel reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])'
];
type: 'u64';

@@ -655,2 +695,5 @@ },

name: 'foodToPay';
docs: [
'Food reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])'
];
type: 'u64';

@@ -660,2 +703,5 @@ },

name: 'armsToPay';
docs: [
'Arms reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])'
];
type: 'u64';

@@ -665,11 +711,38 @@ },

name: 'toolkitToPay';
docs: [
'toolkit reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])'
];
type: 'u64';
},
{
name: 'totalFuelPaid';
docs: ['Total fuel paid as reward (stored as token count)'];
type: 'u64';
},
{
name: 'totalFoodPaid';
docs: ['Total food paid as reward (stored as token count)'];
type: 'u64';
},
{
name: 'totalArmsPaid';
docs: ['Total arms paid as reward (stored as token count)'];
type: 'u64';
},
{
name: 'totalToolkitPaid';
docs: ['Total toolkit paid as reward (stored as token count)'];
type: 'u64';
},
{
name: 'stakedAtTimestamp';
docs: [
'Timestamp in second when the claim stakes are staked (in seconds)'
];
type: 'i64';
},
{
name: 'totalRewardsPaid';
type: 'u64';
name: 'totalTimePaid';
docs: ['Total time paid in seconds'];
type: 'i64';
},

@@ -689,3 +762,9 @@ {

{
name: 'version';
docs: ['Account version'];
type: 'u8';
},
{
name: 'updateAuthorityMaster';
docs: ['Update authority key'];
type: 'publicKey';

@@ -695,2 +774,3 @@ },

name: 'fuelMint';
docs: ['Mint for Fuel R4'];
type: 'publicKey';

@@ -700,2 +780,3 @@ },

name: 'foodMint';
docs: ['Mint for Food R4'];
type: 'publicKey';

@@ -705,2 +786,3 @@ },

name: 'armsMint';
docs: ['Mint for Arms R4'];
type: 'publicKey';

@@ -710,2 +792,3 @@ },

name: 'toolkitMint';
docs: ['Mint for Toolkit R4'];
type: 'publicKey';

@@ -712,0 +795,0 @@ },

@@ -571,3 +571,9 @@ "use strict";

{
name: 'version',
docs: ['Account version'],
type: 'u8',
},
{
name: 'claimStakeMint',
docs: ['Mint Pubkey'],
type: 'publicKey',

@@ -577,2 +583,5 @@ },

name: 'fuelRewardRatePerSecond',
docs: [
'Amount of fuel emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision',
],
type: 'u64',

@@ -582,2 +591,5 @@ },

name: 'armsRewardRatePerSecond',
docs: [
'Amount of arms emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision',
],
type: 'u64',

@@ -587,2 +599,5 @@ },

name: 'foodRewardRatePerSecond',
docs: [
'Amount of food emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision',
],
type: 'u64',

@@ -592,2 +607,5 @@ },

name: 'toolkitRewardRatePerSecond',
docs: [
'Amount of toolkit emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied my [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision',
],
type: 'u64',

@@ -597,2 +615,5 @@ },

name: 'fuelMaxReserve',
docs: [
'Max reserve of fuel of claim stake of [claim_stake_mint] // stored in tokens',
],
type: 'u64',

@@ -602,2 +623,5 @@ },

name: 'foodMaxReserve',
docs: [
'Max reserve of food of claim stake of [claim_stake_mint] // stored in tokens',
],
type: 'u64',

@@ -607,2 +631,5 @@ },

name: 'armsMaxReserve',
docs: [
'Max reserve of arms of claim stake of [claim_stake_mint] // stored in tokens',
],
type: 'u64',

@@ -612,2 +639,5 @@ },

name: 'toolkitMaxReserve',
docs: [
'Max reserve of toolkits of claim stake of [claim_stake_mint] // stored in tokens',
],
type: 'u64',

@@ -628,4 +658,5 @@ },

{
name: 'owner',
type: 'publicKey',
name: 'version',
docs: ['Account version'],
type: 'u8',
},

@@ -637,2 +668,6 @@ {

{
name: 'owner',
type: 'publicKey',
},
{
name: 'mint',

@@ -643,2 +678,3 @@ type: 'publicKey',

name: 'lastHarvestTimestamp',
docs: ['Timestamp of last harvest ix call'],
type: 'i64',

@@ -648,2 +684,3 @@ },

name: 'claimStakesInEscrow',
docs: ['Amount deposited - to be returned on withdraw'],
type: 'u64',

@@ -653,2 +690,5 @@ },

name: 'fuelToPay',
docs: [
'Fuel reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])',
],
type: 'u64',

@@ -658,2 +698,5 @@ },

name: 'foodToPay',
docs: [
'Food reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])',
],
type: 'u64',

@@ -663,2 +706,5 @@ },

name: 'armsToPay',
docs: [
'Arms reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])',
],
type: 'u64',

@@ -668,11 +714,38 @@ },

name: 'toolkitToPay',
docs: [
'toolkit reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])',
],
type: 'u64',
},
{
name: 'totalFuelPaid',
docs: ['Total fuel paid as reward (stored as token count)'],
type: 'u64',
},
{
name: 'totalFoodPaid',
docs: ['Total food paid as reward (stored as token count)'],
type: 'u64',
},
{
name: 'totalArmsPaid',
docs: ['Total arms paid as reward (stored as token count)'],
type: 'u64',
},
{
name: 'totalToolkitPaid',
docs: ['Total toolkit paid as reward (stored as token count)'],
type: 'u64',
},
{
name: 'stakedAtTimestamp',
docs: [
'Timestamp in second when the claim stakes are staked (in seconds)',
],
type: 'i64',
},
{
name: 'totalRewardsPaid',
type: 'u64',
name: 'totalTimePaid',
docs: ['Total time paid in seconds'],
type: 'i64',
},

@@ -692,3 +765,9 @@ {

{
name: 'version',
docs: ['Account version'],
type: 'u8',
},
{
name: 'updateAuthorityMaster',
docs: ['Update authority key'],
type: 'publicKey',

@@ -698,2 +777,3 @@ },

name: 'fuelMint',
docs: ['Mint for Fuel R4'],
type: 'publicKey',

@@ -703,2 +783,3 @@ },

name: 'foodMint',
docs: ['Mint for Food R4'],
type: 'publicKey',

@@ -708,2 +789,3 @@ },

name: 'armsMint',
docs: ['Mint for Arms R4'],
type: 'publicKey',

@@ -713,2 +795,3 @@ },

name: 'toolkitMint',
docs: ['Mint for Toolkit R4'],
type: 'publicKey',

@@ -715,0 +798,0 @@ },

import { ClaimStakeIDLProgram } from '../constants';
import { InstructionReturn } from '@staratlas/data-source';
import { PublicKey } from '@solana/web3.js';
export declare function processHarvest(program: ClaimStakeIDLProgram, claimStakingAccount: PublicKey, claimStakeVarsAccount: PublicKey, fuelTreasuryTokenAccount: PublicKey, armsTreasuryTokenAccount: PublicKey, foodTreasuryTokenAccount: PublicKey, toolkitTreasuryTokenAccount: PublicKey, playerFuelTokenAccount: PublicKey, playerArmsTokenAccount: PublicKey, playerFoodTokenAccount: PublicKey, playerToolkitTokenAccount: PublicKey, treasuryAuthorityAccount: PublicKey, claimStakeMint: PublicKey, treasuryBump: number, treasuryAuthBump: number): InstructionReturn;
export declare function processHarvest(program: ClaimStakeIDLProgram, claimStakingAccount: PublicKey, claimStakeVarsAccount: PublicKey, fuelTreasuryTokenAccount: PublicKey, armsTreasuryTokenAccount: PublicKey, foodTreasuryTokenAccount: PublicKey, toolkitTreasuryTokenAccount: PublicKey, playerFuelTokenAccount: PublicKey, playerArmsTokenAccount: PublicKey, playerFoodTokenAccount: PublicKey, playerToolkitTokenAccount: PublicKey, treasuryAuthorityAccount: PublicKey, claimStakeMint: PublicKey): InstructionReturn;
//# sourceMappingURL=harvest.d.ts.map

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

const spl_token_1 = require("@solana/spl-token");
function processHarvest(program, claimStakingAccount, claimStakeVarsAccount, fuelTreasuryTokenAccount, armsTreasuryTokenAccount, foodTreasuryTokenAccount, toolkitTreasuryTokenAccount, playerFuelTokenAccount, playerArmsTokenAccount, playerFoodTokenAccount, playerToolkitTokenAccount, treasuryAuthorityAccount, claimStakeMint, treasuryBump, treasuryAuthBump) {
function processHarvest(program, claimStakingAccount, claimStakeVarsAccount, fuelTreasuryTokenAccount, armsTreasuryTokenAccount, foodTreasuryTokenAccount, toolkitTreasuryTokenAccount, playerFuelTokenAccount, playerArmsTokenAccount, playerFoodTokenAccount, playerToolkitTokenAccount, treasuryAuthorityAccount, claimStakeMint) {
return (funder) => __awaiter(this, void 0, void 0, function* () {

@@ -17,0 +17,0 @@ return ({

@@ -0,5 +1,7 @@

/// <reference types="bn.js" />
import { ClaimStakeIDLProgram } from '../constants';
import { InstructionReturn } from '@staratlas/data-source';
import { PublicKey } from '@solana/web3.js';
export declare function processInitialDeposit(program: ClaimStakeIDLProgram, claimStakingAccount: PublicKey, claimStakeVarsAccount: PublicKey, playerFactionAccount: PublicKey, escrowAuthority: PublicKey, sourceTokenAccount: PublicKey, escrowTokenAccount: PublicKey, claimStakeMint: PublicKey, escrowAuthBump: number, escrowBump: number): InstructionReturn;
import { BN } from '@project-serum/anchor';
export declare function processInitialDeposit(program: ClaimStakeIDLProgram, claimStakingAccount: PublicKey, claimStakeVarsAccount: PublicKey, playerFactionAccount: PublicKey, escrowAuthority: PublicKey, sourceTokenAccount: PublicKey, escrowTokenAccount: PublicKey, claimStakeMint: PublicKey, amount: BN): InstructionReturn;
//# sourceMappingURL=initialDeposit.d.ts.map

@@ -18,7 +18,7 @@ "use strict";

// playerAccount: AsyncSigner,
claimStakingAccount, claimStakeVarsAccount, playerFactionAccount, escrowAuthority, sourceTokenAccount, escrowTokenAccount, claimStakeMint, escrowAuthBump, escrowBump) {
claimStakingAccount, claimStakeVarsAccount, playerFactionAccount, escrowAuthority, sourceTokenAccount, escrowTokenAccount, claimStakeMint, amount) {
return (funder) => __awaiter(this, void 0, void 0, function* () {
return ({
instruction: yield program.methods
.processInitialDeposit(new anchor_1.BN(2))
.processInitialDeposit(amount)
.accountsStrict({

@@ -25,0 +25,0 @@ funder: funder.publicKey(),

@@ -0,5 +1,7 @@

/// <reference types="bn.js" />
import { ClaimStakeIDLProgram } from '../constants';
import { InstructionReturn } from '@staratlas/data-source';
import { PublicKey } from '@solana/web3.js';
export declare function processPartialDeposit(program: ClaimStakeIDLProgram, claimStakingAccount: PublicKey, claimStakeVarsAccount: PublicKey, escrowAuthority: PublicKey, claimStakeMint: PublicKey, fromTokenAccount: PublicKey, claimStakeEscrow: PublicKey, escrowAuthBump: number, escrowBump: number): InstructionReturn;
import { BN } from '@project-serum/anchor';
export declare function processPartialDeposit(program: ClaimStakeIDLProgram, claimStakingAccount: PublicKey, claimStakeVarsAccount: PublicKey, escrowAuthority: PublicKey, claimStakeMint: PublicKey, fromTokenAccount: PublicKey, claimStakeEscrow: PublicKey, amount: BN): InstructionReturn;
//# sourceMappingURL=partialDeposit.d.ts.map

@@ -15,8 +15,7 @@ "use strict";

const spl_token_1 = require("@solana/spl-token");
const anchor_1 = require("@project-serum/anchor");
function processPartialDeposit(program, claimStakingAccount, claimStakeVarsAccount, escrowAuthority, claimStakeMint, fromTokenAccount, claimStakeEscrow, escrowAuthBump, escrowBump) {
function processPartialDeposit(program, claimStakingAccount, claimStakeVarsAccount, escrowAuthority, claimStakeMint, fromTokenAccount, claimStakeEscrow, amount) {
return (funder) => __awaiter(this, void 0, void 0, function* () {
return ({
instruction: yield program.methods
.processPartialDeposit(new anchor_1.BN(5))
.processPartialDeposit(amount)
.accountsStrict({

@@ -23,0 +22,0 @@ playerAccount: funder.publicKey(),

import { ClaimStakeIDLProgram } from '../constants';
import { InstructionReturn } from '@staratlas/data-source';
import { PublicKey } from '@solana/web3.js';
export declare function processWithdrawClaimStakes(program: ClaimStakeIDLProgram, claimStakingAccount: PublicKey, globalVarsAccount: PublicKey, claimStakeVarsAccount: PublicKey, playerTokenAccount: PublicKey, playerFuelTokenAccount: PublicKey, playerArmsTokenAccount: PublicKey, playerFoodTokenAccount: PublicKey, playerToolkitTokenAccount: PublicKey, claimStakeEscrowAccount: PublicKey, fuelTreasuryTokenAccount: PublicKey, armsTreasuryTokenAccount: PublicKey, foodTreasuryTokenAccount: PublicKey, toolkitTreasuryTokenAccount: PublicKey, treasuryAuthorityAccount: PublicKey, escrowAuthority: PublicKey, claimStakeMint: PublicKey, escrowAuthBump: number, escrowBump: number, treasuryAuthBump: number, treasuryBump: number): InstructionReturn;
export declare function processWithdrawClaimStakes(program: ClaimStakeIDLProgram, claimStakingAccount: PublicKey, globalVarsAccount: PublicKey, claimStakeVarsAccount: PublicKey, playerTokenAccount: PublicKey, playerFuelTokenAccount: PublicKey, playerArmsTokenAccount: PublicKey, playerFoodTokenAccount: PublicKey, playerToolkitTokenAccount: PublicKey, claimStakeEscrowAccount: PublicKey, fuelTreasuryTokenAccount: PublicKey, armsTreasuryTokenAccount: PublicKey, foodTreasuryTokenAccount: PublicKey, toolkitTreasuryTokenAccount: PublicKey, treasuryAuthorityAccount: PublicKey, escrowAuthority: PublicKey, claimStakeMint: PublicKey): InstructionReturn;
//# sourceMappingURL=withdrawClaimStake.d.ts.map

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

const spl_token_1 = require("@solana/spl-token");
function processWithdrawClaimStakes(program, claimStakingAccount, globalVarsAccount, claimStakeVarsAccount, playerTokenAccount, playerFuelTokenAccount, playerArmsTokenAccount, playerFoodTokenAccount, playerToolkitTokenAccount, claimStakeEscrowAccount, fuelTreasuryTokenAccount, armsTreasuryTokenAccount, foodTreasuryTokenAccount, toolkitTreasuryTokenAccount, treasuryAuthorityAccount, escrowAuthority, claimStakeMint, escrowAuthBump, escrowBump, treasuryAuthBump, treasuryBump) {
function processWithdrawClaimStakes(program, claimStakingAccount, globalVarsAccount, claimStakeVarsAccount, playerTokenAccount, playerFuelTokenAccount, playerArmsTokenAccount, playerFoodTokenAccount, playerToolkitTokenAccount, claimStakeEscrowAccount, fuelTreasuryTokenAccount, armsTreasuryTokenAccount, foodTreasuryTokenAccount, toolkitTreasuryTokenAccount, treasuryAuthorityAccount, escrowAuthority, claimStakeMint) {
return (funder) => __awaiter(this, void 0, void 0, function* () {

@@ -18,0 +18,0 @@ return ({

{
"name": "@staratlas/claim-stake",
"version": "0.2.8",
"version": "0.2.10",
"description": "> TODO: description",

@@ -11,7 +11,7 @@ "author": "Brett Etter <brett.etter@staratlas.com>",

"build": "rm -rf dist && tsc",
"test": "jest"
"test": "jest --testTimeout=60000 --detectOpenHandles"
},
"repository": {
"type": "git",
"url": "git+https://github.com/staratlasmeta/shadow-factory.git"
"url": "git+https://github.com/staratlasmeta/star-atlas-programs.git"
},

@@ -22,5 +22,6 @@ "bugs": {

"dependencies": {
"@staratlas/data-source": "^0.3.8"
"@staratlas/data-source": "^0.3.10"
},
"devDependencies": {
"@staratlas/faction-enlistment": "^0.2.10",
"@types/jest": "^29.2.3",

@@ -32,4 +33,3 @@ "@types/jest-expect-message": "^1.1.0",

"ts-node": "^10.9.1"
},
"gitHead": "3b02d5c46c35213403d3446ebfd796c9b926cb88"
}
}

@@ -12,2 +12,3 @@ import {

export const REWARD_MULTIPLIER = 1000000;
export function claimStakeVarsEquals(

@@ -55,11 +56,13 @@ claimStakeVarsAccount1: ClaimStakeVarsAccount,

8 + // discriminator
1 + // Version
32 + // Claim Stake Mint
8 + // Fuel Reward Rate per second
8 + // Arms reward rate per second
8 + // Food reward rate per second
8 + // Toolkit reward rate per second
8 + // Fuel reward rate
8 + // Arms reward rate
8 + // Food reward rate
8 + // Toolkit reward rate
8 + // Fuel max reserve
8 + // Food max reserve
8 + // Arms max reserve
8; // Toolkit max reserve
8 + // Toolkit max reserve
1; // Bump

@@ -66,0 +69,0 @@ constructor(private _data: ClaimStakeVarsAccount, private _key: PublicKey) {}

import {
Account,
AccountStatic,
arrayDeepEquals,
decodeAccount,

@@ -19,10 +18,9 @@ DecodedAccountData,

claimStaking1.claimStakesInEscrow.eq(claimStaking2.claimStakesInEscrow) &&
claimStaking1.armsToPay.eq(claimStaking2.armsToPay) &&
claimStaking1.factionId === claimStaking2.factionId &&
claimStaking1.foodToPay.eq(claimStaking2.foodToPay) &&
claimStaking1.fuelToPay.eq(claimStaking2.fuelToPay) &&
claimStaking1.mint.equals(claimStaking2.mint) &&
claimStaking1.owner.equals(claimStaking2.owner) &&
claimStaking1.toolkitToPay.eq(claimStaking2.toolkitToPay) &&
claimStaking1.totalRewardsPaid.eq(claimStaking2.totalRewardsPaid)
// claimStaking1.armsToPay.eq(claimStaking2.armsToPay) &&
// claimStaking1.factionId === claimStaking2.factionId &&
// claimStaking1.foodToPay.eq(claimStaking2.foodToPay) &&
// claimStaking1.fuelToPay.eq(claimStaking2.fuelToPay) &&
// claimStaking1.mint.equals(claimStaking2.mint) &&
// claimStaking1.owner.equals(claimStaking2.owner) &&
claimStaking1.toolkitToPay.eq(claimStaking2.toolkitToPay)
);

@@ -39,4 +37,3 @@ }

claimStaking1.mint.equals(claimStaking2.mint) &&
claimStaking1.owner.equals(claimStaking2.owner) &&
claimStaking1.totalRewardsPaid < claimStaking2.totalRewardsPaid
claimStaking1.owner.equals(claimStaking2.owner)
);

@@ -51,13 +48,20 @@ }

static readonly MIN_DATA_SIZE =
8 + // discriminator
32 + // owner
32 + // mint
8 + // last harvest timestamp
8 + // Number of stakes in escrow
8 + // Fuel to pay at harvest
8 + // Food to pay at harvest
8 + // Arms to pay at harvest
8 + // Toolkits to pay at harvest
8 + //discriminator
1 + //Version
1 + // Faction ID
32 + // owner pubkey
32 + // Mint
8 + // Timestamp
8 + // Claim Stake quantity
8 + // Fuel to pay
8 + // Food to pay
8 + // Arms to pay
8 + // Toolkit to pay
8 + // Total fuel paid
8 + // Total food paid
8 + // Total arms paid
8 + // Total toolkit paid
8 + // Staked at timestamp
8; // Total rewards paid
8 + // Total time paid
1; // Bump

@@ -64,0 +68,0 @@ constructor(private _data: ClaimStakingAccount, private _key: PublicKey) {}

@@ -1,17 +0,21 @@

import { ClaimStake as ClaimStakeIDL } from './idl/claim_stake';
import {
ClaimStake as ClaimStakeIDL,
IDL as CLAIM_STAKE_IDL,
} from './idl/claim_stake';
import {
AnchorTypes,
ExtractArrayType,
ListenProgram,
ListenProgramStatic,
ProgramMethods,
staticImplements,
} from '@staratlas/data-source';
import { Coder } from '@project-serum/anchor';
import { Coder, Program, Provider } from '@project-serum/anchor';
import { ClaimStakeVars } from './claimStakeVars';
import { ClaimStaking } from './claimStaking';
import { GlobalVars } from './globalVars';
import { PublicKey } from '@solana/web3.js';
export type { ClaimStake as ClaimStakeIDL } from './idl/claim_stake';
export { IDL as CLAIM_STAKE_IDL } from './idl/claim_stake';
export type { ClaimStakeLogs as ClaimStakeLogsIDL } from './idl/claim_stake_logs';
export { IDL as CLAIM_STAKE_LOGS_IDL } from './idl/claim_stake_logs';

@@ -57,2 +61,5 @@ export type ClaimStakeAccountsArray = ExtractArrayType<

@staticImplements<
ListenProgramStatic<ClaimStakeProgram, ClaimStakeAccounts, ClaimStakeIDL>
>()
export class ClaimStakeProgram extends ListenProgram<

@@ -69,2 +76,10 @@ ClaimStakeAccounts,

}
static buildProgram(
programId: PublicKey,
provider?: Provider,
coder?: Coder
): ClaimStakeIDLProgram {
return new Program(CLAIM_STAKE_IDL, programId, provider, coder);
}
}

@@ -568,3 +568,9 @@ export type ClaimStake = {

{
name: 'version';
docs: ['Account version'];
type: 'u8';
},
{
name: 'claimStakeMint';
docs: ['Mint Pubkey'];
type: 'publicKey';

@@ -574,2 +580,5 @@ },

name: 'fuelRewardRatePerSecond';
docs: [
'Amount of fuel emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision'
];
type: 'u64';

@@ -579,2 +588,5 @@ },

name: 'armsRewardRatePerSecond';
docs: [
'Amount of arms emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision'
];
type: 'u64';

@@ -584,2 +596,5 @@ },

name: 'foodRewardRatePerSecond';
docs: [
'Amount of food emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision'
];
type: 'u64';

@@ -589,2 +604,5 @@ },

name: 'toolkitRewardRatePerSecond';
docs: [
'Amount of toolkit emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied my [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision'
];
type: 'u64';

@@ -594,2 +612,5 @@ },

name: 'fuelMaxReserve';
docs: [
'Max reserve of fuel of claim stake of [claim_stake_mint] // stored in tokens'
];
type: 'u64';

@@ -599,2 +620,5 @@ },

name: 'foodMaxReserve';
docs: [
'Max reserve of food of claim stake of [claim_stake_mint] // stored in tokens'
];
type: 'u64';

@@ -604,2 +628,5 @@ },

name: 'armsMaxReserve';
docs: [
'Max reserve of arms of claim stake of [claim_stake_mint] // stored in tokens'
];
type: 'u64';

@@ -609,2 +636,5 @@ },

name: 'toolkitMaxReserve';
docs: [
'Max reserve of toolkits of claim stake of [claim_stake_mint] // stored in tokens'
];
type: 'u64';

@@ -625,4 +655,5 @@ },

{
name: 'owner';
type: 'publicKey';
name: 'version';
docs: ['Account version'];
type: 'u8';
},

@@ -634,2 +665,6 @@ {

{
name: 'owner';
type: 'publicKey';
},
{
name: 'mint';

@@ -640,2 +675,3 @@ type: 'publicKey';

name: 'lastHarvestTimestamp';
docs: ['Timestamp of last harvest ix call'];
type: 'i64';

@@ -645,2 +681,3 @@ },

name: 'claimStakesInEscrow';
docs: ['Amount deposited - to be returned on withdraw'];
type: 'u64';

@@ -650,2 +687,5 @@ },

name: 'fuelToPay';
docs: [
'Fuel reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])'
];
type: 'u64';

@@ -655,2 +695,5 @@ },

name: 'foodToPay';
docs: [
'Food reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])'
];
type: 'u64';

@@ -660,2 +703,5 @@ },

name: 'armsToPay';
docs: [
'Arms reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])'
];
type: 'u64';

@@ -665,11 +711,38 @@ },

name: 'toolkitToPay';
docs: [
'toolkit reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])'
];
type: 'u64';
},
{
name: 'totalFuelPaid';
docs: ['Total fuel paid as reward (stored as token count)'];
type: 'u64';
},
{
name: 'totalFoodPaid';
docs: ['Total food paid as reward (stored as token count)'];
type: 'u64';
},
{
name: 'totalArmsPaid';
docs: ['Total arms paid as reward (stored as token count)'];
type: 'u64';
},
{
name: 'totalToolkitPaid';
docs: ['Total toolkit paid as reward (stored as token count)'];
type: 'u64';
},
{
name: 'stakedAtTimestamp';
docs: [
'Timestamp in second when the claim stakes are staked (in seconds)'
];
type: 'i64';
},
{
name: 'totalRewardsPaid';
type: 'u64';
name: 'totalTimePaid';
docs: ['Total time paid in seconds'];
type: 'i64';
},

@@ -689,3 +762,9 @@ {

{
name: 'version';
docs: ['Account version'];
type: 'u8';
},
{
name: 'updateAuthorityMaster';
docs: ['Update authority key'];
type: 'publicKey';

@@ -695,2 +774,3 @@ },

name: 'fuelMint';
docs: ['Mint for Fuel R4'];
type: 'publicKey';

@@ -700,2 +780,3 @@ },

name: 'foodMint';
docs: ['Mint for Food R4'];
type: 'publicKey';

@@ -705,2 +786,3 @@ },

name: 'armsMint';
docs: ['Mint for Arms R4'];
type: 'publicKey';

@@ -710,2 +792,3 @@ },

name: 'toolkitMint';
docs: ['Mint for Toolkit R4'];
type: 'publicKey';

@@ -1426,3 +1509,9 @@ },

{
name: 'version',
docs: ['Account version'],
type: 'u8',
},
{
name: 'claimStakeMint',
docs: ['Mint Pubkey'],
type: 'publicKey',

@@ -1432,2 +1521,5 @@ },

name: 'fuelRewardRatePerSecond',
docs: [
'Amount of fuel emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision',
],
type: 'u64',

@@ -1437,2 +1529,5 @@ },

name: 'armsRewardRatePerSecond',
docs: [
'Amount of arms emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision',
],
type: 'u64',

@@ -1442,2 +1537,5 @@ },

name: 'foodRewardRatePerSecond',
docs: [
'Amount of food emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied by [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision',
],
type: 'u64',

@@ -1447,2 +1545,5 @@ },

name: 'toolkitRewardRatePerSecond',
docs: [
'Amount of toolkit emitted as reward by claim stake of [claim_stake_mint] per second // Multiplied my [crate::util::REWARD_RATE_MULTIPLIER] to maintain precision',
],
type: 'u64',

@@ -1452,2 +1553,5 @@ },

name: 'fuelMaxReserve',
docs: [
'Max reserve of fuel of claim stake of [claim_stake_mint] // stored in tokens',
],
type: 'u64',

@@ -1457,2 +1561,5 @@ },

name: 'foodMaxReserve',
docs: [
'Max reserve of food of claim stake of [claim_stake_mint] // stored in tokens',
],
type: 'u64',

@@ -1462,2 +1569,5 @@ },

name: 'armsMaxReserve',
docs: [
'Max reserve of arms of claim stake of [claim_stake_mint] // stored in tokens',
],
type: 'u64',

@@ -1467,2 +1577,5 @@ },

name: 'toolkitMaxReserve',
docs: [
'Max reserve of toolkits of claim stake of [claim_stake_mint] // stored in tokens',
],
type: 'u64',

@@ -1483,4 +1596,5 @@ },

{
name: 'owner',
type: 'publicKey',
name: 'version',
docs: ['Account version'],
type: 'u8',
},

@@ -1492,2 +1606,6 @@ {

{
name: 'owner',
type: 'publicKey',
},
{
name: 'mint',

@@ -1498,2 +1616,3 @@ type: 'publicKey',

name: 'lastHarvestTimestamp',
docs: ['Timestamp of last harvest ix call'],
type: 'i64',

@@ -1503,2 +1622,3 @@ },

name: 'claimStakesInEscrow',
docs: ['Amount deposited - to be returned on withdraw'],
type: 'u64',

@@ -1508,2 +1628,5 @@ },

name: 'fuelToPay',
docs: [
'Fuel reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])',
],
type: 'u64',

@@ -1513,2 +1636,5 @@ },

name: 'foodToPay',
docs: [
'Food reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])',
],
type: 'u64',

@@ -1518,2 +1644,5 @@ },

name: 'armsToPay',
docs: [
'Arms reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])',
],
type: 'u64',

@@ -1523,11 +1652,38 @@ },

name: 'toolkitToPay',
docs: [
'toolkit reward to pay on harvest/ withdraw // stored as (token count * [`crate::util::REWARD_RATE_MULTIPLIER`])',
],
type: 'u64',
},
{
name: 'totalFuelPaid',
docs: ['Total fuel paid as reward (stored as token count)'],
type: 'u64',
},
{
name: 'totalFoodPaid',
docs: ['Total food paid as reward (stored as token count)'],
type: 'u64',
},
{
name: 'totalArmsPaid',
docs: ['Total arms paid as reward (stored as token count)'],
type: 'u64',
},
{
name: 'totalToolkitPaid',
docs: ['Total toolkit paid as reward (stored as token count)'],
type: 'u64',
},
{
name: 'stakedAtTimestamp',
docs: [
'Timestamp in second when the claim stakes are staked (in seconds)',
],
type: 'i64',
},
{
name: 'totalRewardsPaid',
type: 'u64',
name: 'totalTimePaid',
docs: ['Total time paid in seconds'],
type: 'i64',
},

@@ -1547,3 +1703,9 @@ {

{
name: 'version',
docs: ['Account version'],
type: 'u8',
},
{
name: 'updateAuthorityMaster',
docs: ['Update authority key'],
type: 'publicKey',

@@ -1553,2 +1715,3 @@ },

name: 'fuelMint',
docs: ['Mint for Fuel R4'],
type: 'publicKey',

@@ -1558,2 +1721,3 @@ },

name: 'foodMint',
docs: ['Mint for Food R4'],
type: 'publicKey',

@@ -1563,2 +1727,3 @@ },

name: 'armsMint',
docs: ['Mint for Arms R4'],
type: 'publicKey',

@@ -1568,2 +1733,3 @@ },

name: 'toolkitMint',
docs: ['Mint for Toolkit R4'],
type: 'publicKey',

@@ -1570,0 +1736,0 @@ },

@@ -1,10 +0,6 @@

import { ClaimStakeIDLProgram, ClaimStakingAccount } from '../constants';
import {
AsyncSigner,
FixedSizeArray,
InstructionReturn,
} from '@staratlas/data-source';
import { PublicKey, SystemProgram } from '@solana/web3.js';
import { ClaimStakeIDLProgram } from '../constants';
import { AsyncSigner, InstructionReturn } from '@staratlas/data-source';
import { PublicKey } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { BN } from '@project-serum/anchor';
import { Wallet } from '@project-serum/anchor';

@@ -24,5 +20,3 @@ export function processHarvest(

treasuryAuthorityAccount: PublicKey,
claimStakeMint: PublicKey,
treasuryBump: number,
treasuryAuthBump: number
claimStakeMint: PublicKey
): InstructionReturn {

@@ -29,0 +23,0 @@ return async (funder) => ({

@@ -1,7 +0,3 @@

import { ClaimStakeIDLProgram, InitialDeposit } from '../constants';
import {
AsyncSigner,
FixedSizeArray,
InstructionReturn,
} from '@staratlas/data-source';
import { ClaimStakeIDLProgram } from '../constants';
import { InstructionReturn } from '@staratlas/data-source';
import { PublicKey, SystemProgram } from '@solana/web3.js';

@@ -21,8 +17,7 @@ import { TOKEN_PROGRAM_ID } from '@solana/spl-token';

claimStakeMint: PublicKey,
escrowAuthBump: number,
escrowBump: number
amount: BN
): InstructionReturn {
return async (funder) => ({
instruction: await program.methods
.processInitialDeposit(new BN(2))
.processInitialDeposit(amount)
.accountsStrict({

@@ -29,0 +24,0 @@ funder: funder.publicKey(),

import { ClaimStakeIDLProgram } from '../constants';
import {
AsyncSigner,
FixedSizeArray,
InstructionReturn,
} from '@staratlas/data-source';
import { AsyncSigner, InstructionReturn } from '@staratlas/data-source';
import { PublicKey, SystemProgram } from '@solana/web3.js';
import { BN, web3 } from '@project-serum/anchor';
import { web3 } from '@project-serum/anchor';
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { findProgramAddressSync } from '@project-serum/anchor/dist/cjs/utils/pubkey';

@@ -12,0 +7,0 @@ export function processInitialize(

@@ -1,7 +0,3 @@

import { ClaimStakeIDLProgram, ClaimStakingAccount } from '../constants';
import {
AsyncSigner,
FixedSizeArray,
InstructionReturn,
} from '@staratlas/data-source';
import { ClaimStakeIDLProgram } from '../constants';
import { InstructionReturn } from '@staratlas/data-source';
import { PublicKey, SystemProgram } from '@solana/web3.js';

@@ -19,8 +15,7 @@ import { TOKEN_PROGRAM_ID } from '@solana/spl-token';

claimStakeEscrow: PublicKey,
escrowAuthBump: number,
escrowBump: number
amount: BN
): InstructionReturn {
return async (funder) => ({
instruction: await program.methods
.processPartialDeposit(new BN(5))
.processPartialDeposit(amount)
.accountsStrict({

@@ -27,0 +22,0 @@ playerAccount: funder.publicKey(),

@@ -6,10 +6,4 @@ import {

} from '../constants';
import {
AsyncSigner,
FixedSizeArray,
InstructionReturn,
} from '@staratlas/data-source';
import { AsyncSigner, InstructionReturn } from '@staratlas/data-source';
import { PublicKey, SystemProgram } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { BN } from '@project-serum/anchor';

@@ -16,0 +10,0 @@ export function processRegisterClaimStake(

@@ -1,11 +0,4 @@

import { ClaimStakeIDLProgram, InitialDeposit } from '../constants';
import {
AsyncSigner,
FixedSizeArray,
InstructionReturn,
} from '@staratlas/data-source';
import { PublicKey, SystemProgram } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { BN } from '@project-serum/anchor';
import { ClaimStakeVarsAccount } from '../constants';
import { ClaimStakeIDLProgram } from '../constants';
import { InstructionReturn } from '@staratlas/data-source';
import { PublicKey } from '@solana/web3.js';

@@ -12,0 +5,0 @@ export function processSettle(

@@ -1,10 +0,4 @@

import { ClaimStakeIDLProgram, InitialDeposit, NewValues } from '../constants';
import {
AsyncSigner,
FixedSizeArray,
InstructionReturn,
} from '@staratlas/data-source';
import { PublicKey, SystemProgram } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { BN } from '@project-serum/anchor';
import { ClaimStakeIDLProgram, NewValues } from '../constants';
import { AsyncSigner, InstructionReturn } from '@staratlas/data-source';
import { PublicKey } from '@solana/web3.js';

@@ -11,0 +5,0 @@ export function processUpdateRewardRates(

@@ -1,10 +0,5 @@

import { ClaimStakeIDLProgram, ClaimStakeVarsAccount } from '../constants';
import {
AsyncSigner,
FixedSizeArray,
InstructionReturn,
} from '@staratlas/data-source';
import { ClaimStakeIDLProgram } from '../constants';
import { InstructionReturn } from '@staratlas/data-source';
import { PublicKey, SystemProgram } from '@solana/web3.js';
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
import { BN } from '@project-serum/anchor';

@@ -28,7 +23,3 @@ export function processWithdrawClaimStakes(

escrowAuthority: PublicKey,
claimStakeMint: PublicKey,
escrowAuthBump: number,
escrowBump: number,
treasuryAuthBump: number,
treasuryBump: number
claimStakeMint: PublicKey
): InstructionReturn {

@@ -35,0 +26,0 @@ return async (funder) => ({

@@ -1,716 +0,725 @@

// import { BN, Program } from '@project-serum/anchor';
// import {
// processInitialize,
// processPartialDeposit,
// processInitialDeposit,
// processHarvest,
// processRegisterClaimStake,
// processSettle,
// processUpdateRewardRates,
// processWithdrawClaimStakes,
// GlobalVars,
// ClaimStakeIDLProgram,
// NewValues,
// RewardRateValues,
// MaxReserveValues,
// CLAIM_STAKE_IDL,
// findTreasuryAccounts,
// findClaimStakeEscrowAccount,
// findEscrowAuthorityAccount,
// findFactionAccount,
// globalVarsEquals,
// ClaimStakeVars,
// claimStakeVarsEquals,
// ClaimStaking,
// claimStakingAccountEquals,
// claimStakingAccountEqualsAfterHarvest,
// } from '../src';
// import { ENLIST_TO_FACTION_IDL } from '@staratlas/faction-enlistment';
// import { findProgramAddressSync } from '@project-serum/anchor/dist/cjs/utils/pubkey';
// import {
// createAssociatedTokenAccount,
// createTokenAccount,
// mintToTokenAccount,
// buildSendAndCheck,
// keypairToAsyncSigner,
// readFromRPCOrError,
// createMint,
// InstructionReturn,
// } from '@staratlas/data-source';
// import { processEnlistPlayer } from '@staratlas/faction-enlistment';
// import {
// TOKEN_PROGRAM_ID,
// getAssociatedTokenAddressSync,
// } from '@solana/spl-token';
// import {
// Connection,
// Keypair,
// LAMPORTS_PER_SOL,
// PublicKey,
// } from '@solana/web3.js';
//
// function sleep(ms: number) {
// return new Promise((resolve) => setTimeout(resolve, ms));
// }
import { BN, Program } from '@project-serum/anchor';
import {
processInitialize,
processPartialDeposit,
processInitialDeposit,
processHarvest,
processRegisterClaimStake,
processSettle,
processUpdateRewardRates,
processWithdrawClaimStakes,
GlobalVars,
ClaimStakeIDLProgram,
NewValues,
RewardRateValues,
MaxReserveValues,
CLAIM_STAKE_IDL,
findTreasuryAccounts,
findClaimStakeEscrowAccount,
findEscrowAuthorityAccount,
findFactionAccount,
globalVarsEquals,
ClaimStakeVars,
claimStakeVarsEquals,
ClaimStaking,
claimStakingAccountEquals,
claimStakingAccountEqualsAfterHarvest,
} from '../src';
import {
ENLIST_TO_FACTION_IDL,
PlayerFactionData,
} from '@staratlas/faction-enlistment';
import { findProgramAddressSync } from '@project-serum/anchor/dist/cjs/utils/pubkey';
import {
createAssociatedTokenAccount,
createTokenAccount,
mintToTokenAccount,
buildSendAndCheck,
keypairToAsyncSigner,
readFromRPCOrError,
createMint,
InstructionReturn,
readFromRPCNullable,
} from '@staratlas/data-source';
import { processEnlistPlayer } from '@staratlas/faction-enlistment';
import {
TOKEN_PROGRAM_ID,
getAssociatedTokenAddressSync,
} from '@solana/spl-token';
import {
Connection,
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
} from '@solana/web3.js';
// FIXME: Joy
function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
describe('claim stake tests', function () {
it('should succcedd', function () {
expect(true).toBeTruthy();
});
// const connection = new Connection('http://localhost:8899', 'confirmed');
// const program: ClaimStakeIDLProgram = new Program(
// CLAIM_STAKE_IDL,
// new PublicKey('21FciwD1gDdXotb4UxEUnFxQn26jg31JrqFuwWPufztW'),
// { connection }
// );
// const factionProgram = new Program(
// ENLIST_TO_FACTION_IDL,
// new PublicKey('FACTNmq2FhA2QNTnGM2aWJH3i7zT3cND5CgvjYTjyVYe'),
// { connection }
// );
// // Constants for Test
// // Mints
// const fuelMint = keypairToAsyncSigner(Keypair.generate());
// const armsMint = keypairToAsyncSigner(Keypair.generate());
// const foodMint = keypairToAsyncSigner(Keypair.generate());
// const toolkitMint = keypairToAsyncSigner(Keypair.generate());
// const claimStakeMint = keypairToAsyncSigner(Keypair.generate());
//
// // Required Accounts
// const userAccount = keypairToAsyncSigner(Keypair.generate());
// const authorityAccount = keypairToAsyncSigner(Keypair.generate());
// // Treasury Authority
// const [treasuryAuthority, treasuryAuthBump] = findProgramAddressSync(
// [Buffer.from('TREASURY_AUTHORITY')],
// program.programId
// );
// // Escrow Authority
// const [escrowAuthority, escrowAuthBump] = findEscrowAuthorityAccount(
// program.programId,
// userAccount.publicKey(),
// claimStakeMint.publicKey()
// );
// // CLaim Stake Escrow
// const [claimStakeEscrow, escrowBump] = findClaimStakeEscrowAccount(
// program.programId,
// userAccount.publicKey(),
// claimStakeMint.publicKey()
// );
// // Player faction Account
// const playerFactionAccount = findFactionAccount(
// factionProgram.programId,
// userAccount.publicKey()
// )[0];
//
// // Quanities
// const claimStakeQuantity = 5;
//
// // Claim Stake Max Reserves
// const fuelMaxReserve = 120;
// const armsMaxReserve = 120;
// const foodMaxReserve = 120;
// const toolkitMaxReserve = 4;
//
// // Claim Stake Account
// const claimStakingAccount = findProgramAddressSync(
// [
// Buffer.from('CLAIM_STAKING_INFO'),
// userAccount.publicKey().toBuffer(),
// claimStakeMint.publicKey().toBuffer(),
// ],
// program.programId
// )[0];
//
// const globalVarsAccount = findProgramAddressSync(
// [Buffer.from('GLOBALVARS')],
// program.programId
// )[0];
//
// const claimStakeVarsAccount = findProgramAddressSync(
// [Buffer.from('CLAIM_STAKE_VARS'), claimStakeMint.publicKey().toBuffer()],
// program.programId
// )[0];
//
// // Token Accounts
// let claimStakeTokenAccount;
// const playerTokenAccount = keypairToAsyncSigner(Keypair.generate());
// const playerAssociatedTokenAccount = getAssociatedTokenAddressSync(
// claimStakeMint.publicKey(),
// userAccount.publicKey(),
// false,
// TOKEN_PROGRAM_ID
// );
// const playerFuelTokenAccount = keypairToAsyncSigner(Keypair.generate());
// const playerArmsTokenAccount = keypairToAsyncSigner(Keypair.generate());
// const playerFoodTokenAccount = keypairToAsyncSigner(Keypair.generate());
// const playerToolkitTokenAccount = keypairToAsyncSigner(Keypair.generate());
//
// const {
// fuelTreasuryAccount,
// armsTreasuryAccount,
// foodTreasuryAccount,
// toolkitTreasuryAccount,
// treasuryBump,
// } = findTreasuryAccounts(program.programId);
//
// // Value Constants
// const rewardRate: RewardRateValues = {
// fuel: new BN(5),
// food: new BN(5),
// arms: new BN(5),
// toolkit: new BN(5),
// };
// const maxReserves: MaxReserveValues = {
// fuel: new BN(50),
// food: new BN(50),
// arms: new BN(50),
// toolkit: new BN(50),
// };
// const updatedRewardRates: NewValues = {
// fuel: new BN(2),
// food: new BN(2),
// arms: new BN(2),
// toolkit: new BN(2),
// };
//
// beforeAll(async () => {
// const airdrop = await connection.requestAirdrop(
// userAccount.publicKey(),
// LAMPORTS_PER_SOL * 10
// );
// await connection.confirmTransaction(airdrop);
//
// const airdrop2 = await connection.requestAirdrop(
// authorityAccount.publicKey(),
// LAMPORTS_PER_SOL
// );
// await connection.confirmTransaction(airdrop);
//
// const airdrop3 = await connection.requestAirdrop(
// escrowAuthority,
// LAMPORTS_PER_SOL * 5
// );
//
// // Create Mints
// const IXs: InstructionReturn[] = [];
// // Fuel Mint
// IXs.push(
// createMint(
// fuelMint,
// 0,
// fuelMint.publicKey(),
// null,
// connection,
// 'confirmed'
// )
// );
// // Arms Mint
// IXs.push(
// createMint(
// armsMint,
// 0,
// armsMint.publicKey(),
// null,
// connection,
// 'confirmed'
// )
// );
// // Food Mint
// IXs.push(
// createMint(
// foodMint,
// 0,
// foodMint.publicKey(),
// null,
// connection,
// 'confirmed'
// )
// );
// // ToolkitMint
// IXs.push(
// createMint(
// toolkitMint,
// 0,
// toolkitMint.publicKey(),
// null,
// connection,
// 'confirmed'
// )
// );
// // Claim Stake Mint
// IXs.push(
// createMint(
// claimStakeMint,
// 0,
// claimStakeMint.publicKey(),
// null,
// connection,
// 'confirmed'
// )
// );
//
// await Promise.all(
// IXs.map((IXs) => buildSendAndCheck(IXs, userAccount, connection))
// );
// const IX2: InstructionReturn[] = [];
// IX2.push(
// createTokenAccount(
// playerTokenAccount,
// userAccount.publicKey(),
// claimStakeMint.publicKey(),
// connection
// )
// );
// IX2.push(
// createAssociatedTokenAccount(
// userAccount,
// claimStakeMint.publicKey(),
// userAccount.publicKey(),
// false,
// TOKEN_PROGRAM_ID
// ).instructions
// );
// const mintToIx: InstructionReturn[] = [];
//
// await Promise.all(
// IX2.map((IX2) => buildSendAndCheck(IX2, userAccount, connection))
// );
// mintToIx.push(
// mintToTokenAccount(
// claimStakeMint,
// claimStakeMint.publicKey(),
// playerAssociatedTokenAccount,
// 10
// )
// );
// await buildSendAndCheck(mintToIx, userAccount, connection);
//
// const IX3: InstructionReturn[] = [];
// IX3.push(
// createTokenAccount(
// playerFuelTokenAccount,
// userAccount.publicKey(),
// fuelMint.publicKey(),
// connection
// )
// );
// IX3.push(
// createTokenAccount(
// playerArmsTokenAccount,
// userAccount.publicKey(),
// armsMint.publicKey(),
// connection
// )
// );
// IX3.push(
// createTokenAccount(
// playerFoodTokenAccount,
// userAccount.publicKey(),
// foodMint.publicKey(),
// connection
// )
// );
// IX3.push(
// createTokenAccount(
// playerToolkitTokenAccount,
// userAccount.publicKey(),
// toolkitMint.publicKey(),
// connection
// )
// );
//
// await Promise.all(
// IX3.map((IX3) => buildSendAndCheck(IX3, userAccount, connection))
// );
// });
//
// it('init claim stake program', async () => {
// await buildSendAndCheck(
// processInitialize(
// program,
// authorityAccount,
// globalVarsAccount,
// treasuryAuthBump,
// fuelTreasuryAccount,
// armsTreasuryAccount,
// foodTreasuryAccount,
// toolkitTreasuryAccount,
// foodMint.publicKey(),
// fuelMint.publicKey(),
// armsMint.publicKey(),
// toolkitMint.publicKey(),
// treasuryAuthority
// ),
// userAccount,
// connection
// );
//
// const globalVarsAccountInfo = await readFromRPCOrError(
// connection,
// program,
// globalVarsAccount,
// GlobalVars
// );
//
// expect(
// globalVarsEquals(globalVarsAccountInfo.data, {
// updateAuthorityMaster: authorityAccount.publicKey(),
// fuelMint: fuelMint.publicKey(),
// foodMint: foodMint.publicKey(),
// armsMint: armsMint.publicKey(),
// toolkitMint: toolkitMint.publicKey(),
// bump: 0,
// })
// ).toBeTruthy();
// });
// it('mints to', async () => {
// const IX: InstructionReturn[] = [];
// IX.push(
// mintToTokenAccount(
// fuelMint,
// fuelMint.publicKey(),
// fuelTreasuryAccount,
// 999
// )
// );
// IX.push(
// mintToTokenAccount(
// armsMint,
// armsMint.publicKey(),
// armsTreasuryAccount,
// 999
// )
// );
// IX.push(
// mintToTokenAccount(
// foodMint,
// foodMint.publicKey(),
// foodTreasuryAccount,
// 999
// )
// );
// IX.push(
// mintToTokenAccount(
// toolkitMint,
// toolkitMint.publicKey(),
// toolkitTreasuryAccount,
// 999
// )
// );
// await Promise.all(
// IX.map((IX) => buildSendAndCheck(IX, userAccount, connection))
// );
// });
// it('Register Player Faction', async () => {
// await buildSendAndCheck(
// processEnlistPlayer(factionProgram, playerFactionAccount, userAccount),
// userAccount,
// connection
// );
// });
// it('Register Claim Stake', async () => {
// await buildSendAndCheck(
// processRegisterClaimStake(
// program,
// authorityAccount,
// globalVarsAccount,
// claimStakeVarsAccount,
// claimStakeMint.publicKey(),
// rewardRate,
// maxReserves
// ),
// userAccount,
// connection
// );
// const claimStakeVarsAccountInfo = await readFromRPCOrError(
// connection,
// program,
// claimStakeVarsAccount,
// ClaimStakeVars
// );
// expect(
// claimStakeVarsEquals(claimStakeVarsAccountInfo.data, {
// armsMaxReserve: maxReserves.arms,
// foodMaxReserve: maxReserves.food,
// fuelMaxReserve: maxReserves.fuel,
// toolkitMaxReserve: maxReserves.toolkit,
// armsRewardRatePerSecond: rewardRate.arms,
// fuelRewardRatePerSecond: rewardRate.fuel,
// foodRewardRatePerSecond: rewardRate.food,
// toolkitRewardRatePerSecond: rewardRate.toolkit,
// claimStakeMint: claimStakeMint.publicKey(),
// bump: 0,
// })
// ).toBeTruthy();
// });
// it('Initial Deposit', async () => {
// await buildSendAndCheck(
// processInitialDeposit(
// program,
// claimStakingAccount,
// claimStakeVarsAccount,
// playerFactionAccount,
// escrowAuthority,
// playerAssociatedTokenAccount,
// claimStakeEscrow,
// claimStakeMint.publicKey(),
// escrowAuthBump,
// escrowBump
// ),
// userAccount,
// connection
// );
//
// const claimStakingAccountInfo = await readFromRPCOrError(
// connection,
// program,
// claimStakingAccount,
// ClaimStaking
// );
//
// expect(
// claimStakingAccountEquals(claimStakingAccountInfo.data, {
// claimStakesInEscrow: new BN(2),
// armsToPay: new BN(0),
// factionId: 1,
// foodToPay: new BN(0),
// fuelToPay: new BN(0),
// toolkitToPay: new BN(0),
// lastHarvestTimestamp: new BN(Math.floor(Date.now() / 1000)),
// mint: claimStakeMint.publicKey(),
// owner: userAccount.publicKey(),
// stakedAtTimestamp: new BN(Math.floor(Date.now() / 1000)),
// totalRewardsPaid: new BN(0),
// bump: 0,
// })
// ).toBeTruthy();
// });
//
// it('Partial Deposit', async () => {
// await buildSendAndCheck(
// processPartialDeposit(
// program,
// claimStakingAccount,
// claimStakeVarsAccount,
// escrowAuthority,
// claimStakeMint.publicKey(),
// playerAssociatedTokenAccount,
// claimStakeEscrow,
// escrowAuthBump,
// escrowBump
// ),
// userAccount,
// connection
// );
// const claimStakingAccountInfo = await readFromRPCOrError(
// connection,
// program,
// claimStakingAccount,
// ClaimStaking
// );
//
// expect(
// claimStakingAccountEquals(claimStakingAccountInfo.data, {
// claimStakesInEscrow: new BN(7),
// factionId: 1,
// armsToPay: claimStakingAccountInfo.data.armsToPay,
// foodToPay: claimStakingAccountInfo.data.foodToPay,
// fuelToPay: claimStakingAccountInfo.data.fuelToPay,
// toolkitToPay: claimStakingAccountInfo.data.toolkitToPay,
// lastHarvestTimestamp: new BN(Math.floor(Date.now() / 1000)),
// mint: claimStakeMint.publicKey(),
// owner: userAccount.publicKey(),
// stakedAtTimestamp: claimStakingAccountInfo.data.stakedAtTimestamp,
// totalRewardsPaid: new BN(0),
// bump: 0,
// }),
// 'Claim Stake data: ' +
// JSON.stringify(claimStakingAccountInfo.data, null, 2) +
// '\nExpected: ' +
// JSON.stringify(claimStakingAccountInfo.data, null, 2)
// ).toBeTruthy();
// });
//
// it('update reward rates', async () => {
// await buildSendAndCheck(
// processUpdateRewardRates(
// program,
// authorityAccount,
// globalVarsAccount,
// claimStakeVarsAccount,
// claimStakeMint.publicKey(),
// updatedRewardRates
// ),
// userAccount,
// connection
// );
//
// const claimStakeVarsAccountInfo = await readFromRPCOrError(
// connection,
// program,
// claimStakeVarsAccount,
// ClaimStakeVars
// );
//
// expect(
// claimStakeVarsEquals(claimStakeVarsAccountInfo.data, {
// armsMaxReserve: claimStakeVarsAccountInfo.data.armsMaxReserve,
// fuelMaxReserve: claimStakeVarsAccountInfo.data.fuelMaxReserve,
// foodMaxReserve: claimStakeVarsAccountInfo.data.foodMaxReserve,
// toolkitMaxReserve: claimStakeVarsAccountInfo.data.toolkitMaxReserve,
// armsRewardRatePerSecond: new BN(2),
// fuelRewardRatePerSecond: new BN(2),
// foodRewardRatePerSecond: new BN(2),
// toolkitRewardRatePerSecond: new BN(2),
// claimStakeMint: claimStakeMint.publicKey(),
// bump: 0,
// })
// ).toBeTruthy();
// });
//
// it('Settles account', async () => {
// await buildSendAndCheck(
// processSettle(
// program,
// claimStakingAccount,
// claimStakeVarsAccount,
// globalVarsAccount,
// claimStakeMint.publicKey()
// ),
// userAccount,
// connection
// );
//
// const claimStakingAccountInfo = await readFromRPCOrError(
// connection,
// program,
// claimStakeVarsAccount,
// ClaimStakeVars
// );
// });
// it('Harvests Claims', async () => {
// await sleep(2000);
// const oldClaimStakingAccountInfo = await readFromRPCOrError(
// connection,
// program,
// claimStakingAccount,
// ClaimStaking
// );
// await buildSendAndCheck(
// processHarvest(
// program,
// claimStakingAccount,
// claimStakeVarsAccount,
// fuelTreasuryAccount,
// armsTreasuryAccount,
// foodTreasuryAccount,
// toolkitTreasuryAccount,
// playerFuelTokenAccount.publicKey(),
// playerArmsTokenAccount.publicKey(),
// playerFoodTokenAccount.publicKey(),
// playerToolkitTokenAccount.publicKey(),
// treasuryAuthority,
// claimStakeMint.publicKey(),
// treasuryBump,
// treasuryAuthBump
// ),
// userAccount,
// connection
// );
// const claimStakingAccountInfo = await readFromRPCOrError(
// connection,
// program,
// claimStakingAccount,
// ClaimStaking
// );
// expect(
// claimStakingAccountEquals(claimStakingAccountInfo.data, {
// claimStakesInEscrow: new BN(7),
// armsToPay: new BN(0),
// fuelToPay: new BN(0),
// foodToPay: new BN(0),
// toolkitToPay: new BN(0),
// lastHarvestTimestamp: new BN(0),
// mint: claimStakeMint.publicKey(),
// owner: userAccount.publicKey(),
// stakedAtTimestamp: new BN(0),
// totalRewardsPaid: claimStakingAccountInfo.data.totalRewardsPaid,
// bump: 0,
// factionId: 1,
// })
// ).toBeTruthy();
//
// expect(
// claimStakingAccountEqualsAfterHarvest(oldClaimStakingAccountInfo.data, {
// claimStakesInEscrow: new BN(7),
// armsToPay: new BN(0),
// fuelToPay: new BN(0),
// foodToPay: new BN(0),
// toolkitToPay: new BN(0),
// lastHarvestTimestamp: new BN(0),
// mint: claimStakeMint.publicKey(),
// owner: userAccount.publicKey(),
// stakedAtTimestamp: new BN(0),
// totalRewardsPaid: claimStakingAccountInfo.data.totalRewardsPaid,
// bump: 0,
// factionId: 1,
// })
// ).toBeTruthy();
// });
// it('Withdraws Claim Stakes', async () => {
// await sleep(2000);
//
// await buildSendAndCheck(
// processWithdrawClaimStakes(
// program,
// claimStakingAccount,
// globalVarsAccount,
// claimStakeVarsAccount,
// playerAssociatedTokenAccount,
// playerFuelTokenAccount.publicKey(),
// playerArmsTokenAccount.publicKey(),
// playerFoodTokenAccount.publicKey(),
// playerToolkitTokenAccount.publicKey(),
// claimStakeEscrow,
// fuelTreasuryAccount,
// armsTreasuryAccount,
// foodTreasuryAccount,
// toolkitTreasuryAccount,
// treasuryAuthority,
// escrowAuthority,
// claimStakeMint.publicKey(),
// escrowAuthBump,
// escrowBump,
// treasuryAuthBump,
// treasuryBump
// ),
// userAccount,
// connection
// );
//
// const claimStakingAccountInfo = await readFromRPCOrError(
// connection,
// program,
// claimStakingAccount,
// ClaimStaking
// );
//
// expect(
// claimStakingAccountEquals(claimStakingAccountInfo.data, {
// claimStakesInEscrow: new BN(0),
// armsToPay: new BN(0),
// fuelToPay: new BN(0),
// foodToPay: new BN(0),
// toolkitToPay: new BN(0),
// lastHarvestTimestamp: claimStakingAccountInfo.data.lastHarvestTimestamp,
// mint: claimStakeMint.publicKey(),
// owner: userAccount.publicKey(),
// stakedAtTimestamp: claimStakingAccountInfo.data.stakedAtTimestamp,
// totalRewardsPaid: claimStakingAccountInfo.data.totalRewardsPaid,
// bump: claimStakingAccountInfo.data.bump,
// factionId: 1,
// })
// );
// });
const connection = new Connection('http://localhost:8899', 'confirmed');
const program: ClaimStakeIDLProgram = new Program(
CLAIM_STAKE_IDL,
new PublicKey('CSTKjcjKyZMyAZecSq1cKMMjNHnFr1b75QxxA7NDGFWC'),
{ connection }
);
const factionProgram = new Program(
ENLIST_TO_FACTION_IDL,
new PublicKey('FLisTRH6dJnCK8AzTfenGJgHBPMHoat9XRc65Qpk7Yuc'),
{ connection }
);
// Constants for Test
// Mints
const fuelMint = keypairToAsyncSigner(Keypair.generate());
const armsMint = keypairToAsyncSigner(Keypair.generate());
const foodMint = keypairToAsyncSigner(Keypair.generate());
const toolkitMint = keypairToAsyncSigner(Keypair.generate());
const claimStakeMint = keypairToAsyncSigner(Keypair.generate());
// Required Accounts
const userAccount = keypairToAsyncSigner(Keypair.generate());
// Expected authority pubkey: 4msrMm4M1y7jpwG4X2PQVhpV1WnE1tUoT5mM2Rn1Dsxv
const authKey = Uint8Array.from([
234, 138, 5, 166, 152, 131, 252, 133, 84, 73, 55, 236, 13, 83, 171, 151, 75,
21, 116, 70, 130, 197, 9, 0, 109, 129, 4, 196, 159, 106, 53, 35, 56, 18, 29,
33, 18, 115, 128, 11, 103, 250, 25, 233, 86, 2, 117, 206, 132, 218, 143,
128, 230, 59, 114, 2, 120, 217, 142, 163, 103, 47, 177, 51,
]);
const authorityAccount = keypairToAsyncSigner(Keypair.fromSecretKey(authKey));
// Treasury Authority
const [treasuryAuthority, treasuryAuthBump] = findProgramAddressSync(
[Buffer.from('TREASURY_AUTHORITY')],
program.programId
);
// Escrow Authority
const [escrowAuthority] = findEscrowAuthorityAccount(
program.programId,
userAccount.publicKey(),
claimStakeMint.publicKey()
);
// CLaim Stake Escrow
const [claimStakeEscrow] = findClaimStakeEscrowAccount(
program.programId,
userAccount.publicKey(),
claimStakeMint.publicKey()
);
// Player faction Account
const playerFactionAccount = findFactionAccount(
factionProgram.programId,
userAccount.publicKey()
)[0];
// Claim Stake Account
const claimStakingAccount = findProgramAddressSync(
[
Buffer.from('CLAIM_STAKING_INFO'),
userAccount.publicKey().toBuffer(),
claimStakeMint.publicKey().toBuffer(),
],
program.programId
)[0];
const globalVarsAccount = findProgramAddressSync(
[Buffer.from('GLOBALVARS')],
program.programId
)[0];
const claimStakeVarsAccount = findProgramAddressSync(
[Buffer.from('CLAIM_STAKE_VARS'), claimStakeMint.publicKey().toBuffer()],
program.programId
)[0];
// Token Accounts
const playerTokenAccount = keypairToAsyncSigner(Keypair.generate());
const playerAssociatedTokenAccount = getAssociatedTokenAddressSync(
claimStakeMint.publicKey(),
userAccount.publicKey(),
false,
TOKEN_PROGRAM_ID
);
const playerFuelTokenAccount = keypairToAsyncSigner(Keypair.generate());
const playerArmsTokenAccount = keypairToAsyncSigner(Keypair.generate());
const playerFoodTokenAccount = keypairToAsyncSigner(Keypair.generate());
const playerToolkitTokenAccount = keypairToAsyncSigner(Keypair.generate());
const {
fuelTreasuryAccount,
armsTreasuryAccount,
foodTreasuryAccount,
toolkitTreasuryAccount,
} = findTreasuryAccounts(program.programId);
// Value Constants
const rewardRate: RewardRateValues = {
fuel: new BN(5000000),
food: new BN(5000000),
arms: new BN(5000000),
toolkit: new BN(5000000),
};
const maxReserves: MaxReserveValues = {
fuel: new BN(50),
food: new BN(50),
arms: new BN(50),
toolkit: new BN(50),
};
const updatedRewardRates: NewValues = {
fuel: new BN(2000000),
food: new BN(2000000),
arms: new BN(2000000),
toolkit: new BN(2000000),
};
beforeAll(async () => {
const airdrop = await connection.requestAirdrop(
userAccount.publicKey(),
LAMPORTS_PER_SOL * 10
);
await connection.confirmTransaction(airdrop);
const airdrop2 = await connection.requestAirdrop(
authorityAccount.publicKey(),
LAMPORTS_PER_SOL
);
await connection.confirmTransaction(airdrop);
const airdrop3 = await connection.requestAirdrop(
escrowAuthority,
LAMPORTS_PER_SOL * 5
);
// Create Mints
const IXs: InstructionReturn[] = [];
// Fuel Mint
IXs.push(createMint(fuelMint, 0, fuelMint.publicKey(), null));
// Arms Mint
IXs.push(createMint(armsMint, 0, armsMint.publicKey(), null));
// Food Mint
IXs.push(createMint(foodMint, 0, foodMint.publicKey(), null));
// ToolkitMint
IXs.push(createMint(toolkitMint, 0, toolkitMint.publicKey(), null));
// Claim Stake Mint
IXs.push(createMint(claimStakeMint, 0, claimStakeMint.publicKey(), null));
await Promise.all(
IXs.map((IXs) => buildSendAndCheck(IXs, userAccount, connection))
);
const IX2: InstructionReturn[] = [];
IX2.push(
createTokenAccount(
playerTokenAccount,
userAccount.publicKey(),
claimStakeMint.publicKey()
)
);
IX2.push(
createAssociatedTokenAccount(
userAccount,
claimStakeMint.publicKey(),
userAccount.publicKey(),
false,
TOKEN_PROGRAM_ID
).instructions
);
const mintToIx: InstructionReturn[] = [];
await Promise.all(
IX2.map((IX2) => buildSendAndCheck(IX2, userAccount, connection))
);
mintToIx.push(
mintToTokenAccount(
claimStakeMint,
claimStakeMint.publicKey(),
playerAssociatedTokenAccount,
10
)
);
await buildSendAndCheck(mintToIx, userAccount, connection);
const IX3: InstructionReturn[] = [];
IX3.push(
createTokenAccount(
playerFuelTokenAccount,
userAccount.publicKey(),
fuelMint.publicKey()
)
);
IX3.push(
createTokenAccount(
playerArmsTokenAccount,
userAccount.publicKey(),
armsMint.publicKey()
)
);
IX3.push(
createTokenAccount(
playerFoodTokenAccount,
userAccount.publicKey(),
foodMint.publicKey()
)
);
IX3.push(
createTokenAccount(
playerToolkitTokenAccount,
userAccount.publicKey(),
toolkitMint.publicKey()
)
);
await Promise.all(
IX3.map((IX3) => buildSendAndCheck(IX3, userAccount, connection))
);
});
it('init claim stake program', async () => {
const preRead = await readFromRPCNullable(
connection,
program,
globalVarsAccount,
GlobalVars
);
if (preRead === null) {
await buildSendAndCheck(
processInitialize(
program,
authorityAccount,
globalVarsAccount,
treasuryAuthBump,
fuelTreasuryAccount,
armsTreasuryAccount,
foodTreasuryAccount,
toolkitTreasuryAccount,
foodMint.publicKey(),
fuelMint.publicKey(),
armsMint.publicKey(),
toolkitMint.publicKey(),
treasuryAuthority
),
userAccount,
connection
);
const globalVarsAccountInfo = await readFromRPCOrError(
connection,
program,
globalVarsAccount,
GlobalVars
);
expect(
globalVarsEquals(globalVarsAccountInfo.data, {
version: 0,
updateAuthorityMaster: authorityAccount.publicKey(),
fuelMint: fuelMint.publicKey(),
foodMint: foodMint.publicKey(),
armsMint: armsMint.publicKey(),
toolkitMint: toolkitMint.publicKey(),
bump: 0,
})
).toBeTruthy();
} else {
console.log('Global vars account already initialized');
}
});
it('mints to', async () => {
const IX: InstructionReturn[] = [];
IX.push(
mintToTokenAccount(
fuelMint,
fuelMint.publicKey(),
fuelTreasuryAccount,
999
)
);
IX.push(
mintToTokenAccount(
armsMint,
armsMint.publicKey(),
armsTreasuryAccount,
999
)
);
IX.push(
mintToTokenAccount(
foodMint,
foodMint.publicKey(),
foodTreasuryAccount,
999
)
);
IX.push(
mintToTokenAccount(
toolkitMint,
toolkitMint.publicKey(),
toolkitTreasuryAccount,
999
)
);
await Promise.all(
IX.map((IX) => buildSendAndCheck(IX, userAccount, connection))
);
});
it('Register Player Faction', async () => {
await buildSendAndCheck(
processEnlistPlayer(factionProgram, userAccount, 1),
userAccount,
connection
);
});
it('Register Claim Stake', async () => {
const preRead = await readFromRPCNullable(
connection,
program,
claimStakeVarsAccount,
ClaimStakeVars
);
if (preRead === null) {
await buildSendAndCheck(
processRegisterClaimStake(
program,
authorityAccount,
globalVarsAccount,
claimStakeVarsAccount,
claimStakeMint.publicKey(),
rewardRate,
maxReserves
),
userAccount,
connection
);
const claimStakeVarsAccountInfo = await readFromRPCOrError(
connection,
program,
claimStakeVarsAccount,
ClaimStakeVars
);
expect(
claimStakeVarsEquals(claimStakeVarsAccountInfo.data, {
version: 0,
armsMaxReserve: maxReserves.arms,
foodMaxReserve: maxReserves.food,
fuelMaxReserve: maxReserves.fuel,
toolkitMaxReserve: maxReserves.toolkit,
armsRewardRatePerSecond: rewardRate.arms,
fuelRewardRatePerSecond: rewardRate.fuel,
foodRewardRatePerSecond: rewardRate.food,
toolkitRewardRatePerSecond: rewardRate.toolkit,
claimStakeMint: claimStakeMint.publicKey(),
bump: 0,
})
).toBeTruthy();
} else {
console.log('Claim Stake Vars Account Already initialized');
}
});
it('Initial Deposit', async () => {
const preRead = await readFromRPCNullable(
connection,
program,
claimStakingAccount,
ClaimStaking
);
if (preRead === null) {
await buildSendAndCheck(
processInitialDeposit(
program,
claimStakingAccount,
claimStakeVarsAccount,
playerFactionAccount,
escrowAuthority,
playerAssociatedTokenAccount,
claimStakeEscrow,
claimStakeMint.publicKey(),
new BN(2)
),
userAccount,
connection
);
const claimStakingAccountInfo = await readFromRPCOrError(
connection,
program,
claimStakingAccount,
ClaimStaking
);
const factionEnlistmentAccountInfo = await readFromRPCOrError(
connection,
factionProgram,
playerFactionAccount,
PlayerFactionData
);
expect(
claimStakingAccountEquals(claimStakingAccountInfo.data, {
version: 0,
claimStakesInEscrow: new BN(2),
factionId: factionEnlistmentAccountInfo.data.factionId,
armsToPay: claimStakingAccountInfo.data.armsToPay,
foodToPay: claimStakingAccountInfo.data.foodToPay,
fuelToPay: claimStakingAccountInfo.data.fuelToPay,
toolkitToPay: claimStakingAccountInfo.data.toolkitToPay,
lastHarvestTimestamp:
claimStakingAccountInfo.data.lastHarvestTimestamp,
mint: claimStakeMint.publicKey(),
owner: userAccount.publicKey(),
stakedAtTimestamp: claimStakingAccountInfo.data.stakedAtTimestamp,
totalFuelPaid: new BN(0),
totalArmsPaid: new BN(0),
totalFoodPaid: new BN(0),
totalToolkitPaid: new BN(0),
totalTimePaid: new BN(0),
bump: 0,
}),
'Claim Stake data: ' +
JSON.stringify(claimStakingAccountInfo.data, null, 2) +
'\nExpected: ' +
JSON.stringify(claimStakingAccountInfo.data, null, 2)
).toBeTruthy();
}
});
it('Partial Deposit', async () => {
await buildSendAndCheck(
processPartialDeposit(
program,
claimStakingAccount,
claimStakeVarsAccount,
escrowAuthority,
claimStakeMint.publicKey(),
playerAssociatedTokenAccount,
claimStakeEscrow,
new BN(5)
),
userAccount,
connection
);
const claimStakingAccountInfo = await readFromRPCOrError(
connection,
program,
claimStakingAccount,
ClaimStaking
);
expect(
claimStakingAccountEquals(claimStakingAccountInfo.data, {
version: 0,
claimStakesInEscrow: new BN(7),
factionId: 1,
armsToPay: claimStakingAccountInfo.data.armsToPay,
foodToPay: claimStakingAccountInfo.data.foodToPay,
fuelToPay: claimStakingAccountInfo.data.fuelToPay,
toolkitToPay: claimStakingAccountInfo.data.toolkitToPay,
lastHarvestTimestamp: new BN(jest.now()),
mint: claimStakeMint.publicKey(),
owner: userAccount.publicKey(),
stakedAtTimestamp: claimStakingAccountInfo.data.stakedAtTimestamp,
totalFuelPaid: new BN(0),
totalArmsPaid: new BN(0),
totalFoodPaid: new BN(0),
totalToolkitPaid: new BN(0),
totalTimePaid: new BN(0),
bump: 0,
}),
'Claim Stake data: ' +
JSON.stringify(claimStakingAccountInfo.data, null, 2) +
'\nExpected: ' +
JSON.stringify(claimStakingAccountInfo.data, null, 2)
).toBeTruthy();
});
it('update reward rates', async () => {
await buildSendAndCheck(
processUpdateRewardRates(
program,
authorityAccount,
globalVarsAccount,
claimStakeVarsAccount,
claimStakeMint.publicKey(),
updatedRewardRates
),
userAccount,
connection
);
const claimStakeVarsAccountInfo = await readFromRPCOrError(
connection,
program,
claimStakeVarsAccount,
ClaimStakeVars
);
expect(
claimStakeVarsEquals(claimStakeVarsAccountInfo.data, {
version: 0,
armsMaxReserve: claimStakeVarsAccountInfo.data.armsMaxReserve,
fuelMaxReserve: claimStakeVarsAccountInfo.data.fuelMaxReserve,
foodMaxReserve: claimStakeVarsAccountInfo.data.foodMaxReserve,
toolkitMaxReserve: claimStakeVarsAccountInfo.data.toolkitMaxReserve,
armsRewardRatePerSecond: new BN(2000000),
fuelRewardRatePerSecond: new BN(2000000),
foodRewardRatePerSecond: new BN(2000000),
toolkitRewardRatePerSecond: new BN(2000000),
claimStakeMint: claimStakeMint.publicKey(),
bump: 0,
})
).toBeTruthy();
});
it('Settles account', async () => {
await buildSendAndCheck(
processSettle(
program,
claimStakingAccount,
claimStakeVarsAccount,
globalVarsAccount,
claimStakeMint.publicKey()
),
userAccount,
connection
);
const claimStakingAccountInfo = await readFromRPCOrError(
connection,
program,
claimStakeVarsAccount,
ClaimStakeVars
);
});
it('Harvests Claims', async () => {
await sleep(2000);
const oldClaimStakingAccountInfo = await readFromRPCOrError(
connection,
program,
claimStakingAccount,
ClaimStaking
);
await buildSendAndCheck(
processHarvest(
program,
claimStakingAccount,
claimStakeVarsAccount,
fuelTreasuryAccount,
armsTreasuryAccount,
foodTreasuryAccount,
toolkitTreasuryAccount,
playerFuelTokenAccount.publicKey(),
playerArmsTokenAccount.publicKey(),
playerFoodTokenAccount.publicKey(),
playerToolkitTokenAccount.publicKey(),
treasuryAuthority,
claimStakeMint.publicKey()
),
userAccount,
connection
);
const claimStakingAccountInfo = await readFromRPCOrError(
connection,
program,
claimStakingAccount,
ClaimStaking
);
expect(
claimStakingAccountEquals(claimStakingAccountInfo.data, {
version: 0,
claimStakesInEscrow: new BN(7),
armsToPay: claimStakingAccountInfo.data.armsToPay,
fuelToPay: claimStakingAccountInfo.data.fuelToPay,
foodToPay: claimStakingAccountInfo.data.foodToPay,
toolkitToPay: claimStakingAccountInfo.data.toolkitToPay,
lastHarvestTimestamp: claimStakingAccountInfo.data.lastHarvestTimestamp,
mint: claimStakingAccountInfo.data.mint,
owner: claimStakingAccountInfo.data.owner,
stakedAtTimestamp: claimStakingAccountInfo.data.stakedAtTimestamp,
totalFuelPaid: new BN(0),
totalTimePaid: new BN(0),
totalFoodPaid: new BN(0),
totalArmsPaid: new BN(0),
totalToolkitPaid: new BN(0),
bump: 0,
factionId: 1,
})
).toBeTruthy();
expect(
claimStakingAccountEqualsAfterHarvest(oldClaimStakingAccountInfo.data, {
version: 0,
claimStakesInEscrow: new BN(7),
armsToPay: oldClaimStakingAccountInfo.data.armsToPay,
fuelToPay: oldClaimStakingAccountInfo.data.fuelToPay,
foodToPay: oldClaimStakingAccountInfo.data.foodToPay,
toolkitToPay: oldClaimStakingAccountInfo.data.toolkitToPay,
lastHarvestTimestamp:
oldClaimStakingAccountInfo.data.lastHarvestTimestamp,
mint: claimStakeMint.publicKey(),
owner: userAccount.publicKey(),
stakedAtTimestamp: oldClaimStakingAccountInfo.data.stakedAtTimestamp,
totalTimePaid: new BN(0),
totalFuelPaid: new BN(0),
totalFoodPaid: new BN(0),
totalArmsPaid: new BN(0),
totalToolkitPaid: new BN(0),
bump: 0,
factionId: 1,
})
).toBeTruthy();
});
it('Withdraws Claim Stakes', async () => {
await sleep(2000);
await buildSendAndCheck(
processWithdrawClaimStakes(
program,
claimStakingAccount,
globalVarsAccount,
claimStakeVarsAccount,
playerAssociatedTokenAccount,
playerFuelTokenAccount.publicKey(),
playerArmsTokenAccount.publicKey(),
playerFoodTokenAccount.publicKey(),
playerToolkitTokenAccount.publicKey(),
claimStakeEscrow,
fuelTreasuryAccount,
armsTreasuryAccount,
foodTreasuryAccount,
toolkitTreasuryAccount,
treasuryAuthority,
escrowAuthority,
claimStakeMint.publicKey()
),
userAccount,
connection
);
const claimStakingAccountInfo = await readFromRPCOrError(
connection,
program,
claimStakingAccount,
ClaimStaking
);
expect(
claimStakingAccountEquals(claimStakingAccountInfo.data, {
version: 0,
claimStakesInEscrow: new BN(0),
armsToPay: claimStakingAccountInfo.data.armsToPay,
fuelToPay: claimStakingAccountInfo.data.fuelToPay,
foodToPay: claimStakingAccountInfo.data.foodToPay,
toolkitToPay: claimStakingAccountInfo.data.toolkitToPay,
lastHarvestTimestamp: claimStakingAccountInfo.data.lastHarvestTimestamp,
mint: claimStakeMint.publicKey(),
owner: userAccount.publicKey(),
stakedAtTimestamp: claimStakingAccountInfo.data.stakedAtTimestamp,
totalTimePaid: new BN(0),
totalFuelPaid: new BN(0),
totalFoodPaid: new BN(0),
totalArmsPaid: new BN(0),
totalToolkitPaid: new BN(0),
bump: claimStakingAccountInfo.data.bump,
factionId: 1,
})
);
});
});

@@ -21,4 +21,4 @@ {

},
"include": ["src/**/*.ts"],
"include": ["src/**/*.ts","test/**/*.ts"],
"exclude": ["node_modules", "dist"]
}

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

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