@exponent-labs/exponent-fetcher 0.9.24 → 0.9.25
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 +11 -2
- package/build/exponentFetcher.js +74 -41
- package/build/exponentFetcher.js.map +1 -1
- package/build/utils/adrena.d.ts +2 -0
- package/build/utils/adrena.js +2 -1
- package/build/utils/adrena.js.map +1 -1
- package/build/utils/fragmetric.d.ts +2 -0
- package/build/utils/fragmetric.js +2 -2
- package/build/utils/fragmetric.js.map +1 -1
- package/build/utils/jito.d.ts +2 -0
- package/build/utils/jito.js +2 -1
- package/build/utils/jito.js.map +1 -1
- package/build/utils/jupiter.d.ts +2 -0
- package/build/utils/jupiter.js +3 -2
- package/build/utils/jupiter.js.map +1 -1
- package/build/utils/kamino.d.ts +2 -0
- package/build/utils/kamino.js +2 -1
- package/build/utils/kamino.js.map +1 -1
- package/build/utils/meteora.d.ts +3 -0
- package/build/utils/meteora.js +5 -5
- package/build/utils/meteora.js.map +1 -1
- package/build/utils/ore.d.ts +3 -0
- package/build/utils/ore.js +2 -1
- package/build/utils/ore.js.map +1 -1
- package/build/utils/perena.d.ts +2 -0
- package/build/utils/perena.js +3 -2
- package/build/utils/perena.js.map +1 -1
- package/build/utils/sanctum.d.ts +2 -0
- package/build/utils/sanctum.js +2 -1
- package/build/utils/sanctum.js.map +1 -1
- package/build/utils/solstice.d.ts +2 -0
- package/build/utils/solstice.js +3 -2
- package/build/utils/solstice.js.map +1 -1
- package/package.json +21 -21
- package/src/exponentFetcher.ts +54 -12
package/build/constants.js
CHANGED
|
@@ -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
|
*/
|
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;;;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";
|
|
@@ -117,6 +120,7 @@ export interface MarketThree {
|
|
|
117
120
|
ticks: web3.PublicKey;
|
|
118
121
|
statusFlags: number;
|
|
119
122
|
configurationOptions: MarketConfigurationOptions;
|
|
123
|
+
selfCpiStatus: number;
|
|
120
124
|
financials: MarketThreeFinancials;
|
|
121
125
|
cpiSyAccounts: CpiAccountIndexes;
|
|
122
126
|
cpiCoreAccounts: MarketCpiCoreIndexes;
|
|
@@ -217,6 +221,7 @@ export interface MarketThreeRaw {
|
|
|
217
221
|
ticks: web3.PublicKey;
|
|
218
222
|
statusFlags: number;
|
|
219
223
|
configurationOptions: MarketConfigurationOptionsRaw;
|
|
224
|
+
selfCpiStatus: number;
|
|
220
225
|
financials: MarketThreeFinancialsRaw;
|
|
221
226
|
cpiSyAccounts: CpiAccountIndexes;
|
|
222
227
|
cpiCoreAccounts: MarketCpiCoreIndexes;
|
|
@@ -335,6 +340,7 @@ export interface Vault {
|
|
|
335
340
|
}
|
|
336
341
|
interface OrderbookFinancials {
|
|
337
342
|
expirationTs: number;
|
|
343
|
+
lastSeenSyIndex: number;
|
|
338
344
|
ytBalance: bigint;
|
|
339
345
|
syBalance: bigint;
|
|
340
346
|
ptBalance: bigint;
|
|
@@ -348,6 +354,7 @@ export interface ConfigurationOptions {
|
|
|
348
354
|
thresholdAmount: bigint;
|
|
349
355
|
lnMakerFeeRate: number;
|
|
350
356
|
lnTakerFeeRate: number;
|
|
357
|
+
finalPyIndex: number;
|
|
351
358
|
}
|
|
352
359
|
export interface Orderbook {
|
|
353
360
|
vault: web3.PublicKey;
|
|
@@ -360,6 +367,7 @@ export interface Orderbook {
|
|
|
360
367
|
tokenEscrowPt: web3.PublicKey;
|
|
361
368
|
cpiAccountOrderbook: web3.PublicKey;
|
|
362
369
|
admin: web3.PublicKey;
|
|
370
|
+
lastSyExchangeRate: number;
|
|
363
371
|
configurationOptions: ConfigurationOptions;
|
|
364
372
|
financials: OrderbookFinancials;
|
|
365
373
|
prices: PriceTreeNode[];
|
|
@@ -523,11 +531,12 @@ export interface OfferNodeRaw {
|
|
|
523
531
|
}
|
|
524
532
|
export interface UserEscrowNodeRaw {
|
|
525
533
|
user: web3.PublicKey;
|
|
526
|
-
yieldIndex:
|
|
534
|
+
yieldIndex: number;
|
|
527
535
|
ptAmount: BN;
|
|
528
536
|
syAmount: BN;
|
|
529
537
|
ytAmount: BN;
|
|
530
|
-
|
|
538
|
+
stakedYtAmount: BN;
|
|
539
|
+
staged: BN;
|
|
531
540
|
}
|
|
532
541
|
export declare function deserializeAnchorizedPNum(x: AnchorizedPNum): number;
|
|
533
542
|
/** Convert PreciseNumber (Number type in Rust) from Anchor format to raw 256-bit bigint */
|
package/build/exponentFetcher.js
CHANGED
|
@@ -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");
|
|
@@ -74,10 +44,12 @@ function serializeAnchorizedPNumFromJson(pnum) {
|
|
|
74
44
|
const serializedArray = pnum[0].map((bn) => bn.toString());
|
|
75
45
|
return { 0: serializedArray };
|
|
76
46
|
}
|
|
47
|
+
exports.serializeAnchorizedPNumFromJson = serializeAnchorizedPNumFromJson;
|
|
77
48
|
function deserializeAnchorizedPNumFromJson(serialized) {
|
|
78
49
|
const bnArray = serialized[0].map((str) => new anchor_1.BN(str));
|
|
79
50
|
return { 0: bnArray };
|
|
80
51
|
}
|
|
52
|
+
exports.deserializeAnchorizedPNumFromJson = deserializeAnchorizedPNumFromJson;
|
|
81
53
|
class MyWallet {
|
|
82
54
|
payer;
|
|
83
55
|
constructor(payer) {
|
|
@@ -593,6 +565,7 @@ function deserializeMarketThreeTicks(data) {
|
|
|
593
565
|
tickTreeFreeListHead,
|
|
594
566
|
};
|
|
595
567
|
}
|
|
568
|
+
exports.deserializeMarketThreeTicks = deserializeMarketThreeTicks;
|
|
596
569
|
function deserializeMarketThree(m) {
|
|
597
570
|
return {
|
|
598
571
|
addressLookupTable: m.addressLookupTable,
|
|
@@ -606,6 +579,7 @@ function deserializeMarketThree(m) {
|
|
|
606
579
|
selfAddress: m.selfAddress,
|
|
607
580
|
syProgram: m.syProgram,
|
|
608
581
|
statusFlags: m.statusFlags,
|
|
582
|
+
selfCpiStatus: m.selfCpiStatus,
|
|
609
583
|
cpiSyAccounts: m.cpiSyAccounts,
|
|
610
584
|
isCurrentFlashSwap: m.isCurrentFlashSwap,
|
|
611
585
|
lpFarm: m.lpFarm,
|
|
@@ -640,6 +614,7 @@ function deserializeMarketThree(m) {
|
|
|
640
614
|
seedId: m.seedId,
|
|
641
615
|
};
|
|
642
616
|
}
|
|
617
|
+
exports.deserializeMarketThree = deserializeMarketThree;
|
|
643
618
|
function deserializeMarketTwo(m) {
|
|
644
619
|
return {
|
|
645
620
|
ptBalance: BigInt(m.financials.ptBalance.toString()),
|
|
@@ -766,9 +741,12 @@ function deserializeOrderbook(data) {
|
|
|
766
741
|
offset += 8;
|
|
767
742
|
const priceDecimals = data.readUint8(offset);
|
|
768
743
|
offset += 1;
|
|
744
|
+
// _placeholder_one[15]
|
|
745
|
+
offset += 15;
|
|
746
|
+
const finalPyIndex = readPreciseNumberAsFloat();
|
|
769
747
|
// Skip ConfigurationOptions padding/reserve:
|
|
770
|
-
//
|
|
771
|
-
offset +=
|
|
748
|
+
// _placeholder_three[32] + _placeholder_four[32] + _reserved[1024]
|
|
749
|
+
offset += 1088;
|
|
772
750
|
// Pubkeys
|
|
773
751
|
const vault = readPubkey();
|
|
774
752
|
const yieldPosition = readPubkey();
|
|
@@ -780,11 +758,9 @@ function deserializeOrderbook(data) {
|
|
|
780
758
|
const tokenEscrowPt = readPubkey();
|
|
781
759
|
const cpiAccountOrderbook = readPubkey();
|
|
782
760
|
const admin = readPubkey();
|
|
783
|
-
|
|
784
|
-
offset += 32;
|
|
761
|
+
const lastSyExchangeRate = readPreciseNumberAsFloat();
|
|
785
762
|
// OrderbookFinancials struct
|
|
786
|
-
|
|
787
|
-
offset += 32;
|
|
763
|
+
const lastSeenSyIndex = readPreciseNumberAsFloat();
|
|
788
764
|
const ytBalance = data.readBigUInt64LE(offset);
|
|
789
765
|
offset += 8;
|
|
790
766
|
const syBalance = data.readBigUInt64LE(offset);
|
|
@@ -808,9 +784,11 @@ function deserializeOrderbook(data) {
|
|
|
808
784
|
thresholdAmount,
|
|
809
785
|
lnMakerFeeRate,
|
|
810
786
|
lnTakerFeeRate,
|
|
787
|
+
finalPyIndex,
|
|
811
788
|
};
|
|
812
789
|
const financials = {
|
|
813
790
|
expirationTs,
|
|
791
|
+
lastSeenSyIndex,
|
|
814
792
|
syBalance: syBalance,
|
|
815
793
|
ytBalance: ytBalance,
|
|
816
794
|
ptBalance: ptBalance,
|
|
@@ -836,7 +814,7 @@ function deserializeOrderbook(data) {
|
|
|
836
814
|
const _priceTreeFreeIdx = data.readUInt32LE(offset);
|
|
837
815
|
offset += 4;
|
|
838
816
|
// each RBNode entry = registers[3] + key:u32 + first_offer:u32
|
|
839
|
-
const
|
|
817
|
+
const priceSlots = [];
|
|
840
818
|
for (let i = 0; i < exponent_types_2.MAX_PRICE_NODES; i++) {
|
|
841
819
|
const left = data.readUInt32LE(offset);
|
|
842
820
|
offset += 4;
|
|
@@ -855,10 +833,34 @@ function deserializeOrderbook(data) {
|
|
|
855
833
|
offset += 4;
|
|
856
834
|
const lastOfferBuyYt = data.readUInt32LE(offset);
|
|
857
835
|
offset += 4;
|
|
858
|
-
|
|
836
|
+
priceSlots.push({
|
|
837
|
+
priceIndex: i + 1,
|
|
838
|
+
key,
|
|
839
|
+
firstOfferSellYt,
|
|
840
|
+
firstOfferBuyYt,
|
|
841
|
+
lastOfferSellYt,
|
|
842
|
+
lastOfferBuyYt,
|
|
843
|
+
parent,
|
|
844
|
+
left,
|
|
845
|
+
right,
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
const pricePointers = [root];
|
|
849
|
+
const visitedPricePointers = new Set();
|
|
850
|
+
while (pricePointers.length > 0) {
|
|
851
|
+
const pricePointer = pricePointers.pop();
|
|
852
|
+
if (pricePointer === 0 || visitedPricePointers.has(pricePointer))
|
|
859
853
|
continue;
|
|
860
|
-
|
|
854
|
+
const price = priceSlots[pricePointer - 1];
|
|
855
|
+
if (!price)
|
|
856
|
+
throw new Error(`Invalid orderbook price pointer ${pricePointer}`);
|
|
857
|
+
visitedPricePointers.add(pricePointer);
|
|
858
|
+
pricePointers.push(price.left, price.right);
|
|
861
859
|
}
|
|
860
|
+
if (visitedPricePointers.size !== priceTreeSize) {
|
|
861
|
+
throw new Error(`Orderbook price tree size mismatch: decoded ${visitedPricePointers.size}, expected ${priceTreeSize}`);
|
|
862
|
+
}
|
|
863
|
+
const prices = priceSlots.filter((price) => visitedPricePointers.has(price.priceIndex));
|
|
862
864
|
// ─── Parse Offers slab ────────────────────────────────────────────────────
|
|
863
865
|
// NodeAllocator<Offer, MAX_OFFERS, 4>
|
|
864
866
|
// header: size:u64, bump_index:u32, free_list_head:u32
|
|
@@ -909,13 +911,15 @@ function deserializeOrderbook(data) {
|
|
|
909
911
|
// ─── Parse UserEscrow slab ────────────────────────────────────────────────
|
|
910
912
|
// NodeAllocator<UserEscrow, MAX_USER_ESCROWS, 2>
|
|
911
913
|
// header: size:u64, bump_index:u32, free_list_head:u32
|
|
914
|
+
const escrowStartOffset = offset;
|
|
912
915
|
const escSize = Number(data.readBigUInt64LE(offset));
|
|
913
916
|
offset += 8;
|
|
914
917
|
const _escBump = data.readUInt32LE(offset);
|
|
915
918
|
offset += 4;
|
|
916
919
|
const _escFreeIdx = data.readUInt32LE(offset);
|
|
917
920
|
offset += 4;
|
|
918
|
-
// each Node = [
|
|
921
|
+
// each Node = registers[2] + UserEscrow.value
|
|
922
|
+
// NodeAllocator<UserEscrow, MAX_USER_ESCROWS, 2> means 2 registers per node
|
|
919
923
|
const userEscrows = [];
|
|
920
924
|
for (let i = 0; i < exponent_types_2.MAX_USER_ESCROWS; i++) {
|
|
921
925
|
const register = data.readUInt32LE(offset);
|
|
@@ -964,6 +968,7 @@ function deserializeOrderbook(data) {
|
|
|
964
968
|
tokenEscrowYt,
|
|
965
969
|
tokenEscrowPt,
|
|
966
970
|
cpiAccountOrderbook,
|
|
971
|
+
lastSyExchangeRate,
|
|
967
972
|
financials,
|
|
968
973
|
prices,
|
|
969
974
|
configurationOptions,
|
|
@@ -1009,6 +1014,7 @@ function deserializeLpPosition(x) {
|
|
|
1009
1014
|
})),
|
|
1010
1015
|
};
|
|
1011
1016
|
}
|
|
1017
|
+
exports.deserializeLpPosition = deserializeLpPosition;
|
|
1012
1018
|
function deserializeYtPosition(x) {
|
|
1013
1019
|
return {
|
|
1014
1020
|
owner: x.owner,
|
|
@@ -1018,6 +1024,7 @@ function deserializeYtPosition(x) {
|
|
|
1018
1024
|
emissions: x.emissions.map(deserializeYieldTokenTracker),
|
|
1019
1025
|
};
|
|
1020
1026
|
}
|
|
1027
|
+
exports.deserializeYtPosition = deserializeYtPosition;
|
|
1021
1028
|
function deserializeYieldTokenTracker(x) {
|
|
1022
1029
|
return {
|
|
1023
1030
|
staged: BigInt(x.staged.toString()),
|
|
@@ -1041,6 +1048,7 @@ async function fetchKaminoReserve(address, connection) {
|
|
|
1041
1048
|
scopePriceFeed,
|
|
1042
1049
|
};
|
|
1043
1050
|
}
|
|
1051
|
+
exports.fetchKaminoReserve = fetchKaminoReserve;
|
|
1044
1052
|
const DEPOSITS_LIMIT = 8;
|
|
1045
1053
|
async function fetchAllKaminoObligationsByKaminoReserve(reserve, connection) {
|
|
1046
1054
|
const finalObligations = [];
|
|
@@ -1069,6 +1077,7 @@ async function fetchAllKaminoObligationsByKaminoReserve(reserve, connection) {
|
|
|
1069
1077
|
}
|
|
1070
1078
|
return finalObligations;
|
|
1071
1079
|
}
|
|
1080
|
+
exports.fetchAllKaminoObligationsByKaminoReserve = fetchAllKaminoObligationsByKaminoReserve;
|
|
1072
1081
|
function serializeEmission(emission) {
|
|
1073
1082
|
return {
|
|
1074
1083
|
tokenAccount: emission.tokenAccount.toString(),
|
|
@@ -1080,6 +1089,7 @@ function serializeEmission(emission) {
|
|
|
1080
1089
|
treasuryEmission: emission.treasuryEmission.toString(),
|
|
1081
1090
|
};
|
|
1082
1091
|
}
|
|
1092
|
+
exports.serializeEmission = serializeEmission;
|
|
1083
1093
|
function deserializeEmission(emission) {
|
|
1084
1094
|
return {
|
|
1085
1095
|
tokenAccount: new anchor_1.web3.PublicKey(emission.tokenAccount),
|
|
@@ -1091,9 +1101,11 @@ function deserializeEmission(emission) {
|
|
|
1091
1101
|
treasuryEmission: new anchor_1.BN(emission.treasuryEmission),
|
|
1092
1102
|
};
|
|
1093
1103
|
}
|
|
1104
|
+
exports.deserializeEmission = deserializeEmission;
|
|
1094
1105
|
function deserializeAnchorizedPNum(x) {
|
|
1095
1106
|
return parseFloat(precise_number_1.PreciseNumber.fromRaw(x[0]).valueString);
|
|
1096
1107
|
}
|
|
1108
|
+
exports.deserializeAnchorizedPNum = deserializeAnchorizedPNum;
|
|
1097
1109
|
/** Convert PreciseNumber (Number type in Rust) from Anchor format to raw 256-bit bigint */
|
|
1098
1110
|
function anchorizedPNumToRawBigint(pnum) {
|
|
1099
1111
|
const bnArray = pnum[0];
|
|
@@ -1103,6 +1115,7 @@ function anchorizedPNumToRawBigint(pnum) {
|
|
|
1103
1115
|
}
|
|
1104
1116
|
return val;
|
|
1105
1117
|
}
|
|
1118
|
+
exports.anchorizedPNumToRawBigint = anchorizedPNumToRawBigint;
|
|
1106
1119
|
/** Fetch the exchange rate of a JitoRestaking vault's VRT to JitoSOL */
|
|
1107
1120
|
async function fetchJitoVaultData({ connection, vaultAddress, }) {
|
|
1108
1121
|
const vaultAccountInfo = await connection.getAccountInfo(vaultAddress);
|
|
@@ -1119,6 +1132,7 @@ async function fetchSplStakePoolIndex({ connection, stakePool, }) {
|
|
|
1119
1132
|
const stakePoolAccount = await (0, spl_stake_pool_1.getStakePoolAccount)(connection, stakePool);
|
|
1120
1133
|
return Number(stakePoolAccount.account.data.totalLamports) / Number(stakePoolAccount.account.data.poolTokenSupply);
|
|
1121
1134
|
}
|
|
1135
|
+
exports.fetchSplStakePoolIndex = fetchSplStakePoolIndex;
|
|
1122
1136
|
async function fetchPerenaStablePoolData({ connection, perenaStablePool, }) {
|
|
1123
1137
|
const lpMint = (0, perena_1.getPerenaLpMint)(perenaStablePool);
|
|
1124
1138
|
const [accountInfo, lpMintInfo] = await connection.getMultipleAccountsInfo([perenaStablePool, lpMint]);
|
|
@@ -1128,6 +1142,7 @@ async function fetchPerenaStablePoolData({ connection, perenaStablePool, }) {
|
|
|
1128
1142
|
});
|
|
1129
1143
|
return { lpSupply, invT, exchangeRate, lpMint };
|
|
1130
1144
|
}
|
|
1145
|
+
exports.fetchPerenaStablePoolData = fetchPerenaStablePoolData;
|
|
1131
1146
|
/**
|
|
1132
1147
|
* Fetch the exchange rate of a JitoRestaking vault
|
|
1133
1148
|
* @param connection
|
|
@@ -1148,6 +1163,7 @@ async function fetchJitoRestaking(connection, accounts, interfaceType, vaultAddr
|
|
|
1148
1163
|
exchangeRate: exr.toString(),
|
|
1149
1164
|
};
|
|
1150
1165
|
}
|
|
1166
|
+
exports.fetchJitoRestaking = fetchJitoRestaking;
|
|
1151
1167
|
/**
|
|
1152
1168
|
* Fetch the pre-simulated index for Jupiter Perps pool to mirror on-chain logic in utils.rs (InterfaceType::JupiterPerps)
|
|
1153
1169
|
* Uses fields: pool.pool_apr.{realized_fee_usd, fee_apr_bps, last_updated}, pool.aum_usd,
|
|
@@ -1163,9 +1179,11 @@ async function fetchJupiterPerpsIndex({ connection, pool, lastFeeUsdResetUnixTim
|
|
|
1163
1179
|
lastRealizedFeeUsdUpdateUnixTimestamp,
|
|
1164
1180
|
});
|
|
1165
1181
|
}
|
|
1182
|
+
exports.fetchJupiterPerpsIndex = fetchJupiterPerpsIndex;
|
|
1166
1183
|
async function fetchPyth(connection) {
|
|
1167
1184
|
return "";
|
|
1168
1185
|
}
|
|
1186
|
+
exports.fetchPyth = fetchPyth;
|
|
1169
1187
|
async function fetchGenericSyMetaIndex({ connection, genericSyMeta, }) {
|
|
1170
1188
|
const [accountInfo] = await connection.getMultipleAccountsInfo([genericSyMeta]);
|
|
1171
1189
|
const d = accountInfo.data;
|
|
@@ -1190,6 +1208,7 @@ async function fetchGenericSyMetaIndex({ connection, genericSyMeta, }) {
|
|
|
1190
1208
|
const index = parseFloat(precise_number_1.PreciseNumber.fromRaw(indexRaw[0]).valueString);
|
|
1191
1209
|
return { index };
|
|
1192
1210
|
}
|
|
1211
|
+
exports.fetchGenericSyMetaIndex = fetchGenericSyMetaIndex;
|
|
1193
1212
|
async function fetchFragmetricIndex({ connection, fragmetricFund, }) {
|
|
1194
1213
|
const fragmetricFundRaw = await connection.getAccountInfo(fragmetricFund);
|
|
1195
1214
|
const { index, receiptTokenMint, wrappedTokenMint } = (0, fragmetric_1.calculateFragmetricIndex)({
|
|
@@ -1197,6 +1216,7 @@ async function fetchFragmetricIndex({ connection, fragmetricFund, }) {
|
|
|
1197
1216
|
});
|
|
1198
1217
|
return { index, receiptTokenMint, wrappedTokenMint };
|
|
1199
1218
|
}
|
|
1219
|
+
exports.fetchFragmetricIndex = fetchFragmetricIndex;
|
|
1200
1220
|
async function fetchJupiterLendIndex({ connection, jupiterLendAccount, }) {
|
|
1201
1221
|
const account = await connection.getAccountInfo(jupiterLendAccount);
|
|
1202
1222
|
const rateModel = jupiterLendAccount.equals(new anchor_1.web3.PublicKey("BeAqbxfrcXmzEYT2Ra62oW2MqkuFDHaCtps47Mzg6Zj3"))
|
|
@@ -1213,6 +1233,7 @@ async function fetchJupiterLendIndex({ connection, jupiterLendAccount, }) {
|
|
|
1213
1233
|
rewardsRateModel,
|
|
1214
1234
|
};
|
|
1215
1235
|
}
|
|
1236
|
+
exports.fetchJupiterLendIndex = fetchJupiterLendIndex;
|
|
1216
1237
|
async function fetchKaminoVaultIndex({ connection, kaminoVaultAccount, }) {
|
|
1217
1238
|
const account = await connection.getAccountInfo(kaminoVaultAccount);
|
|
1218
1239
|
const coder = new anchor_2.BorshCoder(kamino_vault_idl_1.IDL);
|
|
@@ -1272,10 +1293,12 @@ async function fetchKaminoVaultIndex({ connection, kaminoVaultAccount, }) {
|
|
|
1272
1293
|
reserves,
|
|
1273
1294
|
};
|
|
1274
1295
|
}
|
|
1296
|
+
exports.fetchKaminoVaultIndex = fetchKaminoVaultIndex;
|
|
1275
1297
|
async function fetchFragmetricSupportedTokenIndex({ connection, fragmetricFund, index, }) {
|
|
1276
1298
|
const account = await connection.getAccountInfo(fragmetricFund);
|
|
1277
1299
|
return (0, fragmetric_1.calculateFragmetricSupportedTokenIndex)({ fragmetricFund: account.data }, index);
|
|
1278
1300
|
}
|
|
1301
|
+
exports.fetchFragmetricSupportedTokenIndex = fetchFragmetricSupportedTokenIndex;
|
|
1279
1302
|
async function fetchMeteoraIndex({ connection, accounts, onChainTime, }) {
|
|
1280
1303
|
try {
|
|
1281
1304
|
const VIRTUAL_PRICE_PRECISION = new anchor_1.BN(100_000_000);
|
|
@@ -1311,6 +1334,7 @@ async function fetchMeteoraIndex({ connection, accounts, onChainTime, }) {
|
|
|
1311
1334
|
throw error;
|
|
1312
1335
|
}
|
|
1313
1336
|
}
|
|
1337
|
+
exports.fetchMeteoraIndex = fetchMeteoraIndex;
|
|
1314
1338
|
async function fetchAdrenaIndex({ connection, accounts, previousTotalFees, currentIndex, }) {
|
|
1315
1339
|
try {
|
|
1316
1340
|
// Fetch all account data in a single RPC call
|
|
@@ -1336,6 +1360,7 @@ async function fetchAdrenaIndex({ connection, accounts, previousTotalFees, curre
|
|
|
1336
1360
|
throw error;
|
|
1337
1361
|
}
|
|
1338
1362
|
}
|
|
1363
|
+
exports.fetchAdrenaIndex = fetchAdrenaIndex;
|
|
1339
1364
|
async function fetchSanctumIndex({ connection, accounts, }) {
|
|
1340
1365
|
const [poolStateAccountRaw, lpMintAccountRaw] = await Promise.all([accounts.poolState, accounts.lpMint].map((pk) => connection.getAccountInfo(pk)));
|
|
1341
1366
|
return (0, sanctum_1.calculateSanctumIndex)({
|
|
@@ -1343,6 +1368,7 @@ async function fetchSanctumIndex({ connection, accounts, }) {
|
|
|
1343
1368
|
lpMintAccountData: lpMintAccountRaw.data,
|
|
1344
1369
|
});
|
|
1345
1370
|
}
|
|
1371
|
+
exports.fetchSanctumIndex = fetchSanctumIndex;
|
|
1346
1372
|
async function fetchSolsticeRedemptionRate({ connection, yieldPool, vestingSchedule, }) {
|
|
1347
1373
|
// Fetch both accounts in a single RPC call for efficiency
|
|
1348
1374
|
const accountInfos = await connection.getMultipleAccountsInfo([yieldPool, vestingSchedule]);
|
|
@@ -1351,6 +1377,7 @@ async function fetchSolsticeRedemptionRate({ connection, yieldPool, vestingSched
|
|
|
1351
1377
|
}
|
|
1352
1378
|
return (0, solstice_1.calculateSolsticeRedemptionRate)({ yieldPool: accountInfos[0].data, vestingSchedule: accountInfos[1].data });
|
|
1353
1379
|
}
|
|
1380
|
+
exports.fetchSolsticeRedemptionRate = fetchSolsticeRedemptionRate;
|
|
1354
1381
|
async function fetchSolsticeGlamVaultExchangeRate({ connection, stakingVaultSlxAta, slxMint, stslxMint, }) {
|
|
1355
1382
|
const accountInfos = await connection.getMultipleAccountsInfo([stakingVaultSlxAta, slxMint, stslxMint]);
|
|
1356
1383
|
if (!accountInfos[0] || !accountInfos[1] || !accountInfos[2]) {
|
|
@@ -1362,6 +1389,7 @@ async function fetchSolsticeGlamVaultExchangeRate({ connection, stakingVaultSlxA
|
|
|
1362
1389
|
stslxMint: accountInfos[2].data,
|
|
1363
1390
|
});
|
|
1364
1391
|
}
|
|
1392
|
+
exports.fetchSolsticeGlamVaultExchangeRate = fetchSolsticeGlamVaultExchangeRate;
|
|
1365
1393
|
const REFLECT_ORACLE_LEN = 17;
|
|
1366
1394
|
const REFLECT_MAX_STALENESS_SLOTS = 150000000000;
|
|
1367
1395
|
async function fetchReflectRedemptionRate({ connection, oracle, }) {
|
|
@@ -1379,6 +1407,8 @@ async function fetchReflectRedemptionRate({ connection, oracle, }) {
|
|
|
1379
1407
|
if (slot > currentSlot) {
|
|
1380
1408
|
throw new Error("Reflect oracle slot is ahead of the current slot");
|
|
1381
1409
|
}
|
|
1410
|
+
console.log("currentSlot", currentSlot);
|
|
1411
|
+
console.log("slot", slot);
|
|
1382
1412
|
const slotDelta = currentSlot - slot;
|
|
1383
1413
|
if (slotDelta > REFLECT_MAX_STALENESS_SLOTS) {
|
|
1384
1414
|
throw new Error("Reflect oracle data is stale");
|
|
@@ -1389,6 +1419,7 @@ async function fetchReflectRedemptionRate({ connection, oracle, }) {
|
|
|
1389
1419
|
}
|
|
1390
1420
|
return price / scale;
|
|
1391
1421
|
}
|
|
1422
|
+
exports.fetchReflectRedemptionRate = fetchReflectRedemptionRate;
|
|
1392
1423
|
async function fetchOreExchangeRate({ connection, storeMint, stakeAccount, treasury, }) {
|
|
1393
1424
|
// Fetch all accounts in parallel for efficiency
|
|
1394
1425
|
const [storeMintInfo, stakeAccountInfo, treasuryAccountInfo] = await Promise.all([
|
|
@@ -1405,6 +1436,7 @@ async function fetchOreExchangeRate({ connection, storeMint, stakeAccount, treas
|
|
|
1405
1436
|
storeMint: storeMintInfo.data,
|
|
1406
1437
|
});
|
|
1407
1438
|
}
|
|
1439
|
+
exports.fetchOreExchangeRate = fetchOreExchangeRate;
|
|
1408
1440
|
async function fetchChainlinkRate({ connection, priceFeed, }) {
|
|
1409
1441
|
const accountInfo = await connection.getAccountInfo(priceFeed);
|
|
1410
1442
|
if (!accountInfo) {
|
|
@@ -1414,4 +1446,5 @@ async function fetchChainlinkRate({ connection, priceFeed, }) {
|
|
|
1414
1446
|
const scale = Math.pow(10, header.decimals);
|
|
1415
1447
|
return Number(answer) / scale;
|
|
1416
1448
|
}
|
|
1449
|
+
exports.fetchChainlinkRate = fetchChainlinkRate;
|
|
1417
1450
|
//# sourceMappingURL=exponentFetcher.js.map
|