@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,6 +4,17 @@
|
|
|
4
4
|
*
|
|
5
5
|
* The instruction builders for deposit/withdraw are in adapter.ts.
|
|
6
6
|
* This file provides static account addresses and position parsing utilities.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Read-only utilities for displaying JLP Borrow positions. This module exports
|
|
10
|
+
* **no instruction builders** — all on-chain operations against the Jupiter
|
|
11
|
+
* Lend Borrow program are routed through `adapter.ts`. The exports here are:
|
|
12
|
+
*
|
|
13
|
+
* - Static program / account constants (program IDs, vault accounts, oracles)
|
|
14
|
+
* - `parsePosition` — deserializes a position account
|
|
15
|
+
* - `readBorrowExchangePrice` — reads the vault state exchange price
|
|
16
|
+
*
|
|
17
|
+
* Anything new that needs to *send transactions* should live in `adapter.ts`.
|
|
7
18
|
*/
|
|
8
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
20
|
exports.POSITION_DISCRIMINATOR = exports.JLP_JUPUSD_VAULT_ID = exports.ORACLE_PROGRAM = exports.LIQUIDITY_PROGRAM = exports.LIQUIDITY = exports.NEW_BRANCH = exports.VAULT_BORROW_ATA = exports.VAULT_SUPPLY_ATA = exports.BORROW_RATE_MODEL = exports.SUPPLY_RATE_MODEL = exports.VAULT_BORROW_POS_ON_LIQ = exports.VAULT_SUPPLY_POS_ON_LIQ = exports.BORROW_RESERVES_LIQUIDITY = exports.SUPPLY_RESERVES_LIQUIDITY = exports.BORROW_ORACLE = exports.BORROW_VAULT_STATE = exports.BORROW_VAULT_CONFIG = exports.JUP_LEND_BORROW_PROGRAM = void 0;
|
|
@@ -38,6 +49,20 @@ exports.JLP_JUPUSD_VAULT_ID = 58;
|
|
|
38
49
|
// Position Account Parsing
|
|
39
50
|
// ============================================================================
|
|
40
51
|
exports.POSITION_DISCRIMINATOR = Buffer.from([0xaa, 0xbc, 0x8f, 0xe4, 0x7a, 0x40, 0xf7, 0xd0]);
|
|
52
|
+
/**
|
|
53
|
+
* Parse a Jupiter Lend Borrow Position account.
|
|
54
|
+
*
|
|
55
|
+
* Layout (offsets include the 8-byte discriminator):
|
|
56
|
+
* [ 0.. 8] discriminator (sha256("account:Position")[..8] —
|
|
57
|
+
* value documented in `POSITION_DISCRIMINATOR`)
|
|
58
|
+
* [ 8.. 14] _padding [u8; 6]
|
|
59
|
+
* [ 14.. 46] positionMint Pubkey (NFT mint that owns this position)
|
|
60
|
+
* [ 46.. 47] _padding u8
|
|
61
|
+
* [ 47.. 51] tick i32 (signed Fluid Vaults tick)
|
|
62
|
+
* [ 51.. 55] _padding [u8; 4]
|
|
63
|
+
* [ 55.. 63] supplyAmount u64 (collateral)
|
|
64
|
+
* [ 63.. 71] dustDebtAmount u64 (residual borrow)
|
|
65
|
+
*/
|
|
41
66
|
function parsePosition(data) {
|
|
42
67
|
if (data.length < 71)
|
|
43
68
|
throw new Error(`Position data too short: ${data.length}`);
|
|
@@ -51,9 +76,12 @@ function parsePosition(data) {
|
|
|
51
76
|
dustDebtAmount: (0, buffer_1.readU64)(data, 63),
|
|
52
77
|
};
|
|
53
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Read the exchange price (1e12 precision) from a Jupiter Lend Borrow VaultState
|
|
81
|
+
* account. The price is at offset 107 (u64 LE) within the account data.
|
|
82
|
+
*/
|
|
54
83
|
function readBorrowExchangePrice(vaultStateData) {
|
|
55
84
|
if (vaultStateData.length < 115)
|
|
56
85
|
throw new Error("VaultState data too short");
|
|
57
86
|
return (0, buffer_1.readU64)(vaultStateData, 107);
|
|
58
87
|
}
|
|
59
|
-
//# sourceMappingURL=jlp-borrow.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { SolanaConnection } from "../common/connection";
|
|
2
3
|
export type CustodyName = "SOL" | "ETH" | "WBTC" | "USDC" | "USDT";
|
|
3
4
|
export interface JlpCustody {
|
|
4
5
|
name: CustodyName;
|
|
@@ -43,7 +44,7 @@ export interface JlpPoolDetails {
|
|
|
43
44
|
* Reads the Pool account for fees and aumUsd, Custody accounts for per-asset
|
|
44
45
|
* data including target weights, and the JLP mint for total supply.
|
|
45
46
|
*/
|
|
46
|
-
export declare function fetchJlpPoolDetails(connection:
|
|
47
|
+
export declare function fetchJlpPoolDetails(connection: SolanaConnection): Promise<JlpPoolDetails>;
|
|
47
48
|
/**
|
|
48
49
|
* Estimate the addLiquidity fee for depositing into a specific JLP custody.
|
|
49
50
|
*
|
|
@@ -69,5 +70,4 @@ export declare function computeAddLiquidityFee(args: {
|
|
|
69
70
|
feeBps: number;
|
|
70
71
|
isDiscount: boolean;
|
|
71
72
|
};
|
|
72
|
-
export declare function fetchJlpCustodyData(connection:
|
|
73
|
-
//# sourceMappingURL=jlp-data.d.ts.map
|
|
73
|
+
export declare function fetchJlpCustodyData(connection: SolanaConnection): Promise<JlpData>;
|
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Jupiter Lend Earn SDK helpers for JLPD Strategy.
|
|
3
3
|
*
|
|
4
|
-
* Provides
|
|
5
|
-
*
|
|
4
|
+
* Provides position reading and APR computation for the JupUSD Earn
|
|
5
|
+
* pool used by the JLP Borrow / JupUSD Earn route.
|
|
6
6
|
*
|
|
7
7
|
* Reuses the JupUSD pool config from elemental-lend/jupiter-lend.ts
|
|
8
8
|
* since it's the same Jupiter Lend Earn program and pool.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Read-only utilities for displaying JupUSD Earn positions. This module exports
|
|
12
|
+
* **no instruction builders** — all on-chain operations against the Jupiter
|
|
13
|
+
* Lend Earn program are routed through `adapter.ts`. The exports here are:
|
|
14
|
+
*
|
|
15
|
+
* - Static program / account constants for the JupUSD Earn pool
|
|
16
|
+
* - `computeExchangeRate`, `computeFTokenValue`, `computeEarnApr` — math
|
|
17
|
+
* - `fetchEarnPosition` — read-only position fetcher
|
|
18
|
+
*
|
|
19
|
+
* Anything new that needs to *send transactions* should live in `adapter.ts`.
|
|
9
20
|
*/
|
|
10
|
-
import {
|
|
21
|
+
import { PublicKey } from "@solana/web3.js";
|
|
11
22
|
import BN from "bn.js";
|
|
12
|
-
|
|
23
|
+
import type { SolanaConnection } from "../common/connection";
|
|
24
|
+
import { JUP_LEND_EARN_PROGRAM } from "../elemental-lend/constants";
|
|
25
|
+
/**
|
|
26
|
+
* Jupiter Lend Earn program ID. Re-exported from `elemental-lend/constants`
|
|
27
|
+
* so callers of `jlpd-strategy/jupusd-earn` can reach it without an extra
|
|
28
|
+
* import path.
|
|
29
|
+
*/
|
|
30
|
+
export { JUP_LEND_EARN_PROGRAM };
|
|
13
31
|
export declare const JUPUSD_LENDING: PublicKey;
|
|
14
32
|
export declare const JUPUSD_FTOKEN_MINT: PublicKey;
|
|
15
33
|
export declare const JUPUSD_RESERVES_LIQUIDITY: PublicKey;
|
|
@@ -21,6 +39,14 @@ export declare const JUPUSD_LENDING_ADMIN: PublicKey;
|
|
|
21
39
|
/**
|
|
22
40
|
* Read the earn exchange rate from lending account + rewards model.
|
|
23
41
|
* Returns the rate scaled to 1e12.
|
|
42
|
+
*
|
|
43
|
+
* Jupiter Lend Earn lending account layout (relevant fields):
|
|
44
|
+
* [115..123] baseExchangePrice u64 (1e12 precision)
|
|
45
|
+
* [123..131] lastUpdate u64 (unix seconds)
|
|
46
|
+
*
|
|
47
|
+
* Jupiter Lend rewards rate model layout (relevant fields):
|
|
48
|
+
* [ 56.. 64] startTime u64 (unix seconds)
|
|
49
|
+
* [ 64.. 72] yearlyReward u64 (rewards distributed per year)
|
|
24
50
|
*/
|
|
25
51
|
export declare function computeExchangeRate(lendingData: Buffer, rewardsModelData: Buffer, fTokenTotalSupply: BN, currentTimestamp: number): bigint;
|
|
26
52
|
/**
|
|
@@ -61,5 +87,4 @@ export interface EarnPositionInfo {
|
|
|
61
87
|
* Fetch the earn position for a jlpd_config PDA.
|
|
62
88
|
* Returns null if no fToken ATA exists.
|
|
63
89
|
*/
|
|
64
|
-
export declare function fetchEarnPosition(connection:
|
|
65
|
-
//# sourceMappingURL=jupusd-earn.d.ts.map
|
|
90
|
+
export declare function fetchEarnPosition(connection: SolanaConnection, fTokenAta: PublicKey): Promise<EarnPositionInfo | null>;
|
|
@@ -2,11 +2,22 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Jupiter Lend Earn SDK helpers for JLPD Strategy.
|
|
4
4
|
*
|
|
5
|
-
* Provides
|
|
6
|
-
*
|
|
5
|
+
* Provides position reading and APR computation for the JupUSD Earn
|
|
6
|
+
* pool used by the JLP Borrow / JupUSD Earn route.
|
|
7
7
|
*
|
|
8
8
|
* Reuses the JupUSD pool config from elemental-lend/jupiter-lend.ts
|
|
9
9
|
* since it's the same Jupiter Lend Earn program and pool.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* Read-only utilities for displaying JupUSD Earn positions. This module exports
|
|
13
|
+
* **no instruction builders** — all on-chain operations against the Jupiter
|
|
14
|
+
* Lend Earn program are routed through `adapter.ts`. The exports here are:
|
|
15
|
+
*
|
|
16
|
+
* - Static program / account constants for the JupUSD Earn pool
|
|
17
|
+
* - `computeExchangeRate`, `computeFTokenValue`, `computeEarnApr` — math
|
|
18
|
+
* - `fetchEarnPosition` — read-only position fetcher
|
|
19
|
+
*
|
|
20
|
+
* Anything new that needs to *send transactions* should live in `adapter.ts`.
|
|
10
21
|
*/
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -17,29 +28,26 @@ exports.computeExchangeRate = computeExchangeRate;
|
|
|
17
28
|
exports.computeFTokenValue = computeFTokenValue;
|
|
18
29
|
exports.computeEarnApr = computeEarnApr;
|
|
19
30
|
exports.fetchEarnPosition = fetchEarnPosition;
|
|
20
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
21
31
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
22
32
|
const buffer_1 = require("../common/buffer");
|
|
33
|
+
const jupiter_lend_1 = require("../elemental-lend/jupiter-lend");
|
|
34
|
+
const constants_1 = require("../elemental-lend/constants");
|
|
35
|
+
Object.defineProperty(exports, "JUP_LEND_EARN_PROGRAM", { enumerable: true, get: function () { return constants_1.JUP_LEND_EARN_PROGRAM; } });
|
|
23
36
|
// ============================================================================
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
|
|
37
|
+
// JupUSD Earn Pool — Static Accounts
|
|
38
|
+
// ----------------------------------------------------------------------------
|
|
39
|
+
// All pool addresses are imported from `elemental-lend/jupiter-lend.ts` so
|
|
40
|
+
// there is exactly one canonical definition. The named re-exports below are
|
|
41
|
+
// preserved for backwards compatibility with any external consumers.
|
|
27
42
|
// ============================================================================
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
exports.
|
|
32
|
-
exports.
|
|
33
|
-
exports.
|
|
34
|
-
exports.
|
|
35
|
-
exports.
|
|
36
|
-
exports.JUPUSD_VAULT = new web3_js_1.PublicKey("9kGqd5zsQGaFfFPdUuEgbRM4V7x72Jdt7WTS4uRouAQ7");
|
|
37
|
-
exports.JUPUSD_REWARDS_RATE_MODEL = new web3_js_1.PublicKey("E3U32h49TL9Qof3NeLja9qJxTrGYpY1o1NQPtrSLJjcc");
|
|
38
|
-
exports.JUPUSD_LENDING_ADMIN = new web3_js_1.PublicKey("5nmGjA4s7ATzpBQXC5RNceRpaJ7pYw2wKsNBWyuSAZV6");
|
|
39
|
-
const LIQUIDITY = new web3_js_1.PublicKey("7s1da8DduuBFqGra5bJBjpnvL5E9mGzCuMk1Qkh4or2Z");
|
|
40
|
-
const LIQUIDITY_PROGRAM = new web3_js_1.PublicKey("jupeiUmn818Jg1ekPURTpr4mFo29p46vygyykFJ3wZC");
|
|
41
|
-
const TOKEN_PROGRAM = new web3_js_1.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
42
|
-
const ATA_PROGRAM = new web3_js_1.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
|
|
43
|
+
exports.JUPUSD_LENDING = jupiter_lend_1.JUPUSD_POOL.lending;
|
|
44
|
+
exports.JUPUSD_FTOKEN_MINT = jupiter_lend_1.JUPUSD_POOL.fTokenMint;
|
|
45
|
+
exports.JUPUSD_RESERVES_LIQUIDITY = jupiter_lend_1.JUPUSD_POOL.tokenReservesLiquidity;
|
|
46
|
+
exports.JUPUSD_SUPPLY_POS_ON_LIQ = jupiter_lend_1.JUPUSD_POOL.supplyPositionOnLiquidity;
|
|
47
|
+
exports.JUPUSD_RATE_MODEL = jupiter_lend_1.JUPUSD_POOL.rateModel;
|
|
48
|
+
exports.JUPUSD_VAULT = jupiter_lend_1.JUPUSD_POOL.vault;
|
|
49
|
+
exports.JUPUSD_REWARDS_RATE_MODEL = jupiter_lend_1.JUPUSD_POOL.rewardsRateModel;
|
|
50
|
+
exports.JUPUSD_LENDING_ADMIN = jupiter_lend_1.LENDING_ADMIN;
|
|
43
51
|
// ============================================================================
|
|
44
52
|
// Exchange Rate / APR Computation
|
|
45
53
|
// ============================================================================
|
|
@@ -48,14 +56,20 @@ const SECONDS_PER_YEAR = 31536000;
|
|
|
48
56
|
/**
|
|
49
57
|
* Read the earn exchange rate from lending account + rewards model.
|
|
50
58
|
* Returns the rate scaled to 1e12.
|
|
59
|
+
*
|
|
60
|
+
* Jupiter Lend Earn lending account layout (relevant fields):
|
|
61
|
+
* [115..123] baseExchangePrice u64 (1e12 precision)
|
|
62
|
+
* [123..131] lastUpdate u64 (unix seconds)
|
|
63
|
+
*
|
|
64
|
+
* Jupiter Lend rewards rate model layout (relevant fields):
|
|
65
|
+
* [ 56.. 64] startTime u64 (unix seconds)
|
|
66
|
+
* [ 64.. 72] yearlyReward u64 (rewards distributed per year)
|
|
51
67
|
*/
|
|
52
68
|
function computeExchangeRate(lendingData, rewardsModelData, fTokenTotalSupply, currentTimestamp) {
|
|
53
69
|
if (lendingData.length < 131)
|
|
54
70
|
throw new Error("Lending data too short");
|
|
55
|
-
// Base exchange price (offset 115, u64 LE, 1e12 precision)
|
|
56
71
|
const baseRate = (0, buffer_1.readU64)(lendingData, 115).toNumber();
|
|
57
72
|
const lastUpdate = (0, buffer_1.readU64)(lendingData, 123).toNumber();
|
|
58
|
-
// Rewards rate model (offset 56: start_time, 64: yearly_reward)
|
|
59
73
|
if (rewardsModelData.length < 72)
|
|
60
74
|
return BigInt(baseRate);
|
|
61
75
|
const startTime = (0, buffer_1.readU64)(rewardsModelData, 56).toNumber();
|
|
@@ -132,14 +146,15 @@ async function fetchEarnPosition(connection, fTokenAta) {
|
|
|
132
146
|
]);
|
|
133
147
|
if (!ataInfo || !lendingInfo || !rewardsInfo || !mintInfo)
|
|
134
148
|
return null;
|
|
135
|
-
//
|
|
149
|
+
// SPL Token Account layout: [mint(0..32)][owner(32..64)][amount(64..72)]…
|
|
136
150
|
const ataData = ataInfo.data;
|
|
137
151
|
if (ataData.length < 72)
|
|
138
152
|
return null;
|
|
139
153
|
const fTokenBalance = (0, buffer_1.readU64)(ataData, 64);
|
|
140
|
-
//
|
|
154
|
+
// SPL Token Mint layout: [mintAuthority(0..36)][supply(36..44)][decimals(44..45)]…
|
|
141
155
|
const mintData = mintInfo.data;
|
|
142
156
|
const fTokenSupply = (0, buffer_1.readU64)(mintData, 36);
|
|
157
|
+
// baseExchangePrice from Jupiter Lend Earn lending account (offset 115)
|
|
143
158
|
const lendingData = lendingInfo.data;
|
|
144
159
|
const rewardsData = rewardsInfo.data;
|
|
145
160
|
const tokenExchangePrice = BigInt((0, buffer_1.readU64)(lendingData, 115).toString());
|
|
@@ -149,4 +164,3 @@ async function fetchEarnPosition(connection, fTokenAta) {
|
|
|
149
164
|
const apr = computeEarnApr(rewardsData, fTokenSupply, tokenExchangePrice);
|
|
150
165
|
return { fTokenBalance, jupusdValue, apr };
|
|
151
166
|
}
|
|
152
|
-
//# sourceMappingURL=jupusd-earn.js.map
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
|
2
2
|
export declare function findJlpdConfigPda(programId?: PublicKey): [PublicKey, number];
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Derive the per-JlpdConfig `ManagerRole` PDA for JLPD Strategy.
|
|
5
|
+
* Seeds: `["manager", config, manager]`.
|
|
6
|
+
*
|
|
7
|
+
* Note the per-program prefix on the name: each Elemental program has its
|
|
8
|
+
* own `ManagerRole` PDA scoped to a different anchor account (`p-stv-core`
|
|
9
|
+
* → STV, `elemental-lend` → strategy_state).
|
|
10
|
+
*/
|
|
11
|
+
export declare function findJlpdManagerRolePda(config: PublicKey, manager: PublicKey, programId?: PublicKey): [PublicKey, number];
|
|
6
12
|
export declare function findStrategyStatePda(baseMint: PublicKey, programId?: PublicKey): [PublicKey, number];
|
|
7
13
|
export declare function findStvPositionPda(stv: PublicKey, programId?: PublicKey): [PublicKey, number];
|
|
8
|
-
//# sourceMappingURL=pda.d.ts.map
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findJlpVaultPda = void 0;
|
|
4
3
|
exports.findJlpdConfigPda = findJlpdConfigPda;
|
|
5
|
-
exports.
|
|
4
|
+
exports.findJlpdManagerRolePda = findJlpdManagerRolePda;
|
|
6
5
|
exports.findStrategyStatePda = findStrategyStatePda;
|
|
7
6
|
exports.findStvPositionPda = findStvPositionPda;
|
|
8
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
@@ -10,9 +9,15 @@ const constants_1 = require("./constants");
|
|
|
10
9
|
function findJlpdConfigPda(programId = constants_1.PROGRAM_ID) {
|
|
11
10
|
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.CONFIG_SEED], programId);
|
|
12
11
|
}
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Derive the per-JlpdConfig `ManagerRole` PDA for JLPD Strategy.
|
|
14
|
+
* Seeds: `["manager", config, manager]`.
|
|
15
|
+
*
|
|
16
|
+
* Note the per-program prefix on the name: each Elemental program has its
|
|
17
|
+
* own `ManagerRole` PDA scoped to a different anchor account (`p-stv-core`
|
|
18
|
+
* → STV, `elemental-lend` → strategy_state).
|
|
19
|
+
*/
|
|
20
|
+
function findJlpdManagerRolePda(config, manager, programId = constants_1.PROGRAM_ID) {
|
|
16
21
|
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.MANAGER_SEED, config.toBuffer(), manager.toBuffer()], programId);
|
|
17
22
|
}
|
|
18
23
|
function findStrategyStatePda(baseMint, programId = constants_1.PROGRAM_ID) {
|
|
@@ -21,4 +26,3 @@ function findStrategyStatePda(baseMint, programId = constants_1.PROGRAM_ID) {
|
|
|
21
26
|
function findStvPositionPda(stv, programId = constants_1.PROGRAM_ID) {
|
|
22
27
|
return web3_js_1.PublicKey.findProgramAddressSync([constants_1.POSITION_SEED, stv.toBuffer()], programId);
|
|
23
28
|
}
|
|
24
|
-
//# sourceMappingURL=pda.js.map
|
|
@@ -1,54 +1,21 @@
|
|
|
1
1
|
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
/** Arguments
|
|
2
|
+
/** Arguments accepted by `createSettleYieldIx`. */
|
|
3
3
|
export interface CreateSettleYieldIxArgs {
|
|
4
|
-
config: PublicKey;
|
|
5
|
-
managerRole: PublicKey;
|
|
6
|
-
vaultJlpAta: PublicKey;
|
|
7
|
-
stv0: PublicKey;
|
|
8
|
-
stv1: PublicKey;
|
|
9
|
-
stv2: PublicKey;
|
|
10
|
-
stv3: PublicKey;
|
|
11
|
-
stv4: PublicKey;
|
|
12
|
-
dovesBtcUsd: PublicKey;
|
|
13
|
-
dovesEthUsd: PublicKey;
|
|
14
|
-
dovesSolUsd: PublicKey;
|
|
15
|
-
jlpPool: PublicKey;
|
|
16
|
-
jlpMintAccount: PublicKey;
|
|
17
4
|
manager: PublicKey;
|
|
5
|
+
/** 5 base asset mints in order: [BTC, ETH, SOL, USDC, JupUSD]. */
|
|
6
|
+
baseAssetMints: [PublicKey, PublicKey, PublicKey, PublicKey, PublicKey];
|
|
7
|
+
jlpMint?: PublicKey;
|
|
8
|
+
tokenProgram?: PublicKey;
|
|
9
|
+
programId?: PublicKey;
|
|
18
10
|
}
|
|
19
11
|
/**
|
|
20
|
-
* Build
|
|
21
|
-
*
|
|
22
|
-
* settle_yield takes no params -- instruction data is just the 8-byte discriminator.
|
|
23
|
-
*
|
|
24
|
-
* Accounts (14 total):
|
|
25
|
-
* 0: config (JlpdConfig PDA)
|
|
26
|
-
* 1: manager_role (ManagerRole PDA)
|
|
27
|
-
* 2: vault_jlp_ata (JLP ATA owned by config)
|
|
28
|
-
* 3: stv_0 (BTC strategy_state, mut)
|
|
29
|
-
* 4: stv_1 (ETH strategy_state, mut)
|
|
30
|
-
* 5: stv_2 (SOL strategy_state, mut)
|
|
31
|
-
* 6: stv_3 (USDC strategy_state, mut)
|
|
32
|
-
* 7: stv_4 (JupUSD strategy_state, mut)
|
|
33
|
-
* 8: doves_btc_usd (oracle)
|
|
34
|
-
* 9: doves_eth_usd (oracle)
|
|
35
|
-
* 10: doves_sol_usd (oracle)
|
|
36
|
-
* 11: jlp_pool (Jupiter Perps Pool)
|
|
37
|
-
* 12: jlp_mint_account
|
|
38
|
-
* 13: manager (signer)
|
|
39
|
-
*/
|
|
40
|
-
export declare function createSettleYieldIx(args: CreateSettleYieldIxArgs, programId?: PublicKey): TransactionInstruction;
|
|
41
|
-
/**
|
|
42
|
-
* Build a settle_yield instruction with automatic PDA derivation.
|
|
12
|
+
* Build a `settle_yield` instruction with automatic PDA derivation.
|
|
43
13
|
*
|
|
44
14
|
* Requires the 5 base asset mints in order: [BTC, ETH, SOL, USDC, JupUSD].
|
|
45
15
|
* These must match the `base_asset_mints` array on the JlpdConfig account.
|
|
16
|
+
*
|
|
17
|
+
* Naming follows the SDK convention: low-level instruction builders are named
|
|
18
|
+
* `create*Ix` (this is the canonical name); high-level transaction wrappers
|
|
19
|
+
* (if any) are named `build*Transaction`.
|
|
46
20
|
*/
|
|
47
|
-
export declare function
|
|
48
|
-
manager: PublicKey;
|
|
49
|
-
baseAssetMints: [PublicKey, PublicKey, PublicKey, PublicKey, PublicKey];
|
|
50
|
-
jlpMint?: PublicKey;
|
|
51
|
-
tokenProgram?: PublicKey;
|
|
52
|
-
programId?: PublicKey;
|
|
53
|
-
}): TransactionInstruction;
|
|
54
|
-
//# sourceMappingURL=settle-yield.d.ts.map
|
|
21
|
+
export declare function createSettleYieldIx(args: CreateSettleYieldIxArgs): TransactionInstruction;
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSettleYieldIx = createSettleYieldIx;
|
|
4
|
-
exports.buildSettleYieldIx = buildSettleYieldIx;
|
|
5
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
5
|
const spl_token_1 = require("@solana/spl-token");
|
|
7
6
|
const constants_1 = require("./constants");
|
|
8
7
|
const pda_1 = require("./pda");
|
|
8
|
+
const ata_1 = require("../common/ata");
|
|
9
9
|
// ---------------------------------------------------------------------------
|
|
10
|
-
//
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
/** Derive ATA address */
|
|
13
|
-
function findAta(mint, owner, tokenProgram) {
|
|
14
|
-
const [ata] = web3_js_1.PublicKey.findProgramAddressSync([owner.toBuffer(), tokenProgram.toBuffer(), mint.toBuffer()], spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
15
|
-
return ata;
|
|
16
|
-
}
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
// Low-level instruction builder
|
|
10
|
+
// Internal raw builder
|
|
19
11
|
// ---------------------------------------------------------------------------
|
|
20
12
|
/**
|
|
21
|
-
* Build the on-chain `settle_yield` instruction.
|
|
13
|
+
* Build the on-chain `settle_yield` instruction from explicit account inputs.
|
|
22
14
|
*
|
|
23
15
|
* settle_yield takes no params -- instruction data is just the 8-byte discriminator.
|
|
24
16
|
*
|
|
@@ -38,7 +30,7 @@ function findAta(mint, owner, tokenProgram) {
|
|
|
38
30
|
* 12: jlp_mint_account
|
|
39
31
|
* 13: manager (signer)
|
|
40
32
|
*/
|
|
41
|
-
function
|
|
33
|
+
function buildRawSettleYieldIx(args, programId = constants_1.PROGRAM_ID) {
|
|
42
34
|
const { config, managerRole, vaultJlpAta, stv0, stv1, stv2, stv3, stv4, dovesBtcUsd, dovesEthUsd, dovesSolUsd, jlpPool, jlpMintAccount, manager, } = args;
|
|
43
35
|
// Instruction data: just the 8-byte discriminator (no params)
|
|
44
36
|
const data = Buffer.alloc(8);
|
|
@@ -62,19 +54,23 @@ function createSettleYieldIx(args, programId = constants_1.PROGRAM_ID) {
|
|
|
62
54
|
return new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
63
55
|
}
|
|
64
56
|
// ---------------------------------------------------------------------------
|
|
65
|
-
//
|
|
57
|
+
// Public instruction builder
|
|
66
58
|
// ---------------------------------------------------------------------------
|
|
67
59
|
/**
|
|
68
|
-
* Build a settle_yield instruction with automatic PDA derivation.
|
|
60
|
+
* Build a `settle_yield` instruction with automatic PDA derivation.
|
|
69
61
|
*
|
|
70
62
|
* Requires the 5 base asset mints in order: [BTC, ETH, SOL, USDC, JupUSD].
|
|
71
63
|
* These must match the `base_asset_mints` array on the JlpdConfig account.
|
|
64
|
+
*
|
|
65
|
+
* Naming follows the SDK convention: low-level instruction builders are named
|
|
66
|
+
* `create*Ix` (this is the canonical name); high-level transaction wrappers
|
|
67
|
+
* (if any) are named `build*Transaction`.
|
|
72
68
|
*/
|
|
73
|
-
function
|
|
69
|
+
function createSettleYieldIx(args) {
|
|
74
70
|
const { manager, baseAssetMints, jlpMint = constants_1.JLP_MINT, tokenProgram = spl_token_1.TOKEN_PROGRAM_ID, programId = constants_1.PROGRAM_ID, } = args;
|
|
75
71
|
// Derive PDAs
|
|
76
72
|
const [config] = (0, pda_1.findJlpdConfigPda)(programId);
|
|
77
|
-
const [managerRole] = (0, pda_1.
|
|
73
|
+
const [managerRole] = (0, pda_1.findJlpdManagerRolePda)(config, manager, programId);
|
|
78
74
|
// Derive strategy_state PDAs for all 5 base assets
|
|
79
75
|
const [stv0] = (0, pda_1.findStrategyStatePda)(baseAssetMints[0], programId);
|
|
80
76
|
const [stv1] = (0, pda_1.findStrategyStatePda)(baseAssetMints[1], programId);
|
|
@@ -82,8 +78,8 @@ function buildSettleYieldIx(args) {
|
|
|
82
78
|
const [stv3] = (0, pda_1.findStrategyStatePda)(baseAssetMints[3], programId);
|
|
83
79
|
const [stv4] = (0, pda_1.findStrategyStatePda)(baseAssetMints[4], programId);
|
|
84
80
|
// Derive vault JLP ATA (owned by config PDA)
|
|
85
|
-
const vaultJlpAta = findAta(jlpMint, config, tokenProgram);
|
|
86
|
-
return
|
|
81
|
+
const vaultJlpAta = (0, ata_1.findAta)(jlpMint, config, tokenProgram);
|
|
82
|
+
return buildRawSettleYieldIx({
|
|
87
83
|
config,
|
|
88
84
|
managerRole,
|
|
89
85
|
vaultJlpAta,
|
|
@@ -100,4 +96,3 @@ function buildSettleYieldIx(args) {
|
|
|
100
96
|
manager,
|
|
101
97
|
}, programId);
|
|
102
98
|
}
|
|
103
|
-
//# sourceMappingURL=settle-yield.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { PublicKey, TransactionInstruction,
|
|
1
|
+
import { PublicKey, TransactionInstruction, AddressLookupTableAccount, AccountMeta } from "@solana/web3.js";
|
|
2
|
+
import type { SolanaConnection } from "../common/connection";
|
|
2
3
|
import BN from "bn.js";
|
|
3
4
|
/** Direction of the JLP swap */
|
|
4
5
|
export type SwapDirection = "BaseToJlp" | "JlpToBase";
|
|
@@ -97,7 +98,7 @@ export declare function getJupiterSwapInstructions(args: {
|
|
|
97
98
|
* 5. Returns instructions + ALTs for a versioned transaction
|
|
98
99
|
*/
|
|
99
100
|
export declare function buildSwapJlpTransaction(args: {
|
|
100
|
-
connection:
|
|
101
|
+
connection: SolanaConnection;
|
|
101
102
|
manager: PublicKey;
|
|
102
103
|
baseMint: PublicKey;
|
|
103
104
|
direction: SwapDirection;
|
|
@@ -113,7 +114,7 @@ export declare function buildSwapJlpTransaction(args: {
|
|
|
113
114
|
quoteInAmount: bigint;
|
|
114
115
|
}>;
|
|
115
116
|
export interface RebalanceArgs {
|
|
116
|
-
connection:
|
|
117
|
+
connection: SolanaConnection;
|
|
117
118
|
manager: PublicKey;
|
|
118
119
|
baseMint: PublicKey;
|
|
119
120
|
vaultId: number;
|
|
@@ -150,4 +151,3 @@ export interface RebalanceResult {
|
|
|
150
151
|
* For JlpToBase: builds swap_jlp + withdraw_from_strategy in 1 tx.
|
|
151
152
|
*/
|
|
152
153
|
export declare function buildRebalanceTransaction(args: RebalanceArgs): Promise<RebalanceResult>;
|
|
153
|
-
//# sourceMappingURL=swap-jlp.d.ts.map
|