Skip to content

Add transfer_vault_depositor_shares instruction#105

Open
Jesscha wants to merge 5 commits intomasterfrom
feat/transfer-vault-depositor-shares
Open

Add transfer_vault_depositor_shares instruction#105
Jesscha wants to merge 5 commits intomasterfrom
feat/transfer-vault-depositor-shares

Conversation

@Jesscha
Copy link
Collaborator

@Jesscha Jesscha commented Mar 3, 2026

Summary

  • Adds transfer_vault_depositor_shares instruction to the vault program (BE-185)
  • Allows a vault depositor to transfer shares to another existing VaultDepositor within the same vault
  • Only the sender signs; receiver's VaultDepositor must already exist
  • Leverages existing transfer_shares trait method in traits.rs

Changes

  • Rust instruction handler (transfer_vault_depositor_shares.rs) — accounts validation, equity calculation, share transfer with invariant checks
  • SDK method (vaultClient.ts) — transferVaultDepositorShares + createTransferVaultDepositorSharesIx
  • IDL/types updated via anchor build
  • Tests — 4 bankrun tests: basic transfer, full transfer, unauthorized rejection, over-transfer rejection

Test plan

  • anchor build succeeds
  • New bankrun tests pass (4/4)
  • Existing tests unaffected (same pass/fail as master)

Jesscha added 5 commits March 2, 2026 21:29
Allows a vault depositor to transfer their shares to another existing
VaultDepositor account within the same vault. Only the sender needs to
sign. Leverages the existing transfer_shares trait method in traits.rs.

Includes Rust instruction handler, SDK method, and bankrun tests.
- Add self-transfer guard (from == to depositor)
- Add zero amount guard
- Validate destination depositor has no pending withdraw
- Remove unnecessary mut on drift_user account
- Fix invariant check to propagate safe_add errors
@Jesscha Jesscha self-assigned this Mar 3, 2026
@Jesscha Jesscha requested a review from wphan March 3, 2026 03:39
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.

1 participant