Skip to content

fix: pool deposit allows zero-amount — no distinct ZeroAmount error #384

@sanmipaul

Description

@sanmipaul

Bug

`contracts/pool/src/lib.rs` — `deposit(token, amount)` does not distinguish between a zero-amount and a negative-amount call. Both paths hit the same generic error, wasting gas and polluting event logs with no-op deposits.

Impact

  • Zero-amount deposits succeed silently or emit misleading events
  • Storage entries are created for deposits that transfer no value
  • Event log becomes noisy, making off-chain indexers unreliable

Fix

Add an explicit guard at the top of `deposit()`:

```rust
if amount == 0 {
return Err(PoolError::ZeroAmount);
}
if amount < 0 {
return Err(PoolError::NegativeAmount);
}
```

Add `ZeroAmount` and `NegativeAmount` variants to `PoolError`.

Acceptance Criteria

  • `deposit(token, 0)` returns `PoolError::ZeroAmount`
  • `deposit(token, -1)` returns `PoolError::NegativeAmount`
  • Unit tests cover both zero and negative input cases
  • No storage mutation occurs before the guard

References

  • `contracts/pool/src/lib.rs` — `deposit()` function

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't workingsmart-contractSoroban/Rust contract work

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions