@triadxyz/triad-protocol 0.0.4-beta → 0.0.6-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/stake.d.ts CHANGED
@@ -118,5 +118,5 @@ export default class Stake {
118
118
  * @param nftName - Name of the nft
119
119
  *
120
120
  */
121
- claimStakeRewards({ wallet, mint, week, stakeVault, nftName }: ClaimStakeRewardsArgs, options?: RpcOptions): Promise<any>;
121
+ claimStakeRewards({ wallet, mint, week, stakeVault, nftName }: ClaimStakeRewardsArgs, options?: RpcOptions): Promise<string>;
122
122
  }
package/dist/stake.js CHANGED
@@ -72,13 +72,29 @@ class Stake {
72
72
  let rewards = stake.dailyRewards
73
73
  .slice(start, end)
74
74
  .reduce((a, b) => a + b, 0);
75
+ let allRewards = stake.dailyRewards.reduce((a, b) => a + b);
76
+ stake.rewardsToClaim = 0;
77
+ stake.dailyRewards.forEach((item, index) => {
78
+ let week = 0;
79
+ let limit = 6;
80
+ if (!stake.weeklyRewardsPaid[week]) {
81
+ stake.rewardsToClaim += item;
82
+ }
83
+ if (index === limit) {
84
+ limit += 6;
85
+ week + 1;
86
+ }
87
+ });
75
88
  stake.weeklyRewards = rewards;
89
+ stake.allRewards = allRewards;
76
90
  }
77
91
  catch (error) {
78
92
  stake.apr = 0;
79
93
  stake.dailyRewards = [];
80
94
  stake.weeklyRewardsPaid = [];
81
95
  stake.weeklyRewards = 0;
96
+ stake.rewardsToClaim = 0;
97
+ stake.allRewards = 0;
82
98
  }
83
99
  }
84
100
  return myStakes;
@@ -392,9 +408,9 @@ class Stake {
392
408
  const NFTRewards = (0, helpers_1.getNFTRewardsAddressSync)(this.program.programId, Stake);
393
409
  const FromAta = (0, helpers_1.getATASync)(StakeVault, mint);
394
410
  const ToAta = (0, helpers_1.getATASync)(wallet, mint);
395
- let method;
411
+ let ixs = [];
396
412
  for (let w of week) {
397
- method = this.program.methods
413
+ ixs.push(yield this.program.methods
398
414
  .claimStakeRewards({
399
415
  week: w
400
416
  })
@@ -406,16 +422,25 @@ class Stake {
406
422
  nftRewards: NFTRewards,
407
423
  stake: Stake,
408
424
  stakeVault: StakeVault
409
- });
425
+ })
426
+ .instruction());
410
427
  }
411
428
  if (options === null || options === void 0 ? void 0 : options.microLamports) {
412
- method.postInstructions([
413
- web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
414
- microLamports: options.microLamports
415
- })
416
- ]);
429
+ ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
430
+ microLamports: options.microLamports
431
+ }));
417
432
  }
418
- return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
433
+ const { blockhash } = yield this.provider.connection.getLatestBlockhash();
434
+ const messageV0 = new web3_js_1.TransactionMessage({
435
+ payerKey: wallet,
436
+ recentBlockhash: blockhash,
437
+ instructions: ixs
438
+ }).compileToV0Message();
439
+ const tx = new web3_js_1.VersionedTransaction(messageV0);
440
+ return this.provider.sendAndConfirm(tx, [], {
441
+ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
442
+ commitment: 'confirmed'
443
+ });
419
444
  });
420
445
  }
421
446
  }
package/dist/test.js CHANGED
@@ -204,3 +204,6 @@ const updateStakeRewards = () => __awaiter(void 0, void 0, void 0, function* ()
204
204
  console.log(`Failed chunks saved to ./src/utils/stake-season-1/stakes/2/failedChunks_${ts}.json`);
205
205
  }
206
206
  });
207
+ triadProtocol.stake
208
+ .getStakeByWallet(new web3_js_1.PublicKey('E48CKgbZVpDzerQ7DdommgqNobRHLqHy8RUVi8HXkSHE'), constants_1.STAKE_SEASON_1)
209
+ .then(console.log);
@@ -111,4 +111,6 @@ export type StakeResponse = {
111
111
  dailyRewards?: number[];
112
112
  weeklyRewardsPaid?: boolean[];
113
113
  weeklyRewards?: number;
114
+ rewardsToClaim?: number;
115
+ allRewards?: number;
114
116
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "0.0.4-beta",
3
+ "version": "0.0.6-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",