@kamino-finance/klend-sdk 3.2.0 → 3.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.
@@ -1,4 +1,17 @@
1
- ## Kamino Manager CLI
1
+ # Kamino Manager Guidelines
2
+
3
+ ## 1. Kamino Manager CLI
4
+
5
+ #### Installation Instructions
6
+
7
+ Ensure *yarn* is installed first [here](https://classic.yarnpkg.com/lang/en/docs/install/)
8
+ ```shell
9
+ git clone git@github.com:Kamino-Finance/klend-sdk.git
10
+ cd klend-sdk
11
+ yarn
12
+ ```
13
+
14
+ #### Requirements
2
15
 
3
16
  In order to use the CLI, the followign `.env` configuration is required:
4
17
  ```
@@ -11,59 +24,134 @@ KVAULT_PROGRAM_ID_STAGING="STkvh7ostar39Fwr4uZKASs1RNNuYMFMTsE77FiRsL2"
11
24
  ```
12
25
 
13
26
  #### Create a new market
14
- `npx ts-node src/client_kamino_manager.ts create-market --staging`
27
+ ```
28
+ yarn kamino-manager create-market --staging --mode execute
29
+ ```
15
30
 
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
31
+ - **mode** - can have these values:
32
+ - *inspect* - will print an url to the explorer txn inspection, where it can be simulated
33
+ - *simulate* - will print the simulation outputs
34
+ - *execute* - will execute the transaction
35
+ - *multisig* - will print the bs58 transaction to be used within a multisig
36
+ It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
37
+ - **staging** - is a boolean flag. If set, staging programs will be used
38
+ - **multisig** - address string to be used as admin PublicKey. To be used in conjunction with multisig mode
19
39
 
20
40
  #### 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`
41
+ ```
42
+ yarn kamino-manager add-asset-to-market --market market_address --mint token_mint --mint-program-id TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA --reserve-config-path ./configs/reserve_config_example.json --staging --mode execute
43
+ ```
22
44
 
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
45
+ - **market** - address to create the reserve for
46
+ - **mint** - the liquidity mint to create the reserve for
47
+ - **mint-program-id** - the program id of the mint - `TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA` - spl token program `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb` - for token 2022 token program
48
+ - **reserve-config-path** - path to the reserve config to be used. A reserve config example can be found [here](https://github.com/Kamino-Finance/klend-sdk/blob/master/configs/reserve_config_example.json)
49
+ - **mode** - can have these values:
50
+ - *inspect* - will print an url to the explorer txn inspection, where it can be simulated
51
+ - *simulate* - will print the simulation outputs
52
+ - *execute* - will execute the transaction
53
+ - *multisig* - will print the bs58 transaction to be used within a multisig
54
+ It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
55
+ - **staging** - is a boolean flag. If set, staging programs will be used
56
+ - **multisig** - address string to be used as admin PublicKey. To be used in conjunction with multisig mode
29
57
 
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
58
 
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
59
 
39
60
  #### Download a reserve config
40
61
 
41
62
  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
63
 
43
- `npx ts-node src/client_kamino_manager.ts download-reserve-config --reserve reserve_address --staging`
64
+ ```
65
+ yarn kamino-manager download-reserve-config --reserve reserve_address --staging
66
+ ```
67
+
68
+ - **reserve** - address to update the reserve config for
69
+ - **staging** - is a boolean flag. If set, staging programs will be used
70
+
71
+ #### Update a reserve config
72
+ ```
73
+ yarn kamino-manager update-reserve-config --reserve reserve_address --reserve-config-path ./configs/reserve_config_example.json --staging --update-entire-config --mode execute
74
+ ```
75
+
76
+ - **reserve** - address to update the reserve config for
77
+ - **reserve-config-path** - the path to the config file to be used
78
+ - **update-entire-config** - wether to update the entrie reserve config or just the difference between current on-chain state and given config
79
+ - **mode** - can have these values:
80
+ - *inspect* - will print an url to the explorer txn inspection, where it can be simulated
81
+ - *simulate* - will print the simulation outputs
82
+ - *execute* - will execute the transaction
83
+ - *multisig* - will print the bs58 transaction to be used within a multisig
84
+ It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
85
+ - **staging** - is a boolean flag. If set, staging programs will be used
44
86
 
45
- - reserve - address to update the reserve config for
46
- - staging - is a boolean flag. If set, staging programs will be used
87
+ A reserve config example can be found [here](https://github.com/Kamino-Finance/klend-sdk/blob/master/configs/reserve_config_example.json)
47
88
 
48
89
  #### Create a vault
49
- `npx ts-node src/client_kamino_manager.ts create-vault --mint token_mint --staging`
90
+ ```
91
+ yarn kamino-manager create-vault --mint token_mint --staging --mode execute
92
+ ```
50
93
 
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
94
+ - **mint** - the liquidity mint to create the reserve for
95
+ - **mode** - can have these values:
96
+ - *inspect* - will print an url to the explorer txn inspection, where it can be simulated
97
+ - *simulate* - will print the simulation outputs
98
+ - *execute* - will execute the transaction
99
+ - *multisig* - will print the bs58 transaction to be used within a multisig
100
+ It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
101
+ - **staging** - is a boolean flag. If set, staging programs will be used
102
+ - **multisig** - address string to be used as admin PublicKey. To be used in conjunction with multisig mode
55
103
 
56
104
  #### 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`
105
+ ```
106
+ yarn kamino-manager update-vault-reserve-allocation --vault vault_address --reserve reserve_address --allocation-weight number --allocation-cap number --staging --mode execute
107
+ ```
58
108
 
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
109
+ - **vault** - the vault address to add/update the reserve allocation for
110
+ - **reserve** - the reserve address to add/update the reserve allocation for
111
+ - **allocation-weight** - the allocation weight for given reserve; only relevant in relation with the other reserve allocation weights
112
+ - **allocation-cap** - the allocation cap in decimal (not lamports) for given reserve
113
+ - **mode** - can have these values:
114
+ - *inspect* - will print an url to the explorer txn inspection, where it can be simulated
115
+ - *simulate* - will print the simulation outputs
116
+ - *execute* - will execute the transaction
117
+ - *multisig* - will print the bs58 transaction to be used within a multisig
118
+ It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
119
+ - **staging** - is a boolean flag. If set, staging programs will be used
120
+ - **multisig** - address string to be used as admin PublicKey. To be used in conjunction with multisig mode
66
121
 
67
122
  #### Get oracle mappings
68
123
  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`
124
+ ```
125
+ yarn kamino-manager get-oracle-mappings
126
+ ```
127
+
128
+ ## 2. Kamino Manager Class
129
+
130
+ In order to use the kamino manager class, which provides a high-level interface
131
+ for the main actions in regards to managing a market or a vault, you will need to use
132
+ the kamino manager class.
133
+
134
+ #### Installation Instructions
135
+
136
+ Run one of the following commands within the project directory you want to use the manager class within
137
+ ```shell
138
+ # npm
139
+ npm install @kamino-finance/klend-sdk
140
+
141
+ # yarn
142
+ yarn add @kamino-finance/klend-sdk
143
+ ```
144
+
145
+ #### Getting Started
146
+
147
+ ```ts
148
+ const connection = new anchor.web3.Connection("rpc.url");
149
+ const kaminoManager = new KaminoManager(connection, kLendProgramId, kVaultProgramId);
150
+ ```
151
+
152
+ - kLendProgramId and kVaultProgramId can be undefined and default prod programs will be used
153
+ - programIds can be found [here](https://github.com/Kamino-Finance/klend-sdk/blob/master/.env.example)
154
+
155
+ #### Example Usage
156
+
157
+ For usage examples, a good starting place is [this](https://github.com/Kamino-Finance/klend-sdk/blob/master/tests/kamino_manager_tests/kamino_manager.test.ts) test file
@@ -1347,7 +1347,7 @@ function updateReserveConfigEncodedValue(discriminator, value) {
1347
1347
  valueArray = value;
1348
1348
  buffer = Buffer.alloc(32);
1349
1349
  for (let i = 0; i < valueArray.length; i++) {
1350
- buffer.writeBigUint64LE(BigInt(valueArray[i]), 8 * i);
1350
+ buffer.writeUIntLE(valueArray[i], i, 1);
1351
1351
  }
1352
1352
  break;
1353
1353
  case types_1.UpdateConfigMode.UpdateScopePriceFeed.discriminator: