@elmntl/jlpd-sdk 0.1.8 → 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 +67 -204
- package/dist/index.d.ts +67 -204
- package/dist/index.js +58 -146
- package/dist/index.mjs +56 -145
- 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");
|
|
@@ -3655,7 +3656,10 @@ async function createUpdateStvInstruction(program, params, accounts) {
|
|
|
3655
3656
|
flags: params.flags,
|
|
3656
3657
|
maxDeposit: params.maxDeposit,
|
|
3657
3658
|
minDeposit: params.minDeposit,
|
|
3658
|
-
jlMint: params.jlMint
|
|
3659
|
+
jlMint: params.jlMint,
|
|
3660
|
+
pps: params.pps,
|
|
3661
|
+
hwm: params.hwm,
|
|
3662
|
+
baseLoaned: params.baseLoaned
|
|
3659
3663
|
}).accounts({
|
|
3660
3664
|
admin: accounts.admin,
|
|
3661
3665
|
jlpVault: accounts.jlpVault,
|
|
@@ -3734,24 +3738,6 @@ async function createMoveJlxInstruction(program, params, accounts, remainingAcco
|
|
|
3734
3738
|
tokenProgram: accounts.tokenProgram
|
|
3735
3739
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3736
3740
|
}
|
|
3737
|
-
async function createSwapJlxJlxInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3738
|
-
return await program.methods.swapJlxJlx({
|
|
3739
|
-
fromIndex: params.fromIndex,
|
|
3740
|
-
toIndex: params.toIndex,
|
|
3741
|
-
amountIn: params.amountIn,
|
|
3742
|
-
minOut: params.minOut,
|
|
3743
|
-
jupiterData: params.jupiterData
|
|
3744
|
-
}).accounts({
|
|
3745
|
-
manager: accounts.manager,
|
|
3746
|
-
jlpVault: accounts.jlpVault,
|
|
3747
|
-
fromJlxMint: accounts.fromJlxMint,
|
|
3748
|
-
toJlxMint: accounts.toJlxMint,
|
|
3749
|
-
fromJlxAta: accounts.fromJlxAta,
|
|
3750
|
-
toJlxAta: accounts.toJlxAta,
|
|
3751
|
-
tokenProgram: accounts.tokenProgram,
|
|
3752
|
-
jupiterProgram: accounts.jupiterProgram
|
|
3753
|
-
}).remainingAccounts(remainingAccounts).instruction();
|
|
3754
|
-
}
|
|
3755
3741
|
async function createSwapJlxJlpInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3756
3742
|
return await program.methods.swapJlxToFromJlp({
|
|
3757
3743
|
stvIndex: params.stvIndex,
|
|
@@ -3770,9 +3756,7 @@ async function createSwapJlxJlpInstruction(program, params, accounts, remainingA
|
|
|
3770
3756
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3771
3757
|
}
|
|
3772
3758
|
async function createSettleYieldInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3773
|
-
return await program.methods.settleYield({
|
|
3774
|
-
jlpRate: params.jlpRate
|
|
3775
|
-
}).accounts({
|
|
3759
|
+
return await program.methods.settleYield().accounts({
|
|
3776
3760
|
jlpVault: accounts.jlpVault,
|
|
3777
3761
|
vaultJlpAta: accounts.vaultJlpAta,
|
|
3778
3762
|
stv0: accounts.stvBtc,
|
|
@@ -3788,7 +3772,8 @@ async function createSettleYieldInstruction(program, params, accounts, remaining
|
|
|
3788
3772
|
dovesBtcUsd: accounts.oracleBtc,
|
|
3789
3773
|
dovesEthUsd: accounts.oracleEth,
|
|
3790
3774
|
dovesSolUsd: accounts.oracleSol,
|
|
3791
|
-
|
|
3775
|
+
jlpPool: accounts.jlpPool,
|
|
3776
|
+
jlpMintAccount: accounts.jlpMintAccount,
|
|
3792
3777
|
manager: accounts.manager
|
|
3793
3778
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3794
3779
|
}
|
|
@@ -4191,8 +4176,10 @@ var PoolContext = class {
|
|
|
4191
4176
|
flags: params.flags ?? stv.flags,
|
|
4192
4177
|
maxDeposit: params.maxDeposit ?? stv.maxDeposit,
|
|
4193
4178
|
minDeposit: params.minDeposit ?? stv.minDeposit,
|
|
4194
|
-
jlMint: params.jlMint ?? null
|
|
4195
|
-
|
|
4179
|
+
jlMint: params.jlMint ?? null,
|
|
4180
|
+
pps: params.pps ?? null,
|
|
4181
|
+
hwm: params.hwm ?? null,
|
|
4182
|
+
baseLoaned: params.baseLoaned ?? null
|
|
4196
4183
|
},
|
|
4197
4184
|
{
|
|
4198
4185
|
admin: params.admin,
|
|
@@ -4279,83 +4266,6 @@ var SwapContext = class {
|
|
|
4279
4266
|
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4280
4267
|
return new import_web39.VersionedTransaction(message);
|
|
4281
4268
|
}
|
|
4282
|
-
// Get a quote for jlX <-> jlX swap
|
|
4283
|
-
async quoteJlxJlx(params) {
|
|
4284
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4285
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4286
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4287
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4288
|
-
const inputMint = fromPoolConfig.fTokenMint;
|
|
4289
|
-
const outputMint = toPoolConfig.fTokenMint;
|
|
4290
|
-
const quote = await getJupiterQuote(
|
|
4291
|
-
inputMint,
|
|
4292
|
-
outputMint,
|
|
4293
|
-
BigInt(params.amountIn.toString()),
|
|
4294
|
-
params.slippageBps ?? 30,
|
|
4295
|
-
40,
|
|
4296
|
-
this.client.jupiterApiKey
|
|
4297
|
-
);
|
|
4298
|
-
const swapIxs = await getJupiterSwapInstructions(quote, this.client.vaultPda, this.client.jupiterApiKey);
|
|
4299
|
-
const remainingAccounts = parseSwapRemainingAccounts(swapIxs.swapInstruction);
|
|
4300
|
-
const alts = await fetchAddressLookupTables(
|
|
4301
|
-
this.client.connection,
|
|
4302
|
-
swapIxs.addressLookupTableAddresses
|
|
4303
|
-
);
|
|
4304
|
-
return {
|
|
4305
|
-
inputMint,
|
|
4306
|
-
outputMint,
|
|
4307
|
-
inAmount: new import_anchor6.BN(quote.inAmount),
|
|
4308
|
-
outAmount: new import_anchor6.BN(quote.outAmount),
|
|
4309
|
-
minOutAmount: new import_anchor6.BN(quote.otherAmountThreshold),
|
|
4310
|
-
priceImpactPct: parseFloat(quote.priceImpactPct),
|
|
4311
|
-
route: quote.routePlan.map((r) => r.swapInfo.label || "unknown"),
|
|
4312
|
-
jupiterData: Buffer.from(swapIxs.swapInstruction.data, "base64"),
|
|
4313
|
-
remainingAccounts,
|
|
4314
|
-
addressLookupTables: alts,
|
|
4315
|
-
computeUnitLimit: swapIxs.computeUnitLimit ?? 6e5
|
|
4316
|
-
};
|
|
4317
|
-
}
|
|
4318
|
-
// Build jlX <-> jlX swap transaction
|
|
4319
|
-
async swapJlxJlx(params) {
|
|
4320
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4321
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4322
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4323
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4324
|
-
const fromPoolCtx = this.client.pool(params.fromPool);
|
|
4325
|
-
const toPoolCtx = this.client.pool(params.toPool);
|
|
4326
|
-
const computeIx = import_web39.ComputeBudgetProgram.setComputeUnitLimit({
|
|
4327
|
-
units: params.quote.computeUnitLimit
|
|
4328
|
-
});
|
|
4329
|
-
const jupiterProgram = JUPITER_SWAP_PROGRAM_ID;
|
|
4330
|
-
const swapIx = await createSwapJlxJlxInstruction(
|
|
4331
|
-
this.client.program,
|
|
4332
|
-
{
|
|
4333
|
-
fromIndex: fromPoolConfig.stvIndex,
|
|
4334
|
-
toIndex: toPoolConfig.stvIndex,
|
|
4335
|
-
amountIn: params.amountIn,
|
|
4336
|
-
minOut: params.minOut,
|
|
4337
|
-
jupiterData: params.quote.jupiterData
|
|
4338
|
-
},
|
|
4339
|
-
{
|
|
4340
|
-
manager: params.manager,
|
|
4341
|
-
jlpVault: this.client.vaultPda,
|
|
4342
|
-
fromJlxMint: fromPoolConfig.fTokenMint,
|
|
4343
|
-
toJlxMint: toPoolConfig.fTokenMint,
|
|
4344
|
-
fromJlxAta: fromPoolCtx.vaultStagingAta,
|
|
4345
|
-
toJlxAta: toPoolCtx.vaultStagingAta,
|
|
4346
|
-
tokenProgram: import_spl_token5.TOKEN_PROGRAM_ID,
|
|
4347
|
-
jupiterProgram
|
|
4348
|
-
},
|
|
4349
|
-
params.quote.remainingAccounts
|
|
4350
|
-
);
|
|
4351
|
-
const { blockhash } = await this.client.connection.getLatestBlockhash("confirmed");
|
|
4352
|
-
const message = new import_web39.TransactionMessage({
|
|
4353
|
-
payerKey: params.manager,
|
|
4354
|
-
recentBlockhash: blockhash,
|
|
4355
|
-
instructions: [computeIx, swapIx]
|
|
4356
|
-
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4357
|
-
return new import_web39.VersionedTransaction(message);
|
|
4358
|
-
}
|
|
4359
4269
|
};
|
|
4360
4270
|
var AdminContext = class {
|
|
4361
4271
|
constructor(client) {
|
|
@@ -4436,7 +4346,7 @@ var AdminContext = class {
|
|
|
4436
4346
|
const remainingAccounts = [...lendingAccounts, ...rewardsAccounts, ...mintAccounts];
|
|
4437
4347
|
const ix = await createSettleYieldInstruction(
|
|
4438
4348
|
this.client.program,
|
|
4439
|
-
{
|
|
4349
|
+
{},
|
|
4440
4350
|
{
|
|
4441
4351
|
manager: params.manager,
|
|
4442
4352
|
jlpVault: this.client.vaultPda,
|
|
@@ -4455,7 +4365,8 @@ var AdminContext = class {
|
|
|
4455
4365
|
oracleBtc: ORACLES.DOVES_BTC_USD,
|
|
4456
4366
|
oracleEth: ORACLES.DOVES_ETH_USD,
|
|
4457
4367
|
oracleSol: ORACLES.DOVES_SOL_USD,
|
|
4458
|
-
|
|
4368
|
+
jlpPool: JLP_POOL_PUBKEY,
|
|
4369
|
+
jlpMintAccount: MINTS.JLP
|
|
4459
4370
|
},
|
|
4460
4371
|
remainingAccounts
|
|
4461
4372
|
);
|
|
@@ -4472,10 +4383,12 @@ var AdminContext = class {
|
|
|
4472
4383
|
FLAG_REBALANCE_DISABLED,
|
|
4473
4384
|
FLAG_WITHDRAWALS_DISABLED,
|
|
4474
4385
|
JLPD_PROGRAM_ID,
|
|
4386
|
+
JLP_POOL_PUBKEY,
|
|
4475
4387
|
JLP_VAULT_ACCOUNT_SIZE,
|
|
4476
4388
|
JLP_VAULT_DATA_SIZE,
|
|
4477
4389
|
JLP_VAULT_DISCRIMINATOR,
|
|
4478
4390
|
JUPITER_LEND_PROGRAM_ID,
|
|
4391
|
+
JUPITER_PERPS_PROGRAM_ID,
|
|
4479
4392
|
JUPITER_SWAP_PROGRAM_ID,
|
|
4480
4393
|
JUPUSD_POOL,
|
|
4481
4394
|
JUP_LEND_PROGRAM_ID,
|
|
@@ -4520,7 +4433,6 @@ var AdminContext = class {
|
|
|
4520
4433
|
createProgram,
|
|
4521
4434
|
createSettleYieldInstruction,
|
|
4522
4435
|
createSwapJlxJlpInstruction,
|
|
4523
|
-
createSwapJlxJlxInstruction,
|
|
4524
4436
|
createUpdateStvInstruction,
|
|
4525
4437
|
createWithdrawInstruction,
|
|
4526
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";
|
|
@@ -3562,7 +3562,10 @@ async function createUpdateStvInstruction(program, params, accounts) {
|
|
|
3562
3562
|
flags: params.flags,
|
|
3563
3563
|
maxDeposit: params.maxDeposit,
|
|
3564
3564
|
minDeposit: params.minDeposit,
|
|
3565
|
-
jlMint: params.jlMint
|
|
3565
|
+
jlMint: params.jlMint,
|
|
3566
|
+
pps: params.pps,
|
|
3567
|
+
hwm: params.hwm,
|
|
3568
|
+
baseLoaned: params.baseLoaned
|
|
3566
3569
|
}).accounts({
|
|
3567
3570
|
admin: accounts.admin,
|
|
3568
3571
|
jlpVault: accounts.jlpVault,
|
|
@@ -3641,24 +3644,6 @@ async function createMoveJlxInstruction(program, params, accounts, remainingAcco
|
|
|
3641
3644
|
tokenProgram: accounts.tokenProgram
|
|
3642
3645
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3643
3646
|
}
|
|
3644
|
-
async function createSwapJlxJlxInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3645
|
-
return await program.methods.swapJlxJlx({
|
|
3646
|
-
fromIndex: params.fromIndex,
|
|
3647
|
-
toIndex: params.toIndex,
|
|
3648
|
-
amountIn: params.amountIn,
|
|
3649
|
-
minOut: params.minOut,
|
|
3650
|
-
jupiterData: params.jupiterData
|
|
3651
|
-
}).accounts({
|
|
3652
|
-
manager: accounts.manager,
|
|
3653
|
-
jlpVault: accounts.jlpVault,
|
|
3654
|
-
fromJlxMint: accounts.fromJlxMint,
|
|
3655
|
-
toJlxMint: accounts.toJlxMint,
|
|
3656
|
-
fromJlxAta: accounts.fromJlxAta,
|
|
3657
|
-
toJlxAta: accounts.toJlxAta,
|
|
3658
|
-
tokenProgram: accounts.tokenProgram,
|
|
3659
|
-
jupiterProgram: accounts.jupiterProgram
|
|
3660
|
-
}).remainingAccounts(remainingAccounts).instruction();
|
|
3661
|
-
}
|
|
3662
3647
|
async function createSwapJlxJlpInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3663
3648
|
return await program.methods.swapJlxToFromJlp({
|
|
3664
3649
|
stvIndex: params.stvIndex,
|
|
@@ -3677,9 +3662,7 @@ async function createSwapJlxJlpInstruction(program, params, accounts, remainingA
|
|
|
3677
3662
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3678
3663
|
}
|
|
3679
3664
|
async function createSettleYieldInstruction(program, params, accounts, remainingAccounts = []) {
|
|
3680
|
-
return await program.methods.settleYield({
|
|
3681
|
-
jlpRate: params.jlpRate
|
|
3682
|
-
}).accounts({
|
|
3665
|
+
return await program.methods.settleYield().accounts({
|
|
3683
3666
|
jlpVault: accounts.jlpVault,
|
|
3684
3667
|
vaultJlpAta: accounts.vaultJlpAta,
|
|
3685
3668
|
stv0: accounts.stvBtc,
|
|
@@ -3695,7 +3678,8 @@ async function createSettleYieldInstruction(program, params, accounts, remaining
|
|
|
3695
3678
|
dovesBtcUsd: accounts.oracleBtc,
|
|
3696
3679
|
dovesEthUsd: accounts.oracleEth,
|
|
3697
3680
|
dovesSolUsd: accounts.oracleSol,
|
|
3698
|
-
|
|
3681
|
+
jlpPool: accounts.jlpPool,
|
|
3682
|
+
jlpMintAccount: accounts.jlpMintAccount,
|
|
3699
3683
|
manager: accounts.manager
|
|
3700
3684
|
}).remainingAccounts(remainingAccounts).instruction();
|
|
3701
3685
|
}
|
|
@@ -4098,8 +4082,10 @@ var PoolContext = class {
|
|
|
4098
4082
|
flags: params.flags ?? stv.flags,
|
|
4099
4083
|
maxDeposit: params.maxDeposit ?? stv.maxDeposit,
|
|
4100
4084
|
minDeposit: params.minDeposit ?? stv.minDeposit,
|
|
4101
|
-
jlMint: params.jlMint ?? null
|
|
4102
|
-
|
|
4085
|
+
jlMint: params.jlMint ?? null,
|
|
4086
|
+
pps: params.pps ?? null,
|
|
4087
|
+
hwm: params.hwm ?? null,
|
|
4088
|
+
baseLoaned: params.baseLoaned ?? null
|
|
4103
4089
|
},
|
|
4104
4090
|
{
|
|
4105
4091
|
admin: params.admin,
|
|
@@ -4186,83 +4172,6 @@ var SwapContext = class {
|
|
|
4186
4172
|
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4187
4173
|
return new VersionedTransaction(message);
|
|
4188
4174
|
}
|
|
4189
|
-
// Get a quote for jlX <-> jlX swap
|
|
4190
|
-
async quoteJlxJlx(params) {
|
|
4191
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4192
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4193
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4194
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4195
|
-
const inputMint = fromPoolConfig.fTokenMint;
|
|
4196
|
-
const outputMint = toPoolConfig.fTokenMint;
|
|
4197
|
-
const quote = await getJupiterQuote(
|
|
4198
|
-
inputMint,
|
|
4199
|
-
outputMint,
|
|
4200
|
-
BigInt(params.amountIn.toString()),
|
|
4201
|
-
params.slippageBps ?? 30,
|
|
4202
|
-
40,
|
|
4203
|
-
this.client.jupiterApiKey
|
|
4204
|
-
);
|
|
4205
|
-
const swapIxs = await getJupiterSwapInstructions(quote, this.client.vaultPda, this.client.jupiterApiKey);
|
|
4206
|
-
const remainingAccounts = parseSwapRemainingAccounts(swapIxs.swapInstruction);
|
|
4207
|
-
const alts = await fetchAddressLookupTables(
|
|
4208
|
-
this.client.connection,
|
|
4209
|
-
swapIxs.addressLookupTableAddresses
|
|
4210
|
-
);
|
|
4211
|
-
return {
|
|
4212
|
-
inputMint,
|
|
4213
|
-
outputMint,
|
|
4214
|
-
inAmount: new BN5(quote.inAmount),
|
|
4215
|
-
outAmount: new BN5(quote.outAmount),
|
|
4216
|
-
minOutAmount: new BN5(quote.otherAmountThreshold),
|
|
4217
|
-
priceImpactPct: parseFloat(quote.priceImpactPct),
|
|
4218
|
-
route: quote.routePlan.map((r) => r.swapInfo.label || "unknown"),
|
|
4219
|
-
jupiterData: Buffer.from(swapIxs.swapInstruction.data, "base64"),
|
|
4220
|
-
remainingAccounts,
|
|
4221
|
-
addressLookupTables: alts,
|
|
4222
|
-
computeUnitLimit: swapIxs.computeUnitLimit ?? 6e5
|
|
4223
|
-
};
|
|
4224
|
-
}
|
|
4225
|
-
// Build jlX <-> jlX swap transaction
|
|
4226
|
-
async swapJlxJlx(params) {
|
|
4227
|
-
const fromPoolConfig = getPoolByName(params.fromPool);
|
|
4228
|
-
const toPoolConfig = getPoolByName(params.toPool);
|
|
4229
|
-
if (!fromPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.fromPool}`);
|
|
4230
|
-
if (!toPoolConfig) throw new JlpdClientError(`Unknown pool: ${params.toPool}`);
|
|
4231
|
-
const fromPoolCtx = this.client.pool(params.fromPool);
|
|
4232
|
-
const toPoolCtx = this.client.pool(params.toPool);
|
|
4233
|
-
const computeIx = ComputeBudgetProgram.setComputeUnitLimit({
|
|
4234
|
-
units: params.quote.computeUnitLimit
|
|
4235
|
-
});
|
|
4236
|
-
const jupiterProgram = JUPITER_SWAP_PROGRAM_ID;
|
|
4237
|
-
const swapIx = await createSwapJlxJlxInstruction(
|
|
4238
|
-
this.client.program,
|
|
4239
|
-
{
|
|
4240
|
-
fromIndex: fromPoolConfig.stvIndex,
|
|
4241
|
-
toIndex: toPoolConfig.stvIndex,
|
|
4242
|
-
amountIn: params.amountIn,
|
|
4243
|
-
minOut: params.minOut,
|
|
4244
|
-
jupiterData: params.quote.jupiterData
|
|
4245
|
-
},
|
|
4246
|
-
{
|
|
4247
|
-
manager: params.manager,
|
|
4248
|
-
jlpVault: this.client.vaultPda,
|
|
4249
|
-
fromJlxMint: fromPoolConfig.fTokenMint,
|
|
4250
|
-
toJlxMint: toPoolConfig.fTokenMint,
|
|
4251
|
-
fromJlxAta: fromPoolCtx.vaultStagingAta,
|
|
4252
|
-
toJlxAta: toPoolCtx.vaultStagingAta,
|
|
4253
|
-
tokenProgram: TOKEN_PROGRAM_ID2,
|
|
4254
|
-
jupiterProgram
|
|
4255
|
-
},
|
|
4256
|
-
params.quote.remainingAccounts
|
|
4257
|
-
);
|
|
4258
|
-
const { blockhash } = await this.client.connection.getLatestBlockhash("confirmed");
|
|
4259
|
-
const message = new TransactionMessage({
|
|
4260
|
-
payerKey: params.manager,
|
|
4261
|
-
recentBlockhash: blockhash,
|
|
4262
|
-
instructions: [computeIx, swapIx]
|
|
4263
|
-
}).compileToV0Message(params.quote.addressLookupTables);
|
|
4264
|
-
return new VersionedTransaction(message);
|
|
4265
|
-
}
|
|
4266
4175
|
};
|
|
4267
4176
|
var AdminContext = class {
|
|
4268
4177
|
constructor(client) {
|
|
@@ -4343,7 +4252,7 @@ var AdminContext = class {
|
|
|
4343
4252
|
const remainingAccounts = [...lendingAccounts, ...rewardsAccounts, ...mintAccounts];
|
|
4344
4253
|
const ix = await createSettleYieldInstruction(
|
|
4345
4254
|
this.client.program,
|
|
4346
|
-
{
|
|
4255
|
+
{},
|
|
4347
4256
|
{
|
|
4348
4257
|
manager: params.manager,
|
|
4349
4258
|
jlpVault: this.client.vaultPda,
|
|
@@ -4362,7 +4271,8 @@ var AdminContext = class {
|
|
|
4362
4271
|
oracleBtc: ORACLES.DOVES_BTC_USD,
|
|
4363
4272
|
oracleEth: ORACLES.DOVES_ETH_USD,
|
|
4364
4273
|
oracleSol: ORACLES.DOVES_SOL_USD,
|
|
4365
|
-
|
|
4274
|
+
jlpPool: JLP_POOL_PUBKEY,
|
|
4275
|
+
jlpMintAccount: MINTS.JLP
|
|
4366
4276
|
},
|
|
4367
4277
|
remainingAccounts
|
|
4368
4278
|
);
|
|
@@ -4378,10 +4288,12 @@ export {
|
|
|
4378
4288
|
FLAG_REBALANCE_DISABLED,
|
|
4379
4289
|
FLAG_WITHDRAWALS_DISABLED,
|
|
4380
4290
|
JLPD_PROGRAM_ID,
|
|
4291
|
+
JLP_POOL_PUBKEY,
|
|
4381
4292
|
JLP_VAULT_ACCOUNT_SIZE,
|
|
4382
4293
|
JLP_VAULT_DATA_SIZE,
|
|
4383
4294
|
JLP_VAULT_DISCRIMINATOR,
|
|
4384
4295
|
JUPITER_LEND_PROGRAM_ID,
|
|
4296
|
+
JUPITER_PERPS_PROGRAM_ID,
|
|
4385
4297
|
JUPITER_SWAP_PROGRAM_ID,
|
|
4386
4298
|
JUPUSD_POOL,
|
|
4387
4299
|
JUPITER_LEND_PROGRAM_ID2 as JUP_LEND_PROGRAM_ID,
|
|
@@ -4426,7 +4338,6 @@ export {
|
|
|
4426
4338
|
createProgram,
|
|
4427
4339
|
createSettleYieldInstruction,
|
|
4428
4340
|
createSwapJlxJlpInstruction,
|
|
4429
|
-
createSwapJlxJlxInstruction,
|
|
4430
4341
|
createUpdateStvInstruction,
|
|
4431
4342
|
createWithdrawInstruction,
|
|
4432
4343
|
deriveAta,
|