@kamino-finance/klend-sdk 7.1.10 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/farm_utils.d.ts +8 -0
- package/dist/classes/farm_utils.d.ts.map +1 -1
- package/dist/classes/farm_utils.js +39 -0
- package/dist/classes/farm_utils.js.map +1 -1
- package/dist/classes/manager.d.ts +52 -5
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +68 -9
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/reserve.d.ts +1 -1
- package/dist/classes/reserve.js +1 -1
- package/dist/classes/vault.d.ts +156 -10
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +477 -71
- package/dist/classes/vault.js.map +1 -1
- package/dist/manager/client_kamino_manager.js +69 -43
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/utils/farmUtils.d.ts +1 -1
- package/dist/utils/farmUtils.d.ts.map +1 -1
- package/dist/utils/farmUtils.js +1 -1
- package/dist/utils/farmUtils.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/farm_utils.ts +48 -0
- package/src/classes/manager.ts +100 -14
- package/src/classes/reserve.ts +1 -1
- package/src/classes/vault.ts +677 -74
- package/src/manager/client_kamino_manager.ts +103 -44
- package/src/utils/farmUtils.ts +0 -1
|
@@ -6,5 +6,5 @@ export interface ReserveIncentives {
|
|
|
6
6
|
collateralFarmIncentives: FarmIncentives;
|
|
7
7
|
debtFarmIncentives: FarmIncentives;
|
|
8
8
|
}
|
|
9
|
-
export declare function getReserveFarmRewardsAPY(rpc: Rpc<SolanaRpcApi>, recentSlotDurationMs: number, reserve: Address, reserveLiquidityTokenPrice: Decimal, kaminoLendProgramId: Address, farmsClient: Farms, slot: Slot, reserveState?: Reserve,
|
|
9
|
+
export declare function getReserveFarmRewardsAPY(rpc: Rpc<SolanaRpcApi>, recentSlotDurationMs: number, reserve: Address, reserveLiquidityTokenPrice: Decimal, kaminoLendProgramId: Address, farmsClient: Farms, slot: Slot, reserveState?: Reserve, tokensPrices?: Map<Address, Decimal>): Promise<ReserveIncentives>;
|
|
10
10
|
//# sourceMappingURL=farmUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"farmUtils.d.ts","sourceRoot":"","sources":["../../src/utils/farmUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGrD,MAAM,WAAW,iBAAiB;IAChC,wBAAwB,EAAE,cAAc,CAAC;IACzC,kBAAkB,EAAE,cAAc,CAAC;CACpC;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,EACtB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,OAAO,EAChB,0BAA0B,EAAE,OAAO,EACnC,mBAAmB,EAAE,OAAO,EAC5B,WAAW,EAAE,KAAK,EAClB,IAAI,EAAE,IAAI,EACV,YAAY,CAAC,EAAE,OAAO,EACtB,
|
|
1
|
+
{"version":3,"file":"farmUtils.d.ts","sourceRoot":"","sources":["../../src/utils/farmUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGrD,MAAM,WAAW,iBAAiB;IAChC,wBAAwB,EAAE,cAAc,CAAC;IACzC,kBAAkB,EAAE,cAAc,CAAC;CACpC;AAED,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,GAAG,CAAC,YAAY,CAAC,EACtB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,OAAO,EAChB,0BAA0B,EAAE,OAAO,EACnC,mBAAmB,EAAE,OAAO,EAC5B,WAAW,EAAE,KAAK,EAClB,IAAI,EAAE,IAAI,EACV,YAAY,CAAC,EAAE,OAAO,EACtB,YAAY,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,GACnC,OAAO,CAAC,iBAAiB,CAAC,CAgD5B"}
|
package/dist/utils/farmUtils.js
CHANGED
|
@@ -5,7 +5,7 @@ const apy_1 = require("@kamino-finance/farms-sdk/dist/utils/apy");
|
|
|
5
5
|
const farms_sdk_1 = require("@kamino-finance/farms-sdk");
|
|
6
6
|
const accounts_1 = require("../@codegen/klend/accounts");
|
|
7
7
|
const lib_1 = require("../lib");
|
|
8
|
-
async function getReserveFarmRewardsAPY(rpc, recentSlotDurationMs, reserve, reserveLiquidityTokenPrice, kaminoLendProgramId, farmsClient, slot, reserveState,
|
|
8
|
+
async function getReserveFarmRewardsAPY(rpc, recentSlotDurationMs, reserve, reserveLiquidityTokenPrice, kaminoLendProgramId, farmsClient, slot, reserveState, tokensPrices) {
|
|
9
9
|
const reserveIncentives = {
|
|
10
10
|
collateralFarmIncentives: {
|
|
11
11
|
incentivesStats: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"farmUtils.js","sourceRoot":"","sources":["../../src/utils/farmUtils.ts"],"names":[],"mappings":";;AAaA,
|
|
1
|
+
{"version":3,"file":"farmUtils.js","sourceRoot":"","sources":["../../src/utils/farmUtils.ts"],"names":[],"mappings":";;AAaA,4DA0DC;AApED,kEAA6E;AAC7E,yDAA+D;AAC/D,yDAAqD;AACrD,gCAAuC;AAOhC,KAAK,UAAU,wBAAwB,CAC5C,GAAsB,EACtB,oBAA4B,EAC5B,OAAgB,EAChB,0BAAmC,EACnC,mBAA4B,EAC5B,WAAkB,EAClB,IAAU,EACV,YAAsB,EACtB,YAAoC;IAEpC,MAAM,iBAAiB,GAAsB;QAC3C,wBAAwB,EAAE;YACxB,eAAe,EAAE,EAAE;YACnB,kBAAkB,EAAE,CAAC;SACtB;QACD,kBAAkB,EAAE;YAClB,eAAe,EAAE,EAAE;YACnB,kBAAkB,EAAE,CAAC;SACtB;KACF,CAAC;IAEF,MAAM,cAAc,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,kBAAO,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC;IAC5G,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,WAAW,OAAO,YAAY,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,mBAAa,CAAC,qBAAqB,CAAC,OAAO,EAAE,GAAG,EAAE,oBAAoB,EAAE,cAAc,CAAC,CAAC;IAEpH,MAAM,cAAc,GAAG,aAAa,CAAC,KAAK,CAAC,cAAc,CAAC;IAC1D,MAAM,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC;IAE9C,MAAM,uBAAuB,GAAG,aAAa,CAAC,eAAe,EAAE,CAAC;IAChE,MAAM,kBAAkB,GAAG,0BAA0B,CAAC,GAAG,CAAC,aAAa,CAAC,kCAAkC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAErH,IAAI,cAAc,KAAK,8BAAkB,EAAE,CAAC;QAC1C,MAAM,wBAAwB,GAAG,MAAM,IAAA,uBAAiB,EACtD,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,YAAY,CACb,CAAC;QACF,iBAAiB,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;IACxE,CAAC;IAED,IAAI,QAAQ,KAAK,8BAAkB,EAAE,CAAC;QACpC,MAAM,kBAAkB,GAAG,MAAM,IAAA,uBAAiB,EAChD,WAAW,EACX,QAAQ,EACR,0BAA0B,EAC1B,uBAAuB,EACvB,YAAY,CACb,CAAC;QACF,iBAAiB,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IAC5D,CAAC;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -202,3 +202,51 @@ export function getRewardPerTimeUnitSecond(reward: RewardInfo) {
|
|
|
202
202
|
|
|
203
203
|
return rewardPerTimeUnitSecond ? rpsAdjusted : new Decimal(0);
|
|
204
204
|
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* reads the pending rewards for a user in a vault farm
|
|
208
|
+
* @param rpc - the rpc connection
|
|
209
|
+
* @param userStateAddress - the address of the user state (computed differently depending on farm type)
|
|
210
|
+
* @param farm - the address of the farm
|
|
211
|
+
* @returns a map of the pending rewards per token
|
|
212
|
+
*/
|
|
213
|
+
export async function getUserPendingRewardsInFarm(
|
|
214
|
+
rpc: Rpc<SolanaRpcApi>,
|
|
215
|
+
userStateAddress: Address,
|
|
216
|
+
farm: Address
|
|
217
|
+
): Promise<Map<Address, Decimal>> {
|
|
218
|
+
const pendingRewardsPerToken: Map<Address, Decimal> = new Map();
|
|
219
|
+
|
|
220
|
+
const farmClient = new Farms(rpc);
|
|
221
|
+
// if the user state does not exist, return 0
|
|
222
|
+
const userStateAccountInfo = await fetchEncodedAccount(rpc, userStateAddress);
|
|
223
|
+
if (!userStateAccountInfo.exists) {
|
|
224
|
+
return pendingRewardsPerToken;
|
|
225
|
+
}
|
|
226
|
+
const userState = UserState.decode(Buffer.from(userStateAccountInfo.data));
|
|
227
|
+
|
|
228
|
+
const farmState = await FarmState.fetch(rpc, farm);
|
|
229
|
+
if (!farmState) {
|
|
230
|
+
throw new Error(`Farm state not found for ${farm}`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const currentTimestamp = new Decimal(new Date().getTime() / 1000);
|
|
234
|
+
const rawRewards = farmClient.getUserPendingRewards(userState, farmState, currentTimestamp, null);
|
|
235
|
+
|
|
236
|
+
if (!rawRewards.hasReward) {
|
|
237
|
+
return pendingRewardsPerToken;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
for (let i = 0; i < rawRewards.userPendingRewardAmounts.length; i++) {
|
|
241
|
+
const reward = rawRewards.userPendingRewardAmounts[i];
|
|
242
|
+
const rewardToken = farmState.rewardInfos[i].token.mint;
|
|
243
|
+
const existingReward = pendingRewardsPerToken.get(rewardToken);
|
|
244
|
+
if (existingReward) {
|
|
245
|
+
pendingRewardsPerToken.set(rewardToken, existingReward.add(reward));
|
|
246
|
+
} else {
|
|
247
|
+
pendingRewardsPerToken.set(rewardToken, reward);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return pendingRewardsPerToken;
|
|
252
|
+
}
|
package/src/classes/manager.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
KaminoVaultConfig,
|
|
21
21
|
kaminoVaultId,
|
|
22
22
|
MarketOverview,
|
|
23
|
+
PendingRewardsForUserInVault,
|
|
23
24
|
ReserveAllocationConfig,
|
|
24
25
|
ReserveOverview,
|
|
25
26
|
SimulatedVaultHoldingsWithEarnedInterest,
|
|
@@ -37,6 +38,7 @@ import {
|
|
|
37
38
|
CreateKaminoMarketParams,
|
|
38
39
|
createReserveIxs,
|
|
39
40
|
DEFAULT_PUBLIC_KEY,
|
|
41
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
40
42
|
ENV,
|
|
41
43
|
getAllLendingMarketAccounts,
|
|
42
44
|
getAllOracleAccounts,
|
|
@@ -116,12 +118,12 @@ export class KaminoManager {
|
|
|
116
118
|
|
|
117
119
|
constructor(
|
|
118
120
|
rpc: Rpc<SolanaRpcApi>,
|
|
119
|
-
recentSlotDurationMs
|
|
121
|
+
recentSlotDurationMs?: number,
|
|
120
122
|
kaminoLendProgramId?: Address,
|
|
121
123
|
kaminoVaultProgramId?: Address
|
|
122
124
|
) {
|
|
123
125
|
this._rpc = rpc;
|
|
124
|
-
this.recentSlotDurationMs = recentSlotDurationMs;
|
|
126
|
+
this.recentSlotDurationMs = recentSlotDurationMs ?? DEFAULT_RECENT_SLOT_DURATION_MS;
|
|
125
127
|
this._kaminoVaultProgramId = kaminoVaultProgramId ? kaminoVaultProgramId : kaminoVaultId;
|
|
126
128
|
this._kaminoLendProgramId = kaminoLendProgramId ? kaminoLendProgramId : PROGRAM_ID;
|
|
127
129
|
this._vaultClient = new KaminoVaultClient(
|
|
@@ -245,7 +247,7 @@ export class KaminoManager {
|
|
|
245
247
|
* @returns - an instruction to set the shares metadata for the vault
|
|
246
248
|
*/
|
|
247
249
|
async getSetSharesMetadataIx(authority: TransactionSigner, vault: KaminoVault, tokenName: string, extraName: string) {
|
|
248
|
-
const vaultState = await vault.getState(
|
|
250
|
+
const vaultState = await vault.getState();
|
|
249
251
|
return this._vaultClient.getSetSharesMetadataIx(
|
|
250
252
|
this._rpc,
|
|
251
253
|
authority,
|
|
@@ -324,7 +326,7 @@ export class KaminoManager {
|
|
|
324
326
|
reserveState?: Reserve
|
|
325
327
|
): Promise<Instruction[]> {
|
|
326
328
|
const connection = this.getRpc();
|
|
327
|
-
const vaultState = await kaminoVault.getState(
|
|
329
|
+
const vaultState = await kaminoVault.getState();
|
|
328
330
|
|
|
329
331
|
const allocations = this.getVaultReserves(vaultState);
|
|
330
332
|
if (!allocations.includes(reserveAddress)) {
|
|
@@ -907,7 +909,7 @@ export class KaminoManager {
|
|
|
907
909
|
throw Error(`kaminoVault with pubkey ${kaminoVault.address} could not be decoded`);
|
|
908
910
|
}
|
|
909
911
|
|
|
910
|
-
return
|
|
912
|
+
return KaminoVault.loadWithClientAndState(this._vaultClient, kaminoVault.address, kaminoVaultAccount);
|
|
911
913
|
});
|
|
912
914
|
}
|
|
913
915
|
|
|
@@ -950,7 +952,7 @@ export class KaminoManager {
|
|
|
950
952
|
async getVaultTokenAccounts(
|
|
951
953
|
vault: KaminoVault
|
|
952
954
|
): Promise<AccountInfoWithPubkey<AccountInfoBase & AccountInfoWithJsonData>[]> {
|
|
953
|
-
const vaultState = await vault.getState(
|
|
955
|
+
const vaultState = await vault.getState();
|
|
954
956
|
return this.getShareTokenAccounts(vaultState.sharesMint);
|
|
955
957
|
}
|
|
956
958
|
|
|
@@ -960,7 +962,7 @@ export class KaminoManager {
|
|
|
960
962
|
* @returns an array of all vault holders with their pubkeys and amounts
|
|
961
963
|
*/
|
|
962
964
|
getVaultHolders = async (vault: KaminoVault): Promise<VaultHolder[]> => {
|
|
963
|
-
await vault.getState(
|
|
965
|
+
await vault.getState();
|
|
964
966
|
const tokenAccounts = await this.getVaultTokenAccounts(vault);
|
|
965
967
|
const result: VaultHolder[] = [];
|
|
966
968
|
for (const tokenAccount of tokenAccounts) {
|
|
@@ -1042,7 +1044,7 @@ export class KaminoManager {
|
|
|
1042
1044
|
* @returns an VaultOverview object with details about the tokens available and invested in the vault, denominated in tokens and USD, along sie APYs
|
|
1043
1045
|
*/
|
|
1044
1046
|
async getVaultOverview(
|
|
1045
|
-
vault:
|
|
1047
|
+
vault: KaminoVault,
|
|
1046
1048
|
price: Decimal,
|
|
1047
1049
|
slot?: Slot,
|
|
1048
1050
|
vaultReserves?: Map<Address, KaminoReserve>,
|
|
@@ -1221,6 +1223,89 @@ export class KaminoManager {
|
|
|
1221
1223
|
return this._vaultClient.getVaultRewardsAPY(vault, vaultTokenPrice, farmsClient, slot);
|
|
1222
1224
|
}
|
|
1223
1225
|
|
|
1226
|
+
/**
|
|
1227
|
+
* Read the APY of the delegated farm providing incentives for vault depositors
|
|
1228
|
+
* @param vault - the vault to read the farm APY for
|
|
1229
|
+
* @param vaultTokenPrice - the price of the vault token in USD (e.g. 1.0 for USDC)
|
|
1230
|
+
* @param [farmsClient] - the farms client to use. Optional. If not provided, the function will create a new one
|
|
1231
|
+
* @param [slot] - the slot to read the farm APY for. Optional. If not provided, the function will read the current slot
|
|
1232
|
+
* @param [tokensPrices] - the prices of the tokens in USD. Optional. If not provided, the function will fetch the prices
|
|
1233
|
+
* @returns the APY of the delegated farm providing incentives for vault depositors
|
|
1234
|
+
*/
|
|
1235
|
+
async getVaultDelegatedFarmRewardsAPY(
|
|
1236
|
+
vault: KaminoVault,
|
|
1237
|
+
vaultTokenPrice: Decimal,
|
|
1238
|
+
farmsClient?: Farms,
|
|
1239
|
+
slot?: Slot
|
|
1240
|
+
): Promise<FarmIncentives> {
|
|
1241
|
+
return this._vaultClient.getVaultDelegatedFarmRewardsAPY(vault, vaultTokenPrice, farmsClient, slot);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
/**
|
|
1245
|
+
* This will read the pending rewards for a user in the vault farm, the reserves farms of the vault and the delegated vault farm
|
|
1246
|
+
* @param user - the user address
|
|
1247
|
+
* @param vault - the vault
|
|
1248
|
+
* @param [vaultReservesMap] - the vault reserves map to get the reserves for; if not provided, the function will fetch the reserves
|
|
1249
|
+
* @returns a struct containing the pending rewards in the vault farm, the reserves farms of the vault and the delegated vault farm, and the total pending rewards in lamports
|
|
1250
|
+
*/
|
|
1251
|
+
async getAllPendingRewardsForUserInVault(
|
|
1252
|
+
user: Address,
|
|
1253
|
+
vault: KaminoVault,
|
|
1254
|
+
vaultReservesMap?: Map<Address, KaminoReserve>
|
|
1255
|
+
): Promise<PendingRewardsForUserInVault> {
|
|
1256
|
+
return this._vaultClient.getAllPendingRewardsForUserInVault(user, vault, vaultReservesMap);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* This function will return the instructions to claim the rewards for the farm of a vault, the delegated farm of the vault and the reserves farms of the vault
|
|
1261
|
+
* @param user - the user to claim the rewards
|
|
1262
|
+
* @param vault - the vault
|
|
1263
|
+
* @param [vaultReservesMap] - the vault reserves map to get the reserves for; if not provided, the function will fetch the reserves
|
|
1264
|
+
* @returns the instructions to claim the rewards for the farm of the vault, the delegated farm of the vault and the reserves farms of the vault
|
|
1265
|
+
*/
|
|
1266
|
+
async getClaimAllRewardsForVaultIxs(
|
|
1267
|
+
user: TransactionSigner,
|
|
1268
|
+
vault: KaminoVault,
|
|
1269
|
+
vaultReservesMap?: Map<Address, KaminoReserve>
|
|
1270
|
+
): Promise<Instruction[]> {
|
|
1271
|
+
return this._vaultClient.getClaimAllRewardsForVaultIxs(user, vault, vaultReservesMap);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* This function will return the instructions to claim the rewards for the farm of a vault
|
|
1276
|
+
* @param user - the user to claim the rewards
|
|
1277
|
+
* @param vault - the vault
|
|
1278
|
+
* @returns the instructions to claim the rewards for the farm of the vault
|
|
1279
|
+
*/
|
|
1280
|
+
async getClaimVaultFarmRewardsIxs(user: TransactionSigner, vault: KaminoVault): Promise<Instruction[]> {
|
|
1281
|
+
return this._vaultClient.getClaimVaultFarmRewardsIxs(user, vault);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* This function will return the instructions to claim the rewards for the delegated farm of a vault
|
|
1286
|
+
* @param user - the user to claim the rewards
|
|
1287
|
+
* @param vault - the vault
|
|
1288
|
+
* @returns the instructions to claim the rewards for the delegated farm of the vault
|
|
1289
|
+
*/
|
|
1290
|
+
async getClaimVaultDelegatedFarmRewardsIxs(user: TransactionSigner, vault: KaminoVault): Promise<Instruction[]> {
|
|
1291
|
+
return this._vaultClient.getClaimVaultDelegatedFarmRewardsIxs(user, vault);
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* This function will return the instructions to claim the rewards for the reserves farms of a vault
|
|
1296
|
+
* @param user - the user to claim the rewards
|
|
1297
|
+
* @param vault - the vault
|
|
1298
|
+
* @param [vaultReservesMap] - the vault reserves map to get the reserves for; if not provided, the function will fetch the reserves
|
|
1299
|
+
* @returns the instructions to claim the rewards for the reserves farms of the vault
|
|
1300
|
+
*/
|
|
1301
|
+
async getClaimVaultReservesFarmsRewardsIxs(
|
|
1302
|
+
user: TransactionSigner,
|
|
1303
|
+
vault: KaminoVault,
|
|
1304
|
+
vaultReservesMap?: Map<Address, KaminoReserve>
|
|
1305
|
+
): Promise<Instruction[]> {
|
|
1306
|
+
return this._vaultClient.getClaimVaultReservesFarmsRewardsIxs(user, vault, vaultReservesMap);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1224
1309
|
/**
|
|
1225
1310
|
* Get all the token mints of the vault, vault farm rewards and the allocation rewards
|
|
1226
1311
|
* @param vaults - the vaults to get the token mints for
|
|
@@ -1243,7 +1328,6 @@ export class KaminoManager {
|
|
|
1243
1328
|
* @param [farmsClient] - the farms client to use. Optional. If not provided, the function will create a new one
|
|
1244
1329
|
* @param [slot] - the slot to read the farm APY for. Optional. If not provided, the function will read the current slot
|
|
1245
1330
|
* @param [reserveState] - the reserve state. Optional. If not provided, the function will fetch the reserve state
|
|
1246
|
-
* @param [cTokenMintDecimals] - the decimals of the cToken mint. Optional. If not provided, the function will fetch the decimals from the mint
|
|
1247
1331
|
* @returns the APY of the farm built on top of the reserve
|
|
1248
1332
|
*/
|
|
1249
1333
|
async getReserveFarmRewardsAPY(
|
|
@@ -1251,8 +1335,7 @@ export class KaminoManager {
|
|
|
1251
1335
|
reserveTokenPrice: Decimal,
|
|
1252
1336
|
farmsClient?: Farms,
|
|
1253
1337
|
slot?: Slot,
|
|
1254
|
-
reserveState?: Reserve
|
|
1255
|
-
cTokenMintDecimals?: number
|
|
1338
|
+
reserveState?: Reserve
|
|
1256
1339
|
): Promise<ReserveIncentives> {
|
|
1257
1340
|
return getReserveFarmRewardsAPYUtils(
|
|
1258
1341
|
this._rpc,
|
|
@@ -1262,8 +1345,7 @@ export class KaminoManager {
|
|
|
1262
1345
|
this._kaminoLendProgramId,
|
|
1263
1346
|
farmsClient ? farmsClient : new Farms(this._rpc),
|
|
1264
1347
|
slot ? slot : await this.getRpc().getSlot().send(),
|
|
1265
|
-
reserveState
|
|
1266
|
-
cTokenMintDecimals
|
|
1348
|
+
reserveState
|
|
1267
1349
|
);
|
|
1268
1350
|
}
|
|
1269
1351
|
|
|
@@ -1320,7 +1402,11 @@ export class KaminoManager {
|
|
|
1320
1402
|
* @param skipComputationChecks - if true, the function will skip the computation checks and will invest all the reserves
|
|
1321
1403
|
* @returns - an array of invest instructions for each invest action required for the vault reserves
|
|
1322
1404
|
*/
|
|
1323
|
-
async investAllReservesIxs(
|
|
1405
|
+
async investAllReservesIxs(
|
|
1406
|
+
payer: TransactionSigner,
|
|
1407
|
+
kaminoVault: KaminoVault,
|
|
1408
|
+
skipComputationChecks: boolean = false
|
|
1409
|
+
): Promise<Instruction[]> {
|
|
1324
1410
|
return this._vaultClient.investAllReservesIxs(payer, kaminoVault, skipComputationChecks);
|
|
1325
1411
|
}
|
|
1326
1412
|
|
package/src/classes/reserve.ts
CHANGED
|
@@ -60,7 +60,7 @@ import { Scope, ScopeEntryMetadata } from '@kamino-finance/scope-sdk';
|
|
|
60
60
|
|
|
61
61
|
export type KaminoReserveRpcApi = GetProgramAccountsApi & GetAccountInfoApi & GetMultipleAccountsApi;
|
|
62
62
|
|
|
63
|
-
export const DEFAULT_RECENT_SLOT_DURATION_MS =
|
|
63
|
+
export const DEFAULT_RECENT_SLOT_DURATION_MS = 400;
|
|
64
64
|
|
|
65
65
|
export class KaminoReserve {
|
|
66
66
|
state: Reserve;
|