Skip to content

Add quote_fee_for_anchor(anchor, asset, amount) so fee-waived anchors get an accurate zero-fee previewΒ #117

Description

@Jagadeeshftw

πŸ“Œ Description

quote_fee(env, asset, amount) in src/lib.rs computes amount * effective_fee_bps(asset) / BPS_DENOMINATOR with no anchor parameter, so it always reports a nonzero fee for an asset with a nonzero rate β€” even for an anchor that currently holds an active set_fee_waiver, which open_settlement charges 0 fee via its own storage::is_fee_waived check. Any integrator previewing cost for a waived anchor via quote_fee today gets an overstated number.

🧩 Requirements and context

  • Add quote_fee_for_anchor(env, anchor, asset, amount) -> Result<i128, Error> that checks storage::is_fee_waived first, mirroring open_settlement's fee branch, and falls back to the existing effective_fee_bps calculation otherwise.
  • Keep quote_fee's existing (anchor-agnostic) signature and behavior unchanged for backward compatibility.
  • Add a regression test asserting quote_fee_for_anchor returns 0 for a waived anchor and matches quote_fee for a non-waived one.

πŸ› οΈ Suggested execution

  • Add the new entrypoint to src/lib.rs, sharing logic with quote_fee and open_settlement's fee computation where practical.
  • Add src/test.rs coverage for a waived anchor, a non-waived anchor, and an asset with a set_asset_fee override combined with a waiver.
  • Document in the README that quote_fee is anchor-agnostic while quote_fee_for_anchor accounts for waivers.

βœ… Acceptance criteria

  • quote_fee_for_anchor returns 0 whenever the anchor holds an active fee waiver, regardless of the asset's configured rate.
  • For a non-waived anchor, quote_fee_for_anchor matches quote_fee's existing result.
  • The fee actually accrued by a subsequent open_settlement/execute_settlement matches the anchor-aware preview.

πŸ”’ Security notes

A quote that overstates cost is a minor trust issue, but a quote that understates cost (the inverse bug) would let an integrator commit to a settlement based on a wrong number; locking in an accurate anchor-aware preview closes that risk in either direction.

πŸ“‹ 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 issuebugSomething isn't workingsmart-contractSoroban/Rust smart contract work

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions