@exponent-labs/exponent-fetcher 0.1.7 → 0.1.8
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/exponentFetcher.d.ts +303 -31
- package/build/exponentFetcher.js +666 -168
- package/build/exponentFetcher.js.map +1 -1
- package/build/index.d.ts +10 -0
- package/build/index.js +10 -0
- package/build/index.js.map +1 -1
- package/build/utils/adrena.d.ts +13 -0
- package/build/utils/adrena.js +29 -0
- package/build/utils/adrena.js.map +1 -0
- package/build/utils/fragmetric.d.ts +17 -0
- package/build/utils/fragmetric.js +23 -0
- package/build/utils/fragmetric.js.map +1 -0
- package/build/utils/jito.d.ts +7 -0
- package/build/utils/jito.js +29 -0
- package/build/utils/jito.js.map +1 -0
- package/build/utils/jupiter.d.ts +30 -0
- package/build/utils/jupiter.js +63 -0
- package/build/utils/jupiter.js.map +1 -0
- package/build/utils/kamino.d.ts +5 -0
- package/build/utils/kamino.js +10 -0
- package/build/utils/kamino.js.map +1 -0
- package/build/utils/meteora.d.ts +19 -0
- package/build/utils/meteora.js +36 -1
- package/build/utils/meteora.js.map +1 -1
- package/build/utils/ore.d.ts +74 -0
- package/build/utils/ore.js +217 -0
- package/build/utils/ore.js.map +1 -0
- package/build/utils/perena.d.ts +12 -0
- package/build/utils/perena.js +27 -0
- package/build/utils/perena.js.map +1 -0
- package/build/utils/sanctum.d.ts +6 -0
- package/build/utils/sanctum.js +26 -0
- package/build/utils/sanctum.js.map +1 -0
- package/build/utils/solstice.d.ts +12 -0
- package/build/utils/solstice.js +45 -0
- package/build/utils/solstice.js.map +1 -0
- package/package.json +20 -18
- package/src/exponentFetcher.ts +1077 -222
- package/src/index.ts +10 -0
- package/src/utils/adrena.ts +44 -0
- package/src/utils/fragmetric.ts +34 -0
- package/src/utils/jito.ts +30 -0
- package/src/utils/jupiter.ts +98 -0
- package/src/utils/kamino.ts +6 -0
- package/src/utils/meteora.ts +73 -1
- package/src/utils/ore.ts +322 -0
- package/src/utils/perena.ts +28 -0
- package/src/utils/sanctum.ts +24 -0
- package/src/utils/solstice.ts +51 -0
- package/tsconfig.json +2 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import { BN } from "@coral-xyz/anchor";
|
|
5
|
+
import { web3 } from "@coral-xyz/anchor";
|
|
6
|
+
import Decimal from "decimal.js";
|
|
7
|
+
/**
|
|
8
|
+
* Represents a Numeric value from the steel crate
|
|
9
|
+
* Steel's Numeric is a u128 (16 bytes) with 1e12 scaling factor
|
|
10
|
+
*/
|
|
11
|
+
export interface Numeric {
|
|
12
|
+
rawValue: BN;
|
|
13
|
+
decimalValue: Decimal;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* TypeScript representation of the Stake struct from ore_cpi
|
|
17
|
+
* Matches the Rust struct in solana/libraries/ore_cpi/src/state/stake.rs
|
|
18
|
+
*/
|
|
19
|
+
export interface Stake {
|
|
20
|
+
authority: web3.PublicKey;
|
|
21
|
+
balance: BN;
|
|
22
|
+
bufferA: BN;
|
|
23
|
+
bufferB: BN;
|
|
24
|
+
bufferC: BN;
|
|
25
|
+
bufferD: BN;
|
|
26
|
+
compoundFeeReserve: BN;
|
|
27
|
+
lastClaimAt: BN;
|
|
28
|
+
lastDepositAt: BN;
|
|
29
|
+
lastWithdrawAt: BN;
|
|
30
|
+
rewardsFactor: Numeric;
|
|
31
|
+
rewards: BN;
|
|
32
|
+
lifetimeRewards: BN;
|
|
33
|
+
bufferF: BN;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* TypeScript representation of the Treasury struct from ore_cpi
|
|
37
|
+
* Matches the Rust struct in solana/libraries/ore_cpi/src/state/treasury.rs
|
|
38
|
+
*/
|
|
39
|
+
export interface Treasury {
|
|
40
|
+
balance: BN;
|
|
41
|
+
bufferA: BN;
|
|
42
|
+
motherlode: BN;
|
|
43
|
+
minerRewardsFactor: Numeric;
|
|
44
|
+
stakeRewardsFactor: Numeric;
|
|
45
|
+
bufferB: BN;
|
|
46
|
+
totalRefined: BN;
|
|
47
|
+
totalStaked: BN;
|
|
48
|
+
totalUnclaimed: BN;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Calculate ORE exchange rate from account data
|
|
52
|
+
* This mirrors the logic from the Rust implementation in generic_standard/src/utils.rs
|
|
53
|
+
*
|
|
54
|
+
* Exchange rate formula: (stake.balance + total_rewards) / stORE_supply
|
|
55
|
+
*
|
|
56
|
+
* Where total_rewards is calculated using ORE protocol's Stake::calculate_accrued_rewards:
|
|
57
|
+
* 1. accumulated_rewards = treasury.stake_rewards_factor - stake.rewards_factor
|
|
58
|
+
* 2. personal_rewards = accumulated_rewards * stake.balance
|
|
59
|
+
* 3. total_rewards = stake.rewards + personal_rewards
|
|
60
|
+
*
|
|
61
|
+
* Security note: We use stake.balance as the canonical staked amount, NOT
|
|
62
|
+
* stake_tokens.amount from the token account. This prevents manipulation
|
|
63
|
+
* where an attacker transfers ORE directly into the stake ATA to inflate
|
|
64
|
+
* the exchange rate. The stake.balance is only updated via ORE program
|
|
65
|
+
* deposit/withdraw instructions.
|
|
66
|
+
*
|
|
67
|
+
* Note: Numeric values are stored as fixed-point numbers with 1e12 precision.
|
|
68
|
+
* When multiplying two Numeric values, the result is divided by 1e12 to maintain scale.
|
|
69
|
+
*/
|
|
70
|
+
export declare function calculateOreExchangeRate(accounts: {
|
|
71
|
+
stakeAccount: Buffer;
|
|
72
|
+
treasuryAccount: Buffer;
|
|
73
|
+
storeMint: Buffer;
|
|
74
|
+
}): number;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.calculateOreExchangeRate = void 0;
|
|
7
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
8
|
+
const anchor_2 = require("@coral-xyz/anchor");
|
|
9
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
10
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
11
|
+
// Steel's Numeric type is a u128 with 12 decimal places of precision
|
|
12
|
+
const NUMERIC_DECIMAL_PLACES = 12;
|
|
13
|
+
/**
|
|
14
|
+
* Deserialize a steel Numeric type from buffer
|
|
15
|
+
* Numeric is stored as u128 (16 bytes = 2 x u64, little-endian)
|
|
16
|
+
*/
|
|
17
|
+
function deserializeNumeric(data, offset) {
|
|
18
|
+
const low = new anchor_1.BN(data.slice(offset, offset + 8), "le");
|
|
19
|
+
const high = new anchor_1.BN(data.slice(offset + 8, offset + 16), "le");
|
|
20
|
+
const rawValue = low.add(high.shln(64));
|
|
21
|
+
const decimalValue = new decimal_js_1.default(rawValue.toString()).div(new decimal_js_1.default(10).pow(NUMERIC_DECIMAL_PLACES));
|
|
22
|
+
return { rawValue, decimalValue };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Deserialize Stake account from Buffer
|
|
26
|
+
* Skips the 8-byte steel discriminator and deserializes the struct fields
|
|
27
|
+
*
|
|
28
|
+
* Account layout (152 bytes total):
|
|
29
|
+
* - discriminator: 8 bytes
|
|
30
|
+
* - authority: 32 bytes
|
|
31
|
+
* - balance: 8 bytes
|
|
32
|
+
* - buffer_a through buffer_d: 32 bytes (4 x u64)
|
|
33
|
+
* - compound_fee_reserve: 8 bytes
|
|
34
|
+
* - last_claim_at, last_deposit_at, last_withdraw_at: 24 bytes (3 x i64)
|
|
35
|
+
* - rewards_factor: 16 bytes (u128 Numeric)
|
|
36
|
+
* - rewards: 8 bytes
|
|
37
|
+
* - lifetime_rewards: 8 bytes
|
|
38
|
+
* - buffer_f: 8 bytes
|
|
39
|
+
*/
|
|
40
|
+
function deserializeStakeAccount(stakeData) {
|
|
41
|
+
const DISCRIMINATOR_SIZE = 8;
|
|
42
|
+
let offset = DISCRIMINATOR_SIZE;
|
|
43
|
+
// authority: Pubkey (32 bytes)
|
|
44
|
+
const authority = new anchor_2.web3.PublicKey(stakeData.slice(offset, offset + 32));
|
|
45
|
+
offset += 32;
|
|
46
|
+
// balance: u64 (8 bytes)
|
|
47
|
+
const balance = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
48
|
+
offset += 8;
|
|
49
|
+
// buffer_a: u64 (8 bytes)
|
|
50
|
+
const bufferA = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
51
|
+
offset += 8;
|
|
52
|
+
// buffer_b: u64 (8 bytes)
|
|
53
|
+
const bufferB = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
54
|
+
offset += 8;
|
|
55
|
+
// buffer_c: u64 (8 bytes)
|
|
56
|
+
const bufferC = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
57
|
+
offset += 8;
|
|
58
|
+
// buffer_d: u64 (8 bytes)
|
|
59
|
+
const bufferD = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
60
|
+
offset += 8;
|
|
61
|
+
// compound_fee_reserve: u64 (8 bytes)
|
|
62
|
+
const compoundFeeReserve = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
63
|
+
offset += 8;
|
|
64
|
+
// last_claim_at: i64 (8 bytes)
|
|
65
|
+
const lastClaimAt = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
66
|
+
offset += 8;
|
|
67
|
+
// last_deposit_at: i64 (8 bytes)
|
|
68
|
+
const lastDepositAt = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
69
|
+
offset += 8;
|
|
70
|
+
// last_withdraw_at: i64 (8 bytes)
|
|
71
|
+
const lastWithdrawAt = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
72
|
+
offset += 8;
|
|
73
|
+
// rewards_factor: Numeric (16 bytes = u128)
|
|
74
|
+
const rewardsFactor = deserializeNumeric(stakeData, offset);
|
|
75
|
+
offset += 16;
|
|
76
|
+
// rewards: u64 (8 bytes)
|
|
77
|
+
const rewards = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
78
|
+
offset += 8;
|
|
79
|
+
// lifetime_rewards: u64 (8 bytes)
|
|
80
|
+
const lifetimeRewards = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
81
|
+
offset += 8;
|
|
82
|
+
// buffer_f: u64 (8 bytes)
|
|
83
|
+
const bufferF = new anchor_1.BN(stakeData.slice(offset, offset + 8), "le");
|
|
84
|
+
return {
|
|
85
|
+
authority,
|
|
86
|
+
balance,
|
|
87
|
+
bufferA,
|
|
88
|
+
bufferB,
|
|
89
|
+
bufferC,
|
|
90
|
+
bufferD,
|
|
91
|
+
compoundFeeReserve,
|
|
92
|
+
lastClaimAt,
|
|
93
|
+
lastDepositAt,
|
|
94
|
+
lastWithdrawAt,
|
|
95
|
+
rewardsFactor,
|
|
96
|
+
rewards,
|
|
97
|
+
lifetimeRewards,
|
|
98
|
+
bufferF,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Deserialize Treasury account from Buffer
|
|
103
|
+
* Skips the 8-byte steel discriminator and deserializes the struct fields
|
|
104
|
+
*
|
|
105
|
+
* Account layout (96 bytes total):
|
|
106
|
+
* - discriminator: 8 bytes
|
|
107
|
+
* - balance: 8 bytes
|
|
108
|
+
* - buffer_a: 8 bytes
|
|
109
|
+
* - motherlode: 8 bytes
|
|
110
|
+
* - miner_rewards_factor: 16 bytes (u128 Numeric)
|
|
111
|
+
* - stake_rewards_factor: 16 bytes (u128 Numeric)
|
|
112
|
+
* - buffer_b: 8 bytes
|
|
113
|
+
* - total_refined: 8 bytes
|
|
114
|
+
* - total_staked: 8 bytes
|
|
115
|
+
* - total_unclaimed: 8 bytes
|
|
116
|
+
*/
|
|
117
|
+
function deserializeTreasuryAccount(treasuryData) {
|
|
118
|
+
const DISCRIMINATOR_SIZE = 8;
|
|
119
|
+
let offset = DISCRIMINATOR_SIZE;
|
|
120
|
+
// balance: u64 (8 bytes)
|
|
121
|
+
const balance = new anchor_1.BN(treasuryData.slice(offset, offset + 8), "le");
|
|
122
|
+
offset += 8;
|
|
123
|
+
// buffer_a: u64 (8 bytes)
|
|
124
|
+
const bufferA = new anchor_1.BN(treasuryData.slice(offset, offset + 8), "le");
|
|
125
|
+
offset += 8;
|
|
126
|
+
// motherlode: u64 (8 bytes)
|
|
127
|
+
const motherlode = new anchor_1.BN(treasuryData.slice(offset, offset + 8), "le");
|
|
128
|
+
offset += 8;
|
|
129
|
+
// miner_rewards_factor: Numeric (16 bytes = u128)
|
|
130
|
+
const minerRewardsFactor = deserializeNumeric(treasuryData, offset);
|
|
131
|
+
offset += 16;
|
|
132
|
+
// stake_rewards_factor: Numeric (16 bytes = u128)
|
|
133
|
+
const stakeRewardsFactor = deserializeNumeric(treasuryData, offset);
|
|
134
|
+
offset += 16;
|
|
135
|
+
// buffer_b: u64 (8 bytes)
|
|
136
|
+
const bufferB = new anchor_1.BN(treasuryData.slice(offset, offset + 8), "le");
|
|
137
|
+
offset += 8;
|
|
138
|
+
// total_refined: u64 (8 bytes)
|
|
139
|
+
const totalRefined = new anchor_1.BN(treasuryData.slice(offset, offset + 8), "le");
|
|
140
|
+
offset += 8;
|
|
141
|
+
// total_staked: u64 (8 bytes)
|
|
142
|
+
const totalStaked = new anchor_1.BN(treasuryData.slice(offset, offset + 8), "le");
|
|
143
|
+
offset += 8;
|
|
144
|
+
// total_unclaimed: u64 (8 bytes)
|
|
145
|
+
const totalUnclaimed = new anchor_1.BN(treasuryData.slice(offset, offset + 8), "le");
|
|
146
|
+
return {
|
|
147
|
+
balance,
|
|
148
|
+
bufferA,
|
|
149
|
+
motherlode,
|
|
150
|
+
minerRewardsFactor,
|
|
151
|
+
stakeRewardsFactor,
|
|
152
|
+
bufferB,
|
|
153
|
+
totalRefined,
|
|
154
|
+
totalStaked,
|
|
155
|
+
totalUnclaimed,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Calculate ORE exchange rate from account data
|
|
160
|
+
* This mirrors the logic from the Rust implementation in generic_standard/src/utils.rs
|
|
161
|
+
*
|
|
162
|
+
* Exchange rate formula: (stake.balance + total_rewards) / stORE_supply
|
|
163
|
+
*
|
|
164
|
+
* Where total_rewards is calculated using ORE protocol's Stake::calculate_accrued_rewards:
|
|
165
|
+
* 1. accumulated_rewards = treasury.stake_rewards_factor - stake.rewards_factor
|
|
166
|
+
* 2. personal_rewards = accumulated_rewards * stake.balance
|
|
167
|
+
* 3. total_rewards = stake.rewards + personal_rewards
|
|
168
|
+
*
|
|
169
|
+
* Security note: We use stake.balance as the canonical staked amount, NOT
|
|
170
|
+
* stake_tokens.amount from the token account. This prevents manipulation
|
|
171
|
+
* where an attacker transfers ORE directly into the stake ATA to inflate
|
|
172
|
+
* the exchange rate. The stake.balance is only updated via ORE program
|
|
173
|
+
* deposit/withdraw instructions.
|
|
174
|
+
*
|
|
175
|
+
* Note: Numeric values are stored as fixed-point numbers with 1e12 precision.
|
|
176
|
+
* When multiplying two Numeric values, the result is divided by 1e12 to maintain scale.
|
|
177
|
+
*/
|
|
178
|
+
function calculateOreExchangeRate(accounts) {
|
|
179
|
+
const { stakeAccount, treasuryAccount, storeMint } = accounts;
|
|
180
|
+
// Decode mint account to get stORE supply
|
|
181
|
+
const storeMintAccount = spl_token_1.MintLayout.decode(storeMint.subarray(0, spl_token_1.MintLayout.span));
|
|
182
|
+
const storeSupply = Number(storeMintAccount.supply.toString());
|
|
183
|
+
if (storeSupply === 0) {
|
|
184
|
+
return 1;
|
|
185
|
+
}
|
|
186
|
+
// Deserialize accounts into structured types
|
|
187
|
+
const stake = deserializeStakeAccount(stakeAccount);
|
|
188
|
+
const treasury = deserializeTreasuryAccount(treasuryAccount);
|
|
189
|
+
// Use stake.balance as the canonical staked amount (not token account balance)
|
|
190
|
+
// This prevents exchange rate manipulation via direct token transfers
|
|
191
|
+
const stakeBalance = stake.balance.toNumber();
|
|
192
|
+
// Calculate accrued rewards using ORE protocol's calculate_accrued_rewards algorithm
|
|
193
|
+
// This mirrors the exact logic from Stake::calculate_accrued_rewards() in ore_cpi
|
|
194
|
+
const treasuryStakeRewardsFactorDecimal = treasury.stakeRewardsFactor.decimalValue;
|
|
195
|
+
const stakeRewardsFactorDecimal = stake.rewardsFactor.decimalValue;
|
|
196
|
+
let newlyAccruedRewards = 0;
|
|
197
|
+
if (treasuryStakeRewardsFactorDecimal.gt(stakeRewardsFactorDecimal)) {
|
|
198
|
+
// accumulated_rewards = treasury.stake_rewards_factor - stake.rewards_factor
|
|
199
|
+
const accumulatedRewards = treasuryStakeRewardsFactorDecimal.minus(stakeRewardsFactorDecimal);
|
|
200
|
+
// personal_rewards = accumulated_rewards * stake.balance
|
|
201
|
+
// In Rust: accumulated_rewards (as Numeric) * Numeric::from_u64(stake.balance)
|
|
202
|
+
// The Numeric type uses 1e12 scaling internally. When multiplying two Numerics,
|
|
203
|
+
// the result is (a * b) / 1e12 to maintain scale. Then to_u64() divides by 1e12.
|
|
204
|
+
// Since decimalValue already gives us the decimal representation (divided by 1e12),
|
|
205
|
+
// we just multiply by balance and floor the result.
|
|
206
|
+
const personalRewards = accumulatedRewards.mul(new decimal_js_1.default(stakeBalance));
|
|
207
|
+
newlyAccruedRewards = Math.floor(personalRewards.toNumber());
|
|
208
|
+
}
|
|
209
|
+
// Total rewards = existing rewards + newly accrued rewards
|
|
210
|
+
const totalRewards = stake.rewards.toNumber() + newlyAccruedRewards;
|
|
211
|
+
// Calculate total balance: stake.balance + total_rewards
|
|
212
|
+
const totalBalanceWithRewards = stakeBalance + totalRewards;
|
|
213
|
+
// Calculate exchange rate: (stake.balance + accrued_rewards) / stORE_supply
|
|
214
|
+
return totalBalanceWithRewards / storeSupply;
|
|
215
|
+
}
|
|
216
|
+
exports.calculateOreExchangeRate = calculateOre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E,CAAC,yBAAyB,CAAC,EAAE,CAAC;QACpE,6EAA6E;QAC7E,MAAM,kBAAkB,GAAG,iCAAiC,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAE7F,yDAAyD;QACzD,+EAA+E;QAC/E,gFAAgF;QAChF,iFAAiF;QACjF,oFAAoF;QACpF,oDAAoD;QACpD,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC,IAAI,oBAAO,CAAC,YAAY,CAAC,CAAC,CAAA;QACzE,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC9D,CAAC;IAED,2DAA2D;IAC3D,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,mBAAmB,CAAA;IAEnE,yDAAyD;IACzD,MAAM,uBAAuB,GAAG,YAAY,GAAG,YAAY,CAAA;IAE3D,4EAA4E;IAC5E,OAAO,uBAAuB,GAAG,WAAW,CAAA;AAC9C,CAAC;AAnDD,4DAmDC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { web3 } from "@coral-xyz/anchor";
|
|
4
|
+
export declare function getPerenaLpMint(perenaStablePool: web3.PublicKey): web3.PublicKey;
|
|
5
|
+
export declare function getPerenaStablePoolData(accounts: {
|
|
6
|
+
perenaStablePoolData: Buffer;
|
|
7
|
+
lpMintData: Buffer;
|
|
8
|
+
}): {
|
|
9
|
+
lpSupply: bigint;
|
|
10
|
+
invT: bigint;
|
|
11
|
+
exchangeRate: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPerenaStablePoolData = exports.getPerenaLpMint = void 0;
|
|
7
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
8
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
9
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
10
|
+
function getPerenaLpMint(perenaStablePool) {
|
|
11
|
+
const PERENA_NUMERAIRE_PROGRAM = new anchor_1.web3.PublicKey("NUMERUNsFCP3kuNmWZuXtm1AaQCPj9uw6Guv2Ekoi5P");
|
|
12
|
+
const [lpMint, _] = anchor_1.web3.PublicKey.findProgramAddressSync([perenaStablePool.toBuffer(), Buffer.from("liquidity")], PERENA_NUMERAIRE_PROGRAM);
|
|
13
|
+
return lpMint;
|
|
14
|
+
}
|
|
15
|
+
exports.getPerenaLpMint = getPerenaLpMint;
|
|
16
|
+
function getPerenaStablePoolData(accounts) {
|
|
17
|
+
const { perenaStablePoolData, lpMintData } = accounts;
|
|
18
|
+
const lpMintDeserialized = spl_token_1.MintLayout.decode(lpMintData);
|
|
19
|
+
const discriminatorOffset = 8;
|
|
20
|
+
const invTOffset = discriminatorOffset + 32 + 32 + 32 + 32; // 4 Pubkeys before invT
|
|
21
|
+
const invTBuffer = perenaStablePoolData.slice(invTOffset, invTOffset + 8);
|
|
22
|
+
const invT = Buffer.from(invTBuffer).readBigUInt64LE(0);
|
|
23
|
+
const exchangeRate = new decimal_js_1.default(invT.toString()).div(new decimal_js_1.default(lpMintDeserialized.supply.toString())).toString();
|
|
24
|
+
return { lpSupply: lpMintDeserialized.supply, invT, exchangeRate };
|
|
25
|
+
}
|
|
26
|
+
exports.getPerenaStablePoolData = getPerenaStablePoolData;
|
|
27
|
+
//# sourceMappingURL=perena.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perena.js","sourceRoot":"","sources":["../../src/utils/perena.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAwC;AACxC,iDAA8C;AAC9C,4DAAgC;AAEhC,SAAgB,eAAe,CAAC,gBAA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&& mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.calculateSanctumIndex = void 0;
|
|
7
|
+
const sanctum_idl_1 = require("@exponent-labs/sanctum-idl");
|
|
8
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
9
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
10
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
11
|
+
function calculateSanctumIndex(accounts) {
|
|
12
|
+
const poolState = (0, sanctum_idl_1.decodePoolState)(accounts.poolStateAccountData);
|
|
13
|
+
const lpMint = spl_token_1.MintLayout.decode(accounts.lpMintAccountData.subarray(0, spl_token_1.MintLayout.span));
|
|
14
|
+
const zeroBn = new anchor_1.BN(0);
|
|
15
|
+
const precision = new anchor_1.BN(10 ** lpMint.decimals);
|
|
16
|
+
const lpTokenSupplyBn = new anchor_1.BN(lpMint.supply.toString());
|
|
17
|
+
const poolTotalSolValueBn = new anchor_1.BN(poolState.totalSolValue.toString());
|
|
18
|
+
if (lpTokenSupplyBn.eq(zeroBn) || poolTotalSolValueBn.eq(zeroBn)) {
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
const exchangeRateBn = lpTokenSupplyBn.mul(precision).div(poolTotalSolValueBn);
|
|
22
|
+
const exchangeRate = new decimal_js_1.default(exchangeRateBn.toString()).div(precision.toString()).toNumber();
|
|
23
|
+
return 1 / exchangeRate; // We return inverse exchange rate
|
|
24
|
+
}
|
|
25
|
+
exports.calculateSanctumIndex = calculateSanctumIndex;
|
|
26
|
+
//# sourceMappingURL=sanctum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanctum.js","sourceRoot":"","sources":["../../src/utils/sanctum.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA4D;AAC5D,iDAA8C;AAC9C,4DAAgC;AAChC,8CAAsC;AAEtC,SAAgB,qBAAqB,CAAC,QAAqE;IACzG,MAAM,SAAS,GAAG,IAAA,6BAAe,EAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAA;IAEhE,MAAM,MAAM,GAAG,sBAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,EAAE,sBAAU,CAAC,IAAI,CAAC,CAAC,CAAA;IAEzF,MAAM,MAAM,GAAG,IAAI,WAAE,CAAC,CAAC,CAAC,CAAA;IACxB,MAAM,SAAS,GAAG,IAAI,WAAE,CAAC,EAAE,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,eAAe,GAAG,IAAI,WAAE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAA;IACxD,MAAM,mBAAmB,GAAG,IAAI,WAAE,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAA;IAEtE,IAAI,eAAe,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,mBAAmB,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;QACjE,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM,cAAc,GAAG,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;IAC9E,MAAM,YAAY,GAAG,IAAI,oBAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAA;IAEhG,OAAO,CAAC,GAAG,YAAY,CAAA,CAAC,kCAAkC;AAC5D,CAAC;AAlBD,sDAkBC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
export declare function calculateSolsticeRedemptionRate(accounts: {
|
|
4
|
+
yieldPool: Buffer;
|
|
5
|
+
vestingSchedule: Buffer;
|
|
6
|
+
}): {
|
|
7
|
+
redemptionRate: number;
|
|
8
|
+
totalAssets: string;
|
|
9
|
+
sharesSupply: string;
|
|
10
|
+
vestingAmount: string;
|
|
11
|
+
totalVestedAssets: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateSolsticeRedemptionRate = void 0;
|
|
4
|
+
const solstice_idl_1 = require("@exponent-labs/solstice-idl");
|
|
5
|
+
function calculateSolsticeRedemptionRate(accounts) {
|
|
6
|
+
// Decode accounts using solstice-idl package function
|
|
7
|
+
const { yieldPoolAccount, vestingScheduleAccount } = (0, solstice_idl_1.decodeYieldPoolAndVestingScheduleAccounts)({
|
|
8
|
+
yieldPool: accounts.yieldPool,
|
|
9
|
+
vestingSchedule: accounts.vestingSchedule,
|
|
10
|
+
});
|
|
11
|
+
// Extract fields for calculation (convert BN to bigint)
|
|
12
|
+
const poolTotalAssets = BigInt(yieldPoolAccount.total_assets.toString());
|
|
13
|
+
const poolSharesSupply = BigInt(yieldPoolAccount.shares_supply.toString());
|
|
14
|
+
const vestingAmount = BigInt(vestingScheduleAccount.vesting_amount.toString());
|
|
15
|
+
// Calculate total vested assets (mimicking the Rust logic)
|
|
16
|
+
let totalVestedAssets;
|
|
17
|
+
if (vestingAmount === 0n) {
|
|
18
|
+
totalVestedAssets = poolTotalAssets; // If no vesting amount, all assets are considered vested
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const vestingStart = BigInt(vestingScheduleAccount.start_time.toString());
|
|
22
|
+
const vestingEnd = BigInt(vestingScheduleAccount.end_time.toString());
|
|
23
|
+
const currentTime = BigInt(Math.floor(Date.now() / 1000)); // Current Unix timestamp
|
|
24
|
+
// Calculate unvested amount
|
|
25
|
+
let unvestedAmount;
|
|
26
|
+
if (currentTime > vestingEnd) {
|
|
27
|
+
unvestedAmount = 0n; // If current time passed the vesting end, no unvested amount
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
unvestedAmount = (vestingAmount * (vestingEnd - currentTime)) / (vestingEnd - vestingStart);
|
|
31
|
+
}
|
|
32
|
+
totalVestedAssets = poolTotalAssets - unvestedAmount;
|
|
33
|
+
}
|
|
34
|
+
// Calculate redemption rate: (total_vested_assets + 1) / (pool_shares_supply + 1)
|
|
35
|
+
const redemptionRate = Number(totalVestedAssets + 1n) / Number(poolSharesSupply + 1n);
|
|
36
|
+
return {
|
|
37
|
+
redemptionRate,
|
|
38
|
+
totalAssets: poolTotalAssets.toString(),
|
|
39
|
+
sharesSupply: poolSharesSupply.toString(),
|
|
40
|
+
vestingAmount: vestingAmount.toString(),
|
|
41
|
+
totalVestedAssets: totalVestedAssets.toString(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.calculateSolsticeRedemptionRate = calculateSolsticeRedemptionRate;
|
|
45
|
+
//# sourceMappingURL=solstice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solstice.js","sourceRoot":"","sources":["../../src/utils/solstice.ts"],"names":[],"mappings":";;;AAAA,8DAAuF;AAEvF,SAAgB,+BAA+B,CAAC,QAAwD;IAOtG,sDAAsD;IACtD,MAAM,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,GAAG,IAAA,wDAAyC,EAAC;QAC7F,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,eAAe,EAAE,QAAQ,CAAC,eAAe;KAC1C,CAAC,CAAA;IAEF,wDAAwD;IACxD,MAAM,eAAe,GAAG,MAAM,CAAC,gBAAgB,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAA;IACxE,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC1E,MAAM,aAAa,GAAG,MAAM,CAAC,sBAAsB,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAA;IAE9E,2DAA2D;IAC3D,IAAI,iBAAyB,CAAA;I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version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -9,23 +9,25 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@coral-xyz/anchor": "0.30.0",
|
|
12
|
-
"@exponent-labs/adrena-idl": "0.1.
|
|
13
|
-
"@exponent-labs/exponent-idl": "0.1.
|
|
14
|
-
"@exponent-labs/exponent-types": "0.1.
|
|
15
|
-
"@exponent-labs/fragmetric-idl": "0.1.
|
|
16
|
-
"@exponent-labs/generic-sy-idl": "0.1.
|
|
17
|
-
"@exponent-labs/jito-restaking-sy-idl": "0.1.
|
|
18
|
-
"@exponent-labs/jupiter-lend-idl": "0.1.
|
|
19
|
-
"@exponent-labs/jupiter-perps-idl": "0.1.
|
|
20
|
-
"@exponent-labs/kamino-reserve-deserializer": "0.1.
|
|
21
|
-
"@exponent-labs/kamino-sy-idl": "0.1.
|
|
22
|
-
"@exponent-labs/kamino-vault-idl": "0.1.
|
|
23
|
-
"@exponent-labs/marginfi-sy-idl": "0.1.
|
|
24
|
-
"@exponent-labs/meteora-idl": "0.1.
|
|
25
|
-
"@exponent-labs/perena-sy-idl": "0.1.
|
|
26
|
-
"@exponent-labs/precise-number": "0.1.
|
|
27
|
-
"@exponent-labs/sanctum-idl": "0.1.
|
|
28
|
-
"@exponent-labs/solstice-idl": "0.1.
|
|
12
|
+
"@exponent-labs/adrena-idl": "0.1.8",
|
|
13
|
+
"@exponent-labs/exponent-idl": "0.1.8",
|
|
14
|
+
"@exponent-labs/exponent-types": "0.1.8",
|
|
15
|
+
"@exponent-labs/fragmetric-idl": "0.1.8",
|
|
16
|
+
"@exponent-labs/generic-sy-idl": "0.1.8",
|
|
17
|
+
"@exponent-labs/jito-restaking-sy-idl": "0.1.8",
|
|
18
|
+
"@exponent-labs/jupiter-lend-idl": "0.1.8",
|
|
19
|
+
"@exponent-labs/jupiter-perps-idl": "0.1.8",
|
|
20
|
+
"@exponent-labs/kamino-reserve-deserializer": "0.1.8",
|
|
21
|
+
"@exponent-labs/kamino-sy-idl": "0.1.8",
|
|
22
|
+
"@exponent-labs/kamino-vault-idl": "0.1.8",
|
|
23
|
+
"@exponent-labs/marginfi-sy-idl": "0.1.8",
|
|
24
|
+
"@exponent-labs/meteora-idl": "0.1.8",
|
|
25
|
+
"@exponent-labs/perena-sy-idl": "0.1.8",
|
|
26
|
+
"@exponent-labs/precise-number": "0.1.8",
|
|
27
|
+
"@exponent-labs/sanctum-idl": "0.1.8",
|
|
28
|
+
"@exponent-labs/solstice-idl": "0.1.8",
|
|
29
|
+
"@exponent-labs/exponent-clmm-idl": "0.1.8",
|
|
30
|
+
"@exponent-labs/exponent-orderbook-idl": "0.1.8",
|
|
29
31
|
"@solana/spl-stake-pool": "1.1.8",
|
|
30
32
|
"@solana/spl-token": "0.4.6",
|
|
31
33
|
"bn-sqrt": "^1.0.0",
|