@kamino-finance/klend-sdk 7.2.3 → 7.2.4
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 +1 -0
- package/dist/classes/farm_utils.d.ts.map +1 -1
- package/dist/classes/farm_utils.js +2 -1
- package/dist/classes/farm_utils.js.map +1 -1
- package/dist/classes/manager.d.ts +8 -1
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +16 -0
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/vault.d.ts +9 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +28 -5
- package/dist/classes/vault.js.map +1 -1
- package/dist/classes/vault_types.d.ts +8 -1
- package/dist/classes/vault_types.d.ts.map +1 -1
- package/dist/manager/client_kamino_manager.js +10 -0
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/utils/vaultAllocation.d.ts +4 -3
- package/dist/utils/vaultAllocation.d.ts.map +1 -1
- package/dist/utils/vaultAllocation.js +8 -5
- package/dist/utils/vaultAllocation.js.map +1 -1
- package/package.json +2 -2
- package/src/classes/farm_utils.ts +1 -0
- package/src/classes/manager.ts +18 -0
- package/src/classes/vault.ts +72 -6
- package/src/classes/vault_types.ts +9 -1
- package/src/manager/client_kamino_manager.ts +16 -0
- package/src/utils/vaultAllocation.ts +9 -5
|
@@ -352,6 +352,22 @@ async function main() {
|
|
|
352
352
|
...instructions.createAtaIfNeededIxs,
|
|
353
353
|
...instructions.initVaultIxs,
|
|
354
354
|
instructions.createLUTIx,
|
|
355
|
+
instructions.setFarmToVaultIx,
|
|
356
|
+
...getPriorityFeeAndCuIxs({
|
|
357
|
+
priorityFeeMultiplier: 2500,
|
|
358
|
+
}),
|
|
359
|
+
],
|
|
360
|
+
mode,
|
|
361
|
+
[]
|
|
362
|
+
);
|
|
363
|
+
await sleep(2000);
|
|
364
|
+
// create the farm
|
|
365
|
+
await processTx(
|
|
366
|
+
env.c,
|
|
367
|
+
admin,
|
|
368
|
+
[
|
|
369
|
+
...instructions.createVaultFarm.setupFarmIxs,
|
|
370
|
+
...instructions.createVaultFarm.updateFarmIxs,
|
|
355
371
|
...getPriorityFeeAndCuIxs({
|
|
356
372
|
priorityFeeMultiplier: 2500,
|
|
357
373
|
}),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
2
|
import { Address } from '@solana/kit';
|
|
3
|
+
import { lamportsToCollDecimal } from '@kamino-finance/farms-sdk';
|
|
3
4
|
|
|
4
5
|
export interface ReserveAllocationOverview {
|
|
5
6
|
targetWeight: Decimal;
|
|
@@ -13,21 +14,22 @@ export interface VaultAllocationResult {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
const ZERO = new Decimal(0);
|
|
16
|
-
const ONE = new Decimal(1);
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Computes the allocation of vault funds across reserves based on weights and caps
|
|
20
|
-
* @param vaultAUM - Total AUM of the vault
|
|
20
|
+
* @param vaultAUM - Total AUM of the vault, in tokens
|
|
21
21
|
* @param vaultUnallocatedWeight - Weight for unallocated funds
|
|
22
22
|
* @param vaultUnallocatedCap - Maximum amount that can remain unallocated
|
|
23
23
|
* @param initialVaultAllocations - Map of reserve addresses to their allocation configurations
|
|
24
|
-
* @
|
|
24
|
+
* @param vaultTokenDecimals - The number of decimals of the vault token, needed to compute the min amount
|
|
25
|
+
* @returns Object containing target unallocated amount and target allocations per reserve, in tokens
|
|
25
26
|
*/
|
|
26
27
|
export function computeReservesAllocation(
|
|
27
28
|
vaultAUM: Decimal,
|
|
28
29
|
vaultUnallocatedWeight: Decimal,
|
|
29
30
|
vaultUnallocatedCap: Decimal,
|
|
30
|
-
initialVaultAllocations: Map<Address, ReserveAllocationOverview
|
|
31
|
+
initialVaultAllocations: Map<Address, ReserveAllocationOverview>,
|
|
32
|
+
vaultTokenDecimals: number
|
|
31
33
|
): VaultAllocationResult {
|
|
32
34
|
let totalAllocation = new Decimal(0);
|
|
33
35
|
const allReserves = Array.from(initialVaultAllocations.keys());
|
|
@@ -51,8 +53,10 @@ export function computeReservesAllocation(
|
|
|
51
53
|
|
|
52
54
|
let currentAllocationSum = totalAllocation;
|
|
53
55
|
|
|
56
|
+
const reservesCount = allReserves.length;
|
|
57
|
+
const maxRemainedUninvestedLamports = lamportsToCollDecimal(new Decimal(reservesCount), vaultTokenDecimals); // invest only if the AUM has more lamports than the number of reserves
|
|
54
58
|
// Iteratively allocate funds to reserves based on weights and caps
|
|
55
|
-
while (totalLeftToInvest.gt(
|
|
59
|
+
while (totalLeftToInvest.gt(maxRemainedUninvestedLamports) && currentAllocationSum.gt(ZERO)) {
|
|
56
60
|
const totalLeftover = totalLeftToInvest;
|
|
57
61
|
|
|
58
62
|
for (const reserve of allReserves) {
|