@exponent-labs/exponent-fetcher 0.9.18 → 0.9.20

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,9 +4,7 @@
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.IGNORED_CLMM_TICKS = exports.IGNORED_CLMM_MARKETS = void 0;
8
- exports.isMarketIgnored = isMarketIgnored;
9
- exports.isTicksIgnored = isTicksIgnored;
7
+ exports.IgnoredClmmEntityError = exports.isTicksIgnored = exports.isMarketIgnored = exports.IGNORED_CLMM_TICKS = exports.IGNORED_CLMM_MARKETS = void 0;
10
8
  /**
11
9
  * Set of market addresses to ignore. O(1) lookup
12
10
  */
@@ -59,12 +57,14 @@ exports.IGNORED_CLMM_TICKS = new Set([
59
57
  function isMarketIgnored(marketAddress) {
60
58
  return exports.IGNORED_CLMM_MARKETS.has(marketAddress);
61
59
  }
60
+ exports.isMarketIgnored = isMarketIgnored;
62
61
  /**
63
62
  * Check if a ticks address is in the ignore list
64
63
  */
65
64
  function isTicksIgnored(ticksAddress) {
66
65
  return exports.IGNORED_CLMM_TICKS.has(ticksAddress);
67
66
  }
67
+ exports.isTicksIgnored = isTicksIgnored;
68
68
  /**
69
69
  * Error class for ignored CLMM entities
70
70
  */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAqDH,0CAEC;AAKD,wCAEC;AA5DD;;GAEG;AACU,QAAA,oBAAoB,GAAG,IAAI,GAAG,CAAC;IAC1C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,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,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,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
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;GAEG;AACU,QAAA,oBAAoB,GAAG,IAAI,GAAG,CAAC;IAC1C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,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,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,8CAA8C;IAC9C,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,3 +1,6 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="bn.js" />
1
4
  import { BN, Program, Wallet, web3 } from "@coral-xyz/anchor";
2
5
  import Decimal from "decimal.js";
3
6
  import { ExponentClmm } from "@exponent-labs/exponent-clmm-idl";
@@ -147,6 +150,20 @@ export interface Ticks {
147
150
  currentPrefixSum: bigint;
148
151
  /** Current spot price (ln implied rate) */
149
152
  currentSpotPrice: number;
153
+ /** Root node index of the on-chain RedBlackTree (0 is sentinel) */
154
+ tickTreeRoot?: number;
155
+ /** Allocated live node count recorded by the on-chain allocator */
156
+ tickTreeSize?: bigint;
157
+ /** Next allocator bump index recorded by the on-chain allocator */
158
+ tickTreeBumpIndex?: number;
159
+ /** Free-list head recorded by the on-chain allocator */
160
+ tickTreeFreeListHead?: number;
161
+ }
162
+ export interface TickTreeNode {
163
+ left: number;
164
+ right: number;
165
+ parent: number;
166
+ colorOrFree: number;
150
167
  }
151
168
  export interface Tick {
152
169
  liquidityNet: bigint;
@@ -180,6 +197,10 @@ export interface Tick {
180
197
  frozenLiquidity: bigint;
181
198
  /** Split-parent tick index for the current tick-split projection layout */
182
199
  splitParentIdx: number;
200
+ /** Raw RB-tree links for this 1-based tick node index */
201
+ treeNode?: TickTreeNode;
202
+ /** True when reachable from tickTreeRoot in the on-chain RB tree */
203
+ isInitialized?: boolean;
183
204
  }
184
205
  export interface MarketThreeRaw {
185
206
  admin: web3.PublicKey;
@@ -582,8 +603,12 @@ export declare function fetchKaminoVaultIndex({ connection, kaminoVaultAccount,
582
603
  index: number;
583
604
  tokenVault: any;
584
605
  tokenMint: any;
606
+ tokenProgram: web3.PublicKey;
607
+ globalConfig: web3.PublicKey;
585
608
  baseVaultAuthority: any;
586
609
  sharesMint: any;
610
+ sharesTokenProgram: web3.PublicKey;
611
+ vaultLookupTable: any;
587
612
  reserves: any;
588
613
  }>;
589
614
  export declare function fetchFragmetricSupportedTokenIndex({ connection, fragmetricFund, index, }: {
@@ -3,37 +3,7 @@ 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.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.deserializeAnchorizedPNum = deserializeAnchorizedPNum;
18
- exports.anchorizedPNumToRawBigint = anchorizedPNumToRawBigint;
19
- exports.fetchSplStakePoolIndex = fetchSplStakePoolIndex;
20
- exports.fetchPerenaStablePoolData = fetchPerenaStablePoolData;
21
- exports.fetchJitoRestaking = fetchJitoRestaking;
22
- exports.fetchJupiterPerpsIndex = fetchJupiterPerpsIndex;
23
- exports.fetchPyth = fetchPyth;
24
- exports.fetchGenericSyMetaIndex = fetchGenericSyMetaIndex;
25
- exports.fetchFragmetricIndex = fetchFragmetricIndex;
26
- exports.fetchJupiterLendIndex = fetchJupiterLendIndex;
27
- exports.fetchKaminoVaultIndex = fetchKaminoVaultIndex;
28
- exports.fetchFragmetricSupportedTokenIndex = fetchFragmetricSupportedTokenIndex;
29
- exports.fetchMeteoraIndex = fetchMeteoraIndex;
30
- exports.fetchAdrenaIndex = fetchAdrenaIndex;
31
- exports.fetchSanctumIndex = fetchSanctumIndex;
32
- exports.fetchSolsticeRedemptionRate = fetchSolsticeRedemptionRate;
33
- exports.fetchSolsticeGlamVaultExchangeRate = fetchSolsticeGlamVaultExchangeRate;
34
- exports.fetchReflectRedemptionRate = fetchReflectRedemptionRate;
35
- exports.fetchOreExchangeRate = fetchOreExchangeRate;
36
- exports.fetchChainlinkRate = fetchChainlinkRate;
6
+ exports.fetchChainlinkRate = exports.fetchOreExchangeRate = exports.fetchReflectRedemptionRate = exports.fetchSolsticeGlamVaultExchangeRate = 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.deserializeAnchorizedPNum = 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;
37
7
  const anchor_1 = require("@coral-xyz/anchor");
38
8
  const anchor_2 = require("@coral-xyz/anchor");
39
9
  const spl_stake_pool_1 = require("@solana/spl-stake-pool");
@@ -69,14 +39,17 @@ const ore_1 = require("./utils/ore");
69
39
  const perena_1 = require("./utils/perena");
70
40
  const sanctum_1 = require("./utils/sanctum");
71
41
  const solstice_1 = require("./utils/solstice");
42
+ const KAMINO_VAULT_GLOBAL_CONFIG = new anchor_1.web3.PublicKey("BKyTcUe6daNG8HbgBix2ugdRHbykG2dK9hPBBqhUyoEX");
72
43
  function serializeAnchorizedPNumFromJson(pnum) {
73
44
  const serializedArray = pnum[0].map((bn) => bn.toString());
74
45
  return { 0: serializedArray };
75
46
  }
47
+ exports.serializeAnchorizedPNumFromJson = serializeAnchorizedPNumFromJson;
76
48
  function deserializeAnchorizedPNumFromJson(serialized) {
77
49
  const bnArray = serialized[0].map((str) => new anchor_1.BN(str));
78
50
  return { 0: bnArray };
79
51
  }
52
+ exports.deserializeAnchorizedPNumFromJson = deserializeAnchorizedPNumFromJson;
80
53
  class MyWallet {
81
54
  payer;
82
55
  constructor(payer) {
@@ -482,16 +455,21 @@ function deserializeMarketThreeTicks(data) {
482
455
  offset += bytes;
483
456
  };
484
457
  // ─── Parse RedBlackTree header ────────────────────────────────────────────
485
- skip(4); // root: u32
458
+ const tickTreeRoot = readU32();
486
459
  skip(12); // padding to align NodeAllocator
487
- skip(8); // size: u64
488
- skip(4); // bump_index: u32
489
- skip(4); // free_list_head: u32
460
+ const tickTreeSize = readU64();
461
+ const tickTreeBumpIndex = readU32();
462
+ const tickTreeFreeListHead = readU32();
490
463
  // ─── Parse tick nodes ─────────────────────────────────────────────────────
491
464
  const ticks = [];
492
465
  for (let i = 0; i < MAX_TICK_NODES; i++) {
493
466
  // RBNode header: left(4) + right(4) + parent(4) + color(4) = 16 bytes
494
- skip(16);
467
+ const treeNode = {
468
+ left: readU32(),
469
+ right: readU32(),
470
+ parent: readU32(),
471
+ colorOrFree: readU32(),
472
+ };
495
473
  // Key: u32 + padding to 8 bytes
496
474
  const apyBasePoints = readU32();
497
475
  skip(4); // padding
@@ -539,8 +517,32 @@ function deserializeMarketThreeTicks(data) {
539
517
  splitParentEpoch,
540
518
  frozenLiquidity,
541
519
  splitParentIdx,
520
+ treeNode,
521
+ isInitialized: false,
542
522
  });
543
523
  }
524
+ const initializedTickIndices = new Set();
525
+ const stack = tickTreeRoot === 0 ? [] : [tickTreeRoot];
526
+ while (stack.length > 0) {
527
+ const tickIdx = stack.pop();
528
+ if (tickIdx < 1 || tickIdx > MAX_TICK_NODES || initializedTickIndices.has(tickIdx)) {
529
+ continue;
530
+ }
531
+ initializedTickIndices.add(tickIdx);
532
+ const node = ticks[tickIdx - 1]?.treeNode;
533
+ if (!node) {
534
+ continue;
535
+ }
536
+ if (node.left !== 0) {
537
+ stack.push(node.left);
538
+ }
539
+ if (node.right !== 0) {
540
+ stack.push(node.right);
541
+ }
542
+ }
543
+ for (let i = 0; i < ticks.length; i++) {
544
+ ticks[i].isInitialized = initializedTickIndices.has(i + 1);
545
+ }
544
546
  // ─── Parse Ticks footer ───────────────────────────────────────────────────
545
547
  const market = readPubkey(); // 32 bytes
546
548
  const feeGrowthIndexGlobalPt = readU128(); // 16 bytes
@@ -557,8 +559,13 @@ function deserializeMarketThreeTicks(data) {
557
559
  currentPrefixSum,
558
560
  currentSpotPrice,
559
561
  currentTick,
562
+ tickTreeRoot,
563
+ tickTreeSize,
564
+ tickTreeBumpIndex,
565
+ tickTreeFreeListHead,
560
566
  };
561
567
  }
568
+ exports.deserializeMarketThreeTicks = deserializeMarketThreeTicks;
562
569
  function deserializeMarketThree(m) {
563
570
  return {
564
571
  addressLookupTable: m.addressLookupTable,
@@ -606,6 +613,7 @@ function deserializeMarketThree(m) {
606
613
  seedId: m.seedId,
607
614
  };
608
615
  }
616
+ exports.deserializeMarketThree = deserializeMarketThree;
609
617
  function deserializeMarketTwo(m) {
610
618
  return {
611
619
  ptBalance: BigInt(m.financials.ptBalance.toString()),
@@ -715,6 +723,14 @@ function deserializeOrderbook(data) {
715
723
  offset += 32;
716
724
  return pk;
717
725
  };
726
+ const readPreciseNumberAsFloat = () => {
727
+ const nums = [];
728
+ for (let i = 0; i < 4; i++) {
729
+ nums.push(new anchor_1.BN(data.slice(offset + i * 8, offset + (i + 1) * 8), undefined, "le"));
730
+ }
731
+ offset += 32;
732
+ return parseFloat(precise_number_1.PreciseNumber.fromRaw(nums).valueString);
733
+ };
718
734
  // ConfigurationOptions struct
719
735
  const thresholdAmount = data.readBigUInt64LE(offset);
720
736
  offset += 8;
@@ -882,20 +898,20 @@ function deserializeOrderbook(data) {
882
898
  offset += 4;
883
899
  const user = new anchor_1.web3.PublicKey(data.slice(offset, offset + 32));
884
900
  offset += 32;
885
- /*const yieldIndex = data.readBigUInt64LE(offset).toString();*/ offset += 32;
901
+ const yieldIndex = readPreciseNumberAsFloat();
886
902
  const ptAmount = data.readBigUInt64LE(offset);
887
903
  offset += 8;
888
904
  const syAmount = data.readBigUInt64LE(offset);
889
905
  offset += 8;
890
906
  const ytAmount = data.readBigUInt64LE(offset);
891
907
  offset += 8;
892
- const stakedYtAmount = data.readBigInt64LE(offset);
908
+ const stakedYtAmount = data.readBigUInt64LE(offset);
893
909
  offset += 8;
894
- const staged = data.readBigInt64LE(offset);
910
+ const staged = data.readBigUInt64LE(offset);
895
911
  offset += 8;
896
912
  offset += 8; // reserved
897
913
  // if (user.toBase58() == "11111111111111111111111111111111") continue
898
- userEscrows.push({ user, yieldIndex: 0, ptAmount, syAmount, ytAmount, stakedYtAmount, staged });
914
+ userEscrows.push({ user, yieldIndex, ptAmount, syAmount, ytAmount, stakedYtAmount, staged });
899
915
  }
900
916
  // ─── Finally, seed_id + signer_bump + reserved ─────────────────────────────
901
917
  // seed_id: [u8; 4]
@@ -967,6 +983,7 @@ function deserializeLpPosition(x) {
967
983
  })),
968
984
  };
969
985
  }
986
+ exports.deserializeLpPosition = deserializeLpPosition;
970
987
  function deserializeYtPosition(x) {
971
988
  return {
972
989
  owner: x.owner,
@@ -976,6 +993,7 @@ function deserializeYtPosition(x) {
976
993
  emissions: x.emissions.map(deserializeYieldTokenTracker),
977
994
  };
978
995
  }
996
+ exports.deserializeYtPosition = deserializeYtPosition;
979
997
  function deserializeYieldTokenTracker(x) {
980
998
  return {
981
999
  staged: BigInt(x.staged.toString()),
@@ -999,6 +1017,7 @@ async function fetchKaminoReserve(address, connection) {
999
1017
  scopePriceFeed,
1000
1018
  };
1001
1019
  }
1020
+ exports.fetchKaminoReserve = fetchKaminoReserve;
1002
1021
  const DEPOSITS_LIMIT = 8;
1003
1022
  async function fetchAllKaminoObligationsByKaminoReserve(reserve, connection) {
1004
1023
  const finalObligations = [];
@@ -1027,6 +1046,7 @@ async function fetchAllKaminoObligationsByKaminoReserve(reserve, connection) {
1027
1046
  }
1028
1047
  return finalObligations;
1029
1048
  }
1049
+ exports.fetchAllKaminoObligationsByKaminoReserve = fetchAllKaminoObligationsByKaminoReserve;
1030
1050
  function serializeEmission(emission) {
1031
1051
  return {
1032
1052
  tokenAccount: emission.tokenAccount.toString(),
@@ -1038,6 +1058,7 @@ function serializeEmission(emission) {
1038
1058
  treasuryEmission: emission.treasuryEmission.toString(),
1039
1059
  };
1040
1060
  }
1061
+ exports.serializeEmission = serializeEmission;
1041
1062
  function deserializeEmission(emission) {
1042
1063
  return {
1043
1064
  tokenAccount: new anchor_1.web3.PublicKey(emission.tokenAccount),
@@ -1049,9 +1070,11 @@ function deserializeEmission(emission) {
1049
1070
  treasuryEmission: new anchor_1.BN(emission.treasuryEmission),
1050
1071
  };
1051
1072
  }
1073
+ exports.deserializeEmission = deserializeEmission;
1052
1074
  function deserializeAnchorizedPNum(x) {
1053
1075
  return parseFloat(precise_number_1.PreciseNumber.fromRaw(x[0]).valueString);
1054
1076
  }
1077
+ exports.deserializeAnchorizedPNum = deserializeAnchorizedPNum;
1055
1078
  /** Convert PreciseNumber (Number type in Rust) from Anchor format to raw 256-bit bigint */
1056
1079
  function anchorizedPNumToRawBigint(pnum) {
1057
1080
  const bnArray = pnum[0];
@@ -1061,6 +1084,7 @@ function anchorizedPNumToRawBigint(pnum) {
1061
1084
  }
1062
1085
  return val;
1063
1086
  }
1087
+ exports.anchorizedPNumToRawBigint = anchorizedPNumToRawBigint;
1064
1088
  /** Fetch the exchange rate of a JitoRestaking vault's VRT to JitoSOL */
1065
1089
  async function fetchJitoVaultData({ connection, vaultAddress, }) {
1066
1090
  const vaultAccountInfo = await connection.getAccountInfo(vaultAddress);
@@ -1077,6 +1101,7 @@ async function fetchSplStakePoolIndex({ connection, stakePool, }) {
1077
1101
  const stakePoolAccount = await (0, spl_stake_pool_1.getStakePoolAccount)(connection, stakePool);
1078
1102
  return Number(stakePoolAccount.account.data.totalLamports) / Number(stakePoolAccount.account.data.poolTokenSupply);
1079
1103
  }
1104
+ exports.fetchSplStakePoolIndex = fetchSplStakePoolIndex;
1080
1105
  async function fetchPerenaStablePoolData({ connection, perenaStablePool, }) {
1081
1106
  const lpMint = (0, perena_1.getPerenaLpMint)(perenaStablePool);
1082
1107
  const [accountInfo, lpMintInfo] = await connection.getMultipleAccountsInfo([perenaStablePool, lpMint]);
@@ -1086,6 +1111,7 @@ async function fetchPerenaStablePoolData({ connection, perenaStablePool, }) {
1086
1111
  });
1087
1112
  return { lpSupply, invT, exchangeRate, lpMint };
1088
1113
  }
1114
+ exports.fetchPerenaStablePoolData = fetchPerenaStablePoolData;
1089
1115
  /**
1090
1116
  * Fetch the exchange rate of a JitoRestaking vault
1091
1117
  * @param connection
@@ -1106,6 +1132,7 @@ async function fetchJitoRestaking(connection, accounts, interfaceType, vaultAddr
1106
1132
  exchangeRate: exr.toString(),
1107
1133
  };
1108
1134
  }
1135
+ exports.fetchJitoRestaking = fetchJitoRestaking;
1109
1136
  /**
1110
1137
  * Fetch the pre-simulated index for Jupiter Perps pool to mirror on-chain logic in utils.rs (InterfaceType::JupiterPerps)
1111
1138
  * Uses fields: pool.pool_apr.{realized_fee_usd, fee_apr_bps, last_updated}, pool.aum_usd,
@@ -1121,9 +1148,11 @@ async function fetchJupiterPerpsIndex({ connection, pool, lastFeeUsdResetUnixTim
1121
1148
  lastRealizedFeeUsdUpdateUnixTimestamp,
1122
1149
  });
1123
1150
  }
1151
+ exports.fetchJupiterPerpsIndex = fetchJupiterPerpsIndex;
1124
1152
  async function fetchPyth(connection) {
1125
1153
  return "";
1126
1154
  }
1155
+ exports.fetchPyth = fetchPyth;
1127
1156
  async function fetchGenericSyMetaIndex({ connection, genericSyMeta, }) {
1128
1157
  const [accountInfo] = await connection.getMultipleAccountsInfo([genericSyMeta]);
1129
1158
  const d = accountInfo.data;
@@ -1148,6 +1177,7 @@ async function fetchGenericSyMetaIndex({ connection, genericSyMeta, }) {
1148
1177
  const index = parseFloat(precise_number_1.PreciseNumber.fromRaw(indexRaw[0]).valueString);
1149
1178
  return { index };
1150
1179
  }
1180
+ exports.fetchGenericSyMetaIndex = fetchGenericSyMetaIndex;
1151
1181
  async function fetchFragmetricIndex({ connection, fragmetricFund, }) {
1152
1182
  const fragmetricFundRaw = await connection.getAccountInfo(fragmetricFund);
1153
1183
  const { index, receiptTokenMint, wrappedTokenMint } = (0, fragmetric_1.calculateFragmetricIndex)({
@@ -1155,6 +1185,7 @@ async function fetchFragmetricIndex({ connection, fragmetricFund, }) {
1155
1185
  });
1156
1186
  return { index, receiptTokenMint, wrappedTokenMint };
1157
1187
  }
1188
+ exports.fetchFragmetricIndex = fetchFragmetricIndex;
1158
1189
  async function fetchJupiterLendIndex({ connection, jupiterLendAccount, }) {
1159
1190
  const account = await connection.getAccountInfo(jupiterLendAccount);
1160
1191
  const rateModel = jupiterLendAccount.equals(new anchor_1.web3.PublicKey("BeAqbxfrcXmzEYT2Ra62oW2MqkuFDHaCtps47Mzg6Zj3"))
@@ -1171,30 +1202,72 @@ async function fetchJupiterLendIndex({ connection, jupiterLendAccount, }) {
1171
1202
  rewardsRateModel,
1172
1203
  };
1173
1204
  }
1205
+ exports.fetchJupiterLendIndex = fetchJupiterLendIndex;
1174
1206
  async function fetchKaminoVaultIndex({ connection, kaminoVaultAccount, }) {
1175
1207
  const account = await connection.getAccountInfo(kaminoVaultAccount);
1176
1208
  const coder = new anchor_2.BorshCoder(kamino_vault_idl_1.IDL);
1177
1209
  const data = coder.accounts.decode("VaultState", account.data);
1178
- const activeReserves = data.vault_allocation_strategy
1179
- .map((r) => r.reserve)
1180
- .filter((reserve) => reserve.toBase58() !== anchor_1.web3.PublicKey.default.toBase58());
1181
- const activeReservesData = await connection.getMultipleAccountsInfo(activeReserves);
1210
+ const activeAllocations = data.vault_allocation_strategy
1211
+ .filter((allocation) => allocation.reserve.toBase58() !== anchor_1.web3.PublicKey.default.toBase58());
1212
+ const activeReserves = activeAllocations.map((allocation) => allocation.reserve);
1213
+ const [activeReservesData, tokenMintInfo, sharesMintInfo] = await Promise.all([
1214
+ connection.getMultipleAccountsInfo(activeReserves),
1215
+ connection.getAccountInfo(data.token_mint),
1216
+ connection.getAccountInfo(data.shares_mint),
1217
+ ]);
1218
+ const decodedReserves = activeReservesData.map((accountInfo, index) => {
1219
+ if (!accountInfo?.data) {
1220
+ throw new Error(`Missing Kamino reserve account ${activeReserves[index].toBase58()}`);
1221
+ }
1222
+ return kamino_reserve_deserializer_1.Reserve.decode(accountInfo.data);
1223
+ });
1224
+ const collateralMintInfos = await connection.getMultipleAccountsInfo(decodedReserves.map((reserve) => reserve.collateral.mintPubkey));
1182
1225
  const reserves = activeReserves.map((r, i) => {
1226
+ const reserveAccount = decodedReserves[i];
1227
+ const allocation = activeAllocations[i];
1228
+ const [lendingMarketAuthority] = anchor_1.web3.PublicKey.findProgramAddressSync([Buffer.from("lma"), reserveAccount.lendingMarket.toBuffer()], new anchor_1.web3.PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD"));
1183
1229
  return {
1184
1230
  reserveAddress: r,
1185
- reserve: kamino_reserve_deserializer_1.Reserve.decode(activeReservesData[i].data).lendingMarket,
1231
+ marketAddress: reserveAccount.lendingMarket,
1232
+ ctokenVault: allocation.ctoken_vault,
1233
+ lendingMarketAuthority,
1234
+ pythOracle: reserveAccount.config.tokenInfo.pythConfiguration.price,
1235
+ switchboardPriceOracle: reserveAccount.config.tokenInfo.switchboardConfiguration.priceAggregator,
1236
+ switchboardTwapOracle: reserveAccount.config.tokenInfo.switchboardConfiguration.twapAggregator,
1237
+ scopePrices: reserveAccount.config.tokenInfo.scopeConfiguration.priceFeed,
1238
+ reserveLiquiditySupply: reserveAccount.liquidity.supplyVault,
1239
+ reserveCollateralMint: reserveAccount.collateral.mintPubkey,
1240
+ reserveCollateralTokenProgram: collateralMintInfos[i]?.owner ?? anchor_1.web3.PublicKey.default,
1186
1241
  };
1187
1242
  });
1188
1243
  const tokenVault = data.token_vault;
1189
1244
  const tokenMint = data.token_mint;
1190
1245
  const baseVaultAuthority = data.base_vault_authority;
1191
1246
  const sharesMint = data.shares_mint;
1192
- return { index: 1, tokenVault, tokenMint, baseVaultAuthority, sharesMint, reserves };
1247
+ const vaultLookupTable = data.vault_lookup_table ?? anchor_1.web3.PublicKey.default;
1248
+ const tokenProgram = tokenMintInfo?.owner ?? anchor_1.web3.PublicKey.default;
1249
+ const sharesTokenProgram = sharesMintInfo?.owner ?? anchor_1.web3.PublicKey.default;
1250
+ return {
1251
+ index: 1,
1252
+ tokenVault,
1253
+ tokenMint,
1254
+ tokenProgram,
1255
+ // Kamino Vault withdraw expects the singleton program global config account.
1256
+ // It is not stored on VaultState, so fetch it from the known program-wide address.
1257
+ globalConfig: KAMINO_VAULT_GLOBAL_CONFIG,
1258
+ baseVaultAuthority,
1259
+ sharesMint,
1260
+ sharesTokenProgram,
1261
+ vaultLookupTable,
1262
+ reserves,
1263
+ };
1193
1264
  }
1265
+ exports.fetchKaminoVaultIndex = fetchKaminoVaultIndex;
1194
1266
  async function fetchFragmetricSupportedTokenIndex({ connection, fragmetricFund, index, }) {
1195
1267
  const account = await connection.getAccountInfo(fragmetricFund);
1196
1268
  return (0, fragmetric_1.calculateFragmetricSupportedTokenIndex)({ fragmetricFund: account.data }, index);
1197
1269
  }
1270
+ exports.fetchFragmetricSupportedTokenIndex = fetchFragmetricSupportedTokenIndex;
1198
1271
  async function fetchMeteoraIndex({ connection, accounts, onChainTime, }) {
1199
1272
  try {
1200
1273
  const VIRTUAL_PRICE_PRECISION = new anchor_1.BN(100_000_000);
@@ -1230,6 +1303,7 @@ async function fetchMeteoraIndex({ connection, accounts, onChainTime, }) {
1230
1303
  throw error;
1231
1304
  }
1232
1305
  }
1306
+ exports.fetchMeteoraIndex = fetchMeteoraIndex;
1233
1307
  async function fetchAdrenaIndex({ connection, accounts, previousTotalFees, currentIndex, }) {
1234
1308
  try {
1235
1309
  // Fetch all account data in a single RPC call
@@ -1255,6 +1329,7 @@ async function fetchAdrenaIndex({ connection, accounts, previousTotalFees, curre
1255
1329
  throw error;
1256
1330
  }
1257
1331
  }
1332
+ exports.fetchAdrenaIndex = fetchAdrenaIndex;
1258
1333
  async function fetchSanctumIndex({ connection, accounts, }) {
1259
1334
  const [poolStateAccountRaw, lpMintAccountRaw] = await Promise.all([accounts.poolState, accounts.lpMint].map((pk) => connection.getAccountInfo(pk)));
1260
1335
  return (0, sanctum_1.calculateSanctumIndex)({
@@ -1262,6 +1337,7 @@ async function fetchSanctumIndex({ connection, accounts, }) {
1262
1337
  lpMintAccountData: lpMintAccountRaw.data,
1263
1338
  });
1264
1339
  }
1340
+ exports.fetchSanctumIndex = fetchSanctumIndex;
1265
1341
  async function fetchSolsticeRedemptionRate({ connection, yieldPool, vestingSchedule, }) {
1266
1342
  // Fetch both accounts in a single RPC call for efficiency
1267
1343
  const accountInfos = await connection.getMultipleAccountsInfo([yieldPool, vestingSchedule]);
@@ -1270,6 +1346,7 @@ async function fetchSolsticeRedemptionRate({ connection, yieldPool, vestingSched
1270
1346
  }
1271
1347
  return (0, solstice_1.calculateSolsticeRedemptionRate)({ yieldPool: accountInfos[0].data, vestingSchedule: accountInfos[1].data });
1272
1348
  }
1349
+ exports.fetchSolsticeRedemptionRate = fetchSolsticeRedemptionRate;
1273
1350
  async function fetchSolsticeGlamVaultExchangeRate({ connection, stakingVaultSlxAta, slxMint, stslxMint, }) {
1274
1351
  const accountInfos = await connection.getMultipleAccountsInfo([stakingVaultSlxAta, slxMint, stslxMint]);
1275
1352
  if (!accountInfos[0] || !accountInfos[1] || !accountInfos[2]) {
@@ -1281,8 +1358,9 @@ async function fetchSolsticeGlamVaultExchangeRate({ connection, stakingVaultSlxA
1281
1358
  stslxMint: accountInfos[2].data,
1282
1359
  });
1283
1360
  }
1361
+ exports.fetchSolsticeGlamVaultExchangeRate = fetchSolsticeGlamVaultExchangeRate;
1284
1362
  const REFLECT_ORACLE_LEN = 17;
1285
- const REFLECT_MAX_STALENESS_SLOTS = 15000000;
1363
+ const REFLECT_MAX_STALENESS_SLOTS = 150000000000;
1286
1364
  async function fetchReflectRedemptionRate({ connection, oracle, }) {
1287
1365
  const accountInfo = await connection.getAccountInfo(oracle);
1288
1366
  if (!accountInfo) {
@@ -1308,6 +1386,7 @@ async function fetchReflectRedemptionRate({ connection, oracle, }) {
1308
1386
  }
1309
1387
  return price / scale;
1310
1388
  }
1389
+ exports.fetchReflectRedemptionRate = fetchReflectRedemptionRate;
1311
1390
  async function fetchOreExchangeRate({ connection, storeMint, stakeAccount, treasury, }) {
1312
1391
  // Fetch all accounts in parallel for efficiency
1313
1392
  const [storeMintInfo, stakeAccountInfo, treasuryAccountInfo] = await Promise.all([
@@ -1324,6 +1403,7 @@ async function fetchOreExchangeRate({ connection, storeMint, stakeAccount, treas
1324
1403
  storeMint: storeMintInfo.data,
1325
1404
  });
1326
1405
  }
1406
+ exports.fetchOreExchangeRate = fetchOreExchangeRate;
1327
1407
  async function fetchChainlinkRate({ connection, priceFeed, }) {
1328
1408
  const accountInfo = await connection.getAccountInfo(priceFeed);
1329
1409
  if (!accountInfo) {
@@ -1333,4 +1413,5 @@ async function fetchChainlinkRate({ connection, priceFeed, }) {
1333
1413
  const scale = Math.pow(10, header.decimals);
1334
1414
  return Number(answer) / scale;
1335
1415
  }
1416
+ exports.fetchChainlinkRate = fetchChainlinkRate;
1336
1417
  //# sourceMappingURL=exponentFetcher.js.map