This repo has a simple CLI for interacting with the vault (run from this `package.json`):
npm install @drift-labs/vaults-sdkThis repo has a simple CLI for interacting with the vault (run from this package.json):
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).
Required Environment Variables or Flags:
Environment Variable| command line flag | Description
--------------------|-------------------|------------
RPC_URL | --url | The RPC node to connect to for transactions
KEYPAIR_PATH | --keypair | Path to keypair (file or base58) to sign transactions. This may also be a ledger filepath (e.g. usb://ledger/)
ENV | --env | 'devnet' or 'mainnet' (default: 'mainnet')
View available commands, run with --help in nested commands to get available options for each command
```
yarn cli --help
The following commands are menat to be run by Vault Managers. KEYPAIR_PATH should be the manager's keypair.
Init a new vault. This will initialize a new vault and update you (the manager) as the delegate, unless --delegate is specified.`
$ yarn cli init-vault --help
Usage: cli init-vault [options]
Initialize a new vault
Options:
-n, --name
-i, --market-index
-r, --redeem-period
-x, --max-tokens
-m, --management-fee
-s, --profit-share
-p, --permissioned Provide this flag to make the vault permissioned, vault-depositors will need to be initialized by the manager
(default: false)
-a, --min-deposit-amount
-h, --help display help for command
`
To update params in a vault:
`
$ yarn cli manager-update-vault --help
Usage: cli manager-update-vault [options]
Update vault params for a manager
Options:
--vault-address
$3
If you wish to trade with spot margin on the vault, you must enable margin trading:
`
yarn cli manager-update-margin-trading-enabled --vault-address= --enabled=
`$3
Make a deposit into a vault as the manager (
DEPOSIT_AMOUNT in human precision, e.g. 5 for 5 USDC):
`
yarn cli manager-deposit --vault-address= --amount=
`$3
Make a withdraw request from a vault as the manager (
SHARES in raw precision):
`
yarn cli manager-request-withdraw --vault-address= --amount=
`After the redeem period has passed, the manager can complete the withdraw:
`
yarn cli manager-withdraw --vault-address=
`$3
Manager can trigger a profit share calculation (this looks up all VaultDepositors for a vault eligible for profit share and batch processes them):
`
yarn cli apply-profit-share-all --vault-address=
`Depositor Commands
$3
#### Permissioned Vaults
Permissioned vaults require the __manager__ to initialize the
VaultDepositor account before a depositor can deposit.Initialize a
VaultDepositor account for AUTHORITY_TO_ALLOW_DEPOSIT to deposit:
`
yarn cli init-vault-depositor --vault-address= --deposit-authority=
`
#### Permissioneless Vaults
Permissionless vaults allow anyone to deposit. The
deposit instruction will initialize a VaultDepositor account if one does not exist.
DEPOSIT_AMOUNT in human precision of the deposit token (e.g. 5 for 5 USDC).`
yarn cli deposit --vault-address= --deposit-authority= --amount=
`Alternatively, you can pass in the
VaultDepositor address directly:
`
yarn cli deposit --vault-depositor-address= --amount=
`$3
Request a withdraw from a vault:
`
yarn cli request-withdraw --vault-address= --authority= --amount=
`After the redeem period has passed, the depositor can complete the withdraw:
`
yarn cli withdraw --vault-address= --authority=
`View only commands
To print out the current state of a
Vault:
`
yarn cli view-vault --vault-address=
`To print out the current state of a
VaultDepositor:
`
yarn cli view-vault-depositor --vault-depositor-address=
``