@kamino-finance/klend-sdk 2.13.9 → 3.0.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/README_KAMINO_MANAGER.md +69 -0
- package/dist/classes/action.js +27 -14
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/index.d.ts +2 -0
- package/dist/classes/index.js +2 -0
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/manager.d.ts +145 -0
- package/dist/classes/manager.js +313 -0
- package/dist/classes/manager.js.map +1 -0
- package/dist/classes/obligation.d.ts +1 -1
- package/dist/classes/obligation.js +2 -2
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +13 -2
- package/dist/classes/reserve.js +753 -0
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/vault.d.ts +150 -0
- package/dist/classes/vault.js +615 -0
- package/dist/classes/vault.js.map +1 -0
- package/dist/client_kamino_manager.d.ts +11 -0
- package/dist/client_kamino_manager.js +465 -0
- package/dist/client_kamino_manager.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.d.ts +89 -0
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.js +164 -0
- package/dist/idl_codegen_kamino_vault/accounts/Reserve.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +68 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +179 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/accounts/index.d.ts +4 -0
- package/dist/idl_codegen_kamino_vault/accounts/index.js +8 -0
- package/dist/idl_codegen_kamino_vault/accounts/index.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/errors/anchor.d.ts +434 -0
- package/dist/idl_codegen_kamino_vault/errors/anchor.js +713 -0
- package/dist/idl_codegen_kamino_vault/errors/anchor.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +194 -0
- package/dist/idl_codegen_kamino_vault/errors/custom.js +322 -0
- package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/errors/index.d.ts +5 -0
- package/dist/idl_codegen_kamino_vault/errors/index.js +65 -0
- package/dist/idl_codegen_kamino_vault/errors/index.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/deposit.d.ts +19 -0
- package/dist/idl_codegen_kamino_vault/instructions/deposit.js +58 -0
- package/dist/idl_codegen_kamino_vault/instructions/deposit.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/index.d.ts +10 -0
- package/dist/idl_codegen_kamino_vault/instructions/index.js +14 -0
- package/dist/idl_codegen_kamino_vault/instructions/index.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +13 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js +23 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/invest.d.ts +18 -0
- package/dist/idl_codegen_kamino_vault/instructions/invest.js +43 -0
- package/dist/idl_codegen_kamino_vault/instructions/invest.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +19 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +58 -0
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.d.ts +27 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.js +77 -0
- package/dist/idl_codegen_kamino_vault/instructions/withdraw.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/programId.d.ts +3 -0
- package/dist/idl_codegen_kamino_vault/programId.js +9 -0
- package/dist/idl_codegen_kamino_vault/programId.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.d.ts +27 -0
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js +70 -0
- package/dist/idl_codegen_kamino_vault/types/BigFractionBytes.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.d.ts +27 -0
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js +62 -0
- package/dist/idl_codegen_kamino_vault/types/BorrowRateCurve.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.d.ts +26 -0
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.js +66 -0
- package/dist/idl_codegen_kamino_vault/types/CurvePoint.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.d.ts +47 -0
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.js +81 -0
- package/dist/idl_codegen_kamino_vault/types/LastUpdate.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.d.ts +41 -0
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js +75 -0
- package/dist/idl_codegen_kamino_vault/types/PriceHeuristic.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.d.ts +25 -0
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js +62 -0
- package/dist/idl_codegen_kamino_vault/types/PythConfiguration.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.d.ts +53 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js +93 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveCollateral.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.d.ts +361 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js +231 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveConfig.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.d.ts +78 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.js +82 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveFees.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.d.ts +173 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js +166 -0
- package/dist/idl_codegen_kamino_vault/types/ReserveLiquidity.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.d.ts +41 -0
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js +76 -0
- package/dist/idl_codegen_kamino_vault/types/ScopeConfiguration.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.d.ts +30 -0
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js +67 -0
- package/dist/idl_codegen_kamino_vault/types/SwitchboardConfiguration.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.d.ts +117 -0
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.js +128 -0
- package/dist/idl_codegen_kamino_vault/types/TokenInfo.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.d.ts +56 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js +104 -0
- package/dist/idl_codegen_kamino_vault/types/VaultAllocation.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.d.ts +38 -0
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js +86 -0
- package/dist/idl_codegen_kamino_vault/types/WithdrawalCaps.js.map +1 -0
- package/dist/idl_codegen_kamino_vault/types/index.d.ts +30 -0
- package/dist/idl_codegen_kamino_vault/types/index.js +34 -0
- package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/instruction.d.ts +1 -0
- package/dist/utils/instruction.js +7 -0
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/managerTypes.d.ts +137 -0
- package/dist/utils/managerTypes.js +295 -0
- package/dist/utils/managerTypes.js.map +1 -0
- package/dist/utils/sendTransactionsUtils.d.ts +40 -0
- package/dist/utils/sendTransactionsUtils.js +154 -0
- package/dist/utils/sendTransactionsUtils.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
## Kamino Manager CLI
|
|
2
|
+
|
|
3
|
+
In order to use the CLI, the followign `.env` configuration is required:
|
|
4
|
+
```
|
|
5
|
+
ADMIN="../staging_owner.json"
|
|
6
|
+
RPC="https://rpc.ironforge.network/mainnet?apiKey=01HVK9A9XRZWKKDZMDDD94R5J6"
|
|
7
|
+
KLEND_PROGRAM_ID_MAINNET="KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD"
|
|
8
|
+
KVAULT_PROGRAM_ID_MAINNET="kvauTFR8qm1dhniz6pYuBZkuene3Hfrs1VQhVRgCNrr"
|
|
9
|
+
KLEND_PROGRAM_ID_STAGING="SLendK7ySfcEzyaFqy93gDnD3RtrpXJcnRwb6zFHJSh"
|
|
10
|
+
KVAULT_PROGRAM_ID_STAGING="STkvh7ostar39Fwr4uZKASs1RNNuYMFMTsE77FiRsL2"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### Create a new market
|
|
14
|
+
`npx ts-node src/client_kamino_manager.ts create-market --staging`
|
|
15
|
+
|
|
16
|
+
- bs58 - is a boolean flag. If set it will print the bs58 txn instead of executing. Should be used for multisig
|
|
17
|
+
- staging - is a boolean flag. If set, staging programs will be used
|
|
18
|
+
- multisig - address string to be used as admin PublicKey. To be used in conjunction with bs58 flag
|
|
19
|
+
|
|
20
|
+
#### Add a new asset to market / Create new reserve
|
|
21
|
+
`npx ts-node src/client_kamino_manager.ts add-asset-to-market --market market_address --mint token_mint --mint-program-id TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA --reserve-config-path ./configs/reserve_config_example.json --staging`
|
|
22
|
+
|
|
23
|
+
- market - address to create the reserve for
|
|
24
|
+
- mint - the liquidity mint to create the reserve for
|
|
25
|
+
- mint-program-id - the program id of the mint - `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA` - spl token program `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb` - for token 2022 token program
|
|
26
|
+
- bs58 - is a boolean flag. If set it will print the bs58 txn instead of executing. Should be used for multisig
|
|
27
|
+
- staging - is a boolean flag. If set, staging programs will be used
|
|
28
|
+
- multisig - address string to be used as admin PublicKey. To be used in conjunction with bs58 flag
|
|
29
|
+
|
|
30
|
+
#### Update a reserve config
|
|
31
|
+
`npx ts-node src/client_kamino_manager.ts update-reserve-config --reserve reserve_address --reserve-config-path ./configs/reserve_config_example.json --staging --update-entire-config`
|
|
32
|
+
|
|
33
|
+
- reserve - address to update the reserve config for
|
|
34
|
+
- reserve-config-path - the path to the config file to be used
|
|
35
|
+
- update-entire-config - wether to update the entrie reserve config or just the difference between current on-chain state and given config
|
|
36
|
+
- bs58 - is a boolean flag. If set it will print the bs58 txn instead of executing. Should be used for multisig
|
|
37
|
+
- staging - is a boolean flag. If set, staging programs will be used
|
|
38
|
+
|
|
39
|
+
#### Download a reserve config
|
|
40
|
+
|
|
41
|
+
In order to update a reserve config, you need the latest reserve configuration, to modify. To get the latest, this command can be used:
|
|
42
|
+
|
|
43
|
+
`npx ts-node src/client_kamino_manager.ts download-reserve-config --reserve reserve_address --staging`
|
|
44
|
+
|
|
45
|
+
- reserve - address to update the reserve config for
|
|
46
|
+
- staging - is a boolean flag. If set, staging programs will be used
|
|
47
|
+
|
|
48
|
+
#### Create a vault
|
|
49
|
+
`npx ts-node src/client_kamino_manager.ts create-vault --mint token_mint --staging`
|
|
50
|
+
|
|
51
|
+
- mint - the liquidity mint to create the reserve for
|
|
52
|
+
- bs58 - is a boolean flag. If set it will print the bs58 txn instead of executing. Should be used for multisig
|
|
53
|
+
- staging - is a boolean flag. If set, staging programs will be used
|
|
54
|
+
- multisig - address string to be used as admin PublicKey. To be used in conjunction with bs58 flag
|
|
55
|
+
|
|
56
|
+
#### Update vault reserve allocation
|
|
57
|
+
`npx ts-node src/client_kamino_manager.ts update-vault-reserve-allocation --vault vault_address --reserve reserve_address --allocation-weight number --allocation-cap number --staging`
|
|
58
|
+
|
|
59
|
+
- vault - the vault address to add/update the reserve allocation for
|
|
60
|
+
- reserve - the reserve address to add/update the reserve allocation for
|
|
61
|
+
- allocation-weight - the allocation weight for given reserve; only relevant in relation with the other reserve allocation weights
|
|
62
|
+
- allocation-cap - the allocation cap in decimal (not lamports) for given reserve
|
|
63
|
+
- bs58 - is a boolean flag. If set it will print the bs58 txn instead of executing. Should be used for multisig
|
|
64
|
+
- staging - is a boolean flag. If set, staging programs will be used
|
|
65
|
+
- multisig - address string to be used as admin PublicKey. To be used in conjunction with bs58 flag
|
|
66
|
+
|
|
67
|
+
#### Get oracle mappings
|
|
68
|
+
This can be used to get scope oracle mappings to be used when configuring the reserve oracle config.
|
|
69
|
+
`npx ts-node src/client_kamino_manager.ts get-oracle-mappings`
|
package/dist/classes/action.js
CHANGED
|
@@ -622,7 +622,6 @@ class KaminoAction {
|
|
|
622
622
|
}, this.kaminoMarket.programId));
|
|
623
623
|
}
|
|
624
624
|
addBorrowIx() {
|
|
625
|
-
var _a;
|
|
626
625
|
this.lendingIxsLabels.push(`borrowObligationLiquidity`);
|
|
627
626
|
const depositReservesList = this.getAdditionalDepositReservesList();
|
|
628
627
|
const depositReserveAccountMetas = depositReservesList.map((reserve) => {
|
|
@@ -644,9 +643,10 @@ class KaminoAction {
|
|
|
644
643
|
tokenProgram: this.reserve.getLiquidityTokenProgram(),
|
|
645
644
|
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
646
645
|
}, this.kaminoMarket.programId);
|
|
647
|
-
borrowIx.keys =
|
|
648
|
-
|
|
649
|
-
|
|
646
|
+
borrowIx.keys =
|
|
647
|
+
this.obligation.state.elevationGroup > 0 || this.obligation.refreshedStats.potentialElevationGroupUpdate > 0
|
|
648
|
+
? borrowIx.keys.concat([...depositReserveAccountMetas])
|
|
649
|
+
: borrowIx.keys;
|
|
650
650
|
this.lendingIxs.push(borrowIx);
|
|
651
651
|
}
|
|
652
652
|
addDepositAndBorrowIx() {
|
|
@@ -791,7 +791,6 @@ class KaminoAction {
|
|
|
791
791
|
}
|
|
792
792
|
addRepayIx() {
|
|
793
793
|
return __awaiter(this, void 0, void 0, function* () {
|
|
794
|
-
var _a;
|
|
795
794
|
this.lendingIxsLabels.push(`repayObligationLiquidity(reserve=${this.reserve.address})(obligation=${this.getObligationPda()})`);
|
|
796
795
|
const depositReservesList = this.getAdditionalDepositReservesList();
|
|
797
796
|
const depositReserveAccountMetas = depositReservesList.map((reserve) => {
|
|
@@ -811,13 +810,12 @@ class KaminoAction {
|
|
|
811
810
|
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
812
811
|
}, this.kaminoMarket.programId);
|
|
813
812
|
repayIx.keys =
|
|
814
|
-
|
|
813
|
+
this.obligation.state.elevationGroup > 0 ? repayIx.keys.concat([...depositReserveAccountMetas]) : repayIx.keys;
|
|
815
814
|
this.lendingIxs.push(repayIx);
|
|
816
815
|
});
|
|
817
816
|
}
|
|
818
817
|
addLiquidateIx() {
|
|
819
818
|
return __awaiter(this, arguments, void 0, function* (maxAllowedLtvOverridePercent = 0) {
|
|
820
|
-
var _a;
|
|
821
819
|
this.lendingIxsLabels.push(`liquidateObligationAndRedeemReserveCollateral`);
|
|
822
820
|
if (!this.outflowReserve) {
|
|
823
821
|
throw Error(`Withdraw reserve during liquidation is not defined`);
|
|
@@ -857,7 +855,7 @@ class KaminoAction {
|
|
|
857
855
|
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
858
856
|
}, this.kaminoMarket.programId);
|
|
859
857
|
liquidateIx.keys =
|
|
860
|
-
|
|
858
|
+
this.obligation.state.elevationGroup > 0
|
|
861
859
|
? liquidateIx.keys.concat([...depositReserveAccountMetas])
|
|
862
860
|
: liquidateIx.keys;
|
|
863
861
|
this.lendingIxs.push(liquidateIx);
|
|
@@ -1033,12 +1031,22 @@ class KaminoAction {
|
|
|
1033
1031
|
throw new Error(`Could not decide on refresh farm for action ${action}`);
|
|
1034
1032
|
}
|
|
1035
1033
|
}
|
|
1036
|
-
if (action === 'depositAndBorrow' && requestElevationGroup) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1034
|
+
if ((action === 'depositAndBorrow' || action === 'borrow') && requestElevationGroup) {
|
|
1035
|
+
let emodeGroupsDebt = this.reserve.state.config.elevationGroups;
|
|
1036
|
+
let emodeGroupsColl = this.reserve.state.config.elevationGroups;
|
|
1037
|
+
let debtReserve = this.reserve.address;
|
|
1038
|
+
if (action === 'depositAndBorrow') {
|
|
1039
|
+
emodeGroupsDebt = this.outflowReserve.state.config.elevationGroups;
|
|
1040
|
+
debtReserve = this.outflowReserve.address;
|
|
1041
|
+
}
|
|
1042
|
+
else if (action === 'borrow') {
|
|
1043
|
+
const depositReserve = this.obligation.state.deposits.find((x) => !x.depositReserve.equals(web3_js_1.PublicKey.default)).depositReserve;
|
|
1044
|
+
const collReserve = this.kaminoMarket.getReserveByAddress(depositReserve);
|
|
1045
|
+
emodeGroupsColl = collReserve.state.config.elevationGroups;
|
|
1046
|
+
}
|
|
1039
1047
|
const groups = this.kaminoMarket.state.elevationGroups;
|
|
1040
|
-
const commonElevationGroups = [...
|
|
1041
|
-
console.log('Groups of coll reserve',
|
|
1048
|
+
const commonElevationGroups = [...emodeGroupsColl].filter((item) => emodeGroupsDebt.includes(item) && item !== 0 && groups[item - 1].debtReserve.equals(debtReserve));
|
|
1049
|
+
console.log('Groups of coll reserve', emodeGroupsColl, 'Groups of debt reserve', emodeGroupsDebt, 'Common groups', commonElevationGroups);
|
|
1042
1050
|
if (commonElevationGroups.length === 0) {
|
|
1043
1051
|
console.log('No common elevation groups found, staying with default');
|
|
1044
1052
|
}
|
|
@@ -1050,8 +1058,13 @@ class KaminoAction {
|
|
|
1050
1058
|
});
|
|
1051
1059
|
const eModeGroup = groups.find((group) => group.id === eModeGroupWithMaxLtvAndDebtReserve).id;
|
|
1052
1060
|
console.log('Setting eModeGroup to', eModeGroup);
|
|
1061
|
+
let addToSetupIxs = false;
|
|
1053
1062
|
if (eModeGroup !== 0 && eModeGroup !== ((_a = this.obligation) === null || _a === void 0 ? void 0 : _a.state.elevationGroup)) {
|
|
1054
|
-
|
|
1063
|
+
if (action === 'borrow') {
|
|
1064
|
+
this.obligation.refreshedStats.potentialElevationGroupUpdate = eModeGroup;
|
|
1065
|
+
addToSetupIxs = true;
|
|
1066
|
+
}
|
|
1067
|
+
this.addRequestElevationIx(eModeGroup, addToSetupIxs);
|
|
1055
1068
|
this.addRefreshReserveIxs(allReservesExcludingCurrent, addToSetupIxs);
|
|
1056
1069
|
this.addRefreshReserveIxs(currentReserveAddresses.toArray(), addToSetupIxs);
|
|
1057
1070
|
this.addRefreshObligationIx(addToSetupIxs);
|