@kamino-finance/klend-sdk 5.0.6 → 5.1.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 +154 -17
- package/dist/classes/action.d.ts +5 -1
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +39 -26
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +22 -0
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +29 -0
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/vault.d.ts +30 -0
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +177 -0
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +113 -1
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +10 -10
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +52 -51
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +3 -9
- package/dist/leverage/operations.js.map +1 -1
- package/dist/referrals/instructions.d.ts +2 -1
- package/dist/referrals/instructions.d.ts.map +1 -1
- package/dist/referrals/instructions.js +13 -8
- package/dist/referrals/instructions.js.map +1 -1
- package/dist/utils/ata.d.ts +1 -2
- package/dist/utils/ata.d.ts.map +1 -1
- package/dist/utils/ata.js +8 -15
- package/dist/utils/ata.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/action.ts +41 -33
- package/src/classes/manager.ts +34 -0
- package/src/classes/vault.ts +250 -0
- package/src/client.ts +4 -20
- package/src/client_kamino_manager.ts +174 -1
- package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +116 -117
- package/src/leverage/operations.ts +3 -9
- package/src/referrals/instructions.ts +16 -9
- package/src/utils/ata.ts +8 -14
package/README_KAMINO_MANAGER.md
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## 1. Kamino Manager CLI
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Installation Instructions
|
|
6
6
|
|
|
7
7
|
Ensure *yarn* is installed first [here](https://classic.yarnpkg.com/lang/en/docs/install/)
|
|
8
|
+
|
|
8
9
|
```shell
|
|
9
10
|
git clone git@github.com:Kamino-Finance/klend-sdk.git
|
|
10
11
|
cd klend-sdk
|
|
@@ -14,6 +15,7 @@ yarn
|
|
|
14
15
|
#### Requirements
|
|
15
16
|
|
|
16
17
|
In order to use the CLI, the followign `.env` configuration is required:
|
|
18
|
+
|
|
17
19
|
```
|
|
18
20
|
ADMIN="admin.json"
|
|
19
21
|
RPC="https://rpc.cluster"
|
|
@@ -23,14 +25,17 @@ KLEND_PROGRAM_ID_STAGING="SLendK7ySfcEzyaFqy93gDnD3RtrpXJcnRwb6zFHJSh"
|
|
|
23
25
|
KVAULT_PROGRAM_ID_STAGING="STkvh7ostar39Fwr4uZKASs1RNNuYMFMTsE77FiRsL2"
|
|
24
26
|
```
|
|
25
27
|
|
|
28
|
+
### Kamino Lending
|
|
29
|
+
|
|
26
30
|
#### Create a new market
|
|
31
|
+
|
|
27
32
|
```
|
|
28
33
|
yarn kamino-manager create-market --staging --mode execute
|
|
29
34
|
```
|
|
30
35
|
|
|
31
36
|
- **mode** - can have these values:
|
|
32
37
|
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
33
|
-
- *simulate* - will print the simulation outputs
|
|
38
|
+
- *simulate* - will print the simulation outputs
|
|
34
39
|
- *execute* - will execute the transaction
|
|
35
40
|
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
36
41
|
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
@@ -38,6 +43,7 @@ yarn kamino-manager create-market --staging --mode execute
|
|
|
38
43
|
- **multisig** - address string to be used as admin PublicKey. To be used in conjunction with multisig mode
|
|
39
44
|
|
|
40
45
|
#### Add a new asset to market / Create new reserve
|
|
46
|
+
|
|
41
47
|
```
|
|
42
48
|
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
49
|
```
|
|
@@ -48,7 +54,7 @@ yarn kamino-manager add-asset-to-market --market market_address --mint token_min
|
|
|
48
54
|
- **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
55
|
- **mode** - can have these values:
|
|
50
56
|
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
51
|
-
- *simulate* - will print the simulation outputs
|
|
57
|
+
- *simulate* - will print the simulation outputs
|
|
52
58
|
- *execute* - will execute the transaction
|
|
53
59
|
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
54
60
|
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
@@ -67,6 +73,7 @@ yarn kamino-manager download-reserve-config --reserve reserve_address --staging
|
|
|
67
73
|
- **staging** - is a boolean flag. If set, staging programs will be used
|
|
68
74
|
|
|
69
75
|
#### Update a reserve config
|
|
76
|
+
|
|
70
77
|
```
|
|
71
78
|
yarn kamino-manager update-reserve-config --reserve reserve_address --reserve-config-path ./configs/reserve_config_example.json --staging --update-entire-config --mode execute
|
|
72
79
|
```
|
|
@@ -76,7 +83,7 @@ yarn kamino-manager update-reserve-config --reserve reserve_address --reserve-co
|
|
|
76
83
|
- **update-entire-config** - wether to update the entrie reserve config or just the difference between current on-chain state and given config
|
|
77
84
|
- **mode** - can have these values:
|
|
78
85
|
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
79
|
-
- *simulate* - will print the simulation outputs
|
|
86
|
+
- *simulate* - will print the simulation outputs
|
|
80
87
|
- *execute* - will execute the transaction
|
|
81
88
|
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
82
89
|
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
@@ -93,7 +100,7 @@ yarn kamino-manager download-lending-market-config --lending-market lending_mark
|
|
|
93
100
|
- **lending-market** - address to download the lending market config for
|
|
94
101
|
- **staging** - is a boolean flag. If set, staging programs will be used
|
|
95
102
|
|
|
96
|
-
#### Download a lending market together with all the associated reserves
|
|
103
|
+
#### Download a lending market together with all the associated reserves
|
|
97
104
|
|
|
98
105
|
```
|
|
99
106
|
yarn kamino-manager download-lending-market-config-and-all-reserves-configs --lending-market lending_market_address --staging
|
|
@@ -103,6 +110,7 @@ yarn kamino-manager download-lending-market-config-and-all-reserves-configs --le
|
|
|
103
110
|
- **staging** - is a boolean flag. If set, staging programs will be used
|
|
104
111
|
|
|
105
112
|
#### Update a lending market
|
|
113
|
+
|
|
106
114
|
```
|
|
107
115
|
yarn kamino-manager update-lending-market-from-config --lending-market lending_market_address --staging --lending-market-config-path ./configs/lending_market_address/market-lending_market_address.json --mode inspect --staging
|
|
108
116
|
```
|
|
@@ -111,23 +119,28 @@ yarn kamino-manager update-lending-market-from-config --lending-market lending_m
|
|
|
111
119
|
- **lending-market-config-path** - the path to the config file to be used
|
|
112
120
|
- **mode** - can have these values:
|
|
113
121
|
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
114
|
-
- *simulate* - will print the simulation outputs
|
|
122
|
+
- *simulate* - will print the simulation outputs
|
|
115
123
|
- *execute* - will execute the transaction
|
|
116
124
|
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
117
125
|
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
118
126
|
- **staging** - is a boolean flag. If set, staging programs will be used
|
|
119
127
|
|
|
120
128
|
#### Update a lending market owner
|
|
121
|
-
|
|
129
|
+
|
|
130
|
+
All markets should be owned by a multisig once they are publicly used and maintained.
|
|
122
131
|
However, to start of with, preparing the configuration and adding all the necessary reserves would take longer under a multisig.
|
|
123
132
|
In order to migrate from a hot wallet (private key on a local machine) you first need to set the lending_market_owner_cached to the new admin (ideally multisig) using the command above, followed by running the following command:
|
|
124
133
|
|
|
125
134
|
```
|
|
126
135
|
yarn kamino-manager update-lending-market-owner --lending-market lending_market_address --staging --mode multisig
|
|
127
136
|
```
|
|
137
|
+
|
|
128
138
|
**To note** this command can only be executed by the current market lending_market_owner_cached and it will set the lending_market_owner to that address.
|
|
129
139
|
|
|
130
|
-
|
|
140
|
+
### Kamino lending Vaults (kVaults)
|
|
141
|
+
|
|
142
|
+
#### Create a vault
|
|
143
|
+
|
|
131
144
|
```
|
|
132
145
|
yarn kamino-manager create-vault --mint token_mint --staging --mode execute
|
|
133
146
|
```
|
|
@@ -135,7 +148,7 @@ yarn kamino-manager create-vault --mint token_mint --staging --mode execute
|
|
|
135
148
|
- **mint** - the liquidity mint to create the reserve for
|
|
136
149
|
- **mode** - can have these values:
|
|
137
150
|
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
138
|
-
- *simulate* - will print the simulation outputs
|
|
151
|
+
- *simulate* - will print the simulation outputs
|
|
139
152
|
- *execute* - will execute the transaction
|
|
140
153
|
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
141
154
|
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
@@ -143,6 +156,7 @@ yarn kamino-manager create-vault --mint token_mint --staging --mode execute
|
|
|
143
156
|
- **multisig** - address string to be used as admin PublicKey. To be used in conjunction with multisig mode
|
|
144
157
|
|
|
145
158
|
#### Update vault reserve allocation
|
|
159
|
+
|
|
146
160
|
```
|
|
147
161
|
yarn kamino-manager update-vault-reserve-allocation --vault vault_address --reserve reserve_address --allocation-weight number --allocation-cap number --staging --mode execute
|
|
148
162
|
```
|
|
@@ -153,44 +167,145 @@ yarn kamino-manager update-vault-reserve-allocation --vault vault_address --rese
|
|
|
153
167
|
- **allocation-cap** - the allocation cap in decimal (not lamports) for given reserve
|
|
154
168
|
- **mode** - can have these values:
|
|
155
169
|
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
156
|
-
- *simulate* - will print the simulation outputs
|
|
170
|
+
- *simulate* - will print the simulation outputs
|
|
157
171
|
- *execute* - will execute the transaction
|
|
158
172
|
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
159
173
|
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
160
174
|
- **staging** - is a boolean flag. If set, staging programs will be used
|
|
161
175
|
- **multisig** - address string to be used as admin PublicKey. To be used in conjunction with multisig mode
|
|
162
176
|
|
|
163
|
-
####
|
|
177
|
+
#### Update vault pending admin
|
|
178
|
+
|
|
179
|
+
(note that this updates only the `pending_admin` field, to actually set the `admin` the `pending_admin` has to accept ownership [see command below])
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
yarn kamino-manager update-vault-pending-admin --vault <vault_address> --new-admin <new_admin_pubkey> --mode <mode>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- **vault** - the vault address to change the pending admin for
|
|
186
|
+
- **new-admin** - the new admin pubkey to set as pending admin
|
|
187
|
+
- **mode** - can have these values:
|
|
188
|
+
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
189
|
+
- *simulate* - will print the simulation outputs
|
|
190
|
+
- *execute* - will execute the transaction
|
|
191
|
+
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
192
|
+
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
193
|
+
|
|
194
|
+
#### Accept vault ownership
|
|
195
|
+
|
|
196
|
+
This is called by the `pending_admin` to accept the ownership of the vault where it is the `pending_admin`.
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
yarn kamino-manager accept-ownership --vault <vault_address> --mode <mode>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
- **vault** - the vault address to change the pending admin for
|
|
203
|
+
- **mode** - can have these values:
|
|
204
|
+
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
205
|
+
- *simulate* - will print the simulation outputs
|
|
206
|
+
- *execute* - will execute the transaction
|
|
207
|
+
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
208
|
+
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
209
|
+
|
|
210
|
+
#### Update performance fee
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
yarn kamino-manager update-vault-perf-fee --vault <vault_address> --fee-bps <performance_fee_in_bps> --mode <mode>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
- **vault** - the vault address to change the pending admin for
|
|
217
|
+
- **fee-bps** - the performance fee applied to all generalted yield, in basis points
|
|
218
|
+
- **mode** - can have these values:
|
|
219
|
+
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
220
|
+
- *simulate* - will print the simulation outputs
|
|
221
|
+
- *execute* - will execute the transaction
|
|
222
|
+
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
223
|
+
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
224
|
+
|
|
225
|
+
#### Update management fee
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
yarn kamino-manager update-vault-mgmt-fee --vault <vault_address> --fee-bps <yearly_mgmt_fee_in_bps> --mode <mode>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
- **vault** - the vault address to change the pending admin for
|
|
232
|
+
- **fee-bps** - the yearly management fee, in basis points
|
|
233
|
+
- **mode** - can have these values:
|
|
234
|
+
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
235
|
+
- *simulate* - will print the simulation outputs
|
|
236
|
+
- *execute* - will execute the transaction
|
|
237
|
+
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
238
|
+
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
239
|
+
|
|
240
|
+
#### Give up pending fees
|
|
241
|
+
|
|
242
|
+
This instruction makes the vault manager to give up a part provided as parameter(or full) of the pending fees, which will become part of the vault so will be distributed to the holders of the vault.
|
|
243
|
+
This can be used also in the case where the pending fees get bigger than the total vault, so the manager give up the pending fees and the vault gets back to a "healthy" state.
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
yarn kamino-manager give-up-pending-fees --vault <vault_address> --max-amount-to-give-up <max_amount_to_give_up_in_tokens> --mode <mode>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
- **vault** - the vault address to change the pending admin for
|
|
250
|
+
- **max-amount-to-give-up** - the amount in tokens to be given up from the pending fees
|
|
251
|
+
- **mode** - can have these values:
|
|
252
|
+
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
253
|
+
- *simulate* - will print the simulation outputs
|
|
254
|
+
- *execute* - will execute the transaction
|
|
255
|
+
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
256
|
+
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
257
|
+
|
|
258
|
+
#### Withdraw pending fees
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
yarn kamino-manager withdraw-pending-fees --vault <vault_address> --mode <mode>
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
- **vault** - the vault address to change the pending admin for
|
|
265
|
+
- **mode** - can have these values:
|
|
266
|
+
- *inspect* - will print an url to the explorer txn inspection, where it can be simulated
|
|
267
|
+
- *simulate* - will print the simulation outputs
|
|
268
|
+
- *execute* - will execute the transaction
|
|
269
|
+
- *multisig* - will print the bs58 transaction to be used within a multisig
|
|
270
|
+
It is recommended to **1. inspect/simulate** and then **2. execute/multisig**
|
|
271
|
+
|
|
272
|
+
#### Get oracle mappings
|
|
273
|
+
|
|
164
274
|
This can be used to get scope oracle mappings to be used when configuring the reserve oracle config.
|
|
275
|
+
|
|
165
276
|
```
|
|
166
277
|
yarn kamino-manager get-oracle-mappings
|
|
167
278
|
```
|
|
168
279
|
|
|
169
280
|
#### Useful to know
|
|
170
281
|
|
|
171
|
-
**Exploring the created markets** on the webapp can be done by going to
|
|
172
|
-
https://app.kamino.finance/?STAGING_PROGRAM&market=market_address for the staging program
|
|
173
|
-
https://app.kamino.finance/?market=market_address for the prod program
|
|
282
|
+
**Exploring the created markets** on the webapp can be done by going to
|
|
283
|
+
<https://app.kamino.finance/?STAGING_PROGRAM&market=market_address> for the staging program
|
|
284
|
+
<https://app.kamino.finance/?market=market_address> for the prod program
|
|
174
285
|
|
|
175
286
|
**Creating a new keypair to use as an admin** can be achieved by running the following:
|
|
287
|
+
|
|
176
288
|
```
|
|
177
289
|
solana-keygen new -o path_to_private_key.json
|
|
178
290
|
```
|
|
291
|
+
|
|
179
292
|
make sure to keep the private key **private** and only shar ethe public key.
|
|
180
293
|
If you forget the publickey you can get it by running the following:
|
|
294
|
+
|
|
181
295
|
```
|
|
182
296
|
solana-keygen pubkey path_to_private_key.json
|
|
183
297
|
```
|
|
184
298
|
|
|
185
|
-
## 2. Kamino Manager Class
|
|
299
|
+
## 2. Kamino Manager Class
|
|
186
300
|
|
|
187
|
-
In order to use the kamino manager class, which provides a high-level interface
|
|
188
|
-
for the main actions in regards to managing a market or a vault, you will need to use
|
|
301
|
+
In order to use the kamino manager class, which provides a high-level interface
|
|
302
|
+
for the main actions in regards to managing a market or a vault, you will need to use
|
|
189
303
|
the kamino manager class.
|
|
190
304
|
|
|
191
305
|
#### Installation Instructions
|
|
192
306
|
|
|
193
307
|
Run one of the following commands within the project directory you want to use the manager class within
|
|
308
|
+
|
|
194
309
|
```shell
|
|
195
310
|
# npm
|
|
196
311
|
npm install @kamino-finance/klend-sdk
|
|
@@ -212,3 +327,25 @@ const kaminoManager = new KaminoManager(connection, kLendProgramId, kVaultProgra
|
|
|
212
327
|
#### Example Usage
|
|
213
328
|
|
|
214
329
|
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
|
|
330
|
+
|
|
331
|
+
## 3. Multisig management
|
|
332
|
+
|
|
333
|
+
For all the interactions and ownership of kVaults we recommend using [a Squads multisig](https://app.squads.so/squads) and a hardware wallet.
|
|
334
|
+
|
|
335
|
+
### Creating a new multisig
|
|
336
|
+
|
|
337
|
+
On the [Squads page](https://app.squads.so/squads) click on the `Create Squad` button and follow the instructions. You'll have to provide a name, the wallets of the other team members if you have any and a threshold (the number of signatures required to execute a transaction).
|
|
338
|
+
After the Squad is created on top left screen you can see its balance and address, the address is what will be the owner of the kVaults.
|
|
339
|
+
|
|
340
|
+
### Creating a new vault under a multisig
|
|
341
|
+
|
|
342
|
+
To have a strategy under multisig you can:
|
|
343
|
+
|
|
344
|
+
- Create the strategy with a hot wallet and then transfer the ownership to the multisig:
|
|
345
|
+
- create the strategy with the hot wallet: `yarn kamino-manager create-vault --mint <token_mint> --mode execute`
|
|
346
|
+
- set the pending admin to the multisig (run it with `--mode simulate` before so you ensure it does what is expected): `yarn kamino-manager update-vault-pending-admin --vault <vault_address> --new-admin <multisig_pubkey> --mode execute`
|
|
347
|
+
- create the proposal for the multisig to accept membership using this command: `yarn kamino-manager accept-vault-ownership --vault <vault_pubkey> --mode multisig --multisig <multisig_pubkey>`and then propose and execute in the multisig
|
|
348
|
+
|
|
349
|
+
### Managing a vault under a multisig
|
|
350
|
+
|
|
351
|
+
For all actions that require admin permissions (updating reserves allocation, setting the performance and management fee, collect pending fees, give up fees) at the commands above you will need to add the `--multisig <multisig_pubkey>` flag and the command will return the base58 transaction to be proposed in the multisig.
|
package/dist/classes/action.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export declare class KaminoAction {
|
|
|
29
29
|
positions?: number;
|
|
30
30
|
amount: BN;
|
|
31
31
|
outflowAmount?: BN;
|
|
32
|
+
computeBudgetIxs: Array<TransactionInstruction>;
|
|
33
|
+
computeBudgetIxsLabels: Array<string>;
|
|
32
34
|
setupIxs: Array<TransactionInstruction>;
|
|
33
35
|
setupIxsLabels: Array<string>;
|
|
34
36
|
inBetweenIxs: Array<TransactionInstruction>;
|
|
@@ -144,7 +146,7 @@ export declare class KaminoAction {
|
|
|
144
146
|
private addInitObligationForFarm;
|
|
145
147
|
private addInitObligationIxs;
|
|
146
148
|
private addInitUserMetadataIxs;
|
|
147
|
-
private
|
|
149
|
+
private addInitReferrerTokenStateIx;
|
|
148
150
|
private addWithdrawReferrerFeesIxs;
|
|
149
151
|
private addComputeBudgetIxn;
|
|
150
152
|
private addAtaIxs;
|
|
@@ -159,5 +161,7 @@ export declare class KaminoAction {
|
|
|
159
161
|
private static getReferrerKey;
|
|
160
162
|
static actionToIxs(action: KaminoAction): Array<TransactionInstruction>;
|
|
161
163
|
static actionToLendingIxs(action: KaminoAction): Array<TransactionInstruction>;
|
|
164
|
+
static actionToIxLabels(action: KaminoAction): Array<string>;
|
|
165
|
+
static actionToLendingIxLabels(action: KaminoAction): Array<string>;
|
|
162
166
|
}
|
|
163
167
|
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/classes/action.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,4BAA4B,EAI5B,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,MAAM,OAAO,CAAC;AA2BvB,OAAO,EAGL,cAAc,
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/classes/action.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,4BAA4B,EAI5B,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAAE,MAAM,OAAO,CAAC;AA2BvB,OAAO,EAGL,cAAc,EAUd,YAAY,EACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,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
|
setupIxs;
|
|
44
46
|
setupIxsLabels;
|
|
45
47
|
inBetweenIxs;
|
|
@@ -74,6 +76,8 @@ class KaminoAction {
|
|
|
74
76
|
this.positions = positions;
|
|
75
77
|
this.userTokenAccountAddress = userTokenAccountAddress;
|
|
76
78
|
this.userCollateralAccountAddress = userCollateralAccountAddress;
|
|
79
|
+
this.computeBudgetIxs = [];
|
|
80
|
+
this.computeBudgetIxsLabels = [];
|
|
77
81
|
this.setupIxs = [];
|
|
78
82
|
this.setupIxsLabels = [];
|
|
79
83
|
this.inBetweenIxs = [];
|
|
@@ -1086,7 +1090,12 @@ class KaminoAction {
|
|
|
1086
1090
|
if (!ownerUserMetadata && includeUserMetadata) {
|
|
1087
1091
|
await this.addInitUserMetadataIxs();
|
|
1088
1092
|
}
|
|
1089
|
-
|
|
1093
|
+
if (['borrow', 'withdrawReferrerFees'].includes(action)) {
|
|
1094
|
+
await this.addInitReferrerTokenStateIx(this.reserve);
|
|
1095
|
+
}
|
|
1096
|
+
if (action === 'deposit' && this.outflowReserve) { // depositAndBorrow
|
|
1097
|
+
await this.addInitReferrerTokenStateIx(this.outflowReserve);
|
|
1098
|
+
}
|
|
1090
1099
|
await this.addInitObligationIxs();
|
|
1091
1100
|
}
|
|
1092
1101
|
await this.addSupportIxsWithoutInitObligation(action, includeAtaIxns, 'setup', requestElevationGroup, addInitObligationForFarm, false, twoTokenAction, overrideElevationGroupRequest);
|
|
@@ -1385,38 +1394,26 @@ class KaminoAction {
|
|
|
1385
1394
|
this.setupIxs.push(initUserMetadataIx);
|
|
1386
1395
|
this.setupIxsLabels.push(`initUserMetadata[${userMetadataAddress.toString()}]`);
|
|
1387
1396
|
}
|
|
1388
|
-
async
|
|
1397
|
+
async addInitReferrerTokenStateIx(reserve) {
|
|
1389
1398
|
if (this.referrer.equals(web3_js_1.PublicKey.default)) {
|
|
1390
1399
|
return;
|
|
1391
1400
|
}
|
|
1392
|
-
const
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
const tokenStatesToCreate = [];
|
|
1397
|
-
for (const reserve of reserves) {
|
|
1398
|
-
if (!reserve) {
|
|
1399
|
-
continue;
|
|
1400
|
-
}
|
|
1401
|
-
const referrerTokenStateAddress = (0, utils_1.referrerTokenStatePda)(this.referrer, reserve, this.kaminoMarket.programId)[0];
|
|
1402
|
-
if (!(await (0, utils_1.checkIfAccountExists)(this.kaminoMarket.getConnection(), referrerTokenStateAddress))) {
|
|
1403
|
-
tokenStatesToCreate.push([referrerTokenStateAddress, reserve]);
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
tokenStatesToCreate.forEach(([referrerTokenStateAddress, reserveAddress]) => {
|
|
1407
|
-
const initreferrerTokenStateIx = (0, instructions_1.initReferrerTokenState)({
|
|
1401
|
+
const referrerTokenState = (0, utils_1.referrerTokenStatePda)(this.referrer, reserve.address, this.kaminoMarket.programId)[0];
|
|
1402
|
+
const account = await this.kaminoMarket.getConnection().getAccountInfo(referrerTokenState);
|
|
1403
|
+
if (!account) {
|
|
1404
|
+
const initReferrerTokenStateIx = (0, instructions_1.initReferrerTokenState)({
|
|
1408
1405
|
referrer: this.referrer,
|
|
1409
1406
|
}, {
|
|
1410
1407
|
lendingMarket: this.kaminoMarket.getAddress(),
|
|
1411
1408
|
payer: this.owner,
|
|
1412
|
-
reserve:
|
|
1413
|
-
referrerTokenState
|
|
1409
|
+
reserve: reserve.address,
|
|
1410
|
+
referrerTokenState,
|
|
1414
1411
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
1415
1412
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
1416
1413
|
}, this.kaminoMarket.programId);
|
|
1417
|
-
this.setupIxs.unshift(
|
|
1418
|
-
this.setupIxsLabels.unshift(`InitReferrerTokenState[${
|
|
1419
|
-
}
|
|
1414
|
+
this.setupIxs.unshift(initReferrerTokenStateIx);
|
|
1415
|
+
this.setupIxsLabels.unshift(`InitReferrerTokenState[${referrerTokenState.toString()} res=${reserve.address}]`);
|
|
1416
|
+
}
|
|
1420
1417
|
}
|
|
1421
1418
|
addWithdrawReferrerFeesIxs() {
|
|
1422
1419
|
const referrerTokenStateAddress = (0, utils_1.referrerTokenStatePda)(this.owner, this.reserve.address, this.kaminoMarket.programId)[0];
|
|
@@ -1435,8 +1432,8 @@ class KaminoAction {
|
|
|
1435
1432
|
this.lendingIxsLabels.push(`WithdrawReferrerFeesIx[${this.owner.toString()}]`);
|
|
1436
1433
|
}
|
|
1437
1434
|
addComputeBudgetIxn(units) {
|
|
1438
|
-
this.
|
|
1439
|
-
this.
|
|
1435
|
+
this.computeBudgetIxs.push((0, utils_1.buildComputeBudgetIx)(units));
|
|
1436
|
+
this.computeBudgetIxsLabels.push(`AddComputeBudget[${units}]`);
|
|
1440
1437
|
}
|
|
1441
1438
|
async addAtaIxs(action) {
|
|
1442
1439
|
if (this.mint.equals(utils_1.WRAPPED_SOL_MINT) || this.secondaryMint?.equals(utils_1.WRAPPED_SOL_MINT)) {
|
|
@@ -1688,7 +1685,7 @@ class KaminoAction {
|
|
|
1688
1685
|
return referrerKey;
|
|
1689
1686
|
}
|
|
1690
1687
|
static actionToIxs(action) {
|
|
1691
|
-
const ixs = [...action.setupIxs];
|
|
1688
|
+
const ixs = [...action.computeBudgetIxs, ...action.setupIxs];
|
|
1692
1689
|
ixs.push(...KaminoAction.actionToLendingIxs(action));
|
|
1693
1690
|
ixs.push(...action.cleanupIxs);
|
|
1694
1691
|
return ixs;
|
|
@@ -1703,6 +1700,22 @@ class KaminoAction {
|
|
|
1703
1700
|
}
|
|
1704
1701
|
return ixs;
|
|
1705
1702
|
}
|
|
1703
|
+
static actionToIxLabels(action) {
|
|
1704
|
+
const labels = [...action.computeBudgetIxsLabels, ...action.setupIxsLabels];
|
|
1705
|
+
labels.push(...KaminoAction.actionToLendingIxLabels(action));
|
|
1706
|
+
labels.push(...action.cleanupIxsLabels);
|
|
1707
|
+
return labels;
|
|
1708
|
+
}
|
|
1709
|
+
static actionToLendingIxLabels(action) {
|
|
1710
|
+
const lables = [];
|
|
1711
|
+
for (let i = 0; i < action.lendingIxsLabels.length; i++) {
|
|
1712
|
+
lables.push(action.lendingIxsLabels[i]);
|
|
1713
|
+
if (i !== action.lendingIxsLabels.length - 1) {
|
|
1714
|
+
lables.push(...action.inBetweenIxsLabels);
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
return lables;
|
|
1718
|
+
}
|
|
1706
1719
|
}
|
|
1707
1720
|
exports.KaminoAction = KaminoAction;
|
|
1708
1721
|
//# sourceMappingURL=action.js.map
|