@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,637 @@
1
+ import { PublicKey, TransactionInstruction, AccountMeta } from "@solana/web3.js";
2
+ import BN from "bn.js";
3
+ export interface InitOrUpdateConfigArgs {
4
+ admin: PublicKey;
5
+ payer: PublicKey;
6
+ config: PublicKey;
7
+ systemProgram?: PublicKey;
8
+ bump: number;
9
+ newAdmin?: PublicKey;
10
+ newFlags?: number;
11
+ }
12
+ export declare function createInitOrUpdateConfigIx(args: InitOrUpdateConfigArgs, programId?: PublicKey): TransactionInstruction;
13
+ export interface InitOrUpdateStvArgs {
14
+ admin: PublicKey;
15
+ payer: PublicKey;
16
+ config: PublicKey;
17
+ stv: PublicKey;
18
+ evMint: PublicKey;
19
+ baseMint: PublicKey;
20
+ vaultAta: PublicKey;
21
+ /** Canonical ATA for feeReceiver + evMint, pinned on STV. */
22
+ feeReceiverEvAta: PublicKey;
23
+ tokenProgram: PublicKey;
24
+ ataProgram?: PublicKey;
25
+ systemProgram?: PublicKey;
26
+ vaultId: number | BN;
27
+ stvBump: number;
28
+ evMintBump: number;
29
+ feeReceiver?: PublicKey;
30
+ strategy?: PublicKey;
31
+ epochSec?: number;
32
+ mgmtFeeBps?: number;
33
+ perfFeeBps?: number;
34
+ vaultCapacity?: BN | number;
35
+ minDeposit?: BN | number;
36
+ flags?: number;
37
+ addStrategy?: PublicKey;
38
+ removeStrategy?: PublicKey;
39
+ lendProgram?: PublicKey;
40
+ /** Max % of AUM claimable per epoch window (BPS, 0 = unlimited, max 10000) */
41
+ dailyWithdrawLimitBps?: number;
42
+ /** Migrate-in fee (BPS, max MAX_FEE_BPS=1000). Applied when FLAG_DEPOSIT_FEE_ON_MIGRATE set. */
43
+ depositFeeBps?: number;
44
+ /** Migrate-out fee (BPS, max MAX_FEE_BPS=1000). Applied when FLAG_WITHDRAWAL_FEE_ON_MIGRATE set. */
45
+ withdrawalFeeBps?: number;
46
+ /**
47
+ * Withdrawal mode: 0=instant, 1=X, 2=X+1. CREATE-ONLY — immutable after the STV
48
+ * exists (the handler rejects a change on update). Instant (0) additionally
49
+ * requires a C-1 seed floor and a non-allocator vault.
50
+ */
51
+ withdrawalMode?: number;
52
+ /**
53
+ * CREATE path (STV does not yet exist): REQUIRED. Per-vault admin pubkey. Must be
54
+ * nonzero — the handler rejects zero / None. The global admin is the signer here;
55
+ * vaultAdmin can be a different key (e.g. a Squads multi-sig vault PDA).
56
+ *
57
+ * Wire encoding: `0x01 + 32 bytes` (Some(nonzero)). The handler will reject
58
+ * `None` (0x00) and `Some([0;32])` with `InvalidParameter`.
59
+ *
60
+ * MUST NOT be supplied together with `pendingAdmin` — they share the same wire
61
+ * position but are branch-interpreted. Pass exactly one of the two.
62
+ */
63
+ vaultAdmin?: PublicKey;
64
+ /**
65
+ * UPDATE path (STV already exists): three-value encoding matching the handler:
66
+ * undefined / not provided → None → no change to pending rotation
67
+ * PublicKey.default ([0u8;32]) → Some([0;32]) → cancel pending rotation
68
+ * any nonzero PublicKey → Some(nonzero) → start/replace rotation; emits AdminRotationStarted
69
+ *
70
+ * Wire encoding: `0x00` (None) or `0x01 + 32 bytes` (Some).
71
+ * ONLY `accept_vault_admin` may change `stv.coldAdmin` post-create/migration.
72
+ * A pending admin has ZERO authority before accept.
73
+ *
74
+ * MUST NOT be supplied together with `vaultAdmin` — they share the same wire
75
+ * position but are branch-interpreted. Pass exactly one of the two.
76
+ */
77
+ pendingAdmin?: PublicKey;
78
+ /**
79
+ * Per-vault strategy staleness window in seconds (u32).
80
+ * `0` = use the on-chain default (24 h). `undefined` = omit from wire (no change
81
+ * on update; resolves to 0/default on create because the STV is zero-initialized).
82
+ * Admin is trusted; no range validation on-chain. This is the LAST optional field
83
+ * in the instruction data — old clients that omit it are wire-compatible (program
84
+ * sees EOF -> None -> no change). Wire: 0x00 (absent) or 0x01 + 4 bytes LE (present).
85
+ */
86
+ strategyStalenessThreshold?: number;
87
+ /**
88
+ * Warm admin (offset 476 in v2 layout). Operational authority:
89
+ * `add_manager`, `remove_manager`, `override_claim_withdraw`,
90
+ * `trip_circuit_breaker` — NOT this instruction / `close_stv` / `seed_stv`
91
+ * / `migrate_lend` (cold-only). See docs/spec-warm-admin-guardrails.md §2-3.
92
+ *
93
+ * CREATE path (`vaultAdmin` supplied): `undefined` / `PublicKey.default`
94
+ * (`[0u8;32]`) / a value equal to `vaultAdmin` all normalize on-chain to
95
+ * the `[0;32]` "follow cold" sentinel (no split — warm tracks the vault's
96
+ * cold admin automatically, including across future
97
+ * `accept_vault_admin` rotations). Any other nonzero key is stored as an
98
+ * explicit split warm admin.
99
+ *
100
+ * UPDATE path (`pendingAdmin` position in use, or neither admin arg
101
+ * supplied): `undefined` → no change to the stored warm admin.
102
+ * `PublicKey.default` → reset to the follow-cold sentinel (undoes a
103
+ * split). A value equal to the CURRENT on-chain `stv.coldAdmin` → normalizes
104
+ * to the sentinel (same invariant). Any other nonzero key → sets
105
+ * `stv.warm_admin` directly (cold is superior and can always re-set; no
106
+ * two-step). Only the cold admin (the update-path signer) can reach this
107
+ * — warm cannot rotate itself.
108
+ *
109
+ * Wire position: appended LAST, immediately after
110
+ * `strategyStalenessThreshold` — preserves every earlier optional's wire
111
+ * position (spec-warm-admin-guardrails.md §3 wire-format table). Wire:
112
+ * `0x00` (None / no-change) or `0x01 + 32 bytes` (Some). Like every other
113
+ * optional field in this builder, the tag byte is ALWAYS emitted
114
+ * (`undefined` still serializes an explicit `0x00`, never a true
115
+ * end-of-data omission) — a pre-this-field client that stops before this
116
+ * position is still wire-compatible, since the on-chain parser treats EOF
117
+ * identically to an explicit `0x00`.
118
+ *
119
+ * PRE-DEPLOY CAVEAT: the currently-deployed mainnet program does not parse
120
+ * this field yet (predates the warm-admin-guardrails upgrade) — extra
121
+ * trailing bytes sent against the old program are simply never read
122
+ * (inert), so building this shape ahead of the upgrade is safe but has no
123
+ * effect until the program is upgraded.
124
+ */
125
+ warmAdmin?: PublicKey;
126
+ /**
127
+ * Lend-activation path: when `lendProgram` is set on a CREATE (or on an UPDATE
128
+ * that activates lend for the first time), the handler CPIs `lend.init_position`
129
+ * and consumes the first two remaining_accounts as:
130
+ * remaining[0] = lend_strategy_state (readonly, owned by lendProgram)
131
+ * remaining[1] = lend_position_pda (writable, to be initialised)
132
+ *
133
+ * Supply these via `lendInitAccounts` and they will be prepended to
134
+ * `remainingAccounts`. If `lendProgram` is set but neither `lendInitAccounts`
135
+ * nor the equivalent entries in `remainingAccounts` are provided, the
136
+ * instruction will fail on-chain with `IncompleteStrategyAccounts`.
137
+ */
138
+ lendInitAccounts?: {
139
+ /** LendStrategyState PDA (readonly). Must be owned by lendProgram. */
140
+ lendStrategyState: PublicKey;
141
+ /** StvPosition PDA to initialise (writable). */
142
+ lendPositionPda: PublicKey;
143
+ };
144
+ remainingAccounts?: AccountMeta[];
145
+ }
146
+ export declare function createInitOrUpdateStvIx(args: InitOrUpdateStvArgs, programId?: PublicKey): TransactionInstruction;
147
+ export interface DepositArgs {
148
+ user: PublicKey;
149
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
150
+ config: PublicKey;
151
+ stv: PublicKey;
152
+ vaultAta: PublicKey;
153
+ userBaseAta: PublicKey;
154
+ userEvAta: PublicKey;
155
+ evMint: PublicKey;
156
+ feeReceiverEvAta: PublicKey;
157
+ baseMint: PublicKey;
158
+ tokenProgram: PublicKey;
159
+ amount: BN | number;
160
+ minShares: BN | number;
161
+ /** Number of protocol AUM accounts in remaining_accounts (after 4 lend accounts) */
162
+ protocolAumCount?: number;
163
+ /** Number of auto-route accounts in remaining_accounts (after strategy pairs) */
164
+ autoRouteCount?: number;
165
+ /** DelayedDepositRequest PDA. Required when the STV has FLAG_DELAYED_DEPOSIT set. */
166
+ delayedDepositRequest?: PublicKey;
167
+ /** PDA bump for delayedDepositRequest. Required when delayedDepositRequest is passed. */
168
+ delayedDepositBump?: number;
169
+ /** System program. Required for delayed deposits because the request PDA may be created. */
170
+ systemProgram?: PublicKey;
171
+ remainingAccounts?: AccountMeta[];
172
+ }
173
+ export declare function createDepositIx(args: DepositArgs, programId?: PublicKey): TransactionInstruction;
174
+ export interface RequestWithdrawArgs {
175
+ user: PublicKey;
176
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
177
+ config: PublicKey;
178
+ stv: PublicKey;
179
+ withdrawRequest: PublicKey;
180
+ userEvAta: PublicKey;
181
+ escrowEvAta: PublicKey;
182
+ evMint: PublicKey;
183
+ tokenProgram: PublicKey;
184
+ systemProgram?: PublicKey;
185
+ shares: BN | number;
186
+ wrBump: number;
187
+ }
188
+ export declare function createRequestWithdrawIx(args: RequestWithdrawArgs, programId?: PublicKey): TransactionInstruction;
189
+ export interface ClaimWithdrawArgs {
190
+ user: PublicKey;
191
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
192
+ config: PublicKey;
193
+ stv: PublicKey;
194
+ withdrawRequest: PublicKey;
195
+ vaultAta: PublicKey;
196
+ userBaseAta: PublicKey;
197
+ /** Fee receiver's base-mint ATA. Required even when withdrawalFeeBps == 0. */
198
+ feeReceiverBaseAta: PublicKey;
199
+ baseMint: PublicKey;
200
+ tokenProgram: PublicKey;
201
+ remainingAccounts?: AccountMeta[];
202
+ /** Number of auto-unroute accounts appended after lend accounts (0 = no auto-unroute) */
203
+ autoUnrouteCount?: number;
204
+ /**
205
+ * Number of protocol-AUM accounts (kVault 2 / Jupiter 3 per protocol) placed in
206
+ * remainingAccounts AFTER the 4 fixed lend accounts and BEFORE the auto-unroute
207
+ * accounts. Feeds the pre-unsweep update_aum refresh. MUST equal the lend strategy's
208
+ * live protocol set when lend has protocols (lend reverts an incomplete tail);
209
+ * pass 0 only when the lend strategy has no protocols.
210
+ */
211
+ protocolAumCount?: number;
212
+ }
213
+ export declare function createClaimWithdrawIx(args: ClaimWithdrawArgs, programId?: PublicKey): TransactionInstruction;
214
+ export interface OverrideClaimWithdrawArgs {
215
+ /** Cold admin (stv.coldAdmin) or warm admin (stv.warmAdminEffective()). Manager is hard-cut — no ManagerRole account. */
216
+ authority: PublicKey;
217
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
218
+ config: PublicKey;
219
+ /** WithdrawRequest owner. NOT a signer — authority acts on their behalf. */
220
+ user: PublicKey;
221
+ stv: PublicKey;
222
+ withdrawRequest: PublicKey;
223
+ vaultAta: PublicKey;
224
+ userBaseAta: PublicKey;
225
+ /** Fee receiver's base-mint ATA. Required even when withdrawalFeeBps == 0. */
226
+ feeReceiverBaseAta: PublicKey;
227
+ baseMint: PublicKey;
228
+ tokenProgram: PublicKey;
229
+ remainingAccounts?: AccountMeta[];
230
+ autoUnrouteCount?: number;
231
+ /** Protocol-AUM accounts count for the pre-unsweep refresh — see ClaimWithdrawArgs. */
232
+ protocolAumCount?: number;
233
+ }
234
+ export declare function createOverrideClaimWithdrawIx(args: OverrideClaimWithdrawArgs, programId?: PublicKey): TransactionInstruction;
235
+ export interface ProcessEpochArgs {
236
+ payer: PublicKey;
237
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
238
+ config: PublicKey;
239
+ stv: PublicKey;
240
+ evMint: PublicKey;
241
+ feeReceiverEvAta: PublicKey;
242
+ escrowEvAta: PublicKey;
243
+ vaultAta: PublicKey;
244
+ tokenProgram: PublicKey;
245
+ advanceEpoch: boolean;
246
+ /** Number of protocol AUM accounts in remaining_accounts (after 4 lend accounts) */
247
+ protocolAumCount?: number;
248
+ remainingAccounts?: AccountMeta[];
249
+ }
250
+ export declare function createProcessEpochIx(args: ProcessEpochArgs, programId?: PublicKey): TransactionInstruction;
251
+ export interface ProcessDelayedDepositArgs {
252
+ payer: PublicKey;
253
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
254
+ config: PublicKey;
255
+ stv: PublicKey;
256
+ delayedDepositRequest: PublicKey;
257
+ /** User account stored on the delayed deposit request; receives closed-account rent. */
258
+ user: PublicKey;
259
+ vaultAta: PublicKey;
260
+ userEvAta: PublicKey;
261
+ evMint: PublicKey;
262
+ feeReceiverEvAta: PublicKey;
263
+ tokenProgram: PublicKey;
264
+ /** Number of protocol AUM accounts in remaining_accounts (after 4 lend accounts) */
265
+ protocolAumCount?: number;
266
+ remainingAccounts?: AccountMeta[];
267
+ }
268
+ export declare function createProcessDelayedDepositIx(args: ProcessDelayedDepositArgs, programId?: PublicKey): TransactionInstruction;
269
+ export interface DepositToStrategyArgs {
270
+ manager: PublicKey;
271
+ managerRole: PublicKey;
272
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
273
+ config: PublicKey;
274
+ stv: PublicKey;
275
+ vaultAta: PublicKey;
276
+ baseMint: PublicKey;
277
+ strategyProgram: PublicKey;
278
+ strategyState: PublicKey;
279
+ stvPosition: PublicKey;
280
+ strategyBaseAta: PublicKey;
281
+ tokenProgram: PublicKey;
282
+ amount: BN | number;
283
+ minShares: BN | number;
284
+ /**
285
+ * Number of protocol AUM accounts (kVault: 2/protocol, Jupiter Lend: 3/protocol)
286
+ * used by update_lend_aum for fresh lend valuation before the reserved_base
287
+ * liquidity lock check. Always required (0 if lend has no active protocols).
288
+ */
289
+ protocolAumCount: number;
290
+ /** Number of auto-unroute accounts appended after protocol accounts (0 = no auto-unroute) */
291
+ autoUnrouteCount?: number;
292
+ remainingAccounts?: AccountMeta[];
293
+ }
294
+ export declare function createDepositToStrategyIx(args: DepositToStrategyArgs, programId?: PublicKey): TransactionInstruction;
295
+ export interface WithdrawFromStrategyArgs {
296
+ manager: PublicKey;
297
+ managerRole: PublicKey;
298
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
299
+ config: PublicKey;
300
+ stv: PublicKey;
301
+ vaultAta: PublicKey;
302
+ baseMint: PublicKey;
303
+ strategyProgram: PublicKey;
304
+ strategyState: PublicKey;
305
+ stvPosition: PublicKey;
306
+ strategyBaseAta: PublicKey;
307
+ tokenProgram: PublicKey;
308
+ shares: BN | number;
309
+ /**
310
+ * remainingAccounts when lend is active: [4 fixed lend, protocolAumCount protocol-AUM
311
+ * accounts]. The protocol-AUM accounts feed the pre-sweep update_aum refresh so the
312
+ * swept base mints lend shares at a fresh pps. Pass 0 only when lend has no protocols.
313
+ */
314
+ protocolAumCount?: number;
315
+ remainingAccounts?: AccountMeta[];
316
+ }
317
+ export declare function createWithdrawFromStrategyIx(args: WithdrawFromStrategyArgs, programId?: PublicKey): TransactionInstruction;
318
+ export interface CloseStvArgs {
319
+ admin: PublicKey;
320
+ payer: PublicKey;
321
+ config: PublicKey;
322
+ stv: PublicKey;
323
+ evMint: PublicKey;
324
+ vaultAta: PublicKey;
325
+ tokenProgram: PublicKey;
326
+ /** canonical ATA(stv_pda, ev_mint) — escrow holding seed shares. */
327
+ escrowEvAta?: PublicKey;
328
+ baseMint?: PublicKey;
329
+ /** ATA(admin, base_mint) — receives drained seed base. */
330
+ adminBaseAta?: PublicKey;
331
+ strategyProgram?: PublicKey;
332
+ stvPosition?: PublicKey;
333
+ }
334
+ export declare function createCloseStvIx(args: CloseStvArgs, programId?: PublicKey): TransactionInstruction;
335
+ export interface AddManagerArgs {
336
+ /** Cold admin (stv.coldAdmin) or warm admin (stv.warmAdminEffective()). NOT the global config admin. */
337
+ admin: PublicKey;
338
+ payer: PublicKey;
339
+ config: PublicKey;
340
+ stv: PublicKey;
341
+ managerRole: PublicKey;
342
+ managerRoleBump: number;
343
+ manager: PublicKey;
344
+ systemProgram?: PublicKey;
345
+ }
346
+ export declare function createAddManagerIx(args: AddManagerArgs, programId?: PublicKey): TransactionInstruction;
347
+ export interface RemoveManagerArgs {
348
+ /**
349
+ * Must be the per-vault cold admin (stv.coldAdmin) or warm admin
350
+ * (stv.warmAdminEffective()). NOT the global config admin.
351
+ */
352
+ admin: PublicKey;
353
+ payer: PublicKey;
354
+ /** STV PDA — required for vault-admin auth check (cold or warm admin). */
355
+ stv: PublicKey;
356
+ managerRole: PublicKey;
357
+ }
358
+ export declare function createRemoveManagerIx(args: RemoveManagerArgs, programId?: PublicKey): TransactionInstruction;
359
+ export interface MigrateLendArgs {
360
+ admin: PublicKey;
361
+ payer: PublicKey;
362
+ config: PublicKey;
363
+ stv: PublicKey;
364
+ vaultAta: PublicKey;
365
+ baseMint: PublicKey;
366
+ tokenProgram: PublicKey;
367
+ systemProgram?: PublicKey;
368
+ /** Current lend program — must match stv.lend_program on-chain. */
369
+ oldLendProgram: PublicKey;
370
+ /** New lend program (PublicKey.default to deactivate lend entirely). */
371
+ newLendProgram: PublicKey;
372
+ /** Protocol AUM accounts for old lend update_aum. */
373
+ protocolAumCount: number;
374
+ /** Auto-unroute accounts for old lend withdraw. */
375
+ autoUnrouteCount: number;
376
+ /**
377
+ * Protocol-AUM accounts for the NEW lend's pre-sweep update_aum refresh, trailing
378
+ * the 4 fixed new-lend accounts in the new section. Pass 0 when deactivating lend or
379
+ * when the new lend has no protocols (else lend reverts an incomplete tail).
380
+ */
381
+ newProtocolAumCount?: number;
382
+ /**
383
+ * remaining_accounts layout:
384
+ * Old section (4 + protocolAumCount + autoUnrouteCount):
385
+ * [oldLendProgram, oldStrategyState, oldStvPosition, oldBaseAta,
386
+ * ...protocolAumAccounts, ...autoUnrouteAccounts]
387
+ * New section (if newLendProgram != default):
388
+ * [newLendProgram, newStrategyState, newPositionPda, newBaseAta,
389
+ * ...newProtocolAumAccounts (count = newProtocolAumCount, for the pre-sweep refresh)]
390
+ */
391
+ remainingAccounts?: AccountMeta[];
392
+ }
393
+ export declare function createMigrateLendIx(args: MigrateLendArgs, programId?: PublicKey): TransactionInstruction;
394
+ export interface MigrateRequestArgs {
395
+ /** The LP migrating (signer, writable). */
396
+ user: PublicKey;
397
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED. */
398
+ config: PublicKey;
399
+ /** STV migrating FROM (writable). */
400
+ sourceStv: PublicKey;
401
+ /** STV migrating TO (read-only; base_mint must match source). */
402
+ destStv: PublicKey;
403
+ /** Source STV's evX mint. */
404
+ evMint: PublicKey;
405
+ /** User's source evX token account (writable). */
406
+ userEvAta: PublicKey;
407
+ /** Source STV escrow evX account, owner = source_stv PDA (writable). */
408
+ escrowEvAta: PublicKey;
409
+ /** Migrate-kind WithdrawRequest PDA to initialize — use findMigrateRequestPda. */
410
+ migrateRequest: PublicKey;
411
+ tokenProgram: PublicKey;
412
+ systemProgram?: PublicKey;
413
+ /** evX shares to migrate. */
414
+ shares: BN | number;
415
+ /** Bump for the migrate_request PDA (findMigrateRequestPda[1]). */
416
+ wrBump: number;
417
+ /** Minimum dest shares accepted at execute time (slippage floor; 0 = none). */
418
+ minDestShares: BN | number;
419
+ }
420
+ /**
421
+ * Instruction data layout (17 bytes, after the 1-byte disc is stripped by the
422
+ * dispatcher): shares(u64 LE) + wr_bump(u8) + min_dest_shares(u64 LE).
423
+ * Confirmed against migrate_request.rs:53-66.
424
+ */
425
+ export declare function createMigrateRequestIx(args: MigrateRequestArgs, programId?: PublicKey): TransactionInstruction;
426
+ export interface MigrateExecuteArgs {
427
+ /** Any signer. Permissionless — no ManagerRole required. */
428
+ caller: PublicKey;
429
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED. */
430
+ config: PublicKey;
431
+ sourceStv: PublicKey;
432
+ destStv: PublicKey;
433
+ /** Migrate-kind WithdrawRequest PDA (writable, program-owned). */
434
+ wrAccount: PublicKey;
435
+ sourceVaultAta: PublicKey;
436
+ destVaultAta: PublicKey;
437
+ destEvMint: PublicKey;
438
+ /** WR user's dest evX ATA (mint = dest ev_mint, owner = wr.user). */
439
+ userDestEvAta: PublicKey;
440
+ /** Source fee receiver's base ATA (withdrawal fee). */
441
+ sourceFeeRecvAta: PublicKey;
442
+ /** Dest fee receiver's evX ATA (deposit fee). */
443
+ destFeeRecvEvAta: PublicKey;
444
+ baseMint: PublicKey;
445
+ tokenProgram: PublicKey;
446
+ /** Account that receives the WR rent on close — must equal wr.user (slot 13). */
447
+ wrUserAccount: PublicKey;
448
+ /** Source-lend protocol AUM account count for update_aum. */
449
+ srcProtocolAumCount: number;
450
+ /** Dest-lend protocol AUM account count for update_aum. */
451
+ dstProtocolAumCount: number;
452
+ /** Source-lend auto-unroute account count (withdraw deficit). */
453
+ srcAutoUnrouteCount: number;
454
+ /** Dest-lend auto-route account count (sweep). */
455
+ dstAutoRouteCount: number;
456
+ /**
457
+ * Deferred path (dest has FLAG_DELAYED_DEPOSIT and FLAG_BYPASS_MIGRATE_DST_WAITOUT
458
+ * is unset): pass the DelayedDepositRequest PDA (writable, new account).
459
+ * The PDA is appended as the last two remaining_accounts after the normal
460
+ * lend/strategy accounts: [dest_delayed_request(w), system_program].
461
+ * Also requires destDelayedBump (the bump for the new PDA).
462
+ */
463
+ destDelayedRequest?: PublicKey;
464
+ destDelayedBump?: number;
465
+ systemProgram?: PublicKey;
466
+ /**
467
+ * remaining_accounts (assemble with buildMigrateRemainingAccounts):
468
+ * src lend fixed(4) + src protocol AUM(srcProtocolAumCount)
469
+ * + src auto-unroute(srcAutoUnrouteCount)
470
+ * + dst lend fixed(4) + dst protocol AUM(dstProtocolAumCount)
471
+ * + dst strategy pairs(0 or 2) + dst auto-route(dstAutoRouteCount)
472
+ * Omit a lend section entirely when that side's lend_program is unset.
473
+ * Do NOT include dest_delayed_request/system_program here — pass them via
474
+ * destDelayedRequest/systemProgram instead; they are appended automatically.
475
+ */
476
+ remainingAccounts?: AccountMeta[];
477
+ }
478
+ /**
479
+ * 14 fixed accounts (migrate_execute.rs:97 destructure). Permissionless.
480
+ * Instruction data: 4 bytes always; 5th byte (dest_delayed_bump) required
481
+ * on the deferred path (migrate_execute.rs:104-114 / 387-401).
482
+ */
483
+ export declare function createMigrateExecuteIx(args: MigrateExecuteArgs, programId?: PublicKey): TransactionInstruction;
484
+ export interface MigrateCancelArgs {
485
+ /** Must equal wr.user. Signer + writable (receives WR rent back). */
486
+ user: PublicKey;
487
+ /** GlobalConfig PDA. */
488
+ config: PublicKey;
489
+ /** Source STV (writable). */
490
+ stv: PublicKey;
491
+ /** Migrate-kind WithdrawRequest PDA (writable). */
492
+ wrAccount: PublicKey;
493
+ /** Canonical vault ATA (writable). */
494
+ vaultAta: PublicKey;
495
+ /** User's base token ATA (receives base). */
496
+ userBaseAta: PublicKey;
497
+ /** Fee receiver's base ATA. */
498
+ feeReceiverBaseAta: PublicKey;
499
+ baseMint: PublicKey;
500
+ tokenProgram: PublicKey;
501
+ /** Lend auto-unroute accounts (0 = none). */
502
+ autoUnrouteCount?: number;
503
+ /** Lend protocol AUM accounts (0 = none). */
504
+ protocolAumCount?: number;
505
+ remainingAccounts?: AccountMeta[];
506
+ }
507
+ export declare function createMigrateCancelIx(args: MigrateCancelArgs, programId?: PublicKey): TransactionInstruction;
508
+ export declare function buildLendRemainingAccounts(lend: {
509
+ lendProgram: PublicKey;
510
+ lendStrategyState: PublicKey;
511
+ lendStvPosition: PublicKey;
512
+ lendBaseAta: PublicKey;
513
+ }): AccountMeta[];
514
+ /**
515
+ * Assemble the migrate_execute remaining_accounts in the exact order
516
+ * parse_lend_accounts expects (migrate_execute.rs:298-338):
517
+ *
518
+ * [ source-lend section ] src.lend(4 fixed) + src.protocolAum(P_src)
519
+ * [ source auto-unroute ] src.autoUnroute (U accounts)
520
+ * [ dest-lend section ] dst.lend(4 fixed) + dst.protocolAum(P_dst)
521
+ * [ dest strategy + route] dst.strategy(0 or 2) + dst.autoRoute (R accounts)
522
+ *
523
+ * Pass `undefined` for a `lend` side whose STV has no lend_program (the 4
524
+ * fixed accounts + protocol AUM are omitted, matching the early return in
525
+ * parse_lend_accounts when lend_program_key == default).
526
+ *
527
+ * The 4 fixed lend accounts mirror `buildLendRemainingAccounts`:
528
+ * [lendProgram(ro), lendStrategyState(w), lendStvPosition(w), lendBaseAta(w)]
529
+ * `protocolAum` / `autoUnroute` / `autoRoute` / `strategy` accounts are passed
530
+ * through verbatim; the caller sets their writable flags per protocol.
531
+ */
532
+ export declare function buildMigrateRemainingAccounts(opts: {
533
+ source: {
534
+ lend?: {
535
+ lendProgram: PublicKey;
536
+ lendStrategyState: PublicKey;
537
+ lendStvPosition: PublicKey;
538
+ lendBaseAta: PublicKey;
539
+ };
540
+ protocolAum?: AccountMeta[];
541
+ autoUnroute?: AccountMeta[];
542
+ };
543
+ dest: {
544
+ lend?: {
545
+ lendProgram: PublicKey;
546
+ lendStrategyState: PublicKey;
547
+ lendStvPosition: PublicKey;
548
+ lendBaseAta: PublicKey;
549
+ };
550
+ protocolAum?: AccountMeta[];
551
+ /** Dest strategy pair [strategyState(w), stvPosition(ro)] when dest has a strategy. */
552
+ strategy?: {
553
+ strategyState: PublicKey;
554
+ stvPosition: PublicKey;
555
+ };
556
+ autoRoute?: AccountMeta[];
557
+ };
558
+ }): AccountMeta[];
559
+ export declare function buildStrategyRemainingAccounts(strategies: {
560
+ strategyState: PublicKey;
561
+ stvPosition: PublicKey;
562
+ }[]): AccountMeta[];
563
+ export interface InstantWithdrawArgs {
564
+ user: PublicKey;
565
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
566
+ config: PublicKey;
567
+ stv: PublicKey;
568
+ /** canonical ATA(stv, base_mint) */
569
+ vaultAta: PublicKey;
570
+ /** ATA(user, base_mint) — receives net_base */
571
+ userBaseAta: PublicKey;
572
+ /** ATA(stv.fee_receiver, base_mint) */
573
+ feeReceiverBaseAta: PublicKey;
574
+ /** pinned fee-receiver evX ATA — settle_fees mints fee shares here */
575
+ feeReceiverEvAta: PublicKey;
576
+ baseMint: PublicKey;
577
+ evMint: PublicKey;
578
+ /** source of the user-signed burn — ATA(user, ev_mint) */
579
+ userEvAta: PublicKey;
580
+ tokenProgram: PublicKey;
581
+ /** evX shares to redeem */
582
+ shares: BN | number;
583
+ /** minimum net base out (slippage floor) — must be > 0 */
584
+ minBaseOut: BN | number;
585
+ /** number of protocol AUM accounts after the 4 fixed lend accounts (0 = none) */
586
+ protocolAumCount?: number;
587
+ /** number of auto-unroute accounts appended after the lend section (0 = none) */
588
+ autoUnrouteCount?: number;
589
+ /**
590
+ * Trailing accounts after token_program, in order:
591
+ * [4 fixed lend + protocolAumCount][strategy_state, stv_position,
592
+ * strategy_program, strategy_base_ata (only if stv.strategy != 0)][auto_unroute]
593
+ */
594
+ remainingAccounts?: AccountMeta[];
595
+ }
596
+ export declare function createInstantWithdrawIx(args: InstantWithdrawArgs, programId?: PublicKey): TransactionInstruction;
597
+ export interface SeedStvArgs {
598
+ /** config.admin; pays escrow-ATA rent */
599
+ admin: PublicKey;
600
+ config: PublicKey;
601
+ stv: PublicKey;
602
+ evMint: PublicKey;
603
+ /** canonical ATA(stv_pda, ev_mint) — created idempotently */
604
+ escrowEvAta: PublicKey;
605
+ /** canonical ATA(stv_pda, base_mint) */
606
+ vaultAta: PublicKey;
607
+ /** ATA(admin, base_mint) — source of the seed base */
608
+ adminBaseAta: PublicKey;
609
+ baseMint: PublicKey;
610
+ tokenProgram: PublicKey;
611
+ ataProgram?: PublicKey;
612
+ systemProgram?: PublicKey;
613
+ /** base to seed; with any pre-donated base, sets the minted seed-share floor */
614
+ amount: BN | number;
615
+ }
616
+ export declare function createSeedStvIx(args: SeedStvArgs, programId?: PublicKey): TransactionInstruction;
617
+ export interface AcceptVaultAdminArgs {
618
+ /** Must equal stv.pending_admin on-chain. Signer proves the new key is live. */
619
+ pendingAdmin: PublicKey;
620
+ /** STV account (writable). */
621
+ stv: PublicKey;
622
+ }
623
+ export declare function createAcceptVaultAdminIx(args: AcceptVaultAdminArgs, programId?: PublicKey): TransactionInstruction;
624
+ export interface TripCircuitBreakerArgs {
625
+ /** Cold admin (stv.coldAdmin), warm admin (stv.warmAdminEffective()), or a valid manager. */
626
+ authority: PublicKey;
627
+ stv: PublicKey;
628
+ /**
629
+ * ManagerRole PDA for (stv, authority). Only required when `authority` is
630
+ * neither the cold nor the warm admin (the manager path) — the on-chain
631
+ * OR-auth precedence means a cold/warm signer succeeds regardless of
632
+ * whether this is supplied. Omit when `authority` is known to be cold or
633
+ * warm.
634
+ */
635
+ managerRole?: PublicKey;
636
+ }
637
+ export declare function createTripCircuitBreakerIx(args: TripCircuitBreakerArgs, programId?: PublicKey): TransactionInstruction;