flash-sdk 13.0.2 → 14.0.1

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.
@@ -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;