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
- Create a savings vault.
- Send USDC to the vault.
- Call the vault close endpoint.
- 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.
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
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.