@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/.env.example
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# CLI Usage
|
|
2
|
+
|
|
3
|
+
This repo has a simple CLI for interacting with the vault (run from this `package.json`):
|
|
4
|
+
|
|
5
|
+
This CLI utility requires an RPC node and keypair to sign transactions. You can either provide these as environment variables, in a `.env` file, or use cli flags (like `--keypair` and `--url`).
|
|
6
|
+
|
|
7
|
+
Required Environment Variables or Flags:
|
|
8
|
+
|
|
9
|
+
Environment Variable| command line flag | Description
|
|
10
|
+
--------------------|-------------------|------------
|
|
11
|
+
RPC_URL | --url | The RPC node to connect to for transactions
|
|
12
|
+
KEYPAIR_PATH | --keypair | Path to keypair (file or base58) to sign transactions. This may also be a ledger filepath (e.g. `usb://ledger/<wallet_id>?key=0/0`)
|
|
13
|
+
ENV | --env | 'devnet' or 'mainnet' (default: 'mainnet')
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
View available commands, run with `--help` in nested commands to get available options for each command
|
|
17
|
+
```
|
|
18
|
+
yarn cli --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Manager Commands
|
|
22
|
+
|
|
23
|
+
The following commands are menat to be run by Vault Managers. `KEYPAIR_PATH` should be the manager's keypair.
|
|
24
|
+
|
|
25
|
+
### Initialize a new vault
|
|
26
|
+
|
|
27
|
+
Init a new vault. This will initialize a new vault and update you (the manager) as the delegate, unless `--delegate` is specified.
|
|
28
|
+
```
|
|
29
|
+
$ yarn cli init-vault --help
|
|
30
|
+
Usage: cli init-vault [options]
|
|
31
|
+
|
|
32
|
+
Initialize a new vault
|
|
33
|
+
|
|
34
|
+
Options:
|
|
35
|
+
-n, --name <string> Name of the vault to create
|
|
36
|
+
-i, --market-index <number> Spot market index to accept for deposits (default 0 == USDC) (default: "0")
|
|
37
|
+
-r, --redeem-period <number> The period (in seconds) depositors must wait after requesting a withdraw (default: 7 days) (default: "604800")
|
|
38
|
+
-x, --max-tokens <number> The max number of spot marketIndex tokens the vault can accept (default 0 == unlimited) (default: "0")
|
|
39
|
+
-m, --management-fee <percent> The annualized management fee to charge depositors (default: "0")
|
|
40
|
+
-s, --profit-share <percent> The percentage of profits charged by manager (default: "0")
|
|
41
|
+
-p, --permissioned Provide this flag to make the vault permissioned, vault-depositors will need to be initialized by the manager
|
|
42
|
+
(default: false)
|
|
43
|
+
-a, --min-deposit-amount <number The minimum token amount allowed to deposit (default: "0")
|
|
44
|
+
-d, --delegate <publicKey> The address to make the delegate of the vault
|
|
45
|
+
-h, --help display help for command
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Update Vault Params
|
|
49
|
+
|
|
50
|
+
To update params in a vault:
|
|
51
|
+
```
|
|
52
|
+
$ yarn cli manager-update-vault --help
|
|
53
|
+
Usage: cli manager-update-vault [options]
|
|
54
|
+
|
|
55
|
+
Update vault params for a manager
|
|
56
|
+
|
|
57
|
+
Options:
|
|
58
|
+
--vault-address <address> Address of the vault to update
|
|
59
|
+
-r, --redeem-period <number> The new redeem period (can only be lowered)
|
|
60
|
+
-x, --max-tokens <number> The max tokens the vault can accept
|
|
61
|
+
-a, --min-deposit-amount <number The minimum token amount allowed to deposit
|
|
62
|
+
-m, --management-fee <percent> The new management fee (can only be lowered)
|
|
63
|
+
-s, --profit-share <percent> The new profit share percentage (can only be lowered)
|
|
64
|
+
-p, --permissioned <boolean> Set the vault as permissioned (true) or open (false) (default: false)
|
|
65
|
+
-h, --help display help for command
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Update Margin Trading Enabled
|
|
69
|
+
|
|
70
|
+
If you wish to trade with spot margin on the vault, you must enable margin trading:
|
|
71
|
+
```
|
|
72
|
+
yarn cli manager-update-margin-trading-enabled --vault-address=<VAULT_ADDRESS> --enabled=<true|false>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Manager Deposit
|
|
76
|
+
|
|
77
|
+
Make a deposit into a vault as the manager (`DEPOSIT_AMOUNT` in human precision, e.g. 5 for 5 USDC):
|
|
78
|
+
```
|
|
79
|
+
yarn cli manager-deposit --vault-address=<VAULT_ADDRESS> --amount=<DEPOSIT_AMOUNT>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Manager Withdraw
|
|
83
|
+
|
|
84
|
+
Make a withdraw request from a vault as the manager (`SHARES` in raw precision):
|
|
85
|
+
```
|
|
86
|
+
yarn cli manager-request-withdraw --vault-address=<VAULT_ADDRESS> --amount=<SHARES>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
After the redeem period has passed, the manager can complete the withdraw:
|
|
90
|
+
```
|
|
91
|
+
yarn cli manager-withdraw --vault-address=<VAULT_ADDRESS>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Apply Profit Share
|
|
95
|
+
Manager can trigger a profit share calculation (this looks up all `VaultDepositors` for a vault eligible for profit share and batch processes them):
|
|
96
|
+
```
|
|
97
|
+
yarn cli apply-profit-share-all --vault-address=<VAULT_ADDRESS>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Depositor Commands
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
### Deposit into a vault
|
|
104
|
+
|
|
105
|
+
#### Permissioned Vaults
|
|
106
|
+
|
|
107
|
+
Permissioned vaults require the __manager__ to initialize the `VaultDepositor` account before a depositor can deposit.
|
|
108
|
+
|
|
109
|
+
Initialize a `VaultDepositor` account for `AUTHORITY_TO_ALLOW_DEPOSIT` to deposit:
|
|
110
|
+
```
|
|
111
|
+
yarn cli init-vault-depositor --vault-address=<VAULT_ADDRESS> --deposit-authority=<AUTHORITY_TO_ALLOW_DEPOSIT>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
#### Permissioneless Vaults
|
|
116
|
+
|
|
117
|
+
Permissionless vaults allow anyone to deposit. The `deposit` instruction will initialize a `VaultDepositor` account if one does not exist.
|
|
118
|
+
`DEPOSIT_AMOUNT` in human precision of the deposit token (e.g. 5 for 5 USDC).
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
yarn cli deposit --vault-address=<VAULT_ADDRESS> --deposit-authority=<DEPOSIT_AUTHORITY> --amount=<DEPOSIT_AMOUNT>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Alternatively, you can pass in the `VaultDepositor` address directly:
|
|
125
|
+
```
|
|
126
|
+
yarn cli deposit --vault-depositor-address=<VAULT_DEPOSITOR_ADDRESS> --amount=<DEPOSIT_AMOUNT>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Withdraw from a vault
|
|
130
|
+
|
|
131
|
+
Request a withdraw from a vault:
|
|
132
|
+
```
|
|
133
|
+
yarn cli request-withdraw --vault-address=<VAULT_ADDRESS> --authority=<AUTHORITY> --amount=<WITHDRAW_AMOUNT>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
After the redeem period has passed, the depositor can complete the withdraw:
|
|
137
|
+
```
|
|
138
|
+
yarn cli withdraw --vault-address=<VAULT_ADDRESS> --authority=<AUTHORITY>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## View only commands
|
|
142
|
+
|
|
143
|
+
To print out the current state of a `Vault`:
|
|
144
|
+
```
|
|
145
|
+
yarn cli view-vault --vault-address=<VAULT_ADDRESS>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
To print out the current state of a `VaultDepositor`:
|
|
149
|
+
```
|
|
150
|
+
yarn cli view-vault-depositor --vault-depositor-address=<VAULT_DEPOSITOR_ADDRESS>
|
|
151
|
+
```
|
|
152
|
+
|