@elemental-stv-core/sdk 0.4.0 → 0.6.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 (149) 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 +6 -7
  18. package/dist/elemental-lend/constants.js +13 -12
  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 +60 -0
  38. package/dist/jlpd-strategy/adapter.js +90 -0
  39. package/dist/jlpd-strategy/constants.d.ts +27 -16
  40. package/dist/jlpd-strategy/constants.js +40 -29
  41. package/dist/jlpd-strategy/index.d.ts +3 -1
  42. package/dist/jlpd-strategy/index.js +3 -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 +63 -0
  46. package/dist/jlpd-strategy/jlp-borrow.js +87 -0
  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 +90 -0
  50. package/dist/jlpd-strategy/jupusd-earn.js +166 -0
  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 +35 -27
  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 +83 -5
  61. package/dist/p-stv-core/constants.d.ts +13 -3
  62. package/dist/p-stv-core/constants.js +23 -11
  63. package/dist/p-stv-core/events.d.ts +0 -1
  64. package/dist/p-stv-core/events.js +50 -1
  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 +13 -14
  74. package/dist/p-stv-core/remaining-accounts.js +53 -46
  75. package/dist/p-stv-core/send-tx.d.ts +23 -7
  76. package/dist/p-stv-core/send-tx.js +17 -26
  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 +9 -2
  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/constants.d.ts.map +0 -1
  113. package/dist/jlpd-strategy/constants.js.map +0 -1
  114. package/dist/jlpd-strategy/index.d.ts.map +0 -1
  115. package/dist/jlpd-strategy/index.js.map +0 -1
  116. package/dist/jlpd-strategy/instructions.d.ts.map +0 -1
  117. package/dist/jlpd-strategy/instructions.js.map +0 -1
  118. package/dist/jlpd-strategy/jlp-data.d.ts.map +0 -1
  119. package/dist/jlpd-strategy/jlp-data.js.map +0 -1
  120. package/dist/jlpd-strategy/pda.d.ts.map +0 -1
  121. package/dist/jlpd-strategy/pda.js.map +0 -1
  122. package/dist/jlpd-strategy/settle-yield.d.ts.map +0 -1
  123. package/dist/jlpd-strategy/settle-yield.js.map +0 -1
  124. package/dist/jlpd-strategy/swap-jlp.d.ts.map +0 -1
  125. package/dist/jlpd-strategy/swap-jlp.js.map +0 -1
  126. package/dist/jlpd-strategy/types.d.ts.map +0 -1
  127. package/dist/jlpd-strategy/types.js.map +0 -1
  128. package/dist/p-stv-core/accounts.d.ts.map +0 -1
  129. package/dist/p-stv-core/accounts.js.map +0 -1
  130. package/dist/p-stv-core/constants.d.ts.map +0 -1
  131. package/dist/p-stv-core/constants.js.map +0 -1
  132. package/dist/p-stv-core/events.d.ts.map +0 -1
  133. package/dist/p-stv-core/events.js.map +0 -1
  134. package/dist/p-stv-core/index.d.ts.map +0 -1
  135. package/dist/p-stv-core/index.js.map +0 -1
  136. package/dist/p-stv-core/instructions.d.ts.map +0 -1
  137. package/dist/p-stv-core/instructions.js.map +0 -1
  138. package/dist/p-stv-core/pda.d.ts.map +0 -1
  139. package/dist/p-stv-core/pda.js.map +0 -1
  140. package/dist/p-stv-core/prices.d.ts.map +0 -1
  141. package/dist/p-stv-core/prices.js.map +0 -1
  142. package/dist/p-stv-core/remaining-accounts.d.ts.map +0 -1
  143. package/dist/p-stv-core/remaining-accounts.js.map +0 -1
  144. package/dist/p-stv-core/send-tx.d.ts.map +0 -1
  145. package/dist/p-stv-core/send-tx.js.map +0 -1
  146. package/dist/p-stv-core/sol-wrap.d.ts.map +0 -1
  147. package/dist/p-stv-core/sol-wrap.js.map +0 -1
  148. package/dist/p-stv-core/types.d.ts.map +0 -1
  149. package/dist/p-stv-core/types.js.map +0 -1
@@ -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,17 +39,26 @@ 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;
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;
47
58
  export { PPS_DECIMALS, BPS_DENOMINATOR, STALENESS_THRESHOLD } from "../common/constants";
48
59
  export declare const MAX_STRATEGIES = 10;
49
60
  export declare const FEE_CAP_BPS = 9900;
50
61
  export declare const GLOBAL_CONFIG_SIZE = 56;
51
62
  export declare const STV_SIZE = 664;
52
- export declare const WITHDRAW_REQUEST_SIZE = 104;
63
+ export declare const WITHDRAW_REQUEST_SIZE = 168;
53
64
  export declare const MANAGER_ROLE_SIZE = 80;
54
- //# sourceMappingURL=constants.d.ts.map
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FEE_CAP_BPS = exports.MAX_STRATEGIES = exports.STALENESS_THRESHOLD = exports.BPS_DENOMINATOR = exports.PPS_DECIMALS = 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 = 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.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,22 +66,34 @@ 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
  // ---------------------------------------------------------------------------
73
+ // STV flags
71
74
  exports.FLAG_PAUSED = 0x0001;
72
75
  exports.FLAG_DEPOSITS_DISABLED = 0x0002;
73
76
  exports.FLAG_WITHDRAWALS_DISABLED = 0x0004;
74
77
  exports.FLAG_REBALANCE_DISABLED = 0x0008;
75
78
  exports.FLAG_TEST_MODE = 0x0010;
76
79
  exports.FLAG_ALLOCATOR = 0x0020;
80
+ // GlobalConfig flags
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;
77
90
  // ---------------------------------------------------------------------------
78
91
  // Protocol Constants
79
92
  // ---------------------------------------------------------------------------
80
- var constants_1 = require("../common/constants");
81
- Object.defineProperty(exports, "PPS_DECIMALS", { enumerable: true, get: function () { return constants_1.PPS_DECIMALS; } });
82
- Object.defineProperty(exports, "BPS_DENOMINATOR", { enumerable: true, get: function () { return constants_1.BPS_DENOMINATOR; } });
83
- Object.defineProperty(exports, "STALENESS_THRESHOLD", { enumerable: true, get: function () { return constants_1.STALENESS_THRESHOLD; } });
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; } });
84
97
  exports.MAX_STRATEGIES = 10;
85
98
  exports.FEE_CAP_BPS = 9900;
86
99
  // ---------------------------------------------------------------------------
@@ -88,6 +101,5 @@ exports.FEE_CAP_BPS = 9900;
88
101
  // ---------------------------------------------------------------------------
89
102
  exports.GLOBAL_CONFIG_SIZE = 56;
90
103
  exports.STV_SIZE = 664;
91
- exports.WITHDRAW_REQUEST_SIZE = 104;
104
+ exports.WITHDRAW_REQUEST_SIZE = 168;
92
105
  exports.MANAGER_ROLE_SIZE = 80;
93
- //# 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
@@ -40,6 +40,45 @@ function parseEventsFromLogs(logs, programId = constants_1.PROGRAM_ID) {
40
40
  }
41
41
  return events;
42
42
  }
43
+ /**
44
+ * p-stv-core event payload layout reference (offsets are within the
45
+ * `Program data: …` log buffer; see also `EVT_*` discriminators in
46
+ * `constants.ts`):
47
+ *
48
+ * ConfigInitialized [0..1] disc | [1..33] admin
49
+ * ConfigUpdated [0..1] disc | [1..33] admin | [33..35] flags
50
+ * StvCreated [0..1] disc | [1..9] vaultId | [9..41] baseMint |
51
+ * [41..73] evMint | [73..105] feeReceiver | [105..137] strategy |
52
+ * [137..169] lendProgram | [169..173] epochSec |
53
+ * [173..175] mgmtFeeBps | [175..177] perfFeeBps
54
+ * StvUpdated [0..1] disc | [1..9] vaultId | [9..41] feeReceiver |
55
+ * [41..43] flags | [43..45] mgmtFeeBps | [45..47] perfFeeBps |
56
+ * [47..55] vaultCapacity | [55..63] minDeposit |
57
+ * [63..64] strategyCount | [64..96] lendProgram
58
+ * Deposited [0..1] disc | [1..9] vaultId | [9..41] user |
59
+ * [41..49] amount | [49..57] sharesMinted | [57..65] pps
60
+ * WithdrawRequested [0..1] disc | [1..9] vaultId | [9..41] user |
61
+ * [41..49] shares | [49..53] epochId
62
+ * WithdrawRequestIncreased [0..1] disc | [1..9] vaultId | [9..41] user |
63
+ * [41..49] additionalShares | [49..57] totalShares |
64
+ * [57..61] epochId
65
+ * WithdrawClaimed [0..1] disc | [1..9] vaultId | [9..41] user |
66
+ * [41..49] shares | [49..57] baseAmount | [57..61] epochId
67
+ * DepositedToStrategy [0..1] disc | [1..9] vaultId | [9..41] strategy |
68
+ * [41..49] amount | [49..57] sharesReceived
69
+ * WithdrawnFromStrategy [0..1] disc | [1..9] vaultId | [9..41] strategy |
70
+ * [41..49] shares | [49..57] baseReceived
71
+ * EpochProcessed [0..1] disc | [1..9] vaultId | [9..13] epochId |
72
+ * [13..21] epochPps | [21..29] feeSharesMinted
73
+ * EpochAdvanced [0..1] disc | [1..9] vaultId | [9..13] newEpochId |
74
+ * [13..17] nextEpochTs
75
+ * FeesSettled [0..1] disc | [1..9] vaultId | [9..17] mgmtFeeBase |
76
+ * [17..25] perfFeeBase | [25..33] feeSharesMinted |
77
+ * [33..41] postFeePps | [41..49] hwm
78
+ * StvClosed [0..1] disc | [1..9] vaultId
79
+ * ManagerAdded [0..1] disc | [1..33] stv | [33..65] manager
80
+ * ManagerRemoved [0..1] disc | [1..33] stv | [33..65] manager
81
+ */
43
82
  function parseEventBuffer(data) {
44
83
  if (data.length === 0)
45
84
  return null;
@@ -120,8 +159,18 @@ function parseEventBuffer(data) {
120
159
  return data.length >= 65 ? {
121
160
  name: "ManagerRemoved", stv: (0, buffer_1.readPubkey)(data, 1), manager: (0, buffer_1.readPubkey)(data, 33),
122
161
  } : null;
162
+ case constants_1.EVT_WITHDRAW_OVERRIDE_CLAIMED:
163
+ return data.length >= 109 ? {
164
+ name: "WithdrawOverrideClaimed", vaultId: (0, buffer_1.readU64)(data, 1), manager: (0, buffer_1.readPubkey)(data, 9),
165
+ user: (0, buffer_1.readPubkey)(data, 41), shares: (0, buffer_1.readU64)(data, 73), baseAmount: (0, buffer_1.readU64)(data, 81),
166
+ epochId: (0, buffer_1.readU32)(data, 89), dailyWithdrawnBase: (0, buffer_1.readU64)(data, 93), dailyLimit: (0, buffer_1.readU64)(data, 101),
167
+ } : null;
168
+ case constants_1.EVT_LEND_MIGRATED:
169
+ return data.length >= 89 ? {
170
+ name: "LendMigrated", vaultId: (0, buffer_1.readU64)(data, 1), oldLendProgram: (0, buffer_1.readPubkey)(data, 9),
171
+ newLendProgram: (0, buffer_1.readPubkey)(data, 41), sharesWithdrawn: (0, buffer_1.readU64)(data, 73), baseMigrated: (0, buffer_1.readU64)(data, 81),
172
+ } : null;
123
173
  default:
124
174
  return null;
125
175
  }
126
176
  }
127
- //# sourceMappingURL=events.js.map
@@ -8,4 +8,3 @@ export * from "./remaining-accounts";
8
8
  export * from "./send-tx";
9
9
  export * from "./sol-wrap";
10
10
  export * from "./prices";
11
- //# sourceMappingURL=index.d.ts.map
@@ -24,4 +24,3 @@ __exportStar(require("./remaining-accounts"), exports);
24
24
  __exportStar(require("./send-tx"), exports);
25
25
  __exportStar(require("./sol-wrap"), exports);
26
26
  __exportStar(require("./prices"), exports);
27
- //# sourceMappingURL=index.js.map
@@ -42,6 +42,8 @@ export interface InitOrUpdateStvArgs {
42
42
  export declare function createInitOrUpdateStvIx(args: InitOrUpdateStvArgs, programId?: PublicKey): TransactionInstruction;
43
43
  export interface DepositArgs {
44
44
  user: PublicKey;
45
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
46
+ config: PublicKey;
45
47
  stv: PublicKey;
46
48
  vaultAta: PublicKey;
47
49
  userBaseAta: PublicKey;
@@ -61,6 +63,8 @@ export interface DepositArgs {
61
63
  export declare function createDepositIx(args: DepositArgs, programId?: PublicKey): TransactionInstruction;
62
64
  export interface RequestWithdrawArgs {
63
65
  user: PublicKey;
66
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
67
+ config: PublicKey;
64
68
  stv: PublicKey;
65
69
  withdrawRequest: PublicKey;
66
70
  userEvAta: PublicKey;
@@ -74,6 +78,8 @@ export interface RequestWithdrawArgs {
74
78
  export declare function createRequestWithdrawIx(args: RequestWithdrawArgs, programId?: PublicKey): TransactionInstruction;
75
79
  export interface ClaimWithdrawArgs {
76
80
  user: PublicKey;
81
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
82
+ config: PublicKey;
77
83
  stv: PublicKey;
78
84
  withdrawRequest: PublicKey;
79
85
  vaultAta: PublicKey;
@@ -88,6 +94,8 @@ export declare function createClaimWithdrawIx(args: ClaimWithdrawArgs, programId
88
94
  export interface OverrideClaimWithdrawArgs {
89
95
  manager: PublicKey;
90
96
  managerRole: PublicKey;
97
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
98
+ config: PublicKey;
91
99
  user: PublicKey;
92
100
  stv: PublicKey;
93
101
  withdrawRequest: PublicKey;
@@ -101,6 +109,8 @@ export interface OverrideClaimWithdrawArgs {
101
109
  export declare function createOverrideClaimWithdrawIx(args: OverrideClaimWithdrawArgs, programId?: PublicKey): TransactionInstruction;
102
110
  export interface ProcessEpochArgs {
103
111
  payer: PublicKey;
112
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
113
+ config: PublicKey;
104
114
  stv: PublicKey;
105
115
  evMint: PublicKey;
106
116
  feeReceiverEvAta: PublicKey;
@@ -116,6 +126,8 @@ export declare function createProcessEpochIx(args: ProcessEpochArgs, programId?:
116
126
  export interface DepositToStrategyArgs {
117
127
  manager: PublicKey;
118
128
  managerRole: PublicKey;
129
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
130
+ config: PublicKey;
119
131
  stv: PublicKey;
120
132
  vaultAta: PublicKey;
121
133
  baseMint: PublicKey;
@@ -126,7 +138,13 @@ export interface DepositToStrategyArgs {
126
138
  tokenProgram: PublicKey;
127
139
  amount: BN | number;
128
140
  minShares: BN | number;
129
- /** Number of auto-unroute accounts appended after lend accounts (0 = no auto-unroute) */
141
+ /**
142
+ * Number of protocol AUM accounts (kVault: 2/protocol, Jupiter Lend: 3/protocol)
143
+ * used by update_lend_aum for fresh lend valuation before the reserved_base
144
+ * liquidity lock check. Always required (0 if lend has no active protocols).
145
+ */
146
+ protocolAumCount: number;
147
+ /** Number of auto-unroute accounts appended after protocol accounts (0 = no auto-unroute) */
130
148
  autoUnrouteCount?: number;
131
149
  remainingAccounts?: AccountMeta[];
132
150
  }
@@ -134,6 +152,8 @@ export declare function createDepositToStrategyIx(args: DepositToStrategyArgs, p
134
152
  export interface WithdrawFromStrategyArgs {
135
153
  manager: PublicKey;
136
154
  managerRole: PublicKey;
155
+ /** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED */
156
+ config: PublicKey;
137
157
  stv: PublicKey;
138
158
  vaultAta: PublicKey;
139
159
  baseMint: PublicKey;
@@ -153,9 +173,7 @@ export interface CloseStvArgs {
153
173
  stv: PublicKey;
154
174
  evMint: PublicKey;
155
175
  vaultAta: PublicKey;
156
- baseMint: PublicKey;
157
176
  tokenProgram: PublicKey;
158
- remainingAccounts?: AccountMeta[];
159
177
  }
160
178
  export declare function createCloseStvIx(args: CloseStvArgs, programId?: PublicKey): TransactionInstruction;
161
179
  export interface AddManagerArgs {
@@ -176,6 +194,34 @@ export interface RemoveManagerArgs {
176
194
  managerRole: PublicKey;
177
195
  }
178
196
  export declare function createRemoveManagerIx(args: RemoveManagerArgs, programId?: PublicKey): TransactionInstruction;
197
+ export interface MigrateLendArgs {
198
+ admin: PublicKey;
199
+ payer: PublicKey;
200
+ config: PublicKey;
201
+ stv: PublicKey;
202
+ vaultAta: PublicKey;
203
+ baseMint: PublicKey;
204
+ tokenProgram: PublicKey;
205
+ systemProgram?: PublicKey;
206
+ /** Current lend program — must match stv.lend_program on-chain. */
207
+ oldLendProgram: PublicKey;
208
+ /** New lend program (PublicKey.default to deactivate lend entirely). */
209
+ newLendProgram: PublicKey;
210
+ /** Protocol AUM accounts for old lend update_aum. */
211
+ protocolAumCount: number;
212
+ /** Auto-unroute accounts for old lend withdraw. */
213
+ autoUnrouteCount: number;
214
+ /**
215
+ * remaining_accounts layout:
216
+ * Old section (4 + protocolAumCount + autoUnrouteCount):
217
+ * [oldLendProgram, oldStrategyState, oldStvPosition, oldBaseAta,
218
+ * ...protocolAumAccounts, ...autoUnrouteAccounts]
219
+ * New section (if newLendProgram != default, 4 accounts):
220
+ * [newLendProgram, newStrategyState, newPositionPda, newBaseAta]
221
+ */
222
+ remainingAccounts?: AccountMeta[];
223
+ }
224
+ export declare function createMigrateLendIx(args: MigrateLendArgs, programId?: PublicKey): TransactionInstruction;
179
225
  export declare function buildLendRemainingAccounts(lend: {
180
226
  lendProgram: PublicKey;
181
227
  lendStrategyState: PublicKey;
@@ -186,4 +232,3 @@ export declare function buildStrategyRemainingAccounts(strategies: {
186
232
  strategyState: PublicKey;
187
233
  stvPosition: PublicKey;
188
234
  }[]): AccountMeta[];
189
- //# sourceMappingURL=instructions.d.ts.map
@@ -12,6 +12,7 @@ exports.createWithdrawFromStrategyIx = createWithdrawFromStrategyIx;
12
12
  exports.createCloseStvIx = createCloseStvIx;
13
13
  exports.createAddManagerIx = createAddManagerIx;
14
14
  exports.createRemoveManagerIx = createRemoveManagerIx;
15
+ exports.createMigrateLendIx = createMigrateLendIx;
15
16
  exports.buildLendRemainingAccounts = buildLendRemainingAccounts;
16
17
  exports.buildStrategyRemainingAccounts = buildStrategyRemainingAccounts;
17
18
  const web3_js_1 = require("@solana/web3.js");
@@ -71,7 +72,7 @@ function createInitOrUpdateStvIx(args, programId = constants_1.PROGRAM_ID) {
71
72
  });
72
73
  }
73
74
  function createDepositIx(args, programId = constants_1.PROGRAM_ID) {
74
- const { user, stv, vaultAta, userBaseAta, userEvAta, evMint, feeReceiverEvAta, baseMint, tokenProgram, amount, minShares, protocolAumCount = 0, autoRouteCount = 0, remainingAccounts = [], } = args;
75
+ const { user, config, stv, vaultAta, userBaseAta, userEvAta, evMint, feeReceiverEvAta, baseMint, tokenProgram, amount, minShares, protocolAumCount = 0, autoRouteCount = 0, remainingAccounts = [], } = args;
75
76
  const data = [constants_1.IX_DEPOSIT];
76
77
  (0, buffer_1.writeU64)(data, amount);
77
78
  (0, buffer_1.writeU64)(data, minShares);
@@ -80,6 +81,7 @@ function createDepositIx(args, programId = constants_1.PROGRAM_ID) {
80
81
  return new web3_js_1.TransactionInstruction({
81
82
  keys: [
82
83
  { pubkey: user, isSigner: true, isWritable: true },
84
+ { pubkey: config, isSigner: false, isWritable: false },
83
85
  { pubkey: stv, isSigner: false, isWritable: true },
84
86
  { pubkey: vaultAta, isSigner: false, isWritable: true },
85
87
  { pubkey: userBaseAta, isSigner: false, isWritable: true },
@@ -95,13 +97,14 @@ function createDepositIx(args, programId = constants_1.PROGRAM_ID) {
95
97
  });
96
98
  }
97
99
  function createRequestWithdrawIx(args, programId = constants_1.PROGRAM_ID) {
98
- const { user, stv, withdrawRequest, userEvAta, escrowEvAta, evMint, tokenProgram, systemProgram = web3_js_1.SystemProgram.programId, shares, wrBump, } = args;
100
+ const { user, config, stv, withdrawRequest, userEvAta, escrowEvAta, evMint, tokenProgram, systemProgram = web3_js_1.SystemProgram.programId, shares, wrBump, } = args;
99
101
  const data = [constants_1.IX_REQUEST_WITHDRAW];
100
102
  (0, buffer_1.writeU64)(data, shares);
101
103
  data.push(wrBump & 0xff);
102
104
  return new web3_js_1.TransactionInstruction({
103
105
  keys: [
104
106
  { pubkey: user, isSigner: true, isWritable: true },
107
+ { pubkey: config, isSigner: false, isWritable: false },
105
108
  { pubkey: stv, isSigner: false, isWritable: true },
106
109
  { pubkey: withdrawRequest, isSigner: false, isWritable: true },
107
110
  { pubkey: userEvAta, isSigner: false, isWritable: true },
@@ -115,13 +118,15 @@ function createRequestWithdrawIx(args, programId = constants_1.PROGRAM_ID) {
115
118
  });
116
119
  }
117
120
  function createClaimWithdrawIx(args, programId = constants_1.PROGRAM_ID) {
118
- const { user, stv, withdrawRequest, vaultAta, userBaseAta, baseMint, tokenProgram, remainingAccounts = [], autoUnrouteCount = 0, } = args;
119
- const data = autoUnrouteCount > 0
120
- ? Buffer.from([constants_1.IX_CLAIM_WITHDRAW, autoUnrouteCount & 0xff])
121
- : Buffer.from([constants_1.IX_CLAIM_WITHDRAW]);
121
+ const { user, config, stv, withdrawRequest, vaultAta, userBaseAta, baseMint, tokenProgram, remainingAccounts = [], autoUnrouteCount = 0, } = args;
122
+ // Always serialize the auto_unroute_count byte (write 0 when there's no
123
+ // auto-unroute). The on-chain handler always reads this byte from
124
+ // instruction data.
125
+ const data = Buffer.from([constants_1.IX_CLAIM_WITHDRAW, autoUnrouteCount & 0xff]);
122
126
  return new web3_js_1.TransactionInstruction({
123
127
  keys: [
124
128
  { pubkey: user, isSigner: true, isWritable: true },
129
+ { pubkey: config, isSigner: false, isWritable: false },
125
130
  { pubkey: stv, isSigner: false, isWritable: true },
126
131
  { pubkey: withdrawRequest, isSigner: false, isWritable: true },
127
132
  { pubkey: vaultAta, isSigner: false, isWritable: true },
@@ -135,7 +140,7 @@ function createClaimWithdrawIx(args, programId = constants_1.PROGRAM_ID) {
135
140
  });
136
141
  }
137
142
  function createOverrideClaimWithdrawIx(args, programId = constants_1.PROGRAM_ID) {
138
- const { manager, managerRole, user, stv, withdrawRequest, vaultAta, userBaseAta, baseMint, tokenProgram, remainingAccounts = [], autoUnrouteCount = 0, } = args;
143
+ const { manager, managerRole, config, user, stv, withdrawRequest, vaultAta, userBaseAta, baseMint, tokenProgram, remainingAccounts = [], autoUnrouteCount = 0, } = args;
139
144
  const data = autoUnrouteCount > 0
140
145
  ? Buffer.from([constants_1.IX_OVERRIDE_CLAIM_WITHDRAW, autoUnrouteCount & 0xff])
141
146
  : Buffer.from([constants_1.IX_OVERRIDE_CLAIM_WITHDRAW]);
@@ -143,6 +148,7 @@ function createOverrideClaimWithdrawIx(args, programId = constants_1.PROGRAM_ID)
143
148
  keys: [
144
149
  { pubkey: manager, isSigner: true, isWritable: false },
145
150
  { pubkey: managerRole, isSigner: false, isWritable: false },
151
+ { pubkey: config, isSigner: false, isWritable: false },
146
152
  { pubkey: user, isSigner: false, isWritable: true },
147
153
  { pubkey: stv, isSigner: false, isWritable: true },
148
154
  { pubkey: withdrawRequest, isSigner: false, isWritable: true },
@@ -157,10 +163,11 @@ function createOverrideClaimWithdrawIx(args, programId = constants_1.PROGRAM_ID)
157
163
  });
158
164
  }
159
165
  function createProcessEpochIx(args, programId = constants_1.PROGRAM_ID) {
160
- const { payer, stv, evMint, feeReceiverEvAta, escrowEvAta, vaultAta, tokenProgram, advanceEpoch, protocolAumCount = 0, remainingAccounts = [], } = args;
166
+ const { payer, config, stv, evMint, feeReceiverEvAta, escrowEvAta, vaultAta, tokenProgram, advanceEpoch, protocolAumCount = 0, remainingAccounts = [], } = args;
161
167
  return new web3_js_1.TransactionInstruction({
162
168
  keys: [
163
169
  { pubkey: payer, isSigner: true, isWritable: true },
170
+ { pubkey: config, isSigner: false, isWritable: false },
164
171
  { pubkey: stv, isSigner: false, isWritable: true },
165
172
  { pubkey: evMint, isSigner: false, isWritable: true },
166
173
  { pubkey: feeReceiverEvAta, isSigner: false, isWritable: true },
@@ -174,10 +181,13 @@ function createProcessEpochIx(args, programId = constants_1.PROGRAM_ID) {
174
181
  });
175
182
  }
176
183
  function createDepositToStrategyIx(args, programId = constants_1.PROGRAM_ID) {
177
- const { manager, managerRole, stv, vaultAta, baseMint, strategyProgram, strategyState, stvPosition, strategyBaseAta, tokenProgram, amount, minShares, autoUnrouteCount = 0, remainingAccounts = [], } = args;
184
+ const { manager, managerRole, config, stv, vaultAta, baseMint, strategyProgram, strategyState, stvPosition, strategyBaseAta, tokenProgram, amount, minShares, protocolAumCount, autoUnrouteCount = 0, remainingAccounts = [], } = args;
178
185
  const data = [constants_1.IX_DEPOSIT_TO_STRATEGY];
179
186
  (0, buffer_1.writeU64)(data, amount);
180
187
  (0, buffer_1.writeU64)(data, minShares);
188
+ // Always emit protocol_aum_count at offset 16 (even if 0); auto_unroute_count
189
+ // remains optional and is appended only when > 0.
190
+ data.push(protocolAumCount & 0xff);
181
191
  if (autoUnrouteCount > 0) {
182
192
  data.push(autoUnrouteCount & 0xff);
183
193
  }
@@ -185,6 +195,7 @@ function createDepositToStrategyIx(args, programId = constants_1.PROGRAM_ID) {
185
195
  keys: [
186
196
  { pubkey: manager, isSigner: true, isWritable: true },
187
197
  { pubkey: managerRole, isSigner: false, isWritable: false },
198
+ { pubkey: config, isSigner: false, isWritable: false },
188
199
  { pubkey: stv, isSigner: false, isWritable: true },
189
200
  { pubkey: vaultAta, isSigner: false, isWritable: true },
190
201
  { pubkey: baseMint, isSigner: false, isWritable: false },
@@ -200,13 +211,14 @@ function createDepositToStrategyIx(args, programId = constants_1.PROGRAM_ID) {
200
211
  });
201
212
  }
202
213
  function createWithdrawFromStrategyIx(args, programId = constants_1.PROGRAM_ID) {
203
- const { manager, managerRole, stv, vaultAta, baseMint, strategyProgram, strategyState, stvPosition, strategyBaseAta, tokenProgram, shares, remainingAccounts = [], } = args;
214
+ const { manager, managerRole, config, stv, vaultAta, baseMint, strategyProgram, strategyState, stvPosition, strategyBaseAta, tokenProgram, shares, remainingAccounts = [], } = args;
204
215
  const data = [constants_1.IX_WITHDRAW_FROM_STRATEGY];
205
216
  (0, buffer_1.writeU64)(data, shares);
206
217
  return new web3_js_1.TransactionInstruction({
207
218
  keys: [
208
219
  { pubkey: manager, isSigner: true, isWritable: true },
209
220
  { pubkey: managerRole, isSigner: false, isWritable: false },
221
+ { pubkey: config, isSigner: false, isWritable: false },
210
222
  { pubkey: stv, isSigner: false, isWritable: true },
211
223
  { pubkey: vaultAta, isSigner: false, isWritable: true },
212
224
  { pubkey: baseMint, isSigner: false, isWritable: false },
@@ -222,7 +234,7 @@ function createWithdrawFromStrategyIx(args, programId = constants_1.PROGRAM_ID)
222
234
  });
223
235
  }
224
236
  function createCloseStvIx(args, programId = constants_1.PROGRAM_ID) {
225
- const { admin, payer, config, stv, evMint, vaultAta, baseMint, tokenProgram, remainingAccounts = [] } = args;
237
+ const { admin, payer, config, stv, evMint, vaultAta, tokenProgram } = args;
226
238
  return new web3_js_1.TransactionInstruction({
227
239
  keys: [
228
240
  { pubkey: admin, isSigner: true, isWritable: false },
@@ -231,9 +243,7 @@ function createCloseStvIx(args, programId = constants_1.PROGRAM_ID) {
231
243
  { pubkey: stv, isSigner: false, isWritable: true },
232
244
  { pubkey: evMint, isSigner: false, isWritable: true },
233
245
  { pubkey: vaultAta, isSigner: false, isWritable: true },
234
- { pubkey: baseMint, isSigner: false, isWritable: false },
235
246
  { pubkey: tokenProgram, isSigner: false, isWritable: false },
236
- ...remainingAccounts,
237
247
  ],
238
248
  programId,
239
249
  data: Buffer.from([constants_1.IX_CLOSE_STV]),
@@ -269,6 +279,29 @@ function createRemoveManagerIx(args, programId = constants_1.PROGRAM_ID) {
269
279
  data: Buffer.from([constants_1.IX_REMOVE_MANAGER]),
270
280
  });
271
281
  }
282
+ function createMigrateLendIx(args, programId = constants_1.PROGRAM_ID) {
283
+ const { admin, payer, config, stv, vaultAta, baseMint, tokenProgram, systemProgram = web3_js_1.SystemProgram.programId, oldLendProgram, newLendProgram, protocolAumCount, autoUnrouteCount, remainingAccounts = [], } = args;
284
+ const data = [constants_1.IX_MIGRATE_LEND];
285
+ data.push(...oldLendProgram.toBuffer());
286
+ data.push(...newLendProgram.toBuffer());
287
+ data.push(protocolAumCount & 0xff);
288
+ data.push(autoUnrouteCount & 0xff);
289
+ return new web3_js_1.TransactionInstruction({
290
+ keys: [
291
+ { pubkey: admin, isSigner: true, isWritable: false },
292
+ { pubkey: payer, isSigner: true, isWritable: true },
293
+ { pubkey: config, isSigner: false, isWritable: false },
294
+ { pubkey: stv, isSigner: false, isWritable: true },
295
+ { pubkey: vaultAta, isSigner: false, isWritable: true },
296
+ { pubkey: baseMint, isSigner: false, isWritable: false },
297
+ { pubkey: tokenProgram, isSigner: false, isWritable: false },
298
+ { pubkey: systemProgram, isSigner: false, isWritable: false },
299
+ ...remainingAccounts,
300
+ ],
301
+ programId,
302
+ data: Buffer.from(data),
303
+ });
304
+ }
272
305
  // ---------------------------------------------------------------------------
273
306
  // Remaining Accounts Helpers
274
307
  // ---------------------------------------------------------------------------
@@ -287,4 +320,3 @@ function buildStrategyRemainingAccounts(strategies) {
287
320
  }
288
321
  return accounts;
289
322
  }
290
- //# sourceMappingURL=instructions.js.map
@@ -4,5 +4,12 @@ export declare function findConfigPda(programId?: PublicKey): [PublicKey, number
4
4
  export declare function findStvPda(vaultId: number | BN, programId?: PublicKey): [PublicKey, number];
5
5
  export declare function findEvMintPda(vaultId: number | BN, programId?: PublicKey): [PublicKey, number];
6
6
  export declare function findWithdrawRequestPda(stv: PublicKey, user: PublicKey, epochId: number, programId?: PublicKey): [PublicKey, number];
7
- export declare function findManagerRolePda(stv: PublicKey, manager: PublicKey, programId?: PublicKey): [PublicKey, number];
8
- //# sourceMappingURL=pda.d.ts.map
7
+ /**
8
+ * Derive the per-STV `ManagerRole` PDA for p-STV Core.
9
+ * Seeds: `["manager", stv, manager]`.
10
+ *
11
+ * Note the per-program prefix on the name: each Elemental program has its
12
+ * own `ManagerRole` PDA scoped to a different anchor account
13
+ * (`elemental-lend` → strategy_state, `jlpd-strategy` → config).
14
+ */
15
+ export declare function findStvManagerRolePda(stv: PublicKey, manager: PublicKey, programId?: PublicKey): [PublicKey, number];
@@ -7,7 +7,7 @@ exports.findConfigPda = findConfigPda;
7
7
  exports.findStvPda = findStvPda;
8
8
  exports.findEvMintPda = findEvMintPda;
9
9
  exports.findWithdrawRequestPda = findWithdrawRequestPda;
10
- exports.findManagerRolePda = findManagerRolePda;
10
+ exports.findStvManagerRolePda = findStvManagerRolePda;
11
11
  const web3_js_1 = require("@solana/web3.js");
12
12
  const bn_js_1 = __importDefault(require("bn.js"));
13
13
  const constants_1 = require("./constants");
@@ -27,7 +27,14 @@ function findWithdrawRequestPda(stv, user, epochId, programId = constants_1.PROG
27
27
  epochBuf.writeUInt32LE(epochId, 0);
28
28
  return web3_js_1.PublicKey.findProgramAddressSync([constants_1.WITHDRAW_REQUEST_SEED, stv.toBuffer(), user.toBuffer(), epochBuf], programId);
29
29
  }
30
- function findManagerRolePda(stv, manager, programId = constants_1.PROGRAM_ID) {
30
+ /**
31
+ * Derive the per-STV `ManagerRole` PDA for p-STV Core.
32
+ * Seeds: `["manager", stv, manager]`.
33
+ *
34
+ * Note the per-program prefix on the name: each Elemental program has its
35
+ * own `ManagerRole` PDA scoped to a different anchor account
36
+ * (`elemental-lend` → strategy_state, `jlpd-strategy` → config).
37
+ */
38
+ function findStvManagerRolePda(stv, manager, programId = constants_1.PROGRAM_ID) {
31
39
  return web3_js_1.PublicKey.findProgramAddressSync([constants_1.MANAGER_SEED, stv.toBuffer(), manager.toBuffer()], programId);
32
40
  }
33
- //# sourceMappingURL=pda.js.map
@@ -18,4 +18,3 @@ export interface TokenPrice {
18
18
  * @returns Record<mint, usdPrice>
19
19
  */
20
20
  export declare function fetchUsdPrices(mints: string[]): Promise<Record<string, number>>;
21
- //# sourceMappingURL=prices.d.ts.map
@@ -75,4 +75,3 @@ async function fetchUsdPrices(mints) {
75
75
  }
76
76
  return prices;
77
77
  }
78
- //# sourceMappingURL=prices.js.map
@@ -6,13 +6,9 @@
6
6
  * lend + protocol AUM + strategy pair + auto-route/unroute account building
7
7
  * logic out of the frontend and into the SDK.
8
8
  */
9
- import { AccountMeta, Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
10
- /**
11
- * Minimal connection interface accepted by the context builders.
12
- * Using a structural type avoids nominal type mismatches when the
13
- * consumer has a different version of @solana/web3.js installed.
14
- */
15
- export type SolanaConnection = Pick<Connection, "getAccountInfo" | "getMultipleAccountsInfo" | "getTokenAccountsByOwner" | "getSlot" | "getEpochInfo" | "getBlockTime">;
9
+ import { AccountMeta, PublicKey, TransactionInstruction } from "@solana/web3.js";
10
+ import type { SolanaConnection } from "../common/connection";
11
+ export type { SolanaConnection };
16
12
  /** Minimal vault shape required by the context builders. */
17
13
  export interface VaultInfo {
18
14
  /** STV account address */
@@ -43,6 +39,8 @@ export interface ClaimWithdrawContext {
43
39
  }
44
40
  export interface DepositToStrategyContext {
45
41
  remainingAccounts: AccountMeta[];
42
+ /** Number of protocol AUM accounts (after the 4 fixed lend accounts). */
43
+ protocolAumCount: number;
46
44
  autoUnrouteCount: number;
47
45
  preInstructions: TransactionInstruction[];
48
46
  }
@@ -76,17 +74,19 @@ export declare function buildDepositContext(connection: SolanaConnection, vault:
76
74
  * - If lend is active, derives lend PDAs
77
75
  * - If USDC + Jupiter Lend, appends auto-unroute accounts
78
76
  */
79
- export declare function buildClaimWithdrawContext(connection: SolanaConnection, vault: VaultInfo): Promise<ClaimWithdrawContext>;
77
+ export declare function buildClaimWithdrawContext(vault: VaultInfo): Promise<ClaimWithdrawContext>;
80
78
  /**
81
79
  * Build the complete remaining_accounts for a deposit_to_strategy instruction.
82
80
  *
83
- * Layout: [4 lend, K auto_unroute]
81
+ * Layout: [4 fixed lend, N protocol_aum, K auto_unroute]
84
82
  *
85
- * Same as claim_withdraw: if lend is active, derives lend PDAs.
86
- * If USDC + Jupiter Lend, appends auto-unroute accounts for unsweep.
83
+ * - Fixed lend accounts (if lend is active)
84
+ * - Protocol AUM accounts: required by the on-chain handler to refresh lend
85
+ * valuation via update_lend_aum before the reserved_base liquidity lock check
86
+ * - Auto-unroute accounts: forwarded to the lend withdraw CPI for unsweep
87
87
  *
88
- * Note: no Kamino invest pre-instructions here deposit_to_strategy unsweeps
89
- * from the active protocol (Jupiter Lend for USDC), not Kamino.
88
+ * The `connection` parameter is required to fetch LendStrategyState and
89
+ * resolve protocol AUM accounts.
90
90
  */
91
91
  export declare function buildDepositToStrategyContext(connection: SolanaConnection, vault: VaultInfo): Promise<DepositToStrategyContext>;
92
92
  /**
@@ -96,4 +96,3 @@ export declare function buildDepositToStrategyContext(connection: SolanaConnecti
96
96
  * 'advance': empty remaining_accounts.
97
97
  */
98
98
  export declare function buildProcessEpochContext(connection: SolanaConnection, vault: VaultInfo, phase: "lockPps" | "advance"): Promise<ProcessEpochContext>;
99
- //# sourceMappingURL=remaining-accounts.d.ts.map