@anywalletkit/protocol-lending-kamino-solana 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +96 -2
- package/dist/index.cjs +759 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +445 -0
- package/dist/index.d.ts +445 -0
- package/dist/index.js +736 -0
- package/dist/index.js.map +1 -0
- package/module.json +11 -0
- package/package.json +64 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { LendingProtocol, IWalletAccountReadOnly, IWalletAccount, SupplyOptions, LendingQuote, LendingResult, WithdrawOptions, BorrowOptions, RepayOptions } from '@anywalletkit/core';
|
|
2
|
+
|
|
3
|
+
type AmountOption = bigint | number | 'max';
|
|
4
|
+
/** Base-unit amount: a positive bigint or safe integer. */
|
|
5
|
+
declare function toAmount(amount: bigint | number | string | undefined): bigint;
|
|
6
|
+
/** Base units → the decimal string Kamino's API takes ("1.5" for 1_500_000n at 6 decimals). */
|
|
7
|
+
declare function toDecimalString(amount: bigint, decimals: number): string;
|
|
8
|
+
/** Decimal string → base units, rounded down (the API reports decimals; the chain counts base units). */
|
|
9
|
+
declare function fromDecimalString(value: string | number, decimals: number): bigint;
|
|
10
|
+
/** Fixed-point helper: `value` (decimal string) scaled by 1e18. */
|
|
11
|
+
declare const WAD: bigint;
|
|
12
|
+
declare const toWad: (value: string | number) => bigint;
|
|
13
|
+
declare const mulWad: (a: bigint, wad: bigint) => bigint;
|
|
14
|
+
declare const divWadUp: (a: bigint, wad: bigint) => bigint;
|
|
15
|
+
/** `amount × (10_000 − bps) / 10_000`, rounded down. */
|
|
16
|
+
declare const lessBps: (amount: bigint, bps: number) => bigint;
|
|
17
|
+
|
|
18
|
+
declare const KAMINO_API = "https://api.kamino.finance";
|
|
19
|
+
/** Kamino's Main Market. */
|
|
20
|
+
declare const MAIN_MARKET = "7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF";
|
|
21
|
+
/** The decimal string that means "every share" on /ktx/kvault/withdraw. */
|
|
22
|
+
declare const WITHDRAW_ALL = "18446744073709551615";
|
|
23
|
+
interface ApiMarket {
|
|
24
|
+
lendingMarket: string;
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
isPrimary: boolean;
|
|
28
|
+
isCurated: boolean;
|
|
29
|
+
lookupTable: string | null;
|
|
30
|
+
}
|
|
31
|
+
interface ApiReserve {
|
|
32
|
+
reserve: string;
|
|
33
|
+
symbol: string;
|
|
34
|
+
mint: string;
|
|
35
|
+
/** Fraction (0.74). */
|
|
36
|
+
maxLtv: number;
|
|
37
|
+
/** Percent. */
|
|
38
|
+
supplyApy: number;
|
|
39
|
+
borrowApy: number;
|
|
40
|
+
/** Decimal strings in token units. */
|
|
41
|
+
totalSupply: string;
|
|
42
|
+
totalBorrow: string;
|
|
43
|
+
totalSupplyUsd: number;
|
|
44
|
+
totalBorrowUsd: number;
|
|
45
|
+
}
|
|
46
|
+
interface ApiVaultAllocation {
|
|
47
|
+
reserve: string;
|
|
48
|
+
targetAllocationWeight: number;
|
|
49
|
+
tokenAllocationCap: bigint;
|
|
50
|
+
}
|
|
51
|
+
interface ApiVault {
|
|
52
|
+
address: string;
|
|
53
|
+
programId: string;
|
|
54
|
+
name: string;
|
|
55
|
+
tokenMint: string;
|
|
56
|
+
tokenMintDecimals: number;
|
|
57
|
+
tokenProgram: string;
|
|
58
|
+
sharesMint: string;
|
|
59
|
+
sharesMintDecimals: number;
|
|
60
|
+
/** Base units. */
|
|
61
|
+
tokenAvailable: bigint;
|
|
62
|
+
sharesIssued: bigint;
|
|
63
|
+
minDepositAmount: bigint;
|
|
64
|
+
minWithdrawAmount: bigint;
|
|
65
|
+
performanceFeeBps: number;
|
|
66
|
+
managementFeeBps: number;
|
|
67
|
+
vaultFarm: string | null;
|
|
68
|
+
vaultLookupTable: string | null;
|
|
69
|
+
allocations: ApiVaultAllocation[];
|
|
70
|
+
}
|
|
71
|
+
interface ApiVaultMetrics {
|
|
72
|
+
/** Percent, net of fees. */
|
|
73
|
+
apy: number;
|
|
74
|
+
apy24h: number;
|
|
75
|
+
apy7d: number;
|
|
76
|
+
apy30d: number;
|
|
77
|
+
apyActual: number;
|
|
78
|
+
apyFarmRewards: number;
|
|
79
|
+
/** Decimal strings. */
|
|
80
|
+
tokenPrice: string;
|
|
81
|
+
sharePrice: string;
|
|
82
|
+
tokensPerShare: string;
|
|
83
|
+
tokensAvailable: string;
|
|
84
|
+
tokensInvested: string;
|
|
85
|
+
tokensInvestedUsd: string;
|
|
86
|
+
sharesIssued: string;
|
|
87
|
+
numberOfHolders: number;
|
|
88
|
+
}
|
|
89
|
+
interface ApiVaultPosition {
|
|
90
|
+
vaultAddress: string;
|
|
91
|
+
stakedShares: string;
|
|
92
|
+
unstakedShares: string;
|
|
93
|
+
totalShares: string;
|
|
94
|
+
}
|
|
95
|
+
interface ApiLoanLeg {
|
|
96
|
+
mint: string;
|
|
97
|
+
symbol: string;
|
|
98
|
+
amount: string;
|
|
99
|
+
valueUsd: string;
|
|
100
|
+
}
|
|
101
|
+
interface ApiObligation {
|
|
102
|
+
obligation: string;
|
|
103
|
+
market: string;
|
|
104
|
+
user: string;
|
|
105
|
+
elevationGroup: number;
|
|
106
|
+
deposits: ApiLoanLeg[];
|
|
107
|
+
borrows: ApiLoanLeg[];
|
|
108
|
+
/** Fractions. */
|
|
109
|
+
currentLtv: number;
|
|
110
|
+
maxLtv: number | null;
|
|
111
|
+
liquidationLtv: number;
|
|
112
|
+
raw: unknown;
|
|
113
|
+
}
|
|
114
|
+
interface KtxVaultDeposit {
|
|
115
|
+
wallet: string;
|
|
116
|
+
kvault: string;
|
|
117
|
+
amount: string;
|
|
118
|
+
skipFarm?: boolean | undefined;
|
|
119
|
+
memo?: string | undefined;
|
|
120
|
+
}
|
|
121
|
+
interface KtxVaultWithdraw {
|
|
122
|
+
wallet: string;
|
|
123
|
+
kvault: string;
|
|
124
|
+
amount: string;
|
|
125
|
+
closeUserState?: boolean | undefined;
|
|
126
|
+
memo?: string | undefined;
|
|
127
|
+
}
|
|
128
|
+
interface KtxLend {
|
|
129
|
+
wallet: string;
|
|
130
|
+
market: string;
|
|
131
|
+
reserve: string;
|
|
132
|
+
amount: string;
|
|
133
|
+
memo?: string | undefined;
|
|
134
|
+
}
|
|
135
|
+
declare class KaminoApi {
|
|
136
|
+
private readonly endpoint;
|
|
137
|
+
private readonly fetchImpl;
|
|
138
|
+
constructor(endpoint?: string, fetchImpl?: typeof fetch);
|
|
139
|
+
private request;
|
|
140
|
+
/** Every Kamino Lend market (Main Market first). */
|
|
141
|
+
listMarkets(): Promise<ApiMarket[]>;
|
|
142
|
+
/** A market's reserves with live rates. */
|
|
143
|
+
getReserves(market: string): Promise<ApiReserve[]>;
|
|
144
|
+
private vault;
|
|
145
|
+
/** Every Earn vault (kVault) on the mainnet program. */
|
|
146
|
+
listVaults(): Promise<ApiVault[]>;
|
|
147
|
+
getVault(vault: string): Promise<ApiVault>;
|
|
148
|
+
getVaultMetrics(vault: string): Promise<ApiVaultMetrics>;
|
|
149
|
+
/** The user's shares in one vault; a user the vault has never seen is a zero position. */
|
|
150
|
+
getVaultPosition(user: string, vault: string): Promise<ApiVaultPosition>;
|
|
151
|
+
listVaultPositions(user: string): Promise<ApiVaultPosition[]>;
|
|
152
|
+
private obligation;
|
|
153
|
+
/** The user's obligations (loans) in a market. */
|
|
154
|
+
getUserObligations(market: string, user: string): Promise<ApiObligation[]>;
|
|
155
|
+
private ktx;
|
|
156
|
+
/** Base64 unsigned v0 transaction: deposit `amount` (decimal, token units) into an Earn vault. */
|
|
157
|
+
buildVaultDeposit(p: KtxVaultDeposit): Promise<string>;
|
|
158
|
+
/** Base64 unsigned v0 transaction: redeem `amount` SHARES (decimal) — {@link WITHDRAW_ALL} for every share. */
|
|
159
|
+
buildVaultWithdraw(p: KtxVaultWithdraw): Promise<string>;
|
|
160
|
+
buildLendDeposit(p: KtxLend): Promise<string>;
|
|
161
|
+
buildLendWithdraw(p: KtxLend): Promise<string>;
|
|
162
|
+
buildLendBorrow(p: KtxLend): Promise<string>;
|
|
163
|
+
buildLendRepay(p: KtxLend): Promise<string>;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare const SOLANA_MAINNET = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
167
|
+
declare const WSOL_MINT = "So11111111111111111111111111111111111111112";
|
|
168
|
+
/** SOL allowance for rent (ATAs, farm user state) and priority fees on top of the amount itself. */
|
|
169
|
+
declare const DEFAULT_RENT_ALLOWANCE = 10000000n;
|
|
170
|
+
/** Extra SOL a first Lend deposit needs: obligation (~0.024), user metadata, lookup table, ATAs. */
|
|
171
|
+
declare const DEFAULT_FIRST_DEPOSIT_ALLOWANCE = 45000000n;
|
|
172
|
+
/** Decimals of mints Kamino lists, for accounts that cannot read mints (fixtures, read-only without RPC). */
|
|
173
|
+
declare const KNOWN_DECIMALS: Readonly<Record<string, number>>;
|
|
174
|
+
interface KaminoBaseConfig {
|
|
175
|
+
/** API endpoint or a prepared client (default api.kamino.finance). */
|
|
176
|
+
api?: string | KaminoApi;
|
|
177
|
+
/** fetch implementation for the API (default global fetch). */
|
|
178
|
+
fetch?: typeof fetch;
|
|
179
|
+
/** Tolerance on what the wallet must receive on withdrawals / borrows, in basis points (default 50). */
|
|
180
|
+
slippageBps?: number;
|
|
181
|
+
/** SOL the transaction may spend on rent and fees beyond the amount (default 0.01 SOL). */
|
|
182
|
+
rentAllowanceLamports?: bigint | number;
|
|
183
|
+
/** SPL memo (≤ 64 bytes) the API adds to every transaction. */
|
|
184
|
+
memo?: string;
|
|
185
|
+
}
|
|
186
|
+
/** What the guard proves before signing (mirrors wallet-solana's `SerializedExpectation`). */
|
|
187
|
+
interface Expectation {
|
|
188
|
+
maxLamportsOut: bigint;
|
|
189
|
+
tokenIn?: {
|
|
190
|
+
mint: string;
|
|
191
|
+
minAmount: bigint;
|
|
192
|
+
};
|
|
193
|
+
maxTokenOut?: {
|
|
194
|
+
mint: string;
|
|
195
|
+
amount: bigint;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
interface SerializedGuard {
|
|
199
|
+
programAllowlist: readonly string[];
|
|
200
|
+
expect: Expectation;
|
|
201
|
+
}
|
|
202
|
+
/** The write surface of a `@anywalletkit/wallet-solana` account this module needs. */
|
|
203
|
+
interface SolanaAccountSurface {
|
|
204
|
+
getAddress(): Promise<string>;
|
|
205
|
+
checkSerialized?(base64: string, guard: SerializedGuard): Promise<{
|
|
206
|
+
quote: {
|
|
207
|
+
fee: bigint;
|
|
208
|
+
};
|
|
209
|
+
}>;
|
|
210
|
+
sendSerialized?(base64: string, guard: SerializedGuard): Promise<{
|
|
211
|
+
hash: string;
|
|
212
|
+
fee: bigint;
|
|
213
|
+
}>;
|
|
214
|
+
getMintInfo?(mint: string): Promise<{
|
|
215
|
+
decimals: number;
|
|
216
|
+
}>;
|
|
217
|
+
}
|
|
218
|
+
declare abstract class KaminoBase<TConfig extends KaminoBaseConfig> extends LendingProtocol<TConfig> {
|
|
219
|
+
readonly api: KaminoApi;
|
|
220
|
+
protected readonly slippageBps: number;
|
|
221
|
+
protected readonly rentAllowance: bigint;
|
|
222
|
+
private readonly _decimals;
|
|
223
|
+
constructor(account: IWalletAccountReadOnly | IWalletAccount, config: TConfig);
|
|
224
|
+
/** Refuse anything that is not a mainnet Solana account before an API call is made in its name. */
|
|
225
|
+
protected requireSolana(): void;
|
|
226
|
+
protected surface(): SolanaAccountSurface;
|
|
227
|
+
protected me(): Promise<string>;
|
|
228
|
+
/** Mint decimals: the account reads the mint when it can; well-known mints need no RPC. */
|
|
229
|
+
protected decimals(mint: string): Promise<number>;
|
|
230
|
+
protected guard(expect: Expectation): SerializedGuard;
|
|
231
|
+
/** The wallet sends `amount` of `mint` (SOL counts on the lamport side) and may lose rent on top. */
|
|
232
|
+
protected spendExpectation(mint: string, amount: bigint, extraLamports?: bigint): Expectation;
|
|
233
|
+
/** The wallet must receive at least `expected × (1 − slippage)` of `mint`; rent is the only SOL it may lose. */
|
|
234
|
+
protected receiveExpectation(mint: string, expected: bigint, extraLamports?: bigint): Expectation;
|
|
235
|
+
/** Simulate the built transaction through the account's guard and return its fee; nothing is signed. */
|
|
236
|
+
protected quoteBuilt(base64: string, expect: Expectation): Promise<{
|
|
237
|
+
fee: bigint;
|
|
238
|
+
}>;
|
|
239
|
+
/** Guard, sign and broadcast the built transaction; the account refuses before signing if the proof fails. */
|
|
240
|
+
protected sendBuilt(base64: string, expect: Expectation, method: string): Promise<{
|
|
241
|
+
hash: string;
|
|
242
|
+
fee: bigint;
|
|
243
|
+
}>;
|
|
244
|
+
protected memo(): string | undefined;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
interface KaminoVaultConfig extends KaminoBaseConfig {
|
|
248
|
+
/** The Earn vault (kVault) address. */
|
|
249
|
+
vault: string;
|
|
250
|
+
/** Keep the shares in the wallet instead of staking them in the vault farm (default false — staked, as the Kamino app does). */
|
|
251
|
+
skipFarm?: boolean;
|
|
252
|
+
}
|
|
253
|
+
interface KaminoVaultSupplyOptions extends Omit<SupplyOptions, 'token'> {
|
|
254
|
+
token?: string;
|
|
255
|
+
}
|
|
256
|
+
interface KaminoVaultWithdrawOptions extends Omit<WithdrawOptions, 'amount' | 'token'> {
|
|
257
|
+
token?: string;
|
|
258
|
+
amount: AmountOption;
|
|
259
|
+
}
|
|
260
|
+
interface VaultInfo {
|
|
261
|
+
vault: string;
|
|
262
|
+
programId: string;
|
|
263
|
+
name: string;
|
|
264
|
+
asset: {
|
|
265
|
+
mint: string;
|
|
266
|
+
decimals: number;
|
|
267
|
+
symbol: string;
|
|
268
|
+
};
|
|
269
|
+
shares: {
|
|
270
|
+
mint: string;
|
|
271
|
+
decimals: number;
|
|
272
|
+
};
|
|
273
|
+
/** Base units of the asset the vault manages (available + invested), and shares issued. */
|
|
274
|
+
totalAssets: bigint;
|
|
275
|
+
sharesIssued: bigint;
|
|
276
|
+
/** Assets per 1e18 shares (both in token units), for display. */
|
|
277
|
+
tokensPerShareWad: bigint;
|
|
278
|
+
/** USD per asset token and per share, as the API reports them. */
|
|
279
|
+
tokenPriceUsd: number;
|
|
280
|
+
sharePriceUsd: number;
|
|
281
|
+
/** Percent, net of fees; `apy` is the live rate, the others trailing windows. */
|
|
282
|
+
apy: number;
|
|
283
|
+
apy7d: number;
|
|
284
|
+
apy30d: number;
|
|
285
|
+
apyFarmRewards: number;
|
|
286
|
+
fees: {
|
|
287
|
+
performanceBps: number;
|
|
288
|
+
managementBps: number;
|
|
289
|
+
};
|
|
290
|
+
minDeposit: bigint;
|
|
291
|
+
minWithdraw: bigint;
|
|
292
|
+
holders: number;
|
|
293
|
+
farm: string | null;
|
|
294
|
+
allocations: ApiVault['allocations'];
|
|
295
|
+
}
|
|
296
|
+
interface VaultPosition {
|
|
297
|
+
/** Share base units: in the wallet, staked in the vault farm, and both. */
|
|
298
|
+
unstakedShares: bigint;
|
|
299
|
+
stakedShares: bigint;
|
|
300
|
+
shares: bigint;
|
|
301
|
+
/** Asset base units the shares are worth now. */
|
|
302
|
+
assets: bigint;
|
|
303
|
+
}
|
|
304
|
+
interface VaultSupplyQuote extends LendingQuote {
|
|
305
|
+
expectedShares: bigint;
|
|
306
|
+
}
|
|
307
|
+
interface VaultWithdrawQuote extends LendingQuote {
|
|
308
|
+
shares: bigint;
|
|
309
|
+
expectedAssets: bigint;
|
|
310
|
+
minAssets: bigint;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* A Kamino Earn vault (kVault) as a `LendingProtocol`: `supply` deposits the
|
|
314
|
+
* vault's asset for shares (staked in the vault farm unless `skipFarm`),
|
|
315
|
+
* `withdraw` redeems shares for the asset; `borrow` / `repay` reject, a vault
|
|
316
|
+
* does not lend to its depositors.
|
|
317
|
+
*
|
|
318
|
+
* The transaction comes from Kamino's API and is signed only after the
|
|
319
|
+
* wallet's guard proves it calls only the Kamino / token programs and moves
|
|
320
|
+
* exactly the declared balances (the deposit out, the asset in at the quoted
|
|
321
|
+
* minimum, no other token account touched). Rates, TVL and positions are the
|
|
322
|
+
* API's.
|
|
323
|
+
*/
|
|
324
|
+
declare class KaminoVaultProtocolSolana extends KaminoBase<KaminoVaultConfig> {
|
|
325
|
+
readonly vault: string;
|
|
326
|
+
private _vault;
|
|
327
|
+
constructor(account: IWalletAccountReadOnly | IWalletAccount, config: KaminoVaultConfig);
|
|
328
|
+
/** The vault's static state (cached per instance). */
|
|
329
|
+
protected state(): Promise<ApiVault>;
|
|
330
|
+
private info;
|
|
331
|
+
/** The vault as the API describes it: asset, shares, rate, fees, TVL. */
|
|
332
|
+
getVault(): Promise<VaultInfo>;
|
|
333
|
+
/** Net APY in percent. */
|
|
334
|
+
getApy(): Promise<number>;
|
|
335
|
+
/** Shares (wallet + farm) and what they are worth now. */
|
|
336
|
+
getPosition(): Promise<VaultPosition>;
|
|
337
|
+
/** shares (share units) × tokensPerShare → asset units; decimals may differ between the two mints. */
|
|
338
|
+
private sharesToAssets;
|
|
339
|
+
private assetsToShares;
|
|
340
|
+
private plan;
|
|
341
|
+
private supplyExpectation;
|
|
342
|
+
quoteSupply(o: KaminoVaultSupplyOptions): Promise<VaultSupplyQuote>;
|
|
343
|
+
supply(o: KaminoVaultSupplyOptions): Promise<LendingResult>;
|
|
344
|
+
private planWithdraw;
|
|
345
|
+
quoteWithdraw(o: KaminoVaultWithdrawOptions): Promise<VaultWithdrawQuote>;
|
|
346
|
+
withdraw(o: KaminoVaultWithdrawOptions): Promise<LendingResult>;
|
|
347
|
+
borrow(): Promise<LendingResult>;
|
|
348
|
+
quoteBorrow(): Promise<LendingQuote>;
|
|
349
|
+
repay(): Promise<LendingResult>;
|
|
350
|
+
quoteRepay(): Promise<LendingQuote>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
interface KaminoMarketConfig extends KaminoBaseConfig {
|
|
354
|
+
/** The lending market (default: Kamino's Main Market). */
|
|
355
|
+
market?: string;
|
|
356
|
+
/**
|
|
357
|
+
* Pin the reserve a token maps to. Without it the reserve with the most
|
|
358
|
+
* supplied value for that mint is used (the Main Market has several USDC
|
|
359
|
+
* reserves: the big one and small isolated ones).
|
|
360
|
+
*/
|
|
361
|
+
reserves?: Record<string, string>;
|
|
362
|
+
/** SOL a FIRST deposit may spend on the obligation, user metadata, lookup table and ATAs (default 0.045 SOL). */
|
|
363
|
+
firstDepositAllowanceLamports?: bigint | number;
|
|
364
|
+
}
|
|
365
|
+
interface KaminoMarketWithdrawOptions extends Omit<WithdrawOptions, 'amount'> {
|
|
366
|
+
amount: AmountOption;
|
|
367
|
+
}
|
|
368
|
+
interface KaminoMarketRepayOptions extends Omit<RepayOptions, 'amount'> {
|
|
369
|
+
amount: AmountOption;
|
|
370
|
+
}
|
|
371
|
+
interface ReserveInfo extends ApiReserve {
|
|
372
|
+
/** Fraction borrowed of what is supplied. */
|
|
373
|
+
utilization: number;
|
|
374
|
+
}
|
|
375
|
+
interface MarketInfo extends ApiMarket {
|
|
376
|
+
reserves: ReserveInfo[];
|
|
377
|
+
}
|
|
378
|
+
interface MarketPosition {
|
|
379
|
+
/** The obligations (loans) the wallet has in this market; an empty list means no position. */
|
|
380
|
+
obligations: ApiObligation[];
|
|
381
|
+
/** Base units per mint, summed over obligations. */
|
|
382
|
+
supplied: Record<string, bigint>;
|
|
383
|
+
borrowed: Record<string, bigint>;
|
|
384
|
+
}
|
|
385
|
+
interface MarketQuote extends LendingQuote {
|
|
386
|
+
reserve: string;
|
|
387
|
+
minReceived?: bigint;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* A Kamino Lend market as a `LendingProtocol`: `supply` deposits a reserve's
|
|
391
|
+
* token as collateral on the wallet's obligation, `withdraw` takes it back,
|
|
392
|
+
* `borrow` / `repay` take and return a reserve's liquidity against it.
|
|
393
|
+
*
|
|
394
|
+
* Tokens are named by mint. The first deposit creates the obligation (plus
|
|
395
|
+
* user metadata and a per-user lookup table) and costs their rent, which the
|
|
396
|
+
* guard allows once; every transaction is proven before signing.
|
|
397
|
+
*/
|
|
398
|
+
declare class KaminoMarketProtocolSolana extends KaminoBase<KaminoMarketConfig> {
|
|
399
|
+
readonly market: string;
|
|
400
|
+
private readonly firstDepositAllowance;
|
|
401
|
+
private _reserves;
|
|
402
|
+
constructor(account: IWalletAccountReadOnly | IWalletAccount, config?: KaminoMarketConfig);
|
|
403
|
+
/** Reserves with rates, cached for a minute. */
|
|
404
|
+
getReserves(): Promise<ReserveInfo[]>;
|
|
405
|
+
/** The market's config entry plus its reserves. */
|
|
406
|
+
getMarket(): Promise<MarketInfo>;
|
|
407
|
+
/** The reserve a mint maps to: the pinned one, else the deepest by supplied value. */
|
|
408
|
+
resolveReserve(mint: string): Promise<ReserveInfo>;
|
|
409
|
+
/** Obligations and per-mint totals. */
|
|
410
|
+
getPosition(): Promise<MarketPosition>;
|
|
411
|
+
private lend;
|
|
412
|
+
/** A wallet without an obligation here pays the rent of one on its first deposit. */
|
|
413
|
+
private firstDepositExtra;
|
|
414
|
+
/** Resolve 'max' against the position's supplied / borrowed total for the mint. */
|
|
415
|
+
private resolveMax;
|
|
416
|
+
quoteSupply(o: SupplyOptions): Promise<MarketQuote>;
|
|
417
|
+
supply(o: SupplyOptions): Promise<LendingResult>;
|
|
418
|
+
quoteWithdraw(o: KaminoMarketWithdrawOptions): Promise<MarketQuote>;
|
|
419
|
+
withdraw(o: KaminoMarketWithdrawOptions): Promise<LendingResult>;
|
|
420
|
+
quoteBorrow(o: BorrowOptions): Promise<MarketQuote>;
|
|
421
|
+
borrow(o: BorrowOptions): Promise<LendingResult>;
|
|
422
|
+
quoteRepay(o: KaminoMarketRepayOptions): Promise<MarketQuote>;
|
|
423
|
+
repay(o: KaminoMarketRepayOptions): Promise<LendingResult>;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** A refusal or failure inside the Kamino module; `code` carries Kamino's API error code when there is one. */
|
|
427
|
+
declare class KaminoError extends Error {
|
|
428
|
+
readonly code: string | undefined;
|
|
429
|
+
constructor(message: string, code?: string);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
declare const KLEND_PROGRAM = "KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD";
|
|
433
|
+
declare const KVAULT_PROGRAM = "KvauGMspG5k6rtzrqqn7WNn3oZdyKqLKwK2XWQ8FLjd";
|
|
434
|
+
declare const FARMS_PROGRAM = "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr";
|
|
435
|
+
/** A first Lend deposit creates a per-user lookup table (the user pays its rent, stays its authority). */
|
|
436
|
+
declare const ADDRESS_LOOKUP_TABLE_PROGRAM = "AddressLookupTab1e1111111111111111111111111";
|
|
437
|
+
declare const MEMO_PROGRAM = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";
|
|
438
|
+
/** Every program a Kamino Earn / Lend transaction from the API may call; anything else is refused before signing. */
|
|
439
|
+
declare const KAMINO_PROGRAM_ALLOWLIST: readonly string[];
|
|
440
|
+
/** Anchor discriminator (first 8 bytes, hex) → instruction, per program. */
|
|
441
|
+
declare const INSTRUCTION_NAMES: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
442
|
+
/** The instruction a Kamino program call is, from its data; undefined when unknown. */
|
|
443
|
+
declare function instructionName(programId: string, data: Uint8Array): string | undefined;
|
|
444
|
+
|
|
445
|
+
export { ADDRESS_LOOKUP_TABLE_PROGRAM, type AmountOption, type ApiLoanLeg, type ApiMarket, type ApiObligation, type ApiReserve, type ApiVault, type ApiVaultAllocation, type ApiVaultMetrics, type ApiVaultPosition, DEFAULT_FIRST_DEPOSIT_ALLOWANCE, DEFAULT_RENT_ALLOWANCE, type Expectation, FARMS_PROGRAM, INSTRUCTION_NAMES, KAMINO_API, KAMINO_PROGRAM_ALLOWLIST, KLEND_PROGRAM, KNOWN_DECIMALS, KVAULT_PROGRAM, KaminoApi, KaminoBase, type KaminoBaseConfig, KaminoError, type KaminoMarketConfig, KaminoMarketProtocolSolana, type KaminoMarketRepayOptions, type KaminoMarketWithdrawOptions, type KaminoVaultConfig, KaminoVaultProtocolSolana, type KaminoVaultSupplyOptions, type KaminoVaultWithdrawOptions, type KtxLend, type KtxVaultDeposit, type KtxVaultWithdraw, MAIN_MARKET, MEMO_PROGRAM, type MarketInfo, type MarketPosition, type MarketQuote, type ReserveInfo, SOLANA_MAINNET, type SerializedGuard, type VaultInfo, type VaultPosition, type VaultSupplyQuote, type VaultWithdrawQuote, WAD, WITHDRAW_ALL, WSOL_MINT, KaminoVaultProtocolSolana as default, divWadUp, fromDecimalString, instructionName, lessBps, mulWad, toAmount, toDecimalString, toWad };
|