@kamino-finance/klend-sdk 5.10.12 → 5.10.14
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/README.md +32 -0
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +8 -6
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +20 -17
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +28 -35
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts +1 -0
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +23 -1
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.js +10 -10
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/types_utils.d.ts +5 -2
- package/dist/classes/types_utils.d.ts.map +1 -1
- package/dist/classes/types_utils.js +31 -2
- package/dist/classes/types_utils.js.map +1 -1
- package/dist/classes/utils.d.ts +8 -0
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +48 -0
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +24 -19
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +80 -47
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.js +4 -4
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +1137 -132
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +6 -6
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +7 -7
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +15 -7
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +28 -14
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.d.ts +29 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js +125 -0
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js.map +1 -0
- package/dist/idl_codegen/instructions/depositObligationCollateralV2.d.ts +26 -0
- package/dist/idl_codegen/instructions/depositObligationCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositObligationCollateralV2.js +110 -0
- package/dist/idl_codegen/instructions/depositObligationCollateralV2.js.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.d.ts +31 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js +135 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -0
- package/dist/idl_codegen/instructions/index.d.ts +18 -0
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +19 -1
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.d.ts +43 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +181 -0
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js.map +1 -0
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts +8 -6
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +23 -7
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.d.ts +49 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.js +205 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.js.map +1 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.d.ts +27 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js +111 -0
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js.map +1 -0
- package/dist/idl_codegen/instructions/socializeLossV2.d.ts +23 -0
- package/dist/idl_codegen/instructions/socializeLossV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/socializeLossV2.js +95 -0
- package/dist/idl_codegen/instructions/socializeLossV2.js.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.d.ts +31 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +135 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.d.ts +26 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.js +110 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralV2.js.map +1 -0
- package/dist/idl_codegen/types/ReserveConfig.d.ts +8 -5
- package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.js +9 -8
- package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts +7 -7
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.js +12 -12
- package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +7 -7
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +12 -12
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +4 -4
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/programId.d.ts +2 -1
- package/dist/idl_codegen_kamino_vault/programId.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/programId.js +5 -1
- package/dist/idl_codegen_kamino_vault/programId.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/pyth/accounts/index.d.ts +1 -1
- package/dist/pyth/accounts/index.d.ts.map +1 -1
- package/dist/utils/ObligationType.d.ts +10 -4
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/ObligationType.js +36 -11
- package/dist/utils/ObligationType.js.map +1 -1
- package/dist/utils/accountListing.d.ts +3 -1
- package/dist/utils/accountListing.d.ts.map +1 -1
- package/dist/utils/accountListing.js +40 -0
- package/dist/utils/accountListing.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/managerTypes.js +1 -1
- package/dist/utils/managerTypes.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/action.ts +8 -6
- package/src/classes/manager.ts +34 -38
- package/src/classes/obligation.ts +43 -3
- package/src/classes/reserve.ts +12 -12
- package/src/classes/types_utils.ts +33 -3
- package/src/classes/utils.ts +50 -1
- package/src/classes/vault.ts +104 -57
- package/src/client.ts +22 -0
- package/src/client_kamino_manager.ts +4 -4
- package/src/idl.json +1137 -132
- package/src/idl_codegen/accounts/LendingMarket.ts +11 -11
- package/src/idl_codegen/errors/custom.ts +26 -12
- package/src/idl_codegen/instructions/borrowObligationLiquidityV2.ts +124 -0
- package/src/idl_codegen/instructions/depositObligationCollateralV2.ts +106 -0
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +136 -0
- package/src/idl_codegen/instructions/index.ts +45 -0
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +195 -0
- package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +31 -13
- package/src/idl_codegen/instructions/repayAndWithdrawAndRedeemV2.ts +239 -0
- package/src/idl_codegen/instructions/repayObligationLiquidityV2.ts +108 -0
- package/src/idl_codegen/instructions/socializeLossV2.ts +88 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +136 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateralV2.ts +106 -0
- package/src/idl_codegen/types/ReserveConfig.ts +17 -14
- package/src/idl_codegen/types/UpdateConfigMode.ts +13 -13
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +13 -13
- package/src/idl_codegen/types/index.ts +4 -4
- package/src/idl_codegen_kamino_vault/programId.ts +5 -1
- package/src/lending_operations/swap_collateral_operations.ts +1 -1
- package/src/pyth/accounts/index.ts +1 -1
- package/src/utils/ObligationType.ts +41 -12
- package/src/utils/accountListing.ts +43 -1
- package/src/utils/constants.ts +2 -0
- package/src/utils/managerTypes.ts +1 -1
package/dist/classes/vault.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export declare class KaminoVaultClient {
|
|
|
48
48
|
* @param vault the vault to update
|
|
49
49
|
* @param mode the field to update (based on VaultConfigFieldKind enum)
|
|
50
50
|
* @param value the value to update the field with
|
|
51
|
-
* @param [signer] the signer of the transaction. Optional. If not provided the admin of the vault will be used. It should be used when changing the admin of the vault if we want to batch multiple ixs in the same tx
|
|
51
|
+
* @param [signer] the signer of the transaction. Optional. If not provided the admin of the vault will be used. It should be used when changing the admin of the vault if we want to build or batch multiple ixs in the same tx
|
|
52
52
|
* @returns a struct that contains the instruction to update the field and an optional list of instructions to update the lookup table
|
|
53
53
|
*/
|
|
54
54
|
updateVaultConfigIxs(vault: KaminoVault, mode: VaultConfigFieldKind, value: string, signer?: PublicKey): Promise<UpdateVaultConfigIxs>;
|
|
@@ -57,7 +57,7 @@ export declare class KaminoVaultClient {
|
|
|
57
57
|
* @param farm - the farm where the vault shares can be staked
|
|
58
58
|
* @param [errorOnOverride] - if true, the function will throw an error if the vault already has a farm. If false, it will override the farm
|
|
59
59
|
*/
|
|
60
|
-
|
|
60
|
+
setVaultFarmIxs(vault: KaminoVault, farm: PublicKey, errorOnOverride?: boolean): Promise<UpdateVaultConfigIxs>;
|
|
61
61
|
/**
|
|
62
62
|
* This method updates the vault config for a vault that
|
|
63
63
|
* @param vault - address of vault to be updated
|
|
@@ -139,9 +139,9 @@ export declare class KaminoVaultClient {
|
|
|
139
139
|
encodeVaultName(token: string): Uint8Array;
|
|
140
140
|
/**Convert an u8 array to a string */
|
|
141
141
|
decodeVaultName(token: number[]): string;
|
|
142
|
-
private
|
|
143
|
-
private
|
|
144
|
-
private
|
|
142
|
+
private withdrawIx;
|
|
143
|
+
private withdrawFromAvailableIx;
|
|
144
|
+
private withdrawPendingFeesIx;
|
|
145
145
|
/**
|
|
146
146
|
* Sync a vault for lookup table; create and set the LUT for the vault if needed and fill it with all the needed accounts
|
|
147
147
|
* @param vault the vault to sync and set the LUT for if needed
|
|
@@ -234,12 +234,6 @@ export declare class KaminoVaultClient {
|
|
|
234
234
|
* @returns an HashMap of reserves (key) with the amount available to withdraw for each (value)
|
|
235
235
|
*/
|
|
236
236
|
private getReserveAllocationAvailableLiquidityToWithdraw;
|
|
237
|
-
/**
|
|
238
|
-
* This will get the list of all reserve pubkeys that the vault has allocations for
|
|
239
|
-
* @param vault - the vault state to load reserves for
|
|
240
|
-
* @returns a hashmap from each reserve pubkey to the reserve state
|
|
241
|
-
*/
|
|
242
|
-
getAllVaultReserves(vault: VaultState): PublicKey[];
|
|
243
237
|
/**
|
|
244
238
|
* This will get the list of all reserve pubkeys that the vault has allocations for ex
|
|
245
239
|
* @param vault - the vault state to load reserves for
|
|
@@ -266,9 +260,10 @@ export declare class KaminoVaultClient {
|
|
|
266
260
|
* @param vault - the kamino vault to get available liquidity to withdraw for
|
|
267
261
|
* @param [slot] - the slot for which to calculate the holdings. Optional. If not provided the function will fetch the current slot
|
|
268
262
|
* @param [vaultReserves] - a hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
|
|
263
|
+
* @param [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
|
|
269
264
|
* @returns an VaultHoldings object representing the amount available (uninvested) in vault, total amount invested in reseves and a breakdown of the amount invested in each reserve
|
|
270
265
|
*/
|
|
271
|
-
getVaultHoldings(vault: VaultState, slot?: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve
|
|
266
|
+
getVaultHoldings(vault: VaultState, slot?: number, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>, currentSlot?: number): Promise<VaultHoldings>;
|
|
272
267
|
/**
|
|
273
268
|
* This will return an VaultOverview object that encapsulates all the information about the vault, including the holdings, reserves details, theoretical APY, utilization ratio and total borrowed amount
|
|
274
269
|
* @param vault - the kamino vault to get available liquidity to withdraw for
|
|
@@ -314,11 +309,11 @@ export declare class KaminoVaultClient {
|
|
|
314
309
|
*/
|
|
315
310
|
getVaultTheoreticalAPY(vault: VaultState, slot: number, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<Decimal>;
|
|
316
311
|
/**
|
|
317
|
-
* Retrive the total amount of interest earned by the vault since its inception, including what was charged as fees
|
|
312
|
+
* Retrive the total amount of interest earned by the vault since its inception, up to the last interaction with the vault on chain, including what was charged as fees
|
|
318
313
|
* @param vaultState the kamino vault state to get total net yield for
|
|
319
|
-
* @returns a Decimal representing the net number of tokens earned by the vault since its inception
|
|
314
|
+
* @returns a struct containing a Decimal representing the net number of tokens earned by the vault since its inception and the timestamp of the last fee charge
|
|
320
315
|
*/
|
|
321
|
-
getVaultCumulativeInterest(vaultState: VaultState): Promise<
|
|
316
|
+
getVaultCumulativeInterest(vaultState: VaultState): Promise<VaultCumulativeInterestWithTimestamp>;
|
|
322
317
|
/**
|
|
323
318
|
* Simulate the current holdings of the vault and the earned interest
|
|
324
319
|
* @param vaultState the kamino vault state to get simulated holdings and earnings for
|
|
@@ -327,7 +322,7 @@ export declare class KaminoVaultClient {
|
|
|
327
322
|
* @param [previousTotalAUM] - the previous AUM of the vault to compute the earned interest relative to this value. Optional. If not provided the function will estimate the total AUM at the slot of the last state update on chain
|
|
328
323
|
* @returns a struct of simulated vault holdings and earned interest
|
|
329
324
|
*/
|
|
330
|
-
calculateSimulatedHoldingsWithInterest(vaultState: VaultState, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>, currentSlot?: number,
|
|
325
|
+
calculateSimulatedHoldingsWithInterest(vaultState: VaultState, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>, currentSlot?: number, previousNetAUM?: Decimal): Promise<SimulatedVaultHoldingsWithEarnedInterest>;
|
|
331
326
|
/**
|
|
332
327
|
* Simulate the current holdings and compute the fees that would be charged
|
|
333
328
|
* @param vaultState the kamino vault state to get simulated fees for
|
|
@@ -391,8 +386,12 @@ export type VaultHoldings = {
|
|
|
391
386
|
available: Decimal;
|
|
392
387
|
invested: Decimal;
|
|
393
388
|
investedInReserves: PubkeyHashMap<PublicKey, Decimal>;
|
|
394
|
-
|
|
389
|
+
pendingFees: Decimal;
|
|
390
|
+
totalAUMIncludingFees: Decimal;
|
|
395
391
|
};
|
|
392
|
+
/**
|
|
393
|
+
* earnedInterest represents the interest earned from now until the slot provided in the future
|
|
394
|
+
*/
|
|
396
395
|
export type SimulatedVaultHoldingsWithEarnedInterest = {
|
|
397
396
|
holdings: VaultHoldings;
|
|
398
397
|
earnedInterest: Decimal;
|
|
@@ -402,13 +401,15 @@ export type VaultHoldingsWithUSDValue = {
|
|
|
402
401
|
availableUSD: Decimal;
|
|
403
402
|
investedUSD: Decimal;
|
|
404
403
|
investedInReservesUSD: PubkeyHashMap<PublicKey, Decimal>;
|
|
405
|
-
|
|
404
|
+
totalUSDIncludingFees: Decimal;
|
|
405
|
+
pendingFeesUSD: Decimal;
|
|
406
406
|
};
|
|
407
407
|
export type ReserveOverview = {
|
|
408
408
|
supplyAPY: Decimal;
|
|
409
409
|
utilizationRatio: Decimal;
|
|
410
410
|
liquidationThresholdPct: Decimal;
|
|
411
|
-
|
|
411
|
+
totalBorrowedAmount: Decimal;
|
|
412
|
+
amountBorrowedFromSupplied: Decimal;
|
|
412
413
|
suppliedAmount: Decimal;
|
|
413
414
|
market: PublicKey;
|
|
414
415
|
};
|
|
@@ -444,4 +445,8 @@ export type VaultFees = {
|
|
|
444
445
|
managementFee: Decimal;
|
|
445
446
|
performanceFee: Decimal;
|
|
446
447
|
};
|
|
448
|
+
export type VaultCumulativeInterestWithTimestamp = {
|
|
449
|
+
cumulativeInterest: Decimal;
|
|
450
|
+
timestamp: number;
|
|
451
|
+
};
|
|
447
452
|
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../../src/classes/vault.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,UAAU,EAEV,OAAO,EACP,SAAS,EAIT,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAIL,YAAY,EACZ,aAAa,EAEb,aAAa,EACb,OAAO,EAGR,MAAM,QAAQ,CAAC;AA2BhB,OAAO,EAAoB,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,OAAO,MAAM,YAAY,CAAC;AAWjC,OAAO,EAAmC,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAKhF,OAAO,EACL,uBAAuB,EACvB,UAAU,EACV,YAAY,EACZ,yBAAyB,EACzB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AE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE,yBAAyB,CAAC;IACvC,gBAAgB,EAAE,aAAa,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IAC5D,gBAAgB,EAAE,aAAa,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAC3D,oBAAoB,EAAE,OAAO,CAAC;IAC9B,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,kBAAkB,EAAE,OAAO,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
|
package/dist/classes/vault.js
CHANGED
|
@@ -189,7 +189,7 @@ class KaminoVaultClient {
|
|
|
189
189
|
* @param vault the vault to update
|
|
190
190
|
* @param mode the field to update (based on VaultConfigFieldKind enum)
|
|
191
191
|
* @param value the value to update the field with
|
|
192
|
-
* @param [signer] the signer of the transaction. Optional. If not provided the admin of the vault will be used. It should be used when changing the admin of the vault if we want to batch multiple ixs in the same tx
|
|
192
|
+
* @param [signer] the signer of the transaction. Optional. If not provided the admin of the vault will be used. It should be used when changing the admin of the vault if we want to build or batch multiple ixs in the same tx
|
|
193
193
|
* @returns a struct that contains the instruction to update the field and an optional list of instructions to update the lookup table
|
|
194
194
|
*/
|
|
195
195
|
async updateVaultConfigIxs(vault, mode, value, signer) {
|
|
@@ -270,7 +270,7 @@ class KaminoVaultClient {
|
|
|
270
270
|
* @param farm - the farm where the vault shares can be staked
|
|
271
271
|
* @param [errorOnOverride] - if true, the function will throw an error if the vault already has a farm. If false, it will override the farm
|
|
272
272
|
*/
|
|
273
|
-
async
|
|
273
|
+
async setVaultFarmIxs(vault, farm, errorOnOverride = true) {
|
|
274
274
|
const vaultHasFarm = await vault.hasFarm(this.getConnection());
|
|
275
275
|
if (vaultHasFarm && errorOnOverride) {
|
|
276
276
|
throw new Error('Vault already has a farm, if you want to override it set errorOnOverride to false');
|
|
@@ -402,7 +402,7 @@ class KaminoVaultClient {
|
|
|
402
402
|
}
|
|
403
403
|
const reserveState = reserveStates[index];
|
|
404
404
|
const marketAddress = reserveState.lendingMarket;
|
|
405
|
-
return this.
|
|
405
|
+
return this.withdrawPendingFeesIx(vault, vaultState, marketAddress, { address: reserve, state: reserveState }, adminTokenAta);
|
|
406
406
|
}));
|
|
407
407
|
return [createAtaIx, ...withdrawIxns];
|
|
408
408
|
}
|
|
@@ -563,7 +563,7 @@ class KaminoVaultClient {
|
|
|
563
563
|
},
|
|
564
564
|
]);
|
|
565
565
|
const shareLamportsToWithdraw = (0, kliquidity_sdk_1.collToLamportsDecimal)(shareAmount, vaultState.sharesMintDecimals.toNumber());
|
|
566
|
-
const withdrawFromAvailableIxn = await this.
|
|
566
|
+
const withdrawFromAvailableIxn = await this.withdrawFromAvailableIx(user, kaminoVault, vaultState, userSharesAta, userTokenAta, shareLamportsToWithdraw);
|
|
567
567
|
return [createAtaIx, withdrawFromAvailableIxn];
|
|
568
568
|
}
|
|
569
569
|
async wihdrdrawWithReserveIxns(user, vault, shareAmount, slot, vaultReservesMap) {
|
|
@@ -628,7 +628,7 @@ class KaminoVaultClient {
|
|
|
628
628
|
if (isLastWithdraw) {
|
|
629
629
|
sharesToWithdraw = reserveWithTokens.shares;
|
|
630
630
|
}
|
|
631
|
-
const withdrawFromReserveIx = this.
|
|
631
|
+
const withdrawFromReserveIx = this.withdrawIx(user, vault, vaultState, marketAddress, { address: reserveWithTokens.reserve, state: reserveState.state }, userSharesAta, userTokenAta, sharesToWithdraw, vaultReservesState);
|
|
632
632
|
withdrawIxns.push(withdrawFromReserveIx);
|
|
633
633
|
}
|
|
634
634
|
return withdrawIxns;
|
|
@@ -641,7 +641,7 @@ class KaminoVaultClient {
|
|
|
641
641
|
*/
|
|
642
642
|
async investAllReservesIxs(payer, vault) {
|
|
643
643
|
const vaultState = await vault.getState(this.getConnection());
|
|
644
|
-
const allReserves = this.
|
|
644
|
+
const allReserves = this.getVaultReserves(vaultState);
|
|
645
645
|
if (allReserves.length === 0) {
|
|
646
646
|
throw new Error('No reserves found for the vault, please select at least one reserve for the vault');
|
|
647
647
|
}
|
|
@@ -771,7 +771,7 @@ class KaminoVaultClient {
|
|
|
771
771
|
decodeVaultName(token) {
|
|
772
772
|
return (0, utils_1.decodeVaultName)(token);
|
|
773
773
|
}
|
|
774
|
-
|
|
774
|
+
withdrawIx(user, vault, vaultState, marketAddress, reserve, userSharesAta, userTokenAta, shareAmountLamports, vaultReservesState) {
|
|
775
775
|
const lendingMarketAuth = (0, utils_2.lendingMarketAuthPda)(marketAddress, this._kaminoLendProgramId)[0];
|
|
776
776
|
const withdrawAccounts = {
|
|
777
777
|
withdrawFromAvailable: {
|
|
@@ -822,7 +822,7 @@ class KaminoVaultClient {
|
|
|
822
822
|
withdrawIxn.keys = withdrawIxn.keys.concat(vaultReservesLendingMarkets);
|
|
823
823
|
return withdrawIxn;
|
|
824
824
|
}
|
|
825
|
-
async
|
|
825
|
+
async withdrawFromAvailableIx(user, vault, vaultState, userSharesAta, userTokenAta, shareAmountLamports) {
|
|
826
826
|
const withdrawFromAvailableAccounts = {
|
|
827
827
|
user,
|
|
828
828
|
vaultState: vault.address,
|
|
@@ -841,7 +841,7 @@ class KaminoVaultClient {
|
|
|
841
841
|
};
|
|
842
842
|
return (0, instructions_1.withdrawFromAvailable)(withdrawFromAvailableArgs, withdrawFromAvailableAccounts, this._kaminoVaultProgramId);
|
|
843
843
|
}
|
|
844
|
-
async
|
|
844
|
+
async withdrawPendingFeesIx(vault, vaultState, marketAddress, reserve, adminTokenAta) {
|
|
845
845
|
const lendingMarketAuth = (0, utils_2.lendingMarketAuthPda)(marketAddress, this._kaminoLendProgramId)[0];
|
|
846
846
|
const withdrawPendingFeesAccounts = {
|
|
847
847
|
adminAuthority: vaultState.adminAuthority,
|
|
@@ -1006,13 +1006,13 @@ class KaminoVaultClient {
|
|
|
1006
1006
|
async getVaultComputedReservesAllocation(vaultState) {
|
|
1007
1007
|
const holdings = await this.getVaultHoldings(vaultState);
|
|
1008
1008
|
const initialVaultAllocations = this.getVaultAllocations(vaultState);
|
|
1009
|
-
const allReserves = this.
|
|
1009
|
+
const allReserves = this.getVaultReserves(vaultState);
|
|
1010
1010
|
let totalAllocation = new decimal_js_1.default(0);
|
|
1011
1011
|
initialVaultAllocations.forEach((allocation) => {
|
|
1012
1012
|
totalAllocation = totalAllocation.add(allocation.targetWeight);
|
|
1013
1013
|
});
|
|
1014
1014
|
const expectedHoldingsDistribution = new lib_1.PubkeyHashMap();
|
|
1015
|
-
let totalLeftToInvest = holdings.
|
|
1015
|
+
let totalLeftToInvest = holdings.totalAUMIncludingFees.sub(holdings.pendingFees);
|
|
1016
1016
|
let currentAllocationSum = totalAllocation;
|
|
1017
1017
|
const ZERO = new decimal_js_1.default(0);
|
|
1018
1018
|
while (totalLeftToInvest.gt(ZERO)) {
|
|
@@ -1150,7 +1150,8 @@ class KaminoVaultClient {
|
|
|
1150
1150
|
const vaultReservesState = vaultReservesMap ? vaultReservesMap : await this.loadVaultReserves(vaultState);
|
|
1151
1151
|
const sharesDecimal = (0, lib_1.lamportsToDecimal)(vaultState.sharesIssued.toString(), vaultState.sharesMintDecimals.toString());
|
|
1152
1152
|
const holdings = await this.getVaultHoldings(vaultState, slot, vaultReservesState);
|
|
1153
|
-
|
|
1153
|
+
const netAUM = holdings.totalAUMIncludingFees.sub(holdings.pendingFees);
|
|
1154
|
+
return netAUM.div(sharesDecimal);
|
|
1154
1155
|
}
|
|
1155
1156
|
/**
|
|
1156
1157
|
* This method calculates the token per share value. This will always change based on interest earned from the vault, but calculating it requires a bunch of rpc requests. Caching this for a short duration would be optimal
|
|
@@ -1207,11 +1208,16 @@ class KaminoVaultClient {
|
|
|
1207
1208
|
* @returns vault amount supplied in reserve in decimal
|
|
1208
1209
|
*/
|
|
1209
1210
|
getSuppliedInReserve(vaultState, slot, reserve) {
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
.
|
|
1214
|
-
|
|
1211
|
+
let referralFeeBps = 0;
|
|
1212
|
+
const denominator = reserve.state.config.protocolTakeRatePct / 100;
|
|
1213
|
+
if (denominator > 0) {
|
|
1214
|
+
referralFeeBps = new fraction_1.Fraction(reserve.state.liquidity.absoluteReferralRateSf)
|
|
1215
|
+
.toDecimal()
|
|
1216
|
+
.div(denominator)
|
|
1217
|
+
.floor()
|
|
1218
|
+
.toNumber();
|
|
1219
|
+
}
|
|
1220
|
+
const reserveCollExchangeRate = reserve.getEstimatedCollateralExchangeRate(slot, referralFeeBps);
|
|
1215
1221
|
const reserveAllocation = vaultState.vaultAllocationStrategy.find((allocation) => allocation.reserve.equals(reserve.address));
|
|
1216
1222
|
if (!reserveAllocation) {
|
|
1217
1223
|
throw new Error(`Reserve ${reserve.address.toBase58()} not found in vault allocation strategy`);
|
|
@@ -1291,18 +1297,6 @@ class KaminoVaultClient {
|
|
|
1291
1297
|
});
|
|
1292
1298
|
return reserveAllocationAvailableLiquidityToWithdraw;
|
|
1293
1299
|
}
|
|
1294
|
-
/**
|
|
1295
|
-
* This will get the list of all reserve pubkeys that the vault has allocations for
|
|
1296
|
-
* @param vault - the vault state to load reserves for
|
|
1297
|
-
* @returns a hashmap from each reserve pubkey to the reserve state
|
|
1298
|
-
*/
|
|
1299
|
-
getAllVaultReserves(vault) {
|
|
1300
|
-
return vault.vaultAllocationStrategy
|
|
1301
|
-
.map((vaultAllocation) => vaultAllocation.reserve)
|
|
1302
|
-
.filter((reserve) => {
|
|
1303
|
-
return !reserve.equals(web3_js_1.PublicKey.default);
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
1300
|
/**
|
|
1307
1301
|
* This will get the list of all reserve pubkeys that the vault has allocations for ex
|
|
1308
1302
|
* @param vault - the vault state to load reserves for
|
|
@@ -1403,15 +1397,18 @@ class KaminoVaultClient {
|
|
|
1403
1397
|
* @param vault - the kamino vault to get available liquidity to withdraw for
|
|
1404
1398
|
* @param [slot] - the slot for which to calculate the holdings. Optional. If not provided the function will fetch the current slot
|
|
1405
1399
|
* @param [vaultReserves] - a hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
|
|
1400
|
+
* @param [currentSlot] - the latest confirmed slot. Optional. If provided the function will be faster as it will not have to fetch the latest slot
|
|
1406
1401
|
* @returns an VaultHoldings object representing the amount available (uninvested) in vault, total amount invested in reseves and a breakdown of the amount invested in each reserve
|
|
1407
1402
|
*/
|
|
1408
|
-
async getVaultHoldings(vault, slot, vaultReserves) {
|
|
1403
|
+
async getVaultHoldings(vault, slot, vaultReserves, currentSlot) {
|
|
1409
1404
|
const vaultHoldings = {
|
|
1410
1405
|
available: new decimal_js_1.default(vault.tokenAvailable.toString()),
|
|
1411
1406
|
invested: new decimal_js_1.default(0),
|
|
1412
1407
|
investedInReserves: new lib_1.PubkeyHashMap(),
|
|
1413
|
-
|
|
1408
|
+
totalAUMIncludingFees: new decimal_js_1.default(0),
|
|
1409
|
+
pendingFees: new decimal_js_1.default(0),
|
|
1414
1410
|
};
|
|
1411
|
+
const currentSlotToUse = currentSlot ? currentSlot : await this.getConnection().getSlot('confirmed');
|
|
1415
1412
|
const vaultReservesState = vaultReserves ? vaultReserves : await this.loadVaultReserves(vault);
|
|
1416
1413
|
const decimals = new decimal_js_1.default(vault.tokenMintDecimals.toString());
|
|
1417
1414
|
vault.vaultAllocationStrategy.forEach((allocationStrategy) => {
|
|
@@ -1433,13 +1430,38 @@ class KaminoVaultClient {
|
|
|
1433
1430
|
vaultHoldings.invested = vaultHoldings.invested.add(reserveAllocationLiquidityAmount);
|
|
1434
1431
|
vaultHoldings.investedInReserves.set(allocationStrategy.reserve, (0, lib_1.lamportsToDecimal)(reserveAllocationLiquidityAmount, decimals));
|
|
1435
1432
|
});
|
|
1433
|
+
const currentPendingFees = new fraction_1.Fraction(vault.pendingFeesSf).toDecimal();
|
|
1434
|
+
let totalPendingFees = currentPendingFees;
|
|
1435
|
+
// if there is a slot passed and it is in the future we need to estimate the fees from current time until that moment
|
|
1436
|
+
if (slot && slot > currentSlotToUse) {
|
|
1437
|
+
const currentTimestampSec = new Date().getTime() / 1000;
|
|
1438
|
+
const timeAtPassedSlot = currentTimestampSec + (slot - currentSlotToUse) * this.recentSlotDurationMs;
|
|
1439
|
+
const timeUntilPassedSlot = timeAtPassedSlot - currentTimestampSec;
|
|
1440
|
+
const managementFeeFactor = new decimal_js_1.default(timeUntilPassedSlot)
|
|
1441
|
+
.mul(new decimal_js_1.default(vault.managementFeeBps.toString()))
|
|
1442
|
+
.div(new decimal_js_1.default(utils_2.SECONDS_PER_YEAR))
|
|
1443
|
+
.div(CreationParameters_1.FullBPSDecimal);
|
|
1444
|
+
const prevAUM = (0, lib_1.lamportsToDecimal)(new fraction_1.Fraction(vault.prevAumSf).toDecimal(), vault.tokenMintDecimals.toNumber());
|
|
1445
|
+
const simulatedMgmtFee = prevAUM.mul(managementFeeFactor);
|
|
1446
|
+
totalPendingFees = totalPendingFees.add(simulatedMgmtFee);
|
|
1447
|
+
const simulatedEarnedInterest = vaultHoldings.invested
|
|
1448
|
+
.add(vaultHoldings.available)
|
|
1449
|
+
.sub(prevAUM)
|
|
1450
|
+
.sub(simulatedMgmtFee);
|
|
1451
|
+
const simulatedPerformanceFee = simulatedEarnedInterest
|
|
1452
|
+
.mul(new decimal_js_1.default(vault.performanceFeeBps.toString()))
|
|
1453
|
+
.div(CreationParameters_1.FullBPSDecimal);
|
|
1454
|
+
totalPendingFees = totalPendingFees.add(simulatedPerformanceFee);
|
|
1455
|
+
}
|
|
1436
1456
|
const totalAvailableDecimal = (0, lib_1.lamportsToDecimal)(vaultHoldings.available, decimals);
|
|
1437
1457
|
const totalInvestedDecimal = (0, lib_1.lamportsToDecimal)(vaultHoldings.invested, decimals);
|
|
1458
|
+
const pendingFees = (0, lib_1.lamportsToDecimal)(totalPendingFees, decimals);
|
|
1438
1459
|
return {
|
|
1439
1460
|
available: totalAvailableDecimal,
|
|
1440
1461
|
invested: totalInvestedDecimal,
|
|
1441
1462
|
investedInReserves: vaultHoldings.investedInReserves,
|
|
1442
|
-
|
|
1463
|
+
totalAUMIncludingFees: totalAvailableDecimal.add(totalInvestedDecimal),
|
|
1464
|
+
pendingFees: pendingFees,
|
|
1443
1465
|
};
|
|
1444
1466
|
}
|
|
1445
1467
|
/**
|
|
@@ -1462,7 +1484,8 @@ class KaminoVaultClient {
|
|
|
1462
1484
|
availableUSD: holdings.available.mul(price),
|
|
1463
1485
|
investedUSD: holdings.invested.mul(price),
|
|
1464
1486
|
investedInReservesUSD: investedInReservesUSD,
|
|
1465
|
-
|
|
1487
|
+
totalUSDIncludingFees: holdings.totalAUMIncludingFees.mul(price),
|
|
1488
|
+
pendingFeesUSD: holdings.pendingFees.mul(price),
|
|
1466
1489
|
};
|
|
1467
1490
|
}
|
|
1468
1491
|
/**
|
|
@@ -1556,11 +1579,13 @@ class KaminoVaultClient {
|
|
|
1556
1579
|
throw new Error(`Reserve ${allocationStrategy.reserve.toBase58()} not found`);
|
|
1557
1580
|
}
|
|
1558
1581
|
const suppliedInReserve = this.getSuppliedInReserve(vault, slot, reserve);
|
|
1582
|
+
const utilizationRatio = new decimal_js_1.default(reserve.getEstimatedUtilizationRatio(slot, 0));
|
|
1559
1583
|
const reserveOverview = {
|
|
1560
1584
|
supplyAPY: new decimal_js_1.default(reserve.totalSupplyAPY(slot)),
|
|
1561
|
-
utilizationRatio:
|
|
1585
|
+
utilizationRatio: utilizationRatio,
|
|
1562
1586
|
liquidationThresholdPct: new decimal_js_1.default(reserve.state.config.liquidationThresholdPct),
|
|
1563
|
-
|
|
1587
|
+
totalBorrowedAmount: reserve.getBorrowedAmount(),
|
|
1588
|
+
amountBorrowedFromSupplied: suppliedInReserve.mul(utilizationRatio),
|
|
1564
1589
|
market: reserve.state.lendingMarket,
|
|
1565
1590
|
suppliedAmount: suppliedInReserve,
|
|
1566
1591
|
};
|
|
@@ -1596,16 +1621,24 @@ class KaminoVaultClient {
|
|
|
1596
1621
|
if (totalWeights.isZero()) {
|
|
1597
1622
|
return new decimal_js_1.default(0);
|
|
1598
1623
|
}
|
|
1599
|
-
|
|
1624
|
+
const grossAPY = totalAPY.div(totalWeights);
|
|
1625
|
+
const netAPY = grossAPY
|
|
1626
|
+
.mul(new decimal_js_1.default(1).sub(new decimal_js_1.default(vault.performanceFeeBps.toString()).div(CreationParameters_1.FullBPSDecimal)))
|
|
1627
|
+
.mul(new decimal_js_1.default(1).sub(new decimal_js_1.default(vault.managementFeeBps.toString()).div(CreationParameters_1.FullBPSDecimal)));
|
|
1628
|
+
return netAPY;
|
|
1600
1629
|
}
|
|
1601
1630
|
/**
|
|
1602
|
-
* Retrive the total amount of interest earned by the vault since its inception, including what was charged as fees
|
|
1631
|
+
* Retrive the total amount of interest earned by the vault since its inception, up to the last interaction with the vault on chain, including what was charged as fees
|
|
1603
1632
|
* @param vaultState the kamino vault state to get total net yield for
|
|
1604
|
-
* @returns a Decimal representing the net number of tokens earned by the vault since its inception
|
|
1633
|
+
* @returns a struct containing a Decimal representing the net number of tokens earned by the vault since its inception and the timestamp of the last fee charge
|
|
1605
1634
|
*/
|
|
1606
1635
|
async getVaultCumulativeInterest(vaultState) {
|
|
1607
1636
|
const netYieldLamports = new fraction_1.Fraction(vaultState.cumulativeEarnedInterestSf).toDecimal();
|
|
1608
|
-
|
|
1637
|
+
const cumulativeInterest = (0, lib_1.lamportsToDecimal)(netYieldLamports, vaultState.tokenMintDecimals.toString());
|
|
1638
|
+
return {
|
|
1639
|
+
cumulativeInterest: cumulativeInterest,
|
|
1640
|
+
timestamp: vaultState.lastFeeChargeTimestamp.toNumber(),
|
|
1641
|
+
};
|
|
1609
1642
|
}
|
|
1610
1643
|
/**
|
|
1611
1644
|
* Simulate the current holdings of the vault and the earned interest
|
|
@@ -1615,20 +1648,20 @@ class KaminoVaultClient {
|
|
|
1615
1648
|
* @param [previousTotalAUM] - the previous AUM of the vault to compute the earned interest relative to this value. Optional. If not provided the function will estimate the total AUM at the slot of the last state update on chain
|
|
1616
1649
|
* @returns a struct of simulated vault holdings and earned interest
|
|
1617
1650
|
*/
|
|
1618
|
-
async calculateSimulatedHoldingsWithInterest(vaultState, vaultReservesMap, currentSlot,
|
|
1651
|
+
async calculateSimulatedHoldingsWithInterest(vaultState, vaultReservesMap, currentSlot, previousNetAUM) {
|
|
1619
1652
|
let prevAUM;
|
|
1620
|
-
|
|
1621
|
-
|
|
1653
|
+
let pendingFees = kliquidity_sdk_1.ZERO;
|
|
1654
|
+
if (previousNetAUM) {
|
|
1655
|
+
prevAUM = previousNetAUM;
|
|
1622
1656
|
}
|
|
1623
1657
|
else {
|
|
1624
|
-
const
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
prevAUM = lastUpdateHoldings.total;
|
|
1658
|
+
const tokenDecimals = vaultState.tokenMintDecimals.toNumber();
|
|
1659
|
+
prevAUM = (0, lib_1.lamportsToDecimal)(new fraction_1.Fraction(vaultState.prevAumSf).toDecimal(), tokenDecimals);
|
|
1660
|
+
pendingFees = (0, lib_1.lamportsToDecimal)(new fraction_1.Fraction(vaultState.pendingFeesSf).toDecimal(), tokenDecimals);
|
|
1628
1661
|
}
|
|
1629
1662
|
const slot = currentSlot ? currentSlot : await this.getConnection().getSlot('confirmed');
|
|
1630
1663
|
const currentHoldings = await this.getVaultHoldings(vaultState, slot, vaultReservesMap);
|
|
1631
|
-
const earnedInterest = currentHoldings.
|
|
1664
|
+
const earnedInterest = currentHoldings.totalAUMIncludingFees.sub(prevAUM).sub(pendingFees);
|
|
1632
1665
|
return {
|
|
1633
1666
|
holdings: currentHoldings,
|
|
1634
1667
|
earnedInterest: earnedInterest,
|