@exponent-labs/exponent-fetcher 0.9.10 → 0.9.12

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.
@@ -4,7 +4,9 @@
4
4
  * These accounts cannot be deserialized due to program updates and should be skipped.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.IgnoredClmmEntityError = exports.isTicksIgnored = exports.isMarketIgnored = exports.IGNORED_CLMM_TICKS = exports.IGNORED_CLMM_MARKETS = void 0;
7
+ exports.IgnoredClmmEntityError = exports.IGNORED_CLMM_TICKS = exports.IGNORED_CLMM_MARKETS = void 0;
8
+ exports.isMarketIgnored = isMarketIgnored;
9
+ exports.isTicksIgnored = isTicksIgnored;
8
10
  /**
9
11
  * Set of market addresses to ignore. O(1) lookup
10
12
  */
@@ -37,14 +39,12 @@ exports.IGNORED_CLMM_TICKS = new Set([
37
39
  function isMarketIgnored(marketAddress) {
38
40
  return exports.IGNORED_CLMM_MARKETS.has(marketAddress);
39
41
  }
40
- exports.isMarketIgnored = isMarketIgnored;
41
42
  /**
42
43
  * Check if a ticks address is in the ignore list
43
44
  */
44
45
  function isTicksIgnored(ticksAddress) {
45
46
  return exports.IGNORED_CLMM_TICKS.has(ticksAddress);
46
47
  }
47
- exports.isTicksIgnored = isTicksIgnored;
48
48
  /**
49
49
  * Error class for ignored CLMM entities
50
50
  */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACU,QAAA,oBAAoB,GAAG,IAAI,GAAG,CAAC;IAC1C,6CAA6C;IAC7C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;CAC/C,CAAC,CAAA;AAEF;;GAEG;AACU,QAAA,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACxC,6CAA6C;IAC7C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;CAC/C,CAAC,CAAA;AAEF;;GAEG;AACH,SAAgB,eAAe,CAAC,aAAqB;IACnD,OAAO,4BAAoB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;AAChD,CAAC;AAFD,0CAEC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,YAAoB;IACjD,OAAO,0BAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAC7C,CAAC;AAFD,wCAEC;AAED;;GAEG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,UAA8B,EAAE,OAAe;QACzD,KAAK,CAAC,QAAQ,UAAU,eAAe,OAAO,8CAA8C,CAAC,CAAA;QAC7F,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACtC,CAAC;CACF;AALD,wDAKC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAiCH,0CAEC;AAKD,wCAEC;AAxCD;;GAEG;AACU,QAAA,oBAAoB,GAAG,IAAI,GAAG,CAAC;IAC1C,6CAA6C;IAC7C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;CAC/C,CAAC,CAAA;AAEF;;GAEG;AACU,QAAA,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACxC,6CAA6C;IAC7C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;CAC/C,CAAC,CAAA;AAEF;;GAEG;AACH,SAAgB,eAAe,CAAC,aAAqB;IACnD,OAAO,4BAAoB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;AAChD,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,YAAoB;IACjD,OAAO,0BAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAC7C,CAAC;AAED;;GAEG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,UAA8B,EAAE,OAAe;QACzD,KAAK,CAAC,QAAQ,UAAU,eAAe,OAAO,8CAA8C,CAAC,CAAA;QAC7F,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACtC,CAAC;CACF;AALD,wDAKC"}
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="bn.js" />
4
1
  import { BN, Program, Wallet, web3 } from "@coral-xyz/anchor";
5
2
  import Decimal from "decimal.js";
6
3
  import { ExponentClmm } from "@exponent-labs/exponent-clmm-idl";
@@ -81,7 +78,7 @@ export declare class ExponentFetcher {
81
78
  * Layout matches Rust struct `Ticks` with `RedBlackTree<u32, Tick, 1000>`:
82
79
  * - Discriminator: 8 bytes
83
80
  * - RedBlackTree header: root(4) + padding(12) + size(8) + bump(4) + freeIdx(4) = 32 bytes
84
- * - 1000 RBTree nodes, each: nodeHeader(16) + key(4) + padding(4) + Tick = variable bytes
81
+ * - 1000 RBTree nodes, each: nodeHeader(16) + key(4) + padding(4) + Tick(416) = 440 bytes
85
82
  * - Ticks footer: market(32) + feeGrowthPt(16) + feeGrowthSy(16) + prefixSum(8) + spotPrice(8) + currentTick(4) + padding(12) = 96 bytes
86
83
  */
87
84
  export declare function deserializeMarketThreeTicks(data: Buffer): Ticks;
@@ -129,7 +126,6 @@ export interface MarketThree {
129
126
  }[];
130
127
  };
131
128
  liquidityNetBalanceLimits: LiquidityNetBalanceLimits;
132
- seedId: number[];
133
129
  }
134
130
  export interface Ticks {
135
131
  /** Current tick (left boundary of the active interval) */
@@ -162,18 +158,18 @@ export interface Tick {
162
158
  principalSy: bigint;
163
159
  apyBasePoints: number;
164
160
  principalShareSupply: bigint;
165
- /** Farm yield trackers (2 trackers) */
161
+ /** Farm yield trackers (3 trackers) */
166
162
  farms: {
167
163
  lastSeenIndex: number;
168
164
  }[];
169
- /** Emission yield trackers (2 trackers) */
165
+ /** Emission yield trackers (3 trackers) */
170
166
  emissions: {
171
167
  lastSeenIndex: number;
172
168
  lastPositionIndex: number;
173
169
  }[];
174
170
  /** Last split epoch for this tick */
175
171
  lastSplitEpoch: bigint;
176
- /** Frozen liquidity that cannot be withdrawn */
172
+ /** Minimum liquidity retained on ticks used by wrapper-base liquidity */
177
173
  frozenLiquidity: bigint;
178
174
  }
179
175
  export interface MarketThreeRaw {
@@ -337,16 +333,12 @@ export interface Orderbook {
337
333
  tokenEscrowPt: web3.PublicKey;
338
334
  cpiAccountOrderbook: web3.PublicKey;
339
335
  admin: web3.PublicKey;
340
- /** Raw 256-bit PreciseNumber (12 decimals) for last SY exchange rate */
341
- lastSyExchangeRate: bigint;
342
336
  configurationOptions: ConfigurationOptions;
343
337
  financials: OrderbookFinancials;
344
338
  prices: PriceTreeNode[];
345
339
  offers: OfferNode[];
346
340
  userEscrows: UserEscrowNode[];
347
- /** Next offer index that will be allocated (from NodeAllocator free list) */
348
341
  offersFreeListHead: number;
349
- /** Bump index boundary for offers allocator */
350
342
  offersBumpIndex: number;
351
343
  }
352
344
  export interface KaminoSyMeta {
@@ -438,6 +430,12 @@ export interface LpPositionCLMM {
438
430
  lastSeenIndex: number;
439
431
  }[];
440
432
  }[];
433
+ crossingSplit: {
434
+ crossLeftIdx: number;
435
+ crossRightIdx: number;
436
+ lpBalanceCrossing: bigint;
437
+ isActive: boolean;
438
+ };
441
439
  }
442
440
  export interface LpFarm {
443
441
  lastSeenTimestamp: number;
@@ -498,7 +496,7 @@ export interface OfferNodeRaw {
498
496
  }
499
497
  export interface UserEscrowNodeRaw {
500
498
  user: web3.PublicKey;
501
- yieldIndex: number;
499
+ yieldIndex: BN;
502
500
  ptAmount: BN;
503
501
  syAmount: BN;
504
502
  ytAmount: BN;
@@ -574,12 +572,8 @@ export declare function fetchKaminoVaultIndex({ connection, kaminoVaultAccount,
574
572
  index: number;
575
573
  tokenVault: any;
576
574
  tokenMint: any;
577
- tokenProgram: web3.PublicKey;
578
- globalConfig: web3.PublicKey;
579
575
  baseVaultAuthority: any;
580
576
  sharesMint: any;
581
- sharesTokenProgram: web3.PublicKey;
582
- vaultLookupTable: any;
583
577
  reserves: any;
584
578
  }>;
585
579
  export declare function fetchFragmetricSupportedTokenIndex({ connection, fragmetricFund, index, }: {
@@ -3,7 +3,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.fetchChainlinkRate = exports.fetchOreExchangeRate = exports.fetchReflectRedemptionRate = exports.fetchSolsticeRedemptionRate = exports.fetchSanctumIndex = exports.fetchAdrenaIndex = exports.fetchMeteoraIndex = exports.fetchFragmetricSupportedTokenIndex = exports.fetchKaminoVaultIndex = exports.fetchJupiterLendIndex = exports.fetchFragmetricIndex = exports.fetchGenericSyMetaIndex = exports.fetchPyth = exports.fetchJupiterPerpsIndex = exports.fetchJitoRestaking = exports.fetchPerenaStablePoolData = exports.fetchSplStakePoolIndex = exports.anchorizedPNumToRawBigint = exports.deserializeEmission = exports.serializeEmission = exports.fetchAllKaminoObligationsByKaminoReserve = exports.fetchKaminoReserve = exports.deserializeYtPosition = exports.deserializeLpPosition = exports.deserializeMarketThree = exports.deserializeMarketThreeTicks = exports.ExponentFetcher = exports.MyWallet = exports.deserializeAnchorizedPNumFromJson = exports.serializeAnchorizedPNumFromJson = void 0;
6
+ exports.ExponentFetcher = exports.MyWallet = void 0;
7
+ exports.serializeAnchorizedPNumFromJson = serializeAnchorizedPNumFromJson;
8
+ exports.deserializeAnchorizedPNumFromJson = deserializeAnchorizedPNumFromJson;
9
+ exports.deserializeMarketThreeTicks = deserializeMarketThreeTicks;
10
+ exports.deserializeMarketThree = deserializeMarketThree;
11
+ exports.deserializeLpPosition = deserializeLpPosition;
12
+ exports.deserializeYtPosition = deserializeYtPosition;
13
+ exports.fetchKaminoReserve = fetchKaminoReserve;
14
+ exports.fetchAllKaminoObligationsByKaminoReserve = fetchAllKaminoObligationsByKaminoReserve;
15
+ exports.serializeEmission = serializeEmission;
16
+ exports.deserializeEmission = deserializeEmission;
17
+ exports.anchorizedPNumToRawBigint = anchorizedPNumToRawBigint;
18
+ exports.fetchSplStakePoolIndex = fetchSplStakePoolIndex;
19
+ exports.fetchPerenaStablePoolData = fetchPerenaStablePoolData;
20
+ exports.fetchJitoRestaking = fetchJitoRestaking;
21
+ exports.fetchJupiterPerpsIndex = fetchJupiterPerpsIndex;
22
+ exports.fetchPyth = fetchPyth;
23
+ exports.fetchGenericSyMetaIndex = fetchGenericSyMetaIndex;
24
+ exports.fetchFragmetricIndex = fetchFragmetricIndex;
25
+ exports.fetchJupiterLendIndex = fetchJupiterLendIndex;
26
+ exports.fetchKaminoVaultIndex = fetchKaminoVaultIndex;
27
+ exports.fetchFragmetricSupportedTokenIndex = fetchFragmetricSupportedTokenIndex;
28
+ exports.fetchMeteoraIndex = fetchMeteoraIndex;
29
+ exports.fetchAdrenaIndex = fetchAdrenaIndex;
30
+ exports.fetchSanctumIndex = fetchSanctumIndex;
31
+ exports.fetchSolsticeRedemptionRate = fetchSolsticeRedemptionRate;
32
+ exports.fetchReflectRedemptionRate = fetchReflectRedemptionRate;
33
+ exports.fetchOreExchangeRate = fetchOreExchangeRate;
34
+ exports.fetchChainlinkRate = fetchChainlinkRate;
7
35
  const anchor_1 = require("@coral-xyz/anchor");
8
36
  const anchor_2 = require("@coral-xyz/anchor");
9
37
  const spl_stake_pool_1 = require("@solana/spl-stake-pool");
@@ -39,17 +67,14 @@ const ore_1 = require("./utils/ore");
39
67
  const perena_1 = require("./utils/perena");
40
68
  const sanctum_1 = require("./utils/sanctum");
41
69
  const solstice_1 = require("./utils/solstice");
42
- const KAMINO_VAULT_GLOBAL_CONFIG = new anchor_1.web3.PublicKey("BKyTcUe6daNG8HbgBix2ugdRHbykG2dK9hPBBqhUyoEX");
43
70
  function serializeAnchorizedPNumFromJson(pnum) {
44
71
  const serializedArray = pnum[0].map((bn) => bn.toString());
45
72
  return { 0: serializedArray };
46
73
  }
47
- exports.serializeAnchorizedPNumFromJson = serializeAnchorizedPNumFromJson;
48
74
  function deserializeAnchorizedPNumFromJson(serialized) {
49
75
  const bnArray = serialized[0].map((str) => new anchor_1.BN(str));
50
76
  return { 0: bnArray };
51
77
  }
52
- exports.deserializeAnchorizedPNumFromJson = deserializeAnchorizedPNumFromJson;
53
78
  class MyWallet {
54
79
  payer;
55
80
  constructor(payer) {
@@ -266,6 +291,11 @@ class ExponentFetcher {
266
291
  },
267
292
  })),
268
293
  },
294
+ crossingSplit: {
295
+ crossLeftIdx: raw.crossingSplit.crossLeftIdx,
296
+ crossRightIdx: raw.crossingSplit.crossRightIdx,
297
+ lpBalanceCrossing: raw.crossingSplit.lpBalanceCrossing,
298
+ },
269
299
  };
270
300
  return deserializeLpPositionCLMM(v);
271
301
  }
@@ -380,7 +410,7 @@ exports.ExponentFetcher = ExponentFetcher;
380
410
  * Layout matches Rust struct `Ticks` with `RedBlackTree<u32, Tick, 1000>`:
381
411
  * - Discriminator: 8 bytes
382
412
  * - RedBlackTree header: root(4) + padding(12) + size(8) + bump(4) + freeIdx(4) = 32 bytes
383
- * - 1000 RBTree nodes, each: nodeHeader(16) + key(4) + padding(4) + Tick = variable bytes
413
+ * - 1000 RBTree nodes, each: nodeHeader(16) + key(4) + padding(4) + Tick(416) = 440 bytes
384
414
  * - Ticks footer: market(32) + feeGrowthPt(16) + feeGrowthSy(16) + prefixSum(8) + spotPrice(8) + currentTick(4) + padding(12) = 96 bytes
385
415
  */
386
416
  function deserializeMarketThreeTicks(data) {
@@ -465,12 +495,12 @@ function deserializeMarketThreeTicks(data) {
465
495
  const principalPt = readU64(); // 8 bytes
466
496
  const principalSy = readU64(); // 8 bytes
467
497
  const principalShareSupply = readPreciseNumberAsBigint(); // 32 bytes - kept as bigint for arithmetic
468
- // FarmYieldTrackers: 2 x FarmYieldTracker(32 bytes) = 64 bytes
498
+ // FarmYieldTrackers: 3 x FarmYieldTracker(32 bytes) = 96 bytes
469
499
  const farms = [];
470
500
  for (let j = 0; j < PERSONAL_TICK_YIELD_TRACKER_SIZE; j++) {
471
501
  farms.push({ lastSeenIndex: readPreciseNumberAsFloat() });
472
502
  }
473
- // EmissionYieldTrackers: 2 x EmissionYieldTracker(64 bytes) = 128 bytes
503
+ // EmissionYieldTrackers: 3 x EmissionYieldTracker(64 bytes) = 192 bytes
474
504
  const emissions = [];
475
505
  for (let j = 0; j < PERSONAL_TICK_YIELD_TRACKER_SIZE; j++) {
476
506
  emissions.push({
@@ -514,51 +544,7 @@ function deserializeMarketThreeTicks(data) {
514
544
  currentTick,
515
545
  };
516
546
  }
517
- exports.deserializeMarketThreeTicks = deserializeMarketThreeTicks;
518
- /** Decoded account may use snake_case (from JSON IDL); normalize to camelCase for app use. */
519
- function normalizeCpiContext(a) {
520
- return {
521
- altIndex: a.altIndex ?? a.alt_index ?? 0,
522
- isSigner: a.isSigner ?? a.is_signer ?? false,
523
- isWritable: a.isWritable ?? a.is_writable ?? false,
524
- };
525
- }
526
- function normalizeCpiAccountIndexes(raw) {
527
- const arr = (key, snake) => {
528
- const a = raw[key] ?? raw[snake];
529
- return Array.isArray(a) ? a.map((x) => normalizeCpiContext(x)) : [];
530
- };
531
- const arr2 = (key, snake) => {
532
- const a = raw[key] ?? raw[snake];
533
- return Array.isArray(a) ? a.map((inner) => (Array.isArray(inner) ? inner.map((x) => normalizeCpiContext(x)) : [])) : [];
534
- };
535
- return {
536
- getSyState: arr("getSyState", "get_sy_state"),
537
- withdrawSy: arr("withdrawSy", "withdraw_sy"),
538
- depositSy: arr("depositSy", "deposit_sy"),
539
- claimEmission: arr2("claimEmission", "claim_emission"),
540
- getPositionState: arr("getPositionState", "get_position_state"),
541
- };
542
- }
543
- function normalizeMarketCpiCoreIndexes(raw) {
544
- const arr = (key, snake) => {
545
- const a = raw[key] ?? raw[snake];
546
- return Array.isArray(a) ? a.map((x) => normalizeCpiContext(x)) : [];
547
- };
548
- return {
549
- stripSy: arr("stripSy", "strip_sy"),
550
- mergeSy: arr("mergeSy", "merge_sy"),
551
- };
552
- }
553
547
  function deserializeMarketThree(m) {
554
- const rawCpiSy = m.cpiSyAccounts ?? m.cpi_sy_accounts;
555
- const rawCpiCore = m.cpiCoreAccounts ?? m.cpi_core_accounts;
556
- const cpiSyAccounts = rawCpiSy != null && typeof rawCpiSy === "object"
557
- ? normalizeCpiAccountIndexes(rawCpiSy)
558
- : (m.cpiSyAccounts ?? { getSyState: [], withdrawSy: [], depositSy: [], claimEmission: [], getPositionState: [] });
559
- const cpiCoreAccounts = rawCpiCore != null && typeof rawCpiCore === "object"
560
- ? normalizeMarketCpiCoreIndexes(rawCpiCore)
561
- : (m.cpiCoreAccounts ?? { stripSy: [], mergeSy: [] });
562
548
  return {
563
549
  addressLookupTable: m.addressLookupTable,
564
550
  mintSy: m.mintSy,
@@ -571,7 +557,7 @@ function deserializeMarketThree(m) {
571
557
  selfAddress: m.selfAddress,
572
558
  syProgram: m.syProgram,
573
559
  statusFlags: m.statusFlags,
574
- cpiSyAccounts,
560
+ cpiSyAccounts: m.cpiSyAccounts,
575
561
  isCurrentFlashSwap: m.isCurrentFlashSwap,
576
562
  lpFarm: m.lpFarm,
577
563
  mintYt: m.mintYt,
@@ -600,12 +586,10 @@ function deserializeMarketThree(m) {
600
586
  syBalance: BigInt(m.financials.syBalance.toString()),
601
587
  liquidityBalance: BigInt(m.financials.liquidityBalance.toString()),
602
588
  },
603
- cpiCoreAccounts,
589
+ cpiCoreAccounts: m.cpiCoreAccounts,
604
590
  exponentCoreProgram: m.exponentCoreProgram,
605
- seedId: m.seedId,
606
591
  };
607
592
  }
608
- exports.deserializeMarketThree = deserializeMarketThree;
609
593
  function deserializeMarketTwo(m) {
610
594
  return {
611
595
  ptBalance: BigInt(m.financials.ptBalance.toString()),
@@ -668,6 +652,12 @@ function deserializeLpPositionCLMM(x) {
668
652
  lastSeenIndex: parseFloat(precise_number_1.PreciseNumber.fromRaw(e.lastSeenIndex[0]).valueString),
669
653
  })),
670
654
  })),
655
+ crossingSplit: {
656
+ crossLeftIdx: x.crossingSplit.crossLeftIdx,
657
+ crossRightIdx: x.crossingSplit.crossRightIdx,
658
+ lpBalanceCrossing: BigInt(x.crossingSplit.lpBalanceCrossing.toString()),
659
+ isActive: x.crossingSplit.crossLeftIdx !== 0xffffffff && x.crossingSplit.crossRightIdx !== 0xffffffff,
660
+ },
671
661
  };
672
662
  }
673
663
  function deserializeVault(x) {
@@ -718,7 +708,8 @@ function deserializeOrderbook(data) {
718
708
  offset += 8;
719
709
  const priceDecimals = data.readUint8(offset);
720
710
  offset += 1;
721
- // Skip ConfigurationOptions padding: _placeholder_one[15] + _placeholder_two[32] + _placeholder_three[32] + _placeholder_four[32] + _reserved[1024] = 1135 bytes
711
+ // Skip ConfigurationOptions padding/reserve:
712
+ // _placeholder_one[15] + _placeholder_two[32] + _placeholder_three[32] + _placeholder_four[32] + _reserved[1024]
722
713
  offset += 1135;
723
714
  // Pubkeys
724
715
  const vault = readPubkey();
@@ -731,14 +722,7 @@ function deserializeOrderbook(data) {
731
722
  const tokenEscrowPt = readPubkey();
732
723
  const cpiAccountOrderbook = readPubkey();
733
724
  const admin = readPubkey();
734
- // last_sy_exchange_rate (Number type = 32 bytes, PreciseNumber with 12 decimals)
735
- const lastSyExchangeRateRaw = (() => {
736
- let val = 0n;
737
- for (let i = 0; i < 4; i++) {
738
- val += data.readBigUInt64LE(offset + i * 8) << BigInt(i * 64);
739
- }
740
- return val;
741
- })();
725
+ // Skip last_sy_exchange_rate (Number type = 32 bytes)
742
726
  offset += 32;
743
727
  // OrderbookFinancials struct
744
728
  // Skip last_seen_sy_index (Number type = 32 bytes)
@@ -882,12 +866,7 @@ function deserializeOrderbook(data) {
882
866
  offset += 4;
883
867
  const user = new anchor_1.web3.PublicKey(data.slice(offset, offset + 32));
884
868
  offset += 32;
885
- const yieldIndexRaw = [[new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0)]];
886
- for (let word = 0; word < 4; word++) {
887
- yieldIndexRaw[0][word] = new anchor_1.BN(data.subarray(offset + word * 8, offset + (word + 1) * 8), "le");
888
- }
889
- const yieldIndex = deserializeAnchorizedPNum(yieldIndexRaw);
890
- offset += 32;
869
+ /*const yieldIndex = data.readBigUInt64LE(offset).toString();*/ offset += 32;
891
870
  const ptAmount = data.readBigUInt64LE(offset);
892
871
  offset += 8;
893
872
  const syAmount = data.readBigUInt64LE(offset);
@@ -900,7 +879,7 @@ function deserializeOrderbook(data) {
900
879
  offset += 8;
901
880
  offset += 8; // reserved
902
881
  // if (user.toBase58() == "11111111111111111111111111111111") continue
903
- userEscrows.push({ user, yieldIndex, ptAmount, syAmount, ytAmount, stakedYtAmount, staged });
882
+ userEscrows.push({ user, yieldIndex: 0, ptAmount, syAmount, ytAmount, stakedYtAmount, staged });
904
883
  }
905
884
  // ─── Finally, seed_id + signer_bump + reserved ─────────────────────────────
906
885
  // seed_id: [u8; 4]
@@ -927,14 +906,13 @@ function deserializeOrderbook(data) {
927
906
  tokenEscrowYt,
928
907
  tokenEscrowPt,
929
908
  cpiAccountOrderbook,
930
- lastSyExchangeRate: lastSyExchangeRateRaw,
931
909
  financials,
932
910
  prices,
933
911
  configurationOptions,
934
912
  offers,
935
913
  userEscrows,
936
- offersBumpIndex,
937
914
  offersFreeListHead,
915
+ offersBumpIndex,
938
916
  };
939
917
  }
940
918
  function deserializeMarginfiSyMeta(x) {
@@ -972,7 +950,6 @@ function deserializeLpPosition(x) {
972
950
  })),
973
951
  };
974
952
  }
975
- exports.deserializeLpPosition = deserializeLpPosition;
976
953
  function deserializeYtPosition(x) {
977
954
  return {
978
955
  owner: x.owner,
@@ -982,7 +959,6 @@ function deserializeYtPosition(x) {
982
959
  emissions: x.emissions.map(deserializeYieldTokenTracker),
983
960
  };
984
961
  }
985
- exports.deserializeYtPosition = deserializeYtPosition;
986
962
  function deserializeYieldTokenTracker(x) {
987
963
  return {
988
964
  staged: BigInt(x.staged.toString()),
@@ -1003,7 +979,6 @@ async function fetchKaminoReserve(address, connection) {
1003
979
  scopePriceFeed,
1004
980
  };
1005
981
  }
1006
- exports.fetchKaminoReserve = fetchKaminoReserve;
1007
982
  const DEPOSITS_LIMIT = 8;
1008
983
  async function fetchAllKaminoObligationsByKaminoReserve(reserve, connection) {
1009
984
  const finalObligations = [];
@@ -1032,7 +1007,6 @@ async function fetchAllKaminoObligationsByKaminoReserve(reserve, connection) {
1032
1007
  }
1033
1008
  return finalObligations;
1034
1009
  }
1035
- exports.fetchAllKaminoObligationsByKaminoReserve = fetchAllKaminoObligationsByKaminoReserve;
1036
1010
  function serializeEmission(emission) {
1037
1011
  return {
1038
1012
  tokenAccount: emission.tokenAccount.toString(),
@@ -1044,7 +1018,6 @@ function serializeEmission(emission) {
1044
1018
  treasuryEmission: emission.treasuryEmission.toString(),
1045
1019
  };
1046
1020
  }
1047
- exports.serializeEmission = serializeEmission;
1048
1021
  function deserializeEmission(emission) {
1049
1022
  return {
1050
1023
  tokenAccount: new anchor_1.web3.PublicKey(emission.tokenAccount),
@@ -1056,7 +1029,6 @@ function deserializeEmission(emission) {
1056
1029
  treasuryEmission: new anchor_1.BN(emission.treasuryEmission),
1057
1030
  };
1058
1031
  }
1059
- exports.deserializeEmission = deserializeEmission;
1060
1032
  function deserializeAnchorizedPNum(x) {
1061
1033
  return parseFloat(precise_number_1.PreciseNumber.fromRaw(x[0]).valueString);
1062
1034
  }
@@ -1069,7 +1041,6 @@ function anchorizedPNumToRawBigint(pnum) {
1069
1041
  }
1070
1042
  return val;
1071
1043
  }
1072
- exports.anchorizedPNumToRawBigint = anchorizedPNumToRawBigint;
1073
1044
  /** Fetch the exchange rate of a JitoRestaking vault's VRT to JitoSOL */
1074
1045
  async function fetchJitoVaultData({ connection, vaultAddress, }) {
1075
1046
  const vaultAccountInfo = await connection.getAccountInfo(vaultAddress);
@@ -1086,7 +1057,6 @@ async function fetchSplStakePoolIndex({ connection, stakePool, }) {
1086
1057
  const stakePoolAccount = await (0, spl_stake_pool_1.getStakePoolAccount)(connection, stakePool);
1087
1058
  return Number(stakePoolAccount.account.data.totalLamports) / Number(stakePoolAccount.account.data.poolTokenSupply);
1088
1059
  }
1089
- exports.fetchSplStakePoolIndex = fetchSplStakePoolIndex;
1090
1060
  async function fetchPerenaStablePoolData({ connection, perenaStablePool, }) {
1091
1061
  const lpMint = (0, perena_1.getPerenaLpMint)(perenaStablePool);
1092
1062
  const [accountInfo, lpMintInfo] = await connection.getMultipleAccountsInfo([perenaStablePool, lpMint]);
@@ -1096,7 +1066,6 @@ async function fetchPerenaStablePoolData({ connection, perenaStablePool, }) {
1096
1066
  });
1097
1067
  return { lpSupply, invT, exchangeRate, lpMint };
1098
1068
  }
1099
- exports.fetchPerenaStablePoolData = fetchPerenaStablePoolData;
1100
1069
  /**
1101
1070
  * Fetch the exchange rate of a JitoRestaking vault
1102
1071
  * @param connection
@@ -1117,7 +1086,6 @@ async function fetchJitoRestaking(connection, accounts, interfaceType, vaultAddr
1117
1086
  exchangeRate: exr.toString(),
1118
1087
  };
1119
1088
  }
1120
- exports.fetchJitoRestaking = fetchJitoRestaking;
1121
1089
  /**
1122
1090
  * Fetch the pre-simulated index for Jupiter Perps pool to mirror on-chain logic in utils.rs (InterfaceType::JupiterPerps)
1123
1091
  * Uses fields: pool.pool_apr.{realized_fee_usd, fee_apr_bps, last_updated}, pool.aum_usd,
@@ -1133,11 +1101,9 @@ async function fetchJupiterPerpsIndex({ connection, pool, lastFeeUsdResetUnixTim
1133
1101
  lastRealizedFeeUsdUpdateUnixTimestamp,
1134
1102
  });
1135
1103
  }
1136
- exports.fetchJupiterPerpsIndex = fetchJupiterPerpsIndex;
1137
1104
  async function fetchPyth(connection) {
1138
1105
  return "";
1139
1106
  }
1140
- exports.fetchPyth = fetchPyth;
1141
1107
  async function fetchGenericSyMetaIndex({ connection, genericSyMeta, }) {
1142
1108
  const [accountInfo] = await connection.getMultipleAccountsInfo([genericSyMeta]);
1143
1109
  const d = accountInfo.data;
@@ -1162,7 +1128,6 @@ async function fetchGenericSyMetaIndex({ connection, genericSyMeta, }) {
1162
1128
  const index = parseFloat(precise_number_1.PreciseNumber.fromRaw(indexRaw[0]).valueString);
1163
1129
  return { index };
1164
1130
  }
1165
- exports.fetchGenericSyMetaIndex = fetchGenericSyMetaIndex;
1166
1131
  async function fetchFragmetricIndex({ connection, fragmetricFund, }) {
1167
1132
  const fragmetricFundRaw = await connection.getAccountInfo(fragmetricFund);
1168
1133
  const { index, receiptTokenMint, wrappedTokenMint } = (0, fragmetric_1.calculateFragmetricIndex)({
@@ -1170,7 +1135,6 @@ async function fetchFragmetricIndex({ connection, fragmetricFund, }) {
1170
1135
  });
1171
1136
  return { index, receiptTokenMint, wrappedTokenMint };
1172
1137
  }
1173
- exports.fetchFragmetricIndex = fetchFragmetricIndex;
1174
1138
  async function fetchJupiterLendIndex({ connection, jupiterLendAccount, }) {
1175
1139
  const account = await connection.getAccountInfo(jupiterLendAccount);
1176
1140
  const rateModel = jupiterLendAccount.equals(new anchor_1.web3.PublicKey("BeAqbxfrcXmzEYT2Ra62oW2MqkuFDHaCtps47Mzg6Zj3"))
@@ -1187,72 +1151,33 @@ async function fetchJupiterLendIndex({ connection, jupiterLendAccount, }) {
1187
1151
  rewardsRateModel,
1188
1152
  };
1189
1153
  }
1190
- exports.fetchJupiterLendIndex = fetchJupiterLendIndex;
1191
1154
  async function fetchKaminoVaultIndex({ connection, kaminoVaultAccount, }) {
1192
1155
  const account = await connection.getAccountInfo(kaminoVaultAccount);
1193
1156
  const coder = new anchor_2.BorshCoder(kamino_vault_idl_1.IDL);
1194
1157
  const data = coder.accounts.decode("VaultState", account.data);
1195
- const activeAllocations = data.vault_allocation_strategy
1196
- .filter((allocation) => allocation.reserve.toBase58() !== anchor_1.web3.PublicKey.default.toBase58());
1197
- const activeReserves = activeAllocations.map((allocation) => allocation.reserve);
1198
- const [activeReservesData, tokenMintInfo, sharesMintInfo] = await Promise.all([
1199
- connection.getMultipleAccountsInfo(activeReserves),
1200
- connection.getAccountInfo(data.token_mint),
1201
- connection.getAccountInfo(data.shares_mint),
1202
- ]);
1203
- const decodedReserves = activeReservesData.map((accountInfo, index) => {
1204
- if (!accountInfo?.data) {
1205
- throw new Error(`Missing Kamino reserve account ${activeReserves[index].toBase58()}`);
1206
- }
1207
- return kamino_reserve_deserializer_1.Reserve.decode(accountInfo.data);
1208
- });
1209
- const collateralMintInfos = await connection.getMultipleAccountsInfo(decodedReserves.map((reserve) => reserve.collateral.mintPubkey));
1158
+ const activeReserves = data.vault_allocation_strategy
1159
+ .map((r) => r.reserve)
1160
+ .filter((reserve) => reserve.toBase58() !== anchor_1.web3.PublicKey.default.toBase58());
1161
+ console.log("activeReserves", activeReserves);
1162
+ const activeReservesData = await connection.getMultipleAccountsInfo(activeReserves);
1210
1163
  const reserves = activeReserves.map((r, i) => {
1211
- const reserveAccount = decodedReserves[i];
1212
- const allocation = activeAllocations[i];
1213
- const [lendingMarketAuthority] = anchor_1.web3.PublicKey.findProgramAddressSync([Buffer.from("lma"), reserveAccount.lendingMarket.toBuffer()], new anchor_1.web3.PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD"));
1164
+ console.log("r.data", activeReservesData[i].data);
1214
1165
  return {
1215
1166
  reserveAddress: r,
1216
- marketAddress: reserveAccount.lendingMarket,
1217
- ctokenVault: allocation.ctoken_vault,
1218
- lendingMarketAuthority,
1219
- pythOracle: reserveAccount.config.tokenInfo.pythConfiguration.price,
1220
- switchboardPriceOracle: reserveAccount.config.tokenInfo.switchboardConfiguration.priceAggregator,
1221
- switchboardTwapOracle: reserveAccount.config.tokenInfo.switchboardConfiguration.twapAggregator,
1222
- scopePrices: reserveAccount.config.tokenInfo.scopeConfiguration.priceFeed,
1223
- reserveLiquiditySupply: reserveAccount.liquidity.supplyVault,
1224
- reserveCollateralMint: reserveAccount.collateral.mintPubkey,
1225
- reserveCollateralTokenProgram: collateralMintInfos[i]?.owner ?? anchor_1.web3.PublicKey.default,
1167
+ reserve: kamino_reserve_deserializer_1.Reserve.decode(activeReservesData[i].data).lendingMarket,
1226
1168
  };
1227
1169
  });
1170
+ console.log("reserves", reserves);
1228
1171
  const tokenVault = data.token_vault;
1229
1172
  const tokenMint = data.token_mint;
1230
1173
  const baseVaultAuthority = data.base_vault_authority;
1231
1174
  const sharesMint = data.shares_mint;
1232
- const vaultLookupTable = data.vault_lookup_table ?? anchor_1.web3.PublicKey.default;
1233
- const tokenProgram = tokenMintInfo?.owner ?? anchor_1.web3.PublicKey.default;
1234
- const sharesTokenProgram = sharesMintInfo?.owner ?? anchor_1.web3.PublicKey.default;
1235
- return {
1236
- index: 1,
1237
- tokenVault,
1238
- tokenMint,
1239
- tokenProgram,
1240
- // Kamino Vault withdraw expects the singleton program global config account.
1241
- // It is not stored on VaultState, so fetch it from the known program-wide address.
1242
- globalConfig: KAMINO_VAULT_GLOBAL_CONFIG,
1243
- baseVaultAuthority,
1244
- sharesMint,
1245
- sharesTokenProgram,
1246
- vaultLookupTable,
1247
- reserves,
1248
- };
1175
+ return { index: 1, tokenVault, tokenMint, baseVaultAuthority, sharesMint, reserves };
1249
1176
  }
1250
- exports.fetchKaminoVaultIndex = fetchKaminoVaultIndex;
1251
1177
  async function fetchFragmetricSupportedTokenIndex({ connection, fragmetricFund, index, }) {
1252
1178
  const account = await connection.getAccountInfo(fragmetricFund);
1253
1179
  return (0, fragmetric_1.calculateFragmetricSupportedTokenIndex)({ fragmetricFund: account.data }, index);
1254
1180
  }
1255
- exports.fetchFragmetricSupportedTokenIndex = fetchFragmetricSupportedTokenIndex;
1256
1181
  async function fetchMeteoraIndex({ connection, accounts, onChainTime, }) {
1257
1182
  try {
1258
1183
  const VIRTUAL_PRICE_PRECISION = new anchor_1.BN(100_000_000);
@@ -1288,7 +1213,6 @@ async function fetchMeteoraIndex({ connection, accounts, onChainTime, }) {
1288
1213
  throw error;
1289
1214
  }
1290
1215
  }
1291
- exports.fetchMeteoraIndex = fetchMeteoraIndex;
1292
1216
  async function fetchAdrenaIndex({ connection, accounts, previousTotalFees, currentIndex, }) {
1293
1217
  try {
1294
1218
  // Fetch all account data in a single RPC call
@@ -1314,7 +1238,6 @@ async function fetchAdrenaIndex({ connection, accounts, previousTotalFees, curre
1314
1238
  throw error;
1315
1239
  }
1316
1240
  }
1317
- exports.fetchAdrenaIndex = fetchAdrenaIndex;
1318
1241
  async function fetchSanctumIndex({ connection, accounts, }) {
1319
1242
  const [poolStateAccountRaw, lpMintAccountRaw] = await Promise.all([accounts.poolState, accounts.lpMint].map((pk) => connection.getAccountInfo(pk)));
1320
1243
  return (0, sanctum_1.calculateSanctumIndex)({
@@ -1322,7 +1245,6 @@ async function fetchSanctumIndex({ connection, accounts, }) {
1322
1245
  lpMintAccountData: lpMintAccountRaw.data,
1323
1246
  });
1324
1247
  }
1325
- exports.fetchSanctumIndex = fetchSanctumIndex;
1326
1248
  async function fetchSolsticeRedemptionRate({ connection, yieldPool, vestingSchedule, }) {
1327
1249
  // Fetch both accounts in a single RPC call for efficiency
1328
1250
  const accountInfos = await connection.getMultipleAccountsInfo([yieldPool, vestingSchedule]);
@@ -1331,7 +1253,6 @@ async function fetchSolsticeRedemptionRate({ connection, yieldPool, vestingSched
1331
1253
  }
1332
1254
  return (0, solstice_1.calculateSolsticeRedemptionRate)({ yieldPool: accountInfos[0].data, vestingSchedule: accountInfos[1].data });
1333
1255
  }
1334
- exports.fetchSolsticeRedemptionRate = fetchSolsticeRedemptionRate;
1335
1256
  const REFLECT_ORACLE_LEN = 17;
1336
1257
  const REFLECT_MAX_STALENESS_SLOTS = 15000000;
1337
1258
  async function fetchReflectRedemptionRate({ connection, oracle, }) {
@@ -1359,7 +1280,6 @@ async function fetchReflectRedemptionRate({ connection, oracle, }) {
1359
1280
  }
1360
1281
  return price / scale;
1361
1282
  }
1362
- exports.fetchReflectRedemptionRate = fetchReflectRedemptionRate;
1363
1283
  async function fetchOreExchangeRate({ connection, storeMint, stakeAccount, treasury, }) {
1364
1284
  // Fetch all accounts in parallel for efficiency
1365
1285
  const [storeMintInfo, stakeAccountInfo, treasuryAccountInfo] = await Promise.all([
@@ -1376,7 +1296,6 @@ async function fetchOreExchangeRate({ connection, storeMint, stakeAccount, treas
1376
1296
  storeMint: storeMintInfo.data,
1377
1297
  });
1378
1298
  }
1379
- exports.fetchOreExchangeRate = fetchOreExchangeRate;
1380
1299
  async function fetchChainlinkRate({ connection, priceFeed, }) {
1381
1300
  const accountInfo = await connection.getAccountInfo(priceFeed);
1382
1301
  if (!accountInfo) {
@@ -1386,5 +1305,4 @@ async function fetchChainlinkRate({ connection, priceFeed, }) {
1386
1305
  const scale = Math.pow(10, header.decimals);
1387
1306
  return Number(answer) / scale;
1388
1307
  }
1389
- exports.fetchChainlinkRate = fetchChainlinkRate;
1390
1308
  //# sourceMappingURL=exponentFetcher.js.map