@0dotxyz/p0-ts-sdk 2.7.4 → 2.8.0-alpha.0

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.
@@ -0,0 +1,230 @@
1
+ import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
2
+ import BN from 'bn.js';
3
+ import { PublicKey, AccountMeta, Connection, AddressLookupTableAccount } from '@solana/web3.js';
4
+
5
+ declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
6
+ interface CurrentResult {
7
+ value: BN;
8
+ std_dev: BN;
9
+ mean: BN;
10
+ range: BN;
11
+ min_value: BN;
12
+ max_vaalue: BN;
13
+ slot: BN;
14
+ min_slot: BN;
15
+ max_slot: BN;
16
+ }
17
+ interface OracleSubmission {
18
+ oracle: PublicKey;
19
+ slot: BN;
20
+ value: BN;
21
+ }
22
+ interface PullFeedAccountData {
23
+ submissions: OracleSubmission[];
24
+ authority: PublicKey;
25
+ queue: PublicKey;
26
+ feed_hash: Buffer;
27
+ initialized_at: BN;
28
+ permissions: BN;
29
+ max_variance: BN;
30
+ min_responses: number;
31
+ name: Buffer;
32
+ sample_size: number;
33
+ last_update_timestamp: BN;
34
+ lut_slot: BN;
35
+ result: CurrentResult;
36
+ max_staleness: number;
37
+ min_sample_size: number;
38
+ }
39
+ type CrossbarSimulatePayload = FeedResponse[];
40
+ interface FeedResponse {
41
+ feedHash: string;
42
+ results: number[];
43
+ }
44
+ declare const switchboardAccountCoder: BorshCoder<string, string>;
45
+ declare function getSwitchboardProgram(provider: Provider): Program;
46
+ declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
47
+
48
+ /**
49
+ * An Exponent `CpiInterfaceContext` — one SY-program account a `trade_pt` CPI needs,
50
+ * referenced by its index into the **market's address lookup table** (not an inline
51
+ * pubkey). `resolveExponentTradePtContext` turns these into concrete {@link AccountMeta}s.
52
+ */
53
+ interface ExponentCpiInterfaceContext {
54
+ /** Index into the market's address lookup table. */
55
+ altIndex: number;
56
+ isSigner: boolean;
57
+ isWritable: boolean;
58
+ }
59
+ /**
60
+ * The SY-program CPI account lists that `trade_pt` appends as remaining accounts
61
+ * (order: `getSyState` ++ `depositSy` ++ `withdrawSy`). Pricing PT reads the SY rate
62
+ * on-chain, so the trade must carry the flavor's SY-state/deposit/withdraw accounts.
63
+ */
64
+ interface ExponentMarketTwoCpiAccounts {
65
+ getSyState: ExponentCpiInterfaceContext[];
66
+ depositSy: ExponentCpiInterfaceContext[];
67
+ withdrawSy: ExponentCpiInterfaceContext[];
68
+ }
69
+ /** The subset of an Exponent `MarketTwo` account that `trade_pt` needs. */
70
+ interface ExponentMarketTwo {
71
+ /** The market's own address (`self_address`). */
72
+ selfAddress: PublicKey;
73
+ mintPt: PublicKey;
74
+ mintSy: PublicKey;
75
+ vault: PublicKey;
76
+ /** Market liquidity escrow for PT (`token_pt_escrow`). */
77
+ tokenPtEscrow: PublicKey;
78
+ /** Market pass-through SY escrow (`token_sy_escrow`). */
79
+ tokenSyEscrow: PublicKey;
80
+ /** SY account holding treasury fees from PT trading (`token_fee_treasury_sy`). */
81
+ tokenFeeTreasurySy: PublicKey;
82
+ addressLookupTable: PublicKey;
83
+ syProgram: PublicKey;
84
+ statusFlags: number;
85
+ /** SY-program CPI account lists, referenced by ALT index. */
86
+ cpiAccounts: ExponentMarketTwoCpiAccounts;
87
+ }
88
+ /**
89
+ * Accounts required by `trade_pt`. The first 12 are the fixed `#[derive(Accounts)]`
90
+ * accounts; `remainingAccounts` are the SY-program CPI accounts (already resolved from
91
+ * the market ALT by {@link ResolveExponentTradePtContextParams}).
92
+ */
93
+ interface ExponentTradePtAccounts {
94
+ /** Trader / signer (the marginfi account authority). */
95
+ trader: PublicKey;
96
+ /** The `MarketTwo` address. */
97
+ market: PublicKey;
98
+ /** Trader's SY token account (source of the SY spent buying PT). */
99
+ tokenSyTrader: PublicKey;
100
+ /** Trader's PT token account (destination of the bought PT). */
101
+ tokenPtTrader: PublicKey;
102
+ /** `MarketTwo.token_sy_escrow`. */
103
+ tokenSyEscrow: PublicKey;
104
+ /** `MarketTwo.token_pt_escrow`. */
105
+ tokenPtEscrow: PublicKey;
106
+ /** `MarketTwo.address_lookup_table`. */
107
+ addressLookupTable: PublicKey;
108
+ /** `MarketTwo.sy_program`. */
109
+ syProgram: PublicKey;
110
+ /** `MarketTwo.token_fee_treasury_sy`. */
111
+ tokenFeeTreasurySy: PublicKey;
112
+ /** SPL token program for the PT/SY mints (defaults to the classic Token program). */
113
+ tokenProgram?: PublicKey;
114
+ /**
115
+ * SY-program CPI accounts (`getSyState` ++ `depositSy` ++ `withdrawSy`), pubkeys
116
+ * already resolved from the market ALT. Appended after the 12 fixed accounts.
117
+ */
118
+ remainingAccounts: AccountMeta[];
119
+ }
120
+ interface ResolveExponentTradePtContextParams {
121
+ connection: Connection;
122
+ /** Trader / signer (the marginfi account authority). */
123
+ owner: PublicKey;
124
+ /** The successor maturity's `MarketTwo` address (where the new PT trades). */
125
+ market: PublicKey;
126
+ /** Token program for the PT mint (Exponent uses the classic Token program). */
127
+ ptTokenProgram?: PublicKey;
128
+ /** Token program for the SY mint. Defaults to classic Token. */
129
+ syTokenProgram?: PublicKey;
130
+ }
131
+ /**
132
+ * Resolved inputs for a native `trade_pt` (SY → PT) on an Exponent `MarketTwo`: the
133
+ * fully-resolved `trade_pt` accounts (including the ALT-derived SY-CPI remaining
134
+ * accounts), the market ALT to add to the transaction's lookup tables, and the SY/PT
135
+ * token info. Feed `tradePtAccounts` + `addressLookupTable` into `makeRollPtTx`.
136
+ */
137
+ interface ExponentTradePtContext {
138
+ marketAddress: PublicKey;
139
+ market: ExponentMarketTwo;
140
+ tradePtAccounts: ExponentTradePtAccounts;
141
+ /** The market's address lookup table account — must be carried by the transaction. */
142
+ addressLookupTable: AddressLookupTableAccount;
143
+ sy: {
144
+ mint: PublicKey;
145
+ decimals: number;
146
+ tokenProgram: PublicKey;
147
+ };
148
+ pt: {
149
+ mint: PublicKey;
150
+ decimals: number;
151
+ tokenProgram: PublicKey;
152
+ };
153
+ }
154
+
155
+ /** The subset of Exponent's `Vault` account that `merge` / the roll needs. */
156
+ interface ExponentVault {
157
+ /** Vault signer authority (`merge.authority`, via `has_one = authority`). */
158
+ authority: PublicKey;
159
+ syProgram: PublicKey;
160
+ mintSy: PublicKey;
161
+ mintYt: PublicKey;
162
+ mintPt: PublicKey;
163
+ escrowSy: PublicKey;
164
+ yieldPosition: PublicKey;
165
+ addressLookupTable: PublicKey;
166
+ /**
167
+ * SY-program CPI account lists (referenced by ALT index). `merge` appends
168
+ * `get_sy_state ++ withdraw_sy` as remaining accounts.
169
+ */
170
+ cpiAccounts: ExponentMarketTwoCpiAccounts;
171
+ /**
172
+ * Total SY backing all PT (native u64). The PT→SY redemption rate is
173
+ * `sy_for_pt / pt_supply` (Exponent's `Vault::pt_redemption_rate`).
174
+ */
175
+ syForPt: bigint;
176
+ /** Total PT supply (native u64). */
177
+ ptSupply: bigint;
178
+ /** Last-seen SY exchange rate (underlying per SY), scaled by 1e12 → BigNumber. Sizes `strip`. */
179
+ lastSeenSyExchangeRate: BigNumber;
180
+ /** Final (maturity) SY exchange rate, already scaled by 1e12 → BigNumber (informational). */
181
+ finalSyExchangeRate: BigNumber;
182
+ /** Raw status byte. */
183
+ status: number;
184
+ /** Vault start timestamp (unix seconds); maturity = `startTs + duration`. */
185
+ startTs: number;
186
+ /** Vault duration in seconds. */
187
+ duration: number;
188
+ }
189
+
190
+ /**
191
+ * Decoded Gamma `LpVault` account (raw on-chain representation).
192
+ * Pubkeys as {@link PublicKey}, u64/i64 numeric fields as {@link BN}.
193
+ */
194
+ interface GammaLpVaultRaw {
195
+ pubkey: PublicKey;
196
+ assetsAccount: PublicKey;
197
+ pendingSharesAccount: PublicKey;
198
+ sharesMint: PublicKey;
199
+ assetsMint: PublicKey;
200
+ fundAuthority: PublicKey;
201
+ nav: BN;
202
+ totalShares: BN;
203
+ navUpdatedAt: BN;
204
+ navMaxStaleness: BN;
205
+ bump: number;
206
+ vaultName: string;
207
+ pendingWithdrawalValue: BN;
208
+ feeRecipient: PublicKey;
209
+ performanceFeeBps: number;
210
+ assessmentIntervalSecs: BN;
211
+ lastAssessmentTimestamp: BN;
212
+ pricePerShareAtLastAssessment: BN;
213
+ keeperAuthority: PublicKey;
214
+ }
215
+ /**
216
+ * Decoded Gamma `WithdrawReceipt` account — tracks a user's queued withdrawal
217
+ * against a vault (pending → claimable).
218
+ */
219
+ interface GammaWithdrawReceiptRaw {
220
+ pubkey: PublicKey;
221
+ user: PublicKey;
222
+ lpVault: PublicKey;
223
+ pendingShares: BN;
224
+ claimableShares: BN;
225
+ claimableAssets: BN;
226
+ oldestPendingAt: BN;
227
+ bump: number;
228
+ }
229
+
230
+ export { type CurrentResult as C, type ExponentVault as E, type FeedResponse as F, type GammaLpVaultRaw as G, type OracleSubmission as O, type PullFeedAccountData as P, type ResolveExponentTradePtContextParams as R, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION as S, type ExponentCpiInterfaceContext as a, type ExponentMarketTwo as b, type ExponentTradePtContext as c, type ExponentTradePtAccounts as d, type GammaWithdrawReceiptRaw as e, type CrossbarSimulatePayload as f, getSwitchboardProgram as g, decodeSwitchboardPullFeedData as h, type ExponentMarketTwoCpiAccounts as i, switchboardAccountCoder as s };
@@ -0,0 +1,230 @@
1
+ import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
2
+ import BN from 'bn.js';
3
+ import { PublicKey, AccountMeta, Connection, AddressLookupTableAccount } from '@solana/web3.js';
4
+
5
+ declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
6
+ interface CurrentResult {
7
+ value: BN;
8
+ std_dev: BN;
9
+ mean: BN;
10
+ range: BN;
11
+ min_value: BN;
12
+ max_vaalue: BN;
13
+ slot: BN;
14
+ min_slot: BN;
15
+ max_slot: BN;
16
+ }
17
+ interface OracleSubmission {
18
+ oracle: PublicKey;
19
+ slot: BN;
20
+ value: BN;
21
+ }
22
+ interface PullFeedAccountData {
23
+ submissions: OracleSubmission[];
24
+ authority: PublicKey;
25
+ queue: PublicKey;
26
+ feed_hash: Buffer;
27
+ initialized_at: BN;
28
+ permissions: BN;
29
+ max_variance: BN;
30
+ min_responses: number;
31
+ name: Buffer;
32
+ sample_size: number;
33
+ last_update_timestamp: BN;
34
+ lut_slot: BN;
35
+ result: CurrentResult;
36
+ max_staleness: number;
37
+ min_sample_size: number;
38
+ }
39
+ type CrossbarSimulatePayload = FeedResponse[];
40
+ interface FeedResponse {
41
+ feedHash: string;
42
+ results: number[];
43
+ }
44
+ declare const switchboardAccountCoder: BorshCoder<string, string>;
45
+ declare function getSwitchboardProgram(provider: Provider): Program;
46
+ declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
47
+
48
+ /**
49
+ * An Exponent `CpiInterfaceContext` — one SY-program account a `trade_pt` CPI needs,
50
+ * referenced by its index into the **market's address lookup table** (not an inline
51
+ * pubkey). `resolveExponentTradePtContext` turns these into concrete {@link AccountMeta}s.
52
+ */
53
+ interface ExponentCpiInterfaceContext {
54
+ /** Index into the market's address lookup table. */
55
+ altIndex: number;
56
+ isSigner: boolean;
57
+ isWritable: boolean;
58
+ }
59
+ /**
60
+ * The SY-program CPI account lists that `trade_pt` appends as remaining accounts
61
+ * (order: `getSyState` ++ `depositSy` ++ `withdrawSy`). Pricing PT reads the SY rate
62
+ * on-chain, so the trade must carry the flavor's SY-state/deposit/withdraw accounts.
63
+ */
64
+ interface ExponentMarketTwoCpiAccounts {
65
+ getSyState: ExponentCpiInterfaceContext[];
66
+ depositSy: ExponentCpiInterfaceContext[];
67
+ withdrawSy: ExponentCpiInterfaceContext[];
68
+ }
69
+ /** The subset of an Exponent `MarketTwo` account that `trade_pt` needs. */
70
+ interface ExponentMarketTwo {
71
+ /** The market's own address (`self_address`). */
72
+ selfAddress: PublicKey;
73
+ mintPt: PublicKey;
74
+ mintSy: PublicKey;
75
+ vault: PublicKey;
76
+ /** Market liquidity escrow for PT (`token_pt_escrow`). */
77
+ tokenPtEscrow: PublicKey;
78
+ /** Market pass-through SY escrow (`token_sy_escrow`). */
79
+ tokenSyEscrow: PublicKey;
80
+ /** SY account holding treasury fees from PT trading (`token_fee_treasury_sy`). */
81
+ tokenFeeTreasurySy: PublicKey;
82
+ addressLookupTable: PublicKey;
83
+ syProgram: PublicKey;
84
+ statusFlags: number;
85
+ /** SY-program CPI account lists, referenced by ALT index. */
86
+ cpiAccounts: ExponentMarketTwoCpiAccounts;
87
+ }
88
+ /**
89
+ * Accounts required by `trade_pt`. The first 12 are the fixed `#[derive(Accounts)]`
90
+ * accounts; `remainingAccounts` are the SY-program CPI accounts (already resolved from
91
+ * the market ALT by {@link ResolveExponentTradePtContextParams}).
92
+ */
93
+ interface ExponentTradePtAccounts {
94
+ /** Trader / signer (the marginfi account authority). */
95
+ trader: PublicKey;
96
+ /** The `MarketTwo` address. */
97
+ market: PublicKey;
98
+ /** Trader's SY token account (source of the SY spent buying PT). */
99
+ tokenSyTrader: PublicKey;
100
+ /** Trader's PT token account (destination of the bought PT). */
101
+ tokenPtTrader: PublicKey;
102
+ /** `MarketTwo.token_sy_escrow`. */
103
+ tokenSyEscrow: PublicKey;
104
+ /** `MarketTwo.token_pt_escrow`. */
105
+ tokenPtEscrow: PublicKey;
106
+ /** `MarketTwo.address_lookup_table`. */
107
+ addressLookupTable: PublicKey;
108
+ /** `MarketTwo.sy_program`. */
109
+ syProgram: PublicKey;
110
+ /** `MarketTwo.token_fee_treasury_sy`. */
111
+ tokenFeeTreasurySy: PublicKey;
112
+ /** SPL token program for the PT/SY mints (defaults to the classic Token program). */
113
+ tokenProgram?: PublicKey;
114
+ /**
115
+ * SY-program CPI accounts (`getSyState` ++ `depositSy` ++ `withdrawSy`), pubkeys
116
+ * already resolved from the market ALT. Appended after the 12 fixed accounts.
117
+ */
118
+ remainingAccounts: AccountMeta[];
119
+ }
120
+ interface ResolveExponentTradePtContextParams {
121
+ connection: Connection;
122
+ /** Trader / signer (the marginfi account authority). */
123
+ owner: PublicKey;
124
+ /** The successor maturity's `MarketTwo` address (where the new PT trades). */
125
+ market: PublicKey;
126
+ /** Token program for the PT mint (Exponent uses the classic Token program). */
127
+ ptTokenProgram?: PublicKey;
128
+ /** Token program for the SY mint. Defaults to classic Token. */
129
+ syTokenProgram?: PublicKey;
130
+ }
131
+ /**
132
+ * Resolved inputs for a native `trade_pt` (SY → PT) on an Exponent `MarketTwo`: the
133
+ * fully-resolved `trade_pt` accounts (including the ALT-derived SY-CPI remaining
134
+ * accounts), the market ALT to add to the transaction's lookup tables, and the SY/PT
135
+ * token info. Feed `tradePtAccounts` + `addressLookupTable` into `makeRollPtTx`.
136
+ */
137
+ interface ExponentTradePtContext {
138
+ marketAddress: PublicKey;
139
+ market: ExponentMarketTwo;
140
+ tradePtAccounts: ExponentTradePtAccounts;
141
+ /** The market's address lookup table account — must be carried by the transaction. */
142
+ addressLookupTable: AddressLookupTableAccount;
143
+ sy: {
144
+ mint: PublicKey;
145
+ decimals: number;
146
+ tokenProgram: PublicKey;
147
+ };
148
+ pt: {
149
+ mint: PublicKey;
150
+ decimals: number;
151
+ tokenProgram: PublicKey;
152
+ };
153
+ }
154
+
155
+ /** The subset of Exponent's `Vault` account that `merge` / the roll needs. */
156
+ interface ExponentVault {
157
+ /** Vault signer authority (`merge.authority`, via `has_one = authority`). */
158
+ authority: PublicKey;
159
+ syProgram: PublicKey;
160
+ mintSy: PublicKey;
161
+ mintYt: PublicKey;
162
+ mintPt: PublicKey;
163
+ escrowSy: PublicKey;
164
+ yieldPosition: PublicKey;
165
+ addressLookupTable: PublicKey;
166
+ /**
167
+ * SY-program CPI account lists (referenced by ALT index). `merge` appends
168
+ * `get_sy_state ++ withdraw_sy` as remaining accounts.
169
+ */
170
+ cpiAccounts: ExponentMarketTwoCpiAccounts;
171
+ /**
172
+ * Total SY backing all PT (native u64). The PT→SY redemption rate is
173
+ * `sy_for_pt / pt_supply` (Exponent's `Vault::pt_redemption_rate`).
174
+ */
175
+ syForPt: bigint;
176
+ /** Total PT supply (native u64). */
177
+ ptSupply: bigint;
178
+ /** Last-seen SY exchange rate (underlying per SY), scaled by 1e12 → BigNumber. Sizes `strip`. */
179
+ lastSeenSyExchangeRate: BigNumber;
180
+ /** Final (maturity) SY exchange rate, already scaled by 1e12 → BigNumber (informational). */
181
+ finalSyExchangeRate: BigNumber;
182
+ /** Raw status byte. */
183
+ status: number;
184
+ /** Vault start timestamp (unix seconds); maturity = `startTs + duration`. */
185
+ startTs: number;
186
+ /** Vault duration in seconds. */
187
+ duration: number;
188
+ }
189
+
190
+ /**
191
+ * Decoded Gamma `LpVault` account (raw on-chain representation).
192
+ * Pubkeys as {@link PublicKey}, u64/i64 numeric fields as {@link BN}.
193
+ */
194
+ interface GammaLpVaultRaw {
195
+ pubkey: PublicKey;
196
+ assetsAccount: PublicKey;
197
+ pendingSharesAccount: PublicKey;
198
+ sharesMint: PublicKey;
199
+ assetsMint: PublicKey;
200
+ fundAuthority: PublicKey;
201
+ nav: BN;
202
+ totalShares: BN;
203
+ navUpdatedAt: BN;
204
+ navMaxStaleness: BN;
205
+ bump: number;
206
+ vaultName: string;
207
+ pendingWithdrawalValue: BN;
208
+ feeRecipient: PublicKey;
209
+ performanceFeeBps: number;
210
+ assessmentIntervalSecs: BN;
211
+ lastAssessmentTimestamp: BN;
212
+ pricePerShareAtLastAssessment: BN;
213
+ keeperAuthority: PublicKey;
214
+ }
215
+ /**
216
+ * Decoded Gamma `WithdrawReceipt` account — tracks a user's queued withdrawal
217
+ * against a vault (pending → claimable).
218
+ */
219
+ interface GammaWithdrawReceiptRaw {
220
+ pubkey: PublicKey;
221
+ user: PublicKey;
222
+ lpVault: PublicKey;
223
+ pendingShares: BN;
224
+ claimableShares: BN;
225
+ claimableAssets: BN;
226
+ oldestPendingAt: BN;
227
+ bump: number;
228
+ }
229
+
230
+ export { type CurrentResult as C, type ExponentVault as E, type FeedResponse as F, type GammaLpVaultRaw as G, type OracleSubmission as O, type PullFeedAccountData as P, type ResolveExponentTradePtContextParams as R, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION as S, type ExponentCpiInterfaceContext as a, type ExponentMarketTwo as b, type ExponentTradePtContext as c, type ExponentTradePtAccounts as d, type GammaWithdrawReceiptRaw as e, type CrossbarSimulatePayload as f, getSwitchboardProgram as g, decodeSwitchboardPullFeedData as h, type ExponentMarketTwoCpiAccounts as i, switchboardAccountCoder as s };
package/dist/vendor.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var web3_js = require('@solana/web3.js');
4
- var bignumber_js = require('bignumber.js');
4
+ var BigNumber3 = require('bignumber.js');
5
5
  var borsh$1 = require('borsh');
6
6
  var BN5 = require('bn.js');
7
7
  var bufferLayout = require('@solana/buffer-layout');
@@ -33,6 +33,7 @@ function _interopNamespace(e) {
33
33
  return Object.freeze(n);
34
34
  }
35
35
 
36
+ var BigNumber3__default = /*#__PURE__*/_interopDefault(BigNumber3);
36
37
  var BN5__default = /*#__PURE__*/_interopDefault(BN5);
37
38
  var borsh__namespace = /*#__PURE__*/_interopNamespace(borsh);
38
39
  var Decimal3__default = /*#__PURE__*/_interopDefault(Decimal3);
@@ -3895,6 +3896,82 @@ function decodeSwitchboardPullFeedData(data) {
3895
3896
  );
3896
3897
  return pullFeedDAta;
3897
3898
  }
3899
+ var SCOPE_PROGRAM_ID = new web3_js.PublicKey("HFn8GnPADiny6XqUoWE8uRPPxb29ikn4yTuPa9MF2fWJ");
3900
+ var SCOPE_ORACLE_PRICES_DISCRIMINATOR = Buffer.from([89, 128, 118, 221, 6, 72, 180, 146]);
3901
+ var SCOPE_MAX_ENTRIES = 512;
3902
+ var ENTRIES_OFFSET = 40;
3903
+ var DATED_PRICE_SIZE = 56;
3904
+ var SCOPE_ORACLE_PRICES_SIZE = ENTRIES_OFFSET + SCOPE_MAX_ENTRIES * DATED_PRICE_SIZE;
3905
+ function decodeScopePriceAtIndex(data, entryIndex) {
3906
+ if (data.length !== SCOPE_ORACLE_PRICES_SIZE) {
3907
+ throw new Error(`Invalid Scope OraclePrices account size: ${data.length}`);
3908
+ }
3909
+ if (!data.subarray(0, 8).equals(SCOPE_ORACLE_PRICES_DISCRIMINATOR)) {
3910
+ throw new Error("Invalid Scope OraclePrices discriminator");
3911
+ }
3912
+ if (entryIndex < 0 || entryIndex >= SCOPE_MAX_ENTRIES) {
3913
+ throw new Error(`Scope entry index out of range: ${entryIndex}`);
3914
+ }
3915
+ const offset = ENTRIES_OFFSET + entryIndex * DATED_PRICE_SIZE;
3916
+ const value = data.readBigUInt64LE(offset);
3917
+ const exp = data.readBigUInt64LE(offset + 8);
3918
+ const lastUpdatedSlot = data.readBigUInt64LE(offset + 16);
3919
+ const unixTimestamp = data.readBigUInt64LE(offset + 24);
3920
+ const price = new BigNumber3__default.default(value.toString()).shiftedBy(-Number(exp));
3921
+ return {
3922
+ price,
3923
+ lastUpdatedSlot: Number(lastUpdatedSlot),
3924
+ unixTimestamp: Number(unixTimestamp)
3925
+ };
3926
+ }
3927
+ var MARINADE_PROGRAM_ID = new web3_js.PublicKey("MarBmsSgKXdrN1egZf5sqe1TMai9K1rChYNDJgjq7aD");
3928
+ var MARINADE_STATE_SIZE = 520;
3929
+ var MSOL_PRICE_OFFSET = 512;
3930
+ var MSOL_PRICE_PRECISION = new BigNumber3__default.default(2).pow(32);
3931
+ function decodeMarinadeState(data) {
3932
+ if (data.length !== MARINADE_STATE_SIZE) {
3933
+ throw new Error(`Invalid Marinade State account size: ${data.length}`);
3934
+ }
3935
+ const msolPriceRaw = data.readBigUInt64LE(MSOL_PRICE_OFFSET);
3936
+ return {
3937
+ msolPrice: new BigNumber3__default.default(msolPriceRaw.toString()).div(MSOL_PRICE_PRECISION)
3938
+ };
3939
+ }
3940
+ var SPL_STAKE_POOL_PROGRAM_ID = new web3_js.PublicKey(
3941
+ "SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy"
3942
+ );
3943
+ var SANCTUM_SPL_STAKE_POOL_PROGRAM_ID = new web3_js.PublicKey(
3944
+ "SP12tWFxD9oJsVWNavTTBZvMbA6gkAmxtVgxdqvyvhY"
3945
+ );
3946
+ var SANCTUM_SPL_MULTI_STAKE_POOL_PROGRAM_ID = new web3_js.PublicKey(
3947
+ "SPMBzsVUuoHA4Jm6KunbsotaahvVikZs1JyTW6iJvbn"
3948
+ );
3949
+ var ACCOUNT_TYPE_STAKE_POOL = 1;
3950
+ var TOTAL_LAMPORTS_OFFSET = 258;
3951
+ var POOL_TOKEN_SUPPLY_OFFSET = 266;
3952
+ var LAST_UPDATE_EPOCH_OFFSET = 274;
3953
+ function decodeStakePool(data) {
3954
+ if (data.length < LAST_UPDATE_EPOCH_OFFSET + 8) {
3955
+ throw new Error(`Invalid StakePool account size: ${data.length}`);
3956
+ }
3957
+ if (data[0] !== ACCOUNT_TYPE_STAKE_POOL) {
3958
+ throw new Error(`Invalid StakePool account type: ${data[0]}`);
3959
+ }
3960
+ const totalLamports = data.readBigUInt64LE(TOTAL_LAMPORTS_OFFSET);
3961
+ const poolTokenSupply = data.readBigUInt64LE(POOL_TOKEN_SUPPLY_OFFSET);
3962
+ const lastUpdateEpoch = Number(data.readBigUInt64LE(LAST_UPDATE_EPOCH_OFFSET));
3963
+ if (poolTokenSupply === 0n) {
3964
+ throw new Error("StakePool has zero token supply");
3965
+ }
3966
+ return {
3967
+ totalLamports,
3968
+ poolTokenSupply,
3969
+ lastUpdateEpoch,
3970
+ exchangeRate: new BigNumber3__default.default(totalLamports.toString()).div(
3971
+ new BigNumber3__default.default(poolTokenSupply.toString())
3972
+ )
3973
+ };
3974
+ }
3898
3975
  var KLEND_PROGRAM_ID = new web3_js.PublicKey(
3899
3976
  "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD"
3900
3977
  );
@@ -46487,7 +46564,7 @@ var exponent_clmm_default = {
46487
46564
  // src/vendor/exponent/idl/index.ts
46488
46565
  var EXPONENT_CORE_IDL = exponent_core_default;
46489
46566
  var EXPONENT_CLMM_IDL = exponent_clmm_default;
46490
- var EXPONENT_NUMBER_DENOM = new bignumber_js.BigNumber(1e12);
46567
+ var EXPONENT_NUMBER_DENOM = new BigNumber3.BigNumber(1e12);
46491
46568
  var EXPONENT_ACCOUNTS_CODER = new anchor.BorshAccountsCoder(EXPONENT_CORE_IDL);
46492
46569
  var EXPONENT_CLMM_ACCOUNTS_CODER = new anchor.BorshAccountsCoder(EXPONENT_CLMM_IDL);
46493
46570
  function exponentNumberToBigNumber(raw) {
@@ -46498,10 +46575,10 @@ function exponentNumberToBigNumber(raw) {
46498
46575
  if (!Array.isArray(words)) {
46499
46576
  throw new Error("exponentNumberToBigNumber: unexpected Number shape");
46500
46577
  }
46501
- let value = new bignumber_js.BigNumber(0);
46502
- const TWO_64 = new bignumber_js.BigNumber(2).pow(64);
46578
+ let value = new BigNumber3.BigNumber(0);
46579
+ const TWO_64 = new BigNumber3.BigNumber(2).pow(64);
46503
46580
  words.forEach((w, i) => {
46504
- const word = new bignumber_js.BigNumber(BN5__default.default.isBN(w) ? w.toString() : String(w));
46581
+ const word = new BigNumber3.BigNumber(BN5__default.default.isBN(w) ? w.toString() : String(w));
46505
46582
  value = value.plus(word.times(TWO_64.pow(i)));
46506
46583
  });
46507
46584
  return value.div(EXPONENT_NUMBER_DENOM);
@@ -46536,7 +46613,9 @@ function decodeExponentVault(data) {
46536
46613
  finalSyExchangeRate: exponentNumberToBigNumber(
46537
46614
  get("final_sy_exchange_rate", "finalSyExchangeRate")
46538
46615
  ),
46539
- status: Number(get("status", "status") ?? 0)
46616
+ status: Number(get("status", "status") ?? 0),
46617
+ startTs: Number(get("start_ts", "startTs") ?? 0),
46618
+ duration: Number(get("duration", "duration") ?? 0)
46540
46619
  };
46541
46620
  }
46542
46621
  function decodeExponentMarketVault(data) {
@@ -46919,7 +46998,7 @@ async function resolveExponentMergeContext(params) {
46919
46998
  underlying: { mint: vault.mintSy, decimals, tokenProgram: syTokenProgram },
46920
46999
  computeRedeemedAmountNative(ptAmountNative) {
46921
47000
  if (vault.ptSupply === 0n) return 0n;
46922
- const sy = new bignumber_js.BigNumber(ptAmountNative.toString()).times(vault.syForPt.toString()).div(vault.ptSupply.toString()).integerValue(bignumber_js.BigNumber.ROUND_FLOOR);
47001
+ const sy = new BigNumber3.BigNumber(ptAmountNative.toString()).times(vault.syForPt.toString()).div(vault.ptSupply.toString()).integerValue(BigNumber3.BigNumber.ROUND_FLOOR);
46923
47002
  return BigInt(sy.toFixed(0));
46924
47003
  }
46925
47004
  };
@@ -47083,7 +47162,7 @@ async function resolveExponentStripContext(params) {
47083
47162
  yt: { mint: vault.mintYt, tokenProgram: ptYtTokenProgram },
47084
47163
  syExchangeRate,
47085
47164
  computeStrippedPtNative(syInNative) {
47086
- const pt = vault.lastSeenSyExchangeRate.times(syInNative.toString()).integerValue(bignumber_js.BigNumber.ROUND_FLOOR);
47165
+ const pt = vault.lastSeenSyExchangeRate.times(syInNative.toString()).integerValue(BigNumber3.BigNumber.ROUND_FLOOR);
47087
47166
  return BigInt(pt.toFixed(0));
47088
47167
  }
47089
47168
  };
@@ -47195,7 +47274,7 @@ async function resolveExponentWrapperMergeContext(params) {
47195
47274
  ],
47196
47275
  computeRedeemedBaseNative(ptAmountNative) {
47197
47276
  if (vault.ptSupply === 0n) return 0n;
47198
- const base = new bignumber_js.BigNumber(ptAmountNative.toString()).times(vault.syForPt.toString()).div(vault.ptSupply.toString()).integerValue(bignumber_js.BigNumber.ROUND_FLOOR);
47277
+ const base = new BigNumber3.BigNumber(ptAmountNative.toString()).times(vault.syForPt.toString()).div(vault.ptSupply.toString()).integerValue(BigNumber3.BigNumber.ROUND_FLOOR);
47199
47278
  return BigInt(base.toFixed(0));
47200
47279
  }
47201
47280
  };
@@ -52626,6 +52705,8 @@ exports.KLEND_IDL = KLEND_IDL;
52626
52705
  exports.KLEND_PROGRAM_ID = KLEND_PROGRAM_ID;
52627
52706
  exports.KaminoInterestRateBasis = KaminoInterestRateBasis;
52628
52707
  exports.LENGTH_SIZE = LENGTH_SIZE;
52708
+ exports.MARINADE_PROGRAM_ID = MARINADE_PROGRAM_ID;
52709
+ exports.MARINADE_STATE_SIZE = MARINADE_STATE_SIZE;
52629
52710
  exports.MAX_SLOT_DIFFERENCE = MAX_SLOT_DIFFERENCE;
52630
52711
  exports.MEMO_PROGRAM_ID = MEMO_PROGRAM_ID;
52631
52712
  exports.MINT_SIZE = MINT_SIZE;
@@ -52641,6 +52722,12 @@ exports.PERCENTAGE_PRECISION_EXP = PERCENTAGE_PRECISION_EXP;
52641
52722
  exports.PriceStatus = PriceStatus;
52642
52723
  exports.PriceType = PriceType;
52643
52724
  exports.REFRESH_OBLIGATION_DISCRIMINATOR = REFRESH_OBLIGATION_DISCRIMINATOR;
52725
+ exports.SANCTUM_SPL_MULTI_STAKE_POOL_PROGRAM_ID = SANCTUM_SPL_MULTI_STAKE_POOL_PROGRAM_ID;
52726
+ exports.SANCTUM_SPL_STAKE_POOL_PROGRAM_ID = SANCTUM_SPL_STAKE_POOL_PROGRAM_ID;
52727
+ exports.SCOPE_MAX_ENTRIES = SCOPE_MAX_ENTRIES;
52728
+ exports.SCOPE_ORACLE_PRICES_DISCRIMINATOR = SCOPE_ORACLE_PRICES_DISCRIMINATOR;
52729
+ exports.SCOPE_ORACLE_PRICES_SIZE = SCOPE_ORACLE_PRICES_SIZE;
52730
+ exports.SCOPE_PROGRAM_ID = SCOPE_PROGRAM_ID;
52644
52731
  exports.SECONDS_PER_YEAR = SECONDS_PER_YEAR;
52645
52732
  exports.SEED_BASE_REFERRER_STATE = SEED_BASE_REFERRER_STATE;
52646
52733
  exports.SEED_BASE_REFERRER_TOKEN_STATE = SEED_BASE_REFERRER_TOKEN_STATE;
@@ -52677,6 +52764,7 @@ exports.SLOTS_PER_HOUR = SLOTS_PER_HOUR;
52677
52764
  exports.SLOTS_PER_MINUTE = SLOTS_PER_MINUTE;
52678
52765
  exports.SLOTS_PER_SECOND = SLOTS_PER_SECOND;
52679
52766
  exports.SLOTS_PER_YEAR = SLOTS_PER_YEAR;
52767
+ exports.SPL_STAKE_POOL_PROGRAM_ID = SPL_STAKE_POOL_PROGRAM_ID;
52680
52768
  exports.SPOT_MARKET_RATE_PRECISION = SPOT_MARKET_RATE_PRECISION;
52681
52769
  exports.SPOT_MARKET_RATE_PRECISION_EXP = SPOT_MARKET_RATE_PRECISION_EXP;
52682
52770
  exports.SPOT_MARKET_UTILIZATION_PRECISION = SPOT_MARKET_UTILIZATION_PRECISION;
@@ -52763,6 +52851,9 @@ exports.decodeJupRateModelData = decodeJupRateModelData;
52763
52851
  exports.decodeJupTokenReserveData = decodeJupTokenReserveData;
52764
52852
  exports.decodeKlendObligationData = decodeKlendObligationData;
52765
52853
  exports.decodeKlendReserveData = decodeKlendReserveData;
52854
+ exports.decodeMarinadeState = decodeMarinadeState;
52855
+ exports.decodeScopePriceAtIndex = decodeScopePriceAtIndex;
52856
+ exports.decodeStakePool = decodeStakePool;
52766
52857
  exports.decodeSwitchboardPullFeedData = decodeSwitchboardPullFeedData;
52767
52858
  exports.deriveBaseObligation = deriveBaseObligation;
52768
52859
  exports.deriveDriftSigner = deriveDriftSigner;