Skip to content

Add has_asset_fee_override(asset) to distinguish an explicit 0 bps override from no override at all #107

Description

@Jagadeeshftw

📌 Description

asset_fee(env, asset) collapses storage::get_asset_fee's Option<u32> into a plain u32 via effective_fee_bps, so a caller cannot tell whether an asset is explicitly overridden to 0 bps via set_asset_fee(asset, 0) or simply has no override and happens to inherit a global fee() of 0. This is the same "collapsed Option" ambiguity that motivated is_anchor_active for anchors, applied to fee overrides.

🧩 Requirements and context

  • Add has_asset_fee_override(env, asset) -> bool returning whether storage::get_asset_fee is Some(_).
  • Do not change asset_fee's existing collapsing behavior — this is an additive, non-breaking view.
  • Cover both the override-present-at-zero and no-override-at-zero-global-fee cases in src/test.rs.

🛠️ Suggested execution

  • Add the new entrypoint to src/lib.rs, delegating to storage::get_asset_fee(&env, &asset).is_some().
  • Add regression tests in src/test.rs for: no override + global fee 0bps, explicit override of 0bps, explicit override of a nonzero rate, and after clear_asset_fee.
  • Document the distinction in the README fee section.

✅ Acceptance criteria

  • has_asset_fee_override returns true only when set_asset_fee has been called and not yet cleared for that asset.
  • clear_asset_fee flips the result back to false.
  • asset_fee's existing return value and callers are unaffected.

🔒 Security notes

Fee-override ambiguity is primarily an off-chain auditing gap rather than a direct fund-safety bug, but clear override visibility helps catch a misconfigured admin action (e.g. an accidental 0 bps override) before it is exploited via high-volume settlements.

📋 Guidelines

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueenhancementNew feature or improvementsmart-contractSoroban/Rust smart contract work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions