@elmntl/jlpd-sdk 0.1.9 → 0.1.11
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/dist/index.d.mts +61 -204
- package/dist/index.d.ts +61 -204
- package/dist/index.js +50 -143
- package/dist/index.mjs +48 -142
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,10 +28,12 @@ __export(index_exports, {
|
|
|
28
28
|
FLAG_REBALANCE_DISABLED: () => FLAG_REBALANCE_DISABLED,
|
|
29
29
|
FLAG_WITHDRAWALS_DISABLED: () => FLAG_WITHDRAWALS_DISABLED,
|
|
30
30
|
JLPD_PROGRAM_ID: () => JLPD_PROGRAM_ID,
|
|
31
|
+
JLP_POOL_PUBKEY: () => JLP_POOL_PUBKEY,
|
|
31
32
|
JLP_VAULT_ACCOUNT_SIZE: () => JLP_VAULT_ACCOUNT_SIZE,
|
|
32
33
|
JLP_VAULT_DATA_SIZE: () => JLP_VAULT_DATA_SIZE,
|
|
33
34
|
JLP_VAULT_DISCRIMINATOR: () => JLP_VAULT_DISCRIMINATOR,
|
|
34
35
|
JUPITER_LEND_PROGRAM_ID: () => JUPITER_LEND_PROGRAM_ID,
|
|
36
|
+
JUPITER_PERPS_PROGRAM_ID: () => JUPITER_PERPS_PROGRAM_ID,
|
|
35
37
|
JUPITER_SWAP_PROGRAM_ID: () => JUPITER_SWAP_PROGRAM_ID,
|
|
36
38
|
JUPUSD_POOL: () => JUPUSD_POOL,
|
|
37
39
|
JUP_LEND_PROGRAM_ID: () => JUPITER_LEND_PROGRAM_ID2,
|
|
@@ -76,7 +78,6 @@ __export(index_exports, {
|
|
|
76
78
|
createProgram: () => createProgram,
|
|
77
79
|
createSettleYieldInstruction: () => createSettleYieldInstruction,
|
|
78
80
|
createSwapJlxJlpInstruction: () => createSwapJlxJlpInstruction,
|
|
79
|
-
createSwapJlxJlxInstruction: () => createSwapJlxJlxInstruction,
|
|
80
81
|
createUpdateStvInstruction: () => createUpdateStvInstruction,
|
|
81
82
|
createWithdrawInstruction: () => createWithdrawInstruction,
|
|
82
83
|
deriveAta: () => deriveAta,
|
|
@@ -902,17 +903,15 @@ var jlp_d_program_default = {
|
|
|
902
903
|
"2. Values total base_loaned across all STVs in USD",
|
|
903
904
|
"3. Distributes surplus (yield) or deficit (bad debt) proportionally",
|
|
904
905
|
"",
|
|
905
|
-
"# Parameters",
|
|
906
|
-
"- `jlp_rate`: Manager-provided JLP price (8 decimals), cross-checked against Pyth",
|
|
907
|
-
"",
|
|
908
906
|
"# Security",
|
|
909
907
|
"- BTC/ETH/SOL prices come from Doves oracles (manipulation-resistant)",
|
|
910
|
-
"- JLP price
|
|
908
|
+
"- JLP price computed directly from Jupiter Perps Pool account (aumUsd / jlp_supply)",
|
|
911
909
|
"- Exchange rates come from Jupiter Earn (audited, TWAP-based)",
|
|
912
910
|
"- Distribution is proportional to each STV's share of total loans",
|
|
913
911
|
"",
|
|
914
912
|
"# Accounts",
|
|
915
|
-
"Requires all 5 STVs, 5 staging jlX ATAs, 3 Doves oracles (BTC/ETH/SOL),
|
|
913
|
+
"Requires all 5 STVs, 5 staging jlX ATAs, 3 Doves oracles (BTC/ETH/SOL),",
|
|
914
|
+
"Jupiter Perps Pool account, JLP mint account",
|
|
916
915
|
"",
|
|
917
916
|
"# Remaining Accounts (15 accounts)",
|
|
918
917
|
"For exchange rate calculation with time-accrued rewards:",
|
|
@@ -986,7 +985,10 @@ var jlp_d_program_default = {
|
|
|
986
985
|
name: "doves_sol_usd"
|
|
987
986
|
},
|
|
988
987
|
{
|
|
989
|
-
name: "
|
|
988
|
+
name: "jlp_pool"
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
name: "jlp_mint_account"
|
|
990
992
|
},
|
|
991
993
|
{
|
|
992
994
|
name: "manager",
|
|
@@ -996,16 +998,7 @@ var jlp_d_program_default = {
|
|
|
996
998
|
signer: true
|
|
997
999
|
}
|
|
998
1000
|
],
|
|
999
|
-
args: [
|
|
1000
|
-
{
|
|
1001
|
-
name: "params",
|
|
1002
|
-
type: {
|
|
1003
|
-
defined: {
|
|
1004
|
-
name: "SettleYieldParams"
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
]
|
|
1001
|
+
args: []
|
|
1009
1002
|
},
|
|
1010
1003
|
{
|
|
1011
1004
|
name: "swap_jlx_to_from_jlp",
|
|
@@ -1705,8 +1698,8 @@ var jlp_d_program_default = {
|
|
|
1705
1698
|
},
|
|
1706
1699
|
{
|
|
1707
1700
|
code: 6043,
|
|
1708
|
-
name: "
|
|
1709
|
-
msg: "
|
|
1701
|
+
name: "JlpPriceOutOfRange",
|
|
1702
|
+
msg: "JLP price out of reasonable range ($0.50 - $50.00)"
|
|
1710
1703
|
},
|
|
1711
1704
|
{
|
|
1712
1705
|
code: 6044,
|
|
@@ -2571,25 +2564,6 @@ var jlp_d_program_default = {
|
|
|
2571
2564
|
]
|
|
2572
2565
|
}
|
|
2573
2566
|
},
|
|
2574
|
-
{
|
|
2575
|
-
name: "SettleYieldParams",
|
|
2576
|
-
docs: [
|
|
2577
|
-
"Parameters for settle_yield instruction"
|
|
2578
|
-
],
|
|
2579
|
-
type: {
|
|
2580
|
-
kind: "struct",
|
|
2581
|
-
fields: [
|
|
2582
|
-
{
|
|
2583
|
-
name: "jlp_rate",
|
|
2584
|
-
docs: [
|
|
2585
|
-
"Manager-provided JLP rate (8 decimals, e.g., 450000000 = $4.50)",
|
|
2586
|
-
"Cross-checked against Pyth oracle, must be within 50 bps tolerance"
|
|
2587
|
-
],
|
|
2588
|
-
type: "u64"
|
|
2589
|
-
}
|
|
2590
|
-
]
|
|
2591
|
-
}
|
|
2592
|
-
},
|
|
2593
2567
|
{
|
|
2594
2568
|
name: "SettleYieldSkipped",
|
|
2595
2569
|
docs: [
|
|
@@ -2869,6 +2843,33 @@ var jlp_d_program_default = {
|
|
|
2869
2843
|
type: {
|
|
2870
2844
|
option: "pubkey"
|
|
2871
2845
|
}
|
|
2846
|
+
},
|
|
2847
|
+
{
|
|
2848
|
+
name: "pps",
|
|
2849
|
+
docs: [
|
|
2850
|
+
"Override price per share (9 decimals, e.g. 1_000_000_000 = 1.0)"
|
|
2851
|
+
],
|
|
2852
|
+
type: {
|
|
2853
|
+
option: "u64"
|
|
2854
|
+
}
|
|
2855
|
+
},
|
|
2856
|
+
{
|
|
2857
|
+
name: "hwm",
|
|
2858
|
+
docs: [
|
|
2859
|
+
"Override high water mark (9 decimals)"
|
|
2860
|
+
],
|
|
2861
|
+
type: {
|
|
2862
|
+
option: "u64"
|
|
2863
|
+
}
|
|
2864
|
+
},
|
|
2865
|
+
{
|
|
2866
|
+
name: "base_loaned",
|
|
2867
|
+
docs: [
|
|
2868
|
+
"Override base_loaned accounting field"
|
|
2869
|
+
],
|
|
2870
|
+
type: {
|
|
2871
|
+
option: "u64"
|
|
2872
|
+
}
|
|
2872
2873
|
}
|
|
2873
2874
|
]
|
|
2874
2875
|
}
|
|
@@ -2961,10 +2962,10 @@ var ORACLES = {
|
|
|
2961
2962
|
// Doves oracles (Jupiter Perps oracle system)
|
|
2962
2963
|
DOVES_BTC_USD: new import_web32.PublicKey("4HBbPx9QJdjJ7GUe6bsiJjGybvfpDhQMMPXP1UEa7VT5"),
|
|
2963
2964
|
DOVES_ETH_USD: new import_web32.PublicKey("5URYohbPy32nxK1t3jAHVNfdWY2xTubHiFvLrE3VhXEp"),
|
|
2964
|
-
DOVES_SOL_USD: new import_web32.PublicKey("39cWjvHrpHNz2SbXv6ME4NPhqBDBd4KsjUYv5JkHEAJU")
|
|
2965
|
-
// Pyth oracle for JLP price
|
|
2966
|
-
PYTH_JLP_USD: new import_web32.PublicKey("2TTGSRSezqFzeLUH8JwRUbtN66XLLaymfYsWRTMjfiMw")
|
|
2965
|
+
DOVES_SOL_USD: new import_web32.PublicKey("39cWjvHrpHNz2SbXv6ME4NPhqBDBd4KsjUYv5JkHEAJU")
|
|
2967
2966
|
};
|
|
2967
|
+
var JLP_POOL_PUBKEY = new import_web32.PublicKey("5BUwFW4nRbftYTDMbgxykoFWqWHPzahFSNAaaaJtVKsq");
|
|
2968
|
+
var JUPITER_PERPS_PROGRAM_ID = new import_web32.PublicKey("PERPHjGBqRHArX4DySjwM6UJHiR3sWAatqfdBS2qQJu");
|
|
2968
2969
|
|
|
2969
2970
|
// src/accounts/pdas.ts
|
|
2970
2971
|
var import_web33 = require("@solana/web3.js");
|
|
@@ -3737,24 +3738,6 @@ async function createMoveJlxInstruction(program, params, accounts, remainingAcco
|
|
|
3737
3738
|
tokenProgram: accounts.tokenProgram
|
|
3738
3739
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3739
3740
|
}
|
|
3740
|
-
async function createSwapJlxJlxInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3741
|
-
return await program.methods.swapJlxJlx({
|
|
3742
|
-
fromIndex: params.fromIndex,
|
|
3743
|
-
toIndex: params.toIndex,
|
|
3744
|
-
amountIn: params.amountIn,
|
|
3745
|
-
minOut: params.minOut,
|
|
3746
|
-
jupiterData: params.jupiterData
|
|
3747
|
-
}).accounts({
|
|
3748
|
-
manager: accounts.manager,
|
|
3749
|
-
jlpVault: accounts.jlpVault,
|
|
3750
|
-
fromJlxMint: accounts.fromJlxMint,
|
|
3751
|
-
toJlxMint: accounts.toJlxMint,
|
|
3752
|
-
fromJlxAta: accounts.fromJlxAta,
|
|
3753
|
-
toJlxAta: accounts.toJlxAta,
|
|
3754
|
-
tokenProgram: accounts.tokenProgram,
|
|
3755
|
-
jupiterProgram: accounts.jupiterProgram
|
|
3756
|
-
}).remainingAccounts(remainingAccounts).instruction();
|
|
3757
|
-
}
|
|
3758
3741
|
async function createSwapJlxJlpInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3759
3742
|
return await program.methods.swapJlxToFromJlp({
|
|
3760
3743
|
stvIndex: params.stvIndex,
|
|
@@ -3773,9 +3756,7 @@ async function createSwapJlxJlpInstruction(program, params, accounts, remainingA
|
|
|
3773
3756
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3774
3757
|
}
|
|
3775
3758
|
async function createSettleYieldInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3776
|
-
return await program.methods.settleYield({
|
|
3777
|
-
jlpRate: params.jlpRate
|
|
3778
|
-
}).accounts({
|
|
3759
|
+
return await program.methods.settleYield().accounts({
|
|
3779
3760
|
jlpVault: accounts.jlpVault,
|
|
3780
3761
|
vaultJlpAta: accounts.vaultJlpAta,
|
|
3781
3762
|
stv0: accounts.stvBtc,
|
|
@@ -3791,7 +3772,8 @@ async function createSettleYieldInstruction(program, params, accounts, remaining
|
|
|
3791
3772
|
dovesBtcUsd: accounts.oracleBtc,
|
|
3792
3773
|
dovesEthUsd: accounts.oracleEth,
|
|
3793
3774
|
dovesSolUsd: accounts.oracleSol,
|
|
3794
|
-
|
|
3775
|
+
jlpPool: accounts.jlpPool,
|
|
3776
|
+
jlpMintAccount: accounts.jlpMintAccount,
|
|
3795
3777
|
manager: accounts.manager
|
|
3796
3778
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3797
3779
|
}
|
|
@@ -4284,83 +4266,6 @@ var SwapContext = class {
|
|
|
4284
4266
|
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4285
4267
|
return new import_web39.VersionedTransaction(message);
|
|
4286
4268
|
}
|
|
4287
|
-
// Get a quote for jlX <-> jlX swap
|
|
4288
|
-
async quoteJlxJlx(params) {
|
|
4289
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4290
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4291
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4292
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4293
|
-
const inputMint = fromPoolConfig.fTokenMint;
|
|
4294
|
-
const outputMint = toPoolConfig.fTokenMint;
|
|
4295
|
-
const quote = await getJupiterQuote(
|
|
4296
|
-
inputMint,
|
|
4297
|
-
outputMint,
|
|
4298
|
-
BigInt(params.amountIn.toString()),
|
|
4299
|
-
params.slippageBps ?? 30,
|
|
4300
|
-
40,
|
|
4301
|
-
this.client.jupiterApiKey
|
|
4302
|
-
);
|
|
4303
|
-
const swapIxs = await getJupiterSwapInstructions(quote, this.client.vaultPda, this.client.jupiterApiKey);
|
|
4304
|
-
const remainingAccounts = parseSwapRemainingAccounts(swapIxs.swapInstruction);
|
|
4305
|
-
const alts = await fetchAddressLookupTables(
|
|
4306
|
-
this.client.connection,
|
|
4307
|
-
swapIxs.addressLookupTableAddresses
|
|
4308
|
-
);
|
|
4309
|
-
return {
|
|
4310
|
-
inputMint,
|
|
4311
|
-
outputMint,
|
|
4312
|
-
inAmount: new import_anchor6.BN(quote.inAmount),
|
|
4313
|
-
outAmount: new import_anchor6.BN(quote.outAmount),
|
|
4314
|
-
minOutAmount: new import_anchor6.BN(quote.otherAmountThreshold),
|
|
4315
|
-
priceImpactPct: parseFloat(quote.priceImpactPct),
|
|
4316
|
-
route: quote.routePlan.map((r) => r.swapInfo.label || "unknown"),
|
|
4317
|
-
jupiterData: Buffer.from(swapIxs.swapInstruction.data, "base64"),
|
|
4318
|
-
remainingAccounts,
|
|
4319
|
-
addressLookupTables: alts,
|
|
4320
|
-
computeUnitLimit: swapIxs.computeUnitLimit ?? 6e5
|
|
4321
|
-
};
|
|
4322
|
-
}
|
|
4323
|
-
// Build jlX <-> jlX swap transaction
|
|
4324
|
-
async swapJlxJlx(params) {
|
|
4325
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4326
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4327
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4328
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4329
|
-
const fromPoolCtx = this.client.pool(params.fromPool);
|
|
4330
|
-
const toPoolCtx = this.client.pool(params.toPool);
|
|
4331
|
-
const computeIx = import_web39.ComputeBudgetProgram.setComputeUnitLimit({
|
|
4332
|
-
units: params.quote.computeUnitLimit
|
|
4333
|
-
});
|
|
4334
|
-
const jupiterProgram = JUPITER_SWAP_PROGRAM_ID;
|
|
4335
|
-
const swapIx = await createSwapJlxJlxInstruction(
|
|
4336
|
-
this.client.program,
|
|
4337
|
-
{
|
|
4338
|
-
fromIndex: fromPoolConfig.stvIndex,
|
|
4339
|
-
toIndex: toPoolConfig.stvIndex,
|
|
4340
|
-
amountIn: params.amountIn,
|
|
4341
|
-
minOut: params.minOut,
|
|
4342
|
-
jupiterData: params.quote.jupiterData
|
|
4343
|
-
},
|
|
4344
|
-
{
|
|
4345
|
-
manager: params.manager,
|
|
4346
|
-
jlpVault: this.client.vaultPda,
|
|
4347
|
-
fromJlxMint: fromPoolConfig.fTokenMint,
|
|
4348
|
-
toJlxMint: toPoolConfig.fTokenMint,
|
|
4349
|
-
fromJlxAta: fromPoolCtx.vaultStagingAta,
|
|
4350
|
-
toJlxAta: toPoolCtx.vaultStagingAta,
|
|
4351
|
-
tokenProgram: import_spl_token5.TOKEN_PROGRAM_ID,
|
|
4352
|
-
jupiterProgram
|
|
4353
|
-
},
|
|
4354
|
-
params.quote.remainingAccounts
|
|
4355
|
-
);
|
|
4356
|
-
const { blockhash } = await this.client.connection.getLatestBlockhash("confirmed");
|
|
4357
|
-
const message = new import_web39.TransactionMessage({
|
|
4358
|
-
payerKey: params.manager,
|
|
4359
|
-
recentBlockhash: blockhash,
|
|
4360
|
-
instructions: [computeIx, swapIx]
|
|
4361
|
-
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4362
|
-
return new import_web39.VersionedTransaction(message);
|
|
4363
|
-
}
|
|
4364
4269
|
};
|
|
4365
4270
|
var AdminContext = class {
|
|
4366
4271
|
constructor(client) {
|
|
@@ -4441,7 +4346,7 @@ var AdminContext = class {
|
|
|
4441
4346
|
const remainingAccounts = [...lendingAccounts, ...rewardsAccounts, ...mintAccounts];
|
|
4442
4347
|
const ix = await createSettleYieldInstruction(
|
|
4443
4348
|
this.client.program,
|
|
4444
|
-
{
|
|
4349
|
+
{},
|
|
4445
4350
|
{
|
|
4446
4351
|
manager: params.manager,
|
|
4447
4352
|
jlpVault: this.client.vaultPda,
|
|
@@ -4460,7 +4365,8 @@ var AdminContext = class {
|
|
|
4460
4365
|
oracleBtc: ORACLES.DOVES_BTC_USD,
|
|
4461
4366
|
oracleEth: ORACLES.DOVES_ETH_USD,
|
|
4462
4367
|
oracleSol: ORACLES.DOVES_SOL_USD,
|
|
4463
|
-
|
|
4368
|
+
jlpPool: JLP_POOL_PUBKEY,
|
|
4369
|
+
jlpMintAccount: MINTS.JLP
|
|
4464
4370
|
},
|
|
4465
4371
|
remainingAccounts
|
|
4466
4372
|
);
|
|
@@ -4477,10 +4383,12 @@ var AdminContext = class {
|
|
|
4477
4383
|
FLAG_REBALANCE_DISABLED,
|
|
4478
4384
|
FLAG_WITHDRAWALS_DISABLED,
|
|
4479
4385
|
JLPD_PROGRAM_ID,
|
|
4386
|
+
JLP_POOL_PUBKEY,
|
|
4480
4387
|
JLP_VAULT_ACCOUNT_SIZE,
|
|
4481
4388
|
JLP_VAULT_DATA_SIZE,
|
|
4482
4389
|
JLP_VAULT_DISCRIMINATOR,
|
|
4483
4390
|
JUPITER_LEND_PROGRAM_ID,
|
|
4391
|
+
JUPITER_PERPS_PROGRAM_ID,
|
|
4484
4392
|
JUPITER_SWAP_PROGRAM_ID,
|
|
4485
4393
|
JUPUSD_POOL,
|
|
4486
4394
|
JUP_LEND_PROGRAM_ID,
|
|
@@ -4525,7 +4433,6 @@ var AdminContext = class {
|
|
|
4525
4433
|
createProgram,
|
|
4526
4434
|
createSettleYieldInstruction,
|
|
4527
4435
|
createSwapJlxJlpInstruction,
|
|
4528
|
-
createSwapJlxJlxInstruction,
|
|
4529
4436
|
createUpdateStvInstruction,
|
|
4530
4437
|
createWithdrawInstruction,
|
|
4531
4438
|
deriveAta,
|
package/dist/index.mjs
CHANGED
|
@@ -806,17 +806,15 @@ var jlp_d_program_default = {
|
|
|
806
806
|
"2. Values total base_loaned across all STVs in USD",
|
|
807
807
|
"3. Distributes surplus (yield) or deficit (bad debt) proportionally",
|
|
808
808
|
"",
|
|
809
|
-
"# Parameters",
|
|
810
|
-
"- `jlp_rate`: Manager-provided JLP price (8 decimals), cross-checked against Pyth",
|
|
811
|
-
"",
|
|
812
809
|
"# Security",
|
|
813
810
|
"- BTC/ETH/SOL prices come from Doves oracles (manipulation-resistant)",
|
|
814
|
-
"- JLP price
|
|
811
|
+
"- JLP price computed directly from Jupiter Perps Pool account (aumUsd / jlp_supply)",
|
|
815
812
|
"- Exchange rates come from Jupiter Earn (audited, TWAP-based)",
|
|
816
813
|
"- Distribution is proportional to each STV's share of total loans",
|
|
817
814
|
"",
|
|
818
815
|
"# Accounts",
|
|
819
|
-
"Requires all 5 STVs, 5 staging jlX ATAs, 3 Doves oracles (BTC/ETH/SOL),
|
|
816
|
+
"Requires all 5 STVs, 5 staging jlX ATAs, 3 Doves oracles (BTC/ETH/SOL),",
|
|
817
|
+
"Jupiter Perps Pool account, JLP mint account",
|
|
820
818
|
"",
|
|
821
819
|
"# Remaining Accounts (15 accounts)",
|
|
822
820
|
"For exchange rate calculation with time-accrued rewards:",
|
|
@@ -890,7 +888,10 @@ var jlp_d_program_default = {
|
|
|
890
888
|
name: "doves_sol_usd"
|
|
891
889
|
},
|
|
892
890
|
{
|
|
893
|
-
name: "
|
|
891
|
+
name: "jlp_pool"
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
name: "jlp_mint_account"
|
|
894
895
|
},
|
|
895
896
|
{
|
|
896
897
|
name: "manager",
|
|
@@ -900,16 +901,7 @@ var jlp_d_program_default = {
|
|
|
900
901
|
signer: true
|
|
901
902
|
}
|
|
902
903
|
],
|
|
903
|
-
args: [
|
|
904
|
-
{
|
|
905
|
-
name: "params",
|
|
906
|
-
type: {
|
|
907
|
-
defined: {
|
|
908
|
-
name: "SettleYieldParams"
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
]
|
|
904
|
+
args: []
|
|
913
905
|
},
|
|
914
906
|
{
|
|
915
907
|
name: "swap_jlx_to_from_jlp",
|
|
@@ -1609,8 +1601,8 @@ var jlp_d_program_default = {
|
|
|
1609
1601
|
},
|
|
1610
1602
|
{
|
|
1611
1603
|
code: 6043,
|
|
1612
|
-
name: "
|
|
1613
|
-
msg: "
|
|
1604
|
+
name: "JlpPriceOutOfRange",
|
|
1605
|
+
msg: "JLP price out of reasonable range ($0.50 - $50.00)"
|
|
1614
1606
|
},
|
|
1615
1607
|
{
|
|
1616
1608
|
code: 6044,
|
|
@@ -2475,25 +2467,6 @@ var jlp_d_program_default = {
|
|
|
2475
2467
|
]
|
|
2476
2468
|
}
|
|
2477
2469
|
},
|
|
2478
|
-
{
|
|
2479
|
-
name: "SettleYieldParams",
|
|
2480
|
-
docs: [
|
|
2481
|
-
"Parameters for settle_yield instruction"
|
|
2482
|
-
],
|
|
2483
|
-
type: {
|
|
2484
|
-
kind: "struct",
|
|
2485
|
-
fields: [
|
|
2486
|
-
{
|
|
2487
|
-
name: "jlp_rate",
|
|
2488
|
-
docs: [
|
|
2489
|
-
"Manager-provided JLP rate (8 decimals, e.g., 450000000 = $4.50)",
|
|
2490
|
-
"Cross-checked against Pyth oracle, must be within 50 bps tolerance"
|
|
2491
|
-
],
|
|
2492
|
-
type: "u64"
|
|
2493
|
-
}
|
|
2494
|
-
]
|
|
2495
|
-
}
|
|
2496
|
-
},
|
|
2497
2470
|
{
|
|
2498
2471
|
name: "SettleYieldSkipped",
|
|
2499
2472
|
docs: [
|
|
@@ -2773,6 +2746,33 @@ var jlp_d_program_default = {
|
|
|
2773
2746
|
type: {
|
|
2774
2747
|
option: "pubkey"
|
|
2775
2748
|
}
|
|
2749
|
+
},
|
|
2750
|
+
{
|
|
2751
|
+
name: "pps",
|
|
2752
|
+
docs: [
|
|
2753
|
+
"Override price per share (9 decimals, e.g. 1_000_000_000 = 1.0)"
|
|
2754
|
+
],
|
|
2755
|
+
type: {
|
|
2756
|
+
option: "u64"
|
|
2757
|
+
}
|
|
2758
|
+
},
|
|
2759
|
+
{
|
|
2760
|
+
name: "hwm",
|
|
2761
|
+
docs: [
|
|
2762
|
+
"Override high water mark (9 decimals)"
|
|
2763
|
+
],
|
|
2764
|
+
type: {
|
|
2765
|
+
option: "u64"
|
|
2766
|
+
}
|
|
2767
|
+
},
|
|
2768
|
+
{
|
|
2769
|
+
name: "base_loaned",
|
|
2770
|
+
docs: [
|
|
2771
|
+
"Override base_loaned accounting field"
|
|
2772
|
+
],
|
|
2773
|
+
type: {
|
|
2774
|
+
option: "u64"
|
|
2775
|
+
}
|
|
2776
2776
|
}
|
|
2777
2777
|
]
|
|
2778
2778
|
}
|
|
@@ -2865,10 +2865,10 @@ var ORACLES = {
|
|
|
2865
2865
|
// Doves oracles (Jupiter Perps oracle system)
|
|
2866
2866
|
DOVES_BTC_USD: new PublicKey("4HBbPx9QJdjJ7GUe6bsiJjGybvfpDhQMMPXP1UEa7VT5"),
|
|
2867
2867
|
DOVES_ETH_USD: new PublicKey("5URYohbPy32nxK1t3jAHVNfdWY2xTubHiFvLrE3VhXEp"),
|
|
2868
|
-
DOVES_SOL_USD: new PublicKey("39cWjvHrpHNz2SbXv6ME4NPhqBDBd4KsjUYv5JkHEAJU")
|
|
2869
|
-
// Pyth oracle for JLP price
|
|
2870
|
-
PYTH_JLP_USD: new PublicKey("2TTGSRSezqFzeLUH8JwRUbtN66XLLaymfYsWRTMjfiMw")
|
|
2868
|
+
DOVES_SOL_USD: new PublicKey("39cWjvHrpHNz2SbXv6ME4NPhqBDBd4KsjUYv5JkHEAJU")
|
|
2871
2869
|
};
|
|
2870
|
+
var JLP_POOL_PUBKEY = new PublicKey("5BUwFW4nRbftYTDMbgxykoFWqWHPzahFSNAaaaJtVKsq");
|
|
2871
|
+
var JUPITER_PERPS_PROGRAM_ID = new PublicKey("PERPHjGBqRHArX4DySjwM6UJHiR3sWAatqfdBS2qQJu");
|
|
2872
2872
|
|
|
2873
2873
|
// src/accounts/pdas.ts
|
|
2874
2874
|
import { PublicKey as PublicKey2 } from "@solana/web3.js";
|
|
@@ -3644,24 +3644,6 @@ async function createMoveJlxInstruction(program, params, accounts, remainingAcco
|
|
|
3644
3644
|
tokenProgram: accounts.tokenProgram
|
|
3645
3645
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3646
3646
|
}
|
|
3647
|
-
async function createSwapJlxJlxInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3648
|
-
return await program.methods.swapJlxJlx({
|
|
3649
|
-
fromIndex: params.fromIndex,
|
|
3650
|
-
toIndex: params.toIndex,
|
|
3651
|
-
amountIn: params.amountIn,
|
|
3652
|
-
minOut: params.minOut,
|
|
3653
|
-
jupiterData: params.jupiterData
|
|
3654
|
-
}).accounts({
|
|
3655
|
-
manager: accounts.manager,
|
|
3656
|
-
jlpVault: accounts.jlpVault,
|
|
3657
|
-
fromJlxMint: accounts.fromJlxMint,
|
|
3658
|
-
toJlxMint: accounts.toJlxMint,
|
|
3659
|
-
fromJlxAta: accounts.fromJlxAta,
|
|
3660
|
-
toJlxAta: accounts.toJlxAta,
|
|
3661
|
-
tokenProgram: accounts.tokenProgram,
|
|
3662
|
-
jupiterProgram: accounts.jupiterProgram
|
|
3663
|
-
}).remainingAccounts(remainingAccounts).instruction();
|
|
3664
|
-
}
|
|
3665
3647
|
async function createSwapJlxJlpInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3666
3648
|
return await program.methods.swapJlxToFromJlp({
|
|
3667
3649
|
stvIndex: params.stvIndex,
|
|
@@ -3680,9 +3662,7 @@ async function createSwapJlxJlpInstruction(program, params, accounts, remainingA
|
|
|
3680
3662
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3681
3663
|
}
|
|
3682
3664
|
async function createSettleYieldInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3683
|
-
return await program.methods.settleYield({
|
|
3684
|
-
jlpRate: params.jlpRate
|
|
3685
|
-
}).accounts({
|
|
3665
|
+
return await program.methods.settleYield().accounts({
|
|
3686
3666
|
jlpVault: accounts.jlpVault,
|
|
3687
3667
|
vaultJlpAta: accounts.vaultJlpAta,
|
|
3688
3668
|
stv0: accounts.stvBtc,
|
|
@@ -3698,7 +3678,8 @@ async function createSettleYieldInstruction(program, params, accounts, remaining
|
|
|
3698
3678
|
dovesBtcUsd: accounts.oracleBtc,
|
|
3699
3679
|
dovesEthUsd: accounts.oracleEth,
|
|
3700
3680
|
dovesSolUsd: accounts.oracleSol,
|
|
3701
|
-
|
|
3681
|
+
jlpPool: accounts.jlpPool,
|
|
3682
|
+
jlpMintAccount: accounts.jlpMintAccount,
|
|
3702
3683
|
manager: accounts.manager
|
|
3703
3684
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3704
3685
|
}
|
|
@@ -4191,83 +4172,6 @@ var SwapContext = class {
|
|
|
4191
4172
|
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4192
4173
|
return new VersionedTransaction(message);
|
|
4193
4174
|
}
|
|
4194
|
-
// Get a quote for jlX <-> jlX swap
|
|
4195
|
-
async quoteJlxJlx(params) {
|
|
4196
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4197
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4198
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4199
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4200
|
-
const inputMint = fromPoolConfig.fTokenMint;
|
|
4201
|
-
const outputMint = toPoolConfig.fTokenMint;
|
|
4202
|
-
const quote = await getJupiterQuote(
|
|
4203
|
-
inputMint,
|
|
4204
|
-
outputMint,
|
|
4205
|
-
BigInt(params.amountIn.toString()),
|
|
4206
|
-
params.slippageBps ?? 30,
|
|
4207
|
-
40,
|
|
4208
|
-
this.client.jupiterApiKey
|
|
4209
|
-
);
|
|
4210
|
-
const swapIxs = await getJupiterSwapInstructions(quote, this.client.vaultPda, this.client.jupiterApiKey);
|
|
4211
|
-
const remainingAccounts = parseSwapRemainingAccounts(swapIxs.swapInstruction);
|
|
4212
|
-
const alts = await fetchAddressLookupTables(
|
|
4213
|
-
this.client.connection,
|
|
4214
|
-
swapIxs.addressLookupTableAddresses
|
|
4215
|
-
);
|
|
4216
|
-
return {
|
|
4217
|
-
inputMint,
|
|
4218
|
-
outputMint,
|
|
4219
|
-
inAmount: new BN5(quote.inAmount),
|
|
4220
|
-
outAmount: new BN5(quote.outAmount),
|
|
4221
|
-
minOutAmount: new BN5(quote.otherAmountThreshold),
|
|
4222
|
-
priceImpactPct: parseFloat(quote.priceImpactPct),
|
|
4223
|
-
route: quote.routePlan.map((r) => r.swapInfo.label || "unknown"),
|
|
4224
|
-
jupiterData: Buffer.from(swapIxs.swapInstruction.data, "base64"),
|
|
4225
|
-
remainingAccounts,
|
|
4226
|
-
addressLookupTables: alts,
|
|
4227
|
-
computeUnitLimit: swapIxs.computeUnitLimit ?? 6e5
|
|
4228
|
-
};
|
|
4229
|
-
}
|
|
4230
|
-
// Build jlX <-> jlX swap transaction
|
|
4231
|
-
async swapJlxJlx(params) {
|
|
4232
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4233
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4234
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4235
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4236
|
-
const fromPoolCtx = this.client.pool(params.fromPool);
|
|
4237
|
-
const toPoolCtx = this.client.pool(params.toPool);
|
|
4238
|
-
const computeIx = ComputeBudgetProgram.setComputeUnitLimit({
|
|
4239
|
-
units: params.quote.computeUnitLimit
|
|
4240
|
-
});
|
|
4241
|
-
const jupiterProgram = JUPITER_SWAP_PROGRAM_ID;
|
|
4242
|
-
const swapIx = await createSwapJlxJlxInstruction(
|
|
4243
|
-
this.client.program,
|
|
4244
|
-
{
|
|
4245
|
-
fromIndex: fromPoolConfig.stvIndex,
|
|
4246
|
-
toIndex: toPoolConfig.stvIndex,
|
|
4247
|
-
amountIn: params.amountIn,
|
|
4248
|
-
minOut: params.minOut,
|
|
4249
|
-
jupiterData: params.quote.jupiterData
|
|
4250
|
-
},
|
|
4251
|
-
{
|
|
4252
|
-
manager: params.manager,
|
|
4253
|
-
jlpVault: this.client.vaultPda,
|
|
4254
|
-
fromJlxMint: fromPoolConfig.fTokenMint,
|
|
4255
|
-
toJlxMint: toPoolConfig.fTokenMint,
|
|
4256
|
-
fromJlxAta: fromPoolCtx.vaultStagingAta,
|
|
4257
|
-
toJlxAta: toPoolCtx.vaultStagingAta,
|
|
4258
|
-
tokenProgram: TOKEN_PROGRAM_ID2,
|
|
4259
|
-
jupiterProgram
|
|
4260
|
-
},
|
|
4261
|
-
params.quote.remainingAccounts
|
|
4262
|
-
);
|
|
4263
|
-
const { blockhash } = await this.client.connection.getLatestBlockhash("confirmed");
|
|
4264
|
-
const message = new TransactionMessage({
|
|
4265
|
-
payerKey: params.manager,
|
|
4266
|
-
recentBlockhash: blockhash,
|
|
4267
|
-
instructions: [computeIx, swapIx]
|
|
4268
|
-
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4269
|
-
return new VersionedTransaction(message);
|
|
4270
|
-
}
|
|
4271
4175
|
};
|
|
4272
4176
|
var AdminContext = class {
|
|
4273
4177
|
constructor(client) {
|
|
@@ -4348,7 +4252,7 @@ var AdminContext = class {
|
|
|
4348
4252
|
const remainingAccounts = [...lendingAccounts, ...rewardsAccounts, ...mintAccounts];
|
|
4349
4253
|
const ix = await createSettleYieldInstruction(
|
|
4350
4254
|
this.client.program,
|
|
4351
|
-
{
|
|
4255
|
+
{},
|
|
4352
4256
|
{
|
|
4353
4257
|
manager: params.manager,
|
|
4354
4258
|
jlpVault: this.client.vaultPda,
|
|
@@ -4367,7 +4271,8 @@ var AdminContext = class {
|
|
|
4367
4271
|
oracleBtc: ORACLES.DOVES_BTC_USD,
|
|
4368
4272
|
oracleEth: ORACLES.DOVES_ETH_USD,
|
|
4369
4273
|
oracleSol: ORACLES.DOVES_SOL_USD,
|
|
4370
|
-
|
|
4274
|
+
jlpPool: JLP_POOL_PUBKEY,
|
|
4275
|
+
jlpMintAccount: MINTS.JLP
|
|
4371
4276
|
},
|
|
4372
4277
|
remainingAccounts
|
|
4373
4278
|
);
|
|
@@ -4383,10 +4288,12 @@ export {
|
|
|
4383
4288
|
FLAG_REBALANCE_DISABLED,
|
|
4384
4289
|
FLAG_WITHDRAWALS_DISABLED,
|
|
4385
4290
|
JLPD_PROGRAM_ID,
|
|
4291
|
+
JLP_POOL_PUBKEY,
|
|
4386
4292
|
JLP_VAULT_ACCOUNT_SIZE,
|
|
4387
4293
|
JLP_VAULT_DATA_SIZE,
|
|
4388
4294
|
JLP_VAULT_DISCRIMINATOR,
|
|
4389
4295
|
JUPITER_LEND_PROGRAM_ID,
|
|
4296
|
+
JUPITER_PERPS_PROGRAM_ID,
|
|
4390
4297
|
JUPITER_SWAP_PROGRAM_ID,
|
|
4391
4298
|
JUPUSD_POOL,
|
|
4392
4299
|
JUPITER_LEND_PROGRAM_ID2 as JUP_LEND_PROGRAM_ID,
|
|
@@ -4431,7 +4338,6 @@ export {
|
|
|
4431
4338
|
createProgram,
|
|
4432
4339
|
createSettleYieldInstruction,
|
|
4433
4340
|
createSwapJlxJlpInstruction,
|
|
4434
|
-
createSwapJlxJlxInstruction,
|
|
4435
4341
|
createUpdateStvInstruction,
|
|
4436
4342
|
createWithdrawInstruction,
|
|
4437
4343
|
deriveAta,
|