@kamino-finance/klend-sdk 7.1.10 → 7.2.1
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 +480 -80
- package/dist/classes/vault.js.map +1 -1
- package/dist/manager/client_kamino_manager.js +103 -50
- 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 +680 -84
- package/src/manager/client_kamino_manager.ts +144 -62
- package/src/utils/farmUtils.ts +0 -1
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
lamportsToDecimal,
|
|
21
21
|
LendingMarket,
|
|
22
22
|
parseZeroPaddedUtf8,
|
|
23
|
-
printHoldings,
|
|
24
23
|
Reserve,
|
|
25
24
|
ReserveAllocationConfig,
|
|
26
25
|
ReserveWithAddress,
|
|
@@ -49,6 +48,7 @@ import { initEnv, ManagerEnv } from './tx/ManagerEnv';
|
|
|
49
48
|
import { processTx } from './tx/processor';
|
|
50
49
|
import { getPriorityFeeAndCuIxs } from '../client/tx/priorityFee';
|
|
51
50
|
import { fetchAddressLookupTable, fetchAllAddressLookupTable } from '@solana-program/address-lookup-table';
|
|
51
|
+
import { noopSigner } from '../utils/signer';
|
|
52
52
|
|
|
53
53
|
dotenv.config({
|
|
54
54
|
path: `.env${process.env.ENV ? '.' + process.env.ENV : ''}`,
|
|
@@ -401,7 +401,7 @@ async function main() {
|
|
|
401
401
|
.option(`--staging`, 'If true, will use the staging programs')
|
|
402
402
|
.action(async ({ vault, mode, symbol, extraName, staging }) => {
|
|
403
403
|
const env = await initEnv(undefined, staging);
|
|
404
|
-
const kVault = new KaminoVault(address(vault));
|
|
404
|
+
const kVault = new KaminoVault(env.c.rpc, address(vault));
|
|
405
405
|
|
|
406
406
|
const kaminoManager = new KaminoManager(
|
|
407
407
|
env.c.rpc,
|
|
@@ -409,7 +409,7 @@ async function main() {
|
|
|
409
409
|
env.klendProgramId,
|
|
410
410
|
env.kvaultProgramId
|
|
411
411
|
);
|
|
412
|
-
const vaultState = await kVault.getState(
|
|
412
|
+
const vaultState = await kVault.getState();
|
|
413
413
|
const signer = await env.getSigner({ vaultState });
|
|
414
414
|
const ix = await kaminoManager.getSetSharesMetadataIx(signer, kVault, symbol, extraName);
|
|
415
415
|
|
|
@@ -447,8 +447,8 @@ async function main() {
|
|
|
447
447
|
env.kvaultProgramId
|
|
448
448
|
);
|
|
449
449
|
|
|
450
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
451
|
-
const vaultState = await kaminoVault.getState(
|
|
450
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
451
|
+
const vaultState = await kaminoVault.getState();
|
|
452
452
|
const signer = await env.getSigner({ vaultState });
|
|
453
453
|
|
|
454
454
|
const instructions = await kaminoManager.updateVaultConfigIxs(
|
|
@@ -496,8 +496,8 @@ async function main() {
|
|
|
496
496
|
env.kvaultProgramId
|
|
497
497
|
);
|
|
498
498
|
|
|
499
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
500
|
-
const vaultState = await kaminoVault.getState(
|
|
499
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
500
|
+
const vaultState = await kaminoVault.getState();
|
|
501
501
|
const signer = await env.getSigner({ vaultState });
|
|
502
502
|
|
|
503
503
|
const instructions = await kaminoManager.updateVaultConfigIxs(kaminoVault, field, value, signer);
|
|
@@ -539,8 +539,8 @@ async function main() {
|
|
|
539
539
|
env.kvaultProgramId
|
|
540
540
|
);
|
|
541
541
|
|
|
542
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
543
|
-
const vaultState = await kaminoVault.getState(
|
|
542
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
543
|
+
const vaultState = await kaminoVault.getState();
|
|
544
544
|
const signer = await env.getSigner({ vaultState });
|
|
545
545
|
const instructions = await kaminoManager.updateVaultConfigIxs(
|
|
546
546
|
kaminoVault,
|
|
@@ -651,8 +651,8 @@ async function main() {
|
|
|
651
651
|
env.kvaultProgramId
|
|
652
652
|
);
|
|
653
653
|
|
|
654
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
655
|
-
const vaultState = await kaminoVault.getState(
|
|
654
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
655
|
+
const vaultState = await kaminoVault.getState();
|
|
656
656
|
const signer = await env.getSigner({ vaultState });
|
|
657
657
|
const syncLUTIxs = await kaminoManager.syncVaultLUTIxs(signer, kaminoVault);
|
|
658
658
|
|
|
@@ -711,8 +711,8 @@ async function main() {
|
|
|
711
711
|
env.kvaultProgramId
|
|
712
712
|
);
|
|
713
713
|
|
|
714
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
715
|
-
const vaultState = await kaminoVault.getState(
|
|
714
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
715
|
+
const vaultState = await kaminoVault.getState();
|
|
716
716
|
const signer = await env.getSigner({ vaultState });
|
|
717
717
|
const instructions = await kaminoManager.updateVaultConfigIxs(
|
|
718
718
|
kaminoVault,
|
|
@@ -757,8 +757,8 @@ async function main() {
|
|
|
757
757
|
env.kvaultProgramId
|
|
758
758
|
);
|
|
759
759
|
|
|
760
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
761
|
-
const vaultState = await kaminoVault.getState(
|
|
760
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
761
|
+
const vaultState = await kaminoVault.getState();
|
|
762
762
|
const pendingAdmin = await env.getSigner({
|
|
763
763
|
vaultState,
|
|
764
764
|
useVaultPendingAdmin: true,
|
|
@@ -835,8 +835,8 @@ async function main() {
|
|
|
835
835
|
env.kvaultProgramId
|
|
836
836
|
);
|
|
837
837
|
|
|
838
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
839
|
-
const vaultState = await kaminoVault.getState(
|
|
838
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
839
|
+
const vaultState = await kaminoVault.getState();
|
|
840
840
|
const signer = await env.getSigner({ vaultState });
|
|
841
841
|
const instruction = await kaminoManager.giveUpPendingFeesIx(kaminoVault, new Decimal(maxAmountToGiveUp), signer);
|
|
842
842
|
|
|
@@ -875,8 +875,8 @@ async function main() {
|
|
|
875
875
|
env.kvaultProgramId
|
|
876
876
|
);
|
|
877
877
|
|
|
878
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
879
|
-
const vaultState = await kaminoVault.getState(
|
|
878
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
879
|
+
const vaultState = await kaminoVault.getState();
|
|
880
880
|
const signer = await env.getSigner({ vaultState });
|
|
881
881
|
|
|
882
882
|
const instructions = await kaminoManager.withdrawPendingFeesIxs(
|
|
@@ -922,8 +922,8 @@ async function main() {
|
|
|
922
922
|
env.kvaultProgramId
|
|
923
923
|
);
|
|
924
924
|
|
|
925
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
926
|
-
const vaultState = await kaminoVault.getState(
|
|
925
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
926
|
+
const vaultState = await kaminoVault.getState();
|
|
927
927
|
const signer = await env.getSigner({ vaultState });
|
|
928
928
|
|
|
929
929
|
const ixs = await kaminoManager.fullRemoveReserveFromVaultIxs(signer, kaminoVault, reserveAddress);
|
|
@@ -964,7 +964,7 @@ async function main() {
|
|
|
964
964
|
const user = await env.getSigner();
|
|
965
965
|
const vaultAddress = address(vault);
|
|
966
966
|
|
|
967
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
967
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
968
968
|
|
|
969
969
|
const stakeIxs = await new KaminoManager(
|
|
970
970
|
env.c.rpc,
|
|
@@ -992,15 +992,16 @@ async function main() {
|
|
|
992
992
|
.command('update-vault-reserve-allocation')
|
|
993
993
|
.requiredOption('--vault <string>', 'Vault address')
|
|
994
994
|
.requiredOption('--reserve <string>', 'Reserve address')
|
|
995
|
-
.requiredOption('--allocation-weight <number>', 'Allocation weight')
|
|
996
|
-
.requiredOption('--allocation-cap <string>', 'Allocation cap decimal value')
|
|
997
995
|
.requiredOption(
|
|
998
996
|
`--mode <string>`,
|
|
999
997
|
'simulate|multisig|execute - simulate - to print txn simulation and to get tx simulation link in explorer, execute - execute tx, multisig - to get bs58 tx for multisig usage'
|
|
1000
998
|
)
|
|
999
|
+
.option('--allocation-weight <number>', 'Allocation weight')
|
|
1000
|
+
.option('--allocation-cap <string>', 'Allocation cap decimal value')
|
|
1001
1001
|
.option(`--staging`, 'If true, will use the staging programs')
|
|
1002
1002
|
.option(`--multisig <string>`, 'If using multisig mode this is required, otherwise will be ignored')
|
|
1003
|
-
.
|
|
1003
|
+
.option(`--skip-lut-update`, 'If set, it will skip the LUT update')
|
|
1004
|
+
.action(async ({ vault, reserve, mode, allocationWeight, allocationCap, staging, multisig, skipLutUpdate }) => {
|
|
1004
1005
|
if (mode === 'multisig' && !multisig) {
|
|
1005
1006
|
throw new Error('If using multisig mode, multisig is required');
|
|
1006
1007
|
}
|
|
@@ -1008,11 +1009,12 @@ async function main() {
|
|
|
1008
1009
|
const env = await initEnv(staging, ms);
|
|
1009
1010
|
const reserveAddress = address(reserve);
|
|
1010
1011
|
const vaultAddress = address(vault);
|
|
1011
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
1012
|
-
const vaultState = await kaminoVault.getState(
|
|
1012
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
1013
|
+
const vaultState = await kaminoVault.getState();
|
|
1013
1014
|
const signer = await env.getSigner({ vaultState });
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1015
|
+
const shouldUpdateLut = skipLutUpdate ? false : true;
|
|
1016
|
+
let allocationWeightValue: number;
|
|
1017
|
+
let allocationCapDecimal: Decimal;
|
|
1016
1018
|
|
|
1017
1019
|
const kaminoManager = new KaminoManager(
|
|
1018
1020
|
env.c.rpc,
|
|
@@ -1025,6 +1027,29 @@ async function main() {
|
|
|
1025
1027
|
throw new Error('Reserve not found');
|
|
1026
1028
|
}
|
|
1027
1029
|
|
|
1030
|
+
const existentAllocation = kaminoManager.getVaultAllocations(vaultState).get(reserveAddress);
|
|
1031
|
+
|
|
1032
|
+
if (allocationWeight) {
|
|
1033
|
+
allocationWeightValue = Number(allocationWeight);
|
|
1034
|
+
} else if (existentAllocation) {
|
|
1035
|
+
allocationWeightValue = existentAllocation.targetWeight.toNumber();
|
|
1036
|
+
} else {
|
|
1037
|
+
throw new Error('Allocation weight is required');
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
if (allocationCap) {
|
|
1041
|
+
allocationCapDecimal = new Decimal(allocationCap);
|
|
1042
|
+
} else if (existentAllocation) {
|
|
1043
|
+
allocationCapDecimal = existentAllocation.tokenAllocationCap.div(
|
|
1044
|
+
new Decimal(10).pow(Number(vaultState.tokenMintDecimals.toString()))
|
|
1045
|
+
);
|
|
1046
|
+
} else {
|
|
1047
|
+
throw new Error('Allocation cap is required');
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
console.log('allocationWeightValue', allocationWeightValue);
|
|
1051
|
+
console.log('allocationCapDecimal', allocationCapDecimal.toString());
|
|
1052
|
+
|
|
1028
1053
|
const reserveWithAddress: ReserveWithAddress = {
|
|
1029
1054
|
address: reserveAddress,
|
|
1030
1055
|
state: reserveState,
|
|
@@ -1040,19 +1065,17 @@ async function main() {
|
|
|
1040
1065
|
firstReserveAllocationConfig,
|
|
1041
1066
|
signer
|
|
1042
1067
|
);
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
[]
|
|
1055
|
-
);
|
|
1068
|
+
const txInstructions = [
|
|
1069
|
+
instructions.updateReserveAllocationIx,
|
|
1070
|
+
...instructions.updateLUTIxs,
|
|
1071
|
+
...getPriorityFeeAndCuIxs({
|
|
1072
|
+
priorityFeeMultiplier: 2500,
|
|
1073
|
+
}),
|
|
1074
|
+
];
|
|
1075
|
+
if (shouldUpdateLut) {
|
|
1076
|
+
txInstructions.push(...instructions.updateLUTIxs);
|
|
1077
|
+
}
|
|
1078
|
+
await processTx(env.c, signer, txInstructions, mode, []);
|
|
1056
1079
|
|
|
1057
1080
|
mode === 'execute' && console.log('Vault allocation updated');
|
|
1058
1081
|
});
|
|
@@ -1081,7 +1104,7 @@ async function main() {
|
|
|
1081
1104
|
env.kvaultProgramId
|
|
1082
1105
|
);
|
|
1083
1106
|
|
|
1084
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
1107
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
1085
1108
|
const payer = await env.getSigner();
|
|
1086
1109
|
const depositInstructions = await kaminoManager.depositToVaultIxs(payer, kaminoVault, amount);
|
|
1087
1110
|
const instructions = [...depositInstructions.depositIxs, ...depositInstructions.stakeInFarmIfNeededIxs];
|
|
@@ -1128,8 +1151,8 @@ async function main() {
|
|
|
1128
1151
|
env.kvaultProgramId
|
|
1129
1152
|
);
|
|
1130
1153
|
|
|
1131
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
1132
|
-
const vaultState = await kaminoVault.getState(
|
|
1154
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
1155
|
+
const vaultState = await kaminoVault.getState();
|
|
1133
1156
|
const lookupTableAddresses = [];
|
|
1134
1157
|
if (vaultState.vaultLookupTable !== DEFAULT_PUBLIC_KEY) {
|
|
1135
1158
|
lookupTableAddresses.push(vaultState.vaultLookupTable);
|
|
@@ -1186,7 +1209,7 @@ async function main() {
|
|
|
1186
1209
|
env.kvaultProgramId
|
|
1187
1210
|
);
|
|
1188
1211
|
|
|
1189
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
1212
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
1190
1213
|
const instructions = await kaminoManager.investAllReservesIxs(payer, kaminoVault);
|
|
1191
1214
|
|
|
1192
1215
|
for (let i = 0; i < instructions.length; i++) {
|
|
@@ -1234,7 +1257,8 @@ async function main() {
|
|
|
1234
1257
|
env.kvaultProgramId
|
|
1235
1258
|
);
|
|
1236
1259
|
|
|
1237
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
1260
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
1261
|
+
|
|
1238
1262
|
const reserveAddress = address(reserve);
|
|
1239
1263
|
const reserveState = await Reserve.fetch(env.c.rpc, reserveAddress, env.klendProgramId);
|
|
1240
1264
|
if (!reserveState) {
|
|
@@ -1292,7 +1316,7 @@ async function main() {
|
|
|
1292
1316
|
const kaminoManager = new KaminoManager(env.c.rpc, slotDuration, env.klendProgramId, env.kvaultProgramId);
|
|
1293
1317
|
|
|
1294
1318
|
const vaultAddress = address(vault);
|
|
1295
|
-
const vaultState = await new KaminoVault(vaultAddress, undefined, env.kvaultProgramId).getState(
|
|
1319
|
+
const vaultState = await new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId).getState();
|
|
1296
1320
|
const vaultCollaterals = await kaminoManager.getVaultCollaterals(
|
|
1297
1321
|
vaultState,
|
|
1298
1322
|
await env.c.rpc.getSlot({ commitment: 'confirmed' }).send()
|
|
@@ -1317,9 +1341,9 @@ async function main() {
|
|
|
1317
1341
|
const kaminoManager = new KaminoManager(env.c.rpc, slotDuration, env.klendProgramId, env.kvaultProgramId);
|
|
1318
1342
|
|
|
1319
1343
|
const vaultAddress = address(vault);
|
|
1320
|
-
const
|
|
1344
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId);
|
|
1321
1345
|
const vaultOverview = await kaminoManager.getVaultOverview(
|
|
1322
|
-
|
|
1346
|
+
kaminoVault,
|
|
1323
1347
|
new Decimal(tokenPrice),
|
|
1324
1348
|
await env.c.rpc.getSlot({ commitment: 'confirmed' }).send()
|
|
1325
1349
|
);
|
|
@@ -1342,7 +1366,7 @@ async function main() {
|
|
|
1342
1366
|
|
|
1343
1367
|
const kaminoManager = new KaminoManager(env.c.rpc, slotDuration, env.klendProgramId, env.kvaultProgramId);
|
|
1344
1368
|
|
|
1345
|
-
const kaminoVault = new KaminoVault(address(vault));
|
|
1369
|
+
const kaminoVault = new KaminoVault(env.c.rpc, address(vault), undefined, env.kvaultProgramId, slotDuration);
|
|
1346
1370
|
const farmAPY = await kaminoManager.getVaultFarmRewardsAPY(kaminoVault, new Decimal(tokenPrice));
|
|
1347
1371
|
console.log('farmAPY', farmAPY);
|
|
1348
1372
|
});
|
|
@@ -1373,7 +1397,7 @@ async function main() {
|
|
|
1373
1397
|
const kaminoManager = new KaminoManager(env.c.rpc, slotDuration, env.klendProgramId, env.kvaultProgramId);
|
|
1374
1398
|
|
|
1375
1399
|
const vaultAddress = address(vault);
|
|
1376
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
1400
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId, slotDuration);
|
|
1377
1401
|
|
|
1378
1402
|
const allVaultsTokenMints = await kaminoManager.getAllVaultsTokenMintsIncludingRewards([kaminoVault]);
|
|
1379
1403
|
console.log('allVaultsTokenMints', allVaultsTokenMints);
|
|
@@ -1390,7 +1414,13 @@ async function main() {
|
|
|
1390
1414
|
const kaminoManager = new KaminoManager(env.c.rpc, slotDuration, env.klendProgramId, env.kvaultProgramId);
|
|
1391
1415
|
|
|
1392
1416
|
const vaultAddress = address(vault);
|
|
1393
|
-
const vaultState = await new KaminoVault(
|
|
1417
|
+
const vaultState = await new KaminoVault(
|
|
1418
|
+
env.c.rpc,
|
|
1419
|
+
vaultAddress,
|
|
1420
|
+
undefined,
|
|
1421
|
+
env.kvaultProgramId,
|
|
1422
|
+
slotDuration
|
|
1423
|
+
).getState();
|
|
1394
1424
|
const allocationDistribution = kaminoManager.getAllocationsDistribuionPct(vaultState);
|
|
1395
1425
|
|
|
1396
1426
|
allocationDistribution.forEach((allocation, reserveAddress) => {
|
|
@@ -1412,7 +1442,7 @@ async function main() {
|
|
|
1412
1442
|
|
|
1413
1443
|
const vaultAddress = address(vault);
|
|
1414
1444
|
const walletAddress = address(wallet);
|
|
1415
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
1445
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId, slotDuration);
|
|
1416
1446
|
const userShares = await kaminoManager.getUserSharesBalanceSingleVault(walletAddress, kaminoVault);
|
|
1417
1447
|
console.log(
|
|
1418
1448
|
`User shares for vault ${vaultAddress}: unstaked shares: ${userShares.unstakedShares} staked shares: ${userShares.stakedShares} total shares: ${userShares.totalShares}`
|
|
@@ -1451,7 +1481,7 @@ async function main() {
|
|
|
1451
1481
|
const kaminoManager = new KaminoManager(env.c.rpc, slotDuration, env.klendProgramId, env.kvaultProgramId);
|
|
1452
1482
|
|
|
1453
1483
|
const vaultAddress = address(vault);
|
|
1454
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
1484
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId, slotDuration);
|
|
1455
1485
|
const tokensPerShare = await kaminoManager.getTokensPerShareSingleVault(
|
|
1456
1486
|
kaminoVault,
|
|
1457
1487
|
await env.c.rpc.getSlot({ commitment: 'confirmed' }).send()
|
|
@@ -1470,26 +1500,25 @@ async function main() {
|
|
|
1470
1500
|
const kaminoManager = new KaminoManager(env.c.rpc, slotDuration, env.klendProgramId, env.kvaultProgramId);
|
|
1471
1501
|
|
|
1472
1502
|
const vaultAddress = address(vault);
|
|
1473
|
-
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kvaultProgramId);
|
|
1474
|
-
await kaminoVault.getState(
|
|
1503
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress, undefined, env.kvaultProgramId, slotDuration);
|
|
1504
|
+
const vaultState = await kaminoVault.getState();
|
|
1475
1505
|
|
|
1476
1506
|
const slot = await env.c.rpc.getSlot({ commitment: 'confirmed' }).send();
|
|
1477
1507
|
const tokensPerShare = await kaminoManager.getTokensPerShareSingleVault(kaminoVault, slot);
|
|
1478
1508
|
const holdings = await kaminoManager.getVaultHoldings(kaminoVault.state!, slot);
|
|
1479
|
-
const vaultState = kaminoVault.state!;
|
|
1480
1509
|
|
|
1481
1510
|
const sharesIssued = lamportsToDecimal(
|
|
1482
1511
|
vaultState.sharesIssued.toString(),
|
|
1483
1512
|
vaultState.sharesMintDecimals.toString()
|
|
1484
1513
|
);
|
|
1485
1514
|
|
|
1486
|
-
const vaultOverview = await kaminoManager.getVaultOverview(
|
|
1515
|
+
const vaultOverview = await kaminoManager.getVaultOverview(kaminoVault, new Decimal(1.0), slot);
|
|
1487
1516
|
|
|
1488
1517
|
console.log('farm', vaultState.vaultFarm.toString());
|
|
1489
1518
|
console.log('vault token mint', vaultState.tokenMint);
|
|
1490
1519
|
console.log('Name: ', kaminoManager.getDecodedVaultName(kaminoVault.state!));
|
|
1491
1520
|
console.log('Shares issued: ', sharesIssued);
|
|
1492
|
-
|
|
1521
|
+
holdings.print();
|
|
1493
1522
|
console.log(`Tokens per share for vault ${vaultAddress}: ${tokensPerShare}`);
|
|
1494
1523
|
console.log('vaultOverview', vaultOverview);
|
|
1495
1524
|
|
|
@@ -1613,7 +1642,13 @@ async function main() {
|
|
|
1613
1642
|
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
1614
1643
|
|
|
1615
1644
|
const kaminoManager = new KaminoManager(env.c.rpc, slotDuration, env.klendProgramId, env.kvaultProgramId);
|
|
1616
|
-
const vaultState = await new KaminoVault(
|
|
1645
|
+
const vaultState = await new KaminoVault(
|
|
1646
|
+
env.c.rpc,
|
|
1647
|
+
vaultAddress,
|
|
1648
|
+
undefined,
|
|
1649
|
+
env.kvaultProgramId,
|
|
1650
|
+
slotDuration
|
|
1651
|
+
).getState();
|
|
1617
1652
|
|
|
1618
1653
|
const simulatedHoldings = await kaminoManager.calculateSimulatedHoldingsWithInterest(vaultState);
|
|
1619
1654
|
|
|
@@ -1657,7 +1692,13 @@ async function main() {
|
|
|
1657
1692
|
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
1658
1693
|
|
|
1659
1694
|
const kaminoManager = new KaminoManager(env.c.rpc, slotDuration, env.klendProgramId, env.kvaultProgramId);
|
|
1660
|
-
const vaultState = await new KaminoVault(
|
|
1695
|
+
const vaultState = await new KaminoVault(
|
|
1696
|
+
env.c.rpc,
|
|
1697
|
+
vaultAddress,
|
|
1698
|
+
undefined,
|
|
1699
|
+
env.kvaultProgramId,
|
|
1700
|
+
slotDuration
|
|
1701
|
+
).getState();
|
|
1661
1702
|
|
|
1662
1703
|
const computedAllocation = await kaminoManager.getVaultComputedReservesAllocation(vaultState);
|
|
1663
1704
|
console.log('computedAllocation', computedAllocation);
|
|
@@ -1975,6 +2016,47 @@ async function main() {
|
|
|
1975
2016
|
console.log(adminInfo);
|
|
1976
2017
|
});
|
|
1977
2018
|
|
|
2019
|
+
commands
|
|
2020
|
+
.command('claim-rewards-for-vault')
|
|
2021
|
+
.requiredOption('--vault <string>', 'Vault address')
|
|
2022
|
+
.requiredOption(
|
|
2023
|
+
`--mode <string>`,
|
|
2024
|
+
'simulate|multisig|execute - simulate - to print txn simulation and to get tx simulation link in explorer, execute - execute tx, multisig - to get bs58 tx for multisig usage'
|
|
2025
|
+
)
|
|
2026
|
+
.option(`--staging`, 'If true, will use the staging programs')
|
|
2027
|
+
.option(`--user <string>`, 'User address')
|
|
2028
|
+
.action(async ({ vault, mode, staging, user }) => {
|
|
2029
|
+
const env = await initEnv(staging);
|
|
2030
|
+
const vaultAddress = address(vault);
|
|
2031
|
+
const kaminoVault = new KaminoVault(env.c.rpc, vaultAddress);
|
|
2032
|
+
const kaminoManager = new KaminoManager(
|
|
2033
|
+
env.c.rpc,
|
|
2034
|
+
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
2035
|
+
env.klendProgramId,
|
|
2036
|
+
env.kvaultProgramId
|
|
2037
|
+
);
|
|
2038
|
+
const userWallet = user ? noopSigner(address(user)) : await env.getSigner();
|
|
2039
|
+
const rewardsIxs = await kaminoManager.getClaimAllRewardsForVaultIxs(userWallet, kaminoVault);
|
|
2040
|
+
|
|
2041
|
+
if (rewardsIxs.length > 0) {
|
|
2042
|
+
await processTx(
|
|
2043
|
+
env.c,
|
|
2044
|
+
userWallet,
|
|
2045
|
+
[
|
|
2046
|
+
...rewardsIxs,
|
|
2047
|
+
...getPriorityFeeAndCuIxs({
|
|
2048
|
+
priorityFeeMultiplier: 2500,
|
|
2049
|
+
computeUnits: 400_000,
|
|
2050
|
+
}),
|
|
2051
|
+
],
|
|
2052
|
+
mode,
|
|
2053
|
+
[]
|
|
2054
|
+
);
|
|
2055
|
+
} else {
|
|
2056
|
+
console.log('No rewards to claim');
|
|
2057
|
+
}
|
|
2058
|
+
});
|
|
2059
|
+
|
|
1978
2060
|
await commands.parseAsync();
|
|
1979
2061
|
}
|
|
1980
2062
|
|
package/src/utils/farmUtils.ts
CHANGED
|
@@ -20,7 +20,6 @@ export async function getReserveFarmRewardsAPY(
|
|
|
20
20
|
farmsClient: Farms,
|
|
21
21
|
slot: Slot,
|
|
22
22
|
reserveState?: Reserve,
|
|
23
|
-
cTokenMintDecimals?: number,
|
|
24
23
|
tokensPrices?: Map<Address, Decimal>
|
|
25
24
|
): Promise<ReserveIncentives> {
|
|
26
25
|
const reserveIncentives: ReserveIncentives = {
|