@elmntl/jlpd-sdk 0.1.11 → 0.13.4

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.
Files changed (115) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +185 -404
  3. package/dist/common/ata.d.ts +26 -0
  4. package/dist/common/ata.js +48 -0
  5. package/dist/common/buffer.d.ts +15 -0
  6. package/dist/common/buffer.js +118 -0
  7. package/dist/common/connection.d.ts +13 -0
  8. package/dist/common/connection.js +2 -0
  9. package/dist/common/constants.d.ts +14 -0
  10. package/dist/common/constants.js +31 -0
  11. package/dist/common/index.d.ts +6 -0
  12. package/dist/common/index.js +28 -0
  13. package/dist/common/strategy-interface.d.ts +59 -0
  14. package/dist/common/strategy-interface.js +42 -0
  15. package/dist/elemental-lend/accounts.d.ts +103 -0
  16. package/dist/elemental-lend/accounts.js +354 -0
  17. package/dist/elemental-lend/constants.d.ts +25 -0
  18. package/dist/elemental-lend/constants.js +48 -0
  19. package/dist/elemental-lend/index.d.ts +8 -0
  20. package/dist/elemental-lend/index.js +24 -0
  21. package/dist/elemental-lend/instructions.d.ts +104 -0
  22. package/dist/elemental-lend/instructions.js +266 -0
  23. package/dist/elemental-lend/jupiter-lend.d.ts +91 -0
  24. package/dist/elemental-lend/jupiter-lend.js +189 -0
  25. package/dist/elemental-lend/kamino-vault.d.ts +173 -0
  26. package/dist/elemental-lend/kamino-vault.js +483 -0
  27. package/dist/elemental-lend/pda.d.ts +12 -0
  28. package/dist/elemental-lend/pda.js +24 -0
  29. package/dist/elemental-lend/protocol-actions.d.ts +56 -0
  30. package/dist/elemental-lend/protocol-actions.js +244 -0
  31. package/dist/elemental-lend/types.d.ts +113 -0
  32. package/dist/elemental-lend/types.js +2 -0
  33. package/dist/elemental-lend-v2/accounts.d.ts +14 -0
  34. package/dist/elemental-lend-v2/accounts.js +136 -0
  35. package/dist/elemental-lend-v2/adapters.d.ts +22 -0
  36. package/dist/elemental-lend-v2/adapters.js +50 -0
  37. package/dist/elemental-lend-v2/constants.d.ts +48 -0
  38. package/dist/elemental-lend-v2/constants.js +104 -0
  39. package/dist/elemental-lend-v2/index.d.ts +8 -0
  40. package/dist/elemental-lend-v2/index.js +24 -0
  41. package/dist/elemental-lend-v2/instructions.d.ts +96 -0
  42. package/dist/elemental-lend-v2/instructions.js +190 -0
  43. package/dist/elemental-lend-v2/lut.d.ts +20 -0
  44. package/dist/elemental-lend-v2/lut.js +65 -0
  45. package/dist/elemental-lend-v2/pda.d.ts +9 -0
  46. package/dist/elemental-lend-v2/pda.js +27 -0
  47. package/dist/elemental-lend-v2/types.d.ts +105 -0
  48. package/dist/elemental-lend-v2/types.js +2 -0
  49. package/dist/elemental-lend-v2/update-aum.d.ts +29 -0
  50. package/dist/elemental-lend-v2/update-aum.js +82 -0
  51. package/dist/index.d.ts +5 -3552
  52. package/dist/index.js +37 -4454
  53. package/dist/jlpd-strategy/accounts.d.ts +83 -0
  54. package/dist/jlpd-strategy/accounts.js +216 -0
  55. package/dist/jlpd-strategy/adapter.d.ts +81 -0
  56. package/dist/jlpd-strategy/adapter.js +118 -0
  57. package/dist/jlpd-strategy/base-to-base-swap.d.ts +74 -0
  58. package/dist/jlpd-strategy/base-to-base-swap.js +205 -0
  59. package/dist/jlpd-strategy/constants.d.ts +127 -0
  60. package/dist/jlpd-strategy/constants.js +174 -0
  61. package/dist/jlpd-strategy/fluid-view.d.ts +199 -0
  62. package/dist/jlpd-strategy/fluid-view.js +799 -0
  63. package/dist/jlpd-strategy/hedge-derived.d.ts +135 -0
  64. package/dist/jlpd-strategy/hedge-derived.js +231 -0
  65. package/dist/jlpd-strategy/hedge-instructions.d.ts +210 -0
  66. package/dist/jlpd-strategy/hedge-instructions.js +300 -0
  67. package/dist/jlpd-strategy/hedge-state.d.ts +88 -0
  68. package/dist/jlpd-strategy/hedge-state.js +110 -0
  69. package/dist/jlpd-strategy/index.d.ts +17 -0
  70. package/dist/jlpd-strategy/index.js +33 -0
  71. package/dist/jlpd-strategy/instructions.d.ts +159 -0
  72. package/dist/jlpd-strategy/instructions.js +234 -0
  73. package/dist/jlpd-strategy/jlp-borrow.d.ts +63 -0
  74. package/dist/jlpd-strategy/jlp-borrow.js +87 -0
  75. package/dist/jlpd-strategy/jlp-data.d.ts +166 -0
  76. package/dist/jlpd-strategy/jlp-data.js +611 -0
  77. package/dist/jlpd-strategy/jupusd-earn.d.ts +90 -0
  78. package/dist/jlpd-strategy/jupusd-earn.js +166 -0
  79. package/dist/jlpd-strategy/live-jlp-price.d.ts +46 -0
  80. package/dist/jlpd-strategy/live-jlp-price.js +267 -0
  81. package/dist/jlpd-strategy/pda.d.ts +13 -0
  82. package/dist/jlpd-strategy/pda.js +28 -0
  83. package/dist/jlpd-strategy/settle-yield.d.ts +45 -0
  84. package/dist/jlpd-strategy/settle-yield.js +113 -0
  85. package/dist/jlpd-strategy/swap-jlp.d.ts +198 -0
  86. package/dist/jlpd-strategy/swap-jlp.js +586 -0
  87. package/dist/jlpd-strategy/types.d.ts +101 -0
  88. package/dist/jlpd-strategy/types.js +29 -0
  89. package/dist/p-stv-core/accounts.d.ts +152 -0
  90. package/dist/p-stv-core/accounts.js +407 -0
  91. package/dist/p-stv-core/constants.d.ts +138 -0
  92. package/dist/p-stv-core/constants.js +181 -0
  93. package/dist/p-stv-core/events.d.ts +7 -0
  94. package/dist/p-stv-core/events.js +246 -0
  95. package/dist/p-stv-core/index.d.ts +11 -0
  96. package/dist/p-stv-core/index.js +27 -0
  97. package/dist/p-stv-core/instructions.d.ts +637 -0
  98. package/dist/p-stv-core/instructions.js +670 -0
  99. package/dist/p-stv-core/lut.d.ts +41 -0
  100. package/dist/p-stv-core/lut.js +81 -0
  101. package/dist/p-stv-core/pda.d.ts +30 -0
  102. package/dist/p-stv-core/pda.js +65 -0
  103. package/dist/p-stv-core/prices.d.ts +20 -0
  104. package/dist/p-stv-core/prices.js +77 -0
  105. package/dist/p-stv-core/remaining-accounts.d.ts +107 -0
  106. package/dist/p-stv-core/remaining-accounts.js +326 -0
  107. package/dist/p-stv-core/send-tx.d.ts +72 -0
  108. package/dist/p-stv-core/send-tx.js +290 -0
  109. package/dist/p-stv-core/sol-wrap.d.ts +34 -0
  110. package/dist/p-stv-core/sol-wrap.js +74 -0
  111. package/dist/p-stv-core/types.d.ts +361 -0
  112. package/dist/p-stv-core/types.js +2 -0
  113. package/package.json +56 -15
  114. package/dist/index.d.mts +0 -3552
  115. package/dist/index.mjs +0 -4363
@@ -0,0 +1,266 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createInitOrUpdateStrategyIx = createInitOrUpdateStrategyIx;
4
+ exports.createCloseStrategyIx = createCloseStrategyIx;
5
+ exports.createResetStrategyIx = createResetStrategyIx;
6
+ exports.createKvaultDepositIx = createKvaultDepositIx;
7
+ exports.createKvaultWithdrawIx = createKvaultWithdrawIx;
8
+ exports.createJupLendDepositIx = createJupLendDepositIx;
9
+ exports.createJupLendWithdrawIx = createJupLendWithdrawIx;
10
+ exports.createAddManagerIx = createAddManagerIx;
11
+ exports.createRemoveManagerIx = createRemoveManagerIx;
12
+ const web3_js_1 = require("@solana/web3.js");
13
+ const spl_token_1 = require("@solana/spl-token");
14
+ const buffer_1 = require("../common/buffer");
15
+ const constants_1 = require("./constants");
16
+ /** Serialize InitOrUpdateStrategyParams for Anchor (Borsh Option<T> encoding) */
17
+ function serializeInitOrUpdateStrategyParams(args) {
18
+ const parts = [];
19
+ // admin: Option<Pubkey>
20
+ if (args.newAdmin != null) {
21
+ parts.push(0x01);
22
+ parts.push(...args.newAdmin.toBuffer());
23
+ }
24
+ else {
25
+ parts.push(0x00);
26
+ }
27
+ // base_mint: Option<Pubkey> — always None from SDK (set from accounts)
28
+ parts.push(0x00);
29
+ // authority: Option<Pubkey>
30
+ if (args.authority != null) {
31
+ parts.push(0x01);
32
+ parts.push(...args.authority.toBuffer());
33
+ }
34
+ else {
35
+ parts.push(0x00);
36
+ }
37
+ // flags: Option<u16>
38
+ if (args.flags != null) {
39
+ parts.push(0x01);
40
+ const buf = Buffer.alloc(2);
41
+ buf.writeUInt16LE(args.flags, 0);
42
+ parts.push(...buf);
43
+ }
44
+ else {
45
+ parts.push(0x00);
46
+ }
47
+ // add_protocol: Option<Pubkey>
48
+ if (args.addProtocol != null) {
49
+ parts.push(0x01);
50
+ parts.push(...args.addProtocol.toBuffer());
51
+ }
52
+ else {
53
+ parts.push(0x00);
54
+ }
55
+ // remove_protocol: Option<Pubkey>
56
+ if (args.removeProtocol != null) {
57
+ parts.push(0x01);
58
+ parts.push(...args.removeProtocol.toBuffer());
59
+ }
60
+ else {
61
+ parts.push(0x00);
62
+ }
63
+ // manager_count: Option<u8> (last field; update-only backfill)
64
+ if (args.managerCount != null) {
65
+ parts.push(0x01);
66
+ parts.push(args.managerCount & 0xff);
67
+ }
68
+ else {
69
+ parts.push(0x00);
70
+ }
71
+ return Buffer.from(parts);
72
+ }
73
+ function createInitOrUpdateStrategyIx(args, programId = constants_1.PROGRAM_ID) {
74
+ const { admin, strategyState, baseMint, strategyBaseAta, tokenProgram, systemProgram = web3_js_1.SystemProgram.programId, associatedTokenProgram = spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, authority, flags, addProtocol, removeProtocol, newAdmin, managerCount, remainingAccounts = [], } = args;
75
+ // FIX C(1): addProtocol requires the protocol account in remainingAccounts[0].
76
+ // The handler reads remaining[0] as the protocol account (init_or_update_strategy.rs:259).
77
+ if (addProtocol != null && remainingAccounts.length === 0) {
78
+ throw new Error("createInitOrUpdateStrategyIx: addProtocol is set but remainingAccounts is empty — " +
79
+ "the protocol account must be supplied as remainingAccounts[0]");
80
+ }
81
+ // FIX C(2): managerCount is serialized as a single byte; validate range 0..255.
82
+ if (managerCount != null) {
83
+ if (!Number.isInteger(managerCount) || managerCount < 0 || managerCount > 255) {
84
+ throw new RangeError("createInitOrUpdateStrategyIx: managerCount must be an integer in 0..255, got " + managerCount);
85
+ }
86
+ }
87
+ const params = serializeInitOrUpdateStrategyParams({
88
+ newAdmin, authority, flags, addProtocol, removeProtocol, managerCount,
89
+ });
90
+ const data = Buffer.concat([constants_1.IX_INIT_OR_UPDATE_STRATEGY, params]);
91
+ return new web3_js_1.TransactionInstruction({
92
+ keys: [
93
+ { pubkey: admin, isSigner: true, isWritable: true },
94
+ { pubkey: strategyState, isSigner: false, isWritable: true },
95
+ { pubkey: baseMint, isSigner: false, isWritable: false },
96
+ { pubkey: strategyBaseAta, isSigner: false, isWritable: true },
97
+ { pubkey: systemProgram, isSigner: false, isWritable: false },
98
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
99
+ { pubkey: associatedTokenProgram, isSigner: false, isWritable: false },
100
+ ...remainingAccounts,
101
+ ],
102
+ programId,
103
+ data,
104
+ });
105
+ }
106
+ function createCloseStrategyIx(args, programId = constants_1.PROGRAM_ID) {
107
+ const { admin, payer, strategyState, strategyBaseAta, baseMint, tokenProgram, remainingAccounts = [] } = args;
108
+ return new web3_js_1.TransactionInstruction({
109
+ keys: [
110
+ { pubkey: admin, isSigner: true, isWritable: false },
111
+ { pubkey: payer, isSigner: false, isWritable: true },
112
+ { pubkey: strategyState, isSigner: false, isWritable: true },
113
+ { pubkey: strategyBaseAta, isSigner: false, isWritable: true },
114
+ { pubkey: baseMint, isSigner: false, isWritable: false },
115
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
116
+ ...remainingAccounts,
117
+ ],
118
+ programId,
119
+ data: constants_1.IX_CLOSE_STRATEGY,
120
+ });
121
+ }
122
+ function createResetStrategyIx(args, programId = constants_1.PROGRAM_ID) {
123
+ const { admin, strategyState } = args;
124
+ return new web3_js_1.TransactionInstruction({
125
+ keys: [
126
+ { pubkey: admin, isSigner: true, isWritable: false },
127
+ { pubkey: strategyState, isSigner: false, isWritable: true },
128
+ ],
129
+ programId,
130
+ data: constants_1.IX_RESET_STRATEGY,
131
+ });
132
+ }
133
+ // FIX D: minimum remaining-account counts sourced from crate constants:
134
+ // kamino_vault::deposit_accounts::FIXED_COUNT = 13 (kamino-vault/src/lib.rs:84)
135
+ // kamino_vault::withdraw_accounts::FIXED_COUNT = 25 (kamino-vault/src/lib.rs:147)
136
+ // jup_lend::deposit_accounts::COUNT = 17 (jup-lend/src/lib.rs:75)
137
+ // jup_lend::withdraw_accounts::COUNT = 18 (jup-lend/src/lib.rs:98)
138
+ const KVAULT_DEPOSIT_FIXED_COUNT = 13;
139
+ const KVAULT_WITHDRAW_FIXED_COUNT = 25;
140
+ const JUP_LEND_DEPOSIT_COUNT = 17;
141
+ const JUP_LEND_WITHDRAW_COUNT = 18;
142
+ function createKvaultDepositIx(args, programId = constants_1.PROGRAM_ID) {
143
+ const { manager, strategyState, managerRole, depositorBaseAta, depositorSharesAta, amount, minOut = 0, remainingAccounts } = args;
144
+ if (remainingAccounts.length < KVAULT_DEPOSIT_FIXED_COUNT) {
145
+ throw new Error("createKvaultDepositIx: remainingAccounts must contain at least " +
146
+ KVAULT_DEPOSIT_FIXED_COUNT + " accounts (kamino_vault::deposit_accounts::FIXED_COUNT), " +
147
+ "got " + remainingAccounts.length);
148
+ }
149
+ const data = [...constants_1.IX_KVAULT_DEPOSIT];
150
+ (0, buffer_1.writeU64)(data, amount);
151
+ (0, buffer_1.writeU64)(data, minOut); // min_shares_out
152
+ return new web3_js_1.TransactionInstruction({
153
+ keys: [
154
+ { pubkey: manager, isSigner: true, isWritable: true },
155
+ { pubkey: strategyState, isSigner: false, isWritable: false },
156
+ { pubkey: managerRole, isSigner: false, isWritable: false },
157
+ { pubkey: depositorBaseAta, isSigner: false, isWritable: true },
158
+ { pubkey: depositorSharesAta, isSigner: false, isWritable: true },
159
+ ...remainingAccounts,
160
+ ],
161
+ programId,
162
+ data: Buffer.from(data),
163
+ });
164
+ }
165
+ function createKvaultWithdrawIx(args, programId = constants_1.PROGRAM_ID) {
166
+ const { manager, strategyState, managerRole, depositorBaseAta, depositorSharesAta, shares, minOut = 0, remainingAccounts } = args;
167
+ if (remainingAccounts.length < KVAULT_WITHDRAW_FIXED_COUNT) {
168
+ throw new Error("createKvaultWithdrawIx: remainingAccounts must contain at least " +
169
+ KVAULT_WITHDRAW_FIXED_COUNT + " accounts (kamino_vault::withdraw_accounts::FIXED_COUNT), " +
170
+ "got " + remainingAccounts.length);
171
+ }
172
+ const data = [...constants_1.IX_KVAULT_WITHDRAW];
173
+ (0, buffer_1.writeU64)(data, shares);
174
+ (0, buffer_1.writeU64)(data, minOut); // min_base_out
175
+ return new web3_js_1.TransactionInstruction({
176
+ keys: [
177
+ { pubkey: manager, isSigner: true, isWritable: true },
178
+ { pubkey: strategyState, isSigner: false, isWritable: false },
179
+ { pubkey: managerRole, isSigner: false, isWritable: false },
180
+ { pubkey: depositorBaseAta, isSigner: false, isWritable: true },
181
+ { pubkey: depositorSharesAta, isSigner: false, isWritable: true },
182
+ ...remainingAccounts,
183
+ ],
184
+ programId,
185
+ data: Buffer.from(data),
186
+ });
187
+ }
188
+ function createJupLendDepositIx(args, programId = constants_1.PROGRAM_ID) {
189
+ const { manager, strategyState, managerRole, depositorBaseAta, depositorFtokenAta, amount, minOut = 0, remainingAccounts } = args;
190
+ if (remainingAccounts.length < JUP_LEND_DEPOSIT_COUNT) {
191
+ throw new Error("createJupLendDepositIx: remainingAccounts must contain at least " +
192
+ JUP_LEND_DEPOSIT_COUNT + " accounts (jup_lend::deposit_accounts::COUNT), " +
193
+ "got " + remainingAccounts.length);
194
+ }
195
+ const data = [...constants_1.IX_JUP_LEND_DEPOSIT];
196
+ (0, buffer_1.writeU64)(data, amount);
197
+ (0, buffer_1.writeU64)(data, minOut); // min_ftokens_out
198
+ return new web3_js_1.TransactionInstruction({
199
+ keys: [
200
+ { pubkey: manager, isSigner: true, isWritable: true },
201
+ { pubkey: strategyState, isSigner: false, isWritable: false },
202
+ { pubkey: managerRole, isSigner: false, isWritable: false },
203
+ { pubkey: depositorBaseAta, isSigner: false, isWritable: true },
204
+ { pubkey: depositorFtokenAta, isSigner: false, isWritable: true },
205
+ ...remainingAccounts,
206
+ ],
207
+ programId,
208
+ data: Buffer.from(data),
209
+ });
210
+ }
211
+ function createJupLendWithdrawIx(args, programId = constants_1.PROGRAM_ID) {
212
+ const { manager, strategyState, managerRole, depositorBaseAta, depositorFtokenAta, amount, minOut = 0, remainingAccounts } = args;
213
+ if (remainingAccounts.length < JUP_LEND_WITHDRAW_COUNT) {
214
+ throw new Error("createJupLendWithdrawIx: remainingAccounts must contain at least " +
215
+ JUP_LEND_WITHDRAW_COUNT + " accounts (jup_lend::withdraw_accounts::COUNT), " +
216
+ "got " + remainingAccounts.length);
217
+ }
218
+ const data = [...constants_1.IX_JUP_LEND_WITHDRAW];
219
+ (0, buffer_1.writeU64)(data, amount);
220
+ (0, buffer_1.writeU64)(data, minOut); // min_base_out
221
+ return new web3_js_1.TransactionInstruction({
222
+ keys: [
223
+ { pubkey: manager, isSigner: true, isWritable: true },
224
+ { pubkey: strategyState, isSigner: false, isWritable: false },
225
+ { pubkey: managerRole, isSigner: false, isWritable: false },
226
+ { pubkey: depositorBaseAta, isSigner: false, isWritable: true },
227
+ { pubkey: depositorFtokenAta, isSigner: false, isWritable: true },
228
+ ...remainingAccounts,
229
+ ],
230
+ programId,
231
+ data: Buffer.from(data),
232
+ });
233
+ }
234
+ function createAddManagerIx(args, programId = constants_1.PROGRAM_ID) {
235
+ const { admin, payer, strategyState, managerRole, manager, systemProgram = web3_js_1.SystemProgram.programId, } = args;
236
+ const data = Buffer.concat([
237
+ constants_1.IX_ADD_MANAGER,
238
+ manager.toBuffer(),
239
+ ]);
240
+ return new web3_js_1.TransactionInstruction({
241
+ keys: [
242
+ { pubkey: admin, isSigner: true, isWritable: false },
243
+ { pubkey: payer, isSigner: true, isWritable: true },
244
+ { pubkey: strategyState, isSigner: false, isWritable: true },
245
+ { pubkey: managerRole, isSigner: false, isWritable: true },
246
+ { pubkey: systemProgram, isSigner: false, isWritable: false },
247
+ ],
248
+ programId,
249
+ data,
250
+ });
251
+ }
252
+ function createRemoveManagerIx(args, programId = constants_1.PROGRAM_ID) {
253
+ const { admin, payer, strategyState, managerRole } = args;
254
+ return new web3_js_1.TransactionInstruction({
255
+ keys: [
256
+ { pubkey: admin, isSigner: true, isWritable: false },
257
+ { pubkey: payer, isSigner: false, isWritable: true },
258
+ // strategy_state is #[account(mut)] in remove_manager.rs:17 — the handler
259
+ // calls load_mut() and decrements manager_count at line 56.
260
+ { pubkey: strategyState, isSigner: false, isWritable: true },
261
+ { pubkey: managerRole, isSigner: false, isWritable: true },
262
+ ],
263
+ programId,
264
+ data: constants_1.IX_REMOVE_MANAGER,
265
+ });
266
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Jupiter Lend USDC pool configuration and auto-route account builders.
3
+ *
4
+ * All account addresses are mainnet values discovered from on-chain data.
5
+ * These are used to build the remaining_accounts for auto-routing deposits
6
+ * from elemental-lend into Jupiter Lend.
7
+ */
8
+ import { AccountMeta, PublicKey } from "@solana/web3.js";
9
+ /** Lending Admin PDA: ["lending_admin"] on jup3Y... */
10
+ export declare const LENDING_ADMIN: PublicKey;
11
+ /** Fluid/Jupiter Liquidity Program */
12
+ export declare const LIQUIDITY_PROGRAM_ID: PublicKey;
13
+ /** Liquidity singleton PDA */
14
+ export declare const LIQUIDITY_SINGLETON: PublicKey;
15
+ export interface JupiterLendPool {
16
+ mint: PublicKey;
17
+ lending: PublicKey;
18
+ fTokenMint: PublicKey;
19
+ tokenReservesLiquidity: PublicKey;
20
+ supplyPositionOnLiquidity: PublicKey;
21
+ rewardsRateModel: PublicKey;
22
+ vault: PublicKey;
23
+ rateModel: PublicKey;
24
+ claimAccount: PublicKey;
25
+ }
26
+ export declare const USDC_POOL: JupiterLendPool;
27
+ export declare const SOL_POOL: JupiterLendPool;
28
+ export declare const JUPUSD_POOL: JupiterLendPool;
29
+ /** Map base mint address → Jupiter Lend pool config */
30
+ export declare const JUP_LEND_POOLS: Record<string, JupiterLendPool>;
31
+ /**
32
+ * Build the 17 CPI accounts for Jupiter Lend deposit.
33
+ *
34
+ * Account order matches `jup_lend::deposit_accounts`:
35
+ * [0] signer (strategy_state PDA)
36
+ * [1] depositor_token_account (strategy base ATA)
37
+ * [2] recipient_token_account (strategy fToken ATA)
38
+ * [3] mint (base token mint)
39
+ * [4] lending_admin
40
+ * [5] lending
41
+ * [6] f_token_mint
42
+ * [7] supply_token_reserves_liquidity
43
+ * [8] lending_supply_position_on_liquidity
44
+ * [9] rate_model
45
+ * [10] vault
46
+ * [11] liquidity
47
+ * [12] liquidity_program
48
+ * [13] rewards_rate_model
49
+ * [14] token_program
50
+ * [15] associated_token_program
51
+ * [16] system_program
52
+ */
53
+ export declare function buildJupLendDepositAccounts(pool: JupiterLendPool, signer: PublicKey, depositorTokenAccount: PublicKey, recipientTokenAccount: PublicKey): AccountMeta[];
54
+ /**
55
+ * Build the full auto-route remaining_accounts for Jupiter Lend deposit.
56
+ *
57
+ * Returns [jup_lend_program, ...17 CPI accounts] = 18 accounts total.
58
+ * This is what p-stv-core's `sweep_to_lend` forwards to elemental-lend's deposit.
59
+ */
60
+ export declare function buildJupLendAutoRouteAccounts(pool: JupiterLendPool, strategyStatePda: PublicKey, strategyBaseAta: PublicKey, strategyFtokenAta: PublicKey): AccountMeta[];
61
+ /**
62
+ * Build the 18 CPI accounts for Jupiter Lend withdraw.
63
+ *
64
+ * Account order matches `jup_lend::withdraw_accounts`:
65
+ * [0] signer (strategy_state PDA)
66
+ * [1] owner_token_account (fToken ATA — source, fTokens burned)
67
+ * [2] recipient_token_account (base ATA — destination, receives base)
68
+ * [3] lending_admin
69
+ * [4] lending
70
+ * [5] mint (base token mint)
71
+ * [6] f_token_mint
72
+ * [7] supply_token_reserves_liquidity
73
+ * [8] lending_supply_position_on_liquidity
74
+ * [9] rate_model
75
+ * [10] vault
76
+ * [11] claim_account
77
+ * [12] liquidity
78
+ * [13] liquidity_program
79
+ * [14] rewards_rate_model
80
+ * [15] token_program
81
+ * [16] associated_token_program
82
+ * [17] system_program
83
+ */
84
+ export declare function buildJupLendWithdrawAccounts(pool: JupiterLendPool, signer: PublicKey, ownerTokenAccount: PublicKey, recipientTokenAccount: PublicKey): AccountMeta[];
85
+ /**
86
+ * Build the full auto-unroute remaining_accounts for Jupiter Lend withdraw.
87
+ *
88
+ * Returns [jup_lend_program, ...18 CPI accounts] = 19 accounts total.
89
+ * This is what p-stv-core's `unsweep_from_lend` forwards to elemental-lend's withdraw.
90
+ */
91
+ export declare function buildJupLendAutoUnrouteAccounts(pool: JupiterLendPool, strategyStatePda: PublicKey, strategyFtokenAta: PublicKey, strategyBaseAta: PublicKey): AccountMeta[];
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+ /**
3
+ * Jupiter Lend USDC pool configuration and auto-route account builders.
4
+ *
5
+ * All account addresses are mainnet values discovered from on-chain data.
6
+ * These are used to build the remaining_accounts for auto-routing deposits
7
+ * from elemental-lend into Jupiter Lend.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.JUP_LEND_POOLS = exports.JUPUSD_POOL = exports.SOL_POOL = exports.USDC_POOL = exports.LIQUIDITY_SINGLETON = exports.LIQUIDITY_PROGRAM_ID = exports.LENDING_ADMIN = void 0;
11
+ exports.buildJupLendDepositAccounts = buildJupLendDepositAccounts;
12
+ exports.buildJupLendAutoRouteAccounts = buildJupLendAutoRouteAccounts;
13
+ exports.buildJupLendWithdrawAccounts = buildJupLendWithdrawAccounts;
14
+ exports.buildJupLendAutoUnrouteAccounts = buildJupLendAutoUnrouteAccounts;
15
+ const web3_js_1 = require("@solana/web3.js");
16
+ const spl_token_1 = require("@solana/spl-token");
17
+ const constants_1 = require("./constants");
18
+ // ---------------------------------------------------------------------------
19
+ // Jupiter Lend Infrastructure
20
+ // ---------------------------------------------------------------------------
21
+ /** Lending Admin PDA: ["lending_admin"] on jup3Y... */
22
+ exports.LENDING_ADMIN = new web3_js_1.PublicKey("5nmGjA4s7ATzpBQXC5RNceRpaJ7pYw2wKsNBWyuSAZV6");
23
+ /** Fluid/Jupiter Liquidity Program */
24
+ exports.LIQUIDITY_PROGRAM_ID = new web3_js_1.PublicKey("jupeiUmn818Jg1ekPURTpr4mFo29p46vygyykFJ3wZC");
25
+ /** Liquidity singleton PDA */
26
+ exports.LIQUIDITY_SINGLETON = new web3_js_1.PublicKey("7s1da8DduuBFqGra5bJBjpnvL5E9mGzCuMk1Qkh4or2Z");
27
+ exports.USDC_POOL = {
28
+ mint: new web3_js_1.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
29
+ lending: new web3_js_1.PublicKey("2vVYHYM8VYnvZqQWpTJSj8o8DBf1wM8pVs3bsTgYZiqJ"),
30
+ fTokenMint: new web3_js_1.PublicKey("9BEcn9aPEmhSPbPQeFGjidRiEKki46fVQDyPpSQXPA2D"),
31
+ tokenReservesLiquidity: new web3_js_1.PublicKey("94vK29npVbyRHXH63rRcTiSr26SFhrQTzbpNJuhQEDu"),
32
+ supplyPositionOnLiquidity: new web3_js_1.PublicKey("Hf9gtkM4dpVBahVSzEXSVCAPpKzBsBcns3s8As3z77oF"),
33
+ rewardsRateModel: new web3_js_1.PublicKey("5xSPBiD3TibamAnwHDhZABdB4z4F9dcj5PnbteroBTTd"),
34
+ vault: new web3_js_1.PublicKey("BmkUoKMFYBxNSzWXyUjyMJjMAaVz4d8ZnxwwmhDCUXFB"),
35
+ rateModel: new web3_js_1.PublicKey("5pjzT5dFTsXcwixoab1QDLvZQvpYJxJeBphkyfHGn688"),
36
+ claimAccount: new web3_js_1.PublicKey("HN1r4VfkDn53xQQfeGDYrNuDKFdemAhZsHYRwBrFhsW"),
37
+ };
38
+ exports.SOL_POOL = {
39
+ mint: new web3_js_1.PublicKey("So11111111111111111111111111111111111111112"),
40
+ lending: new web3_js_1.PublicKey("BeAqbxfrcXmzEYT2Ra62oW2MqkuFDHaCtps47Mzg6Zj3"),
41
+ fTokenMint: new web3_js_1.PublicKey("2uQsyo1fXXQkDtcpXnLofWy88PxcvnfH2L8FPSE62FVU"),
42
+ tokenReservesLiquidity: new web3_js_1.PublicKey("4Y66HtUEqbbbpZdENGtFdVhUMS3tnagffn3M4do59Nfy"),
43
+ supplyPositionOnLiquidity: new web3_js_1.PublicKey("4SkEYxmiRgQ4VYyvh9VB4k39M49BpqazyzDUFDzJhXQm"),
44
+ rewardsRateModel: new web3_js_1.PublicKey("CkeQGDRsgMZcCaU8cZEdC2aFAohia4jLzL36RaLcUDsR"),
45
+ vault: new web3_js_1.PublicKey("5JP5zgYCb9W37QQLgAHRHuinFLrKt87akDY1CgZoTPzr"),
46
+ rateModel: new web3_js_1.PublicKey("Acvyi9HBGmqh3Exe1N4PjBVyY8fokq2AdC6fSLqV6KSo"),
47
+ claimAccount: web3_js_1.PublicKey.default,
48
+ };
49
+ exports.JUPUSD_POOL = {
50
+ mint: new web3_js_1.PublicKey("JuprjznTrTSp2UFa3ZBUFgwdAmtZCq4MQCwysN55USD"),
51
+ lending: new web3_js_1.PublicKey("papYEgeG5uPE4niUWZhihUUzVVotJn1mAWbYo2UBSHi"),
52
+ fTokenMint: new web3_js_1.PublicKey("7GxATsNMnaC88vdwd2t3mwrFuQwwGvmYPrUQ4D6FotXk"),
53
+ tokenReservesLiquidity: new web3_js_1.PublicKey("2tQE8jVR5ezDw3PDa21BNzfyQ14Ug5cTf6n3swJNjkod"),
54
+ supplyPositionOnLiquidity: new web3_js_1.PublicKey("DXFoJruECdEch2KpzLQ2cSpxoBSsyg4bpYPnHYofsbD4"),
55
+ rewardsRateModel: new web3_js_1.PublicKey("E3U32h49TL9Qof3NeLja9qJxTrGYpY1o1NQPtrSLJjcc"),
56
+ vault: new web3_js_1.PublicKey("9kGqd5zsQGaFfFPdUuEgbRM4V7x72Jdt7WTS4uRouAQ7"),
57
+ rateModel: new web3_js_1.PublicKey("2hT44GA9r5PiqsbbmqN5CuF7ymtquoEdokRncAs9CVej"),
58
+ claimAccount: web3_js_1.PublicKey.default,
59
+ };
60
+ /** Map base mint address → Jupiter Lend pool config */
61
+ exports.JUP_LEND_POOLS = {
62
+ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v": exports.USDC_POOL,
63
+ "So11111111111111111111111111111111111111112": exports.SOL_POOL,
64
+ "JuprjznTrTSp2UFa3ZBUFgwdAmtZCq4MQCwysN55USD": exports.JUPUSD_POOL,
65
+ };
66
+ // ---------------------------------------------------------------------------
67
+ // Auto-Route Account Builders
68
+ // ---------------------------------------------------------------------------
69
+ /**
70
+ * Build the 17 CPI accounts for Jupiter Lend deposit.
71
+ *
72
+ * Account order matches `jup_lend::deposit_accounts`:
73
+ * [0] signer (strategy_state PDA)
74
+ * [1] depositor_token_account (strategy base ATA)
75
+ * [2] recipient_token_account (strategy fToken ATA)
76
+ * [3] mint (base token mint)
77
+ * [4] lending_admin
78
+ * [5] lending
79
+ * [6] f_token_mint
80
+ * [7] supply_token_reserves_liquidity
81
+ * [8] lending_supply_position_on_liquidity
82
+ * [9] rate_model
83
+ * [10] vault
84
+ * [11] liquidity
85
+ * [12] liquidity_program
86
+ * [13] rewards_rate_model
87
+ * [14] token_program
88
+ * [15] associated_token_program
89
+ * [16] system_program
90
+ */
91
+ function buildJupLendDepositAccounts(pool, signer, depositorTokenAccount, recipientTokenAccount) {
92
+ return [
93
+ { pubkey: signer, isSigner: true, isWritable: true },
94
+ { pubkey: depositorTokenAccount, isSigner: false, isWritable: true },
95
+ { pubkey: recipientTokenAccount, isSigner: false, isWritable: true },
96
+ { pubkey: pool.mint, isSigner: false, isWritable: false },
97
+ { pubkey: exports.LENDING_ADMIN, isSigner: false, isWritable: false },
98
+ { pubkey: pool.lending, isSigner: false, isWritable: true },
99
+ { pubkey: pool.fTokenMint, isSigner: false, isWritable: true },
100
+ { pubkey: pool.tokenReservesLiquidity, isSigner: false, isWritable: true },
101
+ { pubkey: pool.supplyPositionOnLiquidity, isSigner: false, isWritable: true },
102
+ { pubkey: pool.rateModel, isSigner: false, isWritable: false },
103
+ { pubkey: pool.vault, isSigner: false, isWritable: true },
104
+ { pubkey: exports.LIQUIDITY_SINGLETON, isSigner: false, isWritable: true },
105
+ { pubkey: exports.LIQUIDITY_PROGRAM_ID, isSigner: false, isWritable: false },
106
+ { pubkey: pool.rewardsRateModel, isSigner: false, isWritable: false },
107
+ { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
108
+ { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
109
+ { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
110
+ ];
111
+ }
112
+ /**
113
+ * Build the full auto-route remaining_accounts for Jupiter Lend deposit.
114
+ *
115
+ * Returns [jup_lend_program, ...17 CPI accounts] = 18 accounts total.
116
+ * This is what p-stv-core's `sweep_to_lend` forwards to elemental-lend's deposit.
117
+ */
118
+ function buildJupLendAutoRouteAccounts(pool, strategyStatePda, strategyBaseAta, strategyFtokenAta) {
119
+ return [
120
+ // [0] Protocol program (identifies the route)
121
+ { pubkey: constants_1.JUP_LEND_EARN_PROGRAM, isSigner: false, isWritable: false },
122
+ // [1..18] Full CPI account array
123
+ ...buildJupLendDepositAccounts(pool, strategyStatePda, strategyBaseAta, strategyFtokenAta),
124
+ ];
125
+ }
126
+ // ---------------------------------------------------------------------------
127
+ // Withdraw / Auto-Unroute Account Builders
128
+ // ---------------------------------------------------------------------------
129
+ /**
130
+ * Build the 18 CPI accounts for Jupiter Lend withdraw.
131
+ *
132
+ * Account order matches `jup_lend::withdraw_accounts`:
133
+ * [0] signer (strategy_state PDA)
134
+ * [1] owner_token_account (fToken ATA — source, fTokens burned)
135
+ * [2] recipient_token_account (base ATA — destination, receives base)
136
+ * [3] lending_admin
137
+ * [4] lending
138
+ * [5] mint (base token mint)
139
+ * [6] f_token_mint
140
+ * [7] supply_token_reserves_liquidity
141
+ * [8] lending_supply_position_on_liquidity
142
+ * [9] rate_model
143
+ * [10] vault
144
+ * [11] claim_account
145
+ * [12] liquidity
146
+ * [13] liquidity_program
147
+ * [14] rewards_rate_model
148
+ * [15] token_program
149
+ * [16] associated_token_program
150
+ * [17] system_program
151
+ */
152
+ function buildJupLendWithdrawAccounts(pool, signer, ownerTokenAccount, recipientTokenAccount) {
153
+ return [
154
+ { pubkey: signer, isSigner: true, isWritable: true },
155
+ { pubkey: ownerTokenAccount, isSigner: false, isWritable: true },
156
+ { pubkey: recipientTokenAccount, isSigner: false, isWritable: true },
157
+ { pubkey: exports.LENDING_ADMIN, isSigner: false, isWritable: false },
158
+ { pubkey: pool.lending, isSigner: false, isWritable: true },
159
+ { pubkey: pool.mint, isSigner: false, isWritable: false },
160
+ { pubkey: pool.fTokenMint, isSigner: false, isWritable: true },
161
+ { pubkey: pool.tokenReservesLiquidity, isSigner: false, isWritable: true },
162
+ { pubkey: pool.supplyPositionOnLiquidity, isSigner: false, isWritable: true },
163
+ { pubkey: pool.rateModel, isSigner: false, isWritable: false },
164
+ { pubkey: pool.vault, isSigner: false, isWritable: true },
165
+ // claim_account: on-chain CPI hardcodes this as writable (AccountMeta::new),
166
+ // so we can't pass System Program (PublicKey.default). Use vault as safe placeholder.
167
+ { pubkey: pool.claimAccount.equals(web3_js_1.PublicKey.default) ? pool.vault : pool.claimAccount, isSigner: false, isWritable: true },
168
+ { pubkey: exports.LIQUIDITY_SINGLETON, isSigner: false, isWritable: true },
169
+ { pubkey: exports.LIQUIDITY_PROGRAM_ID, isSigner: false, isWritable: false },
170
+ { pubkey: pool.rewardsRateModel, isSigner: false, isWritable: false },
171
+ { pubkey: spl_token_1.TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
172
+ { pubkey: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
173
+ { pubkey: web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false },
174
+ ];
175
+ }
176
+ /**
177
+ * Build the full auto-unroute remaining_accounts for Jupiter Lend withdraw.
178
+ *
179
+ * Returns [jup_lend_program, ...18 CPI accounts] = 19 accounts total.
180
+ * This is what p-stv-core's `unsweep_from_lend` forwards to elemental-lend's withdraw.
181
+ */
182
+ function buildJupLendAutoUnrouteAccounts(pool, strategyStatePda, strategyFtokenAta, strategyBaseAta) {
183
+ return [
184
+ // [0] Protocol program (identifies the route)
185
+ { pubkey: constants_1.JUP_LEND_EARN_PROGRAM, isSigner: false, isWritable: false },
186
+ // [1..19] Full CPI account array
187
+ ...buildJupLendWithdrawAccounts(pool, strategyStatePda, strategyFtokenAta, strategyBaseAta),
188
+ ];
189
+ }