@elemental-stv-core/sdk 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +250 -0
- package/dist/common/ata.d.ts +14 -0
- package/dist/common/ata.js +21 -0
- package/dist/common/buffer.d.ts +0 -1
- package/dist/common/buffer.js +16 -1
- package/dist/common/connection.d.ts +13 -0
- package/dist/common/connection.js +2 -0
- package/dist/common/constants.d.ts +6 -1
- package/dist/common/constants.js +21 -2
- package/dist/common/index.d.ts +3 -2
- package/dist/common/index.js +6 -2
- package/dist/common/strategy-interface.d.ts +35 -5
- package/dist/common/strategy-interface.js +7 -5
- package/dist/elemental-lend/accounts.d.ts +53 -9
- package/dist/elemental-lend/accounts.js +66 -8
- package/dist/elemental-lend/constants.d.ts +4 -5
- package/dist/elemental-lend/constants.js +11 -10
- package/dist/elemental-lend/index.d.ts +0 -1
- package/dist/elemental-lend/index.js +0 -1
- package/dist/elemental-lend/instructions.d.ts +0 -1
- package/dist/elemental-lend/instructions.js +0 -1
- package/dist/elemental-lend/jupiter-lend.d.ts +0 -1
- package/dist/elemental-lend/jupiter-lend.js +2 -3
- package/dist/elemental-lend/kamino-vault.d.ts +6 -6
- package/dist/elemental-lend/kamino-vault.js +49 -26
- package/dist/elemental-lend/pda.d.ts +9 -2
- package/dist/elemental-lend/pda.js +10 -3
- package/dist/elemental-lend/protocol-actions.d.ts +6 -5
- package/dist/elemental-lend/protocol-actions.js +22 -17
- package/dist/elemental-lend/types.d.ts +0 -1
- package/dist/elemental-lend/types.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/jlpd-strategy/accounts.d.ts +64 -11
- package/dist/jlpd-strategy/accounts.js +66 -7
- package/dist/jlpd-strategy/adapter.d.ts +1 -2
- package/dist/jlpd-strategy/adapter.js +1 -2
- package/dist/jlpd-strategy/constants.d.ts +21 -13
- package/dist/jlpd-strategy/constants.js +31 -27
- package/dist/jlpd-strategy/index.d.ts +0 -1
- package/dist/jlpd-strategy/index.js +0 -1
- package/dist/jlpd-strategy/instructions.d.ts +0 -1
- package/dist/jlpd-strategy/instructions.js +0 -1
- package/dist/jlpd-strategy/jlp-borrow.d.ts +29 -1
- package/dist/jlpd-strategy/jlp-borrow.js +29 -1
- package/dist/jlpd-strategy/jlp-data.d.ts +4 -4
- package/dist/jlpd-strategy/jlp-data.js +0 -1
- package/dist/jlpd-strategy/jupusd-earn.d.ts +31 -6
- package/dist/jlpd-strategy/jupusd-earn.js +40 -26
- package/dist/jlpd-strategy/pda.d.ts +9 -4
- package/dist/jlpd-strategy/pda.js +10 -6
- package/dist/jlpd-strategy/settle-yield.d.ts +12 -45
- package/dist/jlpd-strategy/settle-yield.js +14 -19
- package/dist/jlpd-strategy/swap-jlp.d.ts +4 -4
- package/dist/jlpd-strategy/swap-jlp.js +36 -29
- package/dist/jlpd-strategy/types.d.ts +5 -4
- package/dist/jlpd-strategy/types.js +0 -1
- package/dist/p-stv-core/accounts.d.ts +84 -11
- package/dist/p-stv-core/accounts.js +108 -30
- package/dist/p-stv-core/constants.d.ts +13 -3
- package/dist/p-stv-core/constants.js +22 -12
- package/dist/p-stv-core/events.d.ts +0 -1
- package/dist/p-stv-core/events.js +51 -2
- package/dist/p-stv-core/index.d.ts +0 -1
- package/dist/p-stv-core/index.js +0 -1
- package/dist/p-stv-core/instructions.d.ts +49 -4
- package/dist/p-stv-core/instructions.js +46 -14
- package/dist/p-stv-core/pda.d.ts +9 -2
- package/dist/p-stv-core/pda.js +10 -3
- package/dist/p-stv-core/prices.d.ts +0 -1
- package/dist/p-stv-core/prices.js +0 -1
- package/dist/p-stv-core/remaining-accounts.d.ts +15 -18
- package/dist/p-stv-core/remaining-accounts.js +66 -75
- package/dist/p-stv-core/send-tx.d.ts +21 -7
- package/dist/p-stv-core/send-tx.js +16 -25
- package/dist/p-stv-core/sol-wrap.d.ts +0 -1
- package/dist/p-stv-core/sol-wrap.js +5 -6
- package/dist/p-stv-core/types.d.ts +12 -5
- package/dist/p-stv-core/types.js +0 -1
- package/package.json +17 -1
- package/dist/common/buffer.d.ts.map +0 -1
- package/dist/common/buffer.js.map +0 -1
- package/dist/common/constants.d.ts.map +0 -1
- package/dist/common/constants.js.map +0 -1
- package/dist/common/index.d.ts.map +0 -1
- package/dist/common/index.js.map +0 -1
- package/dist/common/strategy-interface.d.ts.map +0 -1
- package/dist/common/strategy-interface.js.map +0 -1
- package/dist/elemental-lend/accounts.d.ts.map +0 -1
- package/dist/elemental-lend/accounts.js.map +0 -1
- package/dist/elemental-lend/constants.d.ts.map +0 -1
- package/dist/elemental-lend/constants.js.map +0 -1
- package/dist/elemental-lend/index.d.ts.map +0 -1
- package/dist/elemental-lend/index.js.map +0 -1
- package/dist/elemental-lend/instructions.d.ts.map +0 -1
- package/dist/elemental-lend/instructions.js.map +0 -1
- package/dist/elemental-lend/jupiter-lend.d.ts.map +0 -1
- package/dist/elemental-lend/jupiter-lend.js.map +0 -1
- package/dist/elemental-lend/kamino-vault.d.ts.map +0 -1
- package/dist/elemental-lend/kamino-vault.js.map +0 -1
- package/dist/elemental-lend/pda.d.ts.map +0 -1
- package/dist/elemental-lend/pda.js.map +0 -1
- package/dist/elemental-lend/protocol-actions.d.ts.map +0 -1
- package/dist/elemental-lend/protocol-actions.js.map +0 -1
- package/dist/elemental-lend/types.d.ts.map +0 -1
- package/dist/elemental-lend/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jlpd-strategy/accounts.d.ts.map +0 -1
- package/dist/jlpd-strategy/accounts.js.map +0 -1
- package/dist/jlpd-strategy/adapter.d.ts.map +0 -1
- package/dist/jlpd-strategy/adapter.js.map +0 -1
- package/dist/jlpd-strategy/constants.d.ts.map +0 -1
- package/dist/jlpd-strategy/constants.js.map +0 -1
- package/dist/jlpd-strategy/index.d.ts.map +0 -1
- package/dist/jlpd-strategy/index.js.map +0 -1
- package/dist/jlpd-strategy/instructions.d.ts.map +0 -1
- package/dist/jlpd-strategy/instructions.js.map +0 -1
- package/dist/jlpd-strategy/jlp-borrow.d.ts.map +0 -1
- package/dist/jlpd-strategy/jlp-borrow.js.map +0 -1
- package/dist/jlpd-strategy/jlp-data.d.ts.map +0 -1
- package/dist/jlpd-strategy/jlp-data.js.map +0 -1
- package/dist/jlpd-strategy/jupusd-earn.d.ts.map +0 -1
- package/dist/jlpd-strategy/jupusd-earn.js.map +0 -1
- package/dist/jlpd-strategy/pda.d.ts.map +0 -1
- package/dist/jlpd-strategy/pda.js.map +0 -1
- package/dist/jlpd-strategy/settle-yield.d.ts.map +0 -1
- package/dist/jlpd-strategy/settle-yield.js.map +0 -1
- package/dist/jlpd-strategy/swap-jlp.d.ts.map +0 -1
- package/dist/jlpd-strategy/swap-jlp.js.map +0 -1
- package/dist/jlpd-strategy/types.d.ts.map +0 -1
- package/dist/jlpd-strategy/types.js.map +0 -1
- package/dist/p-stv-core/accounts.d.ts.map +0 -1
- package/dist/p-stv-core/accounts.js.map +0 -1
- package/dist/p-stv-core/constants.d.ts.map +0 -1
- package/dist/p-stv-core/constants.js.map +0 -1
- package/dist/p-stv-core/events.d.ts.map +0 -1
- package/dist/p-stv-core/events.js.map +0 -1
- package/dist/p-stv-core/index.d.ts.map +0 -1
- package/dist/p-stv-core/index.js.map +0 -1
- package/dist/p-stv-core/instructions.d.ts.map +0 -1
- package/dist/p-stv-core/instructions.js.map +0 -1
- package/dist/p-stv-core/pda.d.ts.map +0 -1
- package/dist/p-stv-core/pda.js.map +0 -1
- package/dist/p-stv-core/prices.d.ts.map +0 -1
- package/dist/p-stv-core/prices.js.map +0 -1
- package/dist/p-stv-core/remaining-accounts.d.ts.map +0 -1
- package/dist/p-stv-core/remaining-accounts.js.map +0 -1
- package/dist/p-stv-core/send-tx.d.ts.map +0 -1
- package/dist/p-stv-core/send-tx.js.map +0 -1
- package/dist/p-stv-core/sol-wrap.d.ts.map +0 -1
- package/dist/p-stv-core/sol-wrap.js.map +0 -1
- package/dist/p-stv-core/types.d.ts.map +0 -1
- package/dist/p-stv-core/types.js.map +0 -1
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
* Builds complete instruction arrays for deposit/withdraw to/from
|
|
5
5
|
* Kamino kVault and Jupiter Lend protocols. Ready to pass to sendSmartTx.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Connection interface required by the protocol-action builders. This is a
|
|
10
|
+
* narrower subset of the canonical `SolanaConnection` defined in
|
|
11
|
+
* `common/connection.ts` — protocol actions only ever need to read accounts.
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
+
import type { SolanaConnection } from "../common/connection";
|
|
14
|
+
export type ProtocolActionConnection = Pick<SolanaConnection, "getAccountInfo" | "getMultipleAccountsInfo">;
|
|
13
15
|
import type { JupiterLendPool } from "./jupiter-lend";
|
|
14
16
|
export type ProtocolType = "Kamino kVault" | "Jupiter Lend";
|
|
15
17
|
export type ProtocolAction = "deposit" | "withdraw";
|
|
@@ -46,4 +48,3 @@ export interface ProtocolActionArgs {
|
|
|
46
48
|
* @returns TransactionInstruction[] ready for sendSmartTx
|
|
47
49
|
*/
|
|
48
50
|
export declare function buildProtocolActionIxs(args: ProtocolActionArgs): Promise<TransactionInstruction[]>;
|
|
49
|
-
//# sourceMappingURL=protocol-actions.d.ts.map
|
|
@@ -9,18 +9,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.buildProtocolActionIxs = buildProtocolActionIxs;
|
|
10
10
|
const web3_js_1 = require("@solana/web3.js");
|
|
11
11
|
const spl_token_1 = require("@solana/spl-token");
|
|
12
|
+
const ata_1 = require("../common/ata");
|
|
12
13
|
const constants_1 = require("./constants");
|
|
13
14
|
const pda_1 = require("./pda");
|
|
14
15
|
const kamino_vault_1 = require("./kamino-vault");
|
|
15
16
|
const jupiter_lend_1 = require("./jupiter-lend");
|
|
16
17
|
// ---------------------------------------------------------------------------
|
|
17
|
-
// ATA derivation (inline to avoid spl-token runtime dep)
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
function findAta(mint, owner, tokenProgram) {
|
|
20
|
-
const [ata] = web3_js_1.PublicKey.findProgramAddressSync([owner.toBuffer(), tokenProgram.toBuffer(), mint.toBuffer()], spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
21
|
-
return ata;
|
|
22
|
-
}
|
|
23
|
-
// ---------------------------------------------------------------------------
|
|
24
18
|
// Main Builder
|
|
25
19
|
// ---------------------------------------------------------------------------
|
|
26
20
|
/**
|
|
@@ -40,8 +34,8 @@ async function buildProtocolActionIxs(args) {
|
|
|
40
34
|
const [strategyStatePda] = args.strategyState
|
|
41
35
|
? [args.strategyState]
|
|
42
36
|
: (0, pda_1.findStrategyStatePda)(baseMint, programId);
|
|
43
|
-
const strategyBaseAta = findAta(baseMint, strategyStatePda, tokenProgram);
|
|
44
|
-
const [managerRolePda] = (0, pda_1.
|
|
37
|
+
const strategyBaseAta = (0, ata_1.findAta)(baseMint, strategyStatePda, tokenProgram);
|
|
38
|
+
const [managerRolePda] = (0, pda_1.findLendManagerRolePda)(strategyStatePda, manager, programId);
|
|
45
39
|
if (protocolType === "Jupiter Lend") {
|
|
46
40
|
return buildJupLendActionIxs({
|
|
47
41
|
connection,
|
|
@@ -76,7 +70,7 @@ async function buildProtocolActionIxs(args) {
|
|
|
76
70
|
}
|
|
77
71
|
function buildJupLendActionIxs(params) {
|
|
78
72
|
const { manager, strategyStatePda, strategyBaseAta, managerRolePda, action, amount, tokenProgram, pool, programId, } = params;
|
|
79
|
-
const strategyFtokenAta = findAta(pool.fTokenMint, strategyStatePda, tokenProgram);
|
|
73
|
+
const strategyFtokenAta = (0, ata_1.findAta)(pool.fTokenMint, strategyStatePda, tokenProgram);
|
|
80
74
|
const JUP_LEND_PROG = new web3_js_1.PublicKey("jup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9");
|
|
81
75
|
// Fixed accounts for the Anchor instruction
|
|
82
76
|
const fixedAccounts = [
|
|
@@ -132,18 +126,25 @@ async function buildKvaultActionIxs(params) {
|
|
|
132
126
|
break;
|
|
133
127
|
}
|
|
134
128
|
}
|
|
135
|
-
// Fetch all reserves to read their lending_market field
|
|
129
|
+
// Fetch all reserves to read their lending_market field. `readReserveAccounts`
|
|
130
|
+
// (from kamino-vault.ts) is the canonical parser — keeps the KLend Reserve
|
|
131
|
+
// layout constants in one place.
|
|
136
132
|
const reserveInfos = await connection.getMultipleAccountsInfo(reserveKeys);
|
|
137
133
|
const klendReserves = [];
|
|
138
134
|
for (let i = 0; i < reserveKeys.length; i++) {
|
|
139
135
|
const rInfo = reserveInfos[i];
|
|
140
|
-
if (rInfo
|
|
141
|
-
|
|
136
|
+
if (!rInfo)
|
|
137
|
+
continue;
|
|
138
|
+
try {
|
|
139
|
+
const { lendingMarket } = (0, kamino_vault_1.readReserveAccounts)(rInfo.data);
|
|
142
140
|
klendReserves.push({ reserve: reserveKeys[i], lendingMarket });
|
|
143
141
|
}
|
|
142
|
+
catch {
|
|
143
|
+
// Skip reserves whose data isn't long enough for a full parse
|
|
144
|
+
}
|
|
144
145
|
}
|
|
145
146
|
const [sharesMint] = (0, kamino_vault_1.findKvaultSharesMint)(vaultState);
|
|
146
|
-
const strategySharesAta = findAta(sharesMint, strategyStatePda, tokenProgram);
|
|
147
|
+
const strategySharesAta = (0, ata_1.findAta)(sharesMint, strategyStatePda, tokenProgram);
|
|
147
148
|
// Fixed accounts for the Anchor instruction
|
|
148
149
|
const fixedAccounts = [
|
|
149
150
|
{ pubkey: manager, isSigner: true, isWritable: true },
|
|
@@ -188,7 +189,8 @@ async function buildKvaultWithdrawIxs(connection, fixedAccounts, vaultState, vau
|
|
|
188
189
|
else {
|
|
189
190
|
withdrawShares = amount; // fallback: 1:1
|
|
190
191
|
}
|
|
191
|
-
// Cap to actual kvToken balance
|
|
192
|
+
// Cap to actual kvToken balance.
|
|
193
|
+
// SPL Token Account layout: [mint(0..32)][owner(32..64)][amount(64..72)]…
|
|
192
194
|
const sharesAtaInfo = await connection.getAccountInfo(strategySharesAta);
|
|
193
195
|
if (sharesAtaInfo) {
|
|
194
196
|
const actualBalance = sharesAtaInfo.data.readBigUInt64LE(64);
|
|
@@ -196,7 +198,11 @@ async function buildKvaultWithdrawIxs(connection, fixedAccounts, vaultState, vau
|
|
|
196
198
|
withdrawShares = actualBalance;
|
|
197
199
|
}
|
|
198
200
|
}
|
|
199
|
-
// Read reserve data for withdraw accounts
|
|
201
|
+
// Read reserve data for withdraw accounts.
|
|
202
|
+
// Kamino VaultState — first allocation slot starts at offset 312:
|
|
203
|
+
// [312..344] reserve Pubkey
|
|
204
|
+
// [344..376] ctokenVault Pubkey
|
|
205
|
+
// (See `kamino-vault.ts:VAULT_ALLOCATION_OFFSET` for the full table.)
|
|
200
206
|
const reserveKey = new web3_js_1.PublicKey(vaultData.subarray(312, 344));
|
|
201
207
|
const reserveInfo = await connection.getAccountInfo(reserveKey);
|
|
202
208
|
if (!reserveInfo)
|
|
@@ -225,4 +231,3 @@ async function buildKvaultWithdrawIxs(connection, fixedAccounts, vaultState, vau
|
|
|
225
231
|
});
|
|
226
232
|
return [ix];
|
|
227
233
|
}
|
|
228
|
-
//# sourceMappingURL=protocol-actions.js.map
|
|
@@ -110,4 +110,3 @@ export interface ManagerRemovedEvent {
|
|
|
110
110
|
manager: PublicKey;
|
|
111
111
|
}
|
|
112
112
|
export type LendEvent = StrategyInitializedEvent | StrategyUpdatedEvent | PositionInitializedEvent | LendDepositEvent | LendWithdrawEvent | AumUpdatedEvent | KvaultDepositEvent | KvaultWithdrawEvent | JupLendDepositEvent | JupLendWithdrawEvent | ProtocolAddedEvent | ProtocolRemovedEvent | ManagerAddedEvent | ManagerRemovedEvent;
|
|
113
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -38,4 +38,3 @@ exports.common = __importStar(require("./common"));
|
|
|
38
38
|
exports.pStvCore = __importStar(require("./p-stv-core"));
|
|
39
39
|
exports.elementalLend = __importStar(require("./elemental-lend"));
|
|
40
40
|
exports.jlpdStrategy = __importStar(require("./jlpd-strategy"));
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,17 +1,70 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
import type { StvPosition } from "../common/strategy-interface";
|
|
3
|
+
import type { SolanaConnection } from "../common/connection";
|
|
3
4
|
import { JlpdConfig, ManagerRole, JlpStrategyState } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* JlpdConfig — singleton config shared across all five base-asset strategies.
|
|
7
|
+
* Total 272 bytes.
|
|
8
|
+
*
|
|
9
|
+
* Layout (offsets include the 8-byte discriminator):
|
|
10
|
+
* [ 0.. 8] discriminator (sha256("account:JlpdConfig")[..8])
|
|
11
|
+
* [ 8.. 40] admin Pubkey
|
|
12
|
+
* [ 40.. 72] jlpMint Pubkey
|
|
13
|
+
* [ 72..232] baseAssetMints[5] [Pubkey; 5] (BTC, ETH, SOL, USDC, JupUSD)
|
|
14
|
+
* [232..240] oracleStalenessTh u64 (max age in seconds)
|
|
15
|
+
* [240..242] flags u16
|
|
16
|
+
* [242..244] jlpSlippageBps u16 (max slippage on swap_jlp)
|
|
17
|
+
* [244..245] version u8
|
|
18
|
+
* [245..246] bump u8
|
|
19
|
+
* [246..272] _reserved [u8; 26]
|
|
20
|
+
*/
|
|
4
21
|
export declare function deserializeJlpdConfig(data: Buffer): JlpdConfig;
|
|
5
|
-
/**
|
|
6
|
-
|
|
22
|
+
/**
|
|
23
|
+
* ManagerRole — per-(config, manager) authorization. Total 80 bytes.
|
|
24
|
+
*
|
|
25
|
+
* Layout (offsets include the 8-byte discriminator):
|
|
26
|
+
* [ 0.. 8] discriminator (sha256("account:ManagerRole")[..8] —
|
|
27
|
+
* shared with p-stv-core + elemental-lend)
|
|
28
|
+
* [ 8.. 40] config Pubkey
|
|
29
|
+
* [ 40.. 72] manager Pubkey
|
|
30
|
+
* [ 72.. 73] bump u8
|
|
31
|
+
* [ 73.. 80] _padding [u8; 7]
|
|
32
|
+
*/
|
|
7
33
|
export declare function deserializeManagerRole(data: Buffer): ManagerRole;
|
|
34
|
+
/**
|
|
35
|
+
* JlpStrategyState — per-base-asset JLPD strategy account. Total 224 bytes.
|
|
36
|
+
*
|
|
37
|
+
* Layout (offsets include the 8-byte discriminator):
|
|
38
|
+
* [ 0.. 8] discriminator (sha256("account:StrategyState")[..8] —
|
|
39
|
+
* shared with elemental-lend)
|
|
40
|
+
* --- StrategyStateHeader (104 bytes, identical across all strategy programs) ---
|
|
41
|
+
* [ 8.. 40] baseMint Pubkey
|
|
42
|
+
* [ 40.. 72] authority Pubkey (p-stv-core program)
|
|
43
|
+
* [ 72.. 80] pps u64 (scaled by PPS_DECIMALS = 10^9)
|
|
44
|
+
* [ 80.. 88] totalAum u64
|
|
45
|
+
* [ 88.. 96] totalShares u64
|
|
46
|
+
* [ 96..104] lastUpdated u64 (unix seconds)
|
|
47
|
+
* [104..106] flags u16
|
|
48
|
+
* [106..107] version u8
|
|
49
|
+
* [107..108] bump u8
|
|
50
|
+
* [108..112] _headerPadding [u8; 4]
|
|
51
|
+
* --- Custom JLPD fields (112 bytes) ---
|
|
52
|
+
* [112..120] baseLoaned u64 (base assets swapped into JLP)
|
|
53
|
+
* [120..224] _reserved [u8; 104]
|
|
54
|
+
*/
|
|
8
55
|
export declare function deserializeJlpStrategyState(data: Buffer): JlpStrategyState;
|
|
56
|
+
/**
|
|
57
|
+
* StvPosition — per-STV virtual share record. Total 120 bytes.
|
|
58
|
+
*
|
|
59
|
+
* The on-disk layout is identical across elemental-lend and jlpd-strategy
|
|
60
|
+
* (`StvPosition` from `common/strategy-interface.ts`). The 8-byte
|
|
61
|
+
* discriminator validation here distinguishes the two so a `LendStvPosition`
|
|
62
|
+
* can't be parsed as a JLPD position by mistake. See
|
|
63
|
+
* `common/strategy-interface.ts` for the field-by-field layout.
|
|
64
|
+
*/
|
|
9
65
|
export declare function deserializeJlpStvPosition(data: Buffer): StvPosition;
|
|
10
|
-
export declare function fetchJlpdConfig(connection:
|
|
11
|
-
|
|
12
|
-
export declare
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function fetchAllJlpStrategyStates(connection: Connection, programId?: PublicKey): Promise<[PublicKey, JlpStrategyState][]>;
|
|
16
|
-
export declare function fetchManagersForConfig(connection: Connection, config: PublicKey, programId?: PublicKey): Promise<[PublicKey, ManagerRole][]>;
|
|
17
|
-
//# sourceMappingURL=accounts.d.ts.map
|
|
66
|
+
export declare function fetchJlpdConfig(connection: SolanaConnection, programId?: PublicKey): Promise<JlpdConfig>;
|
|
67
|
+
export declare function fetchJlpStrategyState(connection: SolanaConnection, baseMint: PublicKey, programId?: PublicKey): Promise<JlpStrategyState>;
|
|
68
|
+
export declare function fetchJlpStvPosition(connection: SolanaConnection, stv: PublicKey, programId?: PublicKey): Promise<StvPosition>;
|
|
69
|
+
export declare function fetchAllJlpStrategyStates(connection: SolanaConnection, programId?: PublicKey): Promise<[PublicKey, JlpStrategyState][]>;
|
|
70
|
+
export declare function fetchManagersForConfig(connection: SolanaConnection, config: PublicKey, programId?: PublicKey): Promise<[PublicKey, ManagerRole][]>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchJlpVault = exports.deserializeJlpVault = void 0;
|
|
4
3
|
exports.deserializeJlpdConfig = deserializeJlpdConfig;
|
|
5
4
|
exports.deserializeManagerRole = deserializeManagerRole;
|
|
6
5
|
exports.deserializeJlpStrategyState = deserializeJlpStrategyState;
|
|
@@ -16,7 +15,29 @@ const constants_1 = require("./constants");
|
|
|
16
15
|
const pda_1 = require("./pda");
|
|
17
16
|
// ---------------------------------------------------------------------------
|
|
18
17
|
// Deserialization
|
|
18
|
+
//
|
|
19
|
+
// All offsets below INCLUDE the 8-byte Anchor account discriminator. Layout
|
|
20
|
+
// blocks above each parser show the field map; the helpers in
|
|
21
|
+
// `common/buffer.ts` validate that `offset + width <= data.length` so a
|
|
22
|
+
// drift between this file and the on-chain layout fails loudly with a
|
|
23
|
+
// `RangeError` rather than returning garbage.
|
|
19
24
|
// ---------------------------------------------------------------------------
|
|
25
|
+
/**
|
|
26
|
+
* JlpdConfig — singleton config shared across all five base-asset strategies.
|
|
27
|
+
* Total 272 bytes.
|
|
28
|
+
*
|
|
29
|
+
* Layout (offsets include the 8-byte discriminator):
|
|
30
|
+
* [ 0.. 8] discriminator (sha256("account:JlpdConfig")[..8])
|
|
31
|
+
* [ 8.. 40] admin Pubkey
|
|
32
|
+
* [ 40.. 72] jlpMint Pubkey
|
|
33
|
+
* [ 72..232] baseAssetMints[5] [Pubkey; 5] (BTC, ETH, SOL, USDC, JupUSD)
|
|
34
|
+
* [232..240] oracleStalenessTh u64 (max age in seconds)
|
|
35
|
+
* [240..242] flags u16
|
|
36
|
+
* [242..244] jlpSlippageBps u16 (max slippage on swap_jlp)
|
|
37
|
+
* [244..245] version u8
|
|
38
|
+
* [245..246] bump u8
|
|
39
|
+
* [246..272] _reserved [u8; 26]
|
|
40
|
+
*/
|
|
20
41
|
function deserializeJlpdConfig(data) {
|
|
21
42
|
if (data.length < constants_1.JLPD_CONFIG_SIZE) {
|
|
22
43
|
throw new Error(`JlpdConfig data too short: ${data.length} < ${constants_1.JLPD_CONFIG_SIZE}`);
|
|
@@ -38,10 +59,21 @@ function deserializeJlpdConfig(data) {
|
|
|
38
59
|
jlpSlippageBps: (0, buffer_1.readU16)(data, 242),
|
|
39
60
|
version: (0, buffer_1.readU8)(data, 244),
|
|
40
61
|
bump: (0, buffer_1.readU8)(data, 245),
|
|
62
|
+
jlpEarnAmount: (0, buffer_1.readU64)(data, 248),
|
|
63
|
+
jlpAdapterProgram: (0, buffer_1.readPubkey)(data, 256),
|
|
41
64
|
};
|
|
42
65
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
66
|
+
/**
|
|
67
|
+
* ManagerRole — per-(config, manager) authorization. Total 80 bytes.
|
|
68
|
+
*
|
|
69
|
+
* Layout (offsets include the 8-byte discriminator):
|
|
70
|
+
* [ 0.. 8] discriminator (sha256("account:ManagerRole")[..8] —
|
|
71
|
+
* shared with p-stv-core + elemental-lend)
|
|
72
|
+
* [ 8.. 40] config Pubkey
|
|
73
|
+
* [ 40.. 72] manager Pubkey
|
|
74
|
+
* [ 72.. 73] bump u8
|
|
75
|
+
* [ 73.. 80] _padding [u8; 7]
|
|
76
|
+
*/
|
|
45
77
|
function deserializeManagerRole(data) {
|
|
46
78
|
if (data.length < constants_1.MANAGER_ROLE_SIZE) {
|
|
47
79
|
throw new Error(`ManagerRole data too short: ${data.length} < ${constants_1.MANAGER_ROLE_SIZE}`);
|
|
@@ -56,6 +88,27 @@ function deserializeManagerRole(data) {
|
|
|
56
88
|
bump: (0, buffer_1.readU8)(data, 72),
|
|
57
89
|
};
|
|
58
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* JlpStrategyState — per-base-asset JLPD strategy account. Total 224 bytes.
|
|
93
|
+
*
|
|
94
|
+
* Layout (offsets include the 8-byte discriminator):
|
|
95
|
+
* [ 0.. 8] discriminator (sha256("account:StrategyState")[..8] —
|
|
96
|
+
* shared with elemental-lend)
|
|
97
|
+
* --- StrategyStateHeader (104 bytes, identical across all strategy programs) ---
|
|
98
|
+
* [ 8.. 40] baseMint Pubkey
|
|
99
|
+
* [ 40.. 72] authority Pubkey (p-stv-core program)
|
|
100
|
+
* [ 72.. 80] pps u64 (scaled by PPS_DECIMALS = 10^9)
|
|
101
|
+
* [ 80.. 88] totalAum u64
|
|
102
|
+
* [ 88.. 96] totalShares u64
|
|
103
|
+
* [ 96..104] lastUpdated u64 (unix seconds)
|
|
104
|
+
* [104..106] flags u16
|
|
105
|
+
* [106..107] version u8
|
|
106
|
+
* [107..108] bump u8
|
|
107
|
+
* [108..112] _headerPadding [u8; 4]
|
|
108
|
+
* --- Custom JLPD fields (112 bytes) ---
|
|
109
|
+
* [112..120] baseLoaned u64 (base assets swapped into JLP)
|
|
110
|
+
* [120..224] _reserved [u8; 104]
|
|
111
|
+
*/
|
|
59
112
|
function deserializeJlpStrategyState(data) {
|
|
60
113
|
if (data.length < constants_1.STRATEGY_STATE_SIZE) {
|
|
61
114
|
throw new Error(`JlpStrategyState data too short: ${data.length} < ${constants_1.STRATEGY_STATE_SIZE}`);
|
|
@@ -79,6 +132,15 @@ function deserializeJlpStrategyState(data) {
|
|
|
79
132
|
baseLoaned: (0, buffer_1.readU64)(data, 112),
|
|
80
133
|
};
|
|
81
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* StvPosition — per-STV virtual share record. Total 120 bytes.
|
|
137
|
+
*
|
|
138
|
+
* The on-disk layout is identical across elemental-lend and jlpd-strategy
|
|
139
|
+
* (`StvPosition` from `common/strategy-interface.ts`). The 8-byte
|
|
140
|
+
* discriminator validation here distinguishes the two so a `LendStvPosition`
|
|
141
|
+
* can't be parsed as a JLPD position by mistake. See
|
|
142
|
+
* `common/strategy-interface.ts` for the field-by-field layout.
|
|
143
|
+
*/
|
|
82
144
|
function deserializeJlpStvPosition(data) {
|
|
83
145
|
if (data.length < constants_1.STV_POSITION_SIZE) {
|
|
84
146
|
throw new Error(`StvPosition data too short: ${data.length} < ${constants_1.STV_POSITION_SIZE}`);
|
|
@@ -99,8 +161,6 @@ async function fetchJlpdConfig(connection, programId = constants_1.PROGRAM_ID) {
|
|
|
99
161
|
throw new Error("JlpdConfig account not found");
|
|
100
162
|
return deserializeJlpdConfig(info.data);
|
|
101
163
|
}
|
|
102
|
-
/** @deprecated Use fetchJlpdConfig instead */
|
|
103
|
-
exports.fetchJlpVault = fetchJlpdConfig;
|
|
104
164
|
async function fetchJlpStrategyState(connection, baseMint, programId = constants_1.PROGRAM_ID) {
|
|
105
165
|
const [pda] = (0, pda_1.findStrategyStatePda)(baseMint, programId);
|
|
106
166
|
const info = await connection.getAccountInfo(pda);
|
|
@@ -132,9 +192,8 @@ async function fetchManagersForConfig(connection, config, programId = constants_
|
|
|
132
192
|
filters: [
|
|
133
193
|
{ dataSize: constants_1.MANAGER_ROLE_SIZE },
|
|
134
194
|
{ memcmp: { offset: 0, bytes: constants_1.DISC_MANAGER_ROLE.toString("base64"), encoding: "base64" } },
|
|
135
|
-
{ memcmp: { offset: 8, bytes: config.
|
|
195
|
+
{ memcmp: { offset: 8, bytes: config.toBuffer().toString("base64"), encoding: "base64" } },
|
|
136
196
|
],
|
|
137
197
|
});
|
|
138
198
|
return accounts.map((a) => [a.pubkey, deserializeManagerRole(a.account.data)]);
|
|
139
199
|
}
|
|
140
|
-
//# sourceMappingURL=accounts.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* JLPD Adapter instruction builders.
|
|
3
3
|
*
|
|
4
4
|
* These build JLPD-side instructions (deposit_to_adapter, withdraw_from_adapter)
|
|
5
|
-
* that CPI into the
|
|
5
|
+
* that CPI into the JLPD Lend Adapter program.
|
|
6
6
|
*/
|
|
7
7
|
import { PublicKey, TransactionInstruction, AccountMeta } from "@solana/web3.js";
|
|
8
8
|
import BN from "bn.js";
|
|
@@ -58,4 +58,3 @@ export interface AdapterManageArgs {
|
|
|
58
58
|
* Anchor data: [8-byte disc, AdapterManageParams(u8 + u64)]
|
|
59
59
|
*/
|
|
60
60
|
export declare function createAdapterManageIx(args: AdapterManageArgs, programId?: PublicKey): TransactionInstruction;
|
|
61
|
-
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* JLPD Adapter instruction builders.
|
|
4
4
|
*
|
|
5
5
|
* These build JLPD-side instructions (deposit_to_adapter, withdraw_from_adapter)
|
|
6
|
-
* that CPI into the
|
|
6
|
+
* that CPI into the JLPD Lend Adapter program.
|
|
7
7
|
*/
|
|
8
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -88,4 +88,3 @@ function createAdapterManageIx(args, programId = constants_1.PROGRAM_ID) {
|
|
|
88
88
|
data,
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
//# sourceMappingURL=adapter.js.map
|
|
@@ -20,14 +20,8 @@ export declare const CONFIG_SEED: Buffer<ArrayBuffer>;
|
|
|
20
20
|
export declare const MANAGER_SEED: Buffer<ArrayBuffer>;
|
|
21
21
|
export declare const STRATEGY_STATE_SEED: Buffer<ArrayBuffer>;
|
|
22
22
|
export declare const POSITION_SEED: Buffer<ArrayBuffer>;
|
|
23
|
-
/** @deprecated Use CONFIG_SEED instead */
|
|
24
|
-
export declare const JLP_VAULT_SEED: Buffer<ArrayBuffer>;
|
|
25
23
|
export declare const DISC_JLPD_CONFIG: Buffer<ArrayBuffer>;
|
|
26
|
-
export
|
|
27
|
-
export declare const DISC_STRATEGY_STATE: Buffer<ArrayBuffer>;
|
|
28
|
-
export declare const DISC_STV_POSITION: Buffer<ArrayBuffer>;
|
|
29
|
-
/** @deprecated Use DISC_JLPD_CONFIG instead */
|
|
30
|
-
export declare const DISC_JLP_VAULT: Buffer<ArrayBuffer>;
|
|
24
|
+
export { DISC_STRATEGY_STATE, DISC_STV_POSITION, DISC_MANAGER_ROLE, } from "../common/constants";
|
|
31
25
|
export declare const IX_INIT_OR_UPDATE_CONFIG: Buffer<ArrayBuffer>;
|
|
32
26
|
export declare const IX_INIT_OR_UPDATE_STRATEGY_STATE: Buffer<ArrayBuffer>;
|
|
33
27
|
export declare const IX_INIT_POSITION: Buffer<ArrayBuffer>;
|
|
@@ -42,14 +36,10 @@ export declare const IX_WITHDRAW_FROM_ADAPTER: Buffer<ArrayBuffer>;
|
|
|
42
36
|
export declare const IX_ADAPTER_MANAGE: Buffer<ArrayBuffer>;
|
|
43
37
|
export declare const IX_ADD_MANAGER: Buffer<ArrayBuffer>;
|
|
44
38
|
export declare const IX_REMOVE_MANAGER: Buffer<ArrayBuffer>;
|
|
45
|
-
/** @deprecated Use IX_INIT_OR_UPDATE_CONFIG instead */
|
|
46
|
-
export declare const IX_INIT_OR_UPDATE_JLP_VAULT: Buffer<ArrayBuffer>;
|
|
47
39
|
export declare const JLPD_CONFIG_SIZE = 392;
|
|
48
40
|
export declare const MANAGER_ROLE_SIZE = 80;
|
|
49
41
|
export declare const STRATEGY_STATE_SIZE = 224;
|
|
50
42
|
export declare const STV_POSITION_SIZE = 120;
|
|
51
|
-
/** @deprecated Use JLPD_CONFIG_SIZE instead */
|
|
52
|
-
export declare const JLP_VAULT_SIZE = 392;
|
|
53
43
|
export declare const FLAG_PAUSED = 1;
|
|
54
44
|
export declare const FLAG_DEPOSITS_DISABLED = 2;
|
|
55
45
|
export declare const FLAG_WITHDRAWALS_DISABLED = 4;
|
|
@@ -60,6 +50,24 @@ export declare const NUM_ASSETS = 5;
|
|
|
60
50
|
export declare const MAX_MGMT_FEE_BPS = 500;
|
|
61
51
|
export declare const MAX_PERF_FEE_BPS = 3000;
|
|
62
52
|
export { PPS_DECIMALS, BPS_DENOMINATOR } from "../common/constants";
|
|
63
|
-
/**
|
|
53
|
+
/** Stable per-pool registry for JLPD strategy STVs.
|
|
54
|
+
*
|
|
55
|
+
* Each entry is the canonical record for a pool: short symbol, base mint
|
|
56
|
+
* address (base58), p-STV Core vault id, and base mint decimals. The
|
|
57
|
+
* `JLPD_VAULT_IDS` and `JLPD_POOL_NAMES_BY_VAULT_ID` lookups below are
|
|
58
|
+
* derived from this single table so consumers cannot get out of sync.
|
|
59
|
+
*/
|
|
60
|
+
export declare const JLPD_POOLS: ReadonlyArray<{
|
|
61
|
+
readonly name: "BTC" | "ETH" | "SOL" | "USDC" | "JupUSD";
|
|
62
|
+
readonly mint: string;
|
|
63
|
+
readonly vaultId: number;
|
|
64
|
+
readonly decimals: number;
|
|
65
|
+
}>;
|
|
66
|
+
/** Pool symbol type derived from `JLPD_POOLS`. */
|
|
67
|
+
export type JlpdPoolName = (typeof JLPD_POOLS)[number]["name"];
|
|
68
|
+
/** Lookup: base_mint (base58) → vault_id. Derived from `JLPD_POOLS`. */
|
|
64
69
|
export declare const JLPD_VAULT_IDS: Record<string, number>;
|
|
65
|
-
|
|
70
|
+
/** Lookup: pool symbol → vault_id. Derived from `JLPD_POOLS`. */
|
|
71
|
+
export declare const JLPD_VAULT_IDS_BY_POOL: Record<JlpdPoolName, number>;
|
|
72
|
+
/** Lookup: pool symbol → base mint decimals. Derived from `JLPD_POOLS`. */
|
|
73
|
+
export declare const JLPD_POOL_DECIMALS: Record<JlpdPoolName, number>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.
|
|
4
|
-
exports.
|
|
3
|
+
exports.JLPD_VAULT_IDS_BY_POOL = exports.JLPD_VAULT_IDS = 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_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_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 = 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;
|
|
@@ -28,17 +28,14 @@ exports.CONFIG_SEED = Buffer.from("config");
|
|
|
28
28
|
exports.MANAGER_SEED = Buffer.from("manager");
|
|
29
29
|
exports.STRATEGY_STATE_SEED = Buffer.from("strategy_state");
|
|
30
30
|
exports.POSITION_SEED = Buffer.from("position");
|
|
31
|
-
/** @deprecated Use CONFIG_SEED instead */
|
|
32
|
-
exports.JLP_VAULT_SEED = exports.CONFIG_SEED;
|
|
33
31
|
// Account discriminators (Anchor 8-byte)
|
|
34
|
-
// sha256("account:JlpdConfig")[..8]
|
|
32
|
+
// sha256("account:JlpdConfig")[..8] — JLPD-specific
|
|
35
33
|
exports.DISC_JLPD_CONFIG = Buffer.from([185, 146, 185, 28, 172, 71, 122, 38]);
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
exports.DISC_JLP_VAULT = exports.DISC_JLPD_CONFIG;
|
|
34
|
+
// Shared types — defined once in common/, re-exported here
|
|
35
|
+
var constants_1 = require("../common/constants");
|
|
36
|
+
Object.defineProperty(exports, "DISC_STRATEGY_STATE", { enumerable: true, get: function () { return constants_1.DISC_STRATEGY_STATE; } });
|
|
37
|
+
Object.defineProperty(exports, "DISC_STV_POSITION", { enumerable: true, get: function () { return constants_1.DISC_STV_POSITION; } });
|
|
38
|
+
Object.defineProperty(exports, "DISC_MANAGER_ROLE", { enumerable: true, get: function () { return constants_1.DISC_MANAGER_ROLE; } });
|
|
42
39
|
// Instruction discriminators (Anchor 8-byte)
|
|
43
40
|
exports.IX_INIT_OR_UPDATE_CONFIG = Buffer.from([234, 24, 218, 120, 213, 149, 245, 213]);
|
|
44
41
|
exports.IX_INIT_OR_UPDATE_STRATEGY_STATE = Buffer.from([223, 7, 93, 99, 12, 44, 180, 255]);
|
|
@@ -59,15 +56,11 @@ exports.IX_ADAPTER_MANAGE = Buffer.from([210, 30, 127, 237, 109, 210, 2, 212]);
|
|
|
59
56
|
exports.IX_ADD_MANAGER = Buffer.from([125, 38, 192, 212, 101, 91, 179, 16]);
|
|
60
57
|
// sha256("global:remove_manager")[..8]
|
|
61
58
|
exports.IX_REMOVE_MANAGER = Buffer.from([150, 55, 157, 77, 128, 148, 7, 15]);
|
|
62
|
-
/** @deprecated Use IX_INIT_OR_UPDATE_CONFIG instead */
|
|
63
|
-
exports.IX_INIT_OR_UPDATE_JLP_VAULT = exports.IX_INIT_OR_UPDATE_CONFIG;
|
|
64
59
|
// Account sizes
|
|
65
60
|
exports.JLPD_CONFIG_SIZE = 392;
|
|
66
61
|
exports.MANAGER_ROLE_SIZE = 80;
|
|
67
62
|
exports.STRATEGY_STATE_SIZE = 224;
|
|
68
63
|
exports.STV_POSITION_SIZE = 120;
|
|
69
|
-
/** @deprecated Use JLPD_CONFIG_SIZE instead */
|
|
70
|
-
exports.JLP_VAULT_SIZE = exports.JLPD_CONFIG_SIZE;
|
|
71
64
|
// Flags
|
|
72
65
|
exports.FLAG_PAUSED = 0x0001;
|
|
73
66
|
exports.FLAG_DEPOSITS_DISABLED = 0x0002;
|
|
@@ -79,15 +72,26 @@ exports.FLAG_TEST_MODE = 0x0020;
|
|
|
79
72
|
exports.NUM_ASSETS = 5;
|
|
80
73
|
exports.MAX_MGMT_FEE_BPS = 500;
|
|
81
74
|
exports.MAX_PERF_FEE_BPS = 3000;
|
|
82
|
-
var
|
|
83
|
-
Object.defineProperty(exports, "PPS_DECIMALS", { enumerable: true, get: function () { return
|
|
84
|
-
Object.defineProperty(exports, "BPS_DENOMINATOR", { enumerable: true, get: function () { return
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
75
|
+
var constants_2 = require("../common/constants");
|
|
76
|
+
Object.defineProperty(exports, "PPS_DECIMALS", { enumerable: true, get: function () { return constants_2.PPS_DECIMALS; } });
|
|
77
|
+
Object.defineProperty(exports, "BPS_DENOMINATOR", { enumerable: true, get: function () { return constants_2.BPS_DENOMINATOR; } });
|
|
78
|
+
/** Stable per-pool registry for JLPD strategy STVs.
|
|
79
|
+
*
|
|
80
|
+
* Each entry is the canonical record for a pool: short symbol, base mint
|
|
81
|
+
* address (base58), p-STV Core vault id, and base mint decimals. The
|
|
82
|
+
* `JLPD_VAULT_IDS` and `JLPD_POOL_NAMES_BY_VAULT_ID` lookups below are
|
|
83
|
+
* derived from this single table so consumers cannot get out of sync.
|
|
84
|
+
*/
|
|
85
|
+
exports.JLPD_POOLS = [
|
|
86
|
+
{ name: "BTC", mint: "3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh", vaultId: 11, decimals: 8 },
|
|
87
|
+
{ name: "ETH", mint: "7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs", vaultId: 12, decimals: 8 },
|
|
88
|
+
{ name: "SOL", mint: "So11111111111111111111111111111111111111112", vaultId: 13, decimals: 9 },
|
|
89
|
+
{ name: "USDC", mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", vaultId: 14, decimals: 6 },
|
|
90
|
+
{ name: "JupUSD", mint: "JuprjznTrTSp2UFa3ZBUFgwdAmtZCq4MQCwysN55USD", vaultId: 15, decimals: 6 },
|
|
91
|
+
];
|
|
92
|
+
/** Lookup: base_mint (base58) → vault_id. Derived from `JLPD_POOLS`. */
|
|
93
|
+
exports.JLPD_VAULT_IDS = Object.fromEntries(exports.JLPD_POOLS.map((p) => [p.mint, p.vaultId]));
|
|
94
|
+
/** Lookup: pool symbol → vault_id. Derived from `JLPD_POOLS`. */
|
|
95
|
+
exports.JLPD_VAULT_IDS_BY_POOL = Object.fromEntries(exports.JLPD_POOLS.map((p) => [p.name, p.vaultId]));
|
|
96
|
+
/** Lookup: pool symbol → base mint decimals. Derived from `JLPD_POOLS`. */
|
|
97
|
+
exports.JLPD_POOL_DECIMALS = Object.fromEntries(exports.JLPD_POOLS.map((p) => [p.name, p.decimals]));
|
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The instruction builders for deposit/withdraw are in adapter.ts.
|
|
5
5
|
* This file provides static account addresses and position parsing utilities.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Read-only utilities for displaying JLP Borrow positions. This module exports
|
|
9
|
+
* **no instruction builders** — all on-chain operations against the Jupiter
|
|
10
|
+
* Lend Borrow program are routed through `adapter.ts`. The exports here are:
|
|
11
|
+
*
|
|
12
|
+
* - Static program / account constants (program IDs, vault accounts, oracles)
|
|
13
|
+
* - `parsePosition` — deserializes a position account
|
|
14
|
+
* - `readBorrowExchangePrice` — reads the vault state exchange price
|
|
15
|
+
*
|
|
16
|
+
* Anything new that needs to *send transactions* should live in `adapter.ts`.
|
|
6
17
|
*/
|
|
7
18
|
import { PublicKey } from "@solana/web3.js";
|
|
8
19
|
import BN from "bn.js";
|
|
@@ -30,6 +41,23 @@ export interface BorrowPosition {
|
|
|
30
41
|
dustDebtAmount: BN;
|
|
31
42
|
positionMint: PublicKey;
|
|
32
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Parse a Jupiter Lend Borrow Position account.
|
|
46
|
+
*
|
|
47
|
+
* Layout (offsets include the 8-byte discriminator):
|
|
48
|
+
* [ 0.. 8] discriminator (sha256("account:Position")[..8] —
|
|
49
|
+
* value documented in `POSITION_DISCRIMINATOR`)
|
|
50
|
+
* [ 8.. 14] _padding [u8; 6]
|
|
51
|
+
* [ 14.. 46] positionMint Pubkey (NFT mint that owns this position)
|
|
52
|
+
* [ 46.. 47] _padding u8
|
|
53
|
+
* [ 47.. 51] tick i32 (signed Fluid Vaults tick)
|
|
54
|
+
* [ 51.. 55] _padding [u8; 4]
|
|
55
|
+
* [ 55.. 63] supplyAmount u64 (collateral)
|
|
56
|
+
* [ 63.. 71] dustDebtAmount u64 (residual borrow)
|
|
57
|
+
*/
|
|
33
58
|
export declare function parsePosition(data: Buffer): BorrowPosition;
|
|
59
|
+
/**
|
|
60
|
+
* Read the exchange price (1e12 precision) from a Jupiter Lend Borrow VaultState
|
|
61
|
+
* account. The price is at offset 107 (u64 LE) within the account data.
|
|
62
|
+
*/
|
|
34
63
|
export declare function readBorrowExchangePrice(vaultStateData: Buffer): BN;
|
|
35
|
-
//# sourceMappingURL=jlp-borrow.d.ts.map
|