Dust/leftover reserves in bins will be forced to stay idle
Bins are removed from the swap tree only when total shares hit zero, but rounding-down on burn can leave non-zero reserves with zero shares, locking dust funds in the curve state.
Description
Bins are removed from the tree (which is essential for swaps) when the total shares left for that bin are zero; however, this condition does not assure the bin's reserve in turn will be empty, as the shares burned from users are rounded down, allowing for possible leftover reserves in such a bin while having zero total shares.
if (new_total_shares == 0) {remove_bin_from_tree(storage_keys, internal_bin_id);}
This will cause some reserves to remain unused when swapping, leading to idle funds left in the curve state.
Impact
Dust amounts of token reserves can be locked in bins that have been removed from the swap tree. The amounts are small per bin but accumulate over time and remain inaccessible to swaps or LP withdrawals.
Recommendation
Ensure the shares burned align with the actual reserve returned to the user, or turn the leftover reserves into protocol fees.
Resolution
Fixed in commit 96aa6677a491063d37c81e5fbce252aa97f16873.

