@elemental-stv-core/sdk 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +250 -0
  3. package/dist/common/ata.d.ts +14 -0
  4. package/dist/common/ata.js +21 -0
  5. package/dist/common/buffer.d.ts +0 -1
  6. package/dist/common/buffer.js +16 -1
  7. package/dist/common/connection.d.ts +13 -0
  8. package/dist/common/connection.js +2 -0
  9. package/dist/common/constants.d.ts +6 -1
  10. package/dist/common/constants.js +21 -2
  11. package/dist/common/index.d.ts +3 -2
  12. package/dist/common/index.js +6 -2
  13. package/dist/common/strategy-interface.d.ts +35 -5
  14. package/dist/common/strategy-interface.js +7 -5
  15. package/dist/elemental-lend/accounts.d.ts +53 -9
  16. package/dist/elemental-lend/accounts.js +66 -8
  17. package/dist/elemental-lend/constants.d.ts +4 -5
  18. package/dist/elemental-lend/constants.js +11 -10
  19. package/dist/elemental-lend/index.d.ts +0 -1
  20. package/dist/elemental-lend/index.js +0 -1
  21. package/dist/elemental-lend/instructions.d.ts +0 -1
  22. package/dist/elemental-lend/instructions.js +0 -1
  23. package/dist/elemental-lend/jupiter-lend.d.ts +0 -1
  24. package/dist/elemental-lend/jupiter-lend.js +2 -3
  25. package/dist/elemental-lend/kamino-vault.d.ts +6 -6
  26. package/dist/elemental-lend/kamino-vault.js +49 -26
  27. package/dist/elemental-lend/pda.d.ts +9 -2
  28. package/dist/elemental-lend/pda.js +10 -3
  29. package/dist/elemental-lend/protocol-actions.d.ts +6 -5
  30. package/dist/elemental-lend/protocol-actions.js +22 -17
  31. package/dist/elemental-lend/types.d.ts +0 -1
  32. package/dist/elemental-lend/types.js +0 -1
  33. package/dist/index.d.ts +0 -1
  34. package/dist/index.js +0 -1
  35. package/dist/jlpd-strategy/accounts.d.ts +64 -11
  36. package/dist/jlpd-strategy/accounts.js +66 -7
  37. package/dist/jlpd-strategy/adapter.d.ts +1 -2
  38. package/dist/jlpd-strategy/adapter.js +1 -2
  39. package/dist/jlpd-strategy/constants.d.ts +21 -13
  40. package/dist/jlpd-strategy/constants.js +31 -27
  41. package/dist/jlpd-strategy/index.d.ts +0 -1
  42. package/dist/jlpd-strategy/index.js +0 -1
  43. package/dist/jlpd-strategy/instructions.d.ts +0 -1
  44. package/dist/jlpd-strategy/instructions.js +0 -1
  45. package/dist/jlpd-strategy/jlp-borrow.d.ts +29 -1
  46. package/dist/jlpd-strategy/jlp-borrow.js +29 -1
  47. package/dist/jlpd-strategy/jlp-data.d.ts +4 -4
  48. package/dist/jlpd-strategy/jlp-data.js +0 -1
  49. package/dist/jlpd-strategy/jupusd-earn.d.ts +31 -6
  50. package/dist/jlpd-strategy/jupusd-earn.js +40 -26
  51. package/dist/jlpd-strategy/pda.d.ts +9 -4
  52. package/dist/jlpd-strategy/pda.js +10 -6
  53. package/dist/jlpd-strategy/settle-yield.d.ts +12 -45
  54. package/dist/jlpd-strategy/settle-yield.js +14 -19
  55. package/dist/jlpd-strategy/swap-jlp.d.ts +4 -4
  56. package/dist/jlpd-strategy/swap-jlp.js +36 -29
  57. package/dist/jlpd-strategy/types.d.ts +5 -4
  58. package/dist/jlpd-strategy/types.js +0 -1
  59. package/dist/p-stv-core/accounts.d.ts +84 -11
  60. package/dist/p-stv-core/accounts.js +108 -30
  61. package/dist/p-stv-core/constants.d.ts +13 -3
  62. package/dist/p-stv-core/constants.js +22 -12
  63. package/dist/p-stv-core/events.d.ts +0 -1
  64. package/dist/p-stv-core/events.js +51 -2
  65. package/dist/p-stv-core/index.d.ts +0 -1
  66. package/dist/p-stv-core/index.js +0 -1
  67. package/dist/p-stv-core/instructions.d.ts +49 -4
  68. package/dist/p-stv-core/instructions.js +46 -14
  69. package/dist/p-stv-core/pda.d.ts +9 -2
  70. package/dist/p-stv-core/pda.js +10 -3
  71. package/dist/p-stv-core/prices.d.ts +0 -1
  72. package/dist/p-stv-core/prices.js +0 -1
  73. package/dist/p-stv-core/remaining-accounts.d.ts +15 -18
  74. package/dist/p-stv-core/remaining-accounts.js +66 -75
  75. package/dist/p-stv-core/send-tx.d.ts +21 -7
  76. package/dist/p-stv-core/send-tx.js +16 -25
  77. package/dist/p-stv-core/sol-wrap.d.ts +0 -1
  78. package/dist/p-stv-core/sol-wrap.js +5 -6
  79. package/dist/p-stv-core/types.d.ts +12 -5
  80. package/dist/p-stv-core/types.js +0 -1
  81. package/package.json +17 -1
  82. package/dist/common/buffer.d.ts.map +0 -1
  83. package/dist/common/buffer.js.map +0 -1
  84. package/dist/common/constants.d.ts.map +0 -1
  85. package/dist/common/constants.js.map +0 -1
  86. package/dist/common/index.d.ts.map +0 -1
  87. package/dist/common/index.js.map +0 -1
  88. package/dist/common/strategy-interface.d.ts.map +0 -1
  89. package/dist/common/strategy-interface.js.map +0 -1
  90. package/dist/elemental-lend/accounts.d.ts.map +0 -1
  91. package/dist/elemental-lend/accounts.js.map +0 -1
  92. package/dist/elemental-lend/constants.d.ts.map +0 -1
  93. package/dist/elemental-lend/constants.js.map +0 -1
  94. package/dist/elemental-lend/index.d.ts.map +0 -1
  95. package/dist/elemental-lend/index.js.map +0 -1
  96. package/dist/elemental-lend/instructions.d.ts.map +0 -1
  97. package/dist/elemental-lend/instructions.js.map +0 -1
  98. package/dist/elemental-lend/jupiter-lend.d.ts.map +0 -1
  99. package/dist/elemental-lend/jupiter-lend.js.map +0 -1
  100. package/dist/elemental-lend/kamino-vault.d.ts.map +0 -1
  101. package/dist/elemental-lend/kamino-vault.js.map +0 -1
  102. package/dist/elemental-lend/pda.d.ts.map +0 -1
  103. package/dist/elemental-lend/pda.js.map +0 -1
  104. package/dist/elemental-lend/protocol-actions.d.ts.map +0 -1
  105. package/dist/elemental-lend/protocol-actions.js.map +0 -1
  106. package/dist/elemental-lend/types.d.ts.map +0 -1
  107. package/dist/elemental-lend/types.js.map +0 -1
  108. package/dist/index.d.ts.map +0 -1
  109. package/dist/index.js.map +0 -1
  110. package/dist/jlpd-strategy/accounts.d.ts.map +0 -1
  111. package/dist/jlpd-strategy/accounts.js.map +0 -1
  112. package/dist/jlpd-strategy/adapter.d.ts.map +0 -1
  113. package/dist/jlpd-strategy/adapter.js.map +0 -1
  114. package/dist/jlpd-strategy/constants.d.ts.map +0 -1
  115. package/dist/jlpd-strategy/constants.js.map +0 -1
  116. package/dist/jlpd-strategy/index.d.ts.map +0 -1
  117. package/dist/jlpd-strategy/index.js.map +0 -1
  118. package/dist/jlpd-strategy/instructions.d.ts.map +0 -1
  119. package/dist/jlpd-strategy/instructions.js.map +0 -1
  120. package/dist/jlpd-strategy/jlp-borrow.d.ts.map +0 -1
  121. package/dist/jlpd-strategy/jlp-borrow.js.map +0 -1
  122. package/dist/jlpd-strategy/jlp-data.d.ts.map +0 -1
  123. package/dist/jlpd-strategy/jlp-data.js.map +0 -1
  124. package/dist/jlpd-strategy/jupusd-earn.d.ts.map +0 -1
  125. package/dist/jlpd-strategy/jupusd-earn.js.map +0 -1
  126. package/dist/jlpd-strategy/pda.d.ts.map +0 -1
  127. package/dist/jlpd-strategy/pda.js.map +0 -1
  128. package/dist/jlpd-strategy/settle-yield.d.ts.map +0 -1
  129. package/dist/jlpd-strategy/settle-yield.js.map +0 -1
  130. package/dist/jlpd-strategy/swap-jlp.d.ts.map +0 -1
  131. package/dist/jlpd-strategy/swap-jlp.js.map +0 -1
  132. package/dist/jlpd-strategy/types.d.ts.map +0 -1
  133. package/dist/jlpd-strategy/types.js.map +0 -1
  134. package/dist/p-stv-core/accounts.d.ts.map +0 -1
  135. package/dist/p-stv-core/accounts.js.map +0 -1
  136. package/dist/p-stv-core/constants.d.ts.map +0 -1
  137. package/dist/p-stv-core/constants.js.map +0 -1
  138. package/dist/p-stv-core/events.d.ts.map +0 -1
  139. package/dist/p-stv-core/events.js.map +0 -1
  140. package/dist/p-stv-core/index.d.ts.map +0 -1
  141. package/dist/p-stv-core/index.js.map +0 -1
  142. package/dist/p-stv-core/instructions.d.ts.map +0 -1
  143. package/dist/p-stv-core/instructions.js.map +0 -1
  144. package/dist/p-stv-core/pda.d.ts.map +0 -1
  145. package/dist/p-stv-core/pda.js.map +0 -1
  146. package/dist/p-stv-core/prices.d.ts.map +0 -1
  147. package/dist/p-stv-core/prices.js.map +0 -1
  148. package/dist/p-stv-core/remaining-accounts.d.ts.map +0 -1
  149. package/dist/p-stv-core/remaining-accounts.js.map +0 -1
  150. package/dist/p-stv-core/send-tx.d.ts.map +0 -1
  151. package/dist/p-stv-core/send-tx.js.map +0 -1
  152. package/dist/p-stv-core/sol-wrap.d.ts.map +0 -1
  153. package/dist/p-stv-core/sol-wrap.js.map +0 -1
  154. package/dist/p-stv-core/types.d.ts.map +0 -1
  155. package/dist/p-stv-core/types.js.map +0 -1
@@ -10,6 +10,7 @@ exports.buildSwapJlpTransaction = buildSwapJlpTransaction;
10
10
  exports.buildRebalanceTransaction = buildRebalanceTransaction;
11
11
  const web3_js_1 = require("@solana/web3.js");
12
12
  const spl_token_1 = require("@solana/spl-token");
13
+ const ata_1 = require("../common/ata");
13
14
  const bn_js_1 = __importDefault(require("bn.js"));
14
15
  const constants_1 = require("./constants");
15
16
  const pda_1 = require("./pda");
@@ -26,15 +27,20 @@ const instructions_2 = require("../elemental-lend/instructions");
26
27
  // Helpers
27
28
  // ---------------------------------------------------------------------------
28
29
  const JUPITER_API_BASE = "https://api.jup.ag/swap/v1";
29
- /** Derive ATA address (same logic as @solana/spl-token getAssociatedTokenAddressSync) */
30
- function findAta(mint, owner, tokenProgram) {
31
- const [ata] = web3_js_1.PublicKey.findProgramAddressSync([owner.toBuffer(), tokenProgram.toBuffer(), mint.toBuffer()], spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
32
- return ata;
33
- }
30
+ /**
31
+ * Optional Jupiter API key, read once at module load time. When set,
32
+ * outbound Jupiter requests include an `x-api-key` header for higher rate
33
+ * limits. Read once instead of per-call so the env var is consistent across
34
+ * the lifetime of the process.
35
+ */
36
+ const JUPITER_API_KEY = process.env.NEXT_PUBLIC_JUPITER_API_KEY;
34
37
  function toBigInt(v) {
35
38
  if (typeof v === "bigint")
36
39
  return v;
37
- return BigInt(v.toString());
40
+ const bn = v;
41
+ if (typeof bn.toBigInt === "function")
42
+ return bn.toBigInt();
43
+ return BigInt(bn.toString());
38
44
  }
39
45
  // ---------------------------------------------------------------------------
40
46
  // Low-level instruction builder
@@ -89,7 +95,6 @@ function createSwapJlpIx(args, programId = constants_1.PROGRAM_ID) {
89
95
  */
90
96
  async function getJupiterSwapQuote(args) {
91
97
  const { inputMint, outputMint, amount, slippageBps = 50, maxAccounts = 40 } = args;
92
- const apiKey = process.env.NEXT_PUBLIC_JUPITER_API_KEY;
93
98
  const params = new URLSearchParams({
94
99
  inputMint: inputMint.toBase58(),
95
100
  outputMint: outputMint.toBase58(),
@@ -99,8 +104,8 @@ async function getJupiterSwapQuote(args) {
99
104
  });
100
105
  const url = `${JUPITER_API_BASE}/quote?${params.toString()}`;
101
106
  const headers = {};
102
- if (apiKey) {
103
- headers["x-api-key"] = apiKey;
107
+ if (JUPITER_API_KEY) {
108
+ headers["x-api-key"] = JUPITER_API_KEY;
104
109
  }
105
110
  const response = await fetch(url, { headers });
106
111
  if (!response.ok) {
@@ -121,7 +126,6 @@ async function getJupiterSwapQuote(args) {
121
126
  */
122
127
  async function getJupiterSwapInstructions(args) {
123
128
  const { quoteResponse, userPublicKey } = args;
124
- const apiKey = process.env.NEXT_PUBLIC_JUPITER_API_KEY;
125
129
  const url = `${JUPITER_API_BASE}/swap-instructions`;
126
130
  const body = {
127
131
  quoteResponse,
@@ -133,8 +137,8 @@ async function getJupiterSwapInstructions(args) {
133
137
  const headers = {
134
138
  "Content-Type": "application/json",
135
139
  };
136
- if (apiKey) {
137
- headers["x-api-key"] = apiKey;
140
+ if (JUPITER_API_KEY) {
141
+ headers["x-api-key"] = JUPITER_API_KEY;
138
142
  }
139
143
  const response = await fetch(url, {
140
144
  method: "POST",
@@ -204,12 +208,12 @@ async function buildSwapJlpTransaction(args) {
204
208
  const { connection, manager, baseMint, direction, amount, slippageBps = 50, jlpMint = constants_1.JLP_MINT, tokenProgram = spl_token_1.TOKEN_PROGRAM_ID, programId = constants_1.PROGRAM_ID, } = args;
205
209
  // 1. Derive PDAs
206
210
  const [config] = (0, pda_1.findJlpdConfigPda)(programId);
207
- const [managerRole] = (0, pda_1.findManagerRolePda)(config, manager, programId);
211
+ const [managerRole] = (0, pda_1.findJlpdManagerRolePda)(config, manager, programId);
208
212
  const [strategyState] = (0, pda_1.findStrategyStatePda)(baseMint, programId);
209
213
  // Derive ATAs
210
- const strategyBaseAta = findAta(baseMint, strategyState, tokenProgram);
211
- const strategyJlpAta = findAta(jlpMint, strategyState, tokenProgram);
212
- const vaultJlpAta = findAta(jlpMint, config, tokenProgram);
214
+ const strategyBaseAta = (0, ata_1.findAta)(baseMint, strategyState, tokenProgram);
215
+ const strategyJlpAta = (0, ata_1.findAta)(jlpMint, strategyState, tokenProgram);
216
+ const vaultJlpAta = (0, ata_1.findAta)(jlpMint, config, tokenProgram);
213
217
  // 2. Determine input/output mints for the Jupiter quote
214
218
  const inputMint = direction === "BaseToJlp" ? baseMint : jlpMint;
215
219
  const outputMint = direction === "BaseToJlp" ? jlpMint : baseMint;
@@ -284,7 +288,7 @@ async function buildBaseToJlpRebalance(args) {
284
288
  const { connection, manager, baseMint, vaultId, amount, slippageBps, jlpMint, tokenProgram, programId, pStvProgramId, liquidity, } = args;
285
289
  // Derive JLPD PDAs
286
290
  const [strategyState] = (0, pda_1.findStrategyStatePda)(baseMint, programId);
287
- const strategyBaseAta = findAta(baseMint, strategyState, tokenProgram);
291
+ const strategyBaseAta = (0, ata_1.findAta)(baseMint, strategyState, tokenProgram);
288
292
  // Check if strategy_base_ata already has enough
289
293
  let strategyBalance = liquidity?.strategyAtaBalance ?? 0n;
290
294
  if (!liquidity) {
@@ -320,22 +324,23 @@ async function buildBaseToJlpRebalance(args) {
320
324
  // Fetch STV on-chain for lend info
321
325
  const stv = await (0, accounts_2.fetchStv)(connection, vaultId, pStvProgramId);
322
326
  const [stvAddress] = (0, pda_2.findStvPda)(vaultId, pStvProgramId);
323
- const [stvManagerRole] = (0, pda_2.findManagerRolePda)(stvAddress, manager, pStvProgramId);
327
+ const [stvManagerRole] = (0, pda_2.findStvManagerRolePda)(stvAddress, manager, pStvProgramId);
324
328
  // Build deposit_to_strategy remaining accounts (lend + auto-unroute)
325
329
  const vaultInfo = {
326
330
  address: stvAddress,
327
331
  baseMint,
328
332
  lendProgram: stv.lendProgram,
329
- strategies: stv.strategies,
330
- strategyCount: stv.strategyCount,
333
+ strategy: stv.strategy,
331
334
  };
332
335
  const depositCtx = await (0, remaining_accounts_1.buildDepositToStrategyContext)(connection, vaultInfo);
333
336
  // Derive the JLPD strategy's position PDA in p-STV Core
334
337
  const [jlpdStvPosition] = (0, pda_1.findStvPositionPda)(stvAddress, programId);
335
- const vaultAta = findAta(baseMint, stvAddress, tokenProgram);
338
+ const vaultAta = (0, ata_1.findAta)(baseMint, stvAddress, tokenProgram);
339
+ const [configPda] = (0, pda_2.findConfigPda)(pStvProgramId);
336
340
  const depositIx = (0, instructions_1.createDepositToStrategyIx)({
337
341
  manager,
338
342
  managerRole: stvManagerRole,
343
+ config: configPda,
339
344
  stv: stvAddress,
340
345
  vaultAta,
341
346
  baseMint,
@@ -346,6 +351,7 @@ async function buildBaseToJlpRebalance(args) {
346
351
  tokenProgram,
347
352
  amount: new bn_js_1.default(deficit.toString()),
348
353
  minShares: new bn_js_1.default(0),
354
+ protocolAumCount: depositCtx.protocolAumCount,
349
355
  autoUnrouteCount: depositCtx.autoUnrouteCount,
350
356
  remainingAccounts: depositCtx.remainingAccounts,
351
357
  }, pStvProgramId);
@@ -391,17 +397,17 @@ async function buildJlpToBaseRebalance(args) {
391
397
  sharesToWithdraw = positionShares;
392
398
  }
393
399
  // Build withdraw_from_strategy
394
- const [stvManagerRole] = (0, pda_2.findManagerRolePda)(stvAddress, manager, pStvProgramId);
400
+ const [stvManagerRole] = (0, pda_2.findStvManagerRolePda)(stvAddress, manager, pStvProgramId);
395
401
  const [jlpdStvPosition] = (0, pda_1.findStvPositionPda)(stvAddress, programId);
396
- const strategyBaseAta = findAta(baseMint, strategyState, tokenProgram);
397
- const vaultAta = findAta(baseMint, stvAddress, tokenProgram);
402
+ const strategyBaseAta = (0, ata_1.findAta)(baseMint, strategyState, tokenProgram);
403
+ const vaultAta = (0, ata_1.findAta)(baseMint, stvAddress, tokenProgram);
398
404
  // Build lend remaining_accounts for auto-sweep after withdraw
399
405
  const lendAccounts = [];
400
406
  const DEFAULT_PUBKEY = web3_js_1.PublicKey.default;
401
407
  if (!stv.lendProgram.equals(DEFAULT_PUBKEY)) {
402
408
  const [lendStrategyState] = (0, pda_3.findStrategyStatePda)(baseMint, stv.lendProgram);
403
409
  const [lendPosition] = (0, pda_3.findStvPositionPda)(stvAddress, stv.lendProgram);
404
- const lendBaseAta = findAta(baseMint, lendStrategyState, tokenProgram);
410
+ const lendBaseAta = (0, ata_1.findAta)(baseMint, lendStrategyState, tokenProgram);
405
411
  lendAccounts.push(...(0, instructions_1.buildLendRemainingAccounts)({
406
412
  lendProgram: stv.lendProgram,
407
413
  lendStrategyState,
@@ -409,9 +415,11 @@ async function buildJlpToBaseRebalance(args) {
409
415
  lendBaseAta,
410
416
  }));
411
417
  }
418
+ const [configPda] = (0, pda_2.findConfigPda)(pStvProgramId);
412
419
  const withdrawIx = (0, instructions_1.createWithdrawFromStrategyIx)({
413
420
  manager,
414
421
  managerRole: stvManagerRole,
422
+ config: configPda,
415
423
  stv: stvAddress,
416
424
  vaultAta,
417
425
  baseMint,
@@ -431,9 +439,9 @@ async function buildJlpToBaseRebalance(args) {
431
439
  if (!stv.lendProgram.equals(DEFAULT_PUBKEY) && jupPool) {
432
440
  const lendProgramId = stv.lendProgram;
433
441
  const [lendStrategyState] = (0, pda_3.findStrategyStatePda)(baseMint, lendProgramId);
434
- const [lendManagerRole] = (0, pda_3.findManagerRolePda)(lendStrategyState, manager, lendProgramId);
435
- const lendBaseAta = findAta(baseMint, lendStrategyState, tokenProgram);
436
- const lendFtokenAta = findAta(jupPool.fTokenMint, lendStrategyState, tokenProgram);
442
+ const [lendManagerRole] = (0, pda_3.findLendManagerRolePda)(lendStrategyState, manager, lendProgramId);
443
+ const lendBaseAta = (0, ata_1.findAta)(baseMint, lendStrategyState, tokenProgram);
444
+ const lendFtokenAta = (0, ata_1.findAta)(jupPool.fTokenMint, lendStrategyState, tokenProgram);
437
445
  const JUP_LEND_PROG = new web3_js_1.PublicKey("jup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9");
438
446
  const jupLendAccounts = [
439
447
  ...(0, jupiter_lend_1.buildJupLendDepositAccounts)(jupPool, lendStrategyState, lendBaseAta, lendFtokenAta).map((a) => ({ ...a, isSigner: false })),
@@ -462,4 +470,3 @@ async function buildJlpToBaseRebalance(args) {
462
470
  : "Swap JLP → base → withdraw to vault",
463
471
  };
464
472
  }
465
- //# sourceMappingURL=swap-jlp.js.map
@@ -1,7 +1,7 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import BN from "bn.js";
3
3
  import type { StrategyStateHeader } from "../common/strategy-interface";
4
- /** JlpdConfig global config (272 bytes) */
4
+ /** JlpdConfig global config (392 bytes) */
5
5
  export interface JlpdConfig {
6
6
  admin: PublicKey;
7
7
  jlpMint: PublicKey;
@@ -11,9 +11,11 @@ export interface JlpdConfig {
11
11
  jlpSlippageBps: number;
12
12
  version: number;
13
13
  bump: number;
14
+ /** JLP loaned to the JLPD Lend Adapter (not in vault ATA). Total JLP = vault_jlp_ata + jlpEarnAmount. */
15
+ jlpEarnAmount: BN;
16
+ /** Whitelisted adapter program. PublicKey.default = no adapter. */
17
+ jlpAdapterProgram: PublicKey;
14
18
  }
15
- /** @deprecated Use JlpdConfig instead */
16
- export type JLPVault = JlpdConfig;
17
19
  /** ManagerRole PDA (80 bytes) — grants manager access to rebalance operations */
18
20
  export interface ManagerRole {
19
21
  config: PublicKey;
@@ -53,4 +55,3 @@ export interface ManagerRemovedEvent {
53
55
  config: PublicKey;
54
56
  manager: PublicKey;
55
57
  }
56
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1,17 +1,90 @@
1
- import { Connection, PublicKey } from "@solana/web3.js";
1
+ import { PublicKey } from "@solana/web3.js";
2
2
  import BN from "bn.js";
3
+ import type { SolanaConnection } from "../common/connection";
3
4
  import { GlobalConfig, Stv, WithdrawRequest, ManagerRole } from "./types";
5
+ /**
6
+ * GlobalConfig — singleton protocol registry. Total 56 bytes.
7
+ *
8
+ * Layout (offsets include the 8-byte discriminator):
9
+ * [ 0.. 8] discriminator (sha256("account:GlobalConfig")[..8])
10
+ * [ 8.. 40] admin Pubkey
11
+ * [ 40.. 48] nextVaultId u64
12
+ * [ 48.. 50] flags u16 (CFG_FLAG_*)
13
+ * [ 50.. 51] version u8
14
+ * [ 51.. 52] bump u8
15
+ * [ 52.. 56] _padding [u8; 4]
16
+ */
4
17
  export declare function deserializeGlobalConfig(data: Buffer): GlobalConfig;
18
+ /**
19
+ * STV — per-vault state. Total 664 bytes (v2 layout).
20
+ *
21
+ * Layout (offsets include the 8-byte discriminator):
22
+ * [ 0.. 8] discriminator (sha256("account:Stv")[..8])
23
+ * [ 8.. 40] baseMint Pubkey
24
+ * [ 40.. 72] evMint Pubkey
25
+ * [ 72..104] strategy Pubkey (immutable strategy program)
26
+ * [104..136] feeReceiver Pubkey
27
+ * [136..168] lendProgram Pubkey (zero pubkey if lend not opted-in)
28
+ * [168..248] childVaults[10] [u64; 10] (allocator child vault IDs)
29
+ * [248..256] vaultId u64
30
+ * [256..264] reservedBase u64 (base reserved for pending claims)
31
+ * [264..272] requestedBase u64 (base requested via request_withdraw)
32
+ * [272..280] vaultCapacity u64 (0 = uncapped)
33
+ * [280..288] minDeposit u64
34
+ * [288..296] hwm u64 (high-water mark for perf fees)
35
+ * [296..304] lastFeeTs u64 (last fee crystallization timestamp)
36
+ * [304..312] epochPps u64 (locked PPS for current epoch claims)
37
+ * [312..320] lastNav u64 (snapshot for the rate-limit window)
38
+ * [320..328] dailyWithdrawnBase u64 (rate-limit accumulator)
39
+ * [328..332] nextEpochTs u32
40
+ * [332..336] epochSec u32
41
+ * [336..340] currentEpochId u32
42
+ * [340..344] pendingWithdrawals u32
43
+ * [344..348] withdrawWindowStart u32
44
+ * [348..350] mgmtFeeBps u16
45
+ * [350..352] perfFeeBps u16
46
+ * [352..354] flags u16 (FLAG_PAUSED / DEPOSITS_DISABLED / …)
47
+ * [354..356] dailyWithdrawLimitBps u16
48
+ * [356..357] childVaultCount u8
49
+ * [357..358] version u8
50
+ * [358..359] bump u8
51
+ * [359..360] _padding [u8; 1]
52
+ * [360..664] _reserved [u8; 304]
53
+ */
5
54
  export declare function deserializeStv(data: Buffer): Stv;
55
+ /**
56
+ * WithdrawRequest — per-(STV, user, epoch) withdraw escrow. Total 168 bytes.
57
+ *
58
+ * Layout (offsets include the 8-byte discriminator):
59
+ * [ 0.. 8] discriminator (sha256("account:WithdrawRequest")[..8])
60
+ * [ 8.. 40] stv Pubkey
61
+ * [ 40.. 72] user Pubkey
62
+ * [ 72.. 80] shares u64
63
+ * [ 80.. 88] pps u64 (locked at process_epoch time)
64
+ * [ 88.. 92] epochId u32
65
+ * [ 92.. 96] claimAvailableAfter u32 (unix seconds)
66
+ * [ 96.. 97] bump u8
67
+ * [ 97..168] _reserved [u8; 71]
68
+ */
6
69
  export declare function deserializeWithdrawRequest(data: Buffer): WithdrawRequest;
70
+ /**
71
+ * ManagerRole — per-(STV, manager) authorization record. Total 80 bytes.
72
+ *
73
+ * Layout (offsets include the 8-byte discriminator):
74
+ * [ 0.. 8] discriminator (sha256("account:ManagerRole")[..8] —
75
+ * shared with elemental-lend + jlpd-strategy)
76
+ * [ 8.. 40] stv Pubkey
77
+ * [ 40.. 72] manager Pubkey
78
+ * [ 72.. 73] bump u8
79
+ * [ 73.. 80] _padding [u8; 7]
80
+ */
7
81
  export declare function deserializeManagerRole(data: Buffer): ManagerRole;
8
- export declare function fetchGlobalConfig(connection: Connection, programId?: PublicKey): Promise<GlobalConfig>;
9
- export declare function fetchStv(connection: Connection, vaultId: number | BN, programId?: PublicKey): Promise<Stv>;
10
- export declare function fetchStvByAddress(connection: Connection, address: PublicKey): Promise<Stv>;
11
- export declare function fetchWithdrawRequest(connection: Connection, stv: PublicKey, user: PublicKey, epochId: number, programId?: PublicKey): Promise<WithdrawRequest>;
12
- export declare function fetchWithdrawRequestByAddress(connection: Connection, address: PublicKey): Promise<WithdrawRequest>;
13
- export declare function fetchAllStvs(connection: Connection, programId?: PublicKey): Promise<[PublicKey, Stv][]>;
14
- export declare function fetchPendingWithdrawRequests(connection: Connection, stv: PublicKey, epochId: number, programId?: PublicKey): Promise<[PublicKey, WithdrawRequest][]>;
15
- export declare function fetchManagerRole(connection: Connection, stv: PublicKey, manager: PublicKey, programId?: PublicKey): Promise<ManagerRole | null>;
16
- export declare function fetchManagersForStv(connection: Connection, stv: PublicKey, programId?: PublicKey): Promise<[PublicKey, ManagerRole][]>;
17
- //# sourceMappingURL=accounts.d.ts.map
82
+ export declare function fetchGlobalConfig(connection: SolanaConnection, programId?: PublicKey): Promise<GlobalConfig>;
83
+ export declare function fetchStv(connection: SolanaConnection, vaultId: number | BN, programId?: PublicKey): Promise<Stv>;
84
+ export declare function fetchStvByAddress(connection: SolanaConnection, address: PublicKey): Promise<Stv>;
85
+ export declare function fetchWithdrawRequest(connection: SolanaConnection, stv: PublicKey, user: PublicKey, epochId: number, programId?: PublicKey): Promise<WithdrawRequest>;
86
+ export declare function fetchWithdrawRequestByAddress(connection: SolanaConnection, address: PublicKey): Promise<WithdrawRequest>;
87
+ export declare function fetchAllStvs(connection: SolanaConnection, programId?: PublicKey): Promise<[PublicKey, Stv][]>;
88
+ export declare function fetchPendingWithdrawRequests(connection: SolanaConnection, stv: PublicKey, epochId: number, programId?: PublicKey): Promise<[PublicKey, WithdrawRequest][]>;
89
+ export declare function fetchManagerRole(connection: SolanaConnection, stv: PublicKey, manager: PublicKey, programId?: PublicKey): Promise<ManagerRole | null>;
90
+ export declare function fetchManagersForStv(connection: SolanaConnection, stv: PublicKey, programId?: PublicKey): Promise<[PublicKey, ManagerRole][]>;
@@ -18,7 +18,25 @@ const constants_1 = require("./constants");
18
18
  const pda_1 = require("./pda");
19
19
  // ---------------------------------------------------------------------------
20
20
  // Deserialization
21
+ //
22
+ // All offsets below INCLUDE the 8-byte Anchor account discriminator. Layout
23
+ // blocks above each parser show the field map; the helpers in
24
+ // `common/buffer.ts` validate that `offset + width <= data.length` so a
25
+ // drift between this file and the on-chain layout fails loudly with a
26
+ // `RangeError` rather than returning garbage.
21
27
  // ---------------------------------------------------------------------------
28
+ /**
29
+ * GlobalConfig — singleton protocol registry. Total 56 bytes.
30
+ *
31
+ * Layout (offsets include the 8-byte discriminator):
32
+ * [ 0.. 8] discriminator (sha256("account:GlobalConfig")[..8])
33
+ * [ 8.. 40] admin Pubkey
34
+ * [ 40.. 48] nextVaultId u64
35
+ * [ 48.. 50] flags u16 (CFG_FLAG_*)
36
+ * [ 50.. 51] version u8
37
+ * [ 51.. 52] bump u8
38
+ * [ 52.. 56] _padding [u8; 4]
39
+ */
22
40
  function deserializeGlobalConfig(data) {
23
41
  if (data.length < constants_1.GLOBAL_CONFIG_SIZE) {
24
42
  throw new Error(`GlobalConfig data too short: ${data.length} < ${constants_1.GLOBAL_CONFIG_SIZE}`);
@@ -35,6 +53,42 @@ function deserializeGlobalConfig(data) {
35
53
  bump: (0, buffer_1.readU8)(data, 51),
36
54
  };
37
55
  }
56
+ /**
57
+ * STV — per-vault state. Total 664 bytes (v2 layout).
58
+ *
59
+ * Layout (offsets include the 8-byte discriminator):
60
+ * [ 0.. 8] discriminator (sha256("account:Stv")[..8])
61
+ * [ 8.. 40] baseMint Pubkey
62
+ * [ 40.. 72] evMint Pubkey
63
+ * [ 72..104] strategy Pubkey (immutable strategy program)
64
+ * [104..136] feeReceiver Pubkey
65
+ * [136..168] lendProgram Pubkey (zero pubkey if lend not opted-in)
66
+ * [168..248] childVaults[10] [u64; 10] (allocator child vault IDs)
67
+ * [248..256] vaultId u64
68
+ * [256..264] reservedBase u64 (base reserved for pending claims)
69
+ * [264..272] requestedBase u64 (base requested via request_withdraw)
70
+ * [272..280] vaultCapacity u64 (0 = uncapped)
71
+ * [280..288] minDeposit u64
72
+ * [288..296] hwm u64 (high-water mark for perf fees)
73
+ * [296..304] lastFeeTs u64 (last fee crystallization timestamp)
74
+ * [304..312] epochPps u64 (locked PPS for current epoch claims)
75
+ * [312..320] lastNav u64 (snapshot for the rate-limit window)
76
+ * [320..328] dailyWithdrawnBase u64 (rate-limit accumulator)
77
+ * [328..332] nextEpochTs u32
78
+ * [332..336] epochSec u32
79
+ * [336..340] currentEpochId u32
80
+ * [340..344] pendingWithdrawals u32
81
+ * [344..348] withdrawWindowStart u32
82
+ * [348..350] mgmtFeeBps u16
83
+ * [350..352] perfFeeBps u16
84
+ * [352..354] flags u16 (FLAG_PAUSED / DEPOSITS_DISABLED / …)
85
+ * [354..356] dailyWithdrawLimitBps u16
86
+ * [356..357] childVaultCount u8
87
+ * [357..358] version u8
88
+ * [358..359] bump u8
89
+ * [359..360] _padding [u8; 1]
90
+ * [360..664] _reserved [u8; 304]
91
+ */
38
92
  function deserializeStv(data) {
39
93
  if (data.length < constants_1.STV_SIZE) {
40
94
  throw new Error(`Stv data too short: ${data.length} < ${constants_1.STV_SIZE}`);
@@ -43,9 +97,9 @@ function deserializeStv(data) {
43
97
  if (!disc.equals(constants_1.DISC_STV)) {
44
98
  throw new Error(`Invalid Stv discriminator`);
45
99
  }
46
- const strategies = [];
47
- for (let i = 0; i < 10; i++) {
48
- strategies.push((0, buffer_1.readPubkey)(data, 168 + i * 32));
100
+ const childVaults = [];
101
+ for (let i = 0; i < constants_1.MAX_STRATEGIES; i++) {
102
+ childVaults.push((0, buffer_1.readU64)(data, 168 + i * 8));
49
103
  }
50
104
  return {
51
105
  baseMint: (0, buffer_1.readPubkey)(data, 8),
@@ -53,31 +107,45 @@ function deserializeStv(data) {
53
107
  strategy: (0, buffer_1.readPubkey)(data, 72),
54
108
  feeReceiver: (0, buffer_1.readPubkey)(data, 104),
55
109
  lendProgram: (0, buffer_1.readPubkey)(data, 136),
56
- strategies,
57
- vaultId: (0, buffer_1.readU64)(data, 488),
58
- reservedBase: (0, buffer_1.readU64)(data, 496),
59
- requestedBase: (0, buffer_1.readU64)(data, 504),
60
- vaultCapacity: (0, buffer_1.readU64)(data, 512),
61
- minDeposit: (0, buffer_1.readU64)(data, 520),
62
- hwm: (0, buffer_1.readU64)(data, 528),
63
- lastFeeTs: (0, buffer_1.readU64)(data, 536),
64
- epochPps: (0, buffer_1.readU64)(data, 544),
65
- lastNav: (0, buffer_1.readU64)(data, 552),
66
- dailyWithdrawnBase: (0, buffer_1.readU64)(data, 560),
67
- nextEpochTs: (0, buffer_1.readU32)(data, 568),
68
- epochSec: (0, buffer_1.readU32)(data, 572),
69
- currentEpochId: (0, buffer_1.readU32)(data, 576),
70
- pendingWithdrawals: (0, buffer_1.readU32)(data, 580),
71
- withdrawWindowStart: (0, buffer_1.readU32)(data, 584),
72
- mgmtFeeBps: (0, buffer_1.readU16)(data, 588),
73
- perfFeeBps: (0, buffer_1.readU16)(data, 590),
74
- flags: (0, buffer_1.readU16)(data, 592),
75
- dailyWithdrawLimitBps: (0, buffer_1.readU16)(data, 594),
76
- strategyCount: (0, buffer_1.readU8)(data, 596),
77
- version: (0, buffer_1.readU8)(data, 597),
78
- bump: (0, buffer_1.readU8)(data, 598),
110
+ childVaults,
111
+ vaultId: (0, buffer_1.readU64)(data, 248),
112
+ reservedBase: (0, buffer_1.readU64)(data, 256),
113
+ requestedBase: (0, buffer_1.readU64)(data, 264),
114
+ vaultCapacity: (0, buffer_1.readU64)(data, 272),
115
+ minDeposit: (0, buffer_1.readU64)(data, 280),
116
+ hwm: (0, buffer_1.readU64)(data, 288),
117
+ lastFeeTs: (0, buffer_1.readU64)(data, 296),
118
+ epochPps: (0, buffer_1.readU64)(data, 304),
119
+ lastNav: (0, buffer_1.readU64)(data, 312),
120
+ dailyWithdrawnBase: (0, buffer_1.readU64)(data, 320),
121
+ nextEpochTs: (0, buffer_1.readU32)(data, 328),
122
+ epochSec: (0, buffer_1.readU32)(data, 332),
123
+ currentEpochId: (0, buffer_1.readU32)(data, 336),
124
+ pendingWithdrawals: (0, buffer_1.readU32)(data, 340),
125
+ withdrawWindowStart: (0, buffer_1.readU32)(data, 344),
126
+ mgmtFeeBps: (0, buffer_1.readU16)(data, 348),
127
+ perfFeeBps: (0, buffer_1.readU16)(data, 350),
128
+ flags: (0, buffer_1.readU16)(data, 352),
129
+ dailyWithdrawLimitBps: (0, buffer_1.readU16)(data, 354),
130
+ childVaultCount: (0, buffer_1.readU8)(data, 356),
131
+ version: (0, buffer_1.readU8)(data, 357),
132
+ bump: (0, buffer_1.readU8)(data, 358),
79
133
  };
80
134
  }
135
+ /**
136
+ * WithdrawRequest — per-(STV, user, epoch) withdraw escrow. Total 168 bytes.
137
+ *
138
+ * Layout (offsets include the 8-byte discriminator):
139
+ * [ 0.. 8] discriminator (sha256("account:WithdrawRequest")[..8])
140
+ * [ 8.. 40] stv Pubkey
141
+ * [ 40.. 72] user Pubkey
142
+ * [ 72.. 80] shares u64
143
+ * [ 80.. 88] pps u64 (locked at process_epoch time)
144
+ * [ 88.. 92] epochId u32
145
+ * [ 92.. 96] claimAvailableAfter u32 (unix seconds)
146
+ * [ 96.. 97] bump u8
147
+ * [ 97..168] _reserved [u8; 71]
148
+ */
81
149
  function deserializeWithdrawRequest(data) {
82
150
  if (data.length < constants_1.WITHDRAW_REQUEST_SIZE) {
83
151
  throw new Error(`WithdrawRequest data too short: ${data.length} < ${constants_1.WITHDRAW_REQUEST_SIZE}`);
@@ -96,6 +164,17 @@ function deserializeWithdrawRequest(data) {
96
164
  bump: (0, buffer_1.readU8)(data, 96),
97
165
  };
98
166
  }
167
+ /**
168
+ * ManagerRole — per-(STV, manager) authorization record. Total 80 bytes.
169
+ *
170
+ * Layout (offsets include the 8-byte discriminator):
171
+ * [ 0.. 8] discriminator (sha256("account:ManagerRole")[..8] —
172
+ * shared with elemental-lend + jlpd-strategy)
173
+ * [ 8.. 40] stv Pubkey
174
+ * [ 40.. 72] manager Pubkey
175
+ * [ 72.. 73] bump u8
176
+ * [ 73.. 80] _padding [u8; 7]
177
+ */
99
178
  function deserializeManagerRole(data) {
100
179
  if (data.length < constants_1.MANAGER_ROLE_SIZE) {
101
180
  throw new Error(`ManagerRole data too short: ${data.length} < ${constants_1.MANAGER_ROLE_SIZE}`);
@@ -165,14 +244,14 @@ async function fetchPendingWithdrawRequests(connection, stv, epochId, programId
165
244
  filters: [
166
245
  { dataSize: constants_1.WITHDRAW_REQUEST_SIZE },
167
246
  { memcmp: { offset: 0, bytes: constants_1.DISC_WITHDRAW_REQUEST.toString("base64"), encoding: "base64" } },
168
- { memcmp: { offset: 8, bytes: stv.toBase58() } },
247
+ { memcmp: { offset: 8, bytes: stv.toBuffer().toString("base64"), encoding: "base64" } },
169
248
  { memcmp: { offset: 88, bytes: epochBuf.toString("base64"), encoding: "base64" } },
170
249
  ],
171
250
  });
172
251
  return accounts.map((a) => [a.pubkey, deserializeWithdrawRequest(a.account.data)]);
173
252
  }
174
253
  async function fetchManagerRole(connection, stv, manager, programId = constants_1.PROGRAM_ID) {
175
- const [pda] = (0, pda_1.findManagerRolePda)(stv, manager, programId);
254
+ const [pda] = (0, pda_1.findStvManagerRolePda)(stv, manager, programId);
176
255
  const info = await connection.getAccountInfo(pda);
177
256
  if (!info)
178
257
  return null;
@@ -183,9 +262,8 @@ async function fetchManagersForStv(connection, stv, programId = constants_1.PROG
183
262
  filters: [
184
263
  { dataSize: constants_1.MANAGER_ROLE_SIZE },
185
264
  { memcmp: { offset: 0, bytes: constants_1.DISC_MANAGER_ROLE.toString("base64"), encoding: "base64" } },
186
- { memcmp: { offset: 8, bytes: stv.toBase58() } },
265
+ { memcmp: { offset: 8, bytes: stv.toBuffer().toString("base64"), encoding: "base64" } },
187
266
  ],
188
267
  });
189
268
  return accounts.map((a) => [a.pubkey, deserializeManagerRole(a.account.data)]);
190
269
  }
191
- //# sourceMappingURL=accounts.js.map
@@ -8,7 +8,7 @@ export declare const MANAGER_SEED: Buffer<ArrayBuffer>;
8
8
  export declare const DISC_GLOBAL_CONFIG: Buffer<ArrayBuffer>;
9
9
  export declare const DISC_STV: Buffer<ArrayBuffer>;
10
10
  export declare const DISC_WITHDRAW_REQUEST: Buffer<ArrayBuffer>;
11
- export declare const DISC_MANAGER_ROLE: Buffer<ArrayBuffer>;
11
+ export { DISC_MANAGER_ROLE } from "../common/constants";
12
12
  export declare const IX_INIT_OR_UPDATE_CONFIG = 0;
13
13
  export declare const IX_INIT_OR_UPDATE_STV = 1;
14
14
  export declare const IX_DEPOSIT = 2;
@@ -21,6 +21,7 @@ export declare const IX_CLOSE_STV = 8;
21
21
  export declare const IX_ADD_MANAGER = 9;
22
22
  export declare const IX_REMOVE_MANAGER = 10;
23
23
  export declare const IX_OVERRIDE_CLAIM_WITHDRAW = 11;
24
+ export declare const IX_MIGRATE_LEND = 12;
24
25
  export declare const EVT_CONFIG_INITIALIZED = 0;
25
26
  export declare const EVT_CONFIG_UPDATED = 1;
26
27
  export declare const EVT_STV_CREATED = 2;
@@ -38,18 +39,27 @@ export declare const EVT_STV_CLOSED = 13;
38
39
  export declare const EVT_MANAGER_ADDED = 14;
39
40
  export declare const EVT_MANAGER_REMOVED = 15;
40
41
  export declare const EVT_WITHDRAW_OVERRIDE_CLAIMED = 16;
42
+ export declare const EVT_LEND_MIGRATED = 17;
41
43
  export declare const FLAG_PAUSED = 1;
42
44
  export declare const FLAG_DEPOSITS_DISABLED = 2;
43
45
  export declare const FLAG_WITHDRAWALS_DISABLED = 4;
44
46
  export declare const FLAG_REBALANCE_DISABLED = 8;
45
47
  export declare const FLAG_TEST_MODE = 16;
46
48
  export declare const FLAG_ALLOCATOR = 32;
47
- export declare const CFG_FLAG_ADMIN_LOCKED = 1;
49
+ /**
50
+ * Protocol-wide emergency pause. When set on `GlobalConfig.flags`, blocks
51
+ * every value-movement instruction across every STV (deposit, request/claim
52
+ * withdraw, process_epoch, deposit/withdraw_from_strategy,
53
+ * override_claim_withdraw). Admin/rescue paths
54
+ * (init_or_update_config, init_or_update_stv, close_stv, add/remove_manager)
55
+ * remain open so the admin can reconfigure and clear the pause.
56
+ */
57
+ export declare const CFG_FLAG_GLOBAL_PAUSED = 1;
48
58
  export { PPS_DECIMALS, BPS_DENOMINATOR, STALENESS_THRESHOLD } from "../common/constants";
59
+ export declare const MAX_CHILD_VAULTS = 10;
49
60
  export declare const MAX_STRATEGIES = 10;
50
61
  export declare const FEE_CAP_BPS = 9900;
51
62
  export declare const GLOBAL_CONFIG_SIZE = 56;
52
63
  export declare const STV_SIZE = 664;
53
64
  export declare const WITHDRAW_REQUEST_SIZE = 168;
54
65
  export declare const MANAGER_ROLE_SIZE = 80;
55
- //# sourceMappingURL=constants.d.ts.map
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAX_STRATEGIES = exports.STALENESS_THRESHOLD = exports.BPS_DENOMINATOR = exports.PPS_DECIMALS = exports.CFG_FLAG_ADMIN_LOCKED = exports.FLAG_ALLOCATOR = exports.FLAG_TEST_MODE = exports.FLAG_REBALANCE_DISABLED = exports.FLAG_WITHDRAWALS_DISABLED = exports.FLAG_DEPOSITS_DISABLED = exports.FLAG_PAUSED = exports.EVT_WITHDRAW_OVERRIDE_CLAIMED = exports.EVT_MANAGER_REMOVED = exports.EVT_MANAGER_ADDED = exports.EVT_STV_CLOSED = exports.EVT_FEES_SETTLED = exports.EVT_EPOCH_ADVANCED = exports.EVT_EPOCH_PROCESSED = exports.EVT_WITHDRAWN_FROM_STRATEGY = exports.EVT_DEPOSITED_TO_STRATEGY = exports.EVT_WITHDRAW_CLAIMED = exports.EVT_WITHDRAW_REQUEST_INCREASED = exports.EVT_WITHDRAW_REQUESTED = exports.EVT_DEPOSITED = exports.EVT_STV_UPDATED = exports.EVT_STV_CREATED = exports.EVT_CONFIG_UPDATED = exports.EVT_CONFIG_INITIALIZED = exports.IX_OVERRIDE_CLAIM_WITHDRAW = exports.IX_REMOVE_MANAGER = exports.IX_ADD_MANAGER = exports.IX_CLOSE_STV = exports.IX_WITHDRAW_FROM_STRATEGY = exports.IX_DEPOSIT_TO_STRATEGY = exports.IX_PROCESS_EPOCH = exports.IX_CLAIM_WITHDRAW = exports.IX_REQUEST_WITHDRAW = exports.IX_DEPOSIT = exports.IX_INIT_OR_UPDATE_STV = exports.IX_INIT_OR_UPDATE_CONFIG = exports.DISC_MANAGER_ROLE = exports.DISC_WITHDRAW_REQUEST = exports.DISC_STV = exports.DISC_GLOBAL_CONFIG = exports.MANAGER_SEED = exports.WITHDRAW_REQUEST_SEED = exports.EV_MINT_SEED = exports.STV_SEED = exports.CONFIG_SEED = exports.PROGRAM_ID = void 0;
4
- exports.MANAGER_ROLE_SIZE = exports.WITHDRAW_REQUEST_SIZE = exports.STV_SIZE = exports.GLOBAL_CONFIG_SIZE = exports.FEE_CAP_BPS = void 0;
3
+ exports.BPS_DENOMINATOR = exports.PPS_DECIMALS = exports.CFG_FLAG_GLOBAL_PAUSED = exports.FLAG_ALLOCATOR = exports.FLAG_TEST_MODE = exports.FLAG_REBALANCE_DISABLED = exports.FLAG_WITHDRAWALS_DISABLED = exports.FLAG_DEPOSITS_DISABLED = exports.FLAG_PAUSED = exports.EVT_LEND_MIGRATED = exports.EVT_WITHDRAW_OVERRIDE_CLAIMED = exports.EVT_MANAGER_REMOVED = exports.EVT_MANAGER_ADDED = exports.EVT_STV_CLOSED = exports.EVT_FEES_SETTLED = exports.EVT_EPOCH_ADVANCED = exports.EVT_EPOCH_PROCESSED = exports.EVT_WITHDRAWN_FROM_STRATEGY = exports.EVT_DEPOSITED_TO_STRATEGY = exports.EVT_WITHDRAW_CLAIMED = exports.EVT_WITHDRAW_REQUEST_INCREASED = exports.EVT_WITHDRAW_REQUESTED = exports.EVT_DEPOSITED = exports.EVT_STV_UPDATED = exports.EVT_STV_CREATED = exports.EVT_CONFIG_UPDATED = exports.EVT_CONFIG_INITIALIZED = exports.IX_MIGRATE_LEND = exports.IX_OVERRIDE_CLAIM_WITHDRAW = exports.IX_REMOVE_MANAGER = exports.IX_ADD_MANAGER = exports.IX_CLOSE_STV = exports.IX_WITHDRAW_FROM_STRATEGY = exports.IX_DEPOSIT_TO_STRATEGY = exports.IX_PROCESS_EPOCH = exports.IX_CLAIM_WITHDRAW = exports.IX_REQUEST_WITHDRAW = exports.IX_DEPOSIT = exports.IX_INIT_OR_UPDATE_STV = exports.IX_INIT_OR_UPDATE_CONFIG = exports.DISC_MANAGER_ROLE = exports.DISC_WITHDRAW_REQUEST = exports.DISC_STV = exports.DISC_GLOBAL_CONFIG = exports.MANAGER_SEED = exports.WITHDRAW_REQUEST_SEED = exports.EV_MINT_SEED = exports.STV_SEED = exports.CONFIG_SEED = exports.PROGRAM_ID = void 0;
4
+ exports.MANAGER_ROLE_SIZE = exports.WITHDRAW_REQUEST_SIZE = exports.STV_SIZE = exports.GLOBAL_CONFIG_SIZE = exports.FEE_CAP_BPS = exports.MAX_STRATEGIES = exports.MAX_CHILD_VAULTS = exports.STALENESS_THRESHOLD = void 0;
5
5
  const web3_js_1 = require("@solana/web3.js");
6
6
  // ---------------------------------------------------------------------------
7
7
  // Program ID
@@ -27,9 +27,9 @@ exports.DISC_STV = Buffer.from([
27
27
  exports.DISC_WITHDRAW_REQUEST = Buffer.from([
28
28
  0xba, 0xef, 0xae, 0xbf, 0xbd, 0x0d, 0x2f, 0xc4,
29
29
  ]);
30
- exports.DISC_MANAGER_ROLE = Buffer.from([
31
- 0x25, 0xe8, 0x64, 0xe9, 0xaa, 0xe9, 0xdb, 0xb9,
32
- ]);
30
+ // Shared with elemental-lend and jlpd-strategy — defined once in common/
31
+ var constants_1 = require("../common/constants");
32
+ Object.defineProperty(exports, "DISC_MANAGER_ROLE", { enumerable: true, get: function () { return constants_1.DISC_MANAGER_ROLE; } });
33
33
  // ---------------------------------------------------------------------------
34
34
  // Instruction Discriminators (1-byte)
35
35
  // ---------------------------------------------------------------------------
@@ -45,6 +45,7 @@ exports.IX_CLOSE_STV = 8;
45
45
  exports.IX_ADD_MANAGER = 9;
46
46
  exports.IX_REMOVE_MANAGER = 10;
47
47
  exports.IX_OVERRIDE_CLAIM_WITHDRAW = 11;
48
+ exports.IX_MIGRATE_LEND = 12;
48
49
  // ---------------------------------------------------------------------------
49
50
  // Event Discriminators (1-byte)
50
51
  // ---------------------------------------------------------------------------
@@ -65,6 +66,7 @@ exports.EVT_STV_CLOSED = 13;
65
66
  exports.EVT_MANAGER_ADDED = 14;
66
67
  exports.EVT_MANAGER_REMOVED = 15;
67
68
  exports.EVT_WITHDRAW_OVERRIDE_CLAIMED = 16;
69
+ exports.EVT_LEND_MIGRATED = 17;
68
70
  // ---------------------------------------------------------------------------
69
71
  // Vault Flags
70
72
  // ---------------------------------------------------------------------------
@@ -76,15 +78,24 @@ exports.FLAG_REBALANCE_DISABLED = 0x0008;
76
78
  exports.FLAG_TEST_MODE = 0x0010;
77
79
  exports.FLAG_ALLOCATOR = 0x0020;
78
80
  // GlobalConfig flags
79
- exports.CFG_FLAG_ADMIN_LOCKED = 0x0001;
81
+ /**
82
+ * Protocol-wide emergency pause. When set on `GlobalConfig.flags`, blocks
83
+ * every value-movement instruction across every STV (deposit, request/claim
84
+ * withdraw, process_epoch, deposit/withdraw_from_strategy,
85
+ * override_claim_withdraw). Admin/rescue paths
86
+ * (init_or_update_config, init_or_update_stv, close_stv, add/remove_manager)
87
+ * remain open so the admin can reconfigure and clear the pause.
88
+ */
89
+ exports.CFG_FLAG_GLOBAL_PAUSED = 0x0001;
80
90
  // ---------------------------------------------------------------------------
81
91
  // Protocol Constants
82
92
  // ---------------------------------------------------------------------------
83
- var constants_1 = require("../common/constants");
84
- Object.defineProperty(exports, "PPS_DECIMALS", { enumerable: true, get: function () { return constants_1.PPS_DECIMALS; } });
85
- Object.defineProperty(exports, "BPS_DENOMINATOR", { enumerable: true, get: function () { return constants_1.BPS_DENOMINATOR; } });
86
- Object.defineProperty(exports, "STALENESS_THRESHOLD", { enumerable: true, get: function () { return constants_1.STALENESS_THRESHOLD; } });
87
- exports.MAX_STRATEGIES = 10;
93
+ var constants_2 = require("../common/constants");
94
+ Object.defineProperty(exports, "PPS_DECIMALS", { enumerable: true, get: function () { return constants_2.PPS_DECIMALS; } });
95
+ Object.defineProperty(exports, "BPS_DENOMINATOR", { enumerable: true, get: function () { return constants_2.BPS_DENOMINATOR; } });
96
+ Object.defineProperty(exports, "STALENESS_THRESHOLD", { enumerable: true, get: function () { return constants_2.STALENESS_THRESHOLD; } });
97
+ exports.MAX_CHILD_VAULTS = 10;
98
+ exports.MAX_STRATEGIES = exports.MAX_CHILD_VAULTS; // backward compat
88
99
  exports.FEE_CAP_BPS = 9900;
89
100
  // ---------------------------------------------------------------------------
90
101
  // Account Sizes
@@ -93,4 +104,3 @@ exports.GLOBAL_CONFIG_SIZE = 56;
93
104
  exports.STV_SIZE = 664;
94
105
  exports.WITHDRAW_REQUEST_SIZE = 168;
95
106
  exports.MANAGER_ROLE_SIZE = 80;
96
- //# sourceMappingURL=constants.js.map
@@ -5,4 +5,3 @@ import type { StvEvent } from "./types";
5
5
  * p-stv-core uses 1-byte event discriminators via sol_log_data.
6
6
  */
7
7
  export declare function parseEventsFromLogs(logs: string[], programId?: PublicKey): StvEvent[];
8
- //# sourceMappingURL=events.d.ts.map