flash-sdk 13.0.2 → 14.0.0

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.
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  });
21
21
  };
22
22
  var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
@@ -1913,7 +1913,7 @@ var PerpetualsClient = (function () {
1913
1913
  args_1[_i - 2] = arguments[_i];
1914
1914
  }
1915
1915
  return __awaiter(_this, __spreadArray([POOL_CONFIG_1, userPublicKey_1], args_1, true), void 0, function (POOL_CONFIG, userPublicKey, enableDebuglogs) {
1916
- var fafTokenVaultPk, fafTokenVaultAccountInfo, fafTokenVaultAccount, fafTokenVault, tokenStakeAccount, accountInfo, fafStakeData, tokenStakeFafAccount, activeStakeAmount, revenuePerFafStaked, revenueWatermark, revenueSnapshot, unclaimedRevenue, revenueAmount;
1916
+ var fafTokenVaultPk, fafTokenVaultAccountInfo, fafTokenVaultAccount, fafTokenVault, tokenStakeAccount, accountInfo, fafStakeData, tokenStakeFafAccount, eligibleAmount, revenuePerFafStaked, revenueWatermark, revenueSnapshot, unclaimedRevenue, revenueAmount;
1917
1917
  var _a, _b, _c, _d;
1918
1918
  if (enableDebuglogs === void 0) { enableDebuglogs = false; }
1919
1919
  return __generator(this, function (_e) {
@@ -1942,9 +1942,9 @@ var PerpetualsClient = (function () {
1942
1942
  if (accountInfo) {
1943
1943
  fafStakeData = this.program.coder.accounts.decode('tokenStake', accountInfo.data);
1944
1944
  tokenStakeFafAccount = TokenStakeAccount_1.TokenStakeAccount.from(fafStakeData);
1945
- activeStakeAmount = (_a = tokenStakeFafAccount === null || tokenStakeFafAccount === void 0 ? void 0 : tokenStakeFafAccount.activeStakeAmount) !== null && _a !== void 0 ? _a : constants_1.BN_ZERO;
1945
+ eligibleAmount = (_a = tokenStakeFafAccount === null || tokenStakeFafAccount === void 0 ? void 0 : tokenStakeFafAccount.getRevenueEligibleAmount()) !== null && _a !== void 0 ? _a : constants_1.BN_ZERO;
1946
1946
  revenuePerFafStaked = (_b = fafTokenVaultAccount === null || fafTokenVaultAccount === void 0 ? void 0 : fafTokenVaultAccount.revenuePerFafStaked) !== null && _b !== void 0 ? _b : constants_1.BN_ZERO;
1947
- revenueWatermark = activeStakeAmount
1947
+ revenueWatermark = eligibleAmount
1948
1948
  .mul(revenuePerFafStaked)
1949
1949
  .div(new anchor_1.BN(10).pow(new anchor_1.BN(constants_1.FAF_DECIMALS)));
1950
1950
  revenueSnapshot = (_c = tokenStakeFafAccount === null || tokenStakeFafAccount === void 0 ? void 0 : tokenStakeFafAccount.revenueSnapshot) !== null && _c !== void 0 ? _c : constants_1.BN_ZERO;
@@ -1963,6 +1963,43 @@ var PerpetualsClient = (function () {
1963
1963
  });
1964
1964
  });
1965
1965
  };
1966
+ this.getTokenStakeAccount = function (poolConfig, userPublicKey) { return __awaiter(_this, void 0, void 0, function () {
1967
+ var tokenStakePk, accountInfo, decoded;
1968
+ return __generator(this, function (_a) {
1969
+ switch (_a.label) {
1970
+ case 0:
1971
+ tokenStakePk = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('token_stake'), userPublicKey.toBuffer()], poolConfig.programId)[0];
1972
+ return [4, this.provider.connection.getAccountInfo(tokenStakePk)];
1973
+ case 1:
1974
+ accountInfo = _a.sent();
1975
+ if (!accountInfo) {
1976
+ return [2, null];
1977
+ }
1978
+ decoded = this.program.coder.accounts.decode('tokenStake', accountInfo.data);
1979
+ return [2, TokenStakeAccount_1.TokenStakeAccount.from(decoded)];
1980
+ }
1981
+ });
1982
+ }); };
1983
+ this.getUserUnstakingStatus = function (poolConfig, userPublicKey) { return __awaiter(_this, void 0, void 0, function () {
1984
+ var tokenStakeAccount;
1985
+ return __generator(this, function (_a) {
1986
+ switch (_a.label) {
1987
+ case 0: return [4, this.getTokenStakeAccount(poolConfig, userPublicKey)];
1988
+ case 1:
1989
+ tokenStakeAccount = _a.sent();
1990
+ if (!tokenStakeAccount) {
1991
+ return [2, null];
1992
+ }
1993
+ return [2, {
1994
+ activeStakeAmount: tokenStakeAccount.activeStakeAmount,
1995
+ totalLocked: tokenStakeAccount.getLockedAmount(),
1996
+ totalWithdrawable: tokenStakeAccount.getWithdrawableAmount(),
1997
+ revenueEligibleAmount: tokenStakeAccount.getRevenueEligibleAmount(),
1998
+ requests: tokenStakeAccount.getLockStatus(),
1999
+ }];
2000
+ }
2001
+ });
2002
+ }); };
1966
2003
  this.getLpTokenPriceView = function (poolConfig_1) {
1967
2004
  var args_1 = [];
1968
2005
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -5412,58 +5449,8 @@ var PerpetualsClient = (function () {
5412
5449
  }
5413
5450
  });
5414
5451
  }); };
5415
- this.unstakeTokenInstant = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5416
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_24;
5417
- return __generator(this, function (_a) {
5418
- switch (_a.label) {
5419
- case 0:
5420
- preInstructions = [];
5421
- instructions = [];
5422
- postInstructions = [];
5423
- additionalSigners = [];
5424
- _a.label = 1;
5425
- case 1:
5426
- _a.trys.push([1, 4, , 5]);
5427
- tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
5428
- userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.tokenMint, owner, true);
5429
- return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
5430
- case 2:
5431
- if (!(_a.sent())) {
5432
- preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(this.provider.wallet.publicKey, userTokenAccount, owner, poolConfig.tokenMint));
5433
- }
5434
- return [4, this.program.methods
5435
- .unstakeTokenInstant({
5436
- unstakeAmount: unstakeAmount
5437
- })
5438
- .accountsPartial({
5439
- owner: owner,
5440
- receivingTokenAccount: userTokenAccount,
5441
- perpetuals: poolConfig.perpetuals,
5442
- transferAuthority: poolConfig.transferAuthority,
5443
- tokenVault: poolConfig.tokenVault,
5444
- tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
5445
- tokenStakeAccount: tokenStakeAccount,
5446
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5447
- tokenMint: poolConfig.tokenMint,
5448
- })
5449
- .instruction()];
5450
- case 3:
5451
- unstakeTokenInstantInstruction = _a.sent();
5452
- instructions.push(unstakeTokenInstantInstruction);
5453
- return [3, 5];
5454
- case 4:
5455
- err_24 = _a.sent();
5456
- console.log("perpClient unstakeTokenInstantInstruction error:: ", err_24);
5457
- throw err_24;
5458
- case 5: return [2, {
5459
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5460
- additionalSigners: additionalSigners
5461
- }];
5462
- }
5463
- });
5464
- }); };
5465
5452
  this.withdrawToken = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5466
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_25;
5453
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_24;
5467
5454
  return __generator(this, function (_a) {
5468
5455
  switch (_a.label) {
5469
5456
  case 0:
@@ -5483,7 +5470,7 @@ var PerpetualsClient = (function () {
5483
5470
  }
5484
5471
  return [4, this.program.methods
5485
5472
  .withdrawToken({
5486
- withdrawRequestId: withdrawRequestId
5473
+ withdrawRequestId: withdrawRequestId,
5487
5474
  })
5488
5475
  .accountsPartial({
5489
5476
  owner: owner,
@@ -5502,9 +5489,9 @@ var PerpetualsClient = (function () {
5502
5489
  instructions.push(withdrawTokenInstruction);
5503
5490
  return [3, 5];
5504
5491
  case 4:
5505
- err_25 = _a.sent();
5506
- console.log("perpClient withdrawTokenInstruction error:: ", err_25);
5507
- throw err_25;
5492
+ err_24 = _a.sent();
5493
+ console.log("perpClient withdrawTokenInstruction error:: ", err_24);
5494
+ throw err_24;
5508
5495
  case 5: return [2, {
5509
5496
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5510
5497
  additionalSigners: additionalSigners
@@ -5512,8 +5499,8 @@ var PerpetualsClient = (function () {
5512
5499
  }
5513
5500
  });
5514
5501
  }); };
5515
- this.cancelUnstakeRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5516
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_26;
5502
+ this.cancelUnstakeTokenRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5503
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeTokenRequestInstruction, err_25;
5517
5504
  return __generator(this, function (_a) {
5518
5505
  switch (_a.label) {
5519
5506
  case 0:
@@ -5537,13 +5524,13 @@ var PerpetualsClient = (function () {
5537
5524
  })
5538
5525
  .instruction()];
5539
5526
  case 2:
5540
- cancelUnstakeRequestInstruction = _a.sent();
5541
- instructions.push(cancelUnstakeRequestInstruction);
5527
+ cancelUnstakeTokenRequestInstruction = _a.sent();
5528
+ instructions.push(cancelUnstakeTokenRequestInstruction);
5542
5529
  return [3, 4];
5543
5530
  case 3:
5544
- err_26 = _a.sent();
5545
- console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_26);
5546
- throw err_26;
5531
+ err_25 = _a.sent();
5532
+ console.log("perpClient cancelUnstakeTokenRequestInstruction error:: ", err_25);
5533
+ throw err_25;
5547
5534
  case 4: return [2, {
5548
5535
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5549
5536
  additionalSigners: additionalSigners
@@ -5557,7 +5544,7 @@ var PerpetualsClient = (function () {
5557
5544
  args_1[_i - 2] = arguments[_i];
5558
5545
  }
5559
5546
  return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
5560
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_27;
5547
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_26;
5561
5548
  if (createUserATA === void 0) { createUserATA = true; }
5562
5549
  return __generator(this, function (_b) {
5563
5550
  switch (_b.label) {
@@ -5601,9 +5588,9 @@ var PerpetualsClient = (function () {
5601
5588
  instructions.push(collectTokenRewardInstruction);
5602
5589
  return [3, 6];
5603
5590
  case 5:
5604
- err_27 = _b.sent();
5605
- console.log("perpClient collectTokenRewardInstruction error:: ", err_27);
5606
- throw err_27;
5591
+ err_26 = _b.sent();
5592
+ console.log("perpClient collectTokenRewardInstruction error:: ", err_26);
5593
+ throw err_26;
5607
5594
  case 6: return [2, {
5608
5595
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5609
5596
  additionalSigners: additionalSigners
@@ -5618,7 +5605,7 @@ var PerpetualsClient = (function () {
5618
5605
  args_1[_i - 3] = arguments[_i];
5619
5606
  }
5620
5607
  return __awaiter(_this, __spreadArray([owner_1, rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (owner, rewardSymbol, poolConfig, createUserATA) {
5621
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_28;
5608
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_27;
5622
5609
  if (createUserATA === void 0) { createUserATA = true; }
5623
5610
  return __generator(this, function (_b) {
5624
5611
  switch (_b.label) {
@@ -5663,9 +5650,9 @@ var PerpetualsClient = (function () {
5663
5650
  instructions.push(collectRevenueInstruction);
5664
5651
  return [3, 6];
5665
5652
  case 5:
5666
- err_28 = _b.sent();
5667
- console.log("perpClient collectRevenueInstruction error:: ", err_28);
5668
- throw err_28;
5653
+ err_27 = _b.sent();
5654
+ console.log("perpClient collectRevenueInstruction error:: ", err_27);
5655
+ throw err_27;
5669
5656
  case 6: return [2, {
5670
5657
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5671
5658
  additionalSigners: additionalSigners
@@ -5674,6 +5661,45 @@ var PerpetualsClient = (function () {
5674
5661
  });
5675
5662
  });
5676
5663
  };
5664
+ this.refreshTokenStake = function (tokenStakeAccounts, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5665
+ var instructions, additionalSigners, remainingAccounts, refreshTokenStakeInstruction, err_28;
5666
+ return __generator(this, function (_a) {
5667
+ switch (_a.label) {
5668
+ case 0:
5669
+ instructions = [];
5670
+ additionalSigners = [];
5671
+ _a.label = 1;
5672
+ case 1:
5673
+ _a.trys.push([1, 3, , 4]);
5674
+ remainingAccounts = tokenStakeAccounts.map(function (pubkey) { return ({
5675
+ pubkey: pubkey,
5676
+ isSigner: false,
5677
+ isWritable: true,
5678
+ }); });
5679
+ return [4, this.program.methods
5680
+ .refreshTokenStake({})
5681
+ .accountsPartial({
5682
+ perpetuals: this.perpetuals.publicKey,
5683
+ tokenVault: poolConfig.tokenVault,
5684
+ program: this.programId,
5685
+ })
5686
+ .remainingAccounts(remainingAccounts)
5687
+ .instruction()];
5688
+ case 2:
5689
+ refreshTokenStakeInstruction = _a.sent();
5690
+ instructions.push(refreshTokenStakeInstruction);
5691
+ return [3, 4];
5692
+ case 3:
5693
+ err_28 = _a.sent();
5694
+ console.log("perpClient refreshTokenStakeInstruction error:: ", err_28);
5695
+ throw err_28;
5696
+ case 4: return [2, {
5697
+ instructions: instructions,
5698
+ additionalSigners: additionalSigners
5699
+ }];
5700
+ }
5701
+ });
5702
+ }); };
5677
5703
  this.collectRebate = function (owner_1, rebateSymbol_1, poolConfig_1) {
5678
5704
  var args_1 = [];
5679
5705
  for (var _i = 3; _i < arguments.length; _i++) {
@@ -7790,7 +7816,7 @@ var PerpetualsClient = (function () {
7790
7816
  }
7791
7817
  });
7792
7818
  }); };
7793
- this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7819
+ this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, unlockPeriod, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7794
7820
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_58;
7795
7821
  return __generator(this, function (_a) {
7796
7822
  switch (_a.label) {
@@ -7809,6 +7835,7 @@ var PerpetualsClient = (function () {
7809
7835
  withdrawTimeLimit: withdrawTimeLimit,
7810
7836
  withdrawInstantFee: withdrawInstantFee,
7811
7837
  stakeLevel: stakeLevel,
7838
+ unlockPeriod: unlockPeriod,
7812
7839
  })
7813
7840
  .accountsPartial({
7814
7841
  admin: publicKey,
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { Pool, TokenRatios, StakeStats, CompoundingStats, Permissions } from "./types";
3
4
  import { PublicKey } from "@solana/web3.js";
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { Mint } from "@solana/spl-token";
3
4
  import { CustodyAccount } from "./CustodyAccount";
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { PublicKey } from "@solana/web3.js";
3
4
  import { ContractOraclePrice, Position } from "./types";
@@ -1,13 +1,22 @@
1
- import { TokenStake, WithdrawStakeLog } from "./types";
1
+ /// <reference types="bn.js" />
2
+ import { TokenStake, WithdrawRequest } from "./types";
2
3
  import { BN } from "@coral-xyz/anchor";
3
4
  import { PublicKey } from "@solana/web3.js";
5
+ export interface LockRequestStatus {
6
+ requestId: number;
7
+ lockedAmount: BN;
8
+ withdrawableAmount: BN;
9
+ timeRemaining: BN;
10
+ totalAmount: BN;
11
+ }
4
12
  export declare class TokenStakeAccount implements TokenStake {
5
13
  owner: PublicKey;
6
14
  isInitialized: boolean;
7
15
  bump: number;
8
16
  level: number;
9
17
  withdrawRequestCount: number;
10
- withdrawRequest: WithdrawStakeLog[] | any;
18
+ withdrawRequest: WithdrawRequest[];
19
+ buffer: number[];
11
20
  activeStakeAmount: BN;
12
21
  updateTimestamp: BN;
13
22
  tradeTimestamp: BN;
@@ -23,7 +32,8 @@ export declare class TokenStakeAccount implements TokenStake {
23
32
  bump: number;
24
33
  level: number;
25
34
  withdrawRequestCount: number;
26
- withdrawRequest: WithdrawStakeLog[];
35
+ withdrawRequest: WithdrawRequest[];
36
+ buffer: number[];
27
37
  activeStakeAmount: BN;
28
38
  updateTimestamp: BN;
29
39
  tradeTimestamp: BN;
@@ -35,5 +45,9 @@ export declare class TokenStakeAccount implements TokenStake {
35
45
  claimableRebateUsd: BN;
36
46
  });
37
47
  static from(decodedData: any): TokenStakeAccount;
48
+ getLockedAmount(): BN;
49
+ getWithdrawableAmount(): BN;
50
+ getRevenueEligibleAmount(): BN;
51
+ getLockStatus(): LockRequestStatus[];
38
52
  updateData(newData: Partial<TokenStakeAccount>): void;
39
53
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TokenStakeAccount = void 0;
4
4
  var anchor_1 = require("@coral-xyz/anchor");
5
+ var BN_ZERO = new anchor_1.BN(0);
5
6
  var TokenStakeAccount = (function () {
6
7
  function TokenStakeAccount(data) {
7
8
  this.owner = data.owner;
@@ -10,6 +11,7 @@ var TokenStakeAccount = (function () {
10
11
  this.level = data.level;
11
12
  this.withdrawRequestCount = data.withdrawRequestCount;
12
13
  this.withdrawRequest = data.withdrawRequest;
14
+ this.buffer = data.buffer;
13
15
  this.activeStakeAmount = data.activeStakeAmount;
14
16
  this.updateTimestamp = data.updateTimestamp;
15
17
  this.tradeTimestamp = data.tradeTimestamp;
@@ -28,6 +30,7 @@ var TokenStakeAccount = (function () {
28
30
  level: decodedData.level,
29
31
  withdrawRequestCount: decodedData.withdrawRequestCount,
30
32
  withdrawRequest: decodedData.withdrawRequest,
33
+ buffer: decodedData.buffer,
31
34
  activeStakeAmount: new anchor_1.BN(decodedData.activeStakeAmount),
32
35
  updateTimestamp: new anchor_1.BN(decodedData.updateTimestamp),
33
36
  tradeTimestamp: new anchor_1.BN(decodedData.tradeTimestamp),
@@ -39,6 +42,39 @@ var TokenStakeAccount = (function () {
39
42
  claimableRebateUsd: decodedData.claimableRebateUsd,
40
43
  });
41
44
  };
45
+ TokenStakeAccount.prototype.getLockedAmount = function () {
46
+ var total = BN_ZERO;
47
+ for (var i = 0; i < this.withdrawRequestCount; i++) {
48
+ total = total.add(new anchor_1.BN(this.withdrawRequest[i].lockedAmount));
49
+ }
50
+ return total;
51
+ };
52
+ TokenStakeAccount.prototype.getWithdrawableAmount = function () {
53
+ var total = BN_ZERO;
54
+ for (var i = 0; i < this.withdrawRequestCount; i++) {
55
+ total = total.add(new anchor_1.BN(this.withdrawRequest[i].withdrawableAmount));
56
+ }
57
+ return total;
58
+ };
59
+ TokenStakeAccount.prototype.getRevenueEligibleAmount = function () {
60
+ return this.activeStakeAmount.add(this.getLockedAmount());
61
+ };
62
+ TokenStakeAccount.prototype.getLockStatus = function () {
63
+ var statuses = [];
64
+ for (var i = 0; i < this.withdrawRequestCount; i++) {
65
+ var req = this.withdrawRequest[i];
66
+ var locked = new anchor_1.BN(req.lockedAmount);
67
+ var withdrawable = new anchor_1.BN(req.withdrawableAmount);
68
+ statuses.push({
69
+ requestId: i,
70
+ lockedAmount: locked,
71
+ withdrawableAmount: withdrawable,
72
+ timeRemaining: new anchor_1.BN(req.timeRemaining),
73
+ totalAmount: locked.add(withdrawable),
74
+ });
75
+ }
76
+ return statuses;
77
+ };
42
78
  TokenStakeAccount.prototype.updateData = function (newData) {
43
79
  Object.assign(this, newData);
44
80
  };
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { PublicKey } from "@solana/web3.js";
3
4
  import { TokenVault } from "./types";
@@ -26,6 +27,7 @@ export declare class TokenVaultAccount implements TokenVault {
26
27
  revenueAccrued: BN;
27
28
  revenueDistributed: BN;
28
29
  revenuePaid: BN;
30
+ unlockPeriod: BN;
29
31
  padding2: BN[];
30
32
  constructor(publicKey: PublicKey, parseData: TokenVault);
31
33
  static from(publicKey: PublicKey, parseData: TokenVault): TokenVaultAccount;
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
@@ -40,8 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
40
40
  };
41
41
  var _a;
42
42
  Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.getBackupOracleInstruction = exports.getPythnetOraclePrices = exports.pythPriceServiceConnection = void 0;
44
- exports.createBackupOracleInstruction = createBackupOracleInstruction;
43
+ exports.createBackupOracleInstruction = exports.getBackupOracleInstruction = exports.getPythnetOraclePrices = exports.pythPriceServiceConnection = void 0;
45
44
  var price_service_client_1 = require("@pythnetwork/price-service-client");
46
45
  var web3_js_1 = require("@solana/web3.js");
47
46
  var bn_js_1 = __importDefault(require("bn.js"));
@@ -178,3 +177,4 @@ function createBackupOracleInstruction(poolAddress_1) {
178
177
  });
179
178
  });
180
179
  }
180
+ exports.createBackupOracleInstruction = createBackupOracleInstruction;
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { PublicKey } from '@solana/web3.js';
2
3
  export declare const PERCENTAGE_DECIMALS = 4;
3
4
  export declare const USD_DECIMALS = 6;