flash-sdk 12.0.4-alpha.0 → 12.1.0-alpha.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;
@@ -21,8 +24,6 @@ export interface PositionMetrics {
21
24
  profitUsd: BN;
22
25
  lossUsd: BN;
23
26
  priceImpactUsd: BN;
24
- maxPriceImpactUsd: BN;
25
- netProfitUsd: BN;
26
27
  };
27
28
  leverage: BN;
28
29
  liquidationPrice: OraclePrice;
@@ -77,79 +78,24 @@ export declare class PerpetualsClient {
77
78
  bump: number;
78
79
  };
79
80
  adjustTokenRatios: (ratios: TokenRatios[]) => TokenRatios[];
80
- getPerpetuals: () => Promise<{
81
- permissions: {
82
- allowSwap: boolean;
83
- allowAddLiquidity: boolean;
84
- allowRemoveLiquidity: boolean;
85
- allowOpenPosition: boolean;
86
- allowClosePosition: boolean;
87
- allowCollateralWithdrawal: boolean;
88
- allowSizeChange: boolean;
89
- allowLiquidation: boolean;
90
- allowLpStaking: boolean;
91
- allowFeeDistribution: boolean;
92
- allowUngatedTrading: boolean;
93
- allowFeeDiscounts: boolean;
94
- allowReferralRebates: boolean;
95
- };
96
- pools: PublicKey[];
97
- collections: PublicKey[];
98
- voltageMultiplier: {
99
- volume: BN;
100
- rewards: BN;
101
- rebates: BN;
102
- };
103
- tradingDiscount: BN[];
104
- referralRebate: BN[];
105
- defaultRebate: BN;
106
- inceptionTime: BN;
107
- transferAuthorityBump: number;
108
- perpetualsBump: number;
109
- tradeLimit: number;
110
- triggerOrderLimit: number;
111
- rebateLimitUsd: number;
112
- }>;
81
+ getPerpetuals: () => Promise<any>;
113
82
  getPoolKey: (name: string) => PublicKey;
114
83
  getPool: (name: string) => Promise<{
115
84
  name: string;
116
- permissions: {
117
- allowSwap: boolean;
118
- allowAddLiquidity: boolean;
119
- allowRemoveLiquidity: boolean;
120
- allowOpenPosition: boolean;
121
- allowClosePosition: boolean;
122
- allowCollateralWithdrawal: boolean;
123
- allowSizeChange: boolean;
124
- allowLiquidation: boolean;
125
- allowLpStaking: boolean;
126
- allowFeeDistribution: boolean;
127
- allowUngatedTrading: boolean;
128
- allowFeeDiscounts: boolean;
129
- allowReferralRebates: boolean;
130
- };
85
+ permissions: any;
131
86
  inceptionTime: BN;
132
87
  lpMint: PublicKey;
133
88
  oracleAuthority: PublicKey;
134
89
  stakedLpVault: PublicKey;
135
90
  rewardCustody: PublicKey;
136
91
  custodies: PublicKey[];
137
- ratios: {
138
- target: BN;
139
- min: BN;
140
- max: BN;
141
- }[];
92
+ ratios: any[];
142
93
  markets: PublicKey[];
143
94
  maxAumUsd: BN;
144
95
  buffer: BN;
145
96
  rawAumUsd: BN;
146
97
  equityUsd: BN;
147
- totalStaked: {
148
- pendingActivation: BN;
149
- activeAmount: BN;
150
- pendingDeactivation: BN;
151
- deactivatedAmount: BN;
152
- };
98
+ totalStaked: any;
153
99
  stakingFeeShareBps: BN;
154
100
  bump: number;
155
101
  lpMintBump: number;
@@ -160,13 +106,7 @@ export declare class PerpetualsClient {
160
106
  stakingFeeBoostBps: BN[];
161
107
  compoundingMint: PublicKey;
162
108
  compoundingLpVault: PublicKey;
163
- compoundingStats: {
164
- activeAmount: BN;
165
- totalSupply: BN;
166
- rewardSnapshot: BN;
167
- feeShareBps: BN;
168
- lastCompoundTime: BN;
169
- };
109
+ compoundingStats: any;
170
110
  compoundingMintBump: number;
171
111
  compoundingLpVaultBump: number;
172
112
  minLpPriceUsd: BN;
@@ -180,43 +120,20 @@ export declare class PerpetualsClient {
180
120
  }>;
181
121
  getPools: () => Promise<{
182
122
  name: string;
183
- permissions: {
184
- allowSwap: boolean;
185
- allowAddLiquidity: boolean;
186
- allowRemoveLiquidity: boolean;
187
- allowOpenPosition: boolean;
188
- allowClosePosition: boolean;
189
- allowCollateralWithdrawal: boolean;
190
- allowSizeChange: boolean;
191
- allowLiquidation: boolean;
192
- allowLpStaking: boolean;
193
- allowFeeDistribution: boolean;
194
- allowUngatedTrading: boolean;
195
- allowFeeDiscounts: boolean;
196
- allowReferralRebates: boolean;
197
- };
123
+ permissions: any;
198
124
  inceptionTime: BN;
199
125
  lpMint: PublicKey;
200
126
  oracleAuthority: PublicKey;
201
127
  stakedLpVault: PublicKey;
202
128
  rewardCustody: PublicKey;
203
129
  custodies: PublicKey[];
204
- ratios: {
205
- target: BN;
206
- min: BN;
207
- max: BN;
208
- }[];
130
+ ratios: any[];
209
131
  markets: PublicKey[];
210
132
  maxAumUsd: BN;
211
133
  buffer: BN;
212
134
  rawAumUsd: BN;
213
135
  equityUsd: BN;
214
- totalStaked: {
215
- pendingActivation: BN;
216
- activeAmount: BN;
217
- pendingDeactivation: BN;
218
- deactivatedAmount: BN;
219
- };
136
+ totalStaked: any;
220
137
  stakingFeeShareBps: BN;
221
138
  bump: number;
222
139
  lpMintBump: number;
@@ -227,13 +144,7 @@ export declare class PerpetualsClient {
227
144
  stakingFeeBoostBps: BN[];
228
145
  compoundingMint: PublicKey;
229
146
  compoundingLpVault: PublicKey;
230
- compoundingStats: {
231
- activeAmount: BN;
232
- totalSupply: BN;
233
- rewardSnapshot: BN;
234
- feeShareBps: BN;
235
- lastCompoundTime: BN;
236
- };
147
+ compoundingStats: any;
237
148
  compoundingMintBump: number;
238
149
  compoundingLpVaultBump: number;
239
150
  minLpPriceUsd: BN;
@@ -258,10 +169,7 @@ export declare class PerpetualsClient {
258
169
  delegate: PublicKey;
259
170
  openTime: BN;
260
171
  updateTime: BN;
261
- entryPrice: {
262
- price: BN;
263
- exponent: number;
264
- };
172
+ entryPrice: any;
265
173
  sizeAmount: BN;
266
174
  sizeUsd: BN;
267
175
  lockedAmount: BN;
@@ -272,10 +180,7 @@ export declare class PerpetualsClient {
272
180
  unsettledFeesUsd: BN;
273
181
  cumulativeLockFeeSnapshot: BN;
274
182
  degenSizeUsd: BN;
275
- referencePrice: {
276
- price: BN;
277
- exponent: number;
278
- };
183
+ referencePrice: any;
279
184
  buffer: number[];
280
185
  priceImpactSet: number;
281
186
  sizeDecimals: number;
@@ -288,40 +193,9 @@ export declare class PerpetualsClient {
288
193
  getOrderAccount: (orderAccountKey: PublicKey) => Promise<{
289
194
  owner: PublicKey;
290
195
  market: PublicKey;
291
- limitOrders: {
292
- limitPrice: {
293
- price: BN;
294
- exponent: number;
295
- };
296
- reserveAmount: BN;
297
- reserveCustodyUid: number;
298
- receiveCustodyUid: number;
299
- sizeAmount: BN;
300
- stopLossPrice: {
301
- price: BN;
302
- exponent: number;
303
- };
304
- takeProfitPrice: {
305
- price: BN;
306
- exponent: number;
307
- };
308
- }[];
309
- takeProfitOrders: {
310
- triggerPrice: {
311
- price: BN;
312
- exponent: number;
313
- };
314
- triggerSize: BN;
315
- receiveCustodyUid: number;
316
- }[];
317
- stopLossOrders: {
318
- triggerPrice: {
319
- price: BN;
320
- exponent: number;
321
- };
322
- triggerSize: BN;
323
- receiveCustodyUid: number;
324
- }[];
196
+ limitOrders: any[];
197
+ takeProfitOrders: any[];
198
+ stopLossOrders: any[];
325
199
  isInitialised: boolean;
326
200
  openOrders: number;
327
201
  openSl: number;
@@ -340,10 +214,7 @@ export declare class PerpetualsClient {
340
214
  delegate: PublicKey;
341
215
  openTime: BN;
342
216
  updateTime: BN;
343
- entryPrice: {
344
- price: BN;
345
- exponent: number;
346
- };
217
+ entryPrice: any;
347
218
  sizeAmount: BN;
348
219
  sizeUsd: BN;
349
220
  lockedAmount: BN;
@@ -354,10 +225,7 @@ export declare class PerpetualsClient {
354
225
  unsettledFeesUsd: BN;
355
226
  cumulativeLockFeeSnapshot: BN;
356
227
  degenSizeUsd: BN;
357
- referencePrice: {
358
- price: BN;
359
- exponent: number;
360
- };
228
+ referencePrice: any;
361
229
  buffer: number[];
362
230
  priceImpactSet: number;
363
231
  sizeDecimals: number;
@@ -372,10 +240,7 @@ export declare class PerpetualsClient {
372
240
  delegate: PublicKey;
373
241
  openTime: BN;
374
242
  updateTime: BN;
375
- entryPrice: {
376
- price: BN;
377
- exponent: number;
378
- };
243
+ entryPrice: any;
379
244
  sizeAmount: BN;
380
245
  sizeUsd: BN;
381
246
  lockedAmount: BN;
@@ -386,10 +251,7 @@ export declare class PerpetualsClient {
386
251
  unsettledFeesUsd: BN;
387
252
  cumulativeLockFeeSnapshot: BN;
388
253
  degenSizeUsd: BN;
389
- referencePrice: {
390
- price: BN;
391
- exponent: number;
392
- };
254
+ referencePrice: any;
393
255
  buffer: number[];
394
256
  priceImpactSet: number;
395
257
  sizeDecimals: number;
@@ -450,10 +312,7 @@ export declare class PerpetualsClient {
450
312
  delegate: PublicKey;
451
313
  openTime: BN;
452
314
  updateTime: BN;
453
- entryPrice: {
454
- price: BN;
455
- exponent: number;
456
- };
315
+ entryPrice: any;
457
316
  sizeAmount: BN;
458
317
  sizeUsd: BN;
459
318
  lockedAmount: BN;
@@ -464,10 +323,7 @@ export declare class PerpetualsClient {
464
323
  unsettledFeesUsd: BN;
465
324
  cumulativeLockFeeSnapshot: BN;
466
325
  degenSizeUsd: BN;
467
- referencePrice: {
468
- price: BN;
469
- exponent: number;
470
- };
326
+ referencePrice: any;
471
327
  buffer: number[];
472
328
  priceImpactSet: number;
473
329
  sizeDecimals: number;
@@ -482,10 +338,7 @@ export declare class PerpetualsClient {
482
338
  delegate: PublicKey;
483
339
  openTime: BN;
484
340
  updateTime: BN;
485
- entryPrice: {
486
- price: BN;
487
- exponent: number;
488
- };
341
+ entryPrice: any;
489
342
  sizeAmount: BN;
490
343
  sizeUsd: BN;
491
344
  lockedAmount: BN;
@@ -496,10 +349,7 @@ export declare class PerpetualsClient {
496
349
  unsettledFeesUsd: BN;
497
350
  cumulativeLockFeeSnapshot: BN;
498
351
  degenSizeUsd: BN;
499
- referencePrice: {
500
- price: BN;
501
- exponent: number;
502
- };
352
+ referencePrice: any;
503
353
  buffer: number[];
504
354
  priceImpactSet: number;
505
355
  sizeDecimals: number;
@@ -514,10 +364,7 @@ export declare class PerpetualsClient {
514
364
  delegate: PublicKey;
515
365
  openTime: BN;
516
366
  updateTime: BN;
517
- entryPrice: {
518
- price: BN;
519
- exponent: number;
520
- };
367
+ entryPrice: any;
521
368
  sizeAmount: BN;
522
369
  sizeUsd: BN;
523
370
  lockedAmount: BN;
@@ -528,10 +375,7 @@ export declare class PerpetualsClient {
528
375
  unsettledFeesUsd: BN;
529
376
  cumulativeLockFeeSnapshot: BN;
530
377
  degenSizeUsd: BN;
531
- referencePrice: {
532
- price: BN;
533
- exponent: number;
534
- };
378
+ referencePrice: any;
535
379
  buffer: number[];
536
380
  priceImpactSet: number;
537
381
  sizeDecimals: number;
@@ -546,10 +390,7 @@ export declare class PerpetualsClient {
546
390
  delegate: PublicKey;
547
391
  openTime: BN;
548
392
  updateTime: BN;
549
- entryPrice: {
550
- price: BN;
551
- exponent: number;
552
- };
393
+ entryPrice: any;
553
394
  sizeAmount: BN;
554
395
  sizeUsd: BN;
555
396
  lockedAmount: BN;
@@ -560,10 +401,7 @@ export declare class PerpetualsClient {
560
401
  unsettledFeesUsd: BN;
561
402
  cumulativeLockFeeSnapshot: BN;
562
403
  degenSizeUsd: BN;
563
- referencePrice: {
564
- price: BN;
565
- exponent: number;
566
- };
404
+ referencePrice: any;
567
405
  buffer: number[];
568
406
  priceImpactSet: number;
569
407
  sizeDecimals: number;
@@ -575,40 +413,9 @@ export declare class PerpetualsClient {
575
413
  getAllOrderAccounts: () => Promise<import("@coral-xyz/anchor").ProgramAccount<{
576
414
  owner: PublicKey;
577
415
  market: PublicKey;
578
- limitOrders: {
579
- limitPrice: {
580
- price: BN;
581
- exponent: number;
582
- };
583
- reserveAmount: BN;
584
- reserveCustodyUid: number;
585
- receiveCustodyUid: number;
586
- sizeAmount: BN;
587
- stopLossPrice: {
588
- price: BN;
589
- exponent: number;
590
- };
591
- takeProfitPrice: {
592
- price: BN;
593
- exponent: number;
594
- };
595
- }[];
596
- takeProfitOrders: {
597
- triggerPrice: {
598
- price: BN;
599
- exponent: number;
600
- };
601
- triggerSize: BN;
602
- receiveCustodyUid: number;
603
- }[];
604
- stopLossOrders: {
605
- triggerPrice: {
606
- price: BN;
607
- exponent: number;
608
- };
609
- triggerSize: BN;
610
- receiveCustodyUid: number;
611
- }[];
416
+ limitOrders: any[];
417
+ takeProfitOrders: any[];
418
+ stopLossOrders: any[];
612
419
  isInitialised: boolean;
613
420
  openOrders: number;
614
421
  openSl: number;
@@ -693,15 +500,11 @@ export declare class PerpetualsClient {
693
500
  profitUsd: BN;
694
501
  lossUsd: BN;
695
502
  priceImpactUsd: BN;
696
- maxPriceImpactUsd: BN;
697
- netProfitUsd: BN;
698
503
  };
699
504
  getPnlContractHelper: (positionAccount: PositionAccount, targetTokenPrice: OraclePrice, targetTokenEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN, delay: BN, poolConfig: PoolConfig) => {
700
505
  profitUsd: BN;
701
506
  lossUsd: BN;
702
507
  priceImpactUsd: BN;
703
- maxPriceImpactUsd: BN;
704
- netProfitUsd: BN;
705
508
  };
706
509
  getPositionMetrics: (positionAccount: PositionAccount, targetTokenPrice: OraclePrice, targetTokenEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN, poolConfig: PoolConfig) => PositionMetrics;
707
510
  getPositionsMetricsBatch: (positions: Array<{
@@ -732,6 +535,20 @@ export declare class PerpetualsClient {
732
535
  };
733
536
  getIndexPriceAtParticularTime: (poolConfig: PoolConfig, targetPricesAtT1Ui: Number[], targetPricesAtT2Ui: Number[], tokenRatiosAtT2BN: BN[]) => string;
734
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>;
735
552
  getLpTokenPriceView: (poolConfig: PoolConfig, includeRemainingAccounts?: boolean) => Promise<any>;
736
553
  getStakedLpTokenPrice: (poolKey: PublicKey, POOL_CONFIG: PoolConfig, includeRemainingAccounts?: boolean) => Promise<string>;
737
554
  getCompoundingLPTokenPrice: (poolKey: PublicKey, POOL_CONFIG: PoolConfig, includeRemainingAccounts?: boolean) => Promise<string>;
@@ -864,15 +681,11 @@ export declare class PerpetualsClient {
864
681
  instructions: TransactionInstruction[];
865
682
  additionalSigners: Signer[];
866
683
  }>;
867
- unstakeTokenInstant: (owner: PublicKey, unstakeAmount: BN, poolConfig: PoolConfig) => Promise<{
868
- instructions: TransactionInstruction[];
869
- additionalSigners: Signer[];
870
- }>;
871
684
  withdrawToken: (owner: PublicKey, withdrawRequestId: number, poolConfig: PoolConfig) => Promise<{
872
685
  instructions: TransactionInstruction[];
873
686
  additionalSigners: Signer[];
874
687
  }>;
875
- cancelUnstakeRequest: (owner: PublicKey, withdrawRequestId: number, poolConfig: PoolConfig) => Promise<{
688
+ cancelUnstakeTokenRequest: (owner: PublicKey, withdrawRequestId: number, poolConfig: PoolConfig) => Promise<{
876
689
  instructions: TransactionInstruction[];
877
690
  additionalSigners: Signer[];
878
691
  }>;
@@ -884,6 +697,10 @@ export declare class PerpetualsClient {
884
697
  instructions: TransactionInstruction[];
885
698
  additionalSigners: Signer[];
886
699
  }>;
700
+ refreshTokenStake: (tokenStakeOwners: PublicKey[], poolConfig: PoolConfig) => Promise<{
701
+ instructions: TransactionInstruction[];
702
+ additionalSigners: Signer[];
703
+ }>;
887
704
  collectRebate: (owner: PublicKey, rebateSymbol: string, poolConfig: PoolConfig, createUserATA?: boolean) => Promise<{
888
705
  instructions: TransactionInstruction[];
889
706
  additionalSigners: Signer[];