@elmntl/jlpd-sdk 0.1.11 → 0.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +185 -404
- package/dist/common/ata.d.ts +26 -0
- package/dist/common/ata.js +48 -0
- package/dist/common/buffer.d.ts +15 -0
- package/dist/common/buffer.js +118 -0
- package/dist/common/connection.d.ts +13 -0
- package/dist/common/connection.js +2 -0
- package/dist/common/constants.d.ts +14 -0
- package/dist/common/constants.js +31 -0
- package/dist/common/index.d.ts +6 -0
- package/dist/common/index.js +28 -0
- package/dist/common/strategy-interface.d.ts +59 -0
- package/dist/common/strategy-interface.js +42 -0
- package/dist/elemental-lend/accounts.d.ts +103 -0
- package/dist/elemental-lend/accounts.js +354 -0
- package/dist/elemental-lend/constants.d.ts +25 -0
- package/dist/elemental-lend/constants.js +48 -0
- package/dist/elemental-lend/index.d.ts +8 -0
- package/dist/elemental-lend/index.js +24 -0
- package/dist/elemental-lend/instructions.d.ts +104 -0
- package/dist/elemental-lend/instructions.js +266 -0
- package/dist/elemental-lend/jupiter-lend.d.ts +91 -0
- package/dist/elemental-lend/jupiter-lend.js +189 -0
- package/dist/elemental-lend/kamino-vault.d.ts +173 -0
- package/dist/elemental-lend/kamino-vault.js +483 -0
- package/dist/elemental-lend/pda.d.ts +12 -0
- package/dist/elemental-lend/pda.js +24 -0
- package/dist/elemental-lend/protocol-actions.d.ts +56 -0
- package/dist/elemental-lend/protocol-actions.js +244 -0
- package/dist/elemental-lend/types.d.ts +113 -0
- package/dist/elemental-lend/types.js +2 -0
- package/dist/elemental-lend-v2/accounts.d.ts +14 -0
- package/dist/elemental-lend-v2/accounts.js +136 -0
- package/dist/elemental-lend-v2/adapters.d.ts +22 -0
- package/dist/elemental-lend-v2/adapters.js +50 -0
- package/dist/elemental-lend-v2/constants.d.ts +48 -0
- package/dist/elemental-lend-v2/constants.js +104 -0
- package/dist/elemental-lend-v2/index.d.ts +8 -0
- package/dist/elemental-lend-v2/index.js +24 -0
- package/dist/elemental-lend-v2/instructions.d.ts +96 -0
- package/dist/elemental-lend-v2/instructions.js +190 -0
- package/dist/elemental-lend-v2/lut.d.ts +20 -0
- package/dist/elemental-lend-v2/lut.js +65 -0
- package/dist/elemental-lend-v2/pda.d.ts +9 -0
- package/dist/elemental-lend-v2/pda.js +27 -0
- package/dist/elemental-lend-v2/types.d.ts +105 -0
- package/dist/elemental-lend-v2/types.js +2 -0
- package/dist/elemental-lend-v2/update-aum.d.ts +29 -0
- package/dist/elemental-lend-v2/update-aum.js +82 -0
- package/dist/index.d.ts +5 -3552
- package/dist/index.js +37 -4454
- package/dist/jlpd-strategy/accounts.d.ts +83 -0
- package/dist/jlpd-strategy/accounts.js +216 -0
- package/dist/jlpd-strategy/adapter.d.ts +81 -0
- package/dist/jlpd-strategy/adapter.js +118 -0
- package/dist/jlpd-strategy/base-to-base-swap.d.ts +74 -0
- package/dist/jlpd-strategy/base-to-base-swap.js +205 -0
- package/dist/jlpd-strategy/constants.d.ts +127 -0
- package/dist/jlpd-strategy/constants.js +174 -0
- package/dist/jlpd-strategy/fluid-view.d.ts +199 -0
- package/dist/jlpd-strategy/fluid-view.js +799 -0
- package/dist/jlpd-strategy/hedge-derived.d.ts +135 -0
- package/dist/jlpd-strategy/hedge-derived.js +231 -0
- package/dist/jlpd-strategy/hedge-instructions.d.ts +210 -0
- package/dist/jlpd-strategy/hedge-instructions.js +300 -0
- package/dist/jlpd-strategy/hedge-state.d.ts +88 -0
- package/dist/jlpd-strategy/hedge-state.js +110 -0
- package/dist/jlpd-strategy/index.d.ts +17 -0
- package/dist/jlpd-strategy/index.js +33 -0
- package/dist/jlpd-strategy/instructions.d.ts +159 -0
- package/dist/jlpd-strategy/instructions.js +234 -0
- package/dist/jlpd-strategy/jlp-borrow.d.ts +63 -0
- package/dist/jlpd-strategy/jlp-borrow.js +87 -0
- package/dist/jlpd-strategy/jlp-data.d.ts +166 -0
- package/dist/jlpd-strategy/jlp-data.js +611 -0
- package/dist/jlpd-strategy/jupusd-earn.d.ts +90 -0
- package/dist/jlpd-strategy/jupusd-earn.js +166 -0
- package/dist/jlpd-strategy/live-jlp-price.d.ts +46 -0
- package/dist/jlpd-strategy/live-jlp-price.js +267 -0
- package/dist/jlpd-strategy/pda.d.ts +13 -0
- package/dist/jlpd-strategy/pda.js +28 -0
- package/dist/jlpd-strategy/settle-yield.d.ts +45 -0
- package/dist/jlpd-strategy/settle-yield.js +113 -0
- package/dist/jlpd-strategy/swap-jlp.d.ts +198 -0
- package/dist/jlpd-strategy/swap-jlp.js +586 -0
- package/dist/jlpd-strategy/types.d.ts +101 -0
- package/dist/jlpd-strategy/types.js +29 -0
- package/dist/p-stv-core/accounts.d.ts +152 -0
- package/dist/p-stv-core/accounts.js +407 -0
- package/dist/p-stv-core/constants.d.ts +138 -0
- package/dist/p-stv-core/constants.js +181 -0
- package/dist/p-stv-core/events.d.ts +7 -0
- package/dist/p-stv-core/events.js +246 -0
- package/dist/p-stv-core/index.d.ts +11 -0
- package/dist/p-stv-core/index.js +27 -0
- package/dist/p-stv-core/instructions.d.ts +637 -0
- package/dist/p-stv-core/instructions.js +670 -0
- package/dist/p-stv-core/lut.d.ts +41 -0
- package/dist/p-stv-core/lut.js +81 -0
- package/dist/p-stv-core/pda.d.ts +30 -0
- package/dist/p-stv-core/pda.js +65 -0
- package/dist/p-stv-core/prices.d.ts +20 -0
- package/dist/p-stv-core/prices.js +77 -0
- package/dist/p-stv-core/remaining-accounts.d.ts +107 -0
- package/dist/p-stv-core/remaining-accounts.js +326 -0
- package/dist/p-stv-core/send-tx.d.ts +72 -0
- package/dist/p-stv-core/send-tx.js +290 -0
- package/dist/p-stv-core/sol-wrap.d.ts +34 -0
- package/dist/p-stv-core/sol-wrap.js +74 -0
- package/dist/p-stv-core/types.d.ts +361 -0
- package/dist/p-stv-core/types.js +2 -0
- package/package.json +56 -15
- package/dist/index.d.mts +0 -3552
- package/dist/index.mjs +0 -4363
|
@@ -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,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;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInitStrategyIx = createInitStrategyIx;
|
|
4
|
+
exports.createUpdateStrategyIx = createUpdateStrategyIx;
|
|
5
|
+
exports.createRegisterAdapterIx = createRegisterAdapterIx;
|
|
6
|
+
exports.createDeregisterAdapterIx = createDeregisterAdapterIx;
|
|
7
|
+
exports.createAddManagerIx = createAddManagerIx;
|
|
8
|
+
exports.createRemoveManagerIx = createRemoveManagerIx;
|
|
9
|
+
exports.createInitPositionIx = createInitPositionIx;
|
|
10
|
+
exports.createClosePositionIx = createClosePositionIx;
|
|
11
|
+
exports.createDepositIx = createDepositIx;
|
|
12
|
+
exports.createWithdrawIx = createWithdrawIx;
|
|
13
|
+
exports.createRouteDepositIx = createRouteDepositIx;
|
|
14
|
+
exports.createRouteWithdrawIx = createRouteWithdrawIx;
|
|
15
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
16
|
+
const buffer_1 = require("../common/buffer");
|
|
17
|
+
const constants_1 = require("./constants");
|
|
18
|
+
function createInitStrategyIx(args, programId = constants_1.PROGRAM_ID) {
|
|
19
|
+
const { admin, baseMint, strategyState, authority, systemProgram = web3_js_1.SystemProgram.programId, } = args;
|
|
20
|
+
return new web3_js_1.TransactionInstruction({
|
|
21
|
+
keys: [
|
|
22
|
+
{ pubkey: admin, isSigner: true, isWritable: true },
|
|
23
|
+
{ pubkey: baseMint, isSigner: false, isWritable: false },
|
|
24
|
+
{ pubkey: strategyState, isSigner: false, isWritable: true },
|
|
25
|
+
{ pubkey: authority, isSigner: false, isWritable: false },
|
|
26
|
+
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
27
|
+
],
|
|
28
|
+
programId,
|
|
29
|
+
data: constants_1.IX_INIT_STRATEGY,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function createUpdateStrategyIx(args, programId = constants_1.PROGRAM_ID) {
|
|
33
|
+
const parts = [];
|
|
34
|
+
(0, buffer_1.writeOptionalPubkey)(parts, args.newAdmin ?? null);
|
|
35
|
+
(0, buffer_1.writeOptionalU16)(parts, args.newFlags ?? null);
|
|
36
|
+
return new web3_js_1.TransactionInstruction({
|
|
37
|
+
keys: [
|
|
38
|
+
{ pubkey: args.admin, isSigner: true, isWritable: false },
|
|
39
|
+
{ pubkey: args.strategyState, isSigner: false, isWritable: true },
|
|
40
|
+
],
|
|
41
|
+
programId,
|
|
42
|
+
data: Buffer.concat([constants_1.IX_UPDATE_STRATEGY, Buffer.from(parts)]),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function createRegisterAdapterIx(args, programId = constants_1.PROGRAM_ID) {
|
|
46
|
+
const { admin, strategyState, protocolVault, adapterProgram, index, params, systemProgram = web3_js_1.SystemProgram.programId, } = args;
|
|
47
|
+
if (index < 0 || index > 0xff) {
|
|
48
|
+
throw new RangeError(`index out of range: ${index}`);
|
|
49
|
+
}
|
|
50
|
+
if (params.readAumAccountCount < 0 || params.readAumAccountCount > 0xff) {
|
|
51
|
+
throw new RangeError(`readAumAccountCount out of range: ${params.readAumAccountCount}`);
|
|
52
|
+
}
|
|
53
|
+
const data = Buffer.concat([
|
|
54
|
+
constants_1.IX_REGISTER_ADAPTER,
|
|
55
|
+
Buffer.from([index]),
|
|
56
|
+
params.protocolState.toBuffer(),
|
|
57
|
+
Buffer.from([params.readAumAccountCount]),
|
|
58
|
+
]);
|
|
59
|
+
return new web3_js_1.TransactionInstruction({
|
|
60
|
+
keys: [
|
|
61
|
+
{ pubkey: admin, isSigner: true, isWritable: true },
|
|
62
|
+
{ pubkey: strategyState, isSigner: false, isWritable: true },
|
|
63
|
+
{ pubkey: protocolVault, isSigner: false, isWritable: true },
|
|
64
|
+
{ pubkey: adapterProgram, isSigner: false, isWritable: false },
|
|
65
|
+
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
66
|
+
],
|
|
67
|
+
programId,
|
|
68
|
+
data,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function createDeregisterAdapterIx(args, programId = constants_1.PROGRAM_ID) {
|
|
72
|
+
const { admin, strategyState, protocolVault, systemProgram = web3_js_1.SystemProgram.programId, } = args;
|
|
73
|
+
return new web3_js_1.TransactionInstruction({
|
|
74
|
+
keys: [
|
|
75
|
+
{ pubkey: admin, isSigner: true, isWritable: true },
|
|
76
|
+
{ pubkey: strategyState, isSigner: false, isWritable: true },
|
|
77
|
+
{ pubkey: protocolVault, isSigner: false, isWritable: true },
|
|
78
|
+
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
79
|
+
],
|
|
80
|
+
programId,
|
|
81
|
+
data: constants_1.IX_DEREGISTER_ADAPTER,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function createAddManagerIx(args, programId = constants_1.PROGRAM_ID) {
|
|
85
|
+
const { admin, strategyState, managerRole, manager, systemProgram = web3_js_1.SystemProgram.programId, } = args;
|
|
86
|
+
return new web3_js_1.TransactionInstruction({
|
|
87
|
+
keys: [
|
|
88
|
+
{ pubkey: admin, isSigner: true, isWritable: true },
|
|
89
|
+
{ pubkey: strategyState, isSigner: false, isWritable: false },
|
|
90
|
+
{ pubkey: managerRole, isSigner: false, isWritable: true },
|
|
91
|
+
{ pubkey: manager, isSigner: false, isWritable: false },
|
|
92
|
+
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
93
|
+
],
|
|
94
|
+
programId,
|
|
95
|
+
data: constants_1.IX_ADD_MANAGER,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function createRemoveManagerIx(args, programId = constants_1.PROGRAM_ID) {
|
|
99
|
+
const { admin, strategyState, managerRole, systemProgram = web3_js_1.SystemProgram.programId, } = args;
|
|
100
|
+
return new web3_js_1.TransactionInstruction({
|
|
101
|
+
keys: [
|
|
102
|
+
{ pubkey: admin, isSigner: true, isWritable: true },
|
|
103
|
+
{ pubkey: strategyState, isSigner: false, isWritable: false },
|
|
104
|
+
{ pubkey: managerRole, isSigner: false, isWritable: true },
|
|
105
|
+
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
106
|
+
],
|
|
107
|
+
programId,
|
|
108
|
+
data: constants_1.IX_REMOVE_MANAGER,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function createInitPositionIx(args, programId = constants_1.PROGRAM_ID) {
|
|
112
|
+
const { strategyState, position, stv, payer, systemProgram = web3_js_1.SystemProgram.programId, } = args;
|
|
113
|
+
return new web3_js_1.TransactionInstruction({
|
|
114
|
+
keys: [
|
|
115
|
+
{ pubkey: strategyState, isSigner: false, isWritable: false },
|
|
116
|
+
{ pubkey: position, isSigner: false, isWritable: true },
|
|
117
|
+
{ pubkey: stv, isSigner: true, isWritable: false },
|
|
118
|
+
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
119
|
+
{ pubkey: systemProgram, isSigner: false, isWritable: false },
|
|
120
|
+
],
|
|
121
|
+
programId,
|
|
122
|
+
data: constants_1.IX_INIT_POSITION,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function createClosePositionIx(args, programId = constants_1.PROGRAM_ID) {
|
|
126
|
+
return new web3_js_1.TransactionInstruction({
|
|
127
|
+
keys: [
|
|
128
|
+
{ pubkey: args.strategyState, isSigner: false, isWritable: false },
|
|
129
|
+
{ pubkey: args.position, isSigner: false, isWritable: true },
|
|
130
|
+
{ pubkey: args.stv, isSigner: true, isWritable: true },
|
|
131
|
+
],
|
|
132
|
+
programId,
|
|
133
|
+
data: constants_1.IX_CLOSE_POSITION,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function createDepositIx(args, programId = constants_1.PROGRAM_ID) {
|
|
137
|
+
const data = [...constants_1.IX_DEPOSIT];
|
|
138
|
+
(0, buffer_1.writeU64)(data, args.amount);
|
|
139
|
+
return new web3_js_1.TransactionInstruction({
|
|
140
|
+
keys: [
|
|
141
|
+
{ pubkey: args.strategyState, isSigner: false, isWritable: true },
|
|
142
|
+
{ pubkey: args.position, isSigner: false, isWritable: true },
|
|
143
|
+
{ pubkey: args.stv, isSigner: true, isWritable: false },
|
|
144
|
+
],
|
|
145
|
+
programId,
|
|
146
|
+
data: Buffer.from(data),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function createWithdrawIx(args, programId = constants_1.PROGRAM_ID) {
|
|
150
|
+
const data = [...constants_1.IX_WITHDRAW];
|
|
151
|
+
(0, buffer_1.writeU64)(data, args.shares);
|
|
152
|
+
return new web3_js_1.TransactionInstruction({
|
|
153
|
+
keys: [
|
|
154
|
+
{ pubkey: args.strategyState, isSigner: false, isWritable: true },
|
|
155
|
+
{ pubkey: args.position, isSigner: false, isWritable: true },
|
|
156
|
+
{ pubkey: args.stv, isSigner: true, isWritable: false },
|
|
157
|
+
{ pubkey: args.strategyBaseAta, isSigner: false, isWritable: true },
|
|
158
|
+
{ pubkey: args.destAta, isSigner: false, isWritable: true },
|
|
159
|
+
{ pubkey: args.baseMint, isSigner: false, isWritable: false },
|
|
160
|
+
{ pubkey: args.tokenProgram, isSigner: false, isWritable: false },
|
|
161
|
+
],
|
|
162
|
+
programId,
|
|
163
|
+
data: Buffer.from(data),
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function buildRouteIx(disc, args, programId) {
|
|
167
|
+
const data = [...disc];
|
|
168
|
+
(0, buffer_1.writeU64)(data, args.amount);
|
|
169
|
+
return new web3_js_1.TransactionInstruction({
|
|
170
|
+
keys: [
|
|
171
|
+
{ pubkey: args.manager, isSigner: true, isWritable: false },
|
|
172
|
+
{ pubkey: args.managerRole, isSigner: false, isWritable: false },
|
|
173
|
+
{ pubkey: args.strategyState, isSigner: false, isWritable: false },
|
|
174
|
+
{ pubkey: args.protocolVault, isSigner: false, isWritable: false },
|
|
175
|
+
{ pubkey: args.strategyBaseAta, isSigner: false, isWritable: true },
|
|
176
|
+
{ pubkey: args.baseMint, isSigner: false, isWritable: false },
|
|
177
|
+
{ pubkey: args.tokenProgram, isSigner: false, isWritable: false },
|
|
178
|
+
{ pubkey: args.adapterProgram, isSigner: false, isWritable: false },
|
|
179
|
+
...args.remainingAccounts,
|
|
180
|
+
],
|
|
181
|
+
programId,
|
|
182
|
+
data: Buffer.from(data),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function createRouteDepositIx(args, programId = constants_1.PROGRAM_ID) {
|
|
186
|
+
return buildRouteIx(constants_1.IX_ROUTE_DEPOSIT, args, programId);
|
|
187
|
+
}
|
|
188
|
+
function createRouteWithdrawIx(args, programId = constants_1.PROGRAM_ID) {
|
|
189
|
+
return buildRouteIx(constants_1.IX_ROUTE_WITHDRAW, args, programId);
|
|
190
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PublicKey, TransactionInstruction, AddressLookupTableAccount } from "@solana/web3.js";
|
|
2
|
+
import type { SolanaConnection } from "../common/connection";
|
|
3
|
+
import type { LendStrategyState } from "./types";
|
|
4
|
+
import type { PerProtocolReadAumAccounts } from "./update-aum";
|
|
5
|
+
/**
|
|
6
|
+
* Build `extendLookupTable` instructions for every account touched by
|
|
7
|
+
* update_aum / route_* flows on a given strategy:
|
|
8
|
+
* - lend program ID
|
|
9
|
+
* - each unique adapter program (from ProtocolVault + extras)
|
|
10
|
+
* - each ProtocolVault PDA
|
|
11
|
+
* - each protocol_state
|
|
12
|
+
* - per-protocol adapter-specific accounts (caller-supplied — not stored on-chain in v2)
|
|
13
|
+
*
|
|
14
|
+
* Batched at ≤30 addresses per ix.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildElementalLendLutExtendIxs(connection: SolanaConnection, payer: PublicKey, lutAddress: PublicKey, strategy: LendStrategyState, strategyStatePda: PublicKey, perProtocolReadAumAccounts: PerProtocolReadAumAccounts, extraAdapterPrograms?: PublicKey[], programId?: PublicKey): Promise<TransactionInstruction[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Fetch an existing ALT for use in VersionedTransaction compilation.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveElementalLendLut(connection: Pick<import("@solana/web3.js").Connection, "getAddressLookupTable">, lutAddress: PublicKey): Promise<AddressLookupTableAccount>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildElementalLendLutExtendIxs = buildElementalLendLutExtendIxs;
|
|
4
|
+
exports.resolveElementalLendLut = resolveElementalLendLut;
|
|
5
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
const accounts_1 = require("./accounts");
|
|
8
|
+
const MAX_LUT_EXTEND_PER_IX = 30;
|
|
9
|
+
/**
|
|
10
|
+
* Build `extendLookupTable` instructions for every account touched by
|
|
11
|
+
* update_aum / route_* flows on a given strategy:
|
|
12
|
+
* - lend program ID
|
|
13
|
+
* - each unique adapter program (from ProtocolVault + extras)
|
|
14
|
+
* - each ProtocolVault PDA
|
|
15
|
+
* - each protocol_state
|
|
16
|
+
* - per-protocol adapter-specific accounts (caller-supplied — not stored on-chain in v2)
|
|
17
|
+
*
|
|
18
|
+
* Batched at ≤30 addresses per ix.
|
|
19
|
+
*/
|
|
20
|
+
async function buildElementalLendLutExtendIxs(connection, payer, lutAddress, strategy, strategyStatePda, perProtocolReadAumAccounts, extraAdapterPrograms = [], programId = constants_1.PROGRAM_ID) {
|
|
21
|
+
const keys = [programId];
|
|
22
|
+
if (strategy.protocolCount > 0) {
|
|
23
|
+
const pvs = await (0, accounts_1.fetchAllProtocolVaults)(connection, strategyStatePda, strategy.protocolCount, programId);
|
|
24
|
+
for (let i = 0; i < pvs.length; i++) {
|
|
25
|
+
const [pvPda, pv] = pvs[i];
|
|
26
|
+
keys.push(pvPda);
|
|
27
|
+
keys.push(pv.adapterProgram);
|
|
28
|
+
keys.push(pv.protocolState);
|
|
29
|
+
const reads = perProtocolReadAumAccounts[i];
|
|
30
|
+
if (reads)
|
|
31
|
+
for (const k of reads)
|
|
32
|
+
keys.push(k);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
for (const p of extraAdapterPrograms)
|
|
36
|
+
keys.push(p);
|
|
37
|
+
const seen = new Set();
|
|
38
|
+
const unique = keys.filter((k) => {
|
|
39
|
+
const s = k.toBase58();
|
|
40
|
+
if (seen.has(s))
|
|
41
|
+
return false;
|
|
42
|
+
seen.add(s);
|
|
43
|
+
return true;
|
|
44
|
+
});
|
|
45
|
+
const ixs = [];
|
|
46
|
+
for (let i = 0; i < unique.length; i += MAX_LUT_EXTEND_PER_IX) {
|
|
47
|
+
ixs.push(web3_js_1.AddressLookupTableProgram.extendLookupTable({
|
|
48
|
+
payer,
|
|
49
|
+
authority: payer,
|
|
50
|
+
lookupTable: lutAddress,
|
|
51
|
+
addresses: unique.slice(i, i + MAX_LUT_EXTEND_PER_IX),
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
return ixs;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Fetch an existing ALT for use in VersionedTransaction compilation.
|
|
58
|
+
*/
|
|
59
|
+
async function resolveElementalLendLut(connection, lutAddress) {
|
|
60
|
+
const { value } = await connection.getAddressLookupTable(lutAddress);
|
|
61
|
+
if (!value) {
|
|
62
|
+
throw new Error(`LUT not found: ${lutAddress.toBase58()}`);
|
|
63
|
+
}
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
/** StrategyState PDA: ["strategy_state", base_mint]. */
|
|
3
|
+
export declare function deriveStrategyState(baseMint: PublicKey, programId?: PublicKey): [PublicKey, number];
|
|
4
|
+
/** ProtocolVault PDA: ["protocol", strategy_state, [index]]. */
|
|
5
|
+
export declare function deriveProtocolVault(strategyState: PublicKey, index: number, programId?: PublicKey): [PublicKey, number];
|
|
6
|
+
/** ManagerRole PDA: ["manager", strategy_state, manager]. */
|
|
7
|
+
export declare function deriveManagerRole(strategyState: PublicKey, manager: PublicKey, programId?: PublicKey): [PublicKey, number];
|
|
8
|
+
/** StvPosition PDA: ["position", stv]. */
|
|
9
|
+
export declare function deriveStvPosition(stv: PublicKey, programId?: PublicKey): [PublicKey, number];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deriveStrategyState = deriveStrategyState;
|
|
4
|
+
exports.deriveProtocolVault = deriveProtocolVault;
|
|
5
|
+
exports.deriveManagerRole = deriveManagerRole;
|
|
6
|
+
exports.deriveStvPosition = deriveStvPosition;
|
|
7
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
/** StrategyState PDA: ["strategy_state", base_mint]. */
|
|
10
|
+
function deriveStrategyState(baseMint, programId = constants_1.PROGRAM_ID) {
|
|
11
|
+
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.STRATEGY_STATE_SEED, baseMint.toBuffer()], programId);
|
|
12
|
+
}
|
|
13
|
+
/** ProtocolVault PDA: ["protocol", strategy_state, [index]]. */
|
|
14
|
+
function deriveProtocolVault(strategyState, index, programId = constants_1.PROGRAM_ID) {
|
|
15
|
+
if (index < 0 || index > 0xff) {
|
|
16
|
+
throw new RangeError(`ProtocolVault index out of range: ${index}`);
|
|
17
|
+
}
|
|
18
|
+
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.PROTOCOL_VAULT_SEED, strategyState.toBuffer(), Buffer.from([index])], programId);
|
|
19
|
+
}
|
|
20
|
+
/** ManagerRole PDA: ["manager", strategy_state, manager]. */
|
|
21
|
+
function deriveManagerRole(strategyState, manager, programId = constants_1.PROGRAM_ID) {
|
|
22
|
+
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.MANAGER_SEED, strategyState.toBuffer(), manager.toBuffer()], programId);
|
|
23
|
+
}
|
|
24
|
+
/** StvPosition PDA: ["position", stv]. */
|
|
25
|
+
function deriveStvPosition(stv, programId = constants_1.PROGRAM_ID) {
|
|
26
|
+
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.POSITION_SEED, stv.toBuffer()], programId);
|
|
27
|
+
}
|