@elmntl/jlpd-sdk 0.1.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.
- package/README.md +363 -0
- package/dist/index.d.mts +743 -0
- package/dist/index.d.ts +743 -0
- package/dist/index.js +1843 -0
- package/dist/index.mjs +1753 -0
- package/package.json +30 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
import { PublicKey, AddressLookupTableAccount, Connection, VersionedTransaction, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
import { BN } from '@coral-xyz/anchor';
|
|
3
|
+
|
|
4
|
+
type PoolName = "SOL" | "USDC" | "JupUSD" | "BTC" | "ETH";
|
|
5
|
+
type JupEarnDirection = "Deposit" | "Withdraw";
|
|
6
|
+
type MoveDirection = "ToVault" | "FromVault";
|
|
7
|
+
type SwapDirection = "JlxToJlp" | "JlpToJlx";
|
|
8
|
+
interface JLPVault {
|
|
9
|
+
admin: PublicKey;
|
|
10
|
+
manager: PublicKey;
|
|
11
|
+
feeReceiver: PublicKey;
|
|
12
|
+
jlpMint: PublicKey;
|
|
13
|
+
baseAssetMints: PublicKey[];
|
|
14
|
+
jlxAssetMints: PublicKey[];
|
|
15
|
+
oracleStalenessThreshold: BN;
|
|
16
|
+
flags: number;
|
|
17
|
+
jlpSlippageBps: number;
|
|
18
|
+
version: number;
|
|
19
|
+
bump: number;
|
|
20
|
+
}
|
|
21
|
+
interface STV {
|
|
22
|
+
baseMint: PublicKey;
|
|
23
|
+
jlMint: PublicKey;
|
|
24
|
+
jvMint: PublicKey;
|
|
25
|
+
pps: BN;
|
|
26
|
+
hwm: BN;
|
|
27
|
+
lastMgmtFeeTs: BN;
|
|
28
|
+
baseLoaned: BN;
|
|
29
|
+
accruedFeesJlx: BN;
|
|
30
|
+
maxDeposit: BN;
|
|
31
|
+
minDeposit: BN;
|
|
32
|
+
mgmtFeeBps: number;
|
|
33
|
+
perfFeeBps: number;
|
|
34
|
+
flags: number;
|
|
35
|
+
version: number;
|
|
36
|
+
bump: number;
|
|
37
|
+
}
|
|
38
|
+
interface ExchangeRateResult {
|
|
39
|
+
rate: number;
|
|
40
|
+
rawRate: bigint;
|
|
41
|
+
storedRate: number;
|
|
42
|
+
staleness: number;
|
|
43
|
+
isFresh: boolean;
|
|
44
|
+
}
|
|
45
|
+
interface JupiterLendPool {
|
|
46
|
+
mint: PublicKey;
|
|
47
|
+
name: PoolName;
|
|
48
|
+
lending: PublicKey;
|
|
49
|
+
fTokenMint: PublicKey;
|
|
50
|
+
tokenReservesLiquidity: PublicKey;
|
|
51
|
+
supplyPositionOnLiquidity: PublicKey;
|
|
52
|
+
rewardsRateModel: PublicKey;
|
|
53
|
+
vault: PublicKey;
|
|
54
|
+
rateModel: PublicKey;
|
|
55
|
+
claimAccount: PublicKey;
|
|
56
|
+
decimals: number;
|
|
57
|
+
stvIndex: number;
|
|
58
|
+
hasJupiterLend: boolean;
|
|
59
|
+
}
|
|
60
|
+
interface AccountMeta {
|
|
61
|
+
pubkey: PublicKey;
|
|
62
|
+
isSigner: boolean;
|
|
63
|
+
isWritable: boolean;
|
|
64
|
+
}
|
|
65
|
+
interface SwapQuote {
|
|
66
|
+
inputMint: PublicKey;
|
|
67
|
+
outputMint: PublicKey;
|
|
68
|
+
inAmount: BN;
|
|
69
|
+
outAmount: BN;
|
|
70
|
+
minOutAmount: BN;
|
|
71
|
+
priceImpactPct: number;
|
|
72
|
+
route: string[];
|
|
73
|
+
jupiterData: Buffer;
|
|
74
|
+
remainingAccounts: AccountMeta[];
|
|
75
|
+
addressLookupTables: AddressLookupTableAccount[];
|
|
76
|
+
computeUnitLimit: number;
|
|
77
|
+
}
|
|
78
|
+
interface LendingAccountData {
|
|
79
|
+
mint: PublicKey;
|
|
80
|
+
fTokenMint: PublicKey;
|
|
81
|
+
lendingId: number;
|
|
82
|
+
decimals: number;
|
|
83
|
+
rewardsRateModel: PublicKey;
|
|
84
|
+
liquidityExchangePrice: bigint;
|
|
85
|
+
tokenExchangePrice: bigint;
|
|
86
|
+
lastUpdateTimestamp: bigint;
|
|
87
|
+
tokenReservesLiquidity: PublicKey;
|
|
88
|
+
supplyPositionOnLiquidity: PublicKey;
|
|
89
|
+
bump: number;
|
|
90
|
+
}
|
|
91
|
+
interface RewardsRateModelData {
|
|
92
|
+
mint: PublicKey;
|
|
93
|
+
startTvl: bigint;
|
|
94
|
+
duration: bigint;
|
|
95
|
+
startTime: bigint;
|
|
96
|
+
yearlyReward: bigint;
|
|
97
|
+
nextDuration: bigint;
|
|
98
|
+
nextRewardAmount: bigint;
|
|
99
|
+
bump: number;
|
|
100
|
+
}
|
|
101
|
+
interface UpdateVaultParams {
|
|
102
|
+
jlpMint?: PublicKey | null;
|
|
103
|
+
baseAssetMints?: PublicKey[] | null;
|
|
104
|
+
jlxAssetMints?: PublicKey[] | null;
|
|
105
|
+
newAdmin?: PublicKey | null;
|
|
106
|
+
manager?: PublicKey;
|
|
107
|
+
feeReceiver?: PublicKey;
|
|
108
|
+
oracleStalenessThreshold?: BN | null;
|
|
109
|
+
jlpSlippageBps?: number;
|
|
110
|
+
flags?: number;
|
|
111
|
+
}
|
|
112
|
+
interface UpdateStvParams$1 {
|
|
113
|
+
mgmtFeeBps?: number;
|
|
114
|
+
perfFeeBps?: number;
|
|
115
|
+
maxDeposit?: BN;
|
|
116
|
+
minDeposit?: BN;
|
|
117
|
+
flags?: number;
|
|
118
|
+
}
|
|
119
|
+
interface InitializeStvParams$1 {
|
|
120
|
+
poolName: PoolName;
|
|
121
|
+
mgmtFeeBps: number;
|
|
122
|
+
perfFeeBps: number;
|
|
123
|
+
maxDeposit: BN;
|
|
124
|
+
minDeposit: BN;
|
|
125
|
+
}
|
|
126
|
+
interface JupiterQuoteResponse {
|
|
127
|
+
inputMint: string;
|
|
128
|
+
inAmount: string;
|
|
129
|
+
outputMint: string;
|
|
130
|
+
outAmount: string;
|
|
131
|
+
otherAmountThreshold: string;
|
|
132
|
+
swapMode: string;
|
|
133
|
+
slippageBps: number;
|
|
134
|
+
platformFee: {
|
|
135
|
+
amount: string;
|
|
136
|
+
feeBps: number;
|
|
137
|
+
} | null;
|
|
138
|
+
priceImpactPct: string;
|
|
139
|
+
routePlan: Array<{
|
|
140
|
+
swapInfo: {
|
|
141
|
+
ammKey: string;
|
|
142
|
+
label?: string;
|
|
143
|
+
inputMint: string;
|
|
144
|
+
outputMint: string;
|
|
145
|
+
inAmount: string;
|
|
146
|
+
outAmount: string;
|
|
147
|
+
feeAmount: string;
|
|
148
|
+
feeMint: string;
|
|
149
|
+
};
|
|
150
|
+
percent: number;
|
|
151
|
+
}>;
|
|
152
|
+
contextSlot?: number;
|
|
153
|
+
timeTaken?: number;
|
|
154
|
+
}
|
|
155
|
+
interface JupiterSwapInstructionsResponse {
|
|
156
|
+
tokenLedgerInstruction: SerializedInstruction | null;
|
|
157
|
+
computeBudgetInstructions: SerializedInstruction[];
|
|
158
|
+
setupInstructions: SerializedInstruction[];
|
|
159
|
+
swapInstruction: SerializedInstruction;
|
|
160
|
+
cleanupInstruction: SerializedInstruction | null;
|
|
161
|
+
addressLookupTableAddresses: string[];
|
|
162
|
+
computeUnitLimit?: number;
|
|
163
|
+
error?: string;
|
|
164
|
+
}
|
|
165
|
+
interface SerializedInstruction {
|
|
166
|
+
programId: string;
|
|
167
|
+
accounts: Array<{
|
|
168
|
+
pubkey: string;
|
|
169
|
+
isSigner: boolean;
|
|
170
|
+
isWritable: boolean;
|
|
171
|
+
}>;
|
|
172
|
+
data: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
declare class JlpdClientError extends Error {
|
|
176
|
+
constructor(message: string);
|
|
177
|
+
}
|
|
178
|
+
interface DepositParams {
|
|
179
|
+
user: PublicKey;
|
|
180
|
+
amount: BN;
|
|
181
|
+
}
|
|
182
|
+
interface WithdrawParams {
|
|
183
|
+
user: PublicKey;
|
|
184
|
+
shares: BN;
|
|
185
|
+
}
|
|
186
|
+
interface JupEarnParams$1 {
|
|
187
|
+
manager: PublicKey;
|
|
188
|
+
direction: JupEarnDirection;
|
|
189
|
+
amount: BN;
|
|
190
|
+
}
|
|
191
|
+
interface MoveJlxParams$1 {
|
|
192
|
+
manager: PublicKey;
|
|
193
|
+
direction: MoveDirection;
|
|
194
|
+
jlxAmount: BN;
|
|
195
|
+
}
|
|
196
|
+
interface ClaimFeesParams {
|
|
197
|
+
manager: PublicKey;
|
|
198
|
+
}
|
|
199
|
+
interface SwapJlxJlpParams$1 {
|
|
200
|
+
manager: PublicKey;
|
|
201
|
+
pool: PoolName;
|
|
202
|
+
direction: SwapDirection;
|
|
203
|
+
amountIn: BN;
|
|
204
|
+
expectedOut: BN;
|
|
205
|
+
quote: SwapQuote;
|
|
206
|
+
}
|
|
207
|
+
interface SwapJlxJlxParams$1 {
|
|
208
|
+
manager: PublicKey;
|
|
209
|
+
fromPool: PoolName;
|
|
210
|
+
toPool: PoolName;
|
|
211
|
+
amountIn: BN;
|
|
212
|
+
minOut: BN;
|
|
213
|
+
quote: SwapQuote;
|
|
214
|
+
}
|
|
215
|
+
interface SettleYieldParams {
|
|
216
|
+
manager: PublicKey;
|
|
217
|
+
/** Manager-provided JLP rate (8 decimals, e.g., 460_000_000 = $4.60)
|
|
218
|
+
* Use fetchJlpRate() from jupiter/price to get this value */
|
|
219
|
+
jlpRate: BN;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Main SDK client for JLP.D program
|
|
223
|
+
*/
|
|
224
|
+
declare class JlpdClient {
|
|
225
|
+
readonly connection: Connection;
|
|
226
|
+
readonly programId: PublicKey;
|
|
227
|
+
readonly vaultPda: PublicKey;
|
|
228
|
+
readonly vaultBump: number;
|
|
229
|
+
private readonly poolContextCache;
|
|
230
|
+
constructor(connection: Connection, programId?: PublicKey);
|
|
231
|
+
static mainnet(connection: Connection): JlpdClient;
|
|
232
|
+
static devnet(connection: Connection): JlpdClient;
|
|
233
|
+
fetchVault(): Promise<JLPVault | null>;
|
|
234
|
+
fetchStv(baseMint: PublicKey): Promise<STV | null>;
|
|
235
|
+
fetchExchangeRate(poolName: PoolName): Promise<ExchangeRateResult>;
|
|
236
|
+
pool(poolNameOrMint: PoolName | PublicKey): PoolContext;
|
|
237
|
+
swap(): SwapContext;
|
|
238
|
+
admin(): AdminContext;
|
|
239
|
+
buildTransaction(payer: PublicKey, ixs: TransactionInstruction[], alts?: AddressLookupTableAccount[]): Promise<VersionedTransaction>;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Context for pool-specific operations
|
|
243
|
+
*/
|
|
244
|
+
declare class PoolContext {
|
|
245
|
+
readonly client: JlpdClient;
|
|
246
|
+
readonly pool: JupiterLendPool;
|
|
247
|
+
readonly stvPda: PublicKey;
|
|
248
|
+
readonly stvBump: number;
|
|
249
|
+
readonly vaultStagingAta: PublicKey;
|
|
250
|
+
readonly vaultJlpAta: PublicKey;
|
|
251
|
+
readonly stvBaseAta: PublicKey;
|
|
252
|
+
readonly stvJlxAta: PublicKey;
|
|
253
|
+
constructor(client: JlpdClient, pool: JupiterLendPool);
|
|
254
|
+
deposit(params: DepositParams): Promise<VersionedTransaction>;
|
|
255
|
+
withdraw(params: WithdrawParams): Promise<VersionedTransaction>;
|
|
256
|
+
jupEarn(params: JupEarnParams$1): Promise<VersionedTransaction>;
|
|
257
|
+
moveJlx(params: MoveJlxParams$1): Promise<VersionedTransaction>;
|
|
258
|
+
claimFees(params: ClaimFeesParams): Promise<VersionedTransaction>;
|
|
259
|
+
updateStv(params: {
|
|
260
|
+
admin: PublicKey;
|
|
261
|
+
} & UpdateStvParams$1): Promise<VersionedTransaction>;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Context for swap operations
|
|
265
|
+
*/
|
|
266
|
+
declare class SwapContext {
|
|
267
|
+
readonly client: JlpdClient;
|
|
268
|
+
constructor(client: JlpdClient);
|
|
269
|
+
quoteJlxJlp(params: {
|
|
270
|
+
pool: PoolName;
|
|
271
|
+
direction: SwapDirection;
|
|
272
|
+
amountIn: BN;
|
|
273
|
+
slippageBps?: number;
|
|
274
|
+
}): Promise<SwapQuote>;
|
|
275
|
+
swapJlxJlp(params: SwapJlxJlpParams$1): Promise<VersionedTransaction>;
|
|
276
|
+
quoteJlxJlx(params: {
|
|
277
|
+
fromPool: PoolName;
|
|
278
|
+
toPool: PoolName;
|
|
279
|
+
amountIn: BN;
|
|
280
|
+
slippageBps?: number;
|
|
281
|
+
}): Promise<SwapQuote>;
|
|
282
|
+
swapJlxJlx(params: SwapJlxJlxParams$1): Promise<VersionedTransaction>;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Context for admin operations
|
|
286
|
+
*/
|
|
287
|
+
declare class AdminContext {
|
|
288
|
+
readonly client: JlpdClient;
|
|
289
|
+
constructor(client: JlpdClient);
|
|
290
|
+
initOrUpdateVault(params: {
|
|
291
|
+
admin: PublicKey;
|
|
292
|
+
} & UpdateVaultParams): Promise<VersionedTransaction>;
|
|
293
|
+
initializeStv(params: {
|
|
294
|
+
admin: PublicKey;
|
|
295
|
+
} & InitializeStvParams$1, jvMintKeypair: PublicKey): Promise<VersionedTransaction>;
|
|
296
|
+
settleYield(params: SettleYieldParams): Promise<VersionedTransaction>;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
declare const JLPD_PROGRAM_ID: PublicKey;
|
|
300
|
+
declare const JUPITER_LEND_PROGRAM_ID$1: PublicKey;
|
|
301
|
+
declare const JUPITER_SWAP_PROGRAM_ID: PublicKey;
|
|
302
|
+
declare const SEED_JLP_VAULT = "jlp_vault";
|
|
303
|
+
declare const SEED_STV = "stv";
|
|
304
|
+
declare const FLAG_PAUSED = 1;
|
|
305
|
+
declare const FLAG_DEPOSITS_DISABLED = 2;
|
|
306
|
+
declare const FLAG_WITHDRAWALS_DISABLED = 4;
|
|
307
|
+
declare const FLAG_JLP_DISABLED = 8;
|
|
308
|
+
declare const FLAG_REBALANCE_DISABLED = 16;
|
|
309
|
+
declare const PPS_DECIMALS = 1000000000;
|
|
310
|
+
declare const EXCHANGE_RATE_PRECISION = 1000000000000;
|
|
311
|
+
declare const MINTS: {
|
|
312
|
+
readonly JLP: PublicKey;
|
|
313
|
+
readonly WSOL: PublicKey;
|
|
314
|
+
readonly USDC: PublicKey;
|
|
315
|
+
readonly WBTC: PublicKey;
|
|
316
|
+
readonly WETH: PublicKey;
|
|
317
|
+
readonly JupUSD: PublicKey;
|
|
318
|
+
};
|
|
319
|
+
declare enum STV_INDEX {
|
|
320
|
+
BTC = 0,
|
|
321
|
+
ETH = 1,
|
|
322
|
+
SOL = 2,
|
|
323
|
+
USDC = 3,
|
|
324
|
+
JupUSD = 4
|
|
325
|
+
}
|
|
326
|
+
declare const ORACLES: {
|
|
327
|
+
readonly DOVES_BTC_USD: PublicKey;
|
|
328
|
+
readonly DOVES_ETH_USD: PublicKey;
|
|
329
|
+
readonly DOVES_SOL_USD: PublicKey;
|
|
330
|
+
readonly PYTH_JLP_USD: PublicKey;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Derive the JLP Vault PDA address (cached)
|
|
335
|
+
* Seeds: ["jlp_vault"]
|
|
336
|
+
*/
|
|
337
|
+
declare function deriveVaultPda(programId: PublicKey): [PublicKey, number];
|
|
338
|
+
/**
|
|
339
|
+
* Derive an STV (Single Token Vault) PDA address (cached)
|
|
340
|
+
* Seeds: ["stv", base_mint]
|
|
341
|
+
*/
|
|
342
|
+
declare function deriveStvPda(baseMint: PublicKey, programId: PublicKey): [PublicKey, number];
|
|
343
|
+
/**
|
|
344
|
+
* Clear PDA cache (useful for testing)
|
|
345
|
+
*/
|
|
346
|
+
declare function clearPdaCache(): void;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* JLPVault account layout (464 bytes data + 8 byte discriminator = 472 bytes total)
|
|
350
|
+
*/
|
|
351
|
+
declare const JLP_VAULT_DATA_SIZE = 464;
|
|
352
|
+
declare const JLP_VAULT_ACCOUNT_SIZE: number;
|
|
353
|
+
declare const JLP_VAULT_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
354
|
+
/**
|
|
355
|
+
* Parse a JLPVault account from raw account data
|
|
356
|
+
*/
|
|
357
|
+
declare function parseVault(data: Buffer): JLPVault;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* STV (Single Token Vault) account layout (160 bytes data + 8 byte discriminator = 168 bytes total)
|
|
361
|
+
*/
|
|
362
|
+
declare const STV_DATA_SIZE = 160;
|
|
363
|
+
declare const STV_ACCOUNT_SIZE: number;
|
|
364
|
+
declare const STV_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
365
|
+
/**
|
|
366
|
+
* Parse an STV account from raw account data
|
|
367
|
+
*/
|
|
368
|
+
declare function parseStv(data: Buffer): STV;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Derive ATA address (cached)
|
|
372
|
+
*/
|
|
373
|
+
declare function deriveAta(mint: PublicKey, owner: PublicKey, allowPda?: boolean): PublicKey;
|
|
374
|
+
/**
|
|
375
|
+
* Derive all ATAs for a user interacting with an STV (cached)
|
|
376
|
+
*/
|
|
377
|
+
declare function deriveUserAtas(baseMint: PublicKey, jvMint: PublicKey, userWallet: PublicKey): {
|
|
378
|
+
baseAta: PublicKey;
|
|
379
|
+
jvxAta: PublicKey;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* Derive all ATAs owned by an STV PDA (cached)
|
|
383
|
+
*/
|
|
384
|
+
declare function deriveStvAtas(baseMint: PublicKey, jlxMint: PublicKey, stvPda: PublicKey): {
|
|
385
|
+
baseAta: PublicKey;
|
|
386
|
+
jlxAta: PublicKey;
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Derive vault staging and JLP ATAs (owned by vault PDA, cached)
|
|
390
|
+
*/
|
|
391
|
+
declare function deriveVaultAtas(jlxMint: PublicKey, jlpMint: PublicKey, vaultPda: PublicKey): {
|
|
392
|
+
stagingAta: PublicKey;
|
|
393
|
+
jlpAta: PublicKey;
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* Clear ATA cache (useful for testing)
|
|
397
|
+
*/
|
|
398
|
+
declare function clearAtaCache(): void;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Calculate NAV for an STV
|
|
402
|
+
* NAV = stv_base_ata.amount + (stv_jlx_ata.amount * exchange_rate / 1e12) + base_loaned
|
|
403
|
+
*/
|
|
404
|
+
declare function calculateNav(stvBaseBalance: BN, stvJlxBalance: BN, exchangeRate: bigint, baseLoaned: BN): BN;
|
|
405
|
+
/**
|
|
406
|
+
* Calculate PPS from NAV and total jvX supply
|
|
407
|
+
* PPS = NAV * PPS_DECIMALS / total_jvx_supply
|
|
408
|
+
*/
|
|
409
|
+
declare function calculatePps(nav: BN, jvSupply: BN): BN;
|
|
410
|
+
/**
|
|
411
|
+
* Convert shares to base amount
|
|
412
|
+
*/
|
|
413
|
+
declare function sharesToBase(shares: BN, pps: BN): BN;
|
|
414
|
+
/**
|
|
415
|
+
* Convert base amount to shares
|
|
416
|
+
*/
|
|
417
|
+
declare function baseToShares(base: BN, pps: BN): BN;
|
|
418
|
+
/**
|
|
419
|
+
* Convert jlX to base using exchange rate
|
|
420
|
+
*/
|
|
421
|
+
declare function jlxToBase(jlxAmount: BN, exchangeRate: BN): BN;
|
|
422
|
+
/**
|
|
423
|
+
* Convert base to jlX using exchange rate
|
|
424
|
+
*/
|
|
425
|
+
declare function baseToJlx(baseAmount: BN, exchangeRate: BN): BN;
|
|
426
|
+
/**
|
|
427
|
+
* Calculate full exchange rate including time-accrued rewards
|
|
428
|
+
*/
|
|
429
|
+
declare function calculateExchangeRate(storedRate: bigint, rewardsRate: bigint, currentTimestamp: bigint, lastUpdateTimestamp: bigint, fTokenTotalSupply: bigint): bigint;
|
|
430
|
+
|
|
431
|
+
declare const LENDING_ADMIN: PublicKey;
|
|
432
|
+
declare const LIQUIDITY_PROGRAM_ID: PublicKey;
|
|
433
|
+
declare const LIQUIDITY_SINGLETON: PublicKey;
|
|
434
|
+
declare const WSOL_POOL: JupiterLendPool;
|
|
435
|
+
declare const USDC_POOL: JupiterLendPool;
|
|
436
|
+
declare const JUPUSD_POOL: JupiterLendPool;
|
|
437
|
+
declare const WBTC_POOL: JupiterLendPool;
|
|
438
|
+
declare const WETH_POOL: JupiterLendPool;
|
|
439
|
+
declare const POOLS: Record<PoolName, JupiterLendPool>;
|
|
440
|
+
declare function getPoolByName(name: PoolName): JupiterLendPool | undefined;
|
|
441
|
+
declare function getPoolByMint(mint: PublicKey): JupiterLendPool | undefined;
|
|
442
|
+
|
|
443
|
+
declare const JUPITER_LEND_PROGRAM_ID: PublicKey;
|
|
444
|
+
/**
|
|
445
|
+
* Build remaining accounts for deposit/withdraw exchange rate lookup
|
|
446
|
+
*/
|
|
447
|
+
declare function buildExchangeRateAccounts(pool: JupiterLendPool): {
|
|
448
|
+
lending: PublicKey;
|
|
449
|
+
rewardsRateModel: PublicKey;
|
|
450
|
+
} | null;
|
|
451
|
+
/**
|
|
452
|
+
* Build remaining accounts for jup_earn_deposit instruction (17 accounts + program ID)
|
|
453
|
+
*/
|
|
454
|
+
declare function buildJupEarnDepositAccounts(pool: JupiterLendPool, stvPda: PublicKey, stvBaseAta: PublicKey, stvJlxAta: PublicKey): AccountMeta[];
|
|
455
|
+
/**
|
|
456
|
+
* Build remaining accounts for jup_earn_withdraw instruction (18 accounts + program ID)
|
|
457
|
+
*/
|
|
458
|
+
declare function buildJupEarnWithdrawAccounts(pool: JupiterLendPool, stvPda: PublicKey, stvJlxAta: PublicKey, stvBaseAta: PublicKey): AccountMeta[];
|
|
459
|
+
/**
|
|
460
|
+
* Parse Lending account data from buffer
|
|
461
|
+
*/
|
|
462
|
+
declare function parseLendingAccount(data: Buffer): LendingAccountData;
|
|
463
|
+
/**
|
|
464
|
+
* Parse LendingRewardsRateModel account data from buffer
|
|
465
|
+
*/
|
|
466
|
+
declare function parseRewardsRateModel(data: Buffer): RewardsRateModelData;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Get a swap quote from Jupiter API
|
|
470
|
+
*/
|
|
471
|
+
declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: bigint | number, slippageBps?: number, maxAccounts?: number): Promise<JupiterQuoteResponse>;
|
|
472
|
+
/**
|
|
473
|
+
* Get swap instructions from Jupiter API
|
|
474
|
+
*/
|
|
475
|
+
declare function getJupiterSwapInstructions(quote: JupiterQuoteResponse, userPubkey: PublicKey): Promise<JupiterSwapInstructionsResponse>;
|
|
476
|
+
/**
|
|
477
|
+
* Parse swap instruction to extract remaining accounts
|
|
478
|
+
*/
|
|
479
|
+
declare function parseSwapRemainingAccounts(swapInstruction: SerializedInstruction): AccountMeta[];
|
|
480
|
+
/**
|
|
481
|
+
* Fetch Address Lookup Tables from the chain
|
|
482
|
+
*/
|
|
483
|
+
declare function fetchAddressLookupTables(connection: Connection, addresses: string[]): Promise<AddressLookupTableAccount[]>;
|
|
484
|
+
/**
|
|
485
|
+
* Build complete swap data for CPI including quote, instructions, and ALTs
|
|
486
|
+
*/
|
|
487
|
+
declare function buildSwapData(connection: Connection, inputMint: PublicKey, outputMint: PublicKey, amount: bigint | number, userPubkey: PublicKey, slippageBps?: number, maxAccounts?: number): Promise<{
|
|
488
|
+
quote: JupiterQuoteResponse;
|
|
489
|
+
instructions: JupiterSwapInstructionsResponse;
|
|
490
|
+
remainingAccounts: AccountMeta[];
|
|
491
|
+
addressLookupTables: AddressLookupTableAccount[];
|
|
492
|
+
}>;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Jupiter Price API V3 Integration
|
|
496
|
+
*
|
|
497
|
+
* Used to fetch token prices for settle_yield instruction.
|
|
498
|
+
* Manager must provide JLP rate which is validated against Pyth on-chain.
|
|
499
|
+
*/
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Jupiter Price API V3 response for a single token
|
|
503
|
+
*/
|
|
504
|
+
interface JupiterPriceData {
|
|
505
|
+
createdAt: string;
|
|
506
|
+
liquidity: number;
|
|
507
|
+
usdPrice: number;
|
|
508
|
+
blockId: number;
|
|
509
|
+
decimals: number;
|
|
510
|
+
priceChange24h: number;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Jupiter Price API V3 response
|
|
514
|
+
*/
|
|
515
|
+
type JupiterPriceResponse = {
|
|
516
|
+
[mint: string]: JupiterPriceData;
|
|
517
|
+
};
|
|
518
|
+
/**
|
|
519
|
+
* Fetch token price from Jupiter Price API V3
|
|
520
|
+
*
|
|
521
|
+
* @param mint Token mint address
|
|
522
|
+
* @param apiKey Jupiter API key (uses default if not provided)
|
|
523
|
+
* @returns Price in USD as a number, or null if unavailable
|
|
524
|
+
*/
|
|
525
|
+
declare function fetchJupiterPriceUsd(mint: string, apiKey?: string): Promise<number | null>;
|
|
526
|
+
/**
|
|
527
|
+
* Fetch JLP price and convert to 8 decimals for on-chain use
|
|
528
|
+
*
|
|
529
|
+
* This is the format required by the settle_yield instruction's jlp_rate parameter.
|
|
530
|
+
* The rate is validated against Pyth oracle on-chain (must be within 50 bps).
|
|
531
|
+
*
|
|
532
|
+
* @param jlpMint JLP token mint address
|
|
533
|
+
* @param fallbackPrice Fallback price in USD if API fails (default: $4.60)
|
|
534
|
+
* @param apiKey Jupiter API key (uses default if not provided)
|
|
535
|
+
* @returns Price as BN with 8 decimals (e.g., $4.60 -> 460_000_000)
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* ```typescript
|
|
539
|
+
* const jlpRate = await fetchJlpRate(MINTS.JLP);
|
|
540
|
+
* const tx = await adminContext.settleYield({
|
|
541
|
+
* manager: wallet.publicKey,
|
|
542
|
+
* jlpRate,
|
|
543
|
+
* oracles: { ... }
|
|
544
|
+
* });
|
|
545
|
+
* ```
|
|
546
|
+
*/
|
|
547
|
+
declare function fetchJlpRate(jlpMint: string, fallbackPrice?: number, apiKey?: string): Promise<BN>;
|
|
548
|
+
|
|
549
|
+
interface InitOrUpdateJlpVaultParams {
|
|
550
|
+
jlpMint: PublicKey | null;
|
|
551
|
+
baseAssetMints: PublicKey[] | null;
|
|
552
|
+
jlxAssetMints: PublicKey[] | null;
|
|
553
|
+
newAdmin: PublicKey | null;
|
|
554
|
+
manager?: PublicKey;
|
|
555
|
+
feeReceiver?: PublicKey;
|
|
556
|
+
flags?: number;
|
|
557
|
+
jlpSlippageBps?: number;
|
|
558
|
+
oracleStalenessThreshold: BN | null;
|
|
559
|
+
}
|
|
560
|
+
interface InitializeStvParams {
|
|
561
|
+
mgmtFeeBps: number;
|
|
562
|
+
perfFeeBps: number;
|
|
563
|
+
maxDeposit: BN;
|
|
564
|
+
minDeposit: BN;
|
|
565
|
+
}
|
|
566
|
+
interface UpdateStvParams {
|
|
567
|
+
mgmtFeeBps?: number;
|
|
568
|
+
perfFeeBps?: number;
|
|
569
|
+
flags?: number;
|
|
570
|
+
maxDeposit?: BN;
|
|
571
|
+
minDeposit?: BN;
|
|
572
|
+
}
|
|
573
|
+
interface InitOrUpdateJlpVaultAccounts {
|
|
574
|
+
admin: PublicKey;
|
|
575
|
+
jlpVault: PublicKey;
|
|
576
|
+
systemProgram: PublicKey;
|
|
577
|
+
}
|
|
578
|
+
interface InitializeStvAccounts {
|
|
579
|
+
admin: PublicKey;
|
|
580
|
+
jlpVault: PublicKey;
|
|
581
|
+
stv: PublicKey;
|
|
582
|
+
baseMint: PublicKey;
|
|
583
|
+
jlMint: PublicKey;
|
|
584
|
+
jvMint: PublicKey;
|
|
585
|
+
stvJlxAta: PublicKey;
|
|
586
|
+
systemProgram: PublicKey;
|
|
587
|
+
tokenProgram: PublicKey;
|
|
588
|
+
associatedTokenProgram: PublicKey;
|
|
589
|
+
rent: PublicKey;
|
|
590
|
+
}
|
|
591
|
+
interface UpdateStvAccounts {
|
|
592
|
+
admin: PublicKey;
|
|
593
|
+
jlpVault: PublicKey;
|
|
594
|
+
stv: PublicKey;
|
|
595
|
+
}
|
|
596
|
+
declare function createInitOrUpdateVaultInstruction(params: InitOrUpdateJlpVaultParams, accounts: InitOrUpdateJlpVaultAccounts, programId?: PublicKey): TransactionInstruction;
|
|
597
|
+
declare function createInitializeStvInstruction(params: InitializeStvParams, accounts: InitializeStvAccounts, programId?: PublicKey): TransactionInstruction;
|
|
598
|
+
declare function createUpdateStvInstruction(params: UpdateStvParams, accounts: UpdateStvAccounts, programId?: PublicKey): TransactionInstruction;
|
|
599
|
+
|
|
600
|
+
interface DepositAccounts {
|
|
601
|
+
user: PublicKey;
|
|
602
|
+
jlpVault: PublicKey;
|
|
603
|
+
stv: PublicKey;
|
|
604
|
+
baseMint: PublicKey;
|
|
605
|
+
jlMint: PublicKey;
|
|
606
|
+
jvMint: PublicKey;
|
|
607
|
+
userBaseAta: PublicKey;
|
|
608
|
+
userJvxAta: PublicKey;
|
|
609
|
+
stvBaseAta: PublicKey;
|
|
610
|
+
stvJlxAta: PublicKey;
|
|
611
|
+
tokenProgram: PublicKey;
|
|
612
|
+
}
|
|
613
|
+
interface WithdrawAccounts {
|
|
614
|
+
user: PublicKey;
|
|
615
|
+
jlpVault: PublicKey;
|
|
616
|
+
stv: PublicKey;
|
|
617
|
+
baseMint: PublicKey;
|
|
618
|
+
jlMint: PublicKey;
|
|
619
|
+
jvMint: PublicKey;
|
|
620
|
+
userBaseAta: PublicKey;
|
|
621
|
+
userJvxAta: PublicKey;
|
|
622
|
+
stvBaseAta: PublicKey;
|
|
623
|
+
stvJlxAta: PublicKey;
|
|
624
|
+
tokenProgram: PublicKey;
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Create a deposit instruction
|
|
628
|
+
*/
|
|
629
|
+
declare function createDepositInstruction(amount: BN, accounts: DepositAccounts, remainingAccounts?: AccountMeta[], programId?: PublicKey): TransactionInstruction;
|
|
630
|
+
/**
|
|
631
|
+
* Create a withdraw instruction
|
|
632
|
+
*/
|
|
633
|
+
declare function createWithdrawInstruction(sharesToBurn: BN, accounts: WithdrawAccounts, remainingAccounts?: AccountMeta[], programId?: PublicKey): TransactionInstruction;
|
|
634
|
+
|
|
635
|
+
interface JupEarnParams {
|
|
636
|
+
direction: JupEarnDirection;
|
|
637
|
+
amount: BN;
|
|
638
|
+
}
|
|
639
|
+
interface MoveJlxParams {
|
|
640
|
+
amountJlx: BN;
|
|
641
|
+
direction: MoveDirection;
|
|
642
|
+
}
|
|
643
|
+
interface SwapJlxJlxParams {
|
|
644
|
+
fromIndex: number;
|
|
645
|
+
toIndex: number;
|
|
646
|
+
amountIn: BN;
|
|
647
|
+
minOut: BN;
|
|
648
|
+
jupiterData: Buffer;
|
|
649
|
+
}
|
|
650
|
+
interface SwapJlxJlpParams {
|
|
651
|
+
stvIndex: number;
|
|
652
|
+
direction: SwapDirection;
|
|
653
|
+
amountIn: BN;
|
|
654
|
+
expectedAmountOut: BN;
|
|
655
|
+
jupiterData: Buffer;
|
|
656
|
+
}
|
|
657
|
+
interface JupEarnAccounts {
|
|
658
|
+
manager: PublicKey;
|
|
659
|
+
jlpVault: PublicKey;
|
|
660
|
+
stv: PublicKey;
|
|
661
|
+
baseMint: PublicKey;
|
|
662
|
+
jlMint: PublicKey;
|
|
663
|
+
stvBaseAta: PublicKey;
|
|
664
|
+
stvJlxAta: PublicKey;
|
|
665
|
+
tokenProgram: PublicKey;
|
|
666
|
+
}
|
|
667
|
+
interface MoveStvAccounts {
|
|
668
|
+
manager: PublicKey;
|
|
669
|
+
jlpVault: PublicKey;
|
|
670
|
+
stv: PublicKey;
|
|
671
|
+
baseMint: PublicKey;
|
|
672
|
+
jlMint: PublicKey;
|
|
673
|
+
stvJlxAta: PublicKey;
|
|
674
|
+
vaultStagingAta: PublicKey;
|
|
675
|
+
tokenProgram: PublicKey;
|
|
676
|
+
}
|
|
677
|
+
interface SwapJlxJlxAccounts {
|
|
678
|
+
manager: PublicKey;
|
|
679
|
+
jlpVault: PublicKey;
|
|
680
|
+
fromJlxMint: PublicKey;
|
|
681
|
+
toJlxMint: PublicKey;
|
|
682
|
+
fromJlxAta: PublicKey;
|
|
683
|
+
toJlxAta: PublicKey;
|
|
684
|
+
tokenProgram: PublicKey;
|
|
685
|
+
jupiterProgram: PublicKey;
|
|
686
|
+
}
|
|
687
|
+
interface SwapJlxJlpAccounts {
|
|
688
|
+
manager: PublicKey;
|
|
689
|
+
jlpVault: PublicKey;
|
|
690
|
+
vaultJlxAta: PublicKey;
|
|
691
|
+
vaultJlpAta: PublicKey;
|
|
692
|
+
jlpMint: PublicKey;
|
|
693
|
+
tokenProgram: PublicKey;
|
|
694
|
+
jupiterProgram: PublicKey;
|
|
695
|
+
}
|
|
696
|
+
interface SettleYieldAccounts {
|
|
697
|
+
manager: PublicKey;
|
|
698
|
+
jlpVault: PublicKey;
|
|
699
|
+
vaultJlpAta: PublicKey;
|
|
700
|
+
jlpMint: PublicKey;
|
|
701
|
+
stvBtc: PublicKey;
|
|
702
|
+
stvEth: PublicKey;
|
|
703
|
+
stvSol: PublicKey;
|
|
704
|
+
stvUsdc: PublicKey;
|
|
705
|
+
stvJupusd: PublicKey;
|
|
706
|
+
stagingBtc: PublicKey;
|
|
707
|
+
stagingEth: PublicKey;
|
|
708
|
+
stagingSol: PublicKey;
|
|
709
|
+
stagingUsdc: PublicKey;
|
|
710
|
+
stagingJupusd: PublicKey;
|
|
711
|
+
oracleBtc: PublicKey;
|
|
712
|
+
oracleEth: PublicKey;
|
|
713
|
+
oracleSol: PublicKey;
|
|
714
|
+
oracleJlp: PublicKey;
|
|
715
|
+
}
|
|
716
|
+
interface SettleYieldInstructionParams {
|
|
717
|
+
/** Manager-provided JLP rate (8 decimals, e.g., 460_000_000 = $4.60) */
|
|
718
|
+
jlpRate: BN;
|
|
719
|
+
}
|
|
720
|
+
declare function createJupEarnInstruction(params: JupEarnParams, accounts: JupEarnAccounts, remainingAccounts?: AccountMeta[], programId?: PublicKey): TransactionInstruction;
|
|
721
|
+
declare function createMoveJlxInstruction(params: MoveJlxParams, accounts: MoveStvAccounts, remainingAccounts?: AccountMeta[], programId?: PublicKey): TransactionInstruction;
|
|
722
|
+
declare function createSwapJlxJlxInstruction(params: SwapJlxJlxParams, accounts: SwapJlxJlxAccounts, remainingAccounts?: AccountMeta[], programId?: PublicKey): TransactionInstruction;
|
|
723
|
+
declare function createSwapJlxJlpInstruction(params: SwapJlxJlpParams, accounts: SwapJlxJlpAccounts, remainingAccounts?: AccountMeta[], programId?: PublicKey): TransactionInstruction;
|
|
724
|
+
declare function createSettleYieldInstruction(params: SettleYieldInstructionParams, accounts: SettleYieldAccounts, remainingAccounts?: AccountMeta[], programId?: PublicKey): TransactionInstruction;
|
|
725
|
+
|
|
726
|
+
interface ClaimFeesAccounts {
|
|
727
|
+
manager: PublicKey;
|
|
728
|
+
jlpVault: PublicKey;
|
|
729
|
+
stv: PublicKey;
|
|
730
|
+
baseMint: PublicKey;
|
|
731
|
+
jlMint: PublicKey;
|
|
732
|
+
jvMint: PublicKey;
|
|
733
|
+
stvBaseAta: PublicKey;
|
|
734
|
+
stvJlxAta: PublicKey;
|
|
735
|
+
feeReceiverJlxAta: PublicKey;
|
|
736
|
+
tokenProgram: PublicKey;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Create a claim_fees instruction
|
|
740
|
+
*/
|
|
741
|
+
declare function createClaimFeesInstruction(accounts: ClaimFeesAccounts, remainingAccounts?: AccountMeta[], programId?: PublicKey): TransactionInstruction;
|
|
742
|
+
|
|
743
|
+
export { type AccountMeta, AdminContext, type ClaimFeesAccounts, type ClaimFeesParams, type DepositAccounts, type DepositParams, EXCHANGE_RATE_PRECISION, type ExchangeRateResult, FLAG_DEPOSITS_DISABLED, FLAG_JLP_DISABLED, FLAG_PAUSED, FLAG_REBALANCE_DISABLED, FLAG_WITHDRAWALS_DISABLED, type InitOrUpdateJlpVaultAccounts, type InitOrUpdateJlpVaultParams, type InitializeStvAccounts, type InitializeStvParams$1 as InitializeStvParams, JLPD_PROGRAM_ID, type JLPVault, JLP_VAULT_ACCOUNT_SIZE, JLP_VAULT_DATA_SIZE, JLP_VAULT_DISCRIMINATOR, JUPITER_LEND_PROGRAM_ID$1 as JUPITER_LEND_PROGRAM_ID, JUPITER_SWAP_PROGRAM_ID, JUPUSD_POOL, JUPITER_LEND_PROGRAM_ID as JUP_LEND_PROGRAM_ID, JlpdClient, JlpdClientError, type JupEarnAccounts, type JupEarnDirection, type JupEarnParams$1 as JupEarnParams, type JupiterLendPool, type JupiterPriceData, type JupiterPriceResponse, type JupiterQuoteResponse, type JupiterSwapInstructionsResponse, LENDING_ADMIN, LIQUIDITY_PROGRAM_ID, LIQUIDITY_SINGLETON, type LendingAccountData, MINTS, type MoveDirection, type MoveJlxParams$1 as MoveJlxParams, type MoveStvAccounts, ORACLES, POOLS, PPS_DECIMALS, PoolContext, type PoolName, type RewardsRateModelData, SEED_JLP_VAULT, SEED_STV, type STV, STV_ACCOUNT_SIZE, STV_DATA_SIZE, STV_DISCRIMINATOR, STV_INDEX, type SerializedInstruction, type SettleYieldAccounts, type SettleYieldInstructionParams, type SettleYieldParams, SwapContext, type SwapDirection, type SwapJlxJlpAccounts, type SwapJlxJlpParams$1 as SwapJlxJlpParams, type SwapJlxJlxAccounts, type SwapJlxJlxParams$1 as SwapJlxJlxParams, type SwapQuote, USDC_POOL, type UpdateStvAccounts, type UpdateStvParams$1 as UpdateStvParams, type UpdateVaultParams, WBTC_POOL, WETH_POOL, WSOL_POOL, type WithdrawAccounts, type WithdrawParams, baseToJlx, baseToShares, buildExchangeRateAccounts, buildJupEarnDepositAccounts, buildJupEarnWithdrawAccounts, buildSwapData, calculateExchangeRate, calculateNav, calculatePps, clearAtaCache, clearPdaCache, createClaimFeesInstruction, createDepositInstruction, createInitOrUpdateVaultInstruction, createInitializeStvInstruction, createJupEarnInstruction, createMoveJlxInstruction, createSettleYieldInstruction, createSwapJlxJlpInstruction, createSwapJlxJlxInstruction, createUpdateStvInstruction, createWithdrawInstruction, deriveAta, deriveStvAtas, deriveStvPda, deriveUserAtas, deriveVaultAtas, deriveVaultPda, fetchAddressLookupTables, fetchJlpRate, fetchJupiterPriceUsd, getJupiterQuote, getJupiterSwapInstructions, getPoolByMint, getPoolByName, jlxToBase, parseLendingAccount, parseRewardsRateModel, parseStv, parseSwapRemainingAccounts, parseVault, sharesToBase };
|