Skip to content

Add is_min_liquidity_configured(asset) distinguishing an explicit zero floor from one never set #108

Description

@Jagadeeshftw

📌 Description

min_liquidity(env, asset) and storage::get_min_liquidity both default to 0 via unwrap_or(0) when no entry exists, so a floor that was explicitly set to 0 (disabling the check on purpose) is indistinguishable from an asset the admin never configured at all. set_min_liquidity even documents 0 as "the default" that "disables the check entirely," which only sharpens the ambiguity for an audit trail.

🧩 Requirements and context

  • Add a has_min_liquidity accessor in src/storage.rs using env.storage().persistent().has(&DataKey::MinLiquidity(asset)).
  • Expose is_min_liquidity_configured(env, asset) -> bool on the contract, delegating to the new storage helper.
  • Add regression tests distinguishing never-configured vs. explicitly-zeroed floors.

🛠️ Suggested execution

  • Add has_min_liquidity next to get_min_liquidity/set_min_liquidity in src/storage.rs.
  • Add the public entrypoint in src/lib.rs.
  • Add tests in src/test.rs covering: never called, called with a nonzero floor, called with an explicit 0.

✅ Acceptance criteria

  • is_min_liquidity_configured is false before any set_min_liquidity call for that asset.
  • It is true after set_min_liquidity(asset, 0) even though min_liquidity(asset) still reads 0.
  • Existing min_liquidity/set_min_liquidity behavior is unchanged.

🔒 Security notes

Distinguishing an intentional zero-floor from a never-configured one gives auditors and off-chain monitoring a way to flag an admin action that silently disabled a fund-safety guard, rather than assuming the guard was simply never used.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuesecuritySecurity hardening / auditsmart-contractSoroban/Rust smart contract work

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions