Skip to content

Update withdraw command to use 'shares' parameter#98

Open
johna1203 wants to merge 1 commit intodrift-labs:masterfrom
johna1203:patch-1
Open

Update withdraw command to use 'shares' parameter#98
johna1203 wants to merge 1 commit intodrift-labs:masterfrom
johna1203:patch-1

Conversation

@johna1203
Copy link

I was testing the drift-valts CLI and noticed that the documentation for manager-request-withdraw shows --amount, but shouldn't it be --shares instead?

yarn cli manager-request-withdraw --vault-address=<VAULT_ADDRESS> --amount=<SHARES>

Shouldn't the correct one be:

yarn cli manager-request-withdraw --vault-address=<VAULT_ADDRESS> --shares=<SHARES>

I was testing the drift-valts CLI and noticed that the documentation for manager-request-withdraw shows --amount, but shouldn't it be --shares instead?

```
yarn cli manager-request-withdraw --vault-address=<VAULT_ADDRESS> --amount=<SHARES>
```
Shouldn't the correct one be:
```
yarn cli manager-request-withdraw --vault-address=<VAULT_ADDRESS> --shares=<SHARES>
```
@wphan
Copy link
Member

wphan commented Sep 19, 2025

either works

console.error("One of --shares or --amount must be provided.");

@johna1203
Copy link
Author

When I used --amount, it was throwing an error:

SendTransactionError: Simulation failed.
Message: Transaction simulation failed: Error processing Instruction 2: custom program error: 0x1776.
...
Program log: Error InvalidVaultWithdrawSize thrown at programs/drift_vaults/src/state/vault.rs:641
Program log: Requested n_shares=1000646396753 > manager shares=20160092
...
Error Code: InvalidVaultWithdrawSize. Error Number: 6006. Error Message: InvalidVaultWithdrawSize.

I checked the number of shares I had using the view-vault command and was able to successfully run manager-request-withdraw using the correct --shares value.

I also noticed that the CLI code supports the --amount option:

program
.command("manager-request-withdraw")
.description("Make a withdraw request from your vault")
.addOption(new Option("--vault-address <address>", "Address of the vault to withdraw from").makeOptionMandatory(true))
.addOption(new Option("--shares <shares>", "Amount of shares to withdraw (raw precision, as expected by contract)").makeOptionMandatory(false))
.addOption(new Option("--amount <amount>", "Amount of spot asset to withdraw (in deposit precision, 5 for 5 USDC)").makeOptionMandatory(false))
.addOption(new Option("--dump-transaction-message", "Dump the transaction message to the console").makeOptionMandatory(false))
.action((opts) => managerRequestWithdraw(program, opts));

Maybe the documentation could include examples for both --shares and --amount, or clarify the difference between them — since in my case, using --amount was failing.

@wphan
Copy link
Member

wphan commented Sep 19, 2025

Ah good catch, yeah agree it's poorly documented, will improve soon. There's also a third option to use WithdrawUnit.SHARES_PERCENT which is another option to withdraw a percentage of your shares (pass in 1_000_000 for 100%).

@johna1203
Copy link
Author

That's useful too — I didn’t know that option existed. With that option, you don’t even need to check how many shares are in the vault to make a withdrawal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants