@exponent-labs/exponent-fetcher 0.9.11 → 0.9.13
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.
- package/build/constants.js +3 -3
- package/build/constants.js.map +1 -1
- package/build/exponentFetcher.d.ts +18 -16
- package/build/exponentFetcher.js +74 -141
- package/build/exponentFetcher.js.map +1 -1
- package/build/utils/adrena.d.ts +0 -2
- package/build/utils/adrena.js +1 -2
- package/build/utils/adrena.js.map +1 -1
- package/build/utils/fragmetric.d.ts +0 -2
- package/build/utils/fragmetric.js +2 -2
- package/build/utils/fragmetric.js.map +1 -1
- package/build/utils/jito.d.ts +0 -2
- package/build/utils/jito.js +1 -2
- package/build/utils/jito.js.map +1 -1
- package/build/utils/jupiter.d.ts +0 -2
- package/build/utils/jupiter.js +2 -3
- package/build/utils/jupiter.js.map +1 -1
- package/build/utils/kamino.d.ts +0 -2
- package/build/utils/kamino.js +1 -2
- package/build/utils/kamino.js.map +1 -1
- package/build/utils/meteora.d.ts +0 -3
- package/build/utils/meteora.js +5 -5
- package/build/utils/meteora.js.map +1 -1
- package/build/utils/ore.d.ts +6 -21
- package/build/utils/ore.js +30 -85
- package/build/utils/ore.js.map +1 -1
- package/build/utils/perena.d.ts +0 -2
- package/build/utils/perena.js +2 -3
- package/build/utils/perena.js.map +1 -1
- package/build/utils/sanctum.d.ts +0 -2
- package/build/utils/sanctum.js +1 -2
- package/build/utils/sanctum.js.map +1 -1
- package/build/utils/solstice.d.ts +9 -2
- package/build/utils/solstice.js +20 -2
- package/build/utils/solstice.js.map +1 -1
- package/package.json +21 -21
- package/src/exponentFetcher.ts +75 -155
- package/src/utils/ore.ts +36 -122
- package/src/utils/solstice.ts +27 -0
package/build/constants.js
CHANGED
|
@@ -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.
|
|
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
|
*/
|
package/build/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
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 =
|
|
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;
|
|
@@ -162,18 +159,18 @@ export interface Tick {
|
|
|
162
159
|
principalSy: bigint;
|
|
163
160
|
apyBasePoints: number;
|
|
164
161
|
principalShareSupply: bigint;
|
|
165
|
-
/** Farm yield trackers (
|
|
162
|
+
/** Farm yield trackers (3 trackers) */
|
|
166
163
|
farms: {
|
|
167
164
|
lastSeenIndex: number;
|
|
168
165
|
}[];
|
|
169
|
-
/** Emission yield trackers (
|
|
166
|
+
/** Emission yield trackers (3 trackers) */
|
|
170
167
|
emissions: {
|
|
171
168
|
lastSeenIndex: number;
|
|
172
169
|
lastPositionIndex: number;
|
|
173
170
|
}[];
|
|
174
171
|
/** Last split epoch for this tick */
|
|
175
172
|
lastSplitEpoch: bigint;
|
|
176
|
-
/**
|
|
173
|
+
/** Minimum liquidity retained on ticks used by wrapper-base liquidity */
|
|
177
174
|
frozenLiquidity: bigint;
|
|
178
175
|
}
|
|
179
176
|
export interface MarketThreeRaw {
|
|
@@ -337,16 +334,12 @@ export interface Orderbook {
|
|
|
337
334
|
tokenEscrowPt: web3.PublicKey;
|
|
338
335
|
cpiAccountOrderbook: web3.PublicKey;
|
|
339
336
|
admin: web3.PublicKey;
|
|
340
|
-
/** Raw 256-bit PreciseNumber (12 decimals) for last SY exchange rate */
|
|
341
|
-
lastSyExchangeRate: bigint;
|
|
342
337
|
configurationOptions: ConfigurationOptions;
|
|
343
338
|
financials: OrderbookFinancials;
|
|
344
339
|
prices: PriceTreeNode[];
|
|
345
340
|
offers: OfferNode[];
|
|
346
341
|
userEscrows: UserEscrowNode[];
|
|
347
|
-
/** Next offer index that will be allocated (from NodeAllocator free list) */
|
|
348
342
|
offersFreeListHead: number;
|
|
349
|
-
/** Bump index boundary for offers allocator */
|
|
350
343
|
offersBumpIndex: number;
|
|
351
344
|
}
|
|
352
345
|
export interface KaminoSyMeta {
|
|
@@ -438,6 +431,12 @@ export interface LpPositionCLMM {
|
|
|
438
431
|
lastSeenIndex: number;
|
|
439
432
|
}[];
|
|
440
433
|
}[];
|
|
434
|
+
crossingSplit: {
|
|
435
|
+
crossLeftIdx: number;
|
|
436
|
+
crossRightIdx: number;
|
|
437
|
+
lpBalanceCrossing: bigint;
|
|
438
|
+
isActive: boolean;
|
|
439
|
+
};
|
|
441
440
|
}
|
|
442
441
|
export interface LpFarm {
|
|
443
442
|
lastSeenTimestamp: number;
|
|
@@ -498,12 +497,13 @@ export interface OfferNodeRaw {
|
|
|
498
497
|
}
|
|
499
498
|
export interface UserEscrowNodeRaw {
|
|
500
499
|
user: web3.PublicKey;
|
|
501
|
-
yieldIndex:
|
|
500
|
+
yieldIndex: BN;
|
|
502
501
|
ptAmount: BN;
|
|
503
502
|
syAmount: BN;
|
|
504
503
|
ytAmount: BN;
|
|
505
504
|
staged: number;
|
|
506
505
|
}
|
|
506
|
+
export declare function deserializeAnchorizedPNum(x: AnchorizedPNum): number;
|
|
507
507
|
/** Convert PreciseNumber (Number type in Rust) from Anchor format to raw 256-bit bigint */
|
|
508
508
|
export declare function anchorizedPNumToRawBigint(pnum: AnchorizedPNum): bigint;
|
|
509
509
|
export declare function fetchSplStakePoolIndex({ connection, stakePool, }: {
|
|
@@ -574,12 +574,8 @@ export declare function fetchKaminoVaultIndex({ connection, kaminoVaultAccount,
|
|
|
574
574
|
index: number;
|
|
575
575
|
tokenVault: any;
|
|
576
576
|
tokenMint: any;
|
|
577
|
-
tokenProgram: web3.PublicKey;
|
|
578
|
-
globalConfig: web3.PublicKey;
|
|
579
577
|
baseVaultAuthority: any;
|
|
580
578
|
sharesMint: any;
|
|
581
|
-
sharesTokenProgram: web3.PublicKey;
|
|
582
|
-
vaultLookupTable: any;
|
|
583
579
|
reserves: any;
|
|
584
580
|
}>;
|
|
585
581
|
export declare function fetchFragmetricSupportedTokenIndex({ connection, fragmetricFund, index, }: {
|
|
@@ -619,6 +615,12 @@ export declare function fetchSolsticeRedemptionRate({ connection, yieldPool, ves
|
|
|
619
615
|
yieldPool: web3.PublicKey;
|
|
620
616
|
vestingSchedule: web3.PublicKey;
|
|
621
617
|
}): Promise<ReturnType<typeof calculateSolsticeRedemptionRate>>;
|
|
618
|
+
export declare function fetchSolsticeGlamVaultExchangeRate({ connection, stakingVaultSlxAta, slxMint, stslxMint, }: {
|
|
619
|
+
connection: web3.Connection;
|
|
620
|
+
stakingVaultSlxAta: web3.PublicKey;
|
|
621
|
+
slxMint: web3.PublicKey;
|
|
622
|
+
stslxMint: web3.PublicKey;
|
|
623
|
+
}): Promise<number>;
|
|
622
624
|
export declare function fetchReflectRedemptionRate({ connection, oracle, }: {
|
|
623
625
|
connection: web3.Connection;
|
|
624
626
|
oracle: web3.PublicKey;
|
package/build/exponentFetcher.js
CHANGED
|
@@ -3,7 +3,37 @@ 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.
|
|
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;
|
|
7
37
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
8
38
|
const anchor_2 = require("@coral-xyz/anchor");
|
|
9
39
|
const spl_stake_pool_1 = require("@solana/spl-stake-pool");
|
|
@@ -39,17 +69,14 @@ const ore_1 = require("./utils/ore");
|
|
|
39
69
|
const perena_1 = require("./utils/perena");
|
|
40
70
|
const sanctum_1 = require("./utils/sanctum");
|
|
41
71
|
const solstice_1 = require("./utils/solstice");
|
|
42
|
-
const KAMINO_VAULT_GLOBAL_CONFIG = new anchor_1.web3.PublicKey("BKyTcUe6daNG8HbgBix2ugdRHbykG2dK9hPBBqhUyoEX");
|
|
43
72
|
function serializeAnchorizedPNumFromJson(pnum) {
|
|
44
73
|
const serializedArray = pnum[0].map((bn) => bn.toString());
|
|
45
74
|
return { 0: serializedArray };
|
|
46
75
|
}
|
|
47
|
-
exports.serializeAnchorizedPNumFromJson = serializeAnchorizedPNumFromJson;
|
|
48
76
|
function deserializeAnchorizedPNumFromJson(serialized) {
|
|
49
77
|
const bnArray = serialized[0].map((str) => new anchor_1.BN(str));
|
|
50
78
|
return { 0: bnArray };
|
|
51
79
|
}
|
|
52
|
-
exports.deserializeAnchorizedPNumFromJson = deserializeAnchorizedPNumFromJson;
|
|
53
80
|
class MyWallet {
|
|
54
81
|
payer;
|
|
55
82
|
constructor(payer) {
|
|
@@ -266,6 +293,11 @@ class ExponentFetcher {
|
|
|
266
293
|
},
|
|
267
294
|
})),
|
|
268
295
|
},
|
|
296
|
+
crossingSplit: {
|
|
297
|
+
crossLeftIdx: raw.crossingSplit.crossLeftIdx,
|
|
298
|
+
crossRightIdx: raw.crossingSplit.crossRightIdx,
|
|
299
|
+
lpBalanceCrossing: raw.crossingSplit.lpBalanceCrossing,
|
|
300
|
+
},
|
|
269
301
|
};
|
|
270
302
|
return deserializeLpPositionCLMM(v);
|
|
271
303
|
}
|
|
@@ -380,7 +412,7 @@ exports.ExponentFetcher = ExponentFetcher;
|
|
|
380
412
|
* Layout matches Rust struct `Ticks` with `RedBlackTree<u32, Tick, 1000>`:
|
|
381
413
|
* - Discriminator: 8 bytes
|
|
382
414
|
* - 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 =
|
|
415
|
+
* - 1000 RBTree nodes, each: nodeHeader(16) + key(4) + padding(4) + Tick(416) = 440 bytes
|
|
384
416
|
* - Ticks footer: market(32) + feeGrowthPt(16) + feeGrowthSy(16) + prefixSum(8) + spotPrice(8) + currentTick(4) + padding(12) = 96 bytes
|
|
385
417
|
*/
|
|
386
418
|
function deserializeMarketThreeTicks(data) {
|
|
@@ -465,12 +497,12 @@ function deserializeMarketThreeTicks(data) {
|
|
|
465
497
|
const principalPt = readU64(); // 8 bytes
|
|
466
498
|
const principalSy = readU64(); // 8 bytes
|
|
467
499
|
const principalShareSupply = readPreciseNumberAsBigint(); // 32 bytes - kept as bigint for arithmetic
|
|
468
|
-
// FarmYieldTrackers:
|
|
500
|
+
// FarmYieldTrackers: 3 x FarmYieldTracker(32 bytes) = 96 bytes
|
|
469
501
|
const farms = [];
|
|
470
502
|
for (let j = 0; j < PERSONAL_TICK_YIELD_TRACKER_SIZE; j++) {
|
|
471
503
|
farms.push({ lastSeenIndex: readPreciseNumberAsFloat() });
|
|
472
504
|
}
|
|
473
|
-
// EmissionYieldTrackers:
|
|
505
|
+
// EmissionYieldTrackers: 3 x EmissionYieldTracker(64 bytes) = 192 bytes
|
|
474
506
|
const emissions = [];
|
|
475
507
|
for (let j = 0; j < PERSONAL_TICK_YIELD_TRACKER_SIZE; j++) {
|
|
476
508
|
emissions.push({
|
|
@@ -514,51 +546,7 @@ function deserializeMarketThreeTicks(data) {
|
|
|
514
546
|
currentTick,
|
|
515
547
|
};
|
|
516
548
|
}
|
|
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
549
|
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
550
|
return {
|
|
563
551
|
addressLookupTable: m.addressLookupTable,
|
|
564
552
|
mintSy: m.mintSy,
|
|
@@ -571,7 +559,7 @@ function deserializeMarketThree(m) {
|
|
|
571
559
|
selfAddress: m.selfAddress,
|
|
572
560
|
syProgram: m.syProgram,
|
|
573
561
|
statusFlags: m.statusFlags,
|
|
574
|
-
cpiSyAccounts,
|
|
562
|
+
cpiSyAccounts: m.cpiSyAccounts,
|
|
575
563
|
isCurrentFlashSwap: m.isCurrentFlashSwap,
|
|
576
564
|
lpFarm: m.lpFarm,
|
|
577
565
|
mintYt: m.mintYt,
|
|
@@ -600,12 +588,11 @@ function deserializeMarketThree(m) {
|
|
|
600
588
|
syBalance: BigInt(m.financials.syBalance.toString()),
|
|
601
589
|
liquidityBalance: BigInt(m.financials.liquidityBalance.toString()),
|
|
602
590
|
},
|
|
603
|
-
cpiCoreAccounts,
|
|
591
|
+
cpiCoreAccounts: m.cpiCoreAccounts,
|
|
604
592
|
exponentCoreProgram: m.exponentCoreProgram,
|
|
605
593
|
seedId: m.seedId,
|
|
606
594
|
};
|
|
607
595
|
}
|
|
608
|
-
exports.deserializeMarketThree = deserializeMarketThree;
|
|
609
596
|
function deserializeMarketTwo(m) {
|
|
610
597
|
return {
|
|
611
598
|
ptBalance: BigInt(m.financials.ptBalance.toString()),
|
|
@@ -668,6 +655,12 @@ function deserializeLpPositionCLMM(x) {
|
|
|
668
655
|
lastSeenIndex: parseFloat(precise_number_1.PreciseNumber.fromRaw(e.lastSeenIndex[0]).valueString),
|
|
669
656
|
})),
|
|
670
657
|
})),
|
|
658
|
+
crossingSplit: {
|
|
659
|
+
crossLeftIdx: x.crossingSplit.crossLeftIdx,
|
|
660
|
+
crossRightIdx: x.crossingSplit.crossRightIdx,
|
|
661
|
+
lpBalanceCrossing: BigInt(x.crossingSplit.lpBalanceCrossing.toString()),
|
|
662
|
+
isActive: x.crossingSplit.crossLeftIdx !== 0xffffffff && x.crossingSplit.crossRightIdx !== 0xffffffff,
|
|
663
|
+
},
|
|
671
664
|
};
|
|
672
665
|
}
|
|
673
666
|
function deserializeVault(x) {
|
|
@@ -718,7 +711,8 @@ function deserializeOrderbook(data) {
|
|
|
718
711
|
offset += 8;
|
|
719
712
|
const priceDecimals = data.readUint8(offset);
|
|
720
713
|
offset += 1;
|
|
721
|
-
// Skip ConfigurationOptions padding:
|
|
714
|
+
// Skip ConfigurationOptions padding/reserve:
|
|
715
|
+
// _placeholder_one[15] + _placeholder_two[32] + _placeholder_three[32] + _placeholder_four[32] + _reserved[1024]
|
|
722
716
|
offset += 1135;
|
|
723
717
|
// Pubkeys
|
|
724
718
|
const vault = readPubkey();
|
|
@@ -731,14 +725,7 @@ function deserializeOrderbook(data) {
|
|
|
731
725
|
const tokenEscrowPt = readPubkey();
|
|
732
726
|
const cpiAccountOrderbook = readPubkey();
|
|
733
727
|
const admin = readPubkey();
|
|
734
|
-
// last_sy_exchange_rate (Number type = 32 bytes
|
|
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
|
-
})();
|
|
728
|
+
// Skip last_sy_exchange_rate (Number type = 32 bytes)
|
|
742
729
|
offset += 32;
|
|
743
730
|
// OrderbookFinancials struct
|
|
744
731
|
// Skip last_seen_sy_index (Number type = 32 bytes)
|
|
@@ -882,12 +869,7 @@ function deserializeOrderbook(data) {
|
|
|
882
869
|
offset += 4;
|
|
883
870
|
const user = new anchor_1.web3.PublicKey(data.slice(offset, offset + 32));
|
|
884
871
|
offset += 32;
|
|
885
|
-
const
|
|
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;
|
|
872
|
+
/*const yieldIndex = data.readBigUInt64LE(offset).toString();*/ offset += 32;
|
|
891
873
|
const ptAmount = data.readBigUInt64LE(offset);
|
|
892
874
|
offset += 8;
|
|
893
875
|
const syAmount = data.readBigUInt64LE(offset);
|
|
@@ -900,7 +882,7 @@ function deserializeOrderbook(data) {
|
|
|
900
882
|
offset += 8;
|
|
901
883
|
offset += 8; // reserved
|
|
902
884
|
// if (user.toBase58() == "11111111111111111111111111111111") continue
|
|
903
|
-
userEscrows.push({ user, yieldIndex, ptAmount, syAmount, ytAmount, stakedYtAmount, staged });
|
|
885
|
+
userEscrows.push({ user, yieldIndex: 0, ptAmount, syAmount, ytAmount, stakedYtAmount, staged });
|
|
904
886
|
}
|
|
905
887
|
// ─── Finally, seed_id + signer_bump + reserved ─────────────────────────────
|
|
906
888
|
// seed_id: [u8; 4]
|
|
@@ -927,14 +909,13 @@ function deserializeOrderbook(data) {
|
|
|
927
909
|
tokenEscrowYt,
|
|
928
910
|
tokenEscrowPt,
|
|
929
911
|
cpiAccountOrderbook,
|
|
930
|
-
lastSyExchangeRate: lastSyExchangeRateRaw,
|
|
931
912
|
financials,
|
|
932
913
|
prices,
|
|
933
914
|
configurationOptions,
|
|
934
915
|
offers,
|
|
935
916
|
userEscrows,
|
|
936
|
-
offersBumpIndex,
|
|
937
917
|
offersFreeListHead,
|
|
918
|
+
offersBumpIndex,
|
|
938
919
|
};
|
|
939
920
|
}
|
|
940
921
|
function deserializeMarginfiSyMeta(x) {
|
|
@@ -943,6 +924,7 @@ function deserializeMarginfiSyMeta(x) {
|
|
|
943
924
|
maxSySupply: BigInt(x.maxSySupply.toString()),
|
|
944
925
|
minMintSize: BigInt(x.minMintSize.toString()),
|
|
945
926
|
minRedeemSize: BigInt(x.minRedeemSize.toString()),
|
|
927
|
+
lastSlotCached: BigInt(x.lastSlotCached.toString()),
|
|
946
928
|
};
|
|
947
929
|
}
|
|
948
930
|
function deserializeSyEmissionRaw(x) {
|
|
@@ -972,7 +954,6 @@ function deserializeLpPosition(x) {
|
|
|
972
954
|
})),
|
|
973
955
|
};
|
|
974
956
|
}
|
|
975
|
-
exports.deserializeLpPosition = deserializeLpPosition;
|
|
976
957
|
function deserializeYtPosition(x) {
|
|
977
958
|
return {
|
|
978
959
|
owner: x.owner,
|
|
@@ -982,7 +963,6 @@ function deserializeYtPosition(x) {
|
|
|
982
963
|
emissions: x.emissions.map(deserializeYieldTokenTracker),
|
|
983
964
|
};
|
|
984
965
|
}
|
|
985
|
-
exports.deserializeYtPosition = deserializeYtPosition;
|
|
986
966
|
function deserializeYieldTokenTracker(x) {
|
|
987
967
|
return {
|
|
988
968
|
staged: BigInt(x.staged.toString()),
|
|
@@ -1003,7 +983,6 @@ async function fetchKaminoReserve(address, connection) {
|
|
|
1003
983
|
scopePriceFeed,
|
|
1004
984
|
};
|
|
1005
985
|
}
|
|
1006
|
-
exports.fetchKaminoReserve = fetchKaminoReserve;
|
|
1007
986
|
const DEPOSITS_LIMIT = 8;
|
|
1008
987
|
async function fetchAllKaminoObligationsByKaminoReserve(reserve, connection) {
|
|
1009
988
|
const finalObligations = [];
|
|
@@ -1032,7 +1011,6 @@ async function fetchAllKaminoObligationsByKaminoReserve(reserve, connection) {
|
|
|
1032
1011
|
}
|
|
1033
1012
|
return finalObligations;
|
|
1034
1013
|
}
|
|
1035
|
-
exports.fetchAllKaminoObligationsByKaminoReserve = fetchAllKaminoObligationsByKaminoReserve;
|
|
1036
1014
|
function serializeEmission(emission) {
|
|
1037
1015
|
return {
|
|
1038
1016
|
tokenAccount: emission.tokenAccount.toString(),
|
|
@@ -1044,7 +1022,6 @@ function serializeEmission(emission) {
|
|
|
1044
1022
|
treasuryEmission: emission.treasuryEmission.toString(),
|
|
1045
1023
|
};
|
|
1046
1024
|
}
|
|
1047
|
-
exports.serializeEmission = serializeEmission;
|
|
1048
1025
|
function deserializeEmission(emission) {
|
|
1049
1026
|
return {
|
|
1050
1027
|
tokenAccount: new anchor_1.web3.PublicKey(emission.tokenAccount),
|
|
@@ -1056,7 +1033,6 @@ function deserializeEmission(emission) {
|
|
|
1056
1033
|
treasuryEmission: new anchor_1.BN(emission.treasuryEmission),
|
|
1057
1034
|
};
|
|
1058
1035
|
}
|
|
1059
|
-
exports.deserializeEmission = deserializeEmission;
|
|
1060
1036
|
function deserializeAnchorizedPNum(x) {
|
|
1061
1037
|
return parseFloat(precise_number_1.PreciseNumber.fromRaw(x[0]).valueString);
|
|
1062
1038
|
}
|
|
@@ -1069,7 +1045,6 @@ function anchorizedPNumToRawBigint(pnum) {
|
|
|
1069
1045
|
}
|
|
1070
1046
|
return val;
|
|
1071
1047
|
}
|
|
1072
|
-
exports.anchorizedPNumToRawBigint = anchorizedPNumToRawBigint;
|
|
1073
1048
|
/** Fetch the exchange rate of a JitoRestaking vault's VRT to JitoSOL */
|
|
1074
1049
|
async function fetchJitoVaultData({ connection, vaultAddress, }) {
|
|
1075
1050
|
const vaultAccountInfo = await connection.getAccountInfo(vaultAddress);
|
|
@@ -1086,7 +1061,6 @@ async function fetchSplStakePoolIndex({ connection, stakePool, }) {
|
|
|
1086
1061
|
const stakePoolAccount = await (0, spl_stake_pool_1.getStakePoolAccount)(connection, stakePool);
|
|
1087
1062
|
return Number(stakePoolAccount.account.data.totalLamports) / Number(stakePoolAccount.account.data.poolTokenSupply);
|
|
1088
1063
|
}
|
|
1089
|
-
exports.fetchSplStakePoolIndex = fetchSplStakePoolIndex;
|
|
1090
1064
|
async function fetchPerenaStablePoolData({ connection, perenaStablePool, }) {
|
|
1091
1065
|
const lpMint = (0, perena_1.getPerenaLpMint)(perenaStablePool);
|
|
1092
1066
|
const [accountInfo, lpMintInfo] = await connection.getMultipleAccountsInfo([perenaStablePool, lpMint]);
|
|
@@ -1096,7 +1070,6 @@ async function fetchPerenaStablePoolData({ connection, perenaStablePool, }) {
|
|
|
1096
1070
|
});
|
|
1097
1071
|
return { lpSupply, invT, exchangeRate, lpMint };
|
|
1098
1072
|
}
|
|
1099
|
-
exports.fetchPerenaStablePoolData = fetchPerenaStablePoolData;
|
|
1100
1073
|
/**
|
|
1101
1074
|
* Fetch the exchange rate of a JitoRestaking vault
|
|
1102
1075
|
* @param connection
|
|
@@ -1117,7 +1090,6 @@ async function fetchJitoRestaking(connection, accounts, interfaceType, vaultAddr
|
|
|
1117
1090
|
exchangeRate: exr.toString(),
|
|
1118
1091
|
};
|
|
1119
1092
|
}
|
|
1120
|
-
exports.fetchJitoRestaking = fetchJitoRestaking;
|
|
1121
1093
|
/**
|
|
1122
1094
|
* Fetch the pre-simulated index for Jupiter Perps pool to mirror on-chain logic in utils.rs (InterfaceType::JupiterPerps)
|
|
1123
1095
|
* Uses fields: pool.pool_apr.{realized_fee_usd, fee_apr_bps, last_updated}, pool.aum_usd,
|
|
@@ -1133,11 +1105,9 @@ async function fetchJupiterPerpsIndex({ connection, pool, lastFeeUsdResetUnixTim
|
|
|
1133
1105
|
lastRealizedFeeUsdUpdateUnixTimestamp,
|
|
1134
1106
|
});
|
|
1135
1107
|
}
|
|
1136
|
-
exports.fetchJupiterPerpsIndex = fetchJupiterPerpsIndex;
|
|
1137
1108
|
async function fetchPyth(connection) {
|
|
1138
1109
|
return "";
|
|
1139
1110
|
}
|
|
1140
|
-
exports.fetchPyth = fetchPyth;
|
|
1141
1111
|
async function fetchGenericSyMetaIndex({ connection, genericSyMeta, }) {
|
|
1142
1112
|
const [accountInfo] = await connection.getMultipleAccountsInfo([genericSyMeta]);
|
|
1143
1113
|
const d = accountInfo.data;
|
|
@@ -1162,7 +1132,6 @@ async function fetchGenericSyMetaIndex({ connection, genericSyMeta, }) {
|
|
|
1162
1132
|
const index = parseFloat(precise_number_1.PreciseNumber.fromRaw(indexRaw[0]).valueString);
|
|
1163
1133
|
return { index };
|
|
1164
1134
|
}
|
|
1165
|
-
exports.fetchGenericSyMetaIndex = fetchGenericSyMetaIndex;
|
|
1166
1135
|
async function fetchFragmetricIndex({ connection, fragmetricFund, }) {
|
|
1167
1136
|
const fragmetricFundRaw = await connection.getAccountInfo(fragmetricFund);
|
|
1168
1137
|
const { index, receiptTokenMint, wrappedTokenMint } = (0, fragmetric_1.calculateFragmetricIndex)({
|
|
@@ -1170,7 +1139,6 @@ async function fetchFragmetricIndex({ connection, fragmetricFund, }) {
|
|
|
1170
1139
|
});
|
|
1171
1140
|
return { index, receiptTokenMint, wrappedTokenMint };
|
|
1172
1141
|
}
|
|
1173
|
-
exports.fetchFragmetricIndex = fetchFragmetricIndex;
|
|
1174
1142
|
async function fetchJupiterLendIndex({ connection, jupiterLendAccount, }) {
|
|
1175
1143
|
const account = await connection.getAccountInfo(jupiterLendAccount);
|
|
1176
1144
|
const rateModel = jupiterLendAccount.equals(new anchor_1.web3.PublicKey("BeAqbxfrcXmzEYT2Ra62oW2MqkuFDHaCtps47Mzg6Zj3"))
|
|
@@ -1187,72 +1155,33 @@ async function fetchJupiterLendIndex({ connection, jupiterLendAccount, }) {
|
|
|
1187
1155
|
rewardsRateModel,
|
|
1188
1156
|
};
|
|
1189
1157
|
}
|
|
1190
|
-
exports.fetchJupiterLendIndex = fetchJupiterLendIndex;
|
|
1191
1158
|
async function fetchKaminoVaultIndex({ connection, kaminoVaultAccount, }) {
|
|
1192
1159
|
const account = await connection.getAccountInfo(kaminoVaultAccount);
|
|
1193
1160
|
const coder = new anchor_2.BorshCoder(kamino_vault_idl_1.IDL);
|
|
1194
1161
|
const data = coder.accounts.decode("VaultState", account.data);
|
|
1195
|
-
const
|
|
1196
|
-
.
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
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));
|
|
1162
|
+
const activeReserves = data.vault_allocation_strategy
|
|
1163
|
+
.map((r) => r.reserve)
|
|
1164
|
+
.filter((reserve) => reserve.toBase58() !== anchor_1.web3.PublicKey.default.toBase58());
|
|
1165
|
+
console.log("activeReserves", activeReserves);
|
|
1166
|
+
const activeReservesData = await connection.getMultipleAccountsInfo(activeReserves);
|
|
1210
1167
|
const reserves = activeReserves.map((r, i) => {
|
|
1211
|
-
|
|
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"));
|
|
1168
|
+
console.log("r.data", activeReservesData[i].data);
|
|
1214
1169
|
return {
|
|
1215
1170
|
reserveAddress: r,
|
|
1216
|
-
|
|
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,
|
|
1171
|
+
reserve: kamino_reserve_deserializer_1.Reserve.decode(activeReservesData[i].data).lendingMarket,
|
|
1226
1172
|
};
|
|
1227
1173
|
});
|
|
1174
|
+
console.log("reserves", reserves);
|
|
1228
1175
|
const tokenVault = data.token_vault;
|
|
1229
1176
|
const tokenMint = data.token_mint;
|
|
1230
1177
|
const baseVaultAuthority = data.base_vault_authority;
|
|
1231
1178
|
const sharesMint = data.shares_mint;
|
|
1232
|
-
|
|
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
|
-
};
|
|
1179
|
+
return { index: 1, tokenVault, tokenMint, baseVaultAuthority, sharesMint, reserves };
|
|
1249
1180
|
}
|
|
1250
|
-
exports.fetchKaminoVaultIndex = fetchKaminoVaultIndex;
|
|
1251
1181
|
async function fetchFragmetricSupportedTokenIndex({ connection, fragmetricFund, index, }) {
|
|
1252
1182
|
const account = await connection.getAccountInfo(fragmetricFund);
|
|
1253
1183
|
return (0, fragmetric_1.calculateFragmetricSupportedTokenIndex)({ fragmetricFund: account.data }, index);
|
|
1254
1184
|
}
|
|
1255
|
-
exports.fetchFragmetricSupportedTokenIndex = fetchFragmetricSupportedTokenIndex;
|
|
1256
1185
|
async function fetchMeteoraIndex({ connection, accounts, onChainTime, }) {
|
|
1257
1186
|
try {
|
|
1258
1187
|
const VIRTUAL_PRICE_PRECISION = new anchor_1.BN(100_000_000);
|
|
@@ -1288,7 +1217,6 @@ async function fetchMeteoraIndex({ connection, accounts, onChainTime, }) {
|
|
|
1288
1217
|
throw error;
|
|
1289
1218
|
}
|
|
1290
1219
|
}
|
|
1291
|
-
exports.fetchMeteoraIndex = fetchMeteoraIndex;
|
|
1292
1220
|
async function fetchAdrenaIndex({ connection, accounts, previousTotalFees, currentIndex, }) {
|
|
1293
1221
|
try {
|
|
1294
1222
|
// Fetch all account data in a single RPC call
|
|
@@ -1314,7 +1242,6 @@ async function fetchAdrenaIndex({ connection, accounts, previousTotalFees, curre
|
|
|
1314
1242
|
throw error;
|
|
1315
1243
|
}
|
|
1316
1244
|
}
|
|
1317
|
-
exports.fetchAdrenaIndex = fetchAdrenaIndex;
|
|
1318
1245
|
async function fetchSanctumIndex({ connection, accounts, }) {
|
|
1319
1246
|
const [poolStateAccountRaw, lpMintAccountRaw] = await Promise.all([accounts.poolState, accounts.lpMint].map((pk) => connection.getAccountInfo(pk)));
|
|
1320
1247
|
return (0, sanctum_1.calculateSanctumIndex)({
|
|
@@ -1322,7 +1249,6 @@ async function fetchSanctumIndex({ connection, accounts, }) {
|
|
|
1322
1249
|
lpMintAccountData: lpMintAccountRaw.data,
|
|
1323
1250
|
});
|
|
1324
1251
|
}
|
|
1325
|
-
exports.fetchSanctumIndex = fetchSanctumIndex;
|
|
1326
1252
|
async function fetchSolsticeRedemptionRate({ connection, yieldPool, vestingSchedule, }) {
|
|
1327
1253
|
// Fetch both accounts in a single RPC call for efficiency
|
|
1328
1254
|
const accountInfos = await connection.getMultipleAccountsInfo([yieldPool, vestingSchedule]);
|
|
@@ -1331,7 +1257,17 @@ async function fetchSolsticeRedemptionRate({ connection, yieldPool, vestingSched
|
|
|
1331
1257
|
}
|
|
1332
1258
|
return (0, solstice_1.calculateSolsticeRedemptionRate)({ yieldPool: accountInfos[0].data, vestingSchedule: accountInfos[1].data });
|
|
1333
1259
|
}
|
|
1334
|
-
|
|
1260
|
+
async function fetchSolsticeGlamVaultExchangeRate({ connection, stakingVaultSlxAta, slxMint, stslxMint, }) {
|
|
1261
|
+
const accountInfos = await connection.getMultipleAccountsInfo([stakingVaultSlxAta, slxMint, stslxMint]);
|
|
1262
|
+
if (!accountInfos[0] || !accountInfos[1] || !accountInfos[2]) {
|
|
1263
|
+
throw new Error("One or more Solstice GLAM vault accounts not found");
|
|
1264
|
+
}
|
|
1265
|
+
return (0, solstice_1.calculateSolsticeGlamVaultExchangeRate)({
|
|
1266
|
+
stakingVaultSlxAta: accountInfos[0].data,
|
|
1267
|
+
slxMint: accountInfos[1].data,
|
|
1268
|
+
stslxMint: accountInfos[2].data,
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1335
1271
|
const REFLECT_ORACLE_LEN = 17;
|
|
1336
1272
|
const REFLECT_MAX_STALENESS_SLOTS = 15000000;
|
|
1337
1273
|
async function fetchReflectRedemptionRate({ connection, oracle, }) {
|
|
@@ -1359,7 +1295,6 @@ async function fetchReflectRedemptionRate({ connection, oracle, }) {
|
|
|
1359
1295
|
}
|
|
1360
1296
|
return price / scale;
|
|
1361
1297
|
}
|
|
1362
|
-
exports.fetchReflectRedemptionRate = fetchReflectRedemptionRate;
|
|
1363
1298
|
async function fetchOreExchangeRate({ connection, storeMint, stakeAccount, treasury, }) {
|
|
1364
1299
|
// Fetch all accounts in parallel for efficiency
|
|
1365
1300
|
const [storeMintInfo, stakeAccountInfo, treasuryAccountInfo] = await Promise.all([
|
|
@@ -1376,7 +1311,6 @@ async function fetchOreExchangeRate({ connection, storeMint, stakeAccount, treas
|
|
|
1376
1311
|
storeMint: storeMintInfo.data,
|
|
1377
1312
|
});
|
|
1378
1313
|
}
|
|
1379
|
-
exports.fetchOreExchangeRate = fetchOreExchangeRate;
|
|
1380
1314
|
async function fetchChainlinkRate({ connection, priceFeed, }) {
|
|
1381
1315
|
const accountInfo = await connection.getAccountInfo(priceFeed);
|
|
1382
1316
|
if (!accountInfo) {
|
|
@@ -1386,5 +1320,4 @@ async function fetchChainlinkRate({ connection, priceFeed, }) {
|
|
|
1386
1320
|
const scale = Math.pow(10, header.decimals);
|
|
1387
1321
|
return Number(answer) / scale;
|
|
1388
1322
|
}
|
|
1389
|
-
exports.fetchChainlinkRate = fetchChainlinkRate;
|
|
1390
1323
|
//# sourceMappingURL=exponentFetcher.js.map
|