@elemental-stv-core/sdk 0.8.0 → 0.9.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.
@@ -0,0 +1,14 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import type { StvPosition } from "../common/strategy-interface";
3
+ import type { SolanaConnection } from "../common/connection";
4
+ import type { LendStrategyState, ProtocolVault, ManagerRole } from "./types";
5
+ export declare function deserializeStrategyState(data: Buffer): LendStrategyState;
6
+ export declare function deserializeProtocolVault(data: Buffer): ProtocolVault;
7
+ export declare function deserializeLendStvPosition(data: Buffer): StvPosition;
8
+ export declare function deserializeManagerRole(data: Buffer): ManagerRole;
9
+ export declare function fetchStrategyState(connection: SolanaConnection, baseMint: PublicKey, programId?: PublicKey): Promise<LendStrategyState>;
10
+ export declare function fetchStrategyStateByAddress(connection: SolanaConnection, address: PublicKey): Promise<LendStrategyState>;
11
+ export declare function fetchProtocolVault(connection: SolanaConnection, strategyState: PublicKey, index: number, programId?: PublicKey): Promise<ProtocolVault>;
12
+ export declare function fetchAllProtocolVaults(connection: SolanaConnection, strategyState: PublicKey, protocolCount: number, programId?: PublicKey): Promise<[PublicKey, ProtocolVault][]>;
13
+ export declare function fetchLendStvPosition(connection: SolanaConnection, stv: PublicKey, programId?: PublicKey): Promise<StvPosition>;
14
+ export declare function fetchManagerRole(connection: SolanaConnection, strategyState: PublicKey, manager: PublicKey, programId?: PublicKey): Promise<ManagerRole | null>;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeStrategyState = deserializeStrategyState;
4
+ exports.deserializeProtocolVault = deserializeProtocolVault;
5
+ exports.deserializeLendStvPosition = deserializeLendStvPosition;
6
+ exports.deserializeManagerRole = deserializeManagerRole;
7
+ exports.fetchStrategyState = fetchStrategyState;
8
+ exports.fetchStrategyStateByAddress = fetchStrategyStateByAddress;
9
+ exports.fetchProtocolVault = fetchProtocolVault;
10
+ exports.fetchAllProtocolVaults = fetchAllProtocolVaults;
11
+ exports.fetchLendStvPosition = fetchLendStvPosition;
12
+ exports.fetchManagerRole = fetchManagerRole;
13
+ const buffer_1 = require("../common/buffer");
14
+ const strategy_interface_1 = require("../common/strategy-interface");
15
+ const constants_1 = require("./constants");
16
+ const pda_1 = require("./pda");
17
+ // ---------------------------------------------------------------------------
18
+ // Deserializers
19
+ // ---------------------------------------------------------------------------
20
+ function deserializeStrategyState(data) {
21
+ if (data.length < constants_1.STRATEGY_STATE_SIZE) {
22
+ throw new Error(`StrategyState data too short: ${data.length} < ${constants_1.STRATEGY_STATE_SIZE}`);
23
+ }
24
+ if (!data.subarray(0, 8).equals(constants_1.DISC_STRATEGY_STATE)) {
25
+ throw new Error(`Invalid StrategyState discriminator`);
26
+ }
27
+ return {
28
+ baseMint: (0, buffer_1.readPubkey)(data, 8),
29
+ authority: (0, buffer_1.readPubkey)(data, 40),
30
+ pps: (0, buffer_1.readU64)(data, 72),
31
+ totalAum: (0, buffer_1.readU64)(data, 80),
32
+ totalShares: (0, buffer_1.readU64)(data, 88),
33
+ lastUpdated: (0, buffer_1.readU64)(data, 96),
34
+ flags: (0, buffer_1.readU16)(data, 104),
35
+ version: (0, buffer_1.readU8)(data, 106),
36
+ bump: (0, buffer_1.readU8)(data, 107),
37
+ admin: (0, buffer_1.readPubkey)(data, 112),
38
+ protocolCount: (0, buffer_1.readU8)(data, 144),
39
+ };
40
+ }
41
+ function deserializeProtocolVault(data) {
42
+ if (data.length < constants_1.PROTOCOL_VAULT_SIZE) {
43
+ throw new Error(`ProtocolVault data too short: ${data.length} < ${constants_1.PROTOCOL_VAULT_SIZE}`);
44
+ }
45
+ if (!data.subarray(0, 8).equals(constants_1.DISC_PROTOCOL_VAULT)) {
46
+ throw new Error(`Invalid ProtocolVault discriminator`);
47
+ }
48
+ return {
49
+ strategyState: (0, buffer_1.readPubkey)(data, 8),
50
+ adapterProgram: (0, buffer_1.readPubkey)(data, 40),
51
+ protocolState: (0, buffer_1.readPubkey)(data, 72),
52
+ index: (0, buffer_1.readU8)(data, 104),
53
+ bump: (0, buffer_1.readU8)(data, 105),
54
+ readAumAccountCount: (0, buffer_1.readU8)(data, 106),
55
+ };
56
+ }
57
+ function deserializeLendStvPosition(data) {
58
+ if (data.length < constants_1.STV_POSITION_SIZE) {
59
+ throw new Error(`StvPosition data too short: ${data.length} < ${constants_1.STV_POSITION_SIZE}`);
60
+ }
61
+ if (!data.subarray(0, 8).equals(constants_1.DISC_STV_POSITION)) {
62
+ throw new Error(`Invalid StvPosition discriminator`);
63
+ }
64
+ return (0, strategy_interface_1.deserializeStvPosition)(data);
65
+ }
66
+ function deserializeManagerRole(data) {
67
+ if (data.length < constants_1.MANAGER_ROLE_SIZE) {
68
+ throw new Error(`ManagerRole data too short: ${data.length} < ${constants_1.MANAGER_ROLE_SIZE}`);
69
+ }
70
+ if (!data.subarray(0, 8).equals(constants_1.DISC_MANAGER_ROLE)) {
71
+ throw new Error(`Invalid ManagerRole discriminator`);
72
+ }
73
+ return {
74
+ strategyState: (0, buffer_1.readPubkey)(data, 8),
75
+ manager: (0, buffer_1.readPubkey)(data, 40),
76
+ bump: (0, buffer_1.readU8)(data, 72),
77
+ };
78
+ }
79
+ // ---------------------------------------------------------------------------
80
+ // Fetch helpers
81
+ // ---------------------------------------------------------------------------
82
+ async function fetchStrategyState(connection, baseMint, programId = constants_1.PROGRAM_ID) {
83
+ const [pda] = (0, pda_1.deriveStrategyState)(baseMint, programId);
84
+ const info = await connection.getAccountInfo(pda);
85
+ if (!info) {
86
+ throw new Error(`StrategyState not found for mint ${baseMint.toBase58()}`);
87
+ }
88
+ return deserializeStrategyState(info.data);
89
+ }
90
+ async function fetchStrategyStateByAddress(connection, address) {
91
+ const info = await connection.getAccountInfo(address);
92
+ if (!info)
93
+ throw new Error(`StrategyState not found at ${address.toBase58()}`);
94
+ return deserializeStrategyState(info.data);
95
+ }
96
+ async function fetchProtocolVault(connection, strategyState, index, programId = constants_1.PROGRAM_ID) {
97
+ const [pda] = (0, pda_1.deriveProtocolVault)(strategyState, index, programId);
98
+ const info = await connection.getAccountInfo(pda);
99
+ if (!info) {
100
+ throw new Error(`ProtocolVault not found at index ${index} for ${strategyState.toBase58()}`);
101
+ }
102
+ return deserializeProtocolVault(info.data);
103
+ }
104
+ async function fetchAllProtocolVaults(connection, strategyState, protocolCount, programId = constants_1.PROGRAM_ID) {
105
+ if (protocolCount === 0)
106
+ return [];
107
+ const pdas = [];
108
+ for (let i = 0; i < protocolCount; i++) {
109
+ const [pda] = (0, pda_1.deriveProtocolVault)(strategyState, i, programId);
110
+ pdas.push(pda);
111
+ }
112
+ const infos = await connection.getMultipleAccountsInfo(pdas);
113
+ const out = [];
114
+ for (let i = 0; i < pdas.length; i++) {
115
+ const info = infos[i];
116
+ if (!info) {
117
+ throw new Error(`ProtocolVault ${i} missing at ${pdas[i].toBase58()}`);
118
+ }
119
+ out.push([pdas[i], deserializeProtocolVault(info.data)]);
120
+ }
121
+ return out;
122
+ }
123
+ async function fetchLendStvPosition(connection, stv, programId = constants_1.PROGRAM_ID) {
124
+ const [pda] = (0, pda_1.deriveStvPosition)(stv, programId);
125
+ const info = await connection.getAccountInfo(pda);
126
+ if (!info)
127
+ throw new Error(`StvPosition not found for stv ${stv.toBase58()}`);
128
+ return deserializeLendStvPosition(info.data);
129
+ }
130
+ async function fetchManagerRole(connection, strategyState, manager, programId = constants_1.PROGRAM_ID) {
131
+ const [pda] = (0, pda_1.deriveManagerRole)(strategyState, manager, programId);
132
+ const info = await connection.getAccountInfo(pda);
133
+ if (!info)
134
+ return null;
135
+ return deserializeManagerRole(info.data);
136
+ }
@@ -0,0 +1,22 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export type AdapterKind = "kamino" | "jupiter-lend";
3
+ export interface AdapterMeta {
4
+ kind: AdapterKind;
5
+ programId: PublicKey;
6
+ readAumAccountCount: number;
7
+ }
8
+ export declare const KAMINO_ADAPTER: AdapterMeta;
9
+ export declare const JUPITER_LEND_ADAPTER: AdapterMeta;
10
+ export declare const ADAPTERS: Record<AdapterKind, AdapterMeta>;
11
+ export interface RegisterAdapterParams {
12
+ protocolState: PublicKey;
13
+ readAumAccountCount: number;
14
+ }
15
+ /** Kamino: protocol_state = vault_state, count = 2. */
16
+ export declare function buildRegisterKaminoParams(vaultState: PublicKey): RegisterAdapterParams;
17
+ /** Jupiter Lend: protocol_state = lending, count = 4. */
18
+ export declare function buildRegisterJupLendParams(lending: PublicKey): RegisterAdapterParams;
19
+ /** Kamino: [vault_state, kv_token_ata]. */
20
+ export declare function resolveKaminoReadAumAccounts(vaultState: PublicKey, kvTokenAta: PublicKey): PublicKey[];
21
+ /** Jupiter Lend: [lending, rewards_rate_model, fToken_ata, fToken_mint]. */
22
+ export declare function resolveJupLendReadAumAccounts(lending: PublicKey, rewardsRateModel: PublicKey, ftokenAta: PublicKey, ftokenMint: PublicKey): PublicKey[];
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ADAPTERS = exports.JUPITER_LEND_ADAPTER = exports.KAMINO_ADAPTER = void 0;
4
+ exports.buildRegisterKaminoParams = buildRegisterKaminoParams;
5
+ exports.buildRegisterJupLendParams = buildRegisterJupLendParams;
6
+ exports.resolveKaminoReadAumAccounts = resolveKaminoReadAumAccounts;
7
+ exports.resolveJupLendReadAumAccounts = resolveJupLendReadAumAccounts;
8
+ const constants_1 = require("./constants");
9
+ exports.KAMINO_ADAPTER = {
10
+ kind: "kamino",
11
+ programId: constants_1.KAMINO_ADAPTER_PROGRAM_ID,
12
+ readAumAccountCount: constants_1.KAMINO_READ_AUM_ACCOUNT_COUNT,
13
+ };
14
+ exports.JUPITER_LEND_ADAPTER = {
15
+ kind: "jupiter-lend",
16
+ programId: constants_1.JUPITER_LEND_ADAPTER_PROGRAM_ID,
17
+ readAumAccountCount: constants_1.JUPITER_LEND_READ_AUM_ACCOUNT_COUNT,
18
+ };
19
+ exports.ADAPTERS = {
20
+ kamino: exports.KAMINO_ADAPTER,
21
+ "jupiter-lend": exports.JUPITER_LEND_ADAPTER,
22
+ };
23
+ /** Kamino: protocol_state = vault_state, count = 2. */
24
+ function buildRegisterKaminoParams(vaultState) {
25
+ return {
26
+ protocolState: vaultState,
27
+ readAumAccountCount: constants_1.KAMINO_READ_AUM_ACCOUNT_COUNT,
28
+ };
29
+ }
30
+ /** Jupiter Lend: protocol_state = lending, count = 4. */
31
+ function buildRegisterJupLendParams(lending) {
32
+ return {
33
+ protocolState: lending,
34
+ readAumAccountCount: constants_1.JUPITER_LEND_READ_AUM_ACCOUNT_COUNT,
35
+ };
36
+ }
37
+ // ---------------------------------------------------------------------------
38
+ // read_aum account resolvers
39
+ //
40
+ // Order MUST match the adapter's read_aum layout. First slot = protocol_state
41
+ // (core-pinned). Adapter validates remaining slots from on-chain data.
42
+ // ---------------------------------------------------------------------------
43
+ /** Kamino: [vault_state, kv_token_ata]. */
44
+ function resolveKaminoReadAumAccounts(vaultState, kvTokenAta) {
45
+ return [vaultState, kvTokenAta];
46
+ }
47
+ /** Jupiter Lend: [lending, rewards_rate_model, fToken_ata, fToken_mint]. */
48
+ function resolveJupLendReadAumAccounts(lending, rewardsRateModel, ftokenAta, ftokenMint) {
49
+ return [lending, rewardsRateModel, ftokenAta, ftokenMint];
50
+ }
@@ -0,0 +1,48 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ /** Elemental Lend v2 program ID. Matches `declare_id!` in lib.rs. */
3
+ export declare const PROGRAM_ID: PublicKey;
4
+ /** Kamino stateless adapter program (Pinocchio). */
5
+ export declare const KAMINO_ADAPTER_PROGRAM_ID: PublicKey;
6
+ /** Jupiter Lend stateless adapter program (Pinocchio). */
7
+ export declare const JUPITER_LEND_ADAPTER_PROGRAM_ID: PublicKey;
8
+ export declare const KAMINO_VAULT_PROGRAM: PublicKey;
9
+ export declare const KLEND_PROGRAM: PublicKey;
10
+ export declare const JUP_LEND_EARN_PROGRAM: PublicKey;
11
+ export declare const STRATEGY_STATE_SEED: Buffer<ArrayBuffer>;
12
+ export declare const POSITION_SEED: Buffer<ArrayBuffer>;
13
+ export declare const PROTOCOL_VAULT_SEED: Buffer<ArrayBuffer>;
14
+ export declare const MANAGER_SEED: Buffer<ArrayBuffer>;
15
+ export { DISC_STRATEGY_STATE, DISC_STV_POSITION, DISC_MANAGER_ROLE, } from "../common/constants";
16
+ /**
17
+ * sha256("account:ProtocolVault")[..8]. v2-only account type.
18
+ * Verified via `scripts/regen-discriminators.sh`.
19
+ */
20
+ export declare const DISC_PROTOCOL_VAULT: Buffer<ArrayBuffer>;
21
+ export declare const IX_INIT_STRATEGY: Buffer<ArrayBuffer>;
22
+ export declare const IX_UPDATE_STRATEGY: Buffer<ArrayBuffer>;
23
+ export declare const IX_REGISTER_ADAPTER: Buffer<ArrayBuffer>;
24
+ export declare const IX_DEREGISTER_ADAPTER: Buffer<ArrayBuffer>;
25
+ export declare const IX_ADD_MANAGER: Buffer<ArrayBuffer>;
26
+ export declare const IX_REMOVE_MANAGER: Buffer<ArrayBuffer>;
27
+ export declare const IX_INIT_POSITION: Buffer<ArrayBuffer>;
28
+ export declare const IX_CLOSE_POSITION: Buffer<ArrayBuffer>;
29
+ export declare const IX_DEPOSIT: Buffer<ArrayBuffer>;
30
+ export declare const IX_WITHDRAW: Buffer<ArrayBuffer>;
31
+ export declare const IX_UPDATE_AUM: Buffer<ArrayBuffer>;
32
+ export declare const IX_ROUTE_DEPOSIT: Buffer<ArrayBuffer>;
33
+ export declare const IX_ROUTE_WITHDRAW: Buffer<ArrayBuffer>;
34
+ export declare const ADAPTER_DEPOSIT_DISC = 0;
35
+ export declare const ADAPTER_WITHDRAW_DISC = 1;
36
+ export declare const ADAPTER_READ_AUM_DISC = 2;
37
+ export declare const STRATEGY_STATE_SIZE = 280;
38
+ export declare const PROTOCOL_VAULT_SIZE = 224;
39
+ export declare const STV_POSITION_SIZE = 120;
40
+ export declare const MANAGER_ROLE_SIZE = 80;
41
+ export declare const FLAG_PAUSED = 1;
42
+ /** Hard cap in the program. Practical cap ~5-6 with 2 LUTs. */
43
+ export declare const MAX_PROTOCOLS = 64;
44
+ export declare const MIN_READ_AUM_ACCOUNTS = 2;
45
+ export declare const MAX_READ_AUM_ACCOUNTS = 4;
46
+ export declare const KAMINO_READ_AUM_ACCOUNT_COUNT = 2;
47
+ export declare const JUPITER_LEND_READ_AUM_ACCOUNT_COUNT = 4;
48
+ export { PPS_DECIMALS } from "../common/constants";
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PPS_DECIMALS = exports.JUPITER_LEND_READ_AUM_ACCOUNT_COUNT = exports.KAMINO_READ_AUM_ACCOUNT_COUNT = exports.MAX_READ_AUM_ACCOUNTS = exports.MIN_READ_AUM_ACCOUNTS = exports.MAX_PROTOCOLS = exports.FLAG_PAUSED = exports.MANAGER_ROLE_SIZE = exports.STV_POSITION_SIZE = exports.PROTOCOL_VAULT_SIZE = exports.STRATEGY_STATE_SIZE = exports.ADAPTER_READ_AUM_DISC = exports.ADAPTER_WITHDRAW_DISC = exports.ADAPTER_DEPOSIT_DISC = exports.IX_ROUTE_WITHDRAW = exports.IX_ROUTE_DEPOSIT = exports.IX_UPDATE_AUM = exports.IX_WITHDRAW = exports.IX_DEPOSIT = exports.IX_CLOSE_POSITION = exports.IX_INIT_POSITION = exports.IX_REMOVE_MANAGER = exports.IX_ADD_MANAGER = exports.IX_DEREGISTER_ADAPTER = exports.IX_REGISTER_ADAPTER = exports.IX_UPDATE_STRATEGY = exports.IX_INIT_STRATEGY = exports.DISC_PROTOCOL_VAULT = exports.DISC_MANAGER_ROLE = exports.DISC_STV_POSITION = exports.DISC_STRATEGY_STATE = exports.MANAGER_SEED = exports.PROTOCOL_VAULT_SEED = exports.POSITION_SEED = exports.STRATEGY_STATE_SEED = exports.JUP_LEND_EARN_PROGRAM = exports.KLEND_PROGRAM = exports.KAMINO_VAULT_PROGRAM = exports.JUPITER_LEND_ADAPTER_PROGRAM_ID = exports.KAMINO_ADAPTER_PROGRAM_ID = exports.PROGRAM_ID = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ /** Elemental Lend v2 program ID. Matches `declare_id!` in lib.rs. */
6
+ exports.PROGRAM_ID = new web3_js_1.PublicKey("AiHokenXGVUAY8dAYehwNy4GEzKnNyzV6USQg3y7uy9m");
7
+ /** Kamino stateless adapter program (Pinocchio). */
8
+ exports.KAMINO_ADAPTER_PROGRAM_ID = new web3_js_1.PublicKey("HimkKtjMfnzFjPXFK6iKmQp9DxxZLigAZbrBo2rzYMWo");
9
+ /** Jupiter Lend stateless adapter program (Pinocchio). */
10
+ exports.JUPITER_LEND_ADAPTER_PROGRAM_ID = new web3_js_1.PublicKey("C7GQ8giA7HPKSaYYSdLrmgZcdSLnnF3wjgZ85z28uQMd");
11
+ // External protocol programs (targets behind the stateless adapters).
12
+ exports.KAMINO_VAULT_PROGRAM = new web3_js_1.PublicKey("KvauGMspG5k6rtzrqqn7WNn3oZdyKqLKwK2XWQ8FLjd");
13
+ exports.KLEND_PROGRAM = new web3_js_1.PublicKey("KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD");
14
+ exports.JUP_LEND_EARN_PROGRAM = new web3_js_1.PublicKey("jup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9");
15
+ // ---------------------------------------------------------------------------
16
+ // PDA Seeds
17
+ // ---------------------------------------------------------------------------
18
+ exports.STRATEGY_STATE_SEED = Buffer.from("strategy_state");
19
+ exports.POSITION_SEED = Buffer.from("position");
20
+ exports.PROTOCOL_VAULT_SEED = Buffer.from("protocol");
21
+ exports.MANAGER_SEED = Buffer.from("manager");
22
+ // ---------------------------------------------------------------------------
23
+ // Account discriminators
24
+ // ---------------------------------------------------------------------------
25
+ var constants_1 = require("../common/constants");
26
+ Object.defineProperty(exports, "DISC_STRATEGY_STATE", { enumerable: true, get: function () { return constants_1.DISC_STRATEGY_STATE; } });
27
+ Object.defineProperty(exports, "DISC_STV_POSITION", { enumerable: true, get: function () { return constants_1.DISC_STV_POSITION; } });
28
+ Object.defineProperty(exports, "DISC_MANAGER_ROLE", { enumerable: true, get: function () { return constants_1.DISC_MANAGER_ROLE; } });
29
+ /**
30
+ * sha256("account:ProtocolVault")[..8]. v2-only account type.
31
+ * Verified via `scripts/regen-discriminators.sh`.
32
+ */
33
+ exports.DISC_PROTOCOL_VAULT = Buffer.from([
34
+ 0xc8, 0xa7, 0xc5, 0xee, 0x20, 0x8b, 0x1a, 0x45,
35
+ ]);
36
+ // ---------------------------------------------------------------------------
37
+ // Instruction discriminators. sha256("global:<snake_name>")[..8].
38
+ // Stable across deploys (derived from handler names, not program ID).
39
+ // Verified via `scripts/regen-discriminators.sh`.
40
+ // ---------------------------------------------------------------------------
41
+ exports.IX_INIT_STRATEGY = Buffer.from([
42
+ 0x9a, 0x4a, 0xd7, 0xd8, 0xe5, 0xcc, 0x8d, 0xf1,
43
+ ]);
44
+ exports.IX_UPDATE_STRATEGY = Buffer.from([
45
+ 0x10, 0x4c, 0x8a, 0xb3, 0xab, 0x70, 0xc4, 0x15,
46
+ ]);
47
+ exports.IX_REGISTER_ADAPTER = Buffer.from([
48
+ 0x4a, 0x46, 0xa2, 0x0e, 0xd9, 0x9f, 0xaf, 0xa1,
49
+ ]);
50
+ exports.IX_DEREGISTER_ADAPTER = Buffer.from([
51
+ 0x9e, 0xde, 0x9b, 0x60, 0x1c, 0xfb, 0xa8, 0xbe,
52
+ ]);
53
+ exports.IX_ADD_MANAGER = Buffer.from([
54
+ 0x7d, 0x26, 0xc0, 0xd4, 0x65, 0x5b, 0xb3, 0x10,
55
+ ]);
56
+ exports.IX_REMOVE_MANAGER = Buffer.from([
57
+ 0x96, 0x37, 0x9d, 0x4d, 0x80, 0x94, 0x07, 0x0f,
58
+ ]);
59
+ exports.IX_INIT_POSITION = Buffer.from([
60
+ 0xc5, 0x14, 0x0a, 0x01, 0x61, 0xa0, 0xb1, 0x5b,
61
+ ]);
62
+ exports.IX_CLOSE_POSITION = Buffer.from([
63
+ 0x7b, 0x86, 0x51, 0x00, 0x31, 0x44, 0x62, 0x62,
64
+ ]);
65
+ exports.IX_DEPOSIT = Buffer.from([
66
+ 0xf2, 0x23, 0xc6, 0x89, 0x52, 0xe1, 0xf2, 0xb6,
67
+ ]);
68
+ exports.IX_WITHDRAW = Buffer.from([
69
+ 0xb7, 0x12, 0x46, 0x9c, 0x94, 0x6d, 0xa1, 0x22,
70
+ ]);
71
+ exports.IX_UPDATE_AUM = Buffer.from([
72
+ 0xa2, 0x28, 0xe3, 0x10, 0x54, 0xa9, 0xb6, 0xb9,
73
+ ]);
74
+ exports.IX_ROUTE_DEPOSIT = Buffer.from([
75
+ 0x18, 0x8c, 0xdd, 0xf7, 0x02, 0xb7, 0x0e, 0x35,
76
+ ]);
77
+ exports.IX_ROUTE_WITHDRAW = Buffer.from([
78
+ 0x41, 0xb9, 0xef, 0xc3, 0x29, 0x39, 0x92, 0x2f,
79
+ ]);
80
+ // ---------------------------------------------------------------------------
81
+ // Stateless adapter 1-byte discriminators (Pinocchio convention)
82
+ // ---------------------------------------------------------------------------
83
+ exports.ADAPTER_DEPOSIT_DISC = 0;
84
+ exports.ADAPTER_WITHDRAW_DISC = 1;
85
+ exports.ADAPTER_READ_AUM_DISC = 2;
86
+ // ---------------------------------------------------------------------------
87
+ // Account sizes (include 8-byte discriminator)
88
+ // ---------------------------------------------------------------------------
89
+ exports.STRATEGY_STATE_SIZE = 280;
90
+ exports.PROTOCOL_VAULT_SIZE = 224;
91
+ exports.STV_POSITION_SIZE = 120;
92
+ exports.MANAGER_ROLE_SIZE = 80;
93
+ // ---------------------------------------------------------------------------
94
+ // Flags & limits
95
+ // ---------------------------------------------------------------------------
96
+ exports.FLAG_PAUSED = 0x0001;
97
+ /** Hard cap in the program. Practical cap ~5-6 with 2 LUTs. */
98
+ exports.MAX_PROTOCOLS = 64;
99
+ exports.MIN_READ_AUM_ACCOUNTS = 2;
100
+ exports.MAX_READ_AUM_ACCOUNTS = 4;
101
+ exports.KAMINO_READ_AUM_ACCOUNT_COUNT = 2;
102
+ exports.JUPITER_LEND_READ_AUM_ACCOUNT_COUNT = 4;
103
+ var constants_2 = require("../common/constants");
104
+ Object.defineProperty(exports, "PPS_DECIMALS", { enumerable: true, get: function () { return constants_2.PPS_DECIMALS; } });
@@ -0,0 +1,8 @@
1
+ export * from "./constants";
2
+ export * from "./pda";
3
+ export * from "./types";
4
+ export * from "./accounts";
5
+ export * from "./adapters";
6
+ export * from "./instructions";
7
+ export * from "./update-aum";
8
+ export * from "./lut";
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./pda"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ __exportStar(require("./accounts"), exports);
21
+ __exportStar(require("./adapters"), exports);
22
+ __exportStar(require("./instructions"), exports);
23
+ __exportStar(require("./update-aum"), exports);
24
+ __exportStar(require("./lut"), exports);
@@ -0,0 +1,96 @@
1
+ import { PublicKey, TransactionInstruction, AccountMeta } from "@solana/web3.js";
2
+ import BN from "bn.js";
3
+ import type { RegisterAdapterParams } from "./adapters";
4
+ export interface InitStrategyArgs {
5
+ admin: PublicKey;
6
+ baseMint: PublicKey;
7
+ strategyState: PublicKey;
8
+ authority: PublicKey;
9
+ systemProgram?: PublicKey;
10
+ }
11
+ export declare function createInitStrategyIx(args: InitStrategyArgs, programId?: PublicKey): TransactionInstruction;
12
+ export interface UpdateStrategyArgs {
13
+ admin: PublicKey;
14
+ strategyState: PublicKey;
15
+ newAdmin?: PublicKey | null;
16
+ newFlags?: number | null;
17
+ }
18
+ export declare function createUpdateStrategyIx(args: UpdateStrategyArgs, programId?: PublicKey): TransactionInstruction;
19
+ export interface RegisterAdapterArgs {
20
+ admin: PublicKey;
21
+ strategyState: PublicKey;
22
+ protocolVault: PublicKey;
23
+ adapterProgram: PublicKey;
24
+ index: number;
25
+ params: RegisterAdapterParams;
26
+ systemProgram?: PublicKey;
27
+ }
28
+ export declare function createRegisterAdapterIx(args: RegisterAdapterArgs, programId?: PublicKey): TransactionInstruction;
29
+ export interface DeregisterAdapterArgs {
30
+ admin: PublicKey;
31
+ strategyState: PublicKey;
32
+ protocolVault: PublicKey;
33
+ systemProgram?: PublicKey;
34
+ }
35
+ export declare function createDeregisterAdapterIx(args: DeregisterAdapterArgs, programId?: PublicKey): TransactionInstruction;
36
+ export interface AddManagerArgs {
37
+ admin: PublicKey;
38
+ strategyState: PublicKey;
39
+ managerRole: PublicKey;
40
+ manager: PublicKey;
41
+ systemProgram?: PublicKey;
42
+ }
43
+ export declare function createAddManagerIx(args: AddManagerArgs, programId?: PublicKey): TransactionInstruction;
44
+ export interface RemoveManagerArgs {
45
+ admin: PublicKey;
46
+ strategyState: PublicKey;
47
+ managerRole: PublicKey;
48
+ systemProgram?: PublicKey;
49
+ }
50
+ export declare function createRemoveManagerIx(args: RemoveManagerArgs, programId?: PublicKey): TransactionInstruction;
51
+ export interface InitPositionArgs {
52
+ strategyState: PublicKey;
53
+ position: PublicKey;
54
+ stv: PublicKey;
55
+ payer: PublicKey;
56
+ systemProgram?: PublicKey;
57
+ }
58
+ export declare function createInitPositionIx(args: InitPositionArgs, programId?: PublicKey): TransactionInstruction;
59
+ export interface ClosePositionArgs {
60
+ strategyState: PublicKey;
61
+ position: PublicKey;
62
+ stv: PublicKey;
63
+ }
64
+ export declare function createClosePositionIx(args: ClosePositionArgs, programId?: PublicKey): TransactionInstruction;
65
+ export interface DepositArgs {
66
+ strategyState: PublicKey;
67
+ position: PublicKey;
68
+ stv: PublicKey;
69
+ amount: BN | number;
70
+ }
71
+ export declare function createDepositIx(args: DepositArgs, programId?: PublicKey): TransactionInstruction;
72
+ export interface WithdrawArgs {
73
+ strategyState: PublicKey;
74
+ position: PublicKey;
75
+ stv: PublicKey;
76
+ strategyBaseAta: PublicKey;
77
+ destAta: PublicKey;
78
+ baseMint: PublicKey;
79
+ tokenProgram: PublicKey;
80
+ shares: BN | number;
81
+ }
82
+ export declare function createWithdrawIx(args: WithdrawArgs, programId?: PublicKey): TransactionInstruction;
83
+ export interface RouteArgs {
84
+ manager: PublicKey;
85
+ managerRole: PublicKey;
86
+ strategyState: PublicKey;
87
+ protocolVault: PublicKey;
88
+ strategyBaseAta: PublicKey;
89
+ baseMint: PublicKey;
90
+ tokenProgram: PublicKey;
91
+ adapterProgram: PublicKey;
92
+ amount: BN | number;
93
+ remainingAccounts: AccountMeta[];
94
+ }
95
+ export declare function createRouteDepositIx(args: RouteArgs, programId?: PublicKey): TransactionInstruction;
96
+ export declare function createRouteWithdrawIx(args: RouteArgs, programId?: PublicKey): TransactionInstruction;