@exponent-labs/exponent-sdk 0.9.0 → 0.9.2
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/build/client/vaults/index.d.ts +2 -0
- package/build/client/vaults/index.js +2 -0
- package/build/client/vaults/index.js.map +1 -1
- package/build/client/vaults/types/index.d.ts +2 -0
- package/build/client/vaults/types/index.js +2 -0
- package/build/client/vaults/types/index.js.map +1 -1
- package/build/client/vaults/types/kaminoFarmEntry.d.ts +15 -0
- package/build/client/vaults/types/kaminoFarmEntry.js +17 -0
- package/build/client/vaults/types/kaminoFarmEntry.js.map +1 -0
- package/build/client/vaults/types/kaminoObligationEntry.d.ts +21 -4
- package/build/client/vaults/types/kaminoObligationEntry.js +2 -1
- package/build/client/vaults/types/kaminoObligationEntry.js.map +1 -1
- package/build/client/vaults/types/positionUpdate.d.ts +9 -0
- package/build/client/vaults/types/positionUpdate.js +23 -0
- package/build/client/vaults/types/positionUpdate.js.map +1 -1
- package/build/client/vaults/types/proposalAction.js +0 -3
- package/build/client/vaults/types/proposalAction.js.map +1 -1
- package/build/client/vaults/types/reserveFarmMapping.d.ts +19 -0
- package/build/client/vaults/types/reserveFarmMapping.js +18 -0
- package/build/client/vaults/types/reserveFarmMapping.js.map +1 -0
- package/build/client/vaults/types/strategyPosition.d.ts +5 -0
- package/build/client/vaults/types/strategyPosition.js +5 -0
- package/build/client/vaults/types/strategyPosition.js.map +1 -1
- package/build/exponentVaults/aumCalculator.d.ts +25 -4
- package/build/exponentVaults/aumCalculator.js +236 -15
- package/build/exponentVaults/aumCalculator.js.map +1 -1
- package/build/exponentVaults/fetcher.d.ts +52 -0
- package/build/exponentVaults/fetcher.js +199 -0
- package/build/exponentVaults/fetcher.js.map +1 -0
- package/build/exponentVaults/index.d.ts +10 -9
- package/build/exponentVaults/index.js +26 -8
- package/build/exponentVaults/index.js.map +1 -1
- package/build/exponentVaults/kamino-farms.d.ts +144 -0
- package/build/exponentVaults/kamino-farms.js +396 -0
- package/build/exponentVaults/kamino-farms.js.map +1 -0
- package/build/exponentVaults/loopscale/client.d.ts +240 -0
- package/build/exponentVaults/loopscale/client.js +590 -0
- package/build/exponentVaults/loopscale/client.js.map +1 -0
- package/build/exponentVaults/loopscale/client.test.d.ts +1 -0
- package/build/exponentVaults/loopscale/client.test.js +183 -0
- package/build/exponentVaults/loopscale/client.test.js.map +1 -0
- package/build/exponentVaults/loopscale/helpers.d.ts +29 -0
- package/build/exponentVaults/loopscale/helpers.js +119 -0
- package/build/exponentVaults/loopscale/helpers.js.map +1 -0
- package/build/exponentVaults/loopscale/index.d.ts +3 -0
- package/build/exponentVaults/loopscale/index.js +12 -0
- package/build/exponentVaults/loopscale/index.js.map +1 -0
- package/build/exponentVaults/loopscale/prepared-transactions.d.ts +13 -0
- package/build/exponentVaults/loopscale/prepared-transactions.js +271 -0
- package/build/exponentVaults/loopscale/prepared-transactions.js.map +1 -0
- package/build/exponentVaults/loopscale/prepared-transactions.test.d.ts +1 -0
- package/build/exponentVaults/loopscale/prepared-transactions.test.js +400 -0
- package/build/exponentVaults/loopscale/prepared-transactions.test.js.map +1 -0
- package/build/exponentVaults/loopscale/prepared-types.d.ts +62 -0
- package/build/exponentVaults/loopscale/prepared-types.js +3 -0
- package/build/exponentVaults/loopscale/prepared-types.js.map +1 -0
- package/build/exponentVaults/loopscale/response-plan.d.ts +69 -0
- package/build/exponentVaults/loopscale/response-plan.js +141 -0
- package/build/exponentVaults/loopscale/response-plan.js.map +1 -0
- package/build/exponentVaults/loopscale/response-plan.test.d.ts +1 -0
- package/build/exponentVaults/loopscale/response-plan.test.js +139 -0
- package/build/exponentVaults/loopscale/response-plan.test.js.map +1 -0
- package/build/exponentVaults/loopscale/send-plan.d.ts +75 -0
- package/build/exponentVaults/loopscale/send-plan.js +235 -0
- package/build/exponentVaults/loopscale/send-plan.js.map +1 -0
- package/build/exponentVaults/loopscale/types.d.ts +443 -0
- package/build/exponentVaults/loopscale/types.js +3 -0
- package/build/exponentVaults/loopscale/types.js.map +1 -0
- package/build/exponentVaults/loopscale-client.d.ts +113 -524
- package/build/exponentVaults/loopscale-client.js +296 -539
- package/build/exponentVaults/loopscale-client.js.map +1 -1
- package/build/exponentVaults/loopscale-client.test.d.ts +1 -0
- package/build/exponentVaults/loopscale-client.test.js +162 -0
- package/build/exponentVaults/loopscale-client.test.js.map +1 -0
- package/build/exponentVaults/loopscale-client.types.d.ts +425 -0
- package/build/exponentVaults/loopscale-client.types.js +3 -0
- package/build/exponentVaults/loopscale-client.types.js.map +1 -0
- package/build/exponentVaults/loopscale-execution.d.ts +125 -0
- package/build/exponentVaults/loopscale-execution.js +341 -0
- package/build/exponentVaults/loopscale-execution.js.map +1 -0
- package/build/exponentVaults/loopscale-execution.test.d.ts +1 -0
- package/build/exponentVaults/loopscale-execution.test.js +139 -0
- package/build/exponentVaults/loopscale-execution.test.js.map +1 -0
- package/build/exponentVaults/loopscale-vault.d.ts +115 -0
- package/build/exponentVaults/loopscale-vault.js +275 -0
- package/build/exponentVaults/loopscale-vault.js.map +1 -0
- package/build/exponentVaults/loopscale-vault.test.d.ts +1 -0
- package/build/exponentVaults/loopscale-vault.test.js +102 -0
- package/build/exponentVaults/loopscale-vault.test.js.map +1 -0
- package/build/exponentVaults/policyBuilders.d.ts +62 -0
- package/build/exponentVaults/policyBuilders.js +119 -2
- package/build/exponentVaults/policyBuilders.js.map +1 -1
- package/build/exponentVaults/pricePathResolver.d.ts +45 -0
- package/build/exponentVaults/pricePathResolver.js +198 -0
- package/build/exponentVaults/pricePathResolver.js.map +1 -0
- package/build/exponentVaults/pricePathResolver.test.d.ts +1 -0
- package/build/exponentVaults/pricePathResolver.test.js +369 -0
- package/build/exponentVaults/pricePathResolver.test.js.map +1 -0
- package/build/exponentVaults/syncTransaction.js +4 -1
- package/build/exponentVaults/syncTransaction.js.map +1 -1
- package/build/exponentVaults/titan-quote.js +170 -36
- package/build/exponentVaults/titan-quote.js.map +1 -1
- package/build/exponentVaults/vault-instruction-types.d.ts +363 -0
- package/build/exponentVaults/vault-instruction-types.js +128 -0
- package/build/exponentVaults/vault-instruction-types.js.map +1 -0
- package/build/exponentVaults/vault-interaction.d.ts +203 -343
- package/build/exponentVaults/vault-interaction.js +1894 -426
- package/build/exponentVaults/vault-interaction.js.map +1 -1
- package/build/exponentVaults/vault-interaction.kamino-vault.test.d.ts +1 -0
- package/build/exponentVaults/vault-interaction.kamino-vault.test.js +143 -0
- package/build/exponentVaults/vault-interaction.kamino-vault.test.js.map +1 -0
- package/build/exponentVaults/vault.d.ts +51 -2
- package/build/exponentVaults/vault.js +324 -48
- package/build/exponentVaults/vault.js.map +1 -1
- package/build/exponentVaults/vaultTransactionBuilder.d.ts +100 -134
- package/build/exponentVaults/vaultTransactionBuilder.js +383 -285
- package/build/exponentVaults/vaultTransactionBuilder.js.map +1 -1
- package/build/exponentVaults/vaultTransactionBuilder.test.d.ts +1 -0
- package/build/exponentVaults/vaultTransactionBuilder.test.js +297 -0
- package/build/exponentVaults/vaultTransactionBuilder.test.js.map +1 -0
- package/build/marketThree.d.ts +6 -2
- package/build/marketThree.js +10 -8
- package/build/marketThree.js.map +1 -1
- package/package.json +34 -32
- package/src/client/vaults/index.ts +2 -0
- package/src/client/vaults/types/index.ts +2 -0
- package/src/client/vaults/types/kaminoFarmEntry.ts +32 -0
- package/src/client/vaults/types/kaminoObligationEntry.ts +6 -3
- package/src/client/vaults/types/positionUpdate.ts +62 -0
- package/src/client/vaults/types/proposalAction.ts +0 -3
- package/src/client/vaults/types/reserveFarmMapping.ts +35 -0
- package/src/client/vaults/types/strategyPosition.ts +18 -1
- package/src/exponentVaults/aumCalculator.ts +353 -16
- package/src/exponentVaults/fetcher.ts +257 -0
- package/src/exponentVaults/index.ts +65 -40
- package/src/exponentVaults/kamino-farms.ts +538 -0
- package/src/exponentVaults/loopscale/client.ts +808 -0
- package/src/exponentVaults/loopscale/helpers.ts +172 -0
- package/src/exponentVaults/loopscale/index.ts +57 -0
- package/src/exponentVaults/loopscale/prepared-transactions.ts +435 -0
- package/src/exponentVaults/loopscale/prepared-types.ts +73 -0
- package/src/exponentVaults/loopscale/types.ts +466 -0
- package/src/exponentVaults/policyBuilders.ts +170 -0
- package/src/exponentVaults/pricePathResolver.test.ts +466 -0
- package/src/exponentVaults/pricePathResolver.ts +273 -0
- package/src/exponentVaults/syncTransaction.ts +6 -1
- package/src/exponentVaults/titan-quote.ts +231 -45
- package/src/exponentVaults/vault-instruction-types.ts +493 -0
- package/src/exponentVaults/vault-interaction.kamino-vault.test.ts +149 -0
- package/src/exponentVaults/vault-interaction.ts +2818 -799
- package/src/exponentVaults/vault.ts +474 -63
- package/src/exponentVaults/vaultTransactionBuilder.test.ts +349 -0
- package/src/exponentVaults/vaultTransactionBuilder.ts +581 -433
- package/src/marketThree.ts +14 -6
- package/src/exponentVaults/loopscale-client.ts +0 -1373
|
@@ -1,304 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KaminoMarket } from "./kamino-markets";
|
|
2
|
+
import Decimal from "decimal.js";
|
|
2
3
|
import { SwapDirection } from "../client/clmm";
|
|
3
4
|
import { Environment } from "../environment";
|
|
5
|
+
import { ExponentVault as StrategyVault } from "./vault";
|
|
6
|
+
import type { ExponentPrices } from "@exponent-labs/exponent-vaults-fetcher";
|
|
7
|
+
import type { PriceId as ClientPriceId } from "../client/vaults/types/priceId";
|
|
4
8
|
import * as web3 from "@solana/web3.js";
|
|
5
9
|
import { AccountMeta, Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
6
10
|
import BN from "bn.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
INIT_OBLIGATION = "INIT_OBLIGATION",
|
|
12
|
-
DEPOSIT = "DEPOSIT",
|
|
13
|
-
WITHDRAW = "WITHDRAW",
|
|
14
|
-
BORROW = "BORROW",
|
|
15
|
-
REPAY = "REPAY"
|
|
16
|
-
}
|
|
17
|
-
/** A market-level instruction (no specific reserve needed). */
|
|
18
|
-
export type MarketInstruction = {
|
|
19
|
-
action: VaultAction.INIT_USER_METADATA | VaultAction.INIT_OBLIGATION;
|
|
20
|
-
market: KaminoMarket;
|
|
21
|
-
};
|
|
22
|
-
/** A reserve-level instruction with an amount. */
|
|
23
|
-
export type ReserveInstruction = {
|
|
24
|
-
action: VaultAction.DEPOSIT | VaultAction.WITHDRAW | VaultAction.BORROW | VaultAction.REPAY;
|
|
25
|
-
market: KaminoMarket;
|
|
26
|
-
asset: string;
|
|
27
|
-
amount: BN;
|
|
28
|
-
};
|
|
29
|
-
/** Orderbook trade direction */
|
|
30
|
-
export declare enum OrderbookTradeDirection {
|
|
31
|
-
BUY_PT = "BUY_PT",
|
|
32
|
-
SELL_PT = "SELL_PT",
|
|
33
|
-
BUY_YT = "BUY_YT",
|
|
34
|
-
SELL_YT = "SELL_YT"
|
|
35
|
-
}
|
|
36
|
-
/** Offer options for limit orders (currently only FillOrKill supported) */
|
|
37
|
-
export type OrderbookOfferOption = "FillOrKill";
|
|
38
|
-
/** Actions that can be performed on the Exponent Orderbook */
|
|
39
|
-
export declare enum OrderbookAction {
|
|
40
|
-
POST_OFFER = "POST_OFFER",
|
|
41
|
-
MARKET_OFFER = "MARKET_OFFER",
|
|
42
|
-
REMOVE_OFFER = "REMOVE_OFFER",
|
|
43
|
-
WITHDRAW_FUNDS = "WITHDRAW_FUNDS"
|
|
44
|
-
}
|
|
45
|
-
export type OrderbookInstructionMode = "wrapper" | "raw";
|
|
46
|
-
/** Base instruction type for all orderbook operations */
|
|
47
|
-
interface OrderbookInstructionBase {
|
|
48
|
-
action: OrderbookAction;
|
|
49
|
-
orderbook: PublicKey;
|
|
50
|
-
mode?: OrderbookInstructionMode;
|
|
51
|
-
}
|
|
52
|
-
/** Post a limit order on the orderbook */
|
|
53
|
-
export interface OrderbookPostOfferInstruction extends OrderbookInstructionBase {
|
|
54
|
-
action: OrderbookAction.POST_OFFER;
|
|
55
|
-
direction: OrderbookTradeDirection;
|
|
56
|
-
priceApy: number;
|
|
57
|
-
amount: bigint;
|
|
58
|
-
offerIdx: number;
|
|
59
|
-
offerOption?: OrderbookOfferOption;
|
|
60
|
-
virtualOffer?: boolean;
|
|
61
|
-
expirySeconds?: number;
|
|
62
|
-
}
|
|
63
|
-
/** Execute a market order on the orderbook */
|
|
64
|
-
export interface OrderbookMarketOfferInstruction extends OrderbookInstructionBase {
|
|
65
|
-
action: OrderbookAction.MARKET_OFFER;
|
|
66
|
-
direction: OrderbookTradeDirection;
|
|
67
|
-
maxPriceApy: number;
|
|
68
|
-
amount: bigint;
|
|
69
|
-
minAmountOut: bigint;
|
|
70
|
-
virtualOffer?: boolean;
|
|
71
|
-
}
|
|
72
|
-
/** Cancel an existing limit order */
|
|
73
|
-
export interface OrderbookRemoveOfferInstruction extends OrderbookInstructionBase {
|
|
74
|
-
action: OrderbookAction.REMOVE_OFFER;
|
|
75
|
-
offerIdx: number;
|
|
76
|
-
}
|
|
77
|
-
/** Withdraw funds from user escrow */
|
|
78
|
-
export interface OrderbookWithdrawFundsInstruction extends OrderbookInstructionBase {
|
|
79
|
-
action: OrderbookAction.WITHDRAW_FUNDS;
|
|
80
|
-
ptAmount?: bigint | null;
|
|
81
|
-
ytAmount?: bigint | null;
|
|
82
|
-
syAmount?: bigint | null;
|
|
83
|
-
}
|
|
84
|
-
/** A single orderbook instruction */
|
|
85
|
-
export type OrderbookInstruction = OrderbookPostOfferInstruction | OrderbookMarketOfferInstruction | OrderbookRemoveOfferInstruction | OrderbookWithdrawFundsInstruction;
|
|
86
|
-
/** Actions that can be performed on Exponent Core */
|
|
87
|
-
export declare enum CoreAction {
|
|
88
|
-
STRIP = "STRIP",
|
|
89
|
-
MERGE = "MERGE",
|
|
90
|
-
WITHDRAW_YT = "WITHDRAW_YT",
|
|
91
|
-
DEPOSIT_YT = "DEPOSIT_YT",
|
|
92
|
-
INITIALIZE_YIELD_POSITION = "INITIALIZE_YIELD_POSITION"
|
|
93
|
-
}
|
|
94
|
-
/** Base instruction type for all core operations */
|
|
95
|
-
interface CoreInstructionBase {
|
|
96
|
-
action: CoreAction;
|
|
97
|
-
vault: PublicKey;
|
|
98
|
-
}
|
|
99
|
-
/** Strip LST into PT + YT */
|
|
100
|
-
export interface CoreStripInstruction extends CoreInstructionBase {
|
|
101
|
-
action: CoreAction.STRIP;
|
|
102
|
-
/** Amount of base token (LST) to strip */
|
|
103
|
-
amountBase: bigint;
|
|
104
|
-
}
|
|
105
|
-
/** Merge PT + YT into LST */
|
|
106
|
-
export interface CoreMergeInstruction extends CoreInstructionBase {
|
|
107
|
-
action: CoreAction.MERGE;
|
|
108
|
-
/** Amount of PT/YT to merge (must have equal amounts of both) */
|
|
109
|
-
amountPy: bigint;
|
|
110
|
-
}
|
|
111
|
-
/** Withdraw YT from the tracked yield position back into the YT token account */
|
|
112
|
-
export interface CoreWithdrawYtInstruction extends CoreInstructionBase {
|
|
113
|
-
action: CoreAction.WITHDRAW_YT;
|
|
114
|
-
amountYt: bigint;
|
|
115
|
-
}
|
|
116
|
-
/** Deposit YT from the YT token account back into the tracked yield position */
|
|
117
|
-
export interface CoreDepositYtInstruction extends CoreInstructionBase {
|
|
118
|
-
action: CoreAction.DEPOSIT_YT;
|
|
119
|
-
amountYt: bigint;
|
|
120
|
-
}
|
|
121
|
-
/** Initialize yield position for a vault (owner = Squads vault) */
|
|
122
|
-
export interface CoreInitializeYieldPositionInstruction extends CoreInstructionBase {
|
|
123
|
-
action: CoreAction.INITIALIZE_YIELD_POSITION;
|
|
124
|
-
}
|
|
125
|
-
/** A single core instruction */
|
|
126
|
-
export type CoreInstruction = CoreStripInstruction | CoreMergeInstruction | CoreWithdrawYtInstruction | CoreDepositYtInstruction | CoreInitializeYieldPositionInstruction;
|
|
127
|
-
export declare enum SyAction {
|
|
128
|
-
MINT = "MINT_SY",
|
|
129
|
-
REDEEM = "REDEEM_SY"
|
|
130
|
-
}
|
|
131
|
-
interface SyInstructionBase {
|
|
132
|
-
action: SyAction;
|
|
133
|
-
vault: PublicKey;
|
|
134
|
-
}
|
|
135
|
-
export interface SyMintInstruction extends SyInstructionBase {
|
|
136
|
-
action: SyAction.MINT;
|
|
137
|
-
amountBase: bigint;
|
|
138
|
-
}
|
|
139
|
-
export interface SyRedeemInstruction extends SyInstructionBase {
|
|
140
|
-
action: SyAction.REDEEM;
|
|
141
|
-
amountSy: bigint;
|
|
142
|
-
}
|
|
143
|
-
export type SyInstruction = SyMintInstruction | SyRedeemInstruction;
|
|
144
|
-
export declare enum TitanAction {
|
|
145
|
-
SWAP = "SWAP"
|
|
146
|
-
}
|
|
147
|
-
/** A pre-built Titan swap instruction to wrap in a sync transaction. */
|
|
148
|
-
export interface TitanSwapInstruction {
|
|
149
|
-
action: TitanAction.SWAP;
|
|
150
|
-
/** The raw Titan SwapRouteV2 TransactionInstruction (from Titan's router API) */
|
|
151
|
-
instruction: TransactionInstruction;
|
|
152
|
-
}
|
|
153
|
-
/** Actions for Loopscale interactions (loans = borrower side, strategies = lender side). */
|
|
154
|
-
export declare enum LoopscaleAction {
|
|
155
|
-
CREATE_LOAN = "LOOPSCALE_CREATE_LOAN",
|
|
156
|
-
DEPOSIT_COLLATERAL = "LOOPSCALE_DEPOSIT_COLLATERAL",
|
|
157
|
-
BORROW_PRINCIPAL = "LOOPSCALE_BORROW_PRINCIPAL",
|
|
158
|
-
REPAY_PRINCIPAL = "LOOPSCALE_REPAY_PRINCIPAL",
|
|
159
|
-
WITHDRAW_COLLATERAL = "LOOPSCALE_WITHDRAW_COLLATERAL",
|
|
160
|
-
CLOSE_LOAN = "LOOPSCALE_CLOSE_LOAN",
|
|
161
|
-
UPDATE_WEIGHT_MATRIX = "LOOPSCALE_UPDATE_WEIGHT_MATRIX",
|
|
162
|
-
CREATE_STRATEGY = "LOOPSCALE_CREATE_STRATEGY",
|
|
163
|
-
DEPOSIT_STRATEGY = "LOOPSCALE_DEPOSIT_STRATEGY",
|
|
164
|
-
WITHDRAW_STRATEGY = "LOOPSCALE_WITHDRAW_STRATEGY",
|
|
165
|
-
CLOSE_STRATEGY = "LOOPSCALE_CLOSE_STRATEGY",
|
|
166
|
-
UPDATE_STRATEGY = "LOOPSCALE_UPDATE_STRATEGY",
|
|
167
|
-
LOCK_LOAN = "LOOPSCALE_LOCK_LOAN",
|
|
168
|
-
UNLOCK_LOAN = "LOOPSCALE_UNLOCK_LOAN",
|
|
169
|
-
REFINANCE_LEDGER = "LOOPSCALE_REFINANCE_LEDGER"
|
|
170
|
-
}
|
|
171
|
-
/** A pre-built Loopscale instruction (loan or strategy) to wrap in a sync transaction. */
|
|
172
|
-
export interface LoopscaleInstruction {
|
|
173
|
-
action: LoopscaleAction;
|
|
174
|
-
/** The raw Loopscale TransactionInstruction (from Loopscale API or local builder) */
|
|
175
|
-
instruction: TransactionInstruction;
|
|
176
|
-
}
|
|
177
|
-
/** Actions that can be performed on the Exponent CLMM (Concentrated Liquidity Market Maker). */
|
|
178
|
-
export declare enum ClmmAction {
|
|
179
|
-
/** Create a new LP position with a specified tick range. Generates keypair internally. */
|
|
180
|
-
DEPOSIT_LIQUIDITY = "CLMM_DEPOSIT_LIQUIDITY",
|
|
181
|
-
/** Add more liquidity to an existing LP position. */
|
|
182
|
-
ADD_LIQUIDITY = "CLMM_ADD_LIQUIDITY",
|
|
183
|
-
/** Remove liquidity from an LP position and receive PT + SY. */
|
|
184
|
-
WITHDRAW_LIQUIDITY = "CLMM_WITHDRAW_LIQUIDITY",
|
|
185
|
-
/** Low-level PT/SY swap. Prefer buyPt/sellPt for directional trades. */
|
|
186
|
-
TRADE_PT = "CLMM_TRADE_PT",
|
|
187
|
-
/** Buy PT with SY on the CLMM. */
|
|
188
|
-
BUY_PT = "CLMM_BUY_PT",
|
|
189
|
-
/** Sell PT for SY on the CLMM. */
|
|
190
|
-
SELL_PT = "CLMM_SELL_PT",
|
|
191
|
-
/** Buy YT with SY on the CLMM. */
|
|
192
|
-
BUY_YT = "CLMM_BUY_YT",
|
|
193
|
-
/** Sell YT for SY on the CLMM. */
|
|
194
|
-
SELL_YT = "CLMM_SELL_YT",
|
|
195
|
-
/** Claim farm emissions from an LP position. */
|
|
196
|
-
CLAIM_FARM_EMISSION = "CLMM_CLAIM_FARM_EMISSION"
|
|
197
|
-
}
|
|
198
|
-
/** Base type for all CLMM instructions. */
|
|
199
|
-
interface ClmmInstructionBase {
|
|
200
|
-
action: ClmmAction;
|
|
201
|
-
/** The CLMM MarketThree account address. */
|
|
202
|
-
market: PublicKey;
|
|
203
|
-
}
|
|
204
|
-
/** Create a new LP position on the CLMM. The lpPosition keypair is generated internally for good UX. */
|
|
205
|
-
export interface ClmmDepositLiquidityInstruction extends ClmmInstructionBase {
|
|
206
|
-
action: ClmmAction.DEPOSIT_LIQUIDITY;
|
|
207
|
-
/** Maximum amount of PT to deposit. */
|
|
208
|
-
ptInIntent: bigint;
|
|
209
|
-
/** Maximum amount of SY to deposit. */
|
|
210
|
-
syInIntent: bigint;
|
|
211
|
-
/** Lower tick boundary (APY value). */
|
|
212
|
-
lowerTickKey: number;
|
|
213
|
-
/** Upper tick boundary (APY value). */
|
|
214
|
-
upperTickKey: number;
|
|
215
|
-
}
|
|
216
|
-
/** Add liquidity to an existing LP position. */
|
|
217
|
-
export interface ClmmAddLiquidityInstruction extends ClmmInstructionBase {
|
|
218
|
-
action: ClmmAction.ADD_LIQUIDITY;
|
|
219
|
-
/** The existing LpPosition account public key. */
|
|
220
|
-
lpPosition: PublicKey;
|
|
221
|
-
/** Maximum amount of PT to add. */
|
|
222
|
-
ptInIntent: bigint;
|
|
223
|
-
/** Maximum amount of SY to add. */
|
|
224
|
-
syInIntent: bigint;
|
|
225
|
-
}
|
|
226
|
-
/** Withdraw liquidity from an LP position. */
|
|
227
|
-
export interface ClmmWithdrawLiquidityInstruction extends ClmmInstructionBase {
|
|
228
|
-
action: ClmmAction.WITHDRAW_LIQUIDITY;
|
|
229
|
-
/** The LpPosition account to withdraw from. */
|
|
230
|
-
lpPosition: PublicKey;
|
|
231
|
-
/** Amount of liquidity (LP units) to remove. */
|
|
232
|
-
lpIn: bigint;
|
|
233
|
-
/** Minimum PT to receive (slippage protection). */
|
|
234
|
-
minPtOut: bigint;
|
|
235
|
-
/** Minimum SY to receive (slippage protection). */
|
|
236
|
-
minSyOut: bigint;
|
|
237
|
-
}
|
|
238
|
-
/** Low-level PT/SY swap on the CLMM. Prefer buyPt/sellPt for directional trades. */
|
|
239
|
-
export interface ClmmTradePtInstruction extends ClmmInstructionBase {
|
|
240
|
-
action: ClmmAction.TRADE_PT;
|
|
241
|
-
/** Amount of the input token. */
|
|
242
|
-
traderAmount: bigint;
|
|
243
|
-
/** Minimum output amount (slippage protection). */
|
|
244
|
-
outConstraint: bigint;
|
|
245
|
-
/** Swap direction: SyToPt or PtToSy. */
|
|
246
|
-
swapDirection: SwapDirection;
|
|
247
|
-
/** Optional price limit (ln implied APY). */
|
|
248
|
-
lnImpliedApyLimit?: number;
|
|
249
|
-
}
|
|
250
|
-
/** Buy PT with SY on the CLMM. */
|
|
251
|
-
export interface ClmmBuyPtInstruction extends ClmmInstructionBase {
|
|
252
|
-
action: ClmmAction.BUY_PT;
|
|
253
|
-
/** Amount of SY to spend. */
|
|
254
|
-
amountSy: bigint;
|
|
255
|
-
/** Minimum PT to receive (slippage protection). */
|
|
256
|
-
outConstraint: bigint;
|
|
257
|
-
/** Optional price limit (ln implied APY). */
|
|
258
|
-
lnImpliedApyLimit?: number;
|
|
259
|
-
}
|
|
260
|
-
/** Sell PT for SY on the CLMM. */
|
|
261
|
-
export interface ClmmSellPtInstruction extends ClmmInstructionBase {
|
|
262
|
-
action: ClmmAction.SELL_PT;
|
|
263
|
-
/** Amount of PT to sell. */
|
|
264
|
-
amountPt: bigint;
|
|
265
|
-
/** Minimum SY to receive (slippage protection). */
|
|
266
|
-
outConstraint: bigint;
|
|
267
|
-
/** Optional price limit (ln implied APY). */
|
|
268
|
-
lnImpliedApyLimit?: number;
|
|
269
|
-
}
|
|
270
|
-
/** Buy YT with SY on the CLMM. */
|
|
271
|
-
export interface ClmmBuyYtInstruction extends ClmmInstructionBase {
|
|
272
|
-
action: ClmmAction.BUY_YT;
|
|
273
|
-
/** Minimum amount of YT to receive. */
|
|
274
|
-
ytOut: bigint;
|
|
275
|
-
/** Maximum amount of SY to spend. */
|
|
276
|
-
maxSyIn: bigint;
|
|
277
|
-
/** Optional price limit (ln implied APY). */
|
|
278
|
-
lnImpliedApyLimit?: number;
|
|
279
|
-
}
|
|
280
|
-
/** Sell YT for SY on the CLMM. */
|
|
281
|
-
export interface ClmmSellYtInstruction extends ClmmInstructionBase {
|
|
282
|
-
action: ClmmAction.SELL_YT;
|
|
283
|
-
/** Amount of YT to sell. */
|
|
284
|
-
ytIn: bigint;
|
|
285
|
-
/** Minimum SY to receive (slippage protection). */
|
|
286
|
-
minSyOut: bigint;
|
|
287
|
-
/** Optional price limit (ln implied APY). */
|
|
288
|
-
lnImpliedApyLimit?: number;
|
|
289
|
-
}
|
|
290
|
-
/** Claim farm emissions from an LP position. */
|
|
291
|
-
export interface ClmmClaimFarmEmissionInstruction extends ClmmInstructionBase {
|
|
292
|
-
action: ClmmAction.CLAIM_FARM_EMISSION;
|
|
293
|
-
/** The LpPosition account to claim from. */
|
|
294
|
-
lpPosition: PublicKey;
|
|
295
|
-
/** Index of the farm to claim from. */
|
|
296
|
-
farmIndex: number;
|
|
297
|
-
}
|
|
298
|
-
/** A single CLMM instruction. */
|
|
299
|
-
export type ClmmInstruction = ClmmDepositLiquidityInstruction | ClmmAddLiquidityInstruction | ClmmWithdrawLiquidityInstruction | ClmmTradePtInstruction | ClmmBuyPtInstruction | ClmmSellPtInstruction | ClmmBuyYtInstruction | ClmmSellYtInstruction | ClmmClaimFarmEmissionInstruction;
|
|
300
|
-
/** A single vault instruction — pass an array of these to `createVaultSyncTransaction`. */
|
|
301
|
-
export type VaultInstruction = MarketInstruction | ReserveInstruction | OrderbookInstruction | CoreInstruction | SyInstruction | TitanSwapInstruction | ClmmInstruction | LoopscaleInstruction;
|
|
11
|
+
export { VaultAction, KaminoVaultAction, KaminoFarmAction, OrderbookTradeDirection, OrderbookAction, CoreAction, SyAction, TitanAction, LoopscaleAction, ClmmAction, } from "./vault-instruction-types";
|
|
12
|
+
export type { MarketInstruction, ReserveInstruction, KaminoVaultInstruction, KaminoVaultDepositInstruction, KaminoVaultWithdrawInstruction, KaminoFarmInstruction, KaminoFarmInitializeUserInstruction, KaminoFarmStakeInstruction, KaminoFarmUnstakeInstruction, KaminoFarmWithdrawUnstakedDepositsInstruction, KaminoFarmHarvestRewardInstruction, OrderbookOfferOption, OrderbookInstructionMode, OrderbookPostOfferInstruction, OrderbookMarketOfferInstruction, OrderbookRemoveOfferInstruction, OrderbookWithdrawFundsInstruction, OrderbookInstruction, CoreStripInstruction, CoreMergeInstruction, CoreWithdrawYtInstruction, CoreDepositYtInstruction, CoreInitializeYieldPositionInstruction, CoreInstruction, SyMintInstruction, SyRedeemInstruction, SyInstruction, TitanSwapInstruction, LoopscaleInstruction, ClmmDepositLiquidityInstruction, ClmmAddLiquidityInstruction, ClmmWithdrawLiquidityInstruction, ClmmTradePtInstruction, ClmmBuyPtInstruction, ClmmSellPtInstruction, ClmmBuyYtInstruction, ClmmSellYtInstruction, ClmmClaimFarmEmissionInstruction, ClmmInstruction, VaultInstruction, KaminoReserves, } from "./vault-instruction-types";
|
|
13
|
+
import type { MarketInstruction, ReserveInstruction, KaminoVaultDepositInstruction, KaminoVaultWithdrawInstruction, KaminoFarmInitializeUserInstruction, KaminoFarmStakeInstruction, KaminoFarmUnstakeInstruction, KaminoFarmWithdrawUnstakedDepositsInstruction, KaminoFarmHarvestRewardInstruction, OrderbookOfferOption, OrderbookInstructionMode, OrderbookInstruction, OrderbookPostOfferInstruction, OrderbookMarketOfferInstruction, OrderbookRemoveOfferInstruction, OrderbookWithdrawFundsInstruction, CoreStripInstruction, CoreMergeInstruction, CoreWithdrawYtInstruction, CoreDepositYtInstruction, CoreInitializeYieldPositionInstruction, TitanSwapInstruction, LoopscaleInstruction, ClmmDepositLiquidityInstruction, ClmmAddLiquidityInstruction, ClmmWithdrawLiquidityInstruction, ClmmTradePtInstruction, ClmmBuyPtInstruction, ClmmSellPtInstruction, ClmmBuyYtInstruction, ClmmSellYtInstruction, ClmmClaimFarmEmissionInstruction, VaultInstruction, KaminoReserves, SyMintInstruction, SyRedeemInstruction } from "./vault-instruction-types";
|
|
14
|
+
import { OrderbookTradeDirection } from "./vault-instruction-types";
|
|
302
15
|
/**
|
|
303
16
|
* Builder for Kamino Lending (KLend) vault action descriptors.
|
|
304
17
|
*
|
|
@@ -334,7 +47,8 @@ export declare const kaminoAction: {
|
|
|
334
47
|
initUserMetadata(market: KaminoMarket): MarketInstruction;
|
|
335
48
|
/**
|
|
336
49
|
* Initialize a Kamino obligation for a market.
|
|
337
|
-
*
|
|
50
|
+
* When `autoManagePositions` is enabled, the SDK also registers the new
|
|
51
|
+
* obligation as a tracked strategy position after the init succeeds.
|
|
338
52
|
* @param market - The Kamino lending market
|
|
339
53
|
*/
|
|
340
54
|
initObligation(market: KaminoMarket): MarketInstruction;
|
|
@@ -634,7 +348,6 @@ export declare const kaminoAction: {
|
|
|
634
348
|
pubkey: web3.PublicKey;
|
|
635
349
|
mint: web3.PublicKey;
|
|
636
350
|
};
|
|
637
|
-
/** The existing LpPosition account public key. */
|
|
638
351
|
readonly KMNO: {
|
|
639
352
|
pubkey: web3.PublicKey;
|
|
640
353
|
mint: web3.PublicKey;
|
|
@@ -662,7 +375,7 @@ export declare const kaminoAction: {
|
|
|
662
375
|
readonly TNSR: {
|
|
663
376
|
pubkey: web3.PublicKey;
|
|
664
377
|
mint: web3.PublicKey;
|
|
665
|
-
};
|
|
378
|
+
}; /** Harvest a specific reward index into a managed vault reward ATA. */
|
|
666
379
|
readonly GOAT: {
|
|
667
380
|
pubkey: web3.PublicKey;
|
|
668
381
|
mint: web3.PublicKey;
|
|
@@ -671,7 +384,6 @@ export declare const kaminoAction: {
|
|
|
671
384
|
pubkey: web3.PublicKey;
|
|
672
385
|
mint: web3.PublicKey;
|
|
673
386
|
};
|
|
674
|
-
/** Swap direction: SyToPt or PtToSy. */
|
|
675
387
|
readonly USDH: {
|
|
676
388
|
pubkey: web3.PublicKey;
|
|
677
389
|
mint: web3.PublicKey;
|
|
@@ -1488,7 +1200,6 @@ export declare const kaminoAction: {
|
|
|
1488
1200
|
pubkey: web3.PublicKey;
|
|
1489
1201
|
mint: web3.PublicKey;
|
|
1490
1202
|
};
|
|
1491
|
-
/** The existing LpPosition account public key. */
|
|
1492
1203
|
readonly KMNO: {
|
|
1493
1204
|
pubkey: web3.PublicKey;
|
|
1494
1205
|
mint: web3.PublicKey;
|
|
@@ -1516,7 +1227,7 @@ export declare const kaminoAction: {
|
|
|
1516
1227
|
readonly TNSR: {
|
|
1517
1228
|
pubkey: web3.PublicKey;
|
|
1518
1229
|
mint: web3.PublicKey;
|
|
1519
|
-
};
|
|
1230
|
+
}; /** Harvest a specific reward index into a managed vault reward ATA. */
|
|
1520
1231
|
readonly GOAT: {
|
|
1521
1232
|
pubkey: web3.PublicKey;
|
|
1522
1233
|
mint: web3.PublicKey;
|
|
@@ -1525,7 +1236,6 @@ export declare const kaminoAction: {
|
|
|
1525
1236
|
pubkey: web3.PublicKey;
|
|
1526
1237
|
mint: web3.PublicKey;
|
|
1527
1238
|
};
|
|
1528
|
-
/** Swap direction: SyToPt or PtToSy. */
|
|
1529
1239
|
readonly USDH: {
|
|
1530
1240
|
pubkey: web3.PublicKey;
|
|
1531
1241
|
mint: web3.PublicKey;
|
|
@@ -2342,7 +2052,6 @@ export declare const kaminoAction: {
|
|
|
2342
2052
|
pubkey: web3.PublicKey;
|
|
2343
2053
|
mint: web3.PublicKey;
|
|
2344
2054
|
};
|
|
2345
|
-
/** The existing LpPosition account public key. */
|
|
2346
2055
|
readonly KMNO: {
|
|
2347
2056
|
pubkey: web3.PublicKey;
|
|
2348
2057
|
mint: web3.PublicKey;
|
|
@@ -2370,7 +2079,7 @@ export declare const kaminoAction: {
|
|
|
2370
2079
|
readonly TNSR: {
|
|
2371
2080
|
pubkey: web3.PublicKey;
|
|
2372
2081
|
mint: web3.PublicKey;
|
|
2373
|
-
};
|
|
2082
|
+
}; /** Harvest a specific reward index into a managed vault reward ATA. */
|
|
2374
2083
|
readonly GOAT: {
|
|
2375
2084
|
pubkey: web3.PublicKey;
|
|
2376
2085
|
mint: web3.PublicKey;
|
|
@@ -2379,7 +2088,6 @@ export declare const kaminoAction: {
|
|
|
2379
2088
|
pubkey: web3.PublicKey;
|
|
2380
2089
|
mint: web3.PublicKey;
|
|
2381
2090
|
};
|
|
2382
|
-
/** Swap direction: SyToPt or PtToSy. */
|
|
2383
2091
|
readonly USDH: {
|
|
2384
2092
|
pubkey: web3.PublicKey;
|
|
2385
2093
|
mint: web3.PublicKey;
|
|
@@ -2909,6 +2617,71 @@ export declare const kaminoAction: {
|
|
|
2909
2617
|
};
|
|
2910
2618
|
}[M_3], amount: BN): ReserveInstruction;
|
|
2911
2619
|
};
|
|
2620
|
+
/**
|
|
2621
|
+
* Builder for direct Kamino Vault action descriptors.
|
|
2622
|
+
*
|
|
2623
|
+
* These actions move vault-owned tokens into a Kamino Vault and, when
|
|
2624
|
+
* `autoManagePositions` is enabled, automatically track the resulting share
|
|
2625
|
+
* token account as a managed strategy position.
|
|
2626
|
+
*/
|
|
2627
|
+
export declare const kaminoVaultAction: {
|
|
2628
|
+
/**
|
|
2629
|
+
* Deposit the vault-owned token account into a Kamino Vault.
|
|
2630
|
+
* @param params.vault - Kamino Vault address
|
|
2631
|
+
* @param params.amount - Amount of deposit tokens to move into the vault
|
|
2632
|
+
*/
|
|
2633
|
+
deposit(params: {
|
|
2634
|
+
vault: PublicKey;
|
|
2635
|
+
amount: BN;
|
|
2636
|
+
}): KaminoVaultDepositInstruction;
|
|
2637
|
+
/**
|
|
2638
|
+
* Withdraw Kamino Vault shares back into the vault-owned token account.
|
|
2639
|
+
* `reserve` is an optional override. When omitted, the SDK plans the
|
|
2640
|
+
* withdraw across the vault's active reserves automatically.
|
|
2641
|
+
*/
|
|
2642
|
+
withdraw(params: {
|
|
2643
|
+
vault: PublicKey;
|
|
2644
|
+
sharesAmount: BN;
|
|
2645
|
+
reserve?: PublicKey;
|
|
2646
|
+
}): KaminoVaultWithdrawInstruction;
|
|
2647
|
+
};
|
|
2648
|
+
/**
|
|
2649
|
+
* Builder for direct Kamino Farm action descriptors.
|
|
2650
|
+
*
|
|
2651
|
+
* These actions operate on a farm `user_state` derived from the managed vault
|
|
2652
|
+
* owner by default. Pass `delegatee` when targeting a delegated farm user
|
|
2653
|
+
* state, such as a Kamino obligation-owned farm entry.
|
|
2654
|
+
*/
|
|
2655
|
+
export declare const kaminoFarmAction: {
|
|
2656
|
+
/** Initialize the farm `user_state` PDA. */
|
|
2657
|
+
initializeUser(params: {
|
|
2658
|
+
farmState: PublicKey;
|
|
2659
|
+
delegatee?: PublicKey;
|
|
2660
|
+
}): KaminoFarmInitializeUserInstruction;
|
|
2661
|
+
/** Stake the managed vault's token ATA into the farm. */
|
|
2662
|
+
stake(params: {
|
|
2663
|
+
farmState: PublicKey;
|
|
2664
|
+
amount: BN | "ALL";
|
|
2665
|
+
delegatee?: PublicKey;
|
|
2666
|
+
}): KaminoFarmStakeInstruction;
|
|
2667
|
+
/** Unstake a scaled share amount from the farm. */
|
|
2668
|
+
unstake(params: {
|
|
2669
|
+
farmState: PublicKey;
|
|
2670
|
+
stakeSharesScaled: BN;
|
|
2671
|
+
delegatee?: PublicKey;
|
|
2672
|
+
}): KaminoFarmUnstakeInstruction;
|
|
2673
|
+
/** Withdraw matured unstaked deposits back into the managed vault ATA. */
|
|
2674
|
+
withdrawUnstakedDeposits(params: {
|
|
2675
|
+
farmState: PublicKey;
|
|
2676
|
+
delegatee?: PublicKey;
|
|
2677
|
+
}): KaminoFarmWithdrawUnstakedDepositsInstruction;
|
|
2678
|
+
/** Harvest a specific reward index into a managed vault reward ATA. */
|
|
2679
|
+
harvestReward(params: {
|
|
2680
|
+
farmState: PublicKey;
|
|
2681
|
+
rewardIndex: number;
|
|
2682
|
+
delegatee?: PublicKey;
|
|
2683
|
+
}): KaminoFarmHarvestRewardInstruction;
|
|
2684
|
+
};
|
|
2912
2685
|
/**
|
|
2913
2686
|
* Result of building a vault sync transaction.
|
|
2914
2687
|
*
|
|
@@ -2937,8 +2710,37 @@ export interface VaultSyncTransactionResult {
|
|
|
2937
2710
|
/** ALT addresses that should be loaded and included in the versioned transaction's lookup tables. */
|
|
2938
2711
|
addressLookupTableAddresses: PublicKey[];
|
|
2939
2712
|
}
|
|
2713
|
+
type CreateVaultSyncTransactionParams = {
|
|
2714
|
+
instructions: VaultInstruction[];
|
|
2715
|
+
owner: PublicKey;
|
|
2716
|
+
connection: Connection;
|
|
2717
|
+
policyPda?: PublicKey;
|
|
2718
|
+
vaultPda?: PublicKey;
|
|
2719
|
+
signer: PublicKey;
|
|
2720
|
+
accountIndex?: number;
|
|
2721
|
+
constraintIndices?: number[];
|
|
2722
|
+
/** ExponentStrategyVault PDA — used to auto-resolve hook accounts from the on-chain policy */
|
|
2723
|
+
vaultAddress?: PublicKey;
|
|
2724
|
+
leadingAccounts?: PublicKey[] | AccountMeta[];
|
|
2725
|
+
preHookAccounts?: PublicKey[] | AccountMeta[];
|
|
2726
|
+
postHookAccounts?: PublicKey[] | AccountMeta[];
|
|
2727
|
+
squadsProgram?: PublicKey;
|
|
2728
|
+
/** Automatically manage new Kamino/CLMM/yield position tracking for manager flows. Defaults to `false` for this low-level helper. */
|
|
2729
|
+
autoManagePositions?: boolean;
|
|
2730
|
+
/** Optional shared setup context — when provided, setup state (tracked accounts, positions) is shared across calls, preventing duplicate setup instructions. */
|
|
2731
|
+
setupContext?: StrategySetupContext;
|
|
2732
|
+
};
|
|
2940
2733
|
/**
|
|
2941
|
-
* Build
|
|
2734
|
+
* Build one or more vault sync transactions from high-level instruction descriptors.
|
|
2735
|
+
*
|
|
2736
|
+
* This is the plural companion to {@link createVaultSyncTransaction}. Most
|
|
2737
|
+
* calls return a single result. Smart Kamino Vault withdraws can expand into
|
|
2738
|
+
* multiple reserve-specific sync transactions when the wrapper needs to split
|
|
2739
|
+
* an oversized withdraw across sequential chunks.
|
|
2740
|
+
*/
|
|
2741
|
+
export declare function createVaultSyncTransactions(params: CreateVaultSyncTransactionParams): Promise<VaultSyncTransactionResult[]>;
|
|
2742
|
+
/**
|
|
2743
|
+
* Build exactly one vault sync transaction and return its wrapped instruction set.
|
|
2942
2744
|
*
|
|
2943
2745
|
* Takes high-level `VaultInstruction` descriptors (built with `kamino.*`),
|
|
2944
2746
|
* resolves them to raw Solana instructions, then separates them:
|
|
@@ -2948,42 +2750,99 @@ export interface VaultSyncTransactionResult {
|
|
|
2948
2750
|
* KLend's `check_refresh` requires refreshReserve to be a top-level instruction
|
|
2949
2751
|
* so it can be found via the instruction sysvar.
|
|
2950
2752
|
*
|
|
2951
|
-
*
|
|
2952
|
-
*
|
|
2953
|
-
* @
|
|
2954
|
-
* ```ts
|
|
2955
|
-
* const { setupInstructions, preInstructions, instruction, postInstructions, signers, addressLookupTableAddresses } = await createVaultSyncTransaction({
|
|
2956
|
-
* instructions: [
|
|
2957
|
-
* kamino.initUserMetadata(KaminoMarket.MAIN),
|
|
2958
|
-
* kamino.initObligation(KaminoMarket.MAIN),
|
|
2959
|
-
* kamino.deposit(KaminoMarket.MAIN, "USDC", new BN(1_000_000)),
|
|
2960
|
-
* ],
|
|
2961
|
-
* owner: vaultPda,
|
|
2962
|
-
* connection,
|
|
2963
|
-
* policyPda,
|
|
2964
|
-
* vaultPda,
|
|
2965
|
-
* signer: wallet.publicKey,
|
|
2966
|
-
* vaultAddress: VAULT_ADDRESS,
|
|
2967
|
-
* })
|
|
2968
|
-
* // Send: [...setupInstructions, ...preInstructions, instruction, ...postInstructions]
|
|
2969
|
-
* ```
|
|
2753
|
+
* When a smart Kamino Vault withdraw expands beyond one sync transaction, this
|
|
2754
|
+
* singular helper throws and asks the caller to use
|
|
2755
|
+
* {@link createVaultSyncTransactions} or {@link VaultTransactionBuilder}.
|
|
2970
2756
|
*/
|
|
2971
|
-
export declare function createVaultSyncTransaction(
|
|
2972
|
-
|
|
2973
|
-
|
|
2757
|
+
export declare function createVaultSyncTransaction(params: CreateVaultSyncTransactionParams): Promise<VaultSyncTransactionResult>;
|
|
2758
|
+
type TrackedKaminoObligationState = {
|
|
2759
|
+
quotePriceId: ClientPriceId;
|
|
2760
|
+
quoteInputMint: PublicKey;
|
|
2761
|
+
mappedReserves: Set<string>;
|
|
2762
|
+
};
|
|
2763
|
+
type StrategySetupState = {
|
|
2764
|
+
strategyVault: StrategyVault;
|
|
2765
|
+
prices: ExponentPrices;
|
|
2766
|
+
requiredPriceIds: Set<number>;
|
|
2767
|
+
nextStrategyPositionIndex: number;
|
|
2768
|
+
trackedOrderbooks: Set<string>;
|
|
2769
|
+
trackedYieldVaults: Set<string>;
|
|
2770
|
+
trackedKaminoObligations: Map<string, TrackedKaminoObligationState>;
|
|
2771
|
+
trackedKaminoFarms: Set<string>;
|
|
2772
|
+
trackedClmmPositions: Set<string>;
|
|
2773
|
+
tokenEntryAccountByMint: Map<string, string>;
|
|
2774
|
+
tokenPositionIndexByMint: Map<string, number>;
|
|
2775
|
+
trackedTokenAccounts: Set<string>;
|
|
2776
|
+
baseAumAccounts: AccountMeta[];
|
|
2777
|
+
plannedAumAccounts: AccountMeta[];
|
|
2778
|
+
existingAccounts: Map<string, boolean>;
|
|
2779
|
+
};
|
|
2780
|
+
type ResolvedHookAccounts = {
|
|
2781
|
+
leadingAccounts: PublicKey[] | AccountMeta[];
|
|
2782
|
+
preHookAccounts: PublicKey[] | AccountMeta[];
|
|
2783
|
+
postHookAccounts: PublicKey[] | AccountMeta[];
|
|
2784
|
+
};
|
|
2785
|
+
export type StrategySetupContext = {
|
|
2974
2786
|
connection: Connection;
|
|
2975
|
-
|
|
2976
|
-
|
|
2787
|
+
env: Environment;
|
|
2788
|
+
owner: PublicKey;
|
|
2977
2789
|
signer: PublicKey;
|
|
2978
|
-
accountIndex?: number;
|
|
2979
|
-
constraintIndices?: number[];
|
|
2980
|
-
/** ExponentStrategyVault PDA — used to auto-resolve hook accounts from the on-chain policy */
|
|
2981
2790
|
vaultAddress?: PublicKey;
|
|
2791
|
+
policyPda?: PublicKey;
|
|
2792
|
+
vaultPda?: PublicKey;
|
|
2793
|
+
accountIndex: number;
|
|
2794
|
+
squadsProgram: PublicKey;
|
|
2982
2795
|
leadingAccounts?: PublicKey[] | AccountMeta[];
|
|
2983
2796
|
preHookAccounts?: PublicKey[] | AccountMeta[];
|
|
2984
2797
|
postHookAccounts?: PublicKey[] | AccountMeta[];
|
|
2798
|
+
autoManagePositions: boolean;
|
|
2799
|
+
pricesAccount?: ExponentPrices;
|
|
2800
|
+
statePromise?: Promise<StrategySetupState | null>;
|
|
2801
|
+
/** Cached hook resolution promise — avoids redundant RPC calls when wrapping multiple setup instructions. */
|
|
2802
|
+
resolvedHooksPromise?: Promise<ResolvedHookAccounts>;
|
|
2803
|
+
};
|
|
2804
|
+
export declare function createStrategySetupContext({ connection, env, owner, signer, vaultAddress, policyPda, vaultPda, accountIndex, squadsProgram, leadingAccounts, preHookAccounts, postHookAccounts, autoManagePositions, pricesAccount, }: {
|
|
2805
|
+
connection: Connection;
|
|
2806
|
+
env: Environment;
|
|
2807
|
+
owner: PublicKey;
|
|
2808
|
+
signer: PublicKey;
|
|
2809
|
+
vaultAddress?: PublicKey;
|
|
2810
|
+
policyPda?: PublicKey;
|
|
2811
|
+
vaultPda?: PublicKey;
|
|
2812
|
+
accountIndex?: number;
|
|
2985
2813
|
squadsProgram?: PublicKey;
|
|
2986
|
-
|
|
2814
|
+
leadingAccounts?: PublicKey[] | AccountMeta[];
|
|
2815
|
+
preHookAccounts?: PublicKey[] | AccountMeta[];
|
|
2816
|
+
postHookAccounts?: PublicKey[] | AccountMeta[];
|
|
2817
|
+
autoManagePositions?: boolean;
|
|
2818
|
+
pricesAccount?: ExponentPrices;
|
|
2819
|
+
}): StrategySetupContext;
|
|
2820
|
+
export declare function buildSetupStatePriceRefreshInstructions(setupContext: StrategySetupContext): Promise<TransactionInstruction[]>;
|
|
2821
|
+
type KaminoVaultWithdrawPlanningSnapshot = {
|
|
2822
|
+
sharesBalance: BN;
|
|
2823
|
+
tokenAvailable: BN;
|
|
2824
|
+
sharesIssued: BN;
|
|
2825
|
+
pendingFeesSf: BN;
|
|
2826
|
+
reserves: Array<{
|
|
2827
|
+
reserveAddress: PublicKey;
|
|
2828
|
+
investedLiquidityAmount: Decimal;
|
|
2829
|
+
availableLiquidityToWithdraw: Decimal;
|
|
2830
|
+
}>;
|
|
2831
|
+
};
|
|
2832
|
+
type KaminoVaultWithdrawPlanningLeg = {
|
|
2833
|
+
reserveAddress: PublicKey;
|
|
2834
|
+
sharesAmount: BN;
|
|
2835
|
+
};
|
|
2836
|
+
declare function calculateKaminoVaultTokensPerShareFromSnapshot(snapshot: KaminoVaultWithdrawPlanningSnapshot): Decimal;
|
|
2837
|
+
declare function planKaminoVaultWithdrawLegsFromSnapshot(params: {
|
|
2838
|
+
sharesAmount: BN;
|
|
2839
|
+
reserve?: PublicKey;
|
|
2840
|
+
snapshot: KaminoVaultWithdrawPlanningSnapshot;
|
|
2841
|
+
}): KaminoVaultWithdrawPlanningLeg[];
|
|
2842
|
+
export declare const __kaminoVaultTesting: {
|
|
2843
|
+
calculateKaminoVaultTokensPerShareFromSnapshot: typeof calculateKaminoVaultTokensPerShareFromSnapshot;
|
|
2844
|
+
planKaminoVaultWithdrawLegsFromSnapshot: typeof planKaminoVaultWithdrawLegsFromSnapshot;
|
|
2845
|
+
};
|
|
2987
2846
|
/**
|
|
2988
2847
|
* Builder for Exponent Orderbook vault action descriptors.
|
|
2989
2848
|
*
|
|
@@ -3016,17 +2875,13 @@ export declare const orderbookAction: {
|
|
|
3016
2875
|
/**
|
|
3017
2876
|
* Post a limit order on the orderbook.
|
|
3018
2877
|
* @param params - Order parameters
|
|
3019
|
-
* @param params.offerIdx - Required offer index for position tracking. Must be unique per trader.
|
|
3020
2878
|
*/
|
|
3021
2879
|
postOffer(params: {
|
|
3022
2880
|
orderbook: PublicKey;
|
|
3023
2881
|
direction: OrderbookTradeDirection;
|
|
3024
2882
|
priceApy: number;
|
|
3025
2883
|
amount: bigint;
|
|
3026
|
-
/** Required offer index for position tracking. Must be unique per trader. */
|
|
3027
|
-
offerIdx: number;
|
|
3028
2884
|
offerOption?: OrderbookOfferOption;
|
|
3029
|
-
virtualOffer?: boolean;
|
|
3030
2885
|
expirySeconds?: number;
|
|
3031
2886
|
mode?: OrderbookInstructionMode;
|
|
3032
2887
|
}): OrderbookPostOfferInstruction;
|
|
@@ -3142,7 +2997,8 @@ export declare const coreAction: {
|
|
|
3142
2997
|
}): CoreDepositYtInstruction;
|
|
3143
2998
|
/**
|
|
3144
2999
|
* Initialize yield position for the Squads vault (owner).
|
|
3145
|
-
* Required before buying YT or depositing YT.
|
|
3000
|
+
* Required before buying YT or depositing YT. When `autoManagePositions`
|
|
3001
|
+
* is enabled, the SDK also tracks the new yield position automatically.
|
|
3146
3002
|
*/
|
|
3147
3003
|
initializeYieldPosition(params: {
|
|
3148
3004
|
vault: PublicKey;
|
|
@@ -3183,7 +3039,7 @@ export declare function createOrderbookSyncTransaction({ instructions, owner, co
|
|
|
3183
3039
|
owner: PublicKey;
|
|
3184
3040
|
connection: Connection;
|
|
3185
3041
|
policyPda?: PublicKey;
|
|
3186
|
-
vaultPda
|
|
3042
|
+
vaultPda?: PublicKey;
|
|
3187
3043
|
signer: PublicKey;
|
|
3188
3044
|
accountIndex?: number;
|
|
3189
3045
|
constraintIndices?: number[];
|
|
@@ -3220,13 +3076,15 @@ export declare const titanAction: {
|
|
|
3220
3076
|
/**
|
|
3221
3077
|
* Wrap a Titan SwapRouteV2 instruction for vault execution.
|
|
3222
3078
|
* @param params.instruction - Pre-built TransactionInstruction from Titan's router API
|
|
3079
|
+
* @param params.addressLookupTableAddresses - Optional ALT addresses returned by Titan for this route
|
|
3223
3080
|
*/
|
|
3224
3081
|
swap(params: {
|
|
3225
3082
|
instruction: TransactionInstruction;
|
|
3083
|
+
addressLookupTableAddresses?: PublicKey[];
|
|
3226
3084
|
}): TitanSwapInstruction;
|
|
3227
3085
|
};
|
|
3228
3086
|
/**
|
|
3229
|
-
* Builder for Loopscale
|
|
3087
|
+
* Builder for Loopscale action descriptors used in Exponent sync transactions.
|
|
3230
3088
|
*
|
|
3231
3089
|
* Loans (BORROWER side): create/close loan, deposit/withdraw collateral, borrow/repay principal.
|
|
3232
3090
|
* Strategies (LENDER side): create/close strategy, deposit/withdraw into strategy.
|
|
@@ -3341,7 +3199,9 @@ export declare const clmmAction: {
|
|
|
3341
3199
|
/**
|
|
3342
3200
|
* Create a new LP position on the CLMM with a specified tick range.
|
|
3343
3201
|
* The LP position keypair is generated internally — retrieve it from
|
|
3344
|
-
* `result.signers[0]` after calling `createVaultSyncTransaction`.
|
|
3202
|
+
* `result.signers[0]` after calling `createVaultSyncTransaction`. When
|
|
3203
|
+
* `autoManagePositions` is enabled, the SDK also tracks the new LP
|
|
3204
|
+
* position automatically after the deposit sync instruction succeeds.
|
|
3345
3205
|
*
|
|
3346
3206
|
* @param params.market - CLMM MarketThree account address
|
|
3347
3207
|
* @param params.ptInIntent - Maximum PT to deposit
|