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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { ContractOraclePrice } from "./types";
3
4
  export declare class OraclePrice {
@@ -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 { LimitOrder, Order, TriggerOrder } from "./types";
@@ -1,3 +1,5 @@
1
+ /// <reference types="bn.js" />
2
+ /// <reference types="node" />
1
3
  import { Program, AnchorProvider, BN } from "@coral-xyz/anchor";
2
4
  import { PublicKey, TransactionInstruction, Commitment, Signer, AddressLookupTableAccount, VersionedTransaction } from "@solana/web3.js";
3
5
  import { PoolAccount } from "./PoolAccount";
@@ -9,6 +11,7 @@ import type { Perpetuals } from './idl/perpetuals';
9
11
  import { SendTransactionOpts } from "./utils/rpc";
10
12
  import { MarketConfig, PoolConfig, Token } from "./PoolConfig";
11
13
  import { MarketAccount } from "./MarketAccount";
14
+ import { TokenStakeAccount } from "./TokenStakeAccount";
12
15
  export type PerpClientOptions = {
13
16
  postSendTxCallback?: ({ txid }: {
14
17
  txid: string;
@@ -75,79 +78,24 @@ export declare class PerpetualsClient {
75
78
  bump: number;
76
79
  };
77
80
  adjustTokenRatios: (ratios: TokenRatios[]) => TokenRatios[];
78
- getPerpetuals: () => Promise<{
79
- permissions: {
80
- allowSwap: boolean;
81
- allowAddLiquidity: boolean;
82
- allowRemoveLiquidity: boolean;
83
- allowOpenPosition: boolean;
84
- allowClosePosition: boolean;
85
- allowCollateralWithdrawal: boolean;
86
- allowSizeChange: boolean;
87
- allowLiquidation: boolean;
88
- allowLpStaking: boolean;
89
- allowFeeDistribution: boolean;
90
- allowUngatedTrading: boolean;
91
- allowFeeDiscounts: boolean;
92
- allowReferralRebates: boolean;
93
- };
94
- pools: PublicKey[];
95
- collections: PublicKey[];
96
- voltageMultiplier: {
97
- volume: BN;
98
- rewards: BN;
99
- rebates: BN;
100
- };
101
- tradingDiscount: BN[];
102
- referralRebate: BN[];
103
- defaultRebate: BN;
104
- inceptionTime: BN;
105
- transferAuthorityBump: number;
106
- perpetualsBump: number;
107
- tradeLimit: number;
108
- triggerOrderLimit: number;
109
- rebateLimitUsd: number;
110
- }>;
81
+ getPerpetuals: () => Promise<any>;
111
82
  getPoolKey: (name: string) => PublicKey;
112
83
  getPool: (name: string) => Promise<{
113
84
  name: string;
114
- permissions: {
115
- allowSwap: boolean;
116
- allowAddLiquidity: boolean;
117
- allowRemoveLiquidity: boolean;
118
- allowOpenPosition: boolean;
119
- allowClosePosition: boolean;
120
- allowCollateralWithdrawal: boolean;
121
- allowSizeChange: boolean;
122
- allowLiquidation: boolean;
123
- allowLpStaking: boolean;
124
- allowFeeDistribution: boolean;
125
- allowUngatedTrading: boolean;
126
- allowFeeDiscounts: boolean;
127
- allowReferralRebates: boolean;
128
- };
85
+ permissions: any;
129
86
  inceptionTime: BN;
130
87
  lpMint: PublicKey;
131
88
  oracleAuthority: PublicKey;
132
89
  stakedLpVault: PublicKey;
133
90
  rewardCustody: PublicKey;
134
91
  custodies: PublicKey[];
135
- ratios: {
136
- target: BN;
137
- min: BN;
138
- max: BN;
139
- }[];
92
+ ratios: any[];
140
93
  markets: PublicKey[];
141
94
  maxAumUsd: BN;
142
95
  buffer: BN;
143
96
  rawAumUsd: BN;
144
97
  equityUsd: BN;
145
- totalStaked: {
146
- pendingActivation: BN;
147
- activeAmount: BN;
148
- pendingDeactivation: BN;
149
- deactivatedAmount: BN;
150
- };
98
+ totalStaked: any;
151
99
  stakingFeeShareBps: BN;
152
100
  bump: number;
153
101
  lpMintBump: number;
@@ -158,13 +106,7 @@ export declare class PerpetualsClient {
158
106
  stakingFeeBoostBps: BN[];
159
107
  compoundingMint: PublicKey;
160
108
  compoundingLpVault: PublicKey;
161
- compoundingStats: {
162
- activeAmount: BN;
163
- totalSupply: BN;
164
- rewardSnapshot: BN;
165
- feeShareBps: BN;
166
- lastCompoundTime: BN;
167
- };
109
+ compoundingStats: any;
168
110
  compoundingMintBump: number;
169
111
  compoundingLpVaultBump: number;
170
112
  minLpPriceUsd: BN;
@@ -178,43 +120,20 @@ export declare class PerpetualsClient {
178
120
  }>;
179
121
  getPools: () => Promise<{
180
122
  name: string;
181
- permissions: {
182
- allowSwap: boolean;
183
- allowAddLiquidity: boolean;
184
- allowRemoveLiquidity: boolean;
185
- allowOpenPosition: boolean;
186
- allowClosePosition: boolean;
187
- allowCollateralWithdrawal: boolean;
188
- allowSizeChange: boolean;
189
- allowLiquidation: boolean;
190
- allowLpStaking: boolean;
191
- allowFeeDistribution: boolean;
192
- allowUngatedTrading: boolean;
193
- allowFeeDiscounts: boolean;
194
- allowReferralRebates: boolean;
195
- };
123
+ permissions: any;
196
124
  inceptionTime: BN;
197
125
  lpMint: PublicKey;
198
126
  oracleAuthority: PublicKey;
199
127
  stakedLpVault: PublicKey;
200
128
  rewardCustody: PublicKey;
201
129
  custodies: PublicKey[];
202
- ratios: {
203
- target: BN;
204
- min: BN;
205
- max: BN;
206
- }[];
130
+ ratios: any[];
207
131
  markets: PublicKey[];
208
132
  maxAumUsd: BN;
209
133
  buffer: BN;
210
134
  rawAumUsd: BN;
211
135
  equityUsd: BN;
212
- totalStaked: {
213
- pendingActivation: BN;
214
- activeAmount: BN;
215
- pendingDeactivation: BN;
216
- deactivatedAmount: BN;
217
- };
136
+ totalStaked: any;
218
137
  stakingFeeShareBps: BN;
219
138
  bump: number;
220
139
  lpMintBump: number;
@@ -225,13 +144,7 @@ export declare class PerpetualsClient {
225
144
  stakingFeeBoostBps: BN[];
226
145
  compoundingMint: PublicKey;
227
146
  compoundingLpVault: PublicKey;
228
- compoundingStats: {
229
- activeAmount: BN;
230
- totalSupply: BN;
231
- rewardSnapshot: BN;
232
- feeShareBps: BN;
233
- lastCompoundTime: BN;
234
- };
147
+ compoundingStats: any;
235
148
  compoundingMintBump: number;
236
149
  compoundingLpVaultBump: number;
237
150
  minLpPriceUsd: BN;
@@ -256,10 +169,7 @@ export declare class PerpetualsClient {
256
169
  delegate: PublicKey;
257
170
  openTime: BN;
258
171
  updateTime: BN;
259
- entryPrice: {
260
- price: BN;
261
- exponent: number;
262
- };
172
+ entryPrice: any;
263
173
  sizeAmount: BN;
264
174
  sizeUsd: BN;
265
175
  lockedAmount: BN;
@@ -270,10 +180,7 @@ export declare class PerpetualsClient {
270
180
  unsettledFeesUsd: BN;
271
181
  cumulativeLockFeeSnapshot: BN;
272
182
  degenSizeUsd: BN;
273
- referencePrice: {
274
- price: BN;
275
- exponent: number;
276
- };
183
+ referencePrice: any;
277
184
  buffer: number[];
278
185
  priceImpactSet: number;
279
186
  sizeDecimals: number;
@@ -286,40 +193,9 @@ export declare class PerpetualsClient {
286
193
  getOrderAccount: (orderAccountKey: PublicKey) => Promise<{
287
194
  owner: PublicKey;
288
195
  market: PublicKey;
289
- limitOrders: {
290
- limitPrice: {
291
- price: BN;
292
- exponent: number;
293
- };
294
- reserveAmount: BN;
295
- reserveCustodyUid: number;
296
- receiveCustodyUid: number;
297
- sizeAmount: BN;
298
- stopLossPrice: {
299
- price: BN;
300
- exponent: number;
301
- };
302
- takeProfitPrice: {
303
- price: BN;
304
- exponent: number;
305
- };
306
- }[];
307
- takeProfitOrders: {
308
- triggerPrice: {
309
- price: BN;
310
- exponent: number;
311
- };
312
- triggerSize: BN;
313
- receiveCustodyUid: number;
314
- }[];
315
- stopLossOrders: {
316
- triggerPrice: {
317
- price: BN;
318
- exponent: number;
319
- };
320
- triggerSize: BN;
321
- receiveCustodyUid: number;
322
- }[];
196
+ limitOrders: any[];
197
+ takeProfitOrders: any[];
198
+ stopLossOrders: any[];
323
199
  isInitialised: boolean;
324
200
  openOrders: number;
325
201
  openSl: number;
@@ -338,10 +214,7 @@ export declare class PerpetualsClient {
338
214
  delegate: PublicKey;
339
215
  openTime: BN;
340
216
  updateTime: BN;
341
- entryPrice: {
342
- price: BN;
343
- exponent: number;
344
- };
217
+ entryPrice: any;
345
218
  sizeAmount: BN;
346
219
  sizeUsd: BN;
347
220
  lockedAmount: BN;
@@ -352,10 +225,7 @@ export declare class PerpetualsClient {
352
225
  unsettledFeesUsd: BN;
353
226
  cumulativeLockFeeSnapshot: BN;
354
227
  degenSizeUsd: BN;
355
- referencePrice: {
356
- price: BN;
357
- exponent: number;
358
- };
228
+ referencePrice: any;
359
229
  buffer: number[];
360
230
  priceImpactSet: number;
361
231
  sizeDecimals: number;
@@ -370,10 +240,7 @@ export declare class PerpetualsClient {
370
240
  delegate: PublicKey;
371
241
  openTime: BN;
372
242
  updateTime: BN;
373
- entryPrice: {
374
- price: BN;
375
- exponent: number;
376
- };
243
+ entryPrice: any;
377
244
  sizeAmount: BN;
378
245
  sizeUsd: BN;
379
246
  lockedAmount: BN;
@@ -384,10 +251,7 @@ export declare class PerpetualsClient {
384
251
  unsettledFeesUsd: BN;
385
252
  cumulativeLockFeeSnapshot: BN;
386
253
  degenSizeUsd: BN;
387
- referencePrice: {
388
- price: BN;
389
- exponent: number;
390
- };
254
+ referencePrice: any;
391
255
  buffer: number[];
392
256
  priceImpactSet: number;
393
257
  sizeDecimals: number;
@@ -448,10 +312,7 @@ export declare class PerpetualsClient {
448
312
  delegate: PublicKey;
449
313
  openTime: BN;
450
314
  updateTime: BN;
451
- entryPrice: {
452
- price: BN;
453
- exponent: number;
454
- };
315
+ entryPrice: any;
455
316
  sizeAmount: BN;
456
317
  sizeUsd: BN;
457
318
  lockedAmount: BN;
@@ -462,10 +323,7 @@ export declare class PerpetualsClient {
462
323
  unsettledFeesUsd: BN;
463
324
  cumulativeLockFeeSnapshot: BN;
464
325
  degenSizeUsd: BN;
465
- referencePrice: {
466
- price: BN;
467
- exponent: number;
468
- };
326
+ referencePrice: any;
469
327
  buffer: number[];
470
328
  priceImpactSet: number;
471
329
  sizeDecimals: number;
@@ -480,10 +338,7 @@ export declare class PerpetualsClient {
480
338
  delegate: PublicKey;
481
339
  openTime: BN;
482
340
  updateTime: BN;
483
- entryPrice: {
484
- price: BN;
485
- exponent: number;
486
- };
341
+ entryPrice: any;
487
342
  sizeAmount: BN;
488
343
  sizeUsd: BN;
489
344
  lockedAmount: BN;
@@ -494,10 +349,7 @@ export declare class PerpetualsClient {
494
349
  unsettledFeesUsd: BN;
495
350
  cumulativeLockFeeSnapshot: BN;
496
351
  degenSizeUsd: BN;
497
- referencePrice: {
498
- price: BN;
499
- exponent: number;
500
- };
352
+ referencePrice: any;
501
353
  buffer: number[];
502
354
  priceImpactSet: number;
503
355
  sizeDecimals: number;
@@ -512,10 +364,7 @@ export declare class PerpetualsClient {
512
364
  delegate: PublicKey;
513
365
  openTime: BN;
514
366
  updateTime: BN;
515
- entryPrice: {
516
- price: BN;
517
- exponent: number;
518
- };
367
+ entryPrice: any;
519
368
  sizeAmount: BN;
520
369
  sizeUsd: BN;
521
370
  lockedAmount: BN;
@@ -526,10 +375,7 @@ export declare class PerpetualsClient {
526
375
  unsettledFeesUsd: BN;
527
376
  cumulativeLockFeeSnapshot: BN;
528
377
  degenSizeUsd: BN;
529
- referencePrice: {
530
- price: BN;
531
- exponent: number;
532
- };
378
+ referencePrice: any;
533
379
  buffer: number[];
534
380
  priceImpactSet: number;
535
381
  sizeDecimals: number;
@@ -544,10 +390,7 @@ export declare class PerpetualsClient {
544
390
  delegate: PublicKey;
545
391
  openTime: BN;
546
392
  updateTime: BN;
547
- entryPrice: {
548
- price: BN;
549
- exponent: number;
550
- };
393
+ entryPrice: any;
551
394
  sizeAmount: BN;
552
395
  sizeUsd: BN;
553
396
  lockedAmount: BN;
@@ -558,10 +401,7 @@ export declare class PerpetualsClient {
558
401
  unsettledFeesUsd: BN;
559
402
  cumulativeLockFeeSnapshot: BN;
560
403
  degenSizeUsd: BN;
561
- referencePrice: {
562
- price: BN;
563
- exponent: number;
564
- };
404
+ referencePrice: any;
565
405
  buffer: number[];
566
406
  priceImpactSet: number;
567
407
  sizeDecimals: number;
@@ -573,40 +413,9 @@ export declare class PerpetualsClient {
573
413
  getAllOrderAccounts: () => Promise<import("@coral-xyz/anchor").ProgramAccount<{
574
414
  owner: PublicKey;
575
415
  market: PublicKey;
576
- limitOrders: {
577
- limitPrice: {
578
- price: BN;
579
- exponent: number;
580
- };
581
- reserveAmount: BN;
582
- reserveCustodyUid: number;
583
- receiveCustodyUid: number;
584
- sizeAmount: BN;
585
- stopLossPrice: {
586
- price: BN;
587
- exponent: number;
588
- };
589
- takeProfitPrice: {
590
- price: BN;
591
- exponent: number;
592
- };
593
- }[];
594
- takeProfitOrders: {
595
- triggerPrice: {
596
- price: BN;
597
- exponent: number;
598
- };
599
- triggerSize: BN;
600
- receiveCustodyUid: number;
601
- }[];
602
- stopLossOrders: {
603
- triggerPrice: {
604
- price: BN;
605
- exponent: number;
606
- };
607
- triggerSize: BN;
608
- receiveCustodyUid: number;
609
- }[];
416
+ limitOrders: any[];
417
+ takeProfitOrders: any[];
418
+ stopLossOrders: any[];
610
419
  isInitialised: boolean;
611
420
  openOrders: number;
612
421
  openSl: number;
@@ -726,6 +535,20 @@ export declare class PerpetualsClient {
726
535
  };
727
536
  getIndexPriceAtParticularTime: (poolConfig: PoolConfig, targetPricesAtT1Ui: Number[], targetPricesAtT2Ui: Number[], tokenRatiosAtT2BN: BN[]) => string;
728
537
  getUserClaimableRevenueAmount: (POOL_CONFIG: PoolConfig, userPublicKey: PublicKey, enableDebuglogs?: boolean) => Promise<BN>;
538
+ getTokenStakeAccount: (poolConfig: PoolConfig, userPublicKey: PublicKey) => Promise<TokenStakeAccount | null>;
539
+ getUserUnstakingStatus: (poolConfig: PoolConfig, userPublicKey: PublicKey) => Promise<{
540
+ activeStakeAmount: BN;
541
+ totalLocked: BN;
542
+ totalWithdrawable: BN;
543
+ revenueEligibleAmount: BN;
544
+ requests: {
545
+ requestId: number;
546
+ lockedAmount: BN;
547
+ withdrawableAmount: BN;
548
+ timeRemaining: BN;
549
+ totalAmount: BN;
550
+ }[];
551
+ } | null>;
729
552
  getLpTokenPriceView: (poolConfig: PoolConfig, includeRemainingAccounts?: boolean) => Promise<any>;
730
553
  getStakedLpTokenPrice: (poolKey: PublicKey, POOL_CONFIG: PoolConfig, includeRemainingAccounts?: boolean) => Promise<string>;
731
554
  getCompoundingLPTokenPrice: (poolKey: PublicKey, POOL_CONFIG: PoolConfig, includeRemainingAccounts?: boolean) => Promise<string>;
@@ -862,15 +685,11 @@ export declare class PerpetualsClient {
862
685
  instructions: TransactionInstruction[];
863
686
  additionalSigners: Signer[];
864
687
  }>;
865
- unstakeTokenInstant: (owner: PublicKey, unstakeAmount: BN, poolConfig: PoolConfig) => Promise<{
866
- instructions: TransactionInstruction[];
867
- additionalSigners: Signer[];
868
- }>;
869
688
  withdrawToken: (owner: PublicKey, withdrawRequestId: number, poolConfig: PoolConfig) => Promise<{
870
689
  instructions: TransactionInstruction[];
871
690
  additionalSigners: Signer[];
872
691
  }>;
873
- cancelUnstakeRequest: (owner: PublicKey, withdrawRequestId: number, poolConfig: PoolConfig) => Promise<{
692
+ cancelUnstakeTokenRequest: (owner: PublicKey, withdrawRequestId: number, poolConfig: PoolConfig) => Promise<{
874
693
  instructions: TransactionInstruction[];
875
694
  additionalSigners: Signer[];
876
695
  }>;
@@ -882,6 +701,10 @@ export declare class PerpetualsClient {
882
701
  instructions: TransactionInstruction[];
883
702
  additionalSigners: Signer[];
884
703
  }>;
704
+ refreshTokenStake: (tokenStakeAccounts: PublicKey[], poolConfig: PoolConfig) => Promise<{
705
+ instructions: TransactionInstruction[];
706
+ additionalSigners: Signer[];
707
+ }>;
885
708
  collectRebate: (owner: PublicKey, rebateSymbol: string, poolConfig: PoolConfig, createUserATA?: boolean) => Promise<{
886
709
  instructions: TransactionInstruction[];
887
710
  additionalSigners: Signer[];
@@ -1003,7 +826,7 @@ export declare class PerpetualsClient {
1003
826
  instructions: TransactionInstruction[];
1004
827
  additionalSigners: Signer[];
1005
828
  }>;
1006
- setTokenVaultConfig: (token_permissions: TokenPermissions, withdrawTimeLimit: BN, withdrawInstantFee: BN, stakeLevel: BN[], poolConfig: PoolConfig) => Promise<{
829
+ setTokenVaultConfig: (token_permissions: TokenPermissions, withdrawTimeLimit: BN, withdrawInstantFee: BN, stakeLevel: BN[], unlockPeriod: BN, poolConfig: PoolConfig) => Promise<{
1007
830
  instructions: TransactionInstruction[];
1008
831
  additionalSigners: Signer[];
1009
832
  }>;