@0dotxyz/p0-ts-sdk 2.3.2 → 2.4.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.
@@ -0,0 +1,860 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ import BN from 'bn.js';
3
+
4
+ /**
5
+ * Curated Kamino Reserve used throughout the codebase.
6
+ *
7
+ * Contains only the fields the SDK reads: market/farm addresses, the
8
+ * liquidity and collateral state needed for cToken exchange rates and
9
+ * deposit/withdraw instructions, and the config subset used for interest
10
+ * rates and oracle refreshes.
11
+ */
12
+ interface KaminoReserve {
13
+ /** Lending market address */
14
+ lendingMarket: PublicKey;
15
+ farmCollateral: PublicKey;
16
+ /** Reserve liquidity */
17
+ liquidity: KaminoReserveLiquidity;
18
+ /** Reserve collateral */
19
+ collateral: KaminoReserveCollateral;
20
+ /** Reserve configuration values */
21
+ config: KaminoReserveConfig;
22
+ }
23
+ interface KaminoReserveLiquidity {
24
+ /** Reserve liquidity mint address */
25
+ mintPubkey: PublicKey;
26
+ /** Reserve liquidity supply address */
27
+ supplyVault: PublicKey;
28
+ /** Reserve liquidity mint decimals */
29
+ mintDecimals: BN;
30
+ /** Reserve liquidity available */
31
+ availableAmount: BN;
32
+ /** Reserve liquidity borrowed (scaled fraction) */
33
+ borrowedAmountSf: BN;
34
+ /** Reserve cumulative protocol fees (scaled fraction) */
35
+ accumulatedProtocolFeesSf: BN;
36
+ /** Reserve cumulative referrer fees (scaled fraction) */
37
+ accumulatedReferrerFeesSf: BN;
38
+ /** Reserve pending referrer fees, to be claimed in refresh_obligation by referrer or protocol (scaled fraction) */
39
+ pendingReferrerFeesSf: BN;
40
+ }
41
+ interface KaminoReserveCollateral {
42
+ /** Reserve collateral mint address */
43
+ mintPubkey: PublicKey;
44
+ /** Reserve collateral mint supply, used for exchange rate */
45
+ mintTotalSupply: BN;
46
+ /** Reserve collateral supply address */
47
+ supplyVault: PublicKey;
48
+ }
49
+ interface KaminoReserveConfig {
50
+ /** Protocol take rate is the amount borrowed interest protocol receives, as a percentage */
51
+ protocolTakeRatePct: number;
52
+ /** Flat rate that goes to the host */
53
+ hostFixedInterestRateBps: number;
54
+ /** Borrow rate curve based on utilization */
55
+ borrowRateCurve: KaminoBorrowRateCurve;
56
+ /** Oracle configurations */
57
+ tokenInfo: KaminoReserveTokenInfo;
58
+ }
59
+ interface KaminoBorrowRateCurve {
60
+ points: Array<KaminoBorrowRateCurvePoint>;
61
+ }
62
+ interface KaminoBorrowRateCurvePoint {
63
+ utilizationRateBps: number;
64
+ borrowRateBps: number;
65
+ }
66
+ interface KaminoReserveTokenInfo {
67
+ /** Scope price configuration */
68
+ scopeConfiguration: KaminoScopeConfiguration;
69
+ /** Switchboard configuration */
70
+ switchboardConfiguration: KaminoSwitchboardConfiguration;
71
+ /** Pyth configuration */
72
+ pythConfiguration: KaminoPythConfiguration;
73
+ }
74
+ interface KaminoScopeConfiguration {
75
+ /** Pubkey of the scope price feed (disabled if `null` or `default`) */
76
+ priceFeed: PublicKey;
77
+ }
78
+ interface KaminoSwitchboardConfiguration {
79
+ /** Pubkey of the base price feed (disabled if `null` or `default`) */
80
+ priceAggregator: PublicKey;
81
+ twapAggregator: PublicKey;
82
+ }
83
+ interface KaminoPythConfiguration {
84
+ /** Pubkey of the base price feed (disabled if `null` or `default`) */
85
+ price: PublicKey;
86
+ }
87
+
88
+ /**
89
+ * JSON-serializable DTOs for the curated Kamino Reserve.
90
+ * PublicKey → string, BN → string.
91
+ */
92
+ interface KaminoReserveJSON {
93
+ lendingMarket: string;
94
+ farmCollateral: string;
95
+ liquidity: KaminoReserveLiquidityJSON;
96
+ collateral: KaminoReserveCollateralJSON;
97
+ config: KaminoReserveConfigJSON;
98
+ }
99
+ interface KaminoReserveLiquidityJSON {
100
+ mintPubkey: string;
101
+ supplyVault: string;
102
+ mintDecimals: string;
103
+ availableAmount: string;
104
+ borrowedAmountSf: string;
105
+ accumulatedProtocolFeesSf: string;
106
+ accumulatedReferrerFeesSf: string;
107
+ pendingReferrerFeesSf: string;
108
+ }
109
+ interface KaminoReserveCollateralJSON {
110
+ mintPubkey: string;
111
+ mintTotalSupply: string;
112
+ supplyVault: string;
113
+ }
114
+ interface KaminoReserveConfigJSON {
115
+ protocolTakeRatePct: number;
116
+ hostFixedInterestRateBps: number;
117
+ borrowRateCurve: KaminoBorrowRateCurveJSON;
118
+ tokenInfo: KaminoReserveTokenInfoJSON;
119
+ }
120
+ interface KaminoBorrowRateCurveJSON {
121
+ points: Array<KaminoBorrowRateCurvePointJSON>;
122
+ }
123
+ interface KaminoBorrowRateCurvePointJSON {
124
+ utilizationRateBps: number;
125
+ borrowRateBps: number;
126
+ }
127
+ interface KaminoReserveTokenInfoJSON {
128
+ scopeConfiguration: KaminoScopeConfigurationJSON;
129
+ switchboardConfiguration: KaminoSwitchboardConfigurationJSON;
130
+ pythConfiguration: KaminoPythConfigurationJSON;
131
+ }
132
+ interface KaminoScopeConfigurationJSON {
133
+ priceFeed: string;
134
+ }
135
+ interface KaminoSwitchboardConfigurationJSON {
136
+ priceAggregator: string;
137
+ twapAggregator: string;
138
+ }
139
+ interface KaminoPythConfigurationJSON {
140
+ price: string;
141
+ }
142
+
143
+ /**
144
+ * Curated Kamino Obligation used throughout the codebase.
145
+ *
146
+ * Keeps only the position data: owner, market, and the deposit/borrow
147
+ * slots (fixed-size arrays on-chain, mapped 1:1 without filtering).
148
+ */
149
+ interface KaminoObligation {
150
+ /** Lending market address */
151
+ lendingMarket: PublicKey;
152
+ /** Owner authority which can borrow liquidity */
153
+ owner: PublicKey;
154
+ /** Deposited collateral for the obligation, unique by deposit reserve address */
155
+ deposits: Array<KaminoObligationCollateral>;
156
+ /** Borrowed liquidity for the obligation, unique by borrow reserve address */
157
+ borrows: Array<KaminoObligationLiquidity>;
158
+ }
159
+ interface KaminoObligationCollateral {
160
+ /** Reserve collateral is deposited to */
161
+ depositReserve: PublicKey;
162
+ /** Amount of collateral deposited */
163
+ depositedAmount: BN;
164
+ /** Collateral market value in quote currency (scaled fraction) */
165
+ marketValueSf: BN;
166
+ }
167
+ interface KaminoObligationLiquidity {
168
+ /** Reserve liquidity is borrowed from */
169
+ borrowReserve: PublicKey;
170
+ /** Amount of liquidity borrowed plus interest (scaled fraction) */
171
+ borrowedAmountSf: BN;
172
+ /** Liquidity market value in quote currency (scaled fraction) */
173
+ marketValueSf: BN;
174
+ }
175
+
176
+ /**
177
+ * JSON-serializable DTOs for the curated Kamino Obligation.
178
+ * PublicKey → string, BN → string.
179
+ */
180
+ interface KaminoObligationJSON {
181
+ lendingMarket: string;
182
+ owner: string;
183
+ deposits: Array<KaminoObligationCollateralJSON>;
184
+ borrows: Array<KaminoObligationLiquidityJSON>;
185
+ }
186
+ interface KaminoObligationCollateralJSON {
187
+ depositReserve: string;
188
+ depositedAmount: string;
189
+ marketValueSf: string;
190
+ }
191
+ interface KaminoObligationLiquidityJSON {
192
+ borrowReserve: string;
193
+ borrowedAmountSf: string;
194
+ marketValueSf: string;
195
+ }
196
+
197
+ /**
198
+ * Curated Kamino FarmState used throughout the codebase.
199
+ *
200
+ * Keeps only the staked token identity and the reward schedule data
201
+ * needed to compute reward APYs.
202
+ */
203
+ interface KaminoFarmState {
204
+ token: KaminoFarmTokenInfo;
205
+ rewardInfos: Array<KaminoFarmRewardInfo>;
206
+ }
207
+ interface KaminoFarmTokenInfo {
208
+ mint: PublicKey;
209
+ decimals: BN;
210
+ }
211
+ interface KaminoFarmRewardInfo {
212
+ token: KaminoFarmTokenInfo;
213
+ rewardsPerSecondDecimals: number;
214
+ rewardScheduleCurve: KaminoRewardScheduleCurve;
215
+ }
216
+ interface KaminoRewardScheduleCurve {
217
+ /**
218
+ * This is a stepwise function, meaning that each point represents
219
+ * how many rewards are issued per time unit since the beginning
220
+ * of that point until the beginning of the next point.
221
+ */
222
+ points: Array<KaminoRewardCurvePoint>;
223
+ }
224
+ interface KaminoRewardCurvePoint {
225
+ tsStart: BN;
226
+ rewardPerTimeUnit: BN;
227
+ }
228
+
229
+ /**
230
+ * JSON-serializable DTOs for the curated Kamino FarmState.
231
+ * PublicKey → string, BN → string.
232
+ */
233
+ interface KaminoFarmStateJSON {
234
+ token: KaminoFarmTokenInfoJSON;
235
+ rewardInfos: Array<KaminoFarmRewardInfoJSON>;
236
+ }
237
+ interface KaminoFarmTokenInfoJSON {
238
+ mint: string;
239
+ decimals: string;
240
+ }
241
+ interface KaminoFarmRewardInfoJSON {
242
+ token: KaminoFarmTokenInfoJSON;
243
+ rewardsPerSecondDecimals: number;
244
+ rewardScheduleCurve: KaminoRewardScheduleCurveJSON;
245
+ }
246
+ interface KaminoRewardScheduleCurveJSON {
247
+ points: Array<KaminoRewardCurvePointJSON>;
248
+ }
249
+ interface KaminoRewardCurvePointJSON {
250
+ tsStart: string;
251
+ rewardPerTimeUnit: string;
252
+ }
253
+
254
+ interface DriftUserStatsJSON {
255
+ /** The authority for all of a users sub accounts */
256
+ authority: string;
257
+ /** The address that referred this user */
258
+ referrer: string;
259
+ /** Stats on the fees paid by the user */
260
+ fees: UserFeesJSON;
261
+ /**
262
+ * The timestamp of the next epoch
263
+ * Epoch is used to limit referrer rewards earned in single epoch
264
+ */
265
+ nextEpochTs: string;
266
+ /**
267
+ * Rolling 30day maker volume for user
268
+ * precision: QUOTE_PRECISION
269
+ */
270
+ makerVolume30d: string;
271
+ /**
272
+ * Rolling 30day taker volume for user
273
+ * precision: QUOTE_PRECISION
274
+ */
275
+ takerVolume30d: string;
276
+ /**
277
+ * Rolling 30day filler volume for user
278
+ * precision: QUOTE_PRECISION
279
+ */
280
+ fillerVolume30d: string;
281
+ /** last time the maker volume was updated */
282
+ lastMakerVolume30dTs: string;
283
+ /** last time the taker volume was updated */
284
+ lastTakerVolume30dTs: string;
285
+ /** last time the filler volume was updated */
286
+ lastFillerVolume30dTs: string;
287
+ /** The amount of tokens staked in the quote spot markets if */
288
+ ifStakedQuoteAssetAmount: string;
289
+ /** The current number of sub accounts */
290
+ numberOfSubAccounts: number;
291
+ /**
292
+ * The number of sub accounts created. Can be greater than the number of sub accounts if user
293
+ * has deleted sub accounts
294
+ */
295
+ numberOfSubAccountsCreated: number;
296
+ /**
297
+ * Flags for referrer status:
298
+ * First bit (LSB): 1 if user is a referrer, 0 otherwise
299
+ * Second bit: 1 if user was referred, 0 otherwise
300
+ */
301
+ referrerStatus: number;
302
+ disableUpdatePerpBidAskTwap: boolean;
303
+ padding1: Array<number>;
304
+ /** whether the user has a FuelOverflow account */
305
+ fuelOverflowStatus: number;
306
+ /** accumulated fuel for token amounts of insurance */
307
+ fuelInsurance: number;
308
+ /** accumulated fuel for notional of deposits */
309
+ fuelDeposits: number;
310
+ /** accumulate fuel bonus for notional of borrows */
311
+ fuelBorrows: number;
312
+ /** accumulated fuel for perp open interest */
313
+ fuelPositions: number;
314
+ /** accumulate fuel bonus for taker volume */
315
+ fuelTaker: number;
316
+ /** accumulate fuel bonus for maker volume */
317
+ fuelMaker: number;
318
+ /** The amount of tokens staked in the governance spot markets if */
319
+ ifStakedGovTokenAmount: string;
320
+ /**
321
+ * last unix ts user stats data was used to update if fuel (u32 to save space)
322
+ */
323
+ lastFuelIfBonusUpdateTs: number;
324
+ padding: Array<number>;
325
+ }
326
+ interface UserFeesJSON {
327
+ /**
328
+ * Total taker fee paid
329
+ * precision: QUOTE_PRECISION
330
+ */
331
+ totalFeePaid: string;
332
+ /**
333
+ * Total maker fee rebate
334
+ * precision: QUOTE_PRECISION
335
+ */
336
+ totalFeeRebate: string;
337
+ /**
338
+ * Total discount from holding token
339
+ * precision: QUOTE_PRECISION
340
+ */
341
+ totalTokenDiscount: string;
342
+ /**
343
+ * Total discount from being referred
344
+ * precision: QUOTE_PRECISION
345
+ */
346
+ totalRefereeDiscount: string;
347
+ /**
348
+ * Total reward to referrer
349
+ * precision: QUOTE_PRECISION
350
+ */
351
+ totalReferrerReward: string;
352
+ /**
353
+ * Total reward to referrer this epoch
354
+ * precision: QUOTE_PRECISION
355
+ */
356
+ currentEpochReferrerReward: string;
357
+ }
358
+
359
+ interface DriftUserStats {
360
+ authority: PublicKey;
361
+ referrer: PublicKey;
362
+ fees: UserFeesFields;
363
+ nextEpochTs: BN;
364
+ makerVolume30d: BN;
365
+ takerVolume30d: BN;
366
+ fillerVolume30d: BN;
367
+ lastMakerVolume30dTs: BN;
368
+ lastTakerVolume30dTs: BN;
369
+ lastFillerVolume30dTs: BN;
370
+ ifStakedQuoteAssetAmount: BN;
371
+ numberOfSubAccounts: number;
372
+ numberOfSubAccountsCreated: number;
373
+ referrerStatus: number;
374
+ disableUpdatePerpBidAskTwap: boolean;
375
+ padding1: Array<number>;
376
+ fuelOverflowStatus: number;
377
+ fuelInsurance: number;
378
+ fuelDeposits: number;
379
+ fuelBorrows: number;
380
+ fuelPositions: number;
381
+ fuelTaker: number;
382
+ fuelMaker: number;
383
+ ifStakedGovTokenAmount: BN;
384
+ lastFuelIfBonusUpdateTs: number;
385
+ padding: Array<number>;
386
+ }
387
+ interface UserFeesFields {
388
+ totalFeePaid: BN;
389
+ totalFeeRebate: BN;
390
+ totalTokenDiscount: BN;
391
+ totalRefereeDiscount: BN;
392
+ totalReferrerReward: BN;
393
+ currentEpochReferrerReward: BN;
394
+ }
395
+
396
+ interface DriftSpotMarketJSON {
397
+ pubkey: string;
398
+ oracle: string;
399
+ mint: string;
400
+ decimals: number;
401
+ cumulativeDepositInterest: string;
402
+ marketIndex: number;
403
+ depositBalance: string;
404
+ borrowBalance: string;
405
+ cumulativeBorrowInterest: string;
406
+ optimalUtilization: number;
407
+ optimalBorrowRate: number;
408
+ maxBorrowRate: number;
409
+ minBorrowRate: number;
410
+ insuranceFund: {
411
+ totalFactor: number;
412
+ };
413
+ poolId: number;
414
+ }
415
+
416
+ interface FeeStructure {
417
+ feeTiers: Array<FeeTier>;
418
+ fillerRewardStructure: OrderFillerRewardStructure;
419
+ referrerRewardEpochUpperBound: BN;
420
+ flatFillerFee: BN;
421
+ }
422
+ interface FeeStructureJSON {
423
+ feeTiers: Array<FeeTierJSON>;
424
+ fillerRewardStructure: OrderFillerRewardStructureJSON;
425
+ referrerRewardEpochUpperBound: string;
426
+ flatFillerFee: string;
427
+ }
428
+ interface FeeTier {
429
+ feeNumerator: number;
430
+ feeDenominator: number;
431
+ makerRebateNumerator: number;
432
+ makerRebateDenominator: number;
433
+ referrerRewardNumerator: number;
434
+ referrerRewardDenominator: number;
435
+ refereeFeeNumerator: number;
436
+ refereeFeeDenominator: number;
437
+ }
438
+ interface FeeTierJSON {
439
+ feeNumerator: number;
440
+ feeDenominator: number;
441
+ makerRebateNumerator: number;
442
+ makerRebateDenominator: number;
443
+ referrerRewardNumerator: number;
444
+ referrerRewardDenominator: number;
445
+ refereeFeeNumerator: number;
446
+ refereeFeeDenominator: number;
447
+ }
448
+ interface OrderFillerRewardStructure {
449
+ rewardNumerator: number;
450
+ rewardDenominator: number;
451
+ timeBasedRewardLowerBound: BN;
452
+ }
453
+ interface OrderFillerRewardStructureJSON {
454
+ rewardNumerator: number;
455
+ rewardDenominator: number;
456
+ timeBasedRewardLowerBound: string;
457
+ }
458
+ interface OracleGuardRails {
459
+ priceDivergence: PriceDivergenceGuardRails;
460
+ validity: ValidityGuardRails;
461
+ }
462
+ interface OracleGuardRailsJSON {
463
+ priceDivergence: PriceDivergenceGuardRailsJSON;
464
+ validity: ValidityGuardRailsJSON;
465
+ }
466
+ interface PriceDivergenceGuardRails {
467
+ markOraclePercentDivergence: BN;
468
+ oracleTwap5minPercentDivergence: BN;
469
+ }
470
+ interface PriceDivergenceGuardRailsJSON {
471
+ markOraclePercentDivergence: string;
472
+ oracleTwap5minPercentDivergence: string;
473
+ }
474
+ interface ValidityGuardRails {
475
+ slotsBeforeStaleForAmm: BN;
476
+ slotsBeforeStaleForMargin: BN;
477
+ confidenceIntervalMaxSize: BN;
478
+ tooVolatileRatio: BN;
479
+ }
480
+ interface ValidityGuardRailsJSON {
481
+ slotsBeforeStaleForAmm: string;
482
+ slotsBeforeStaleForMargin: string;
483
+ confidenceIntervalMaxSize: string;
484
+ tooVolatileRatio: string;
485
+ }
486
+ interface HistoricalOracleData {
487
+ /** precision: PRICE_PRECISION */
488
+ lastOraclePrice: BN;
489
+ /** precision: PRICE_PRECISION */
490
+ lastOracleConf: BN;
491
+ /** number of slots since last update */
492
+ lastOracleDelay: BN;
493
+ /** precision: PRICE_PRECISION */
494
+ lastOraclePriceTwap: BN;
495
+ /** precision: PRICE_PRECISION */
496
+ lastOraclePriceTwap5min: BN;
497
+ /** unix_timestamp of last snapshot */
498
+ lastOraclePriceTwapTs: BN;
499
+ }
500
+ interface HistoricalOracleDataJSON {
501
+ /** precision: PRICE_PRECISION */
502
+ lastOraclePrice: string;
503
+ /** precision: PRICE_PRECISION */
504
+ lastOracleConf: string;
505
+ /** number of slots since last update */
506
+ lastOracleDelay: string;
507
+ /** precision: PRICE_PRECISION */
508
+ lastOraclePriceTwap: string;
509
+ /** precision: PRICE_PRECISION */
510
+ lastOraclePriceTwap5min: string;
511
+ /** unix_timestamp of last snapshot */
512
+ lastOraclePriceTwapTs: string;
513
+ }
514
+ interface HistoricalIndexData {
515
+ /** precision: PRICE_PRECISION */
516
+ lastIndexBidPrice: BN;
517
+ /** precision: PRICE_PRECISION */
518
+ lastIndexAskPrice: BN;
519
+ /** precision: PRICE_PRECISION */
520
+ lastIndexPriceTwap: BN;
521
+ /** precision: PRICE_PRECISION */
522
+ lastIndexPriceTwap5min: BN;
523
+ /** unix_timestamp of last snapshot */
524
+ lastIndexPriceTwapTs: BN;
525
+ }
526
+ interface HistoricalIndexDataJSON {
527
+ /** precision: PRICE_PRECISION */
528
+ lastIndexBidPrice: string;
529
+ /** precision: PRICE_PRECISION */
530
+ lastIndexAskPrice: string;
531
+ /** precision: PRICE_PRECISION */
532
+ lastIndexPriceTwap: string;
533
+ /** precision: PRICE_PRECISION */
534
+ lastIndexPriceTwap5min: string;
535
+ /** unix_timestamp of last snapshot */
536
+ lastIndexPriceTwapTs: string;
537
+ }
538
+ interface PoolBalance {
539
+ /**
540
+ * To get the pool's token amount, you must multiply the scaled balance by the market's cumulative
541
+ * deposit interest
542
+ * precision: SPOT_BALANCE_PRECISION
543
+ */
544
+ scaledBalance: BN;
545
+ /** The spot market the pool is for */
546
+ marketIndex: number;
547
+ padding: Array<number>;
548
+ }
549
+ interface PoolBalanceJSON {
550
+ /**
551
+ * To get the pool's token amount, you must multiply the scaled balance by the market's cumulative
552
+ * deposit interest
553
+ * precision: SPOT_BALANCE_PRECISION
554
+ */
555
+ scaledBalance: string;
556
+ /** The spot market the pool is for */
557
+ marketIndex: number;
558
+ padding: Array<number>;
559
+ }
560
+ interface InsuranceFund {
561
+ vault: PublicKey;
562
+ totalShares: BN;
563
+ userShares: BN;
564
+ sharesBase: BN;
565
+ unstakingPeriod: BN;
566
+ lastRevenueSettleTs: BN;
567
+ revenueSettlePeriod: BN;
568
+ totalFactor: number;
569
+ userFactor: number;
570
+ }
571
+ interface InsuranceFundJSON {
572
+ vault: string;
573
+ totalShares: string;
574
+ userShares: string;
575
+ sharesBase: string;
576
+ unstakingPeriod: string;
577
+ lastRevenueSettleTs: string;
578
+ revenueSettlePeriod: string;
579
+ totalFactor: number;
580
+ userFactor: number;
581
+ }
582
+ declare enum SpotBalanceType {
583
+ Deposit = "Deposit",
584
+ Borrow = "Borrow"
585
+ }
586
+ interface SpotPosition {
587
+ /**
588
+ * The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow
589
+ * interest of corresponding market.
590
+ * precision: SPOT_BALANCE_PRECISION
591
+ */
592
+ scaledBalance: BN;
593
+ /**
594
+ * How many spot bids the user has open
595
+ * precision: token mint precision
596
+ */
597
+ openBids: BN;
598
+ /**
599
+ * How many spot asks the user has open
600
+ * precision: token mint precision
601
+ */
602
+ openAsks: BN;
603
+ /**
604
+ * The cumulative deposits/borrows a user has made into a market
605
+ * precision: token mint precision
606
+ */
607
+ cumulativeDeposits: BN;
608
+ /** The market index of the corresponding spot market */
609
+ marketIndex: number;
610
+ /** Whether the position is deposit or borrow */
611
+ balanceType: SpotBalanceType;
612
+ /** Number of open orders */
613
+ openOrders: number;
614
+ padding: Array<number>;
615
+ }
616
+ interface SpotPositionJSON {
617
+ /**
618
+ * The scaled balance of the position. To get the token amount, multiply by the cumulative deposit/borrow
619
+ * interest of corresponding market.
620
+ * precision: SPOT_BALANCE_PRECISION
621
+ */
622
+ scaledBalance: string;
623
+ /**
624
+ * How many spot bids the user has open
625
+ * precision: token mint precision
626
+ */
627
+ openBids: string;
628
+ /**
629
+ * How many spot asks the user has open
630
+ * precision: token mint precision
631
+ */
632
+ openAsks: string;
633
+ /**
634
+ * The cumulative deposits/borrows a user has made into a market
635
+ * precision: token mint precision
636
+ */
637
+ cumulativeDeposits: string;
638
+ /** The market index of the corresponding spot market */
639
+ marketIndex: number;
640
+ /** Whether the position is deposit or borrow */
641
+ balanceType: SpotBalanceType;
642
+ /** Number of open orders */
643
+ openOrders: number;
644
+ padding: Array<number>;
645
+ }
646
+
647
+ interface DriftSpotMarket {
648
+ pubkey: PublicKey;
649
+ oracle: PublicKey;
650
+ mint: PublicKey;
651
+ decimals: number;
652
+ cumulativeDepositInterest: BN;
653
+ marketIndex: number;
654
+ depositBalance: BN;
655
+ borrowBalance: BN;
656
+ cumulativeBorrowInterest: BN;
657
+ optimalUtilization: number;
658
+ optimalBorrowRate: number;
659
+ maxBorrowRate: number;
660
+ minBorrowRate: number;
661
+ insuranceFund: {
662
+ totalFactor: number;
663
+ };
664
+ poolId: number;
665
+ }
666
+ declare enum DriftSpotBalanceType {
667
+ DEPOSIT = "deposit",
668
+ BORROW = "borrow"
669
+ }
670
+ declare function isSpotBalanceTypeVariant(value: DriftSpotBalanceType, variant: "deposit" | "borrow"): boolean;
671
+
672
+ interface DriftUserJSON {
673
+ authority: string;
674
+ spotPositions: Array<SpotPositionJSON>;
675
+ }
676
+
677
+ interface DriftUser {
678
+ authority: PublicKey;
679
+ spotPositions: Array<SpotPosition>;
680
+ }
681
+
682
+ type DriftRewards = {
683
+ oracle: PublicKey;
684
+ marketIndex: number;
685
+ spotMarket: PublicKey;
686
+ mint: PublicKey;
687
+ spotPosition: SpotPosition;
688
+ };
689
+ type DriftRewardsJSON = {
690
+ oracle: string;
691
+ marketIndex: number;
692
+ spotMarket: string;
693
+ mint: string;
694
+ spotPosition: SpotPositionJSON;
695
+ };
696
+
697
+ /**
698
+ * JSON-serializable DTO for the Lending account.
699
+ * PublicKey → string, BN → string.
700
+ */
701
+ interface JupLendingStateJSON {
702
+ pubkey: string;
703
+ mint: string;
704
+ fTokenMint: string;
705
+ lendingId: number;
706
+ decimals: number;
707
+ rewardsRateModel: string;
708
+ liquidityExchangePrice: string;
709
+ tokenExchangePrice: string;
710
+ lastUpdateTimestamp: string;
711
+ tokenReservesLiquidity: string;
712
+ supplyPositionOnLiquidity: string;
713
+ bump?: number;
714
+ }
715
+
716
+ /**
717
+ * Curated Lending State used throughout the codebase.
718
+ *
719
+ * integration_acc_1 – holds cToken/fToken exchange rates.
720
+ * Analogous to a Kamino Reserve or Drift SpotMarket.
721
+ */
722
+ interface JupLendingState {
723
+ pubkey: PublicKey;
724
+ mint: PublicKey;
725
+ fTokenMint: PublicKey;
726
+ lendingId: number;
727
+ decimals: number;
728
+ rewardsRateModel: PublicKey;
729
+ /** Exchange price for the underlying asset in the liquidity protocol (without rewards) */
730
+ liquidityExchangePrice: BN;
731
+ /** Exchange price between fToken and the underlying asset (with rewards) */
732
+ tokenExchangePrice: BN;
733
+ lastUpdateTimestamp: BN;
734
+ tokenReservesLiquidity: PublicKey;
735
+ supplyPositionOnLiquidity: PublicKey;
736
+ }
737
+
738
+ /**
739
+ * Curated TokenReserve used throughout the codebase.
740
+ *
741
+ * Liquidity-layer reserve account for a mint. Contains supply/borrow
742
+ * exchange prices, utilization, and totals.
743
+ */
744
+ interface JupTokenReserve {
745
+ pubkey: PublicKey;
746
+ mint: PublicKey;
747
+ vault: PublicKey;
748
+ borrowRate: number;
749
+ feeOnInterest: number;
750
+ lastUtilization: number;
751
+ lastUpdateTimestamp: BN;
752
+ supplyExchangePrice: BN;
753
+ borrowExchangePrice: BN;
754
+ maxUtilization: number;
755
+ totalSupplyWithInterest: BN;
756
+ totalSupplyInterestFree: BN;
757
+ totalBorrowWithInterest: BN;
758
+ totalBorrowInterestFree: BN;
759
+ totalClaimAmount: BN;
760
+ interactingProtocol: PublicKey;
761
+ interactingTimestamp: BN;
762
+ interactingBalance: BN;
763
+ }
764
+
765
+ /**
766
+ * JSON-serializable DTO for the TokenReserve account.
767
+ * PublicKey → string, BN → string.
768
+ */
769
+ interface JupTokenReserveJSON {
770
+ pubkey: string;
771
+ mint: string;
772
+ vault: string;
773
+ borrowRate: number;
774
+ feeOnInterest: number;
775
+ lastUtilization: number;
776
+ lastUpdateTimestamp: string;
777
+ supplyExchangePrice: string;
778
+ borrowExchangePrice: string;
779
+ maxUtilization: number;
780
+ totalSupplyWithInterest: string;
781
+ totalSupplyInterestFree: string;
782
+ totalBorrowWithInterest: string;
783
+ totalBorrowInterestFree: string;
784
+ totalClaimAmount: string;
785
+ interactingProtocol: string;
786
+ interactingTimestamp: string;
787
+ interactingBalance: string;
788
+ }
789
+
790
+ /**
791
+ * Curated LendingRewardsRateModel used throughout the codebase.
792
+ *
793
+ * Controls the rewards distribution parameters for a jup-lend market.
794
+ */
795
+ interface JupLendingRewardsRateModel {
796
+ pubkey: PublicKey;
797
+ /** Mint address */
798
+ mint: PublicKey;
799
+ /** TVL below which rewards rate is 0 */
800
+ startTvl: BN;
801
+ /** Duration for which current rewards should run */
802
+ duration: BN;
803
+ /** Timestamp when current rewards got started */
804
+ startTime: BN;
805
+ /** Annualized reward based on input params (duration, rewardAmount) */
806
+ yearlyReward: BN;
807
+ /** Duration for the next rewards phase */
808
+ nextDuration: BN;
809
+ /** Amount of rewards for the next phase */
810
+ nextRewardAmount: BN;
811
+ }
812
+
813
+ /**
814
+ * JSON-serializable DTO for the LendingRewardsRateModel account.
815
+ * PublicKey → string, BN → string.
816
+ */
817
+ interface JupLendingRewardsRateModelJSON {
818
+ pubkey: string;
819
+ mint: string;
820
+ startTvl: string;
821
+ duration: string;
822
+ startTime: string;
823
+ yearlyReward: string;
824
+ nextDuration: string;
825
+ nextRewardAmount: string;
826
+ bump?: number;
827
+ }
828
+
829
+ /**
830
+ * Curated RateModel — identical to raw since all fields are primitives + PublicKey.
831
+ */
832
+ interface JupRateModel {
833
+ pubkey: PublicKey;
834
+ mint: PublicKey;
835
+ version: number;
836
+ rateAtZero: number;
837
+ kink1Utilization: number;
838
+ rateAtKink1: number;
839
+ rateAtMax: number;
840
+ kink2Utilization: number;
841
+ rateAtKink2: number;
842
+ }
843
+
844
+ /**
845
+ * JSON-serializable DTO for the RateModel account.
846
+ * PublicKey → string.
847
+ */
848
+ interface JupRateModelJSON {
849
+ pubkey: string;
850
+ mint: string;
851
+ version: number;
852
+ rateAtZero: number;
853
+ kink1Utilization: number;
854
+ rateAtKink1: number;
855
+ rateAtMax: number;
856
+ kink2Utilization: number;
857
+ rateAtKink2: number;
858
+ }
859
+
860
+ export { type KaminoObligationCollateralJSON as $, type KaminoReserveCollateral as A, type KaminoReserveConfig as B, type KaminoBorrowRateCurve as C, type DriftSpotMarket as D, type KaminoReserveTokenInfo as E, type FeeStructureJSON as F, type KaminoScopeConfiguration as G, type HistoricalOracleData as H, type InsuranceFund as I, type JupLendingState as J, type KaminoReserve as K, type KaminoSwitchboardConfiguration as L, type KaminoPythConfiguration as M, type KaminoReserveLiquidityJSON as N, type OracleGuardRailsJSON as O, type PoolBalance as P, type KaminoReserveCollateralJSON as Q, type KaminoReserveConfigJSON as R, type SpotPosition as S, type KaminoBorrowRateCurveJSON as T, type KaminoBorrowRateCurvePointJSON as U, type KaminoReserveTokenInfoJSON as V, type KaminoScopeConfigurationJSON as W, type KaminoSwitchboardConfigurationJSON as X, type KaminoPythConfigurationJSON as Y, type KaminoObligationCollateral as Z, type KaminoObligationLiquidity as _, type KaminoObligation as a, type KaminoObligationLiquidityJSON as a0, type KaminoFarmTokenInfo as a1, type KaminoRewardScheduleCurve as a2, type KaminoRewardCurvePoint as a3, type KaminoFarmTokenInfoJSON as a4, type KaminoFarmRewardInfoJSON as a5, type KaminoRewardScheduleCurveJSON as a6, type KaminoRewardCurvePointJSON as a7, type UserFeesJSON as a8, type UserFeesFields as a9, isSpotBalanceTypeVariant as aa, type FeeTier as ab, type FeeTierJSON as ac, type OrderFillerRewardStructure as ad, type OrderFillerRewardStructureJSON as ae, type PriceDivergenceGuardRails as af, type PriceDivergenceGuardRailsJSON as ag, type ValidityGuardRails as ah, type ValidityGuardRailsJSON as ai, type HistoricalOracleDataJSON as aj, type HistoricalIndexDataJSON as ak, type PoolBalanceJSON as al, type InsuranceFundJSON as am, SpotBalanceType as an, type SpotPositionJSON as ao, type KaminoFarmState as b, type DriftUser as c, type DriftRewards as d, type DriftUserStats as e, type JupTokenReserve as f, type JupLendingRewardsRateModel as g, type JupRateModel as h, type KaminoReserveJSON as i, type KaminoObligationJSON as j, type KaminoFarmStateJSON as k, type DriftSpotMarketJSON as l, type DriftUserJSON as m, type DriftRewardsJSON as n, type DriftUserStatsJSON as o, type JupLendingStateJSON as p, type JupTokenReserveJSON as q, type JupLendingRewardsRateModelJSON as r, type JupRateModelJSON as s, type KaminoBorrowRateCurvePoint as t, type KaminoFarmRewardInfo as u, type HistoricalIndexData as v, type FeeStructure as w, type OracleGuardRails as x, DriftSpotBalanceType as y, type KaminoReserveLiquidity as z };