Skip to content

[BUG] closeVault() fails with USDC balance - account merge requires zero non-native balances #12

Description

@thisisouvik

Description

The closeVault() function in backend/src/stellar/vault.ts calls mergeAccount() which merges all XLM back to the user's wallet but does NOT first remove the USDC trustline or transfer any USDC balance. The Stellar protocol requires all non-native asset balances to be zero before an account merge. If a vault holds any USDC, closeVault() will throw op_has_sub_entries and the vault cannot be closed.

Steps to Reproduce

  1. Create a savings vault.
  2. Send USDC to the vault.
  3. Call the vault close endpoint.
  4. Observe Stellar error: op_has_sub_entries.

Expected Behavior

Before merging: (1) Transfer all USDC back to user wallet, (2) Remove USDC trustline with changeTrust limit 0, (3) Then merge the account.

Impact

Medium - Users who receive USDC in vaults cannot close them, permanently locking their XLM reserve.

Activity

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

Metadata

Metadata

Labels

Stellar WaveMarked as Stellar Wavebug: mediumMedium priority bugstellar-networkRelated to Stellar network interactionvaultRelated to vault system

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions