This is an example of a trading strategy that trades the funds in a vault.
Accounts on drift can have a delegate. The vault has a drift account, and is able to assign a delegate to it. The delegate is able to sign transactions on behalf of the vault. This is how the strategy will be trading the vault funds.
Assumptions on the vault setup:
- vault has some redeem period, so depositors will not withdraw funds immediately
- the deposit token is spot marketIndex 0 (USDC)
- only provides liquidity on SOL-PERP
This vault strategy is a simple market making strategy that quotes around the current oracle price with a 10 bps edge. It provides liquidity with 20% of the vault's available balance (less any pending withdraws).
-
install dependencies
git clone git@github.com:drift-labs/drift-vault-example.git cd drift-vault-example bun install
-
set environment variables in a new .env file
cp .env.example .env
-
run the strategy
bun index.ts
Vault Managers are responsible for making sure the vault has sufficient collateral to fulfil depositor withdrawals.
An example script for monitoring a Vault is available in the scripts folder.
To run the script, run the following command:
bun monitor
This project was created using bun init
in bun v1.1.9. Bun is a fast all-in-one JavaScript runtime.