@velocity-exchange/vaults-sdk 0.0.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/.env.example +3 -0
- package/README.md +152 -0
- package/cli/cli.ts +751 -0
- package/cli/commands/adminDeleteFeeUpdate.ts +73 -0
- package/cli/commands/adminInitFeeUpdate.ts +73 -0
- package/cli/commands/adminUpdateVaultClass.ts +49 -0
- package/cli/commands/applyProfitShare.ts +139 -0
- package/cli/commands/decodeLogs.ts +98 -0
- package/cli/commands/deposit.ts +98 -0
- package/cli/commands/deriveVaultAddress.ts +14 -0
- package/cli/commands/forceWithdraw.ts +56 -0
- package/cli/commands/forceWithdrawAll.ts +142 -0
- package/cli/commands/index.ts +28 -0
- package/cli/commands/initVault.ts +227 -0
- package/cli/commands/initVaultDepositor.ts +42 -0
- package/cli/commands/listDepositorsForVault.ts +32 -0
- package/cli/commands/managerApplyProfitShare.ts +32 -0
- package/cli/commands/managerBorrow.ts +77 -0
- package/cli/commands/managerCancelWithdraw.ts +30 -0
- package/cli/commands/managerDeposit.ts +45 -0
- package/cli/commands/managerRepay.ts +94 -0
- package/cli/commands/managerRequestWithdraw.ts +86 -0
- package/cli/commands/managerUpdateBorrow.ts +56 -0
- package/cli/commands/managerUpdateFees.ts +156 -0
- package/cli/commands/managerUpdateMarginTradingEnabled.ts +32 -0
- package/cli/commands/managerUpdatePoolId.ts +36 -0
- package/cli/commands/managerUpdateVault.ts +210 -0
- package/cli/commands/managerUpdateVaultDelegate.ts +43 -0
- package/cli/commands/managerUpdateVaultManager.ts +77 -0
- package/cli/commands/managerWithdraw.ts +30 -0
- package/cli/commands/requestWithdraw.ts +58 -0
- package/cli/commands/vaultDeposit.ts +42 -0
- package/cli/commands/vaultInvariantChecks.ts +407 -0
- package/cli/commands/vaultWithdraw.ts +42 -0
- package/cli/commands/viewVault.ts +50 -0
- package/cli/commands/viewVaultDepositor.ts +36 -0
- package/cli/commands/withdraw.ts +40 -0
- package/cli/ledgerWallet.test.ts +49 -0
- package/cli/ledgerWallet.ts +111 -0
- package/cli/utils.ts +389 -0
- package/package.json +48 -0
- package/src/accountSubscribers/index.ts +2 -0
- package/src/accountSubscribers/pollingVaultDepositorSubscriber.ts +69 -0
- package/src/accountSubscribers/pollingVaultSubscriber.ts +63 -0
- package/src/accountSubscribers/pollingVaultsProgramAccountSubscriber.ts +114 -0
- package/src/accounts/index.ts +2 -0
- package/src/accounts/vaultAccount.ts +255 -0
- package/src/accounts/vaultDepositorAccount.ts +77 -0
- package/src/accounts/vaultsProgramAccount.ts +38 -0
- package/src/addresses.ts +114 -0
- package/src/constants/index.ts +15 -0
- package/src/idl/drift_vaults.json +5698 -0
- package/src/index.ts +11 -0
- package/src/math/index.ts +2 -0
- package/src/math/vault.ts +71 -0
- package/src/math/vaultDepositor.ts +90 -0
- package/src/name.ts +18 -0
- package/src/parsers/index.ts +1 -0
- package/src/parsers/logParser.ts +28 -0
- package/src/types/drift_vaults.ts +6211 -0
- package/src/types/types.ts +336 -0
- package/src/utils.ts +74 -0
- package/src/vaultClient.ts +3666 -0
- package/tsconfig.json +24 -0
- package/velocity-exchange-vaults-sdk-0.0.1.tgz +0 -0
package/cli/cli.ts
ADDED
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
require('dotenv').config();
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
initVault,
|
|
5
|
+
viewVault,
|
|
6
|
+
deriveVaultAddress,
|
|
7
|
+
managerDeposit,
|
|
8
|
+
managerRequestWithdraw,
|
|
9
|
+
managerCancelWithdraw,
|
|
10
|
+
managerWithdraw,
|
|
11
|
+
managerUpdateVault,
|
|
12
|
+
managerUpdateVaultManager,
|
|
13
|
+
managerUpdateVaultDelegate,
|
|
14
|
+
applyProfitShare,
|
|
15
|
+
initVaultDepositor,
|
|
16
|
+
deposit,
|
|
17
|
+
requestWithdraw,
|
|
18
|
+
withdraw,
|
|
19
|
+
forceWithdraw,
|
|
20
|
+
forceWithdrawAll,
|
|
21
|
+
listDepositorsForVault,
|
|
22
|
+
managerUpdateMarginTradingEnabled,
|
|
23
|
+
decodeLogs,
|
|
24
|
+
vaultInvariantChecks,
|
|
25
|
+
managerBorrow,
|
|
26
|
+
managerRepay,
|
|
27
|
+
managerUpdateBorrow,
|
|
28
|
+
adminUpdateVaultClass,
|
|
29
|
+
} from './commands';
|
|
30
|
+
|
|
31
|
+
import { Command, Option } from 'commander';
|
|
32
|
+
import { viewVaultDepositor } from './commands/viewVaultDepositor';
|
|
33
|
+
import { managerUpdatePoolId } from './commands/managerUpdatePoolId';
|
|
34
|
+
import { managerApplyProfitShare } from './commands/managerApplyProfitShare';
|
|
35
|
+
import { managerUpdateFees } from './commands/managerUpdateFees';
|
|
36
|
+
import { adminInitFeeUpdate } from './commands/adminInitFeeUpdate';
|
|
37
|
+
import { adminDeleteFeeUpdate } from './commands/adminDeleteFeeUpdate';
|
|
38
|
+
|
|
39
|
+
const program = new Command();
|
|
40
|
+
program
|
|
41
|
+
.addOption(
|
|
42
|
+
new Option('-u, --url <url>', 'RPC URL to use for requests')
|
|
43
|
+
.env('RPC_URL')
|
|
44
|
+
.makeOptionMandatory(true)
|
|
45
|
+
)
|
|
46
|
+
.addOption(
|
|
47
|
+
new Option('-k, --keypair <filepath>', 'Path to keypair file').env(
|
|
48
|
+
'KEYPAIR_PATH'
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
.addOption(
|
|
52
|
+
new Option('--commitment <commitment>', 'State commitment to use').default(
|
|
53
|
+
'confirmed'
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
.addOption(
|
|
57
|
+
new Option('--env <env>', 'Environment to use (devnet, mainnet-beta)')
|
|
58
|
+
.default('mainnet-beta')
|
|
59
|
+
.env('ENV')
|
|
60
|
+
);
|
|
61
|
+
program
|
|
62
|
+
.command('init-vault')
|
|
63
|
+
.description('Initialize a new vault')
|
|
64
|
+
.requiredOption('-n, --name <string>', 'Name of the vault to create')
|
|
65
|
+
.option(
|
|
66
|
+
'-i, --market-index <number>',
|
|
67
|
+
'Spot market index to accept for deposits (default 0 == USDC)',
|
|
68
|
+
'0'
|
|
69
|
+
)
|
|
70
|
+
.option(
|
|
71
|
+
'-r, --redeem-period <number>',
|
|
72
|
+
'The period (in seconds) depositors must wait after requesting a withdraw (default: 7 days)',
|
|
73
|
+
(7 * 60 * 60 * 24).toString()
|
|
74
|
+
)
|
|
75
|
+
.option(
|
|
76
|
+
'-x, --max-tokens <number>',
|
|
77
|
+
'The max number of spot marketIndex tokens the vault can accept (default 0 == unlimited)',
|
|
78
|
+
'0'
|
|
79
|
+
)
|
|
80
|
+
.option(
|
|
81
|
+
'-m, --management-fee <percent>',
|
|
82
|
+
'The annualized management fee to charge depositors',
|
|
83
|
+
'0'
|
|
84
|
+
)
|
|
85
|
+
.option(
|
|
86
|
+
'-s, --profit-share <percent>',
|
|
87
|
+
'The percentage of profits charged by manager',
|
|
88
|
+
'0'
|
|
89
|
+
)
|
|
90
|
+
.option(
|
|
91
|
+
'-p, --permissioned',
|
|
92
|
+
'Provide this flag to make the vault permissioned, vault-depositors will need to be initialized by the manager',
|
|
93
|
+
false
|
|
94
|
+
)
|
|
95
|
+
.option(
|
|
96
|
+
'-a, --min-deposit-amount <number',
|
|
97
|
+
'The minimum token amount allowed to deposit',
|
|
98
|
+
'0'
|
|
99
|
+
)
|
|
100
|
+
.option(
|
|
101
|
+
'-d, --delegate <publicKey>',
|
|
102
|
+
'The address to make the delegate of the vault'
|
|
103
|
+
)
|
|
104
|
+
.addOption(new Option('--manager <publickey>', 'The manager for the vault'))
|
|
105
|
+
.addOption(
|
|
106
|
+
new Option(
|
|
107
|
+
'--dump-transaction-message',
|
|
108
|
+
'Dump the transaction message to the console'
|
|
109
|
+
).makeOptionMandatory(false)
|
|
110
|
+
)
|
|
111
|
+
.action((opts) => initVault(program, opts));
|
|
112
|
+
program
|
|
113
|
+
.command('view-vault')
|
|
114
|
+
.description('View Vault account details')
|
|
115
|
+
.addOption(
|
|
116
|
+
new Option(
|
|
117
|
+
'--vault-address <address>',
|
|
118
|
+
'Address of the Vault to view'
|
|
119
|
+
).makeOptionMandatory(true)
|
|
120
|
+
)
|
|
121
|
+
.action((opts) => viewVault(program, opts));
|
|
122
|
+
program
|
|
123
|
+
.command('derive-vault-address')
|
|
124
|
+
.description('Derives the vault address from its name')
|
|
125
|
+
.addOption(
|
|
126
|
+
new Option(
|
|
127
|
+
'--vault-name <string>',
|
|
128
|
+
'Name of the vault'
|
|
129
|
+
).makeOptionMandatory(true)
|
|
130
|
+
)
|
|
131
|
+
.action((opts) => deriveVaultAddress(program, opts));
|
|
132
|
+
program
|
|
133
|
+
.command('view-vault-depositor')
|
|
134
|
+
.description('View VaultDepositor account details')
|
|
135
|
+
.addOption(
|
|
136
|
+
new Option(
|
|
137
|
+
'--vault-depositor-address <address>',
|
|
138
|
+
'Address of the VaultDepositor to view'
|
|
139
|
+
).makeOptionMandatory(false)
|
|
140
|
+
)
|
|
141
|
+
.addOption(
|
|
142
|
+
new Option(
|
|
143
|
+
'--vault-address <address>',
|
|
144
|
+
'Address of the Vault to view'
|
|
145
|
+
).makeOptionMandatory(false)
|
|
146
|
+
)
|
|
147
|
+
.addOption(
|
|
148
|
+
new Option(
|
|
149
|
+
'--authority <vaultDepositorAuthority>',
|
|
150
|
+
'VaultDepositor authority address'
|
|
151
|
+
).makeOptionMandatory(false)
|
|
152
|
+
)
|
|
153
|
+
.action((opts) => viewVaultDepositor(program, opts));
|
|
154
|
+
program
|
|
155
|
+
.command('list-vault-depositors')
|
|
156
|
+
.description('List VaultDepositors for a Vault')
|
|
157
|
+
.addOption(
|
|
158
|
+
new Option(
|
|
159
|
+
'--vault-address <address>',
|
|
160
|
+
'Address of the Vault to list depositors'
|
|
161
|
+
).makeOptionMandatory(true)
|
|
162
|
+
)
|
|
163
|
+
.action((opts) => listDepositorsForVault(program, opts));
|
|
164
|
+
program
|
|
165
|
+
.command('manager-deposit')
|
|
166
|
+
.description('Make a deposit to your vault')
|
|
167
|
+
.addOption(
|
|
168
|
+
new Option(
|
|
169
|
+
'--vault-address <address>',
|
|
170
|
+
'Address of the vault to deposit to'
|
|
171
|
+
).makeOptionMandatory(true)
|
|
172
|
+
)
|
|
173
|
+
.addOption(
|
|
174
|
+
new Option(
|
|
175
|
+
'--amount <amount>',
|
|
176
|
+
'Amount to deposit (in deposit precision, 5 for 5 USDC)'
|
|
177
|
+
).makeOptionMandatory(true)
|
|
178
|
+
)
|
|
179
|
+
.addOption(
|
|
180
|
+
new Option(
|
|
181
|
+
'--dump-transaction-message',
|
|
182
|
+
'Dump the transaction message to the console'
|
|
183
|
+
).makeOptionMandatory(false)
|
|
184
|
+
)
|
|
185
|
+
.action((opts) => managerDeposit(program, opts));
|
|
186
|
+
program
|
|
187
|
+
.command('manager-request-withdraw')
|
|
188
|
+
.description('Make a withdraw request from your vault')
|
|
189
|
+
.addOption(
|
|
190
|
+
new Option(
|
|
191
|
+
'--vault-address <address>',
|
|
192
|
+
'Address of the vault to withdraw from'
|
|
193
|
+
).makeOptionMandatory(true)
|
|
194
|
+
)
|
|
195
|
+
.addOption(
|
|
196
|
+
new Option(
|
|
197
|
+
'--shares <shares>',
|
|
198
|
+
'Amount of shares to withdraw (raw precision, as expected by contract)'
|
|
199
|
+
).makeOptionMandatory(false)
|
|
200
|
+
)
|
|
201
|
+
.addOption(
|
|
202
|
+
new Option(
|
|
203
|
+
'--amount <amount>',
|
|
204
|
+
'Amount of spot asset to withdraw (in deposit precision, 5 for 5 USDC)'
|
|
205
|
+
).makeOptionMandatory(false)
|
|
206
|
+
)
|
|
207
|
+
.addOption(
|
|
208
|
+
new Option(
|
|
209
|
+
'--dump-transaction-message',
|
|
210
|
+
'Dump the transaction message to the console'
|
|
211
|
+
).makeOptionMandatory(false)
|
|
212
|
+
)
|
|
213
|
+
.action((opts) => managerRequestWithdraw(program, opts));
|
|
214
|
+
program
|
|
215
|
+
.command('manager-update-vault')
|
|
216
|
+
.description('Update vault params for a manager')
|
|
217
|
+
.addOption(
|
|
218
|
+
new Option(
|
|
219
|
+
'--vault-address <address>',
|
|
220
|
+
'Address of the vault to update '
|
|
221
|
+
).makeOptionMandatory(true)
|
|
222
|
+
)
|
|
223
|
+
.option(
|
|
224
|
+
'-r, --redeem-period <number>',
|
|
225
|
+
'The new redeem period (can only be lowered)'
|
|
226
|
+
)
|
|
227
|
+
.option('-x, --max-tokens <number>', 'The max tokens the vault can accept')
|
|
228
|
+
.option(
|
|
229
|
+
'-a, --min-deposit-amount <number',
|
|
230
|
+
'The minimum token amount allowed to deposit'
|
|
231
|
+
)
|
|
232
|
+
.option(
|
|
233
|
+
'-m, --management-fee <percent>',
|
|
234
|
+
'The new management fee (can only be lowered, use timelocked manager-update-fees to raise)'
|
|
235
|
+
)
|
|
236
|
+
.option(
|
|
237
|
+
'-s, --profit-share <percent>',
|
|
238
|
+
'The new profit share percentage (can only be lowered, use timelocked manager-update-fees to raise)'
|
|
239
|
+
)
|
|
240
|
+
.option(
|
|
241
|
+
'-h, --hurdle-rate <percent>',
|
|
242
|
+
'The new hurdle rate percentage (can only be raised, use timelocked manager-update-fees to lower)'
|
|
243
|
+
)
|
|
244
|
+
.option(
|
|
245
|
+
'-p, --permissioned <boolean>',
|
|
246
|
+
'Set the vault as permissioned (true) or open (false)'
|
|
247
|
+
)
|
|
248
|
+
.addOption(
|
|
249
|
+
new Option(
|
|
250
|
+
'--dump-transaction-message',
|
|
251
|
+
'Dump the transaction message to the console'
|
|
252
|
+
).makeOptionMandatory(false)
|
|
253
|
+
)
|
|
254
|
+
.action((opts) => managerUpdateVault(program, opts));
|
|
255
|
+
program
|
|
256
|
+
.command('manager-update-vault-manager')
|
|
257
|
+
.description('Update the manager of a vault')
|
|
258
|
+
.addOption(
|
|
259
|
+
new Option(
|
|
260
|
+
'--vault-address <address>',
|
|
261
|
+
'Address of the vault to update '
|
|
262
|
+
).makeOptionMandatory(true)
|
|
263
|
+
)
|
|
264
|
+
.addOption(
|
|
265
|
+
new Option(
|
|
266
|
+
'--new-manager <publickey>',
|
|
267
|
+
'The new manager for the vault'
|
|
268
|
+
).makeOptionMandatory(true)
|
|
269
|
+
)
|
|
270
|
+
.addOption(
|
|
271
|
+
new Option(
|
|
272
|
+
'--dump-transaction-message',
|
|
273
|
+
'Dump the transaction message to the console'
|
|
274
|
+
).makeOptionMandatory(false)
|
|
275
|
+
)
|
|
276
|
+
.action((opts) => managerUpdateVaultManager(program, opts));
|
|
277
|
+
program
|
|
278
|
+
.command('manager-update-delegate')
|
|
279
|
+
.description('Update vault params for a manager')
|
|
280
|
+
.addOption(
|
|
281
|
+
new Option(
|
|
282
|
+
'--vault-address <address>',
|
|
283
|
+
'Address of the vault to update '
|
|
284
|
+
).makeOptionMandatory(true)
|
|
285
|
+
)
|
|
286
|
+
.addOption(
|
|
287
|
+
new Option(
|
|
288
|
+
'-d, --delegate <publickey>',
|
|
289
|
+
'The new delegate authority for the vault'
|
|
290
|
+
).makeOptionMandatory(true)
|
|
291
|
+
)
|
|
292
|
+
.addOption(
|
|
293
|
+
new Option(
|
|
294
|
+
'--dump-transaction-message',
|
|
295
|
+
'Dump the transaction message to the console'
|
|
296
|
+
).makeOptionMandatory(false)
|
|
297
|
+
)
|
|
298
|
+
.action((opts) => managerUpdateVaultDelegate(program, opts));
|
|
299
|
+
program
|
|
300
|
+
.command('manager-update-margin-trading-enabled')
|
|
301
|
+
.description('Update vault margin trading permissiones a manager')
|
|
302
|
+
.addOption(
|
|
303
|
+
new Option(
|
|
304
|
+
'--vault-address <address>',
|
|
305
|
+
'Address of the vault to view'
|
|
306
|
+
).makeOptionMandatory(true)
|
|
307
|
+
)
|
|
308
|
+
.addOption(
|
|
309
|
+
new Option(
|
|
310
|
+
'--enabled <enabled>',
|
|
311
|
+
'true to enable, false to disable'
|
|
312
|
+
).makeOptionMandatory(true)
|
|
313
|
+
)
|
|
314
|
+
.addOption(
|
|
315
|
+
new Option(
|
|
316
|
+
'--dump-transaction-message',
|
|
317
|
+
'Dump the transaction message to the console'
|
|
318
|
+
).makeOptionMandatory(false)
|
|
319
|
+
)
|
|
320
|
+
.action((opts) => managerUpdateMarginTradingEnabled(program, opts));
|
|
321
|
+
program
|
|
322
|
+
.command('manager-update-pool-id')
|
|
323
|
+
.description('Update the pool id for a vault')
|
|
324
|
+
.addOption(
|
|
325
|
+
new Option(
|
|
326
|
+
'--vault-address <address>',
|
|
327
|
+
'Address of the vault to view'
|
|
328
|
+
).makeOptionMandatory(true)
|
|
329
|
+
)
|
|
330
|
+
.addOption(
|
|
331
|
+
new Option(
|
|
332
|
+
'--pool-id <pool-id>',
|
|
333
|
+
'New pool id for the vault'
|
|
334
|
+
).makeOptionMandatory(true)
|
|
335
|
+
)
|
|
336
|
+
.addOption(
|
|
337
|
+
new Option(
|
|
338
|
+
'--dump-transaction-message',
|
|
339
|
+
'Dump the transaction message to the console'
|
|
340
|
+
).makeOptionMandatory(false)
|
|
341
|
+
)
|
|
342
|
+
.action((opts) => managerUpdatePoolId(program, opts));
|
|
343
|
+
program
|
|
344
|
+
.command('manager-apply-profit-share')
|
|
345
|
+
.description('Update the pool id for a vault')
|
|
346
|
+
.addOption(
|
|
347
|
+
new Option(
|
|
348
|
+
'--vault-address <address>',
|
|
349
|
+
'Address of the vault to view'
|
|
350
|
+
).makeOptionMandatory(true)
|
|
351
|
+
)
|
|
352
|
+
.addOption(
|
|
353
|
+
new Option(
|
|
354
|
+
'--vault-depositor <address>',
|
|
355
|
+
'Address of the vault depositor to apply profit share for'
|
|
356
|
+
).makeOptionMandatory(true)
|
|
357
|
+
)
|
|
358
|
+
.addOption(
|
|
359
|
+
new Option(
|
|
360
|
+
'--dump-transaction-message',
|
|
361
|
+
'Dump the transaction message to the console'
|
|
362
|
+
).makeOptionMandatory(false)
|
|
363
|
+
)
|
|
364
|
+
.action((opts) => managerApplyProfitShare(program, opts));
|
|
365
|
+
program
|
|
366
|
+
.command('manager-withdraw')
|
|
367
|
+
.description('Make a withdraw from your vault')
|
|
368
|
+
.addOption(
|
|
369
|
+
new Option(
|
|
370
|
+
'--vault-address <address>',
|
|
371
|
+
'Address of the vault to view'
|
|
372
|
+
).makeOptionMandatory(true)
|
|
373
|
+
)
|
|
374
|
+
.addOption(
|
|
375
|
+
new Option(
|
|
376
|
+
'--dump-transaction-message',
|
|
377
|
+
'Dump the transaction message to the console'
|
|
378
|
+
).makeOptionMandatory(false)
|
|
379
|
+
)
|
|
380
|
+
.action((opts) => managerWithdraw(program, opts));
|
|
381
|
+
program
|
|
382
|
+
.command('manager-cancel-withdraw')
|
|
383
|
+
.description('Cancel a pending manager withdraw withdraw from your vault')
|
|
384
|
+
.addOption(
|
|
385
|
+
new Option(
|
|
386
|
+
'--vault-address <address>',
|
|
387
|
+
'Address of the vault to view'
|
|
388
|
+
).makeOptionMandatory(true)
|
|
389
|
+
)
|
|
390
|
+
.addOption(
|
|
391
|
+
new Option(
|
|
392
|
+
'--dump-transaction-message',
|
|
393
|
+
'Dump the transaction message to the console'
|
|
394
|
+
).makeOptionMandatory(false)
|
|
395
|
+
)
|
|
396
|
+
.action((opts) => managerCancelWithdraw(program, opts));
|
|
397
|
+
program
|
|
398
|
+
.command('apply-profit-share-all')
|
|
399
|
+
.description('Turn the profit share crank for all depositors')
|
|
400
|
+
.addOption(
|
|
401
|
+
new Option(
|
|
402
|
+
'--vault-address <address>',
|
|
403
|
+
'Address of the vault to view'
|
|
404
|
+
).makeOptionMandatory(true)
|
|
405
|
+
)
|
|
406
|
+
.addOption(
|
|
407
|
+
new Option(
|
|
408
|
+
'--threshold <amount>',
|
|
409
|
+
'Minimum threshold (in spot tokens) before profit share is applied'
|
|
410
|
+
).default('1000', 'default is 1000')
|
|
411
|
+
)
|
|
412
|
+
.action((opts) => applyProfitShare(program, opts));
|
|
413
|
+
program
|
|
414
|
+
.command('init-vault-depositor')
|
|
415
|
+
.description(
|
|
416
|
+
'Initialize a VaultDepositor for someone to deposit into your vault'
|
|
417
|
+
)
|
|
418
|
+
.addOption(
|
|
419
|
+
new Option(
|
|
420
|
+
'--vault-address <address>',
|
|
421
|
+
'Address of the vault to create a VaultDepositor for'
|
|
422
|
+
).makeOptionMandatory(true)
|
|
423
|
+
)
|
|
424
|
+
.addOption(
|
|
425
|
+
new Option(
|
|
426
|
+
'--deposit-authority <depositAuthority>',
|
|
427
|
+
'Authority to create the VaultDepositor for, only they can deposit in the vault.'
|
|
428
|
+
).makeOptionMandatory(true)
|
|
429
|
+
)
|
|
430
|
+
.action((opts) => initVaultDepositor(program, opts));
|
|
431
|
+
program
|
|
432
|
+
.command('deposit')
|
|
433
|
+
.description(
|
|
434
|
+
'Deposit into a vault via VaultDepositor (creates a VaultDepositor if one does not exist)'
|
|
435
|
+
)
|
|
436
|
+
.addOption(
|
|
437
|
+
new Option(
|
|
438
|
+
'--vault-depositor-address <vaultDepositorAddress>',
|
|
439
|
+
'VaultDepositor address'
|
|
440
|
+
).makeOptionMandatory(false)
|
|
441
|
+
)
|
|
442
|
+
.addOption(
|
|
443
|
+
new Option(
|
|
444
|
+
'--vault-address <address>',
|
|
445
|
+
'Address of the vault to deposit into'
|
|
446
|
+
).makeOptionMandatory(false)
|
|
447
|
+
)
|
|
448
|
+
.addOption(
|
|
449
|
+
new Option(
|
|
450
|
+
'--deposit-authority <vaultDepositorAuthority>',
|
|
451
|
+
'VaultDepositor authority address'
|
|
452
|
+
).makeOptionMandatory(false)
|
|
453
|
+
)
|
|
454
|
+
.addOption(
|
|
455
|
+
new Option(
|
|
456
|
+
'--amount <amount>',
|
|
457
|
+
'Amount to deposit (in deposit precision, 5 for 5 USDC)'
|
|
458
|
+
).makeOptionMandatory(true)
|
|
459
|
+
)
|
|
460
|
+
.action((opts) => deposit(program, opts));
|
|
461
|
+
program
|
|
462
|
+
.command('request-withdraw')
|
|
463
|
+
.description(
|
|
464
|
+
'Make a request to withdraw shares from the vaultm, redeem period starts now'
|
|
465
|
+
)
|
|
466
|
+
.addOption(
|
|
467
|
+
new Option(
|
|
468
|
+
'--vault-depositor-address <vaultDepositorAddress>',
|
|
469
|
+
'VaultDepositor address'
|
|
470
|
+
).makeOptionMandatory(false)
|
|
471
|
+
)
|
|
472
|
+
.addOption(
|
|
473
|
+
new Option(
|
|
474
|
+
'--vault-address <address>',
|
|
475
|
+
'Address of the vault to deposit into'
|
|
476
|
+
).makeOptionMandatory(false)
|
|
477
|
+
)
|
|
478
|
+
.addOption(
|
|
479
|
+
new Option(
|
|
480
|
+
'--authority <vaultDepositorAuthority>',
|
|
481
|
+
'VaultDepositor authority address'
|
|
482
|
+
).makeOptionMandatory(false)
|
|
483
|
+
)
|
|
484
|
+
.addOption(
|
|
485
|
+
new Option(
|
|
486
|
+
'--amount <amount>',
|
|
487
|
+
'Amount of shares to withdraw (raw format, as expected in the program)'
|
|
488
|
+
).makeOptionMandatory(true)
|
|
489
|
+
)
|
|
490
|
+
.action((opts) => requestWithdraw(program, opts));
|
|
491
|
+
program
|
|
492
|
+
.command('withdraw')
|
|
493
|
+
.description('Initiate the withdraw, after the redeem period has passed')
|
|
494
|
+
.addOption(
|
|
495
|
+
new Option(
|
|
496
|
+
'--vault-depositor-address <vaultDepositorAddress>',
|
|
497
|
+
'VaultDepositor address'
|
|
498
|
+
).makeOptionMandatory(false)
|
|
499
|
+
)
|
|
500
|
+
.addOption(
|
|
501
|
+
new Option(
|
|
502
|
+
'--vault-address <address>',
|
|
503
|
+
'Address of the vault to deposit into'
|
|
504
|
+
).makeOptionMandatory(false)
|
|
505
|
+
)
|
|
506
|
+
.addOption(
|
|
507
|
+
new Option(
|
|
508
|
+
'--authority <vaultDepositorAuthority>',
|
|
509
|
+
'VaultDepositor authority address'
|
|
510
|
+
).makeOptionMandatory(false)
|
|
511
|
+
)
|
|
512
|
+
.action((opts) => withdraw(program, opts));
|
|
513
|
+
program
|
|
514
|
+
.command('force-withdraw')
|
|
515
|
+
.description(
|
|
516
|
+
'Forces the vault to send out a withdraw after the redeem period has passed'
|
|
517
|
+
)
|
|
518
|
+
.addOption(
|
|
519
|
+
new Option(
|
|
520
|
+
'--vault-depositor-address <vaultDepositorAddress>',
|
|
521
|
+
'VaultDepositor address'
|
|
522
|
+
).makeOptionMandatory(false)
|
|
523
|
+
)
|
|
524
|
+
.addOption(
|
|
525
|
+
new Option(
|
|
526
|
+
'--vault-depositor-authority <vaultDepositorAuthority>',
|
|
527
|
+
'Authority address of VaultDepositor, must also provide --vault-address'
|
|
528
|
+
).makeOptionMandatory(false)
|
|
529
|
+
)
|
|
530
|
+
.addOption(
|
|
531
|
+
new Option(
|
|
532
|
+
'--vault-address <vaultAddress>',
|
|
533
|
+
'Address of vault, must required if only --vault-deposit-authority is provided'
|
|
534
|
+
).makeOptionMandatory(false)
|
|
535
|
+
)
|
|
536
|
+
.action((opts) => forceWithdraw(program, opts));
|
|
537
|
+
program
|
|
538
|
+
.command('force-withdraw-all')
|
|
539
|
+
.description(
|
|
540
|
+
'Processes all pending withdrawals that are ready to be redeemed'
|
|
541
|
+
)
|
|
542
|
+
.addOption(
|
|
543
|
+
new Option(
|
|
544
|
+
'--vault-address <vaultAddress>',
|
|
545
|
+
'Address of vault, must required if only --vault-deposit-authority is provided'
|
|
546
|
+
).makeOptionMandatory(true)
|
|
547
|
+
)
|
|
548
|
+
.action((opts) => forceWithdrawAll(program, opts));
|
|
549
|
+
program
|
|
550
|
+
.command('decode-logs')
|
|
551
|
+
.description('Decode program logs from a txid')
|
|
552
|
+
.addOption(
|
|
553
|
+
new Option('--tx <tx>', 'Transaction hash').makeOptionMandatory(true)
|
|
554
|
+
)
|
|
555
|
+
.action((opts) => decodeLogs(program, opts));
|
|
556
|
+
program
|
|
557
|
+
.command('check-invariants')
|
|
558
|
+
.description('Perform sanity checks on vault/depositor invariants')
|
|
559
|
+
.addOption(
|
|
560
|
+
new Option(
|
|
561
|
+
'--vault-address <address>',
|
|
562
|
+
'Vault address'
|
|
563
|
+
).makeOptionMandatory(true)
|
|
564
|
+
)
|
|
565
|
+
.addOption(new Option('--csv', 'Output to csv'))
|
|
566
|
+
|
|
567
|
+
.action((opts) => vaultInvariantChecks(program, opts));
|
|
568
|
+
|
|
569
|
+
program
|
|
570
|
+
.command('manager-update-fees')
|
|
571
|
+
.description('Update vault fees for a manager')
|
|
572
|
+
.addOption(
|
|
573
|
+
new Option(
|
|
574
|
+
'--vault-address <address>',
|
|
575
|
+
'Address of the vault to update'
|
|
576
|
+
).makeOptionMandatory(true)
|
|
577
|
+
)
|
|
578
|
+
.option(
|
|
579
|
+
'-t, --timelock-duration <number>',
|
|
580
|
+
'The timelock before the new fees take effect, in seconds, minimum is max(7 days, 2x redeem period) (default: minimum duration)'
|
|
581
|
+
)
|
|
582
|
+
.option('-m, --management-fee <percent>', 'The new management fee percentage')
|
|
583
|
+
.option('-s, --profit-share <percent>', 'The new profit share percentage')
|
|
584
|
+
.option('-h, --hurdle-rate <percent>', 'The new hurdle rate percentage')
|
|
585
|
+
.addOption(
|
|
586
|
+
new Option(
|
|
587
|
+
'--dump-transaction-message',
|
|
588
|
+
'Dump the transaction message to the console'
|
|
589
|
+
).makeOptionMandatory(false)
|
|
590
|
+
)
|
|
591
|
+
.action((opts) => managerUpdateFees(program, opts));
|
|
592
|
+
|
|
593
|
+
program
|
|
594
|
+
.command('admin-init-fee-update')
|
|
595
|
+
.description('Admin initialize a fee update for a vault')
|
|
596
|
+
.addOption(
|
|
597
|
+
new Option(
|
|
598
|
+
'--vault-address <address>',
|
|
599
|
+
'Address of the vault to initialize fee update for'
|
|
600
|
+
).makeOptionMandatory(true)
|
|
601
|
+
)
|
|
602
|
+
.addOption(
|
|
603
|
+
new Option(
|
|
604
|
+
'--dump-transaction-message',
|
|
605
|
+
'Dump the transaction message to the console'
|
|
606
|
+
).makeOptionMandatory(false)
|
|
607
|
+
)
|
|
608
|
+
.action((opts) => adminInitFeeUpdate(program, opts));
|
|
609
|
+
|
|
610
|
+
program
|
|
611
|
+
.command('admin-delete-fee-update')
|
|
612
|
+
.description('Admin delete a fee update for a vault')
|
|
613
|
+
.addOption(
|
|
614
|
+
new Option(
|
|
615
|
+
'--vault-address <address>',
|
|
616
|
+
'Address of the vault to delete fee update for'
|
|
617
|
+
).makeOptionMandatory(true)
|
|
618
|
+
)
|
|
619
|
+
.addOption(
|
|
620
|
+
new Option(
|
|
621
|
+
'--dump-transaction-message',
|
|
622
|
+
'Dump the transaction message to the console'
|
|
623
|
+
).makeOptionMandatory(false)
|
|
624
|
+
)
|
|
625
|
+
.action((opts) => adminDeleteFeeUpdate(program, opts));
|
|
626
|
+
|
|
627
|
+
program
|
|
628
|
+
.command('manager-borrow')
|
|
629
|
+
.description('Manager borrow from a spot market')
|
|
630
|
+
.addOption(
|
|
631
|
+
new Option(
|
|
632
|
+
'--vault-address <address>',
|
|
633
|
+
'Address of the vault'
|
|
634
|
+
).makeOptionMandatory(true)
|
|
635
|
+
)
|
|
636
|
+
.addOption(
|
|
637
|
+
new Option(
|
|
638
|
+
'--borrow-spot-market-index <index>',
|
|
639
|
+
'Spot market index to borrow from'
|
|
640
|
+
).makeOptionMandatory(true)
|
|
641
|
+
)
|
|
642
|
+
.addOption(
|
|
643
|
+
new Option(
|
|
644
|
+
'--borrow-amount <amount>',
|
|
645
|
+
'Amount to borrow (in borrow precision, 5 for 5 USDC)'
|
|
646
|
+
).makeOptionMandatory(true)
|
|
647
|
+
)
|
|
648
|
+
.addOption(
|
|
649
|
+
new Option(
|
|
650
|
+
'--manager-token-account <address>',
|
|
651
|
+
'Manager token account address (optional, ATA will be used if not provided)'
|
|
652
|
+
).makeOptionMandatory(false)
|
|
653
|
+
)
|
|
654
|
+
.addOption(
|
|
655
|
+
new Option(
|
|
656
|
+
'--dump-transaction-message',
|
|
657
|
+
'Dump the transaction message to the console'
|
|
658
|
+
).makeOptionMandatory(false)
|
|
659
|
+
)
|
|
660
|
+
.action((opts) => managerBorrow(program, opts));
|
|
661
|
+
|
|
662
|
+
program
|
|
663
|
+
.command('manager-repay')
|
|
664
|
+
.description('Manager repay to a spot market')
|
|
665
|
+
.addOption(
|
|
666
|
+
new Option(
|
|
667
|
+
'--vault-address <address>',
|
|
668
|
+
'Address of the vault'
|
|
669
|
+
).makeOptionMandatory(true)
|
|
670
|
+
)
|
|
671
|
+
.addOption(
|
|
672
|
+
new Option(
|
|
673
|
+
'--repay-spot-market-index <index>',
|
|
674
|
+
'Spot market index to repay to'
|
|
675
|
+
).makeOptionMandatory(true)
|
|
676
|
+
)
|
|
677
|
+
.addOption(
|
|
678
|
+
new Option(
|
|
679
|
+
'--repay-amount <amount>',
|
|
680
|
+
'Amount to repay (in repay market precision, 5 for 5 USDC)'
|
|
681
|
+
).makeOptionMandatory(true)
|
|
682
|
+
)
|
|
683
|
+
.addOption(
|
|
684
|
+
new Option(
|
|
685
|
+
'--repay-value <value>',
|
|
686
|
+
'Value (in deposit precision, 5 for 5 USDC) of the repay (optional, if not provided will assume repaying the full outstanding amount)'
|
|
687
|
+
).makeOptionMandatory(false)
|
|
688
|
+
)
|
|
689
|
+
.addOption(
|
|
690
|
+
new Option(
|
|
691
|
+
'--manager-token-account <address>',
|
|
692
|
+
'Manager token account address to receive repay tokens from (optional, ATA will be used if not provided)'
|
|
693
|
+
).makeOptionMandatory(false)
|
|
694
|
+
)
|
|
695
|
+
.addOption(
|
|
696
|
+
new Option(
|
|
697
|
+
'--dump-transaction-message',
|
|
698
|
+
'Dump the transaction message to the console'
|
|
699
|
+
).makeOptionMandatory(false)
|
|
700
|
+
)
|
|
701
|
+
.action((opts) => managerRepay(program, opts));
|
|
702
|
+
|
|
703
|
+
program
|
|
704
|
+
.command('manager-update-borrow')
|
|
705
|
+
.description('Update the manager borrow value for a vault')
|
|
706
|
+
.addOption(
|
|
707
|
+
new Option(
|
|
708
|
+
'--vault-address <address>',
|
|
709
|
+
'Address of the vault'
|
|
710
|
+
).makeOptionMandatory(true)
|
|
711
|
+
)
|
|
712
|
+
.addOption(
|
|
713
|
+
new Option(
|
|
714
|
+
'--new-borrow-value <value>',
|
|
715
|
+
'New borrow value (in deposit precision, 5 for 5 USDC)'
|
|
716
|
+
).makeOptionMandatory(true)
|
|
717
|
+
)
|
|
718
|
+
.addOption(
|
|
719
|
+
new Option(
|
|
720
|
+
'--dump-transaction-message',
|
|
721
|
+
'Dump the transaction message to the console'
|
|
722
|
+
).makeOptionMandatory(false)
|
|
723
|
+
)
|
|
724
|
+
.action((opts) => managerUpdateBorrow(program, opts));
|
|
725
|
+
|
|
726
|
+
program
|
|
727
|
+
.command('admin-update-vault-class')
|
|
728
|
+
.description('Admin update the vault class')
|
|
729
|
+
.addOption(
|
|
730
|
+
new Option(
|
|
731
|
+
'--vault-address <address>',
|
|
732
|
+
'Address of the vault'
|
|
733
|
+
).makeOptionMandatory(true)
|
|
734
|
+
)
|
|
735
|
+
.addOption(
|
|
736
|
+
new Option(
|
|
737
|
+
'--vault-class <class>',
|
|
738
|
+
'New vault class (trusted)'
|
|
739
|
+
).makeOptionMandatory(true)
|
|
740
|
+
)
|
|
741
|
+
.addOption(
|
|
742
|
+
new Option(
|
|
743
|
+
'--dump-transaction-message',
|
|
744
|
+
'Dump the transaction message to the console'
|
|
745
|
+
).makeOptionMandatory(false)
|
|
746
|
+
)
|
|
747
|
+
.action((opts) => adminUpdateVaultClass(program, opts));
|
|
748
|
+
|
|
749
|
+
program.parseAsync().then(() => {
|
|
750
|
+
process.exit(0);
|
|
751
|
+
});
|