@elemental-stv-core/sdk 0.12.0 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elemental-lend/accounts.d.ts +2 -1
- package/dist/elemental-lend/accounts.js +4 -1
- package/dist/elemental-lend/constants.d.ts +4 -6
- package/dist/elemental-lend/constants.js +14 -9
- package/dist/elemental-lend/instructions.d.ts +16 -0
- package/dist/elemental-lend/instructions.js +32 -1
- package/dist/elemental-lend/types.d.ts +2 -1
- package/dist/jlpd-strategy/accounts.d.ts +6 -2
- package/dist/jlpd-strategy/accounts.js +7 -2
- package/dist/jlpd-strategy/constants.d.ts +1 -0
- package/dist/jlpd-strategy/constants.js +4 -2
- package/dist/jlpd-strategy/instructions.d.ts +53 -0
- package/dist/jlpd-strategy/instructions.js +99 -0
- package/dist/jlpd-strategy/types.d.ts +2 -0
- package/dist/p-stv-core/accounts.d.ts +3 -1
- package/dist/p-stv-core/accounts.js +9 -7
- package/dist/p-stv-core/constants.d.ts +0 -4
- package/dist/p-stv-core/constants.js +2 -6
- package/dist/p-stv-core/events.js +0 -5
- package/dist/p-stv-core/instructions.d.ts +49 -36
- package/dist/p-stv-core/instructions.js +68 -52
- package/dist/p-stv-core/types.d.ts +7 -7
- package/package.json +1 -1
|
@@ -23,7 +23,8 @@ import { LendStrategyState, ManagerRole } from "./types";
|
|
|
23
23
|
* [112..144] admin Pubkey
|
|
24
24
|
* [144..464] protocols[10] [Pubkey; 10] (registered protocol accounts)
|
|
25
25
|
* [464..465] protocolCount u8
|
|
26
|
-
* [465..
|
|
26
|
+
* [465..466] managerCount u8
|
|
27
|
+
* [466..472] _padding [u8; 6]
|
|
27
28
|
* [472..536] _reserved [u8; 64]
|
|
28
29
|
*/
|
|
29
30
|
export declare function deserializeLendStrategyState(data: Buffer): LendStrategyState;
|
|
@@ -45,7 +45,8 @@ const pda_1 = require("./pda");
|
|
|
45
45
|
* [112..144] admin Pubkey
|
|
46
46
|
* [144..464] protocols[10] [Pubkey; 10] (registered protocol accounts)
|
|
47
47
|
* [464..465] protocolCount u8
|
|
48
|
-
* [465..
|
|
48
|
+
* [465..466] managerCount u8
|
|
49
|
+
* [466..472] _padding [u8; 6]
|
|
49
50
|
* [472..536] _reserved [u8; 64]
|
|
50
51
|
*/
|
|
51
52
|
function deserializeLendStrategyState(data) {
|
|
@@ -57,6 +58,7 @@ function deserializeLendStrategyState(data) {
|
|
|
57
58
|
throw new Error(`Invalid LendStrategyState discriminator`);
|
|
58
59
|
}
|
|
59
60
|
const protocolCount = (0, buffer_1.readU8)(data, 464);
|
|
61
|
+
const managerCount = (0, buffer_1.readU8)(data, 465);
|
|
60
62
|
const protocols = [];
|
|
61
63
|
for (let i = 0; i < protocolCount; i++) {
|
|
62
64
|
protocols.push((0, buffer_1.readPubkey)(data, 144 + i * 32));
|
|
@@ -76,6 +78,7 @@ function deserializeLendStrategyState(data) {
|
|
|
76
78
|
admin: (0, buffer_1.readPubkey)(data, 112),
|
|
77
79
|
protocols,
|
|
78
80
|
protocolCount,
|
|
81
|
+
managerCount,
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
84
|
/**
|
|
@@ -5,16 +5,14 @@ export declare const POSITION_SEED: Buffer<ArrayBuffer>;
|
|
|
5
5
|
export declare const MANAGER_SEED: Buffer<ArrayBuffer>;
|
|
6
6
|
export { DISC_STRATEGY_STATE, DISC_STV_POSITION, DISC_MANAGER_ROLE, } from "../common/constants";
|
|
7
7
|
export declare const IX_INIT_OR_UPDATE_STRATEGY: Buffer<ArrayBuffer>;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
8
|
+
export declare const IX_CLOSE_STRATEGY: Buffer<ArrayBuffer>;
|
|
9
|
+
export declare const IX_RESET_STRATEGY: Buffer<ArrayBuffer>;
|
|
10
|
+
export declare const IX_ADD_MANAGER: Buffer<ArrayBuffer>;
|
|
11
|
+
export declare const IX_REMOVE_MANAGER: Buffer<ArrayBuffer>;
|
|
12
12
|
export declare const IX_KVAULT_DEPOSIT: Buffer<ArrayBuffer>;
|
|
13
13
|
export declare const IX_KVAULT_WITHDRAW: Buffer<ArrayBuffer>;
|
|
14
14
|
export declare const IX_JUP_LEND_DEPOSIT: Buffer<ArrayBuffer>;
|
|
15
15
|
export declare const IX_JUP_LEND_WITHDRAW: Buffer<ArrayBuffer>;
|
|
16
|
-
export declare const IX_ADD_MANAGER: Buffer<ArrayBuffer>;
|
|
17
|
-
export declare const IX_REMOVE_MANAGER: Buffer<ArrayBuffer>;
|
|
18
16
|
export declare const STRATEGY_STATE_SIZE = 536;
|
|
19
17
|
export declare const STV_POSITION_SIZE = 120;
|
|
20
18
|
export declare const MANAGER_ROLE_SIZE = 80;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PPS_DECIMALS = exports.JUP_LEND_EARN_PROGRAM = exports.KLEND_PROGRAM = exports.KAMINO_VAULT_PROGRAM = exports.MAX_PROTOCOLS = exports.FLAG_PAUSED = exports.MANAGER_ROLE_SIZE = exports.STV_POSITION_SIZE = exports.STRATEGY_STATE_SIZE = exports.
|
|
3
|
+
exports.PPS_DECIMALS = exports.JUP_LEND_EARN_PROGRAM = exports.KLEND_PROGRAM = exports.KAMINO_VAULT_PROGRAM = exports.MAX_PROTOCOLS = exports.FLAG_PAUSED = exports.MANAGER_ROLE_SIZE = exports.STV_POSITION_SIZE = exports.STRATEGY_STATE_SIZE = exports.IX_JUP_LEND_WITHDRAW = exports.IX_JUP_LEND_DEPOSIT = exports.IX_KVAULT_WITHDRAW = exports.IX_KVAULT_DEPOSIT = exports.IX_REMOVE_MANAGER = exports.IX_ADD_MANAGER = exports.IX_RESET_STRATEGY = exports.IX_CLOSE_STRATEGY = exports.IX_INIT_OR_UPDATE_STRATEGY = exports.DISC_MANAGER_ROLE = exports.DISC_STV_POSITION = exports.DISC_STRATEGY_STATE = exports.MANAGER_SEED = exports.POSITION_SEED = exports.STRATEGY_STATE_SEED = exports.PROGRAM_ID = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
exports.PROGRAM_ID = new web3_js_1.PublicKey("EHaGVh7p6xSxZsq4CcEEZhnV5adDvWg1gS1Rc5rLiBpC");
|
|
6
6
|
// PDA Seeds
|
|
@@ -13,19 +13,24 @@ Object.defineProperty(exports, "DISC_STRATEGY_STATE", { enumerable: true, get: f
|
|
|
13
13
|
Object.defineProperty(exports, "DISC_STV_POSITION", { enumerable: true, get: function () { return constants_1.DISC_STV_POSITION; } });
|
|
14
14
|
Object.defineProperty(exports, "DISC_MANAGER_ROLE", { enumerable: true, get: function () { return constants_1.DISC_MANAGER_ROLE; } });
|
|
15
15
|
// Instruction discriminators (Anchor 8-byte)
|
|
16
|
+
// --- Admin instructions ---
|
|
16
17
|
exports.IX_INIT_OR_UPDATE_STRATEGY = Buffer.from([221, 4, 60, 139, 83, 148, 116, 247]);
|
|
17
|
-
|
|
18
|
-
exports.
|
|
19
|
-
|
|
20
|
-
exports.
|
|
21
|
-
exports.IX_KVAULT_DEPOSIT = Buffer.from([240, 233, 97, 12, 52, 70, 230, 243]);
|
|
22
|
-
exports.IX_KVAULT_WITHDRAW = Buffer.from([186, 254, 50, 47, 123, 146, 242, 216]);
|
|
23
|
-
exports.IX_JUP_LEND_DEPOSIT = Buffer.from([87, 129, 182, 64, 170, 11, 223, 59]);
|
|
24
|
-
exports.IX_JUP_LEND_WITHDRAW = Buffer.from([46, 152, 191, 164, 24, 135, 89, 64]);
|
|
18
|
+
// sha256("global:close_strategy")[..8] — verified against elemental_lend.json IDL
|
|
19
|
+
exports.IX_CLOSE_STRATEGY = Buffer.from([56, 247, 170, 246, 89, 221, 134, 200]);
|
|
20
|
+
// sha256("global:reset_strategy")[..8] — verified against elemental_lend.json IDL
|
|
21
|
+
exports.IX_RESET_STRATEGY = Buffer.from([127, 28, 155, 41, 137, 170, 16, 39]);
|
|
25
22
|
// sha256("global:add_manager")[..8]
|
|
26
23
|
exports.IX_ADD_MANAGER = Buffer.from([0x7d, 0x26, 0xc0, 0xd4, 0x65, 0x5b, 0xb3, 0x10]);
|
|
27
24
|
// sha256("global:remove_manager")[..8]
|
|
28
25
|
exports.IX_REMOVE_MANAGER = Buffer.from([0x96, 0x37, 0x9d, 0x4d, 0x80, 0x94, 0x07, 0x0f]);
|
|
26
|
+
// --- Protocol instructions (manager-only via ManagerRole PDA) ---
|
|
27
|
+
exports.IX_KVAULT_DEPOSIT = Buffer.from([240, 233, 97, 12, 52, 70, 230, 243]);
|
|
28
|
+
exports.IX_KVAULT_WITHDRAW = Buffer.from([186, 254, 50, 47, 123, 146, 242, 216]);
|
|
29
|
+
exports.IX_JUP_LEND_DEPOSIT = Buffer.from([87, 129, 182, 64, 170, 11, 223, 59]);
|
|
30
|
+
exports.IX_JUP_LEND_WITHDRAW = Buffer.from([46, 152, 191, 164, 24, 135, 89, 64]);
|
|
31
|
+
// NOTE: The CPI-facing discriminators (init_position, deposit, withdraw, update_aum)
|
|
32
|
+
// are invoked by p-stv-core directly via remaining_accounts; clients do not call them
|
|
33
|
+
// standalone and they are not exported from this SDK module.
|
|
29
34
|
// Account sizes
|
|
30
35
|
exports.STRATEGY_STATE_SIZE = 536;
|
|
31
36
|
exports.STV_POSITION_SIZE = 120;
|
|
@@ -22,6 +22,22 @@ export interface InitOrUpdateStrategyArgs {
|
|
|
22
22
|
remainingAccounts?: AccountMeta[];
|
|
23
23
|
}
|
|
24
24
|
export declare function createInitOrUpdateStrategyIx(args: InitOrUpdateStrategyArgs, programId?: PublicKey): TransactionInstruction;
|
|
25
|
+
export interface CloseStrategyArgs {
|
|
26
|
+
admin: PublicKey;
|
|
27
|
+
payer: PublicKey;
|
|
28
|
+
strategyState: PublicKey;
|
|
29
|
+
strategyBaseAta: PublicKey;
|
|
30
|
+
baseMint: PublicKey;
|
|
31
|
+
tokenProgram: PublicKey;
|
|
32
|
+
/** Optional: required when strategy_base_ata has residual balance to drain. */
|
|
33
|
+
remainingAccounts?: AccountMeta[];
|
|
34
|
+
}
|
|
35
|
+
export declare function createCloseStrategyIx(args: CloseStrategyArgs, programId?: PublicKey): TransactionInstruction;
|
|
36
|
+
export interface ResetStrategyArgs {
|
|
37
|
+
admin: PublicKey;
|
|
38
|
+
strategyState: PublicKey;
|
|
39
|
+
}
|
|
40
|
+
export declare function createResetStrategyIx(args: ResetStrategyArgs, programId?: PublicKey): TransactionInstruction;
|
|
25
41
|
export interface KvaultDepositArgs {
|
|
26
42
|
manager: PublicKey;
|
|
27
43
|
strategyState: PublicKey;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createInitOrUpdateStrategyIx = createInitOrUpdateStrategyIx;
|
|
4
|
+
exports.createCloseStrategyIx = createCloseStrategyIx;
|
|
5
|
+
exports.createResetStrategyIx = createResetStrategyIx;
|
|
4
6
|
exports.createKvaultDepositIx = createKvaultDepositIx;
|
|
5
7
|
exports.createKvaultWithdrawIx = createKvaultWithdrawIx;
|
|
6
8
|
exports.createJupLendDepositIx = createJupLendDepositIx;
|
|
@@ -89,6 +91,33 @@ function createInitOrUpdateStrategyIx(args, programId = constants_1.PROGRAM_ID)
|
|
|
89
91
|
data,
|
|
90
92
|
});
|
|
91
93
|
}
|
|
94
|
+
function createCloseStrategyIx(args, programId = constants_1.PROGRAM_ID) {
|
|
95
|
+
const { admin, payer, strategyState, strategyBaseAta, baseMint, tokenProgram, remainingAccounts = [] } = args;
|
|
96
|
+
return new web3_js_1.TransactionInstruction({
|
|
97
|
+
keys: [
|
|
98
|
+
{ pubkey: admin, isSigner: true, isWritable: false },
|
|
99
|
+
{ pubkey: payer, isSigner: false, isWritable: true },
|
|
100
|
+
{ pubkey: strategyState, isSigner: false, isWritable: true },
|
|
101
|
+
{ pubkey: strategyBaseAta, isSigner: false, isWritable: true },
|
|
102
|
+
{ pubkey: baseMint, isSigner: false, isWritable: false },
|
|
103
|
+
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
104
|
+
...remainingAccounts,
|
|
105
|
+
],
|
|
106
|
+
programId,
|
|
107
|
+
data: constants_1.IX_CLOSE_STRATEGY,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function createResetStrategyIx(args, programId = constants_1.PROGRAM_ID) {
|
|
111
|
+
const { admin, strategyState } = args;
|
|
112
|
+
return new web3_js_1.TransactionInstruction({
|
|
113
|
+
keys: [
|
|
114
|
+
{ pubkey: admin, isSigner: true, isWritable: false },
|
|
115
|
+
{ pubkey: strategyState, isSigner: false, isWritable: true },
|
|
116
|
+
],
|
|
117
|
+
programId,
|
|
118
|
+
data: constants_1.IX_RESET_STRATEGY,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
92
121
|
function createKvaultDepositIx(args, programId = constants_1.PROGRAM_ID) {
|
|
93
122
|
const { manager, strategyState, managerRole, depositorBaseAta, depositorSharesAta, amount, minOut = 0, remainingAccounts } = args;
|
|
94
123
|
const data = [...constants_1.IX_KVAULT_DEPOSIT];
|
|
@@ -185,7 +214,9 @@ function createRemoveManagerIx(args, programId = constants_1.PROGRAM_ID) {
|
|
|
185
214
|
keys: [
|
|
186
215
|
{ pubkey: admin, isSigner: true, isWritable: false },
|
|
187
216
|
{ pubkey: payer, isSigner: false, isWritable: true },
|
|
188
|
-
|
|
217
|
+
// strategy_state is #[account(mut)] in remove_manager.rs:17 — the handler
|
|
218
|
+
// calls load_mut() and decrements manager_count at line 56.
|
|
219
|
+
{ pubkey: strategyState, isSigner: false, isWritable: true },
|
|
189
220
|
{ pubkey: managerRole, isSigner: false, isWritable: true },
|
|
190
221
|
],
|
|
191
222
|
programId,
|
|
@@ -1,11 +1,12 @@
|
|
|
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
|
-
/** Full StrategyState for Elemental Lend (
|
|
4
|
+
/** Full StrategyState for Elemental Lend (536 bytes) */
|
|
5
5
|
export interface LendStrategyState extends StrategyStateHeader {
|
|
6
6
|
admin: PublicKey;
|
|
7
7
|
protocols: PublicKey[];
|
|
8
8
|
protocolCount: number;
|
|
9
|
+
managerCount: number;
|
|
9
10
|
}
|
|
10
11
|
/** ManagerRole account — authorizes a manager for protocol instructions */
|
|
11
12
|
export interface ManagerRole {
|
|
@@ -4,7 +4,7 @@ import type { SolanaConnection } from "../common/connection";
|
|
|
4
4
|
import { JlpdConfig, ManagerRole, JlpStrategyState } from "./types";
|
|
5
5
|
/**
|
|
6
6
|
* JlpdConfig — singleton config shared across all five base-asset strategies.
|
|
7
|
-
* Total
|
|
7
|
+
* Total 392 bytes.
|
|
8
8
|
*
|
|
9
9
|
* Layout (offsets include the 8-byte discriminator):
|
|
10
10
|
* [ 0.. 8] discriminator (sha256("account:JlpdConfig")[..8])
|
|
@@ -16,7 +16,11 @@ import { JlpdConfig, ManagerRole, JlpStrategyState } from "./types";
|
|
|
16
16
|
* [242..244] jlpSlippageBps u16 (max slippage on swap_jlp)
|
|
17
17
|
* [244..245] version u8
|
|
18
18
|
* [245..246] bump u8
|
|
19
|
-
* [246..
|
|
19
|
+
* [246..248] _padding [u8; 2]
|
|
20
|
+
* [248..256] jlpEarnAmount u64
|
|
21
|
+
* [256..288] jlpAdapterProgram Pubkey
|
|
22
|
+
* [288..320] vaultJlpAta Pubkey (canonical vault JLP ATA, carved from _reserved)
|
|
23
|
+
* [320..392] _reserved [u8; 72]
|
|
20
24
|
*/
|
|
21
25
|
export declare function deserializeJlpdConfig(data: Buffer): JlpdConfig;
|
|
22
26
|
/**
|
|
@@ -24,7 +24,7 @@ const pda_1 = require("./pda");
|
|
|
24
24
|
// ---------------------------------------------------------------------------
|
|
25
25
|
/**
|
|
26
26
|
* JlpdConfig — singleton config shared across all five base-asset strategies.
|
|
27
|
-
* Total
|
|
27
|
+
* Total 392 bytes.
|
|
28
28
|
*
|
|
29
29
|
* Layout (offsets include the 8-byte discriminator):
|
|
30
30
|
* [ 0.. 8] discriminator (sha256("account:JlpdConfig")[..8])
|
|
@@ -36,7 +36,11 @@ const pda_1 = require("./pda");
|
|
|
36
36
|
* [242..244] jlpSlippageBps u16 (max slippage on swap_jlp)
|
|
37
37
|
* [244..245] version u8
|
|
38
38
|
* [245..246] bump u8
|
|
39
|
-
* [246..
|
|
39
|
+
* [246..248] _padding [u8; 2]
|
|
40
|
+
* [248..256] jlpEarnAmount u64
|
|
41
|
+
* [256..288] jlpAdapterProgram Pubkey
|
|
42
|
+
* [288..320] vaultJlpAta Pubkey (canonical vault JLP ATA, carved from _reserved)
|
|
43
|
+
* [320..392] _reserved [u8; 72]
|
|
40
44
|
*/
|
|
41
45
|
function deserializeJlpdConfig(data) {
|
|
42
46
|
if (data.length < constants_1.JLPD_CONFIG_SIZE) {
|
|
@@ -61,6 +65,7 @@ function deserializeJlpdConfig(data) {
|
|
|
61
65
|
bump: (0, buffer_1.readU8)(data, 245),
|
|
62
66
|
jlpEarnAmount: (0, buffer_1.readU64)(data, 248),
|
|
63
67
|
jlpAdapterProgram: (0, buffer_1.readPubkey)(data, 256),
|
|
68
|
+
vaultJlpAta: (0, buffer_1.readPubkey)(data, 288),
|
|
64
69
|
};
|
|
65
70
|
}
|
|
66
71
|
/**
|
|
@@ -44,6 +44,7 @@ export declare const IX_WITHDRAW_FROM_ADAPTER: Buffer<ArrayBuffer>;
|
|
|
44
44
|
export declare const IX_ADAPTER_MANAGE: Buffer<ArrayBuffer>;
|
|
45
45
|
export declare const IX_ADD_MANAGER: Buffer<ArrayBuffer>;
|
|
46
46
|
export declare const IX_REMOVE_MANAGER: Buffer<ArrayBuffer>;
|
|
47
|
+
export declare const IX_CLOSE_STRATEGY_STATE: Buffer<ArrayBuffer>;
|
|
47
48
|
export declare const JLPD_CONFIG_SIZE = 392;
|
|
48
49
|
export declare const MANAGER_ROLE_SIZE = 80;
|
|
49
50
|
export declare const STRATEGY_STATE_SIZE = 224;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.JLPD_POOL_DECIMALS = exports.JLPD_VAULT_IDS_BY_POOL = void 0;
|
|
3
|
+
exports.JLPD_POOLS = exports.BPS_DENOMINATOR = exports.PPS_DECIMALS = exports.MAX_PERF_FEE_BPS = exports.MAX_MGMT_FEE_BPS = exports.NUM_ASSETS = exports.FLAG_TEST_MODE = exports.FLAG_REBALANCE_DISABLED = exports.FLAG_JLP_DISABLED = exports.FLAG_WITHDRAWALS_DISABLED = exports.FLAG_DEPOSITS_DISABLED = exports.FLAG_PAUSED = exports.STV_POSITION_SIZE = exports.STRATEGY_STATE_SIZE = exports.MANAGER_ROLE_SIZE = exports.JLPD_CONFIG_SIZE = exports.IX_CLOSE_STRATEGY_STATE = exports.IX_REMOVE_MANAGER = exports.IX_ADD_MANAGER = exports.IX_ADAPTER_MANAGE = exports.IX_WITHDRAW_FROM_ADAPTER = exports.IX_DEPOSIT_TO_ADAPTER = exports.IX_SETTLE_YIELD = exports.IX_BASE_TO_BASE_SWAP = exports.IX_SWAP_JLP = exports.IX_UPDATE_AUM = exports.IX_WITHDRAW = exports.IX_DEPOSIT = exports.IX_CLOSE_POSITION = exports.IX_INIT_POSITION = exports.IX_INIT_OR_UPDATE_STRATEGY_STATE = exports.IX_INIT_OR_UPDATE_CONFIG = exports.DISC_MANAGER_ROLE = exports.DISC_STV_POSITION = exports.DISC_STRATEGY_STATE = exports.DISC_JLPD_CONFIG = exports.POSITION_SEED = exports.STRATEGY_STATE_SEED = exports.MANAGER_SEED = exports.CONFIG_SEED = exports.JUPITER_PERPS_PROGRAM = exports.JLP_POOL_ACCOUNT = exports.DOVES_SOL_USD = exports.DOVES_ETH_USD = exports.DOVES_BTC_USD = exports.JUPITER_PROGRAM = exports.JLP_MINT = exports.PROGRAM_ID_DEVNET = exports.PROGRAM_ID_MAINNET = exports.PROGRAM_ID = void 0;
|
|
4
|
+
exports.JLPD_POOL_DECIMALS = exports.JLPD_VAULT_IDS_BY_POOL = exports.JLPD_VAULT_IDS = void 0;
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
exports.PROGRAM_ID = new web3_js_1.PublicKey("GXqt4ZH2UUBsLWwMNJiZMXza3q7xEGChfW8XjVRjLxr5");
|
|
7
7
|
exports.PROGRAM_ID_MAINNET = exports.PROGRAM_ID;
|
|
@@ -65,6 +65,8 @@ exports.IX_ADAPTER_MANAGE = Buffer.from([210, 30, 127, 237, 109, 210, 2, 212]);
|
|
|
65
65
|
exports.IX_ADD_MANAGER = Buffer.from([125, 38, 192, 212, 101, 91, 179, 16]);
|
|
66
66
|
// sha256("global:remove_manager")[..8]
|
|
67
67
|
exports.IX_REMOVE_MANAGER = Buffer.from([150, 55, 157, 77, 128, 148, 7, 15]);
|
|
68
|
+
// sha256("global:close_strategy_state")[..8] — verified against IDL discriminator
|
|
69
|
+
exports.IX_CLOSE_STRATEGY_STATE = Buffer.from([126, 163, 50, 191, 191, 74, 84, 53]);
|
|
68
70
|
// Account sizes
|
|
69
71
|
exports.JLPD_CONFIG_SIZE = 392;
|
|
70
72
|
exports.MANAGER_ROLE_SIZE = 80;
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
export interface InitOrUpdateConfigArgs {
|
|
3
|
+
/** Must equal params.admin on init; must be existing config.admin on update. Signer + writable. */
|
|
4
|
+
payer: PublicKey;
|
|
5
|
+
/** Config PDA (init_if_needed). */
|
|
6
|
+
config: PublicKey;
|
|
7
|
+
/** JLP token mint — used for ATA derivation on init; must still be passed on update. */
|
|
8
|
+
jlpMint: PublicKey;
|
|
9
|
+
/** Token program that owns the JLP mint's ATA namespace. */
|
|
10
|
+
tokenProgram: PublicKey;
|
|
11
|
+
systemProgram?: PublicKey;
|
|
12
|
+
/** Required on init; ignored on update (pass null on update). */
|
|
13
|
+
jlpMintParam?: PublicKey | null;
|
|
14
|
+
/** Required on init; ignored on update (pass null on update). */
|
|
15
|
+
baseAssetMints?: [PublicKey, PublicKey, PublicKey, PublicKey, PublicKey] | null;
|
|
16
|
+
/** Admin pubkey (sets config.admin; must equal payer on init). */
|
|
17
|
+
admin: PublicKey;
|
|
18
|
+
/** Config flags (FLAG_PAUSED, FLAG_DEPOSITS_DISABLED, etc). */
|
|
19
|
+
flags: number;
|
|
20
|
+
/** Oracle slippage tolerance BPS (max 1000). */
|
|
21
|
+
jlpSlippageBps: number;
|
|
22
|
+
/** Oracle staleness threshold in seconds (1..600). Defaults to 60 on init when null. */
|
|
23
|
+
oracleStalenessSecs?: number | null;
|
|
24
|
+
/** Adapter program pubkey (Pubkey::default = no adapter). */
|
|
25
|
+
jlpAdapterProgram?: PublicKey | null;
|
|
26
|
+
}
|
|
27
|
+
export declare function createInitOrUpdateConfigIx(args: InitOrUpdateConfigArgs, programId?: PublicKey): TransactionInstruction;
|
|
2
28
|
export interface InitOrUpdateStrategyStateArgs {
|
|
3
29
|
/** Admin signer; also the rent payer for the init_if_needed ATAs (writable). */
|
|
4
30
|
admin: PublicKey;
|
|
@@ -87,3 +113,30 @@ export interface RemoveManagerArgs {
|
|
|
87
113
|
* 3. manager_role (writable — closed)
|
|
88
114
|
*/
|
|
89
115
|
export declare function createRemoveManagerIx(args: RemoveManagerArgs, programId?: PublicKey): TransactionInstruction;
|
|
116
|
+
export interface CloseStrategyStateArgs {
|
|
117
|
+
/** Admin signer — must match config.admin. */
|
|
118
|
+
admin: PublicKey;
|
|
119
|
+
/** Receives rent refund from the closed StrategyState account. */
|
|
120
|
+
payer: PublicKey;
|
|
121
|
+
/** JLPD Config PDA. */
|
|
122
|
+
config: PublicKey;
|
|
123
|
+
/** The StrategyState PDA to close. */
|
|
124
|
+
strategyState: PublicKey;
|
|
125
|
+
/** Base asset mint stored in strategy_state.base_mint. */
|
|
126
|
+
baseMint: PublicKey;
|
|
127
|
+
/** JLP mint stored in config.jlp_mint. */
|
|
128
|
+
jlpMint: PublicKey;
|
|
129
|
+
/** Canonical base ATA owned by StrategyState PDA (must have zero balance). */
|
|
130
|
+
strategyBaseAta: PublicKey;
|
|
131
|
+
/** Canonical JLP staging ATA owned by StrategyState PDA (must have zero balance). */
|
|
132
|
+
strategyJlpAta: PublicKey;
|
|
133
|
+
/** Token program that owns the ATA namespace (used for canonical ATA derivation). */
|
|
134
|
+
tokenProgram: PublicKey;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Create a `close_strategy_state` instruction for the JLPD Strategy program.
|
|
138
|
+
*
|
|
139
|
+
* Discriminator verified against IDL:
|
|
140
|
+
* sha256("global:close_strategy_state")[..8] = [126, 163, 50, 191, 191, 74, 84, 53]
|
|
141
|
+
*/
|
|
142
|
+
export declare function createCloseStrategyStateIx(args: CloseStrategyStateArgs, programId?: PublicKey): TransactionInstruction;
|
|
@@ -1,12 +1,84 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInitOrUpdateConfigIx = createInitOrUpdateConfigIx;
|
|
3
4
|
exports.createInitOrUpdateStrategyStateIx = createInitOrUpdateStrategyStateIx;
|
|
4
5
|
exports.createAddManagerIx = createAddManagerIx;
|
|
5
6
|
exports.createRemoveManagerIx = createRemoveManagerIx;
|
|
7
|
+
exports.createCloseStrategyStateIx = createCloseStrategyStateIx;
|
|
6
8
|
const web3_js_1 = require("@solana/web3.js");
|
|
7
9
|
const spl_token_1 = require("@solana/spl-token");
|
|
8
10
|
const buffer_1 = require("../common/buffer");
|
|
9
11
|
const constants_1 = require("./constants");
|
|
12
|
+
/**
|
|
13
|
+
* Serialize `InitOrUpdateConfigParams` in Anchor/Borsh field order.
|
|
14
|
+
* Option<T> → 0x00 (None) or 0x01 + value bytes (Some).
|
|
15
|
+
*/
|
|
16
|
+
function serializeInitOrUpdateConfigParams(args) {
|
|
17
|
+
const parts = [];
|
|
18
|
+
// jlp_mint: Option<Pubkey>
|
|
19
|
+
if (args.jlpMintParam != null) {
|
|
20
|
+
parts.push(0x01);
|
|
21
|
+
parts.push(...args.jlpMintParam.toBuffer());
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
parts.push(0x00);
|
|
25
|
+
}
|
|
26
|
+
// base_asset_mints: Option<[Pubkey; 5]>
|
|
27
|
+
if (args.baseAssetMints != null) {
|
|
28
|
+
parts.push(0x01);
|
|
29
|
+
for (const m of args.baseAssetMints) {
|
|
30
|
+
parts.push(...m.toBuffer());
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
parts.push(0x00);
|
|
35
|
+
}
|
|
36
|
+
// admin: Pubkey (not optional)
|
|
37
|
+
parts.push(...args.admin.toBuffer());
|
|
38
|
+
// flags: u16 LE
|
|
39
|
+
const flagsBuf = Buffer.alloc(2);
|
|
40
|
+
flagsBuf.writeUInt16LE(args.flags & 0xffff, 0);
|
|
41
|
+
parts.push(...flagsBuf);
|
|
42
|
+
// jlp_slippage_bps: u16 LE
|
|
43
|
+
const slippageBuf = Buffer.alloc(2);
|
|
44
|
+
slippageBuf.writeUInt16LE(args.jlpSlippageBps & 0xffff, 0);
|
|
45
|
+
parts.push(...slippageBuf);
|
|
46
|
+
// oracle_staleness_threshold: Option<u64>
|
|
47
|
+
if (args.oracleStalenessSecs != null) {
|
|
48
|
+
parts.push(0x01);
|
|
49
|
+
const stalenessArr = [];
|
|
50
|
+
(0, buffer_1.writeU64)(stalenessArr, args.oracleStalenessSecs);
|
|
51
|
+
parts.push(...stalenessArr);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
parts.push(0x00);
|
|
55
|
+
}
|
|
56
|
+
// jlp_adapter_program: Option<Pubkey>
|
|
57
|
+
if (args.jlpAdapterProgram != null) {
|
|
58
|
+
parts.push(0x01);
|
|
59
|
+
parts.push(...args.jlpAdapterProgram.toBuffer());
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
parts.push(0x00);
|
|
63
|
+
}
|
|
64
|
+
return parts;
|
|
65
|
+
}
|
|
66
|
+
function createInitOrUpdateConfigIx(args, programId = constants_1.PROGRAM_ID) {
|
|
67
|
+
const { payer, config, jlpMint, tokenProgram, systemProgram = web3_js_1.SystemProgram.programId, } = args;
|
|
68
|
+
const paramBytes = serializeInitOrUpdateConfigParams(args);
|
|
69
|
+
const data = Buffer.concat([constants_1.IX_INIT_OR_UPDATE_CONFIG, Buffer.from(paramBytes)]);
|
|
70
|
+
return new web3_js_1.TransactionInstruction({
|
|
71
|
+
keys: [
|
|
72
|
+
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
73
|
+
{ pubkey: config, isSigner: false, isWritable: true },
|
|
74
|
+
{ pubkey: jlpMint, isSigner: false, isWritable: false },
|
|
75
|
+
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
76
|
+
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
77
|
+
],
|
|
78
|
+
programId,
|
|
79
|
+
data,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
10
82
|
/**
|
|
11
83
|
* Create an `init_or_update_strategy_state` instruction for the JLPD program.
|
|
12
84
|
*
|
|
@@ -116,3 +188,30 @@ function createRemoveManagerIx(args, programId = constants_1.PROGRAM_ID) {
|
|
|
116
188
|
data,
|
|
117
189
|
});
|
|
118
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* Create a `close_strategy_state` instruction for the JLPD Strategy program.
|
|
193
|
+
*
|
|
194
|
+
* Discriminator verified against IDL:
|
|
195
|
+
* sha256("global:close_strategy_state")[..8] = [126, 163, 50, 191, 191, 74, 84, 53]
|
|
196
|
+
*/
|
|
197
|
+
function createCloseStrategyStateIx(args, programId = constants_1.PROGRAM_ID) {
|
|
198
|
+
const { admin, payer, config, strategyState, baseMint, jlpMint, strategyBaseAta, strategyJlpAta, tokenProgram, } = args;
|
|
199
|
+
// Discriminator only — no additional instruction data
|
|
200
|
+
const data = Buffer.alloc(8);
|
|
201
|
+
constants_1.IX_CLOSE_STRATEGY_STATE.copy(data, 0);
|
|
202
|
+
return new web3_js_1.TransactionInstruction({
|
|
203
|
+
keys: [
|
|
204
|
+
{ pubkey: admin, isSigner: true, isWritable: false },
|
|
205
|
+
{ pubkey: payer, isSigner: false, isWritable: true },
|
|
206
|
+
{ pubkey: config, isSigner: false, isWritable: false },
|
|
207
|
+
{ pubkey: strategyState, isSigner: false, isWritable: true },
|
|
208
|
+
{ pubkey: baseMint, isSigner: false, isWritable: false },
|
|
209
|
+
{ pubkey: jlpMint, isSigner: false, isWritable: false },
|
|
210
|
+
{ pubkey: strategyBaseAta, isSigner: false, isWritable: false },
|
|
211
|
+
{ pubkey: strategyJlpAta, isSigner: false, isWritable: false },
|
|
212
|
+
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
213
|
+
],
|
|
214
|
+
programId,
|
|
215
|
+
data,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
@@ -15,6 +15,8 @@ export interface JlpdConfig {
|
|
|
15
15
|
jlpEarnAmount: BN;
|
|
16
16
|
/** Whitelisted adapter program. PublicKey.default = no adapter. */
|
|
17
17
|
jlpAdapterProgram: PublicKey;
|
|
18
|
+
/** Canonical vault JLP ATA stored on-chain (ATA(config_pda, jlp_mint)). Carved from _reserved; SIZE unchanged. */
|
|
19
|
+
vaultJlpAta: PublicKey;
|
|
18
20
|
}
|
|
19
21
|
/** ManagerRole PDA (80 bytes) — grants manager access to rebalance operations */
|
|
20
22
|
export interface ManagerRole {
|
|
@@ -62,7 +62,9 @@ export declare function deserializeGlobalConfig(data: Buffer): GlobalConfig;
|
|
|
62
62
|
* [424..456] feeReceiverEvAta Pubkey (_OFFSET_FEE_RECEIVER_EV_ATA == 424)
|
|
63
63
|
* [456..464] lockedSeedShares u64 (_OFFSET_LOCKED_SEED_SHARES == 456)
|
|
64
64
|
* [464..465] withdrawalMode u8 (_OFFSET_WITHDRAWAL_MODE == 464; 0=instant, 1=X, 2=X+1)
|
|
65
|
-
* [465..
|
|
65
|
+
* [465..468] _reservedPad [u8; 3] (_OFFSET_RESERVED_PAD == 465; alignment before last_nav_ts)
|
|
66
|
+
* [468..472] lastNavTs u32 (_OFFSET_LAST_NAV_TS == 468; unix seconds; 0 = no epoch yet)
|
|
67
|
+
* [472..664] _reserved [u8; 192] (_OFFSET_RESERVED == 472)
|
|
66
68
|
*/
|
|
67
69
|
export declare function deserializeStv(data: Buffer): Stv;
|
|
68
70
|
/**
|
|
@@ -105,7 +105,9 @@ function deserializeGlobalConfig(data) {
|
|
|
105
105
|
* [424..456] feeReceiverEvAta Pubkey (_OFFSET_FEE_RECEIVER_EV_ATA == 424)
|
|
106
106
|
* [456..464] lockedSeedShares u64 (_OFFSET_LOCKED_SEED_SHARES == 456)
|
|
107
107
|
* [464..465] withdrawalMode u8 (_OFFSET_WITHDRAWAL_MODE == 464; 0=instant, 1=X, 2=X+1)
|
|
108
|
-
* [465..
|
|
108
|
+
* [465..468] _reservedPad [u8; 3] (_OFFSET_RESERVED_PAD == 465; alignment before last_nav_ts)
|
|
109
|
+
* [468..472] lastNavTs u32 (_OFFSET_LAST_NAV_TS == 468; unix seconds; 0 = no epoch yet)
|
|
110
|
+
* [472..664] _reserved [u8; 192] (_OFFSET_RESERVED == 472)
|
|
109
111
|
*/
|
|
110
112
|
function deserializeStv(data) {
|
|
111
113
|
if (data.length < constants_1.STV_SIZE) {
|
|
@@ -115,13 +117,12 @@ function deserializeStv(data) {
|
|
|
115
117
|
if (!disc.equals(constants_1.DISC_STV)) {
|
|
116
118
|
throw new Error(`Invalid Stv discriminator`);
|
|
117
119
|
}
|
|
118
|
-
// v2
|
|
119
|
-
//
|
|
120
|
+
// v2 gate: version must be 2 (stv.rs Stv::from_account — discriminator +
|
|
121
|
+
// version==2 is the complete loader gate; admin!=0 is enforced at write time
|
|
122
|
+
// by init_or_update_stv and is NOT re-checked by the on-chain loader).
|
|
120
123
|
const version = (0, buffer_1.readU8)(data, 405);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (version !== 2 || adminIsZero) {
|
|
124
|
-
throw new Error(`Stv account is not v2-migrated: version=${version}, admin=${adminIsZero ? "zero" : "nonzero"}`);
|
|
124
|
+
if (version !== 2) {
|
|
125
|
+
throw new Error(`Stv account is not v2: version=${version}`);
|
|
125
126
|
}
|
|
126
127
|
// childVaults: [u64; 4] at offset 264, MAX_CHILD_VAULTS = 4
|
|
127
128
|
const childVaults = [];
|
|
@@ -167,6 +168,7 @@ function deserializeStv(data) {
|
|
|
167
168
|
feeReceiverEvAta: (0, buffer_1.readPubkey)(data, 424),
|
|
168
169
|
lockedSeedShares: (0, buffer_1.readU64)(data, 456),
|
|
169
170
|
withdrawalMode: (0, buffer_1.readU8)(data, 464),
|
|
171
|
+
lastNavTs: (0, buffer_1.readU32)(data, 468),
|
|
170
172
|
};
|
|
171
173
|
}
|
|
172
174
|
/**
|
|
@@ -31,8 +31,6 @@ export declare const IX_PROCESS_DELAYED_DEPOSIT = 15;
|
|
|
31
31
|
export declare const IX_MIGRATE_CANCEL = 16;
|
|
32
32
|
export declare const IX_INSTANT_WITHDRAW = 17;
|
|
33
33
|
export declare const IX_SEED_STV = 18;
|
|
34
|
-
/** migrate_stv_layout (disc 0x13 = 19) — one-shot global-admin v1→v2 layout migration. */
|
|
35
|
-
export declare const IX_MIGRATE_STV_LAYOUT = 19;
|
|
36
34
|
/** accept_vault_admin (disc 0x14 = 20) — complete a two-step vault-admin rotation. */
|
|
37
35
|
export declare const IX_ACCEPT_VAULT_ADMIN = 20;
|
|
38
36
|
export declare const EVT_CONFIG_INITIALIZED = 0;
|
|
@@ -58,8 +56,6 @@ export declare const EVT_MIGRATE_EXECUTED = 19;
|
|
|
58
56
|
export declare const EVT_DELAYED_DEPOSIT_PROCESSED = 20;
|
|
59
57
|
export declare const EVT_INSTANT_WITHDRAWN = 21;
|
|
60
58
|
export declare const EVT_STV_SEEDED = 22;
|
|
61
|
-
/** StvAdminSet — emitted by migrate_stv_layout. Fields: vault_id(8), admin(32). */
|
|
62
|
-
export declare const EVT_STV_ADMIN_SET = 23;
|
|
63
59
|
/** AdminRotationStarted — emitted when update sets pending_admin to nonzero. Fields: vault_id(8), newPendingAdmin(32). */
|
|
64
60
|
export declare const EVT_ADMIN_ROTATION_STARTED = 24;
|
|
65
61
|
/** AdminRotationAccepted — emitted by accept_vault_admin. Fields: vault_id(8), newAdmin(32). */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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_ACCEPT_VAULT_ADMIN = exports.
|
|
4
|
-
exports.MANAGER_ROLE_SIZE = exports.DELAYED_DEPOSIT_REQUEST_SIZE = exports.WITHDRAW_REQUEST_SIZE = exports.STV_SIZE = exports.GLOBAL_CONFIG_SIZE = exports.WR_FLAG_MIGRATE = exports.MAX_FEE_BPS = exports.FEE_CAP_BPS = exports.MAX_STRATEGIES = exports.MAX_CHILD_VAULTS = exports.STALENESS_THRESHOLD = exports.BPS_DENOMINATOR = exports.PPS_DECIMALS = exports.CFG_FLAG_GLOBAL_PAUSED = exports.FLAG_SEEDED = exports.FLAG_BYPASS_MIGRATE_DST_WAITOUT = exports.FLAG_BYPASS_MIGRATE_SRC_WAITOUT = exports.FLAG_DELAYED_DEPOSIT = exports.FLAG_DEPOSIT_FEE_ON_MIGRATE = exports.FLAG_WITHDRAWAL_FEE_ON_MIGRATE = exports.FLAG_BYPASS_WITHDRAW_LIMIT = exports.FLAG_ALLOCATOR = exports.FLAG_REBALANCE_DISABLED = exports.FLAG_WITHDRAWALS_DISABLED = exports.FLAG_DEPOSITS_DISABLED = exports.FLAG_PAUSED = exports.EVT_ADMIN_ROTATION_ACCEPTED = exports.EVT_ADMIN_ROTATION_STARTED = exports.
|
|
3
|
+
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_ACCEPT_VAULT_ADMIN = exports.IX_SEED_STV = exports.IX_INSTANT_WITHDRAW = exports.IX_MIGRATE_CANCEL = exports.IX_PROCESS_DELAYED_DEPOSIT = exports.IX_MIGRATE_EXECUTE = exports.IX_MIGRATE_REQUEST = 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_DELAYED_DEPOSIT_REQUEST = exports.DISC_WITHDRAW_REQUEST = exports.DISC_STV = exports.DISC_GLOBAL_CONFIG = exports.MANAGER_SEED = exports.DELAYED_DEPOSIT_SEED = exports.MIGRATE_REQUEST_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.DELAYED_DEPOSIT_REQUEST_SIZE = exports.WITHDRAW_REQUEST_SIZE = exports.STV_SIZE = exports.GLOBAL_CONFIG_SIZE = exports.WR_FLAG_MIGRATE = exports.MAX_FEE_BPS = exports.FEE_CAP_BPS = exports.MAX_STRATEGIES = exports.MAX_CHILD_VAULTS = exports.STALENESS_THRESHOLD = exports.BPS_DENOMINATOR = exports.PPS_DECIMALS = exports.CFG_FLAG_GLOBAL_PAUSED = exports.FLAG_SEEDED = exports.FLAG_BYPASS_MIGRATE_DST_WAITOUT = exports.FLAG_BYPASS_MIGRATE_SRC_WAITOUT = exports.FLAG_DELAYED_DEPOSIT = exports.FLAG_DEPOSIT_FEE_ON_MIGRATE = exports.FLAG_WITHDRAWAL_FEE_ON_MIGRATE = exports.FLAG_BYPASS_WITHDRAW_LIMIT = exports.FLAG_ALLOCATOR = exports.FLAG_REBALANCE_DISABLED = exports.FLAG_WITHDRAWALS_DISABLED = exports.FLAG_DEPOSITS_DISABLED = exports.FLAG_PAUSED = exports.EVT_ADMIN_ROTATION_ACCEPTED = exports.EVT_ADMIN_ROTATION_STARTED = exports.EVT_STV_SEEDED = exports.EVT_INSTANT_WITHDRAWN = exports.EVT_DELAYED_DEPOSIT_PROCESSED = exports.EVT_MIGRATE_EXECUTED = exports.EVT_MIGRATE_REQUESTED = exports.EVT_LEND_MIGRATED = void 0;
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
7
7
|
// Program ID
|
|
@@ -57,8 +57,6 @@ exports.IX_PROCESS_DELAYED_DEPOSIT = 15;
|
|
|
57
57
|
exports.IX_MIGRATE_CANCEL = 16;
|
|
58
58
|
exports.IX_INSTANT_WITHDRAW = 17;
|
|
59
59
|
exports.IX_SEED_STV = 18;
|
|
60
|
-
/** migrate_stv_layout (disc 0x13 = 19) — one-shot global-admin v1→v2 layout migration. */
|
|
61
|
-
exports.IX_MIGRATE_STV_LAYOUT = 19;
|
|
62
60
|
/** accept_vault_admin (disc 0x14 = 20) — complete a two-step vault-admin rotation. */
|
|
63
61
|
exports.IX_ACCEPT_VAULT_ADMIN = 20;
|
|
64
62
|
// ---------------------------------------------------------------------------
|
|
@@ -87,8 +85,6 @@ exports.EVT_MIGRATE_EXECUTED = 19;
|
|
|
87
85
|
exports.EVT_DELAYED_DEPOSIT_PROCESSED = 20;
|
|
88
86
|
exports.EVT_INSTANT_WITHDRAWN = 21;
|
|
89
87
|
exports.EVT_STV_SEEDED = 22;
|
|
90
|
-
/** StvAdminSet — emitted by migrate_stv_layout. Fields: vault_id(8), admin(32). */
|
|
91
|
-
exports.EVT_STV_ADMIN_SET = 23;
|
|
92
88
|
/** AdminRotationStarted — emitted when update sets pending_admin to nonzero. Fields: vault_id(8), newPendingAdmin(32). */
|
|
93
89
|
exports.EVT_ADMIN_ROTATION_STARTED = 24;
|
|
94
90
|
/** AdminRotationAccepted — emitted by accept_vault_admin. Fields: vault_id(8), newAdmin(32). */
|
|
@@ -213,11 +213,6 @@ function parseEventBuffer(data) {
|
|
|
213
213
|
return data.length >= 17 ? {
|
|
214
214
|
name: "StvSeeded", vaultId: (0, buffer_1.readU64)(data, 1), amount: (0, buffer_1.readU64)(data, 9),
|
|
215
215
|
} : null;
|
|
216
|
-
case constants_1.EVT_STV_ADMIN_SET:
|
|
217
|
-
// Fields: vault_id(8), admin(32) → total payload 41 bytes (with 1-byte disc = 41)
|
|
218
|
-
return data.length >= 41 ? {
|
|
219
|
-
name: "StvAdminSet", vaultId: (0, buffer_1.readU64)(data, 1), admin: (0, buffer_1.readPubkey)(data, 9),
|
|
220
|
-
} : null;
|
|
221
216
|
case constants_1.EVT_ADMIN_ROTATION_STARTED:
|
|
222
217
|
// Fields: vault_id(8), new_pending_admin(32) → total payload 41 bytes
|
|
223
218
|
return data.length >= 41 ? {
|
|
@@ -250,6 +250,13 @@ export interface CloseStvArgs {
|
|
|
250
250
|
evMint: PublicKey;
|
|
251
251
|
vaultAta: PublicKey;
|
|
252
252
|
tokenProgram: PublicKey;
|
|
253
|
+
/** canonical ATA(stv_pda, ev_mint) — escrow holding seed shares. */
|
|
254
|
+
escrowEvAta?: PublicKey;
|
|
255
|
+
baseMint?: PublicKey;
|
|
256
|
+
/** ATA(admin, base_mint) — receives drained seed base. */
|
|
257
|
+
adminBaseAta?: PublicKey;
|
|
258
|
+
strategyProgram?: PublicKey;
|
|
259
|
+
stvPosition?: PublicKey;
|
|
253
260
|
}
|
|
254
261
|
export declare function createCloseStvIx(args: CloseStvArgs, programId?: PublicKey): TransactionInstruction;
|
|
255
262
|
export interface AddManagerArgs {
|
|
@@ -340,9 +347,8 @@ export interface MigrateRequestArgs {
|
|
|
340
347
|
*/
|
|
341
348
|
export declare function createMigrateRequestIx(args: MigrateRequestArgs, programId?: PublicKey): TransactionInstruction;
|
|
342
349
|
export interface MigrateExecuteArgs {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
managerRole: PublicKey;
|
|
350
|
+
/** Any signer. Permissionless — no ManagerRole required. */
|
|
351
|
+
caller: PublicKey;
|
|
346
352
|
/** GlobalConfig PDA — checked for CFG_FLAG_GLOBAL_PAUSED. */
|
|
347
353
|
config: PublicKey;
|
|
348
354
|
sourceStv: PublicKey;
|
|
@@ -360,7 +366,7 @@ export interface MigrateExecuteArgs {
|
|
|
360
366
|
destFeeRecvEvAta: PublicKey;
|
|
361
367
|
baseMint: PublicKey;
|
|
362
368
|
tokenProgram: PublicKey;
|
|
363
|
-
/** Account that receives the WR rent on close — must equal wr.user (slot
|
|
369
|
+
/** Account that receives the WR rent on close — must equal wr.user (slot 13). */
|
|
364
370
|
wrUserAccount: PublicKey;
|
|
365
371
|
/** Source-lend protocol AUM account count for update_aum. */
|
|
366
372
|
srcProtocolAumCount: number;
|
|
@@ -370,6 +376,16 @@ export interface MigrateExecuteArgs {
|
|
|
370
376
|
srcAutoUnrouteCount: number;
|
|
371
377
|
/** Dest-lend auto-route account count (sweep). */
|
|
372
378
|
dstAutoRouteCount: number;
|
|
379
|
+
/**
|
|
380
|
+
* Deferred path (dest has FLAG_DELAYED_DEPOSIT and FLAG_BYPASS_MIGRATE_DST_WAITOUT
|
|
381
|
+
* is unset): pass the DelayedDepositRequest PDA (writable, new account).
|
|
382
|
+
* The PDA is appended as the last two remaining_accounts after the normal
|
|
383
|
+
* lend/strategy accounts: [dest_delayed_request(w), system_program].
|
|
384
|
+
* Also requires destDelayedBump (the bump for the new PDA).
|
|
385
|
+
*/
|
|
386
|
+
destDelayedRequest?: PublicKey;
|
|
387
|
+
destDelayedBump?: number;
|
|
388
|
+
systemProgram?: PublicKey;
|
|
373
389
|
/**
|
|
374
390
|
* remaining_accounts (assemble with buildMigrateRemainingAccounts):
|
|
375
391
|
* src lend fixed(4) + src protocol AUM(srcProtocolAumCount)
|
|
@@ -377,17 +393,41 @@ export interface MigrateExecuteArgs {
|
|
|
377
393
|
* + dst lend fixed(4) + dst protocol AUM(dstProtocolAumCount)
|
|
378
394
|
* + dst strategy pairs(0 or 2) + dst auto-route(dstAutoRouteCount)
|
|
379
395
|
* Omit a lend section entirely when that side's lend_program is unset.
|
|
396
|
+
* Do NOT include dest_delayed_request/system_program here — pass them via
|
|
397
|
+
* destDelayedRequest/systemProgram instead; they are appended automatically.
|
|
380
398
|
*/
|
|
381
399
|
remainingAccounts?: AccountMeta[];
|
|
382
400
|
}
|
|
383
401
|
/**
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
* dst_protocol_aum_count, src_auto_unroute_count, dst_auto_route_count
|
|
388
|
-
* (migrate_execute.rs:94-100).
|
|
402
|
+
* 14 fixed accounts (migrate_execute.rs:97 destructure). Permissionless.
|
|
403
|
+
* Instruction data: 4 bytes always; 5th byte (dest_delayed_bump) required
|
|
404
|
+
* on the deferred path (migrate_execute.rs:104-114 / 387-401).
|
|
389
405
|
*/
|
|
390
406
|
export declare function createMigrateExecuteIx(args: MigrateExecuteArgs, programId?: PublicKey): TransactionInstruction;
|
|
407
|
+
export interface MigrateCancelArgs {
|
|
408
|
+
/** Must equal wr.user. Signer + writable (receives WR rent back). */
|
|
409
|
+
user: PublicKey;
|
|
410
|
+
/** GlobalConfig PDA. */
|
|
411
|
+
config: PublicKey;
|
|
412
|
+
/** Source STV (writable). */
|
|
413
|
+
stv: PublicKey;
|
|
414
|
+
/** Migrate-kind WithdrawRequest PDA (writable). */
|
|
415
|
+
wrAccount: PublicKey;
|
|
416
|
+
/** Canonical vault ATA (writable). */
|
|
417
|
+
vaultAta: PublicKey;
|
|
418
|
+
/** User's base token ATA (receives base). */
|
|
419
|
+
userBaseAta: PublicKey;
|
|
420
|
+
/** Fee receiver's base ATA. */
|
|
421
|
+
feeReceiverBaseAta: PublicKey;
|
|
422
|
+
baseMint: PublicKey;
|
|
423
|
+
tokenProgram: PublicKey;
|
|
424
|
+
/** Lend auto-unroute accounts (0 = none). */
|
|
425
|
+
autoUnrouteCount?: number;
|
|
426
|
+
/** Lend protocol AUM accounts (0 = none). */
|
|
427
|
+
protocolAumCount?: number;
|
|
428
|
+
remainingAccounts?: AccountMeta[];
|
|
429
|
+
}
|
|
430
|
+
export declare function createMigrateCancelIx(args: MigrateCancelArgs, programId?: PublicKey): TransactionInstruction;
|
|
391
431
|
export declare function buildLendRemainingAccounts(lend: {
|
|
392
432
|
lendProgram: PublicKey;
|
|
393
433
|
lendStrategyState: PublicKey;
|
|
@@ -497,33 +537,6 @@ export interface SeedStvArgs {
|
|
|
497
537
|
amount: BN | number;
|
|
498
538
|
}
|
|
499
539
|
export declare function createSeedStvIx(args: SeedStvArgs, programId?: PublicKey): TransactionInstruction;
|
|
500
|
-
export interface MigrateStvLayoutArgs {
|
|
501
|
-
/** Must match GlobalConfig.admin. */
|
|
502
|
-
admin: PublicKey;
|
|
503
|
-
/** GlobalConfig PDA. */
|
|
504
|
-
config: PublicKey;
|
|
505
|
-
/** The v1-shaped STV account to migrate (writable). */
|
|
506
|
-
stv: PublicKey;
|
|
507
|
-
/**
|
|
508
|
-
* Expected vault_id from the v1 account (guards against passing the wrong STV
|
|
509
|
-
* for a given arg set — the handler hard-reverts on mismatch).
|
|
510
|
-
*/
|
|
511
|
-
expectedVaultId: BN | number;
|
|
512
|
-
/**
|
|
513
|
-
* Expected withdrawal_mode byte at the v1 offset (416). The handler validates
|
|
514
|
-
* this before the shuffle. Guards against stale ops scripts.
|
|
515
|
-
*/
|
|
516
|
-
expectedOldWithdrawalMode: number;
|
|
517
|
-
/**
|
|
518
|
-
* Optional withdrawal_mode backfill. When provided, the handler applies
|
|
519
|
-
* queue-empty guards and instant-mode restrictions before writing the new mode
|
|
520
|
-
* at the v2 offset (464). When undefined/omitted, the shuffled v1 byte is preserved.
|
|
521
|
-
*
|
|
522
|
-
* Values: 0=instant, 1=X, 2=X+1.
|
|
523
|
-
*/
|
|
524
|
-
newWithdrawalMode?: number;
|
|
525
|
-
}
|
|
526
|
-
export declare function createMigrateStvLayoutIx(args: MigrateStvLayoutArgs, programId?: PublicKey): TransactionInstruction;
|
|
527
540
|
export interface AcceptVaultAdminArgs {
|
|
528
541
|
/** Must equal stv.pending_admin on-chain. Signer proves the new key is live. */
|
|
529
542
|
pendingAdmin: PublicKey;
|
|
@@ -16,12 +16,12 @@ exports.createRemoveManagerIx = createRemoveManagerIx;
|
|
|
16
16
|
exports.createMigrateLendIx = createMigrateLendIx;
|
|
17
17
|
exports.createMigrateRequestIx = createMigrateRequestIx;
|
|
18
18
|
exports.createMigrateExecuteIx = createMigrateExecuteIx;
|
|
19
|
+
exports.createMigrateCancelIx = createMigrateCancelIx;
|
|
19
20
|
exports.buildLendRemainingAccounts = buildLendRemainingAccounts;
|
|
20
21
|
exports.buildMigrateRemainingAccounts = buildMigrateRemainingAccounts;
|
|
21
22
|
exports.buildStrategyRemainingAccounts = buildStrategyRemainingAccounts;
|
|
22
23
|
exports.createInstantWithdrawIx = createInstantWithdrawIx;
|
|
23
24
|
exports.createSeedStvIx = createSeedStvIx;
|
|
24
|
-
exports.createMigrateStvLayoutIx = createMigrateStvLayoutIx;
|
|
25
25
|
exports.createAcceptVaultAdminIx = createAcceptVaultAdminIx;
|
|
26
26
|
const web3_js_1 = require("@solana/web3.js");
|
|
27
27
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -249,7 +249,7 @@ function createDepositToStrategyIx(args, programId = constants_1.PROGRAM_ID) {
|
|
|
249
249
|
}
|
|
250
250
|
return new web3_js_1.TransactionInstruction({
|
|
251
251
|
keys: [
|
|
252
|
-
{ pubkey: manager, isSigner: true, isWritable:
|
|
252
|
+
{ pubkey: manager, isSigner: true, isWritable: false },
|
|
253
253
|
{ pubkey: managerRole, isSigner: false, isWritable: false },
|
|
254
254
|
{ pubkey: config, isSigner: false, isWritable: false },
|
|
255
255
|
{ pubkey: stv, isSigner: false, isWritable: true },
|
|
@@ -274,7 +274,7 @@ function createWithdrawFromStrategyIx(args, programId = constants_1.PROGRAM_ID)
|
|
|
274
274
|
data.push(protocolAumCount & 0xff);
|
|
275
275
|
return new web3_js_1.TransactionInstruction({
|
|
276
276
|
keys: [
|
|
277
|
-
{ pubkey: manager, isSigner: true, isWritable:
|
|
277
|
+
{ pubkey: manager, isSigner: true, isWritable: false },
|
|
278
278
|
{ pubkey: managerRole, isSigner: false, isWritable: false },
|
|
279
279
|
{ pubkey: config, isSigner: false, isWritable: false },
|
|
280
280
|
{ pubkey: stv, isSigner: false, isWritable: true },
|
|
@@ -292,17 +292,26 @@ function createWithdrawFromStrategyIx(args, programId = constants_1.PROGRAM_ID)
|
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
294
|
function createCloseStvIx(args, programId = constants_1.PROGRAM_ID) {
|
|
295
|
-
const { admin, payer, config, stv, evMint, vaultAta, tokenProgram } = args;
|
|
295
|
+
const { admin, payer, config, stv, evMint, vaultAta, tokenProgram, escrowEvAta, baseMint, adminBaseAta, strategyProgram, stvPosition, } = args;
|
|
296
|
+
const keys = [
|
|
297
|
+
{ pubkey: admin, isSigner: true, isWritable: false },
|
|
298
|
+
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
299
|
+
{ pubkey: config, isSigner: false, isWritable: false },
|
|
300
|
+
{ pubkey: stv, isSigner: false, isWritable: true },
|
|
301
|
+
{ pubkey: evMint, isSigner: false, isWritable: true },
|
|
302
|
+
{ pubkey: vaultAta, isSigner: false, isWritable: true },
|
|
303
|
+
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
304
|
+
];
|
|
305
|
+
// Seeded path trailing accounts (close_stv.rs:122)
|
|
306
|
+
if (escrowEvAta !== undefined && baseMint !== undefined && adminBaseAta !== undefined) {
|
|
307
|
+
keys.push({ pubkey: escrowEvAta, isSigner: false, isWritable: true }, { pubkey: baseMint, isSigner: false, isWritable: false }, { pubkey: adminBaseAta, isSigner: false, isWritable: true });
|
|
308
|
+
// Strategy sub-path (close_stv.rs:149): required when stv.strategy != 0
|
|
309
|
+
if (strategyProgram !== undefined && stvPosition !== undefined) {
|
|
310
|
+
keys.push({ pubkey: strategyProgram, isSigner: false, isWritable: false }, { pubkey: stvPosition, isSigner: false, isWritable: false });
|
|
311
|
+
}
|
|
312
|
+
}
|
|
296
313
|
return new web3_js_1.TransactionInstruction({
|
|
297
|
-
keys
|
|
298
|
-
{ pubkey: admin, isSigner: true, isWritable: false },
|
|
299
|
-
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
300
|
-
{ pubkey: config, isSigner: false, isWritable: false },
|
|
301
|
-
{ pubkey: stv, isSigner: false, isWritable: true },
|
|
302
|
-
{ pubkey: evMint, isSigner: false, isWritable: true },
|
|
303
|
-
{ pubkey: vaultAta, isSigner: false, isWritable: true },
|
|
304
|
-
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
305
|
-
],
|
|
314
|
+
keys,
|
|
306
315
|
programId,
|
|
307
316
|
data: Buffer.from([constants_1.IX_CLOSE_STV]),
|
|
308
317
|
});
|
|
@@ -392,25 +401,38 @@ function createMigrateRequestIx(args, programId = constants_1.PROGRAM_ID) {
|
|
|
392
401
|
});
|
|
393
402
|
}
|
|
394
403
|
/**
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
* dst_protocol_aum_count, src_auto_unroute_count, dst_auto_route_count
|
|
399
|
-
* (migrate_execute.rs:94-100).
|
|
404
|
+
* 14 fixed accounts (migrate_execute.rs:97 destructure). Permissionless.
|
|
405
|
+
* Instruction data: 4 bytes always; 5th byte (dest_delayed_bump) required
|
|
406
|
+
* on the deferred path (migrate_execute.rs:104-114 / 387-401).
|
|
400
407
|
*/
|
|
401
408
|
function createMigrateExecuteIx(args, programId = constants_1.PROGRAM_ID) {
|
|
402
|
-
const {
|
|
403
|
-
const
|
|
409
|
+
const { caller, config, sourceStv, destStv, wrAccount, sourceVaultAta, destVaultAta, destEvMint, userDestEvAta, sourceFeeRecvAta, destFeeRecvEvAta, baseMint, tokenProgram, wrUserAccount, srcProtocolAumCount, dstProtocolAumCount, srcAutoUnrouteCount, dstAutoRouteCount, destDelayedRequest, destDelayedBump, systemProgram, remainingAccounts = [], } = args;
|
|
410
|
+
const dataBytes = [
|
|
404
411
|
constants_1.IX_MIGRATE_EXECUTE,
|
|
405
412
|
srcProtocolAumCount & 0xff,
|
|
406
413
|
dstProtocolAumCount & 0xff,
|
|
407
414
|
srcAutoUnrouteCount & 0xff,
|
|
408
415
|
dstAutoRouteCount & 0xff,
|
|
409
|
-
]
|
|
416
|
+
];
|
|
417
|
+
// 5th byte required on deferred path (migrate_execute.rs:388-390)
|
|
418
|
+
if (destDelayedRequest !== undefined) {
|
|
419
|
+
if (destDelayedBump === undefined) {
|
|
420
|
+
throw new Error("createMigrateExecuteIx: destDelayedBump is required when destDelayedRequest is provided");
|
|
421
|
+
}
|
|
422
|
+
dataBytes.push(destDelayedBump & 0xff);
|
|
423
|
+
}
|
|
424
|
+
// Trailing accounts for deferred path (migrate_execute.rs:393-401):
|
|
425
|
+
// [dest_delayed_request(w), system_program] appended after remaining.
|
|
426
|
+
const trailingKeys = [];
|
|
427
|
+
if (destDelayedRequest !== undefined) {
|
|
428
|
+
trailingKeys.push({ pubkey: destDelayedRequest, isSigner: false, isWritable: true }, { pubkey: systemProgram ?? web3_js_1.SystemProgram.programId, isSigner: false, isWritable: false });
|
|
429
|
+
}
|
|
410
430
|
return new web3_js_1.TransactionInstruction({
|
|
411
431
|
keys: [
|
|
412
|
-
|
|
413
|
-
|
|
432
|
+
// caller must be writable on the deferred path: the handler calls
|
|
433
|
+
// check_writable(caller) at migrate_execute.rs:400 because caller funds
|
|
434
|
+
// the dest_delayed_request CreateAccount rent. Read-only on immediate path.
|
|
435
|
+
{ pubkey: caller, isSigner: true, isWritable: destDelayedRequest !== undefined },
|
|
414
436
|
{ pubkey: config, isSigner: false, isWritable: false },
|
|
415
437
|
{ pubkey: sourceStv, isSigner: false, isWritable: true },
|
|
416
438
|
{ pubkey: destStv, isSigner: false, isWritable: true },
|
|
@@ -425,6 +447,29 @@ function createMigrateExecuteIx(args, programId = constants_1.PROGRAM_ID) {
|
|
|
425
447
|
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
426
448
|
{ pubkey: wrUserAccount, isSigner: false, isWritable: true },
|
|
427
449
|
...remainingAccounts,
|
|
450
|
+
...trailingKeys,
|
|
451
|
+
],
|
|
452
|
+
programId,
|
|
453
|
+
data: Buffer.from(dataBytes),
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
function createMigrateCancelIx(args, programId = constants_1.PROGRAM_ID) {
|
|
457
|
+
const { user, config, stv, wrAccount, vaultAta, userBaseAta, feeReceiverBaseAta, baseMint, tokenProgram, autoUnrouteCount = 0, protocolAumCount = 0, remainingAccounts = [], } = args;
|
|
458
|
+
// Data bytes: [disc, auto_unroute_count, protocol_aum_count]
|
|
459
|
+
// Both counts are optional on-chain (data.is_empty() / data.len() > 1).
|
|
460
|
+
const data = Buffer.from([constants_1.IX_MIGRATE_CANCEL, autoUnrouteCount & 0xff, protocolAumCount & 0xff]);
|
|
461
|
+
return new web3_js_1.TransactionInstruction({
|
|
462
|
+
keys: [
|
|
463
|
+
{ pubkey: user, isSigner: true, isWritable: true },
|
|
464
|
+
{ pubkey: config, isSigner: false, isWritable: false },
|
|
465
|
+
{ pubkey: stv, isSigner: false, isWritable: true },
|
|
466
|
+
{ pubkey: wrAccount, isSigner: false, isWritable: true },
|
|
467
|
+
{ pubkey: vaultAta, isSigner: false, isWritable: true },
|
|
468
|
+
{ pubkey: userBaseAta, isSigner: false, isWritable: true },
|
|
469
|
+
{ pubkey: feeReceiverBaseAta, isSigner: false, isWritable: true },
|
|
470
|
+
{ pubkey: baseMint, isSigner: false, isWritable: false },
|
|
471
|
+
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
472
|
+
...remainingAccounts,
|
|
428
473
|
],
|
|
429
474
|
programId,
|
|
430
475
|
data,
|
|
@@ -542,35 +587,6 @@ function createSeedStvIx(args, programId = constants_1.PROGRAM_ID) {
|
|
|
542
587
|
data: Buffer.from(data),
|
|
543
588
|
});
|
|
544
589
|
}
|
|
545
|
-
function createMigrateStvLayoutIx(args, programId = constants_1.PROGRAM_ID) {
|
|
546
|
-
const { admin, config, stv, expectedVaultId, expectedOldWithdrawalMode, newWithdrawalMode } = args;
|
|
547
|
-
// Data: expected_vault_id(8) + expected_old_withdrawal_mode(1)
|
|
548
|
-
// + new_withdrawal_mode (0x00 or 0x01 + byte).
|
|
549
|
-
const data = [constants_1.IX_MIGRATE_STV_LAYOUT];
|
|
550
|
-
(0, buffer_1.writeU64)(data, expectedVaultId);
|
|
551
|
-
data.push(expectedOldWithdrawalMode & 0xff);
|
|
552
|
-
if (newWithdrawalMode !== undefined && newWithdrawalMode !== null) {
|
|
553
|
-
if (newWithdrawalMode < 0 || newWithdrawalMode > 2) {
|
|
554
|
-
throw new Error(`newWithdrawalMode must be 0 (instant), 1 (X) or 2 (X+1); got ${newWithdrawalMode}`);
|
|
555
|
-
}
|
|
556
|
-
// Some(m): 0x01 tag + mode byte
|
|
557
|
-
data.push(0x01);
|
|
558
|
-
data.push(newWithdrawalMode & 0xff);
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
|
-
// None: 0x00 tag
|
|
562
|
-
data.push(0x00);
|
|
563
|
-
}
|
|
564
|
-
return new web3_js_1.TransactionInstruction({
|
|
565
|
-
keys: [
|
|
566
|
-
{ pubkey: admin, isSigner: true, isWritable: false },
|
|
567
|
-
{ pubkey: config, isSigner: false, isWritable: false },
|
|
568
|
-
{ pubkey: stv, isSigner: false, isWritable: true },
|
|
569
|
-
],
|
|
570
|
-
programId,
|
|
571
|
-
data: Buffer.from(data),
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
590
|
function createAcceptVaultAdminIx(args, programId = constants_1.PROGRAM_ID) {
|
|
575
591
|
const { pendingAdmin, stv } = args;
|
|
576
592
|
return new web3_js_1.TransactionInstruction({
|
|
@@ -66,6 +66,12 @@ export interface Stv {
|
|
|
66
66
|
lockedSeedShares: BN;
|
|
67
67
|
/** Withdrawal mode: 0=instant, 1=X, 2=X+1. Create-only/immutable. */
|
|
68
68
|
withdrawalMode: number;
|
|
69
|
+
/**
|
|
70
|
+
* Unix timestamp (seconds, u32) at which `lastNav` was written by `process_epoch`.
|
|
71
|
+
* Used by allocator NAV freshness gating. 0 = no epoch processed yet.
|
|
72
|
+
* Offset 468 in the v2 layout (_OFFSET_LAST_NAV_TS == 468).
|
|
73
|
+
*/
|
|
74
|
+
lastNavTs: number;
|
|
69
75
|
}
|
|
70
76
|
export interface ManagerRole {
|
|
71
77
|
stv: PublicKey;
|
|
@@ -275,12 +281,6 @@ export interface StvSeededEvent {
|
|
|
275
281
|
vaultId: BN;
|
|
276
282
|
amount: BN;
|
|
277
283
|
}
|
|
278
|
-
/** Emitted by migrate_stv_layout after setting the initial per-vault admin. */
|
|
279
|
-
export interface StvAdminSetEvent {
|
|
280
|
-
name: "StvAdminSet";
|
|
281
|
-
vaultId: BN;
|
|
282
|
-
admin: PublicKey;
|
|
283
|
-
}
|
|
284
284
|
/** Emitted by init_or_update_stv (update path) when pending_admin is set to a nonzero value. */
|
|
285
285
|
export interface AdminRotationStartedEvent {
|
|
286
286
|
name: "AdminRotationStarted";
|
|
@@ -293,4 +293,4 @@ export interface AdminRotationAcceptedEvent {
|
|
|
293
293
|
vaultId: BN;
|
|
294
294
|
newAdmin: PublicKey;
|
|
295
295
|
}
|
|
296
|
-
export type StvEvent = ConfigInitializedEvent | ConfigUpdatedEvent | StvCreatedEvent | StvUpdatedEvent | DepositedEvent | WithdrawRequestedEvent | WithdrawRequestIncreasedEvent | WithdrawClaimedEvent | DepositedToStrategyEvent | WithdrawnFromStrategyEvent | EpochProcessedEvent | EpochAdvancedEvent | FeesSettledEvent | StvClosedEvent | ManagerAddedEvent | ManagerRemovedEvent | WithdrawOverrideClaimedEvent | LendMigratedEvent | MigrateRequestedEvent | MigrateExecutedEvent | DelayedDepositProcessedEvent | InstantWithdrawnEvent | StvSeededEvent |
|
|
296
|
+
export type StvEvent = ConfigInitializedEvent | ConfigUpdatedEvent | StvCreatedEvent | StvUpdatedEvent | DepositedEvent | WithdrawRequestedEvent | WithdrawRequestIncreasedEvent | WithdrawClaimedEvent | DepositedToStrategyEvent | WithdrawnFromStrategyEvent | EpochProcessedEvent | EpochAdvancedEvent | FeesSettledEvent | StvClosedEvent | ManagerAddedEvent | ManagerRemovedEvent | WithdrawOverrideClaimedEvent | LendMigratedEvent | MigrateRequestedEvent | MigrateExecutedEvent | DelayedDepositProcessedEvent | InstantWithdrawnEvent | StvSeededEvent | AdminRotationStartedEvent | AdminRotationAcceptedEvent;
|