@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
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
import type { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for creating a {@link LoopscaleClient}.
|
|
4
|
+
*
|
|
5
|
+
* Import the runtime client from `loopscale-client.ts` or the package barrel.
|
|
6
|
+
*/
|
|
7
|
+
export interface LoopscaleClientConfig {
|
|
8
|
+
/** Solana RPC connection used for transaction decoding helpers. */
|
|
9
|
+
connection: Connection;
|
|
10
|
+
/** Default wallet address used for `user-wallet` / `User-Wallet` headers. */
|
|
11
|
+
userWallet: PublicKey | string;
|
|
12
|
+
/** Optional default fee payer for Loopscale transaction endpoints. Defaults to `userWallet`. */
|
|
13
|
+
payer?: PublicKey | string;
|
|
14
|
+
/** Base URL for the Loopscale API. */
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
/** Enable verbose request/response logging. */
|
|
17
|
+
debug?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Signature metadata returned by Loopscale for a versioned transaction message.
|
|
21
|
+
*/
|
|
22
|
+
export interface LoopscaleTransactionSignature {
|
|
23
|
+
/** Base58 public key of the signer. */
|
|
24
|
+
publicKey: string;
|
|
25
|
+
/** Base64-encoded 64-byte ed25519 signature. */
|
|
26
|
+
signature: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Raw versioned transaction response returned by most Loopscale transaction endpoints.
|
|
30
|
+
*/
|
|
31
|
+
export interface LoopscaleVersionedTransactionResponse {
|
|
32
|
+
/** Base64-encoded versioned transaction message. */
|
|
33
|
+
message: string;
|
|
34
|
+
/** Pre-signed signatures already attached by Loopscale. */
|
|
35
|
+
signatures: LoopscaleTransactionSignature[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Raw batch transaction response returned by multi-transaction Loopscale endpoints.
|
|
39
|
+
*/
|
|
40
|
+
export type LoopscaleVersionedTransactionBatchResponse = LoopscaleVersionedTransactionResponse[];
|
|
41
|
+
/**
|
|
42
|
+
* Minimal post-transaction loan snapshot returned by some Loopscale loan endpoints.
|
|
43
|
+
*/
|
|
44
|
+
export interface LoopscaleExpectedLoanInfo {
|
|
45
|
+
loan?: {
|
|
46
|
+
address?: string;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
};
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Multi-transaction loan response returned by some Loopscale loan endpoints.
|
|
53
|
+
*/
|
|
54
|
+
export interface LoopscaleTransactionsResponse {
|
|
55
|
+
/** One or more serialized transactions returned by Loopscale. */
|
|
56
|
+
transactions: LoopscaleVersionedTransactionResponse[];
|
|
57
|
+
/** Optional post-transaction loan snapshot. */
|
|
58
|
+
expectedLoanInfo?: LoopscaleExpectedLoanInfo;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Raw loan transaction response returned by CPI-compatible loan endpoints.
|
|
62
|
+
*/
|
|
63
|
+
export type LoopscaleLoanTransactionResponse = LoopscaleVersionedTransactionResponse | LoopscaleTransactionsResponse;
|
|
64
|
+
/**
|
|
65
|
+
* Raw response returned by Loopscale loan creation.
|
|
66
|
+
*/
|
|
67
|
+
export interface LoopscaleCreateLoanResponse {
|
|
68
|
+
/** Serialized transaction used to create the loan. */
|
|
69
|
+
transaction: LoopscaleVersionedTransactionResponse;
|
|
70
|
+
/** Derived loan PDA created by the returned transaction. */
|
|
71
|
+
loanAddress: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Union of all raw Loopscale transaction response families supported by the SDK.
|
|
75
|
+
*/
|
|
76
|
+
export type LoopscaleTransactionResponse = LoopscaleVersionedTransactionResponse | LoopscaleVersionedTransactionBatchResponse | LoopscaleTransactionsResponse | LoopscaleCreateLoanResponse;
|
|
77
|
+
/**
|
|
78
|
+
* Request params for `POST /markets/quote`.
|
|
79
|
+
*/
|
|
80
|
+
export interface LoopscaleQuoteParams {
|
|
81
|
+
durationType: number;
|
|
82
|
+
duration: number;
|
|
83
|
+
principal: PublicKey | string;
|
|
84
|
+
collateral: Array<PublicKey | string>;
|
|
85
|
+
limit?: number;
|
|
86
|
+
offset?: number;
|
|
87
|
+
minPrincipalAmount?: bigint | number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Response item returned by `POST /markets/quote`.
|
|
91
|
+
*/
|
|
92
|
+
export interface LoopscaleQuote {
|
|
93
|
+
apy: number;
|
|
94
|
+
ltv: number;
|
|
95
|
+
liquidationThreshold: number;
|
|
96
|
+
maxPrincipalAvailable: number;
|
|
97
|
+
sumPrincipalAvailable?: number;
|
|
98
|
+
[key: string]: unknown;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Request params for `POST /markets/quote/max`.
|
|
102
|
+
*/
|
|
103
|
+
export interface LoopscaleMaxQuoteParams {
|
|
104
|
+
durationType: number;
|
|
105
|
+
duration: number;
|
|
106
|
+
principalMint: PublicKey | string;
|
|
107
|
+
collateralFilter: Array<{
|
|
108
|
+
amount: bigint | number;
|
|
109
|
+
assetData: {
|
|
110
|
+
Spl: {
|
|
111
|
+
mint: string;
|
|
112
|
+
};
|
|
113
|
+
} | {
|
|
114
|
+
Orca: {
|
|
115
|
+
positionMint: string;
|
|
116
|
+
whirlpool: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
}>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Quote item returned by `POST /markets/quote/max`.
|
|
123
|
+
*/
|
|
124
|
+
export interface LoopscaleMaxQuote {
|
|
125
|
+
apy: number;
|
|
126
|
+
strategy: string;
|
|
127
|
+
collateralIdentifier: string;
|
|
128
|
+
ltv: number;
|
|
129
|
+
lqt: number;
|
|
130
|
+
amount: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Request params for `POST /markets/loans/info`.
|
|
134
|
+
*
|
|
135
|
+
* This matches the documented request body. The observed response is a single
|
|
136
|
+
* object with `totalCount` and `loanInfos`.
|
|
137
|
+
*/
|
|
138
|
+
export interface LoopscaleLoanInfoParams {
|
|
139
|
+
loanAddresses?: string[];
|
|
140
|
+
lenders?: string[];
|
|
141
|
+
borrowers?: string[];
|
|
142
|
+
filterType?: number;
|
|
143
|
+
principalMints?: string[];
|
|
144
|
+
collateralMints?: string[];
|
|
145
|
+
orderFundingType?: number;
|
|
146
|
+
page?: number;
|
|
147
|
+
pageSize?: number;
|
|
148
|
+
sortDirection?: number;
|
|
149
|
+
sortType?: number;
|
|
150
|
+
assetTypes?: number;
|
|
151
|
+
excludeCollateralIdentifiers?: string[];
|
|
152
|
+
excludePrincipalMints?: string[];
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Response returned by `POST /markets/loans/info`.
|
|
156
|
+
*/
|
|
157
|
+
export interface LoopscaleLoanInfoResponse {
|
|
158
|
+
totalCount: number;
|
|
159
|
+
principalMints?: string[];
|
|
160
|
+
collateralMints?: string[];
|
|
161
|
+
loanInfos: Array<{
|
|
162
|
+
loan: {
|
|
163
|
+
address: string;
|
|
164
|
+
loanStatus: number;
|
|
165
|
+
borrower: string;
|
|
166
|
+
startTime: number;
|
|
167
|
+
[key: string]: unknown;
|
|
168
|
+
};
|
|
169
|
+
loanType: number;
|
|
170
|
+
ledgers: Array<{
|
|
171
|
+
ledgerIndex: number;
|
|
172
|
+
strategy: string;
|
|
173
|
+
principalMint: string;
|
|
174
|
+
principalDue: number;
|
|
175
|
+
interestOutstanding: number;
|
|
176
|
+
apy: number;
|
|
177
|
+
endTime: number;
|
|
178
|
+
[key: string]: unknown;
|
|
179
|
+
}>;
|
|
180
|
+
collateral: Array<{
|
|
181
|
+
assetMint: string;
|
|
182
|
+
amount: number;
|
|
183
|
+
assetType: number;
|
|
184
|
+
[key: string]: unknown;
|
|
185
|
+
}>;
|
|
186
|
+
[key: string]: unknown;
|
|
187
|
+
}>;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Request params for `POST /markets/strategy/infos`.
|
|
191
|
+
*/
|
|
192
|
+
export interface LoopscaleGetStrategiesParams {
|
|
193
|
+
userAddress?: string;
|
|
194
|
+
addresses?: string[];
|
|
195
|
+
principalMints?: string[];
|
|
196
|
+
page?: number;
|
|
197
|
+
pageSize?: number;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Response returned by `POST /markets/strategy/infos`.
|
|
201
|
+
*/
|
|
202
|
+
export interface LoopscaleStrategyInfoResponse {
|
|
203
|
+
strategies: Array<{
|
|
204
|
+
strategy: {
|
|
205
|
+
address: string;
|
|
206
|
+
principalMint: string;
|
|
207
|
+
tokenBalance: number;
|
|
208
|
+
currentDeployedAmount: number;
|
|
209
|
+
outstandingInterestAmount: number;
|
|
210
|
+
[key: string]: unknown;
|
|
211
|
+
};
|
|
212
|
+
externalYieldInfo?: {
|
|
213
|
+
apy: number;
|
|
214
|
+
[key: string]: unknown;
|
|
215
|
+
};
|
|
216
|
+
[key: string]: unknown;
|
|
217
|
+
}>;
|
|
218
|
+
total: number;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Strategy create request for `POST /markets/strategy/create`.
|
|
222
|
+
*/
|
|
223
|
+
export interface LoopscaleCreateStrategyParams {
|
|
224
|
+
principalMint: PublicKey | string;
|
|
225
|
+
lender: PublicKey | string;
|
|
226
|
+
amount: bigint | number;
|
|
227
|
+
originationsEnabled?: boolean;
|
|
228
|
+
liquidityBuffer?: number;
|
|
229
|
+
interestFee?: number;
|
|
230
|
+
originationFee?: number;
|
|
231
|
+
originationCap?: number;
|
|
232
|
+
collateralTerms?: Array<{
|
|
233
|
+
apy: number;
|
|
234
|
+
indices: Array<{
|
|
235
|
+
collateralIndex: number;
|
|
236
|
+
durationIndex: number;
|
|
237
|
+
}>;
|
|
238
|
+
}>;
|
|
239
|
+
marketInformation?: PublicKey | string;
|
|
240
|
+
externalYieldSourceArgs?: TxnExternalYieldSourceArgs;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Strategy deposit request for `POST /markets/strategy/deposit`.
|
|
244
|
+
*/
|
|
245
|
+
export interface LoopscaleDepositStrategyParams {
|
|
246
|
+
strategy: PublicKey | string;
|
|
247
|
+
amount: bigint | number;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Strategy withdraw request for `POST /markets/strategy/withdraw`.
|
|
251
|
+
*/
|
|
252
|
+
export interface LoopscaleWithdrawStrategyParams {
|
|
253
|
+
strategy: PublicKey | string;
|
|
254
|
+
amount: bigint | number;
|
|
255
|
+
withdrawAll: boolean;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Strategy close request for `POST /markets/strategy/close/{strategy}`.
|
|
259
|
+
*/
|
|
260
|
+
export interface LoopscaleCloseStrategyParams {
|
|
261
|
+
strategy: PublicKey | string;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* External yield source configuration used by Loopscale strategy endpoints.
|
|
265
|
+
*/
|
|
266
|
+
export interface ExternalYieldSourceParams {
|
|
267
|
+
newExternalYieldSource: number;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Strategy create args for initializing external yield state through Loopscale.
|
|
271
|
+
*/
|
|
272
|
+
export interface TxnExternalYieldSourceArgs extends ExternalYieldSourceParams {
|
|
273
|
+
createExternalYieldAccount: boolean;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Duration tuple used by strategy collateral configuration.
|
|
277
|
+
*/
|
|
278
|
+
export interface StrategyDuration {
|
|
279
|
+
duration: number;
|
|
280
|
+
durationType: number;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Strategy collateral add args.
|
|
284
|
+
*/
|
|
285
|
+
export interface AddCollateralArgs {
|
|
286
|
+
durationsAndApys?: Record<string, string>;
|
|
287
|
+
externalMarketInformationAddress?: string;
|
|
288
|
+
marketInformation?: Record<string, unknown>;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Strategy collateral remove args.
|
|
292
|
+
*/
|
|
293
|
+
export interface RemoveCollateralArgs {
|
|
294
|
+
durations: StrategyDuration[];
|
|
295
|
+
removeFromMarketInformation: boolean;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Strategy collateral param update args.
|
|
299
|
+
*/
|
|
300
|
+
export interface CollateralParamsUpdateArgs {
|
|
301
|
+
ltvUpdate?: Record<string, unknown>;
|
|
302
|
+
apyUpdate?: Record<string, string>;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Strategy allocation update args.
|
|
306
|
+
*/
|
|
307
|
+
export interface CollateralAllocationUpdateArgs {
|
|
308
|
+
assetIdentifier: string;
|
|
309
|
+
maxAllocationPct: string;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Strategy collateral update payload for `POST /markets/strategy/update`.
|
|
313
|
+
*/
|
|
314
|
+
export interface StrategyCollateralUpdates {
|
|
315
|
+
addCollateral?: Record<string, AddCollateralArgs>;
|
|
316
|
+
removeCollateral?: Record<string, RemoveCollateralArgs>;
|
|
317
|
+
updateCollateral?: Record<string, CollateralParamsUpdateArgs>;
|
|
318
|
+
updateAssetAllocation?: CollateralAllocationUpdateArgs[];
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Strategy settings update payload for `POST /markets/strategy/update`.
|
|
322
|
+
*/
|
|
323
|
+
export interface EditStrategySettingsArgs {
|
|
324
|
+
originationsEnabled?: boolean;
|
|
325
|
+
liquidityBuffer?: number;
|
|
326
|
+
interestFee?: number;
|
|
327
|
+
originationFee?: number;
|
|
328
|
+
principalFee?: number;
|
|
329
|
+
originationCap?: number;
|
|
330
|
+
externalYieldSource?: ExternalYieldSourceParams;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Strategy update request for `POST /markets/strategy/update`.
|
|
334
|
+
*/
|
|
335
|
+
export interface LoopscaleUpdateStrategyParams {
|
|
336
|
+
strategy: PublicKey | string;
|
|
337
|
+
collateralTerms?: StrategyCollateralUpdates;
|
|
338
|
+
updateParams?: EditStrategySettingsArgs;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Loan create request for `POST /markets/creditbook/create`.
|
|
342
|
+
*/
|
|
343
|
+
export interface LoopscaleCreateLoanParams {
|
|
344
|
+
borrower: PublicKey | string;
|
|
345
|
+
depositCollateral: Array<{
|
|
346
|
+
collateralAmount: bigint | number;
|
|
347
|
+
collateralAssetData: {
|
|
348
|
+
Spl: {
|
|
349
|
+
mint: string;
|
|
350
|
+
};
|
|
351
|
+
} | {
|
|
352
|
+
Orca: {
|
|
353
|
+
positionMint: string;
|
|
354
|
+
whirlpool: string;
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
}>;
|
|
358
|
+
principalRequested: Array<{
|
|
359
|
+
ledgerIndex: number;
|
|
360
|
+
principalAmount: bigint | number;
|
|
361
|
+
principalMint: PublicKey | string;
|
|
362
|
+
strategy: PublicKey | string;
|
|
363
|
+
durationIndex: number;
|
|
364
|
+
expectedLoanValues?: {
|
|
365
|
+
expectedApy?: number;
|
|
366
|
+
expectedLqt?: number[];
|
|
367
|
+
};
|
|
368
|
+
}>;
|
|
369
|
+
assetIndexGuidance?: number[];
|
|
370
|
+
loanNonce?: string;
|
|
371
|
+
isLoop?: boolean;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Loan borrow request for `POST /markets/creditbook/borrow`.
|
|
375
|
+
*/
|
|
376
|
+
export interface LoopscaleBorrowPrincipalParams {
|
|
377
|
+
loan: PublicKey | string;
|
|
378
|
+
borrowParams: {
|
|
379
|
+
amount: bigint | number;
|
|
380
|
+
durationIndex: number;
|
|
381
|
+
expectedLoanValues?: {
|
|
382
|
+
expectedApy?: number;
|
|
383
|
+
expectedLqt?: number[];
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
strategy: PublicKey | string;
|
|
387
|
+
refinanceParams?: {
|
|
388
|
+
ledgerIndex: number;
|
|
389
|
+
durationIndex: number;
|
|
390
|
+
};
|
|
391
|
+
isLoop?: boolean;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Loan collateral deposit request for `POST /markets/creditbook/collateral/deposit`.
|
|
395
|
+
*/
|
|
396
|
+
export interface LoopscaleDepositCollateralParams {
|
|
397
|
+
loan: PublicKey | string;
|
|
398
|
+
depositMint: PublicKey | string;
|
|
399
|
+
amount: bigint | number;
|
|
400
|
+
assetType: number;
|
|
401
|
+
assetIdentifier: PublicKey | string;
|
|
402
|
+
assetIndexGuidance?: number[];
|
|
403
|
+
expectedLoanValues?: {
|
|
404
|
+
expectedApy?: number;
|
|
405
|
+
expectedLqt?: number[];
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Loan collateral withdraw request for `POST /markets/creditbook/collateral/withdraw`.
|
|
410
|
+
*/
|
|
411
|
+
export interface LoopscaleWithdrawCollateralParams {
|
|
412
|
+
loan: PublicKey | string;
|
|
413
|
+
collateralMint: PublicKey | string;
|
|
414
|
+
amount: bigint | number;
|
|
415
|
+
collateralIndex: number;
|
|
416
|
+
expectedLoanValues: {
|
|
417
|
+
expectedApy?: number;
|
|
418
|
+
expectedLqt?: number[];
|
|
419
|
+
};
|
|
420
|
+
assetIndexGuidance?: number[];
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Supported Loopscale strategy + loan instruction names recognized by the SDK.
|
|
424
|
+
*/
|
|
425
|
+
export type LoopscaleInstructionName = "createLoan" | "depositCollateral" | "borrowPrincipal" | "repayPrincipal" | "withdrawCollateral" | "closeLoan" | "updateWeightMatrix" | "lockLoan" | "unlockLoan" | "createStrategy" | "depositStrategy" | "withdrawStrategy" | "closeStrategy" | "updateStrategy" | "refinanceLedger";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopscale-client.types.js","sourceRoot":"","sources":["../../src/exponentVaults/loopscale-client.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { type AccountMeta, type AddressLookupTableAccount, type Commitment, type SendOptions, type Signer, Connection, PublicKey, TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
import { type LoopscaleInstruction } from "./vault-interaction";
|
|
3
|
+
import type { LoopscaleTransactionResponse } from "./loopscale-client.types";
|
|
4
|
+
/**
|
|
5
|
+
* A wrapped Loopscale batch that can be executed through the Exponent sync flow.
|
|
6
|
+
*
|
|
7
|
+
* `preInstructions` and `postInstructions` are top-level instructions hoisted
|
|
8
|
+
* from the raw Loopscale transaction. `syncInstructions` are the original
|
|
9
|
+
* Loopscale program instructions, wrapped minimally for `createVaultSyncTransaction`.
|
|
10
|
+
*/
|
|
11
|
+
export interface LoopscaleSyncBatch {
|
|
12
|
+
kind: "sync";
|
|
13
|
+
preInstructions: TransactionInstruction[];
|
|
14
|
+
syncInstructions: LoopscaleInstruction[];
|
|
15
|
+
postInstructions: TransactionInstruction[];
|
|
16
|
+
signers: Signer[];
|
|
17
|
+
addressLookupTableAddresses: PublicKey[];
|
|
18
|
+
rawTransaction: VersionedTransaction;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A raw top-level transaction batch that does not contain any Loopscale
|
|
22
|
+
* program instructions and therefore must not be wrapped in a Squads sync
|
|
23
|
+
* transaction.
|
|
24
|
+
*/
|
|
25
|
+
export interface LoopscaleStandaloneBatch {
|
|
26
|
+
kind: "standalone";
|
|
27
|
+
instructions: TransactionInstruction[];
|
|
28
|
+
signers: Signer[];
|
|
29
|
+
addressLookupTableAddresses: PublicKey[];
|
|
30
|
+
rawTransaction: VersionedTransaction;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A single executable batch derived from a raw Loopscale response.
|
|
34
|
+
*/
|
|
35
|
+
export type LoopscaleExecutionBatch = LoopscaleSyncBatch | LoopscaleStandaloneBatch;
|
|
36
|
+
/**
|
|
37
|
+
* Minimal execution plan derived from a raw Loopscale response.
|
|
38
|
+
*/
|
|
39
|
+
export interface LoopscaleExecutionPlan {
|
|
40
|
+
/** Executable batches in the same order Loopscale returned them. */
|
|
41
|
+
batches: LoopscaleExecutionBatch[];
|
|
42
|
+
/** Deserialized raw transactions returned by Loopscale. */
|
|
43
|
+
rawTransactions: VersionedTransaction[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Execution context for sending a Loopscale execution plan through Exponent.
|
|
47
|
+
*/
|
|
48
|
+
export interface LoopscaleExecutionContext {
|
|
49
|
+
connection: Connection;
|
|
50
|
+
owner: PublicKey;
|
|
51
|
+
vaultPda: PublicKey;
|
|
52
|
+
signer: PublicKey;
|
|
53
|
+
signers: Signer[];
|
|
54
|
+
vaultAddress?: PublicKey;
|
|
55
|
+
accountIndex?: number;
|
|
56
|
+
policyPda?: PublicKey;
|
|
57
|
+
constraintIndices?: number[];
|
|
58
|
+
leadingAccounts?: PublicKey[] | AccountMeta[];
|
|
59
|
+
preHookAccounts?: PublicKey[] | AccountMeta[];
|
|
60
|
+
postHookAccounts?: PublicKey[] | AccountMeta[];
|
|
61
|
+
squadsProgram?: PublicKey;
|
|
62
|
+
addressLookupTableAccounts?: AddressLookupTableAccount[];
|
|
63
|
+
prependInstructions?: TransactionInstruction[];
|
|
64
|
+
sendOptions?: SendOptions;
|
|
65
|
+
commitment?: Commitment;
|
|
66
|
+
/**
|
|
67
|
+
* Optional co-signing hook used for sync batches.
|
|
68
|
+
*
|
|
69
|
+
* When omitted, sync batches are sent without additional Loopscale co-signing.
|
|
70
|
+
*/
|
|
71
|
+
coSign?: (transaction: VersionedTransaction) => Promise<VersionedTransaction>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Result for a single sent transaction while executing a Loopscale execution plan.
|
|
75
|
+
*/
|
|
76
|
+
export interface LoopscaleBatchExecutionResult {
|
|
77
|
+
batchIndex: number;
|
|
78
|
+
kind: "setup" | "sync" | "standalone";
|
|
79
|
+
signature: string;
|
|
80
|
+
logs: string[] | null;
|
|
81
|
+
error: unknown;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Aggregate result for {@link executeLoopscaleExecutionPlan}.
|
|
85
|
+
*/
|
|
86
|
+
export interface LoopscaleExecutionResult {
|
|
87
|
+
error: unknown;
|
|
88
|
+
results: LoopscaleBatchExecutionResult[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Convert a raw Loopscale strategy or CPI-compatible loan response into an
|
|
92
|
+
* Exponent execution plan.
|
|
93
|
+
*
|
|
94
|
+
* The adapter preserves transaction boundaries while classifying each returned
|
|
95
|
+
* transaction into:
|
|
96
|
+
* 1. standalone top-level batches for contiguous non-Loopscale prefixes/suffixes
|
|
97
|
+
* 2. wrapped Loopscale sync batches containing only compute-budget prefixes and
|
|
98
|
+
* Loopscale program instructions
|
|
99
|
+
*
|
|
100
|
+
* This keeps the wrapped sync transaction small and preserves the relative
|
|
101
|
+
* ordering of any safe top-level setup/finalization work Loopscale includes
|
|
102
|
+
* around the CPI-compatible instruction segment.
|
|
103
|
+
*
|
|
104
|
+
* Loopscale loan maintenance responses such as `repayPrincipal`,
|
|
105
|
+
* `withdrawCollateral`, `updateWeightMatrix`, and `closeLoan` are supported as
|
|
106
|
+
* long as they are returned directly by Loopscale in a clean sync segment.
|
|
107
|
+
* Unsupported instructions such as `lockLoan`, `unlockLoan`, or
|
|
108
|
+
* `refinanceLedger` still throw instead of being guessed into the sync
|
|
109
|
+
* segment.
|
|
110
|
+
*/
|
|
111
|
+
export declare function createLoopscaleExecutionPlan({ connection, response, }: {
|
|
112
|
+
connection: Connection;
|
|
113
|
+
response: LoopscaleTransactionResponse;
|
|
114
|
+
}): Promise<LoopscaleExecutionPlan>;
|
|
115
|
+
/**
|
|
116
|
+
* Execute a previously created Loopscale execution plan.
|
|
117
|
+
*
|
|
118
|
+
* Sync batches are wrapped into Squads sync transactions and optionally passed
|
|
119
|
+
* through `context.coSign`. Standalone batches are sent as regular top-level
|
|
120
|
+
* transactions without wrapping.
|
|
121
|
+
*/
|
|
122
|
+
export declare function executeLoopscaleExecutionPlan({ plan, context, }: {
|
|
123
|
+
plan: LoopscaleExecutionPlan;
|
|
124
|
+
context: LoopscaleExecutionContext;
|
|
125
|
+
}): Promise<LoopscaleExecutionResult>;
|