Trusted Vault Class - drift-labs/drift-vaults GitHub Wiki

This page explains how to initialize and operate a Trusted Vault.

⚠️ Vault depositors in Trusted Vaults place a lot of trust in the vault manager due to the additional capabilities granted to them as outlined in this page.

1) Initialize the Vault

A Trusted Vault is a super class of the original vault. It is initialized the same way as a normal vault, an admin must update the vault class to Trusted after it is initialized.

yarn cli init-vault \
  --name="trusted vault test" \
  --market-index=0 \
  --redeem-period=300 \
  --management-fee=1 \
  --profit-share=10 \
  --min-deposit-amount=100

You will probably also want to enable margin trading for this type of vault:

yarn cli manager-update-margin-trading-enabled --vault-address=<VAULT_ADDRESS> --enabled=true

The devnet vault used for this example: A6VbY18DDpnzm8tCsr8m6mFxaDdDtzHjrVCVSFyyXnGV

1.1) Request for vault class to be updated

After the vault is initialized, ask an admin to update your vault class. One the vault class is updated, the view-vault command will show vaultClass = 1

$ yarn cli view-vault --vault-address=A6VbY18DDpnzm8tCsr8m6mFxaDdDtzHjrVCVSFyyXnGV

isLedgerUrl: false
opts.keypair: ...
driftEnv: devnet
Loaded wallet address: <KEYPAIR>
slot: 386561921
vault: trusted vault test
vaultClass:     1
  managerBorrowedValue: 0 USDC
pubkey:         A6VbY18DDpnzm8tCsr8m6mFxaDdDtzHjrVCVSFyyXnGV
manager:        <MANAGER_ADDRESS>
...

2) Borrowing from the vault

Borrow from the vault (this example borrows USDC from the vault, but it can be any spot market index)

yarn cli manager-borrow \
  --vault-address=A6VbY18DDpnzm8tCsr8m6mFxaDdDtzHjrVCVSFyyXnGV \
  --borrow-spot-market-index=0 \
  --borrow-amount=49999.95

devnet tx

view-vault will show the vault equity as $100k (account value + manager borrow) despite $50k having left the account

$ ts-node cli/cli.ts view-vault --vault-address=A6VbY18DDpnzm8tCsr8m6mFxaDdDtzHjrVCVSFyyXnGV
driftEnv: devnet
Loaded wallet address: mm3MzYmkZbQRuG2B3ed21r2SWewPpcMShkqCaEyqDRY
slot: 386565676
vault: trusted vault test
vaultClass:     1
  managerBorrowedValue: 50000 USDC
pubkey:         A6VbY18DDpnzm8tCsr8m6mFxaDdDtzHjrVCVSFyyXnGV
manager:         mm3MzYmkZbQRuG2B3ed21r2SWewPpcMShkqCaEyqDRY
tokenAccount:    48mGQjwGZgR3ViPjRg5tdA1qKzGcaBcvRDp1ukeqepCi
driftUserStats:  9TwXUW4MHfbZmCRdYGrBUH7edC1mAaR3jpRmxQ89KdQS
driftUser:       BwYL894wxswHHAmLThDnH9YJvKAjzwDRteByo1ipgptC
delegate:        mm3MzYmkZbQRuG2B3ed21r2SWewPpcMShkqCaEyqDRY
liqDelegate:     11111111111111111111111111111111
userShares:      0
totalShares:     100000000000
  [managerShares]: 100000000000 (100.0000%)
totalShares:     100000000000
lastFeeUpdateTs:    1749496314
liquidationStartTs: 0
redeemPeriod:            300
totalWithdrawRequested:  0
maxTokens:               0 USDC (0)
sharesBase:              0
managementFee:           10000
initTs:                  1749495951
netDeposits:             100000 USDC (100000000000)
totalDeposits:           100000 USDC (100000000000)
totalWithdraws:          0 USDC (0)
managerNetDeposits:      100000 USDC (100000000000)
managerTotalDeposits:    100000 USDC (100000000000)
managerTotalWithdraws:   0 USDC (0)
managerTotalFee:         0 USDC (0)
managerTotalProfitShare: 0 USDC (0)
lastManagerWithdrawRequest:
  shares: 0
  values: 0 USDC (0)
  ts:     0
FeeUpdate Account:
  None
minDepositAmount:  100000000
profitShare:       100000
hurdleRate:        0
spotMarketIndex:   0
permissioned:      false
vaultEquity (USDC):   $99999.999999
manager share (USDC): $99999.999999
Spot Position: 0, 49999.999999 USDC
vaultEquity (USDC):   99999.999999
manager share (USDC): 99999.999999
vault PnL     (USDC):   -9.999930625781417e-7
vault PnL (USD) -0.000001
vault PnL (spot) -0.000001

3) Updating the outstanding borrows

There are 2 options (3.1 and 3.2) for the manager to repay borrows or update the the value of any outstanding borrows.

3.1) repay-borrow

This instruction sends repay-spot-market-index tokens back into the vault and reduces manager_borrowed_value by the specified amount (omit to repay the entire amount).

Example sending 0.09 BTC into the vault and reducing the borrow by 10k USDC

yarn cli manager-repay \
  --vault-address=A6VbY18DDpnzm8tCsr8m6mFxaDdDtzHjrVCVSFyyXnGV \
  --repay-spot-market-index=2 \
  --repay-amount=0.09 \
  --repay-value=10000

view vault after repay:

Loaded wallet address: mm3MzYmkZbQRuG2B3ed21r2SWewPpcMShkqCaEyqDRY
slot: 386570066
vault: trusted vault test
vaultClass:     1
  managerBorrowedValue: 40000 USDC
...
vaultEquity (USDC):   99780.062267

devnet tx

Example sending 0.4 BTC into the vault and reducing the outstanding borrows to 0

yarn cli manager-repay \
  --vault-address=A6VbY18DDpnzm8tCsr8m6mFxaDdDtzHjrVCVSFyyXnGV \
  --repay-spot-market-index=2 \
  --repay-amount=0.4

view vault after repay:

Loaded wallet address: mm3MzYmkZbQRuG2B3ed21r2SWewPpcMShkqCaEyqDRY
slot: 386570800
vault: trusted vault test
vaultClass:     1
  managerBorrowedValue: 0 USDC
...
vaultEquity (USDC):   103278.780807

devnet tx

3.2) update-borrow

If funds have left the vault for a prolong period of time and the mark-to-deposit-asset value of those funds have changed significantly, you may want to override managerBorrowedValue to the latest mark-to-deposit-asset value. This can be done by:

yarn cli manager-update-borrow \
  --vault-address=A6VbY18DDpnzm8tCsr8m6mFxaDdDtzHjrVCVSFyyXnGV \
  --new-borrow-value=42000

devnet tx

⚠️ **GitHub.com Fallback** ⚠️