@elemental-stv-core/sdk 0.2.0 → 0.4.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/dist/elemental-lend/index.d.ts +2 -0
- package/dist/elemental-lend/index.d.ts.map +1 -1
- package/dist/elemental-lend/index.js +2 -0
- package/dist/elemental-lend/index.js.map +1 -1
- package/dist/elemental-lend/jupiter-lend.d.ts +4 -0
- package/dist/elemental-lend/jupiter-lend.d.ts.map +1 -1
- package/dist/elemental-lend/jupiter-lend.js +34 -4
- package/dist/elemental-lend/jupiter-lend.js.map +1 -1
- package/dist/elemental-lend/kamino-vault.d.ts +173 -0
- package/dist/elemental-lend/kamino-vault.d.ts.map +1 -0
- package/dist/elemental-lend/kamino-vault.js +460 -0
- package/dist/elemental-lend/kamino-vault.js.map +1 -0
- package/dist/elemental-lend/protocol-actions.d.ts +49 -0
- package/dist/elemental-lend/protocol-actions.d.ts.map +1 -0
- package/dist/elemental-lend/protocol-actions.js +228 -0
- package/dist/elemental-lend/protocol-actions.js.map +1 -0
- package/dist/jlpd-strategy/constants.d.ts +16 -0
- package/dist/jlpd-strategy/constants.d.ts.map +1 -1
- package/dist/jlpd-strategy/constants.js +28 -3
- package/dist/jlpd-strategy/constants.js.map +1 -1
- package/dist/jlpd-strategy/index.d.ts +3 -0
- package/dist/jlpd-strategy/index.d.ts.map +1 -1
- package/dist/jlpd-strategy/index.js +3 -0
- package/dist/jlpd-strategy/index.js.map +1 -1
- package/dist/jlpd-strategy/jlp-data.d.ts +73 -0
- package/dist/jlpd-strategy/jlp-data.d.ts.map +1 -0
- package/dist/jlpd-strategy/jlp-data.js +406 -0
- package/dist/jlpd-strategy/jlp-data.js.map +1 -0
- package/dist/jlpd-strategy/settle-yield.d.ts +54 -0
- package/dist/jlpd-strategy/settle-yield.d.ts.map +1 -0
- package/dist/jlpd-strategy/settle-yield.js +103 -0
- package/dist/jlpd-strategy/settle-yield.js.map +1 -0
- package/dist/jlpd-strategy/swap-jlp.d.ts +153 -0
- package/dist/jlpd-strategy/swap-jlp.d.ts.map +1 -0
- package/dist/jlpd-strategy/swap-jlp.js +465 -0
- package/dist/jlpd-strategy/swap-jlp.js.map +1 -0
- package/dist/p-stv-core/accounts.d.ts.map +1 -1
- package/dist/p-stv-core/accounts.js +14 -10
- package/dist/p-stv-core/accounts.js.map +1 -1
- package/dist/p-stv-core/constants.d.ts +3 -1
- package/dist/p-stv-core/constants.d.ts.map +1 -1
- package/dist/p-stv-core/constants.js +5 -3
- package/dist/p-stv-core/constants.js.map +1 -1
- package/dist/p-stv-core/index.d.ts +4 -0
- package/dist/p-stv-core/index.d.ts.map +1 -1
- package/dist/p-stv-core/index.js +4 -0
- package/dist/p-stv-core/index.js.map +1 -1
- package/dist/p-stv-core/instructions.d.ts +26 -0
- package/dist/p-stv-core/instructions.d.ts.map +1 -1
- package/dist/p-stv-core/instructions.js +37 -6
- package/dist/p-stv-core/instructions.js.map +1 -1
- package/dist/p-stv-core/prices.d.ts +21 -0
- package/dist/p-stv-core/prices.d.ts.map +1 -0
- package/dist/p-stv-core/prices.js +78 -0
- package/dist/p-stv-core/prices.js.map +1 -0
- package/dist/p-stv-core/remaining-accounts.d.ts +99 -0
- package/dist/p-stv-core/remaining-accounts.d.ts.map +1 -0
- package/dist/p-stv-core/remaining-accounts.js +262 -0
- package/dist/p-stv-core/remaining-accounts.js.map +1 -0
- package/dist/p-stv-core/send-tx.d.ts +56 -0
- package/dist/p-stv-core/send-tx.d.ts.map +1 -0
- package/dist/p-stv-core/send-tx.js +299 -0
- package/dist/p-stv-core/send-tx.js.map +1 -0
- package/dist/p-stv-core/sol-wrap.d.ts +35 -0
- package/dist/p-stv-core/sol-wrap.d.ts.map +1 -0
- package/dist/p-stv-core/sol-wrap.js +95 -0
- package/dist/p-stv-core/sol-wrap.js.map +1 -0
- package/dist/p-stv-core/types.d.ts +16 -1
- package/dist/p-stv-core/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { PublicKey, TransactionInstruction, Connection, AddressLookupTableAccount, AccountMeta } from "@solana/web3.js";
|
|
2
|
+
import BN from "bn.js";
|
|
3
|
+
/** Direction of the JLP swap */
|
|
4
|
+
export type SwapDirection = "BaseToJlp" | "JlpToBase";
|
|
5
|
+
/** Arguments for building a swap_jlp instruction */
|
|
6
|
+
export interface CreateSwapJlpIxArgs {
|
|
7
|
+
manager: PublicKey;
|
|
8
|
+
config: PublicKey;
|
|
9
|
+
managerRole: PublicKey;
|
|
10
|
+
strategyState: PublicKey;
|
|
11
|
+
strategyBaseAta: PublicKey;
|
|
12
|
+
strategyJlpAta: PublicKey;
|
|
13
|
+
vaultJlpAta: PublicKey;
|
|
14
|
+
baseMint: PublicKey;
|
|
15
|
+
jlpMint: PublicKey;
|
|
16
|
+
tokenProgram: PublicKey;
|
|
17
|
+
jupiterProgram: PublicKey;
|
|
18
|
+
direction: SwapDirection;
|
|
19
|
+
amount: bigint | BN;
|
|
20
|
+
minOut: bigint | BN;
|
|
21
|
+
jupiterData: Buffer | Uint8Array;
|
|
22
|
+
remainingAccounts?: AccountMeta[];
|
|
23
|
+
}
|
|
24
|
+
/** Jupiter swap quote response */
|
|
25
|
+
export interface JupiterQuote {
|
|
26
|
+
inputMint: string;
|
|
27
|
+
inAmount: string;
|
|
28
|
+
outputMint: string;
|
|
29
|
+
outAmount: string;
|
|
30
|
+
otherAmountThreshold: string;
|
|
31
|
+
swapMode: string;
|
|
32
|
+
slippageBps: number;
|
|
33
|
+
priceImpactPct: string;
|
|
34
|
+
routePlan: unknown[];
|
|
35
|
+
contextSlot?: number;
|
|
36
|
+
timeTaken?: number;
|
|
37
|
+
}
|
|
38
|
+
/** Parsed Jupiter swap instruction from the API */
|
|
39
|
+
export interface JupiterSwapInstruction {
|
|
40
|
+
programId: string;
|
|
41
|
+
data: string;
|
|
42
|
+
accounts: {
|
|
43
|
+
pubkey: string;
|
|
44
|
+
isSigner: boolean;
|
|
45
|
+
isWritable: boolean;
|
|
46
|
+
}[];
|
|
47
|
+
}
|
|
48
|
+
/** Jupiter swap-instructions API response */
|
|
49
|
+
export interface JupiterSwapInstructionsResponse {
|
|
50
|
+
tokenLedgerInstruction: JupiterSwapInstruction | null;
|
|
51
|
+
computeBudgetInstructions: JupiterSwapInstruction[];
|
|
52
|
+
setupInstructions: JupiterSwapInstruction[];
|
|
53
|
+
swapInstruction: JupiterSwapInstruction;
|
|
54
|
+
cleanupInstruction: JupiterSwapInstruction | null;
|
|
55
|
+
addressLookupTableAddresses: string[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Build the on-chain `swap_jlp` instruction.
|
|
59
|
+
*
|
|
60
|
+
* Instruction data layout (Anchor Borsh):
|
|
61
|
+
* [8-byte disc, 1-byte direction, 8-byte amount (LE), 8-byte min_out (LE),
|
|
62
|
+
* 4-byte jupiter_data_len (LE), ...jupiter_data_bytes]
|
|
63
|
+
*/
|
|
64
|
+
export declare function createSwapJlpIx(args: CreateSwapJlpIxArgs, programId?: PublicKey): TransactionInstruction;
|
|
65
|
+
/**
|
|
66
|
+
* Fetch a swap quote from Jupiter's v1 quote API.
|
|
67
|
+
*/
|
|
68
|
+
export declare function getJupiterSwapQuote(args: {
|
|
69
|
+
inputMint: PublicKey;
|
|
70
|
+
outputMint: PublicKey;
|
|
71
|
+
amount: number | bigint;
|
|
72
|
+
slippageBps?: number;
|
|
73
|
+
maxAccounts?: number;
|
|
74
|
+
}): Promise<JupiterQuote>;
|
|
75
|
+
/**
|
|
76
|
+
* Fetch swap instructions from Jupiter's v1 swap-instructions API.
|
|
77
|
+
*
|
|
78
|
+
* @param quoteResponse The quote from getJupiterSwapQuote
|
|
79
|
+
* @param userPublicKey The account that signs the swap -- for JLPD this is the strategy_state PDA
|
|
80
|
+
*/
|
|
81
|
+
export declare function getJupiterSwapInstructions(args: {
|
|
82
|
+
quoteResponse: JupiterQuote;
|
|
83
|
+
userPublicKey: PublicKey;
|
|
84
|
+
}): Promise<{
|
|
85
|
+
swapInstructionData: Buffer;
|
|
86
|
+
remainingAccounts: AccountMeta[];
|
|
87
|
+
addressLookupTableAddresses: string[];
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Build a complete swap_jlp transaction with Jupiter quote + instructions + ALTs.
|
|
91
|
+
*
|
|
92
|
+
* This is the main function the frontend calls. It:
|
|
93
|
+
* 1. Derives all PDAs (config, manager_role, strategy_state, ATAs)
|
|
94
|
+
* 2. Gets Jupiter quote
|
|
95
|
+
* 3. Gets Jupiter swap instructions
|
|
96
|
+
* 4. Builds the swap_jlp instruction with remaining accounts
|
|
97
|
+
* 5. Returns instructions + ALTs for a versioned transaction
|
|
98
|
+
*/
|
|
99
|
+
export declare function buildSwapJlpTransaction(args: {
|
|
100
|
+
connection: Connection;
|
|
101
|
+
manager: PublicKey;
|
|
102
|
+
baseMint: PublicKey;
|
|
103
|
+
direction: SwapDirection;
|
|
104
|
+
amount: bigint;
|
|
105
|
+
slippageBps?: number;
|
|
106
|
+
jlpMint?: PublicKey;
|
|
107
|
+
tokenProgram?: PublicKey;
|
|
108
|
+
programId?: PublicKey;
|
|
109
|
+
}): Promise<{
|
|
110
|
+
instructions: TransactionInstruction[];
|
|
111
|
+
addressLookupTables: AddressLookupTableAccount[];
|
|
112
|
+
/** Actual input amount from Jupiter quote (may differ from requested amount) */
|
|
113
|
+
quoteInAmount: bigint;
|
|
114
|
+
}>;
|
|
115
|
+
export interface RebalanceArgs {
|
|
116
|
+
connection: Connection;
|
|
117
|
+
manager: PublicKey;
|
|
118
|
+
baseMint: PublicKey;
|
|
119
|
+
vaultId: number;
|
|
120
|
+
direction: SwapDirection;
|
|
121
|
+
/** Base amount (BaseToJlp) or JLP amount (JlpToBase) */
|
|
122
|
+
amount: bigint;
|
|
123
|
+
slippageBps?: number;
|
|
124
|
+
/** Pass from frontend to skip RPC balance lookups */
|
|
125
|
+
liquidity?: {
|
|
126
|
+
strategyAtaBalance: bigint;
|
|
127
|
+
vaultAtaBalance: bigint;
|
|
128
|
+
};
|
|
129
|
+
jlpMint?: PublicKey;
|
|
130
|
+
tokenProgram?: PublicKey;
|
|
131
|
+
programId?: PublicKey;
|
|
132
|
+
pStvProgramId?: PublicKey;
|
|
133
|
+
}
|
|
134
|
+
export interface RebalanceResult {
|
|
135
|
+
/** Tx 1 instructions (deposit_to_strategy pre-fill, or empty) */
|
|
136
|
+
preInstructions: TransactionInstruction[];
|
|
137
|
+
/** Tx 2 instructions (swap_jlp, optionally + withdraw_from_strategy) */
|
|
138
|
+
instructions: TransactionInstruction[];
|
|
139
|
+
/** Tx 3 instructions (post-sweep route to Jupiter Lend, or empty) */
|
|
140
|
+
postInstructions: TransactionInstruction[];
|
|
141
|
+
addressLookupTables: AddressLookupTableAccount[];
|
|
142
|
+
routeDescription: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Build a complete rebalance transaction set for JLPD strategy.
|
|
146
|
+
*
|
|
147
|
+
* For BaseToJlp: auto-detects liquidity location and builds
|
|
148
|
+
* deposit_to_strategy + swap_jlp (tries 1 tx, falls back to 2 if needed).
|
|
149
|
+
*
|
|
150
|
+
* For JlpToBase: builds swap_jlp + withdraw_from_strategy in 1 tx.
|
|
151
|
+
*/
|
|
152
|
+
export declare function buildRebalanceTransaction(args: RebalanceArgs): Promise<RebalanceResult>;
|
|
153
|
+
//# sourceMappingURL=swap-jlp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap-jlp.d.ts","sourceRoot":"","sources":["../../src/jlpd-strategy/swap-jlp.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,UAAU,EACV,yBAAyB,EACzB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,MAAM,OAAO,CAAC;AAqDvB,gCAAgC;AAChC,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,CAAC;AAEtD,oDAAoD;AACpD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,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,OAAO,CAAC;IACV,YAAY,EAAE,sBAAsB,EAAE,CAAC;IACvC,mBAAmB,EAAE,yBAAyB,EAAE,CAAC;IACjD,gFAAgF;IAChF,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC,CA6ED;AAMD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,SAAS,CAAC,EAAE;QACV,kBAAkB,EAAE,MAAM,CAAC;QAC3B,eAAe,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,eAAe,EAAE,sBAAsB,EAAE,CAAC;IAC1C,wEAAwE;IACxE,YAAY,EAAE,sBAAsB,EAAE,CAAC;IACvC,qEAAqE;IACrE,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;IAC3C,mBAAmB,EAAE,yBAAyB,EAAE,CAAC;IACjD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,eAAe,CAAC,CA2B1B"}
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createSwapJlpIx = createSwapJlpIx;
|
|
7
|
+
exports.getJupiterSwapQuote = getJupiterSwapQuote;
|
|
8
|
+
exports.getJupiterSwapInstructions = getJupiterSwapInstructions;
|
|
9
|
+
exports.buildSwapJlpTransaction = buildSwapJlpTransaction;
|
|
10
|
+
exports.buildRebalanceTransaction = buildRebalanceTransaction;
|
|
11
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
12
|
+
const spl_token_1 = require("@solana/spl-token");
|
|
13
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
const pda_1 = require("./pda");
|
|
16
|
+
const accounts_1 = require("./accounts");
|
|
17
|
+
const pda_2 = require("../p-stv-core/pda");
|
|
18
|
+
const instructions_1 = require("../p-stv-core/instructions");
|
|
19
|
+
const remaining_accounts_1 = require("../p-stv-core/remaining-accounts");
|
|
20
|
+
const accounts_2 = require("../p-stv-core/accounts");
|
|
21
|
+
const constants_2 = require("../p-stv-core/constants");
|
|
22
|
+
const pda_3 = require("../elemental-lend/pda");
|
|
23
|
+
const jupiter_lend_1 = require("../elemental-lend/jupiter-lend");
|
|
24
|
+
const instructions_2 = require("../elemental-lend/instructions");
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Helpers
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
const JUPITER_API_BASE = "https://api.jup.ag/swap/v1";
|
|
29
|
+
/** Derive ATA address (same logic as @solana/spl-token getAssociatedTokenAddressSync) */
|
|
30
|
+
function findAta(mint, owner, tokenProgram) {
|
|
31
|
+
const [ata] = web3_js_1.PublicKey.findProgramAddressSync([owner.toBuffer(), tokenProgram.toBuffer(), mint.toBuffer()], spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
32
|
+
return ata;
|
|
33
|
+
}
|
|
34
|
+
function toBigInt(v) {
|
|
35
|
+
if (typeof v === "bigint")
|
|
36
|
+
return v;
|
|
37
|
+
return BigInt(v.toString());
|
|
38
|
+
}
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// Low-level instruction builder
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
/**
|
|
43
|
+
* Build the on-chain `swap_jlp` instruction.
|
|
44
|
+
*
|
|
45
|
+
* Instruction data layout (Anchor Borsh):
|
|
46
|
+
* [8-byte disc, 1-byte direction, 8-byte amount (LE), 8-byte min_out (LE),
|
|
47
|
+
* 4-byte jupiter_data_len (LE), ...jupiter_data_bytes]
|
|
48
|
+
*/
|
|
49
|
+
function createSwapJlpIx(args, programId = constants_1.PROGRAM_ID) {
|
|
50
|
+
const { manager, config, managerRole, strategyState, strategyBaseAta, strategyJlpAta, vaultJlpAta, baseMint, jlpMint, tokenProgram, jupiterProgram, direction, amount, minOut, jupiterData, remainingAccounts = [], } = args;
|
|
51
|
+
const amountBi = toBigInt(amount);
|
|
52
|
+
const minOutBi = toBigInt(minOut);
|
|
53
|
+
// Serialize instruction data
|
|
54
|
+
const jupBytes = Buffer.from(jupiterData);
|
|
55
|
+
const dataLen = 8 + 1 + 8 + 8 + 4 + jupBytes.length;
|
|
56
|
+
const data = Buffer.alloc(dataLen);
|
|
57
|
+
// Discriminator
|
|
58
|
+
constants_1.IX_SWAP_JLP.copy(data, 0);
|
|
59
|
+
// Direction (1 byte)
|
|
60
|
+
data.writeUInt8(direction === "BaseToJlp" ? 0 : 1, 8);
|
|
61
|
+
// Amount (u64 LE)
|
|
62
|
+
data.writeBigUInt64LE(amountBi, 9);
|
|
63
|
+
// MinOut (u64 LE)
|
|
64
|
+
data.writeBigUInt64LE(minOutBi, 17);
|
|
65
|
+
// Jupiter data length (u32 LE) + bytes
|
|
66
|
+
data.writeUInt32LE(jupBytes.length, 25);
|
|
67
|
+
jupBytes.copy(data, 29);
|
|
68
|
+
const keys = [
|
|
69
|
+
{ pubkey: manager, isSigner: true, isWritable: false },
|
|
70
|
+
{ pubkey: config, isSigner: false, isWritable: false },
|
|
71
|
+
{ pubkey: managerRole, isSigner: false, isWritable: false },
|
|
72
|
+
{ pubkey: strategyState, isSigner: false, isWritable: true },
|
|
73
|
+
{ pubkey: strategyBaseAta, isSigner: false, isWritable: true },
|
|
74
|
+
{ pubkey: strategyJlpAta, isSigner: false, isWritable: true },
|
|
75
|
+
{ pubkey: vaultJlpAta, isSigner: false, isWritable: true },
|
|
76
|
+
{ pubkey: baseMint, isSigner: false, isWritable: false },
|
|
77
|
+
{ pubkey: jlpMint, isSigner: false, isWritable: false },
|
|
78
|
+
{ pubkey: tokenProgram, isSigner: false, isWritable: false },
|
|
79
|
+
{ pubkey: jupiterProgram, isSigner: false, isWritable: false },
|
|
80
|
+
...remainingAccounts,
|
|
81
|
+
];
|
|
82
|
+
return new web3_js_1.TransactionInstruction({ keys, programId, data });
|
|
83
|
+
}
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// Jupiter API helpers
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
/**
|
|
88
|
+
* Fetch a swap quote from Jupiter's v1 quote API.
|
|
89
|
+
*/
|
|
90
|
+
async function getJupiterSwapQuote(args) {
|
|
91
|
+
const { inputMint, outputMint, amount, slippageBps = 50, maxAccounts = 40 } = args;
|
|
92
|
+
const apiKey = process.env.NEXT_PUBLIC_JUPITER_API_KEY;
|
|
93
|
+
const params = new URLSearchParams({
|
|
94
|
+
inputMint: inputMint.toBase58(),
|
|
95
|
+
outputMint: outputMint.toBase58(),
|
|
96
|
+
amount: amount.toString(),
|
|
97
|
+
slippageBps: slippageBps.toString(),
|
|
98
|
+
maxAccounts: maxAccounts.toString(),
|
|
99
|
+
});
|
|
100
|
+
const url = `${JUPITER_API_BASE}/quote?${params.toString()}`;
|
|
101
|
+
const headers = {};
|
|
102
|
+
if (apiKey) {
|
|
103
|
+
headers["x-api-key"] = apiKey;
|
|
104
|
+
}
|
|
105
|
+
const response = await fetch(url, { headers });
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
const text = await response.text();
|
|
108
|
+
throw new Error(`Jupiter quote API error (${response.status}): ${text}`);
|
|
109
|
+
}
|
|
110
|
+
const data = (await response.json());
|
|
111
|
+
if (data.error) {
|
|
112
|
+
throw new Error(`Jupiter quote error: ${data.error}`);
|
|
113
|
+
}
|
|
114
|
+
return data;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Fetch swap instructions from Jupiter's v1 swap-instructions API.
|
|
118
|
+
*
|
|
119
|
+
* @param quoteResponse The quote from getJupiterSwapQuote
|
|
120
|
+
* @param userPublicKey The account that signs the swap -- for JLPD this is the strategy_state PDA
|
|
121
|
+
*/
|
|
122
|
+
async function getJupiterSwapInstructions(args) {
|
|
123
|
+
const { quoteResponse, userPublicKey } = args;
|
|
124
|
+
const apiKey = process.env.NEXT_PUBLIC_JUPITER_API_KEY;
|
|
125
|
+
const url = `${JUPITER_API_BASE}/swap-instructions`;
|
|
126
|
+
const body = {
|
|
127
|
+
quoteResponse,
|
|
128
|
+
userPublicKey: userPublicKey.toBase58(),
|
|
129
|
+
wrapAndUnwrapSol: false,
|
|
130
|
+
dynamicComputeUnitLimit: true,
|
|
131
|
+
skipUserAccountsRpcCalls: true,
|
|
132
|
+
};
|
|
133
|
+
const headers = {
|
|
134
|
+
"Content-Type": "application/json",
|
|
135
|
+
};
|
|
136
|
+
if (apiKey) {
|
|
137
|
+
headers["x-api-key"] = apiKey;
|
|
138
|
+
}
|
|
139
|
+
const response = await fetch(url, {
|
|
140
|
+
method: "POST",
|
|
141
|
+
headers,
|
|
142
|
+
body: JSON.stringify(body),
|
|
143
|
+
});
|
|
144
|
+
if (!response.ok) {
|
|
145
|
+
const text = await response.text();
|
|
146
|
+
throw new Error(`Jupiter swap-instructions API error (${response.status}): ${text}`);
|
|
147
|
+
}
|
|
148
|
+
const data = (await response.json());
|
|
149
|
+
if (data.error) {
|
|
150
|
+
throw new Error(`Jupiter swap-instructions error: ${data.error}`);
|
|
151
|
+
}
|
|
152
|
+
// Extract the raw instruction data (base64 encoded) from the swap instruction
|
|
153
|
+
const swapIx = data.swapInstruction;
|
|
154
|
+
const swapInstructionData = Buffer.from(swapIx.data, "base64");
|
|
155
|
+
// Build remaining accounts from the swap instruction's accounts
|
|
156
|
+
// All signers become non-signers for CPI (the strategy PDA signs via seeds)
|
|
157
|
+
const remainingAccounts = swapIx.accounts.map((acc) => ({
|
|
158
|
+
pubkey: new web3_js_1.PublicKey(acc.pubkey),
|
|
159
|
+
isSigner: false,
|
|
160
|
+
isWritable: acc.isWritable,
|
|
161
|
+
}));
|
|
162
|
+
return {
|
|
163
|
+
swapInstructionData,
|
|
164
|
+
remainingAccounts,
|
|
165
|
+
addressLookupTableAddresses: data.addressLookupTableAddresses,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Fetch Address Lookup Tables from the chain.
|
|
170
|
+
*/
|
|
171
|
+
async function fetchAddressLookupTables(connection, addresses) {
|
|
172
|
+
if (addresses.length === 0)
|
|
173
|
+
return [];
|
|
174
|
+
const pubkeys = addresses.map((addr) => new web3_js_1.PublicKey(addr));
|
|
175
|
+
const accountInfos = await connection.getMultipleAccountsInfo(pubkeys);
|
|
176
|
+
const tables = [];
|
|
177
|
+
for (let i = 0; i < accountInfos.length; i++) {
|
|
178
|
+
const info = accountInfos[i];
|
|
179
|
+
if (!info) {
|
|
180
|
+
console.warn(`ALT not found: ${addresses[i]}`);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
tables.push(new web3_js_1.AddressLookupTableAccount({
|
|
184
|
+
key: pubkeys[i],
|
|
185
|
+
state: web3_js_1.AddressLookupTableAccount.deserialize(info.data),
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
return tables;
|
|
189
|
+
}
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
// High-level builder
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
/**
|
|
194
|
+
* Build a complete swap_jlp transaction with Jupiter quote + instructions + ALTs.
|
|
195
|
+
*
|
|
196
|
+
* This is the main function the frontend calls. It:
|
|
197
|
+
* 1. Derives all PDAs (config, manager_role, strategy_state, ATAs)
|
|
198
|
+
* 2. Gets Jupiter quote
|
|
199
|
+
* 3. Gets Jupiter swap instructions
|
|
200
|
+
* 4. Builds the swap_jlp instruction with remaining accounts
|
|
201
|
+
* 5. Returns instructions + ALTs for a versioned transaction
|
|
202
|
+
*/
|
|
203
|
+
async function buildSwapJlpTransaction(args) {
|
|
204
|
+
const { connection, manager, baseMint, direction, amount, slippageBps = 50, jlpMint = constants_1.JLP_MINT, tokenProgram = spl_token_1.TOKEN_PROGRAM_ID, programId = constants_1.PROGRAM_ID, } = args;
|
|
205
|
+
// 1. Derive PDAs
|
|
206
|
+
const [config] = (0, pda_1.findJlpdConfigPda)(programId);
|
|
207
|
+
const [managerRole] = (0, pda_1.findManagerRolePda)(config, manager, programId);
|
|
208
|
+
const [strategyState] = (0, pda_1.findStrategyStatePda)(baseMint, programId);
|
|
209
|
+
// Derive ATAs
|
|
210
|
+
const strategyBaseAta = findAta(baseMint, strategyState, tokenProgram);
|
|
211
|
+
const strategyJlpAta = findAta(jlpMint, strategyState, tokenProgram);
|
|
212
|
+
const vaultJlpAta = findAta(jlpMint, config, tokenProgram);
|
|
213
|
+
// 2. Determine input/output mints for the Jupiter quote
|
|
214
|
+
const inputMint = direction === "BaseToJlp" ? baseMint : jlpMint;
|
|
215
|
+
const outputMint = direction === "BaseToJlp" ? jlpMint : baseMint;
|
|
216
|
+
// 3. Get Jupiter quote
|
|
217
|
+
const quote = await getJupiterSwapQuote({
|
|
218
|
+
inputMint,
|
|
219
|
+
outputMint,
|
|
220
|
+
amount,
|
|
221
|
+
slippageBps,
|
|
222
|
+
});
|
|
223
|
+
// 4. Get Jupiter swap instructions (strategy_state PDA signs via CPI)
|
|
224
|
+
const jupSwap = await getJupiterSwapInstructions({
|
|
225
|
+
quoteResponse: quote,
|
|
226
|
+
userPublicKey: strategyState,
|
|
227
|
+
});
|
|
228
|
+
// 5. Build the swap_jlp instruction
|
|
229
|
+
const minOut = BigInt(quote.otherAmountThreshold);
|
|
230
|
+
const swapJlpIx = createSwapJlpIx({
|
|
231
|
+
manager,
|
|
232
|
+
config,
|
|
233
|
+
managerRole,
|
|
234
|
+
strategyState,
|
|
235
|
+
strategyBaseAta,
|
|
236
|
+
strategyJlpAta,
|
|
237
|
+
vaultJlpAta,
|
|
238
|
+
baseMint,
|
|
239
|
+
jlpMint,
|
|
240
|
+
tokenProgram,
|
|
241
|
+
jupiterProgram: constants_1.JUPITER_PROGRAM,
|
|
242
|
+
direction,
|
|
243
|
+
amount,
|
|
244
|
+
minOut,
|
|
245
|
+
jupiterData: jupSwap.swapInstructionData,
|
|
246
|
+
remainingAccounts: jupSwap.remainingAccounts,
|
|
247
|
+
}, programId);
|
|
248
|
+
// 6. Fetch ALTs
|
|
249
|
+
const addressLookupTables = await fetchAddressLookupTables(connection, jupSwap.addressLookupTableAddresses);
|
|
250
|
+
return {
|
|
251
|
+
instructions: [swapJlpIx],
|
|
252
|
+
addressLookupTables,
|
|
253
|
+
quoteInAmount: BigInt(quote.inAmount),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Build a complete rebalance transaction set for JLPD strategy.
|
|
258
|
+
*
|
|
259
|
+
* For BaseToJlp: auto-detects liquidity location and builds
|
|
260
|
+
* deposit_to_strategy + swap_jlp (tries 1 tx, falls back to 2 if needed).
|
|
261
|
+
*
|
|
262
|
+
* For JlpToBase: builds swap_jlp + withdraw_from_strategy in 1 tx.
|
|
263
|
+
*/
|
|
264
|
+
async function buildRebalanceTransaction(args) {
|
|
265
|
+
const { connection, manager, baseMint, vaultId, direction, amount, slippageBps = 50, jlpMint = constants_1.JLP_MINT, tokenProgram = spl_token_1.TOKEN_PROGRAM_ID, programId = constants_1.PROGRAM_ID, pStvProgramId = constants_2.PROGRAM_ID, } = args;
|
|
266
|
+
if (direction === "BaseToJlp") {
|
|
267
|
+
return buildBaseToJlpRebalance({
|
|
268
|
+
connection, manager, baseMint, vaultId, amount, slippageBps,
|
|
269
|
+
jlpMint, tokenProgram, programId, pStvProgramId,
|
|
270
|
+
liquidity: args.liquidity,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
return buildJlpToBaseRebalance({
|
|
275
|
+
connection, manager, baseMint, vaultId, amount, slippageBps,
|
|
276
|
+
jlpMint, tokenProgram, programId, pStvProgramId,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// ---------------------------------------------------------------------------
|
|
281
|
+
// BaseToJlp: deposit_to_strategy (if needed) + swap_jlp
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
async function buildBaseToJlpRebalance(args) {
|
|
284
|
+
const { connection, manager, baseMint, vaultId, amount, slippageBps, jlpMint, tokenProgram, programId, pStvProgramId, liquidity, } = args;
|
|
285
|
+
// Derive JLPD PDAs
|
|
286
|
+
const [strategyState] = (0, pda_1.findStrategyStatePda)(baseMint, programId);
|
|
287
|
+
const strategyBaseAta = findAta(baseMint, strategyState, tokenProgram);
|
|
288
|
+
// Check if strategy_base_ata already has enough
|
|
289
|
+
let strategyBalance = liquidity?.strategyAtaBalance ?? 0n;
|
|
290
|
+
if (!liquidity) {
|
|
291
|
+
try {
|
|
292
|
+
const info = await connection.getAccountInfo(strategyBaseAta);
|
|
293
|
+
if (info && info.data.length >= 72 && info.owner.equals(tokenProgram)) {
|
|
294
|
+
strategyBalance = Buffer.from(info.data).readBigUInt64LE(64);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
// Default to 0 — will try deposit
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// Build the swap_jlp instruction (Jupiter quotes the exact inAmount)
|
|
302
|
+
const { instructions: swapIxs, addressLookupTables, quoteInAmount } = await buildSwapJlpTransaction({
|
|
303
|
+
connection, manager, baseMint, direction: "BaseToJlp",
|
|
304
|
+
amount, slippageBps, jlpMint, tokenProgram, programId,
|
|
305
|
+
});
|
|
306
|
+
if (strategyBalance >= quoteInAmount) {
|
|
307
|
+
// Path 1: strategy_base_ata has enough — just swap
|
|
308
|
+
return {
|
|
309
|
+
preInstructions: [],
|
|
310
|
+
instructions: swapIxs,
|
|
311
|
+
postInstructions: [],
|
|
312
|
+
addressLookupTables,
|
|
313
|
+
routeDescription: "Direct swap (strategy has funds)",
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
// Path 2/3: Need to deposit_to_strategy first (auto-unsweep from lend)
|
|
317
|
+
// Use quoteInAmount (what Jupiter will actually consume) instead of the
|
|
318
|
+
// user's requested amount, to avoid leaving dust in the strategy ATA.
|
|
319
|
+
const deficit = quoteInAmount - strategyBalance;
|
|
320
|
+
// Fetch STV on-chain for lend info
|
|
321
|
+
const stv = await (0, accounts_2.fetchStv)(connection, vaultId, pStvProgramId);
|
|
322
|
+
const [stvAddress] = (0, pda_2.findStvPda)(vaultId, pStvProgramId);
|
|
323
|
+
const [stvManagerRole] = (0, pda_2.findManagerRolePda)(stvAddress, manager, pStvProgramId);
|
|
324
|
+
// Build deposit_to_strategy remaining accounts (lend + auto-unroute)
|
|
325
|
+
const vaultInfo = {
|
|
326
|
+
address: stvAddress,
|
|
327
|
+
baseMint,
|
|
328
|
+
lendProgram: stv.lendProgram,
|
|
329
|
+
strategies: stv.strategies,
|
|
330
|
+
strategyCount: stv.strategyCount,
|
|
331
|
+
};
|
|
332
|
+
const depositCtx = await (0, remaining_accounts_1.buildDepositToStrategyContext)(connection, vaultInfo);
|
|
333
|
+
// Derive the JLPD strategy's position PDA in p-STV Core
|
|
334
|
+
const [jlpdStvPosition] = (0, pda_1.findStvPositionPda)(stvAddress, programId);
|
|
335
|
+
const vaultAta = findAta(baseMint, stvAddress, tokenProgram);
|
|
336
|
+
const depositIx = (0, instructions_1.createDepositToStrategyIx)({
|
|
337
|
+
manager,
|
|
338
|
+
managerRole: stvManagerRole,
|
|
339
|
+
stv: stvAddress,
|
|
340
|
+
vaultAta,
|
|
341
|
+
baseMint,
|
|
342
|
+
strategyProgram: programId,
|
|
343
|
+
strategyState,
|
|
344
|
+
stvPosition: jlpdStvPosition,
|
|
345
|
+
strategyBaseAta,
|
|
346
|
+
tokenProgram,
|
|
347
|
+
amount: new bn_js_1.default(deficit.toString()),
|
|
348
|
+
minShares: new bn_js_1.default(0),
|
|
349
|
+
autoUnrouteCount: depositCtx.autoUnrouteCount,
|
|
350
|
+
remainingAccounts: depositCtx.remainingAccounts,
|
|
351
|
+
}, pStvProgramId);
|
|
352
|
+
const allPreIxs = [...depositCtx.preInstructions, depositIx];
|
|
353
|
+
return {
|
|
354
|
+
preInstructions: allPreIxs,
|
|
355
|
+
instructions: swapIxs,
|
|
356
|
+
postInstructions: [],
|
|
357
|
+
addressLookupTables,
|
|
358
|
+
routeDescription: depositCtx.autoUnrouteCount > 0
|
|
359
|
+
? "Unsweep from lend → deposit to strategy → swap"
|
|
360
|
+
: "Deposit to strategy → swap",
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
// ---------------------------------------------------------------------------
|
|
364
|
+
// JlpToBase: swap_jlp + withdraw_from_strategy
|
|
365
|
+
// ---------------------------------------------------------------------------
|
|
366
|
+
async function buildJlpToBaseRebalance(args) {
|
|
367
|
+
const { connection, manager, baseMint, vaultId, amount, slippageBps, jlpMint, tokenProgram, programId, pStvProgramId, } = args;
|
|
368
|
+
// Build the swap_jlp instruction (JLP → base)
|
|
369
|
+
const { instructions: swapIxs, addressLookupTables } = await buildSwapJlpTransaction({
|
|
370
|
+
connection, manager, baseMint, direction: "JlpToBase",
|
|
371
|
+
amount, slippageBps, jlpMint, tokenProgram, programId,
|
|
372
|
+
});
|
|
373
|
+
// Read JLPD strategy state to get PPS for share calculation
|
|
374
|
+
const [strategyState] = (0, pda_1.findStrategyStatePda)(baseMint, programId);
|
|
375
|
+
const [stvAddress] = (0, pda_2.findStvPda)(vaultId, pStvProgramId);
|
|
376
|
+
const [stratState, position, stv] = await Promise.all([
|
|
377
|
+
(0, accounts_1.fetchJlpStrategyState)(connection, baseMint, programId),
|
|
378
|
+
(0, accounts_1.fetchJlpStvPosition)(connection, stvAddress, programId),
|
|
379
|
+
(0, accounts_2.fetchStv)(connection, vaultId, pStvProgramId),
|
|
380
|
+
]);
|
|
381
|
+
// Use the Jupiter quote's min output to compute shares to withdraw
|
|
382
|
+
// The swap_jlp ix data: [8 disc, 1 dir, 8 amount, 8 minOut, ...]
|
|
383
|
+
const swapIxData = swapIxs[0].data;
|
|
384
|
+
const minBaseOut = swapIxData.readBigUInt64LE(17);
|
|
385
|
+
// shares = ceil(minBaseOut * PPS_DECIMALS / pps), capped at position balance
|
|
386
|
+
const pps = BigInt(stratState.pps.toString());
|
|
387
|
+
const ppsDecimals = BigInt(constants_1.PPS_DECIMALS);
|
|
388
|
+
let sharesToWithdraw = (minBaseOut * ppsDecimals + pps - 1n) / pps;
|
|
389
|
+
const positionShares = BigInt(position.shares.toString());
|
|
390
|
+
if (sharesToWithdraw > positionShares) {
|
|
391
|
+
sharesToWithdraw = positionShares;
|
|
392
|
+
}
|
|
393
|
+
// Build withdraw_from_strategy
|
|
394
|
+
const [stvManagerRole] = (0, pda_2.findManagerRolePda)(stvAddress, manager, pStvProgramId);
|
|
395
|
+
const [jlpdStvPosition] = (0, pda_1.findStvPositionPda)(stvAddress, programId);
|
|
396
|
+
const strategyBaseAta = findAta(baseMint, strategyState, tokenProgram);
|
|
397
|
+
const vaultAta = findAta(baseMint, stvAddress, tokenProgram);
|
|
398
|
+
// Build lend remaining_accounts for auto-sweep after withdraw
|
|
399
|
+
const lendAccounts = [];
|
|
400
|
+
const DEFAULT_PUBKEY = web3_js_1.PublicKey.default;
|
|
401
|
+
if (!stv.lendProgram.equals(DEFAULT_PUBKEY)) {
|
|
402
|
+
const [lendStrategyState] = (0, pda_3.findStrategyStatePda)(baseMint, stv.lendProgram);
|
|
403
|
+
const [lendPosition] = (0, pda_3.findStvPositionPda)(stvAddress, stv.lendProgram);
|
|
404
|
+
const lendBaseAta = findAta(baseMint, lendStrategyState, tokenProgram);
|
|
405
|
+
lendAccounts.push(...(0, instructions_1.buildLendRemainingAccounts)({
|
|
406
|
+
lendProgram: stv.lendProgram,
|
|
407
|
+
lendStrategyState,
|
|
408
|
+
lendStvPosition: lendPosition,
|
|
409
|
+
lendBaseAta,
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
412
|
+
const withdrawIx = (0, instructions_1.createWithdrawFromStrategyIx)({
|
|
413
|
+
manager,
|
|
414
|
+
managerRole: stvManagerRole,
|
|
415
|
+
stv: stvAddress,
|
|
416
|
+
vaultAta,
|
|
417
|
+
baseMint,
|
|
418
|
+
strategyProgram: programId,
|
|
419
|
+
strategyState,
|
|
420
|
+
stvPosition: jlpdStvPosition,
|
|
421
|
+
strategyBaseAta,
|
|
422
|
+
tokenProgram,
|
|
423
|
+
shares: new bn_js_1.default(sharesToWithdraw.toString()),
|
|
424
|
+
remainingAccounts: lendAccounts,
|
|
425
|
+
}, pStvProgramId);
|
|
426
|
+
// Build Jupiter Lend deposit instruction to route funds from Elemental Lend → Jupiter Lend.
|
|
427
|
+
// After withdraw_from_strategy, funds are swept to Elemental Lend's base ATA.
|
|
428
|
+
// This instruction routes them into the Jupiter Lend pool for yield.
|
|
429
|
+
const postInstructions = [];
|
|
430
|
+
const jupPool = jupiter_lend_1.JUP_LEND_POOLS[baseMint.toBase58()];
|
|
431
|
+
if (!stv.lendProgram.equals(DEFAULT_PUBKEY) && jupPool) {
|
|
432
|
+
const lendProgramId = stv.lendProgram;
|
|
433
|
+
const [lendStrategyState] = (0, pda_3.findStrategyStatePda)(baseMint, lendProgramId);
|
|
434
|
+
const [lendManagerRole] = (0, pda_3.findManagerRolePda)(lendStrategyState, manager, lendProgramId);
|
|
435
|
+
const lendBaseAta = findAta(baseMint, lendStrategyState, tokenProgram);
|
|
436
|
+
const lendFtokenAta = findAta(jupPool.fTokenMint, lendStrategyState, tokenProgram);
|
|
437
|
+
const JUP_LEND_PROG = new web3_js_1.PublicKey("jup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9");
|
|
438
|
+
const jupLendAccounts = [
|
|
439
|
+
...(0, jupiter_lend_1.buildJupLendDepositAccounts)(jupPool, lendStrategyState, lendBaseAta, lendFtokenAta).map((a) => ({ ...a, isSigner: false })),
|
|
440
|
+
{ pubkey: JUP_LEND_PROG, isSigner: false, isWritable: false },
|
|
441
|
+
];
|
|
442
|
+
// Use minBaseOut as the deposit amount — this is the minimum base tokens
|
|
443
|
+
// that will arrive in the lend base ATA after swap → withdraw → sweep.
|
|
444
|
+
// The actual amount may be slightly higher due to favorable slippage.
|
|
445
|
+
postInstructions.push((0, instructions_2.createJupLendDepositIx)({
|
|
446
|
+
manager,
|
|
447
|
+
strategyState: lendStrategyState,
|
|
448
|
+
managerRole: lendManagerRole,
|
|
449
|
+
depositorBaseAta: lendBaseAta,
|
|
450
|
+
depositorFtokenAta: lendFtokenAta,
|
|
451
|
+
amount: new bn_js_1.default(minBaseOut.toString()),
|
|
452
|
+
remainingAccounts: jupLendAccounts,
|
|
453
|
+
}, lendProgramId));
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
preInstructions: [],
|
|
457
|
+
instructions: [...swapIxs, withdrawIx],
|
|
458
|
+
postInstructions,
|
|
459
|
+
addressLookupTables,
|
|
460
|
+
routeDescription: jupPool
|
|
461
|
+
? "Swap JLP → base → withdraw to vault → route to Jupiter Lend"
|
|
462
|
+
: "Swap JLP → base → withdraw to vault",
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
//# sourceMappingURL=swap-jlp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap-jlp.js","sourceRoot":"","sources":["../../src/jlpd-strategy/swap-jlp.ts"],"names":[],"mappings":";;;;;AAmJA,0C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C;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/p-stv-core/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,MAAM,OAAO,CAAC;AAavB,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAO1E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAelE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/p-stv-core/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,MAAM,OAAO,CAAC;AAavB,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAO1E,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAelE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CA4ChD;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAiBxE;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAahE;AAMD,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,UAAU,EACtB,SAAS,GAAE,SAAsB,GAChC,OAAO,CAAC,YAAY,CAAC,CAKvB;AAED,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,GAAG,EAAE,EACpB,SAAS,GAAE,SAAsB,GAChC,OAAO,CAAC,GAAG,CAAC,CAKd;AAED,w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