π 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
π 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
π Description
quote_fee(env, asset, amount)insrc/lib.rscomputesamount * effective_fee_bps(asset) / BPS_DENOMINATORwith noanchorparameter, so it always reports a nonzero fee for an asset with a nonzero rate β even for an anchor that currently holds an activeset_fee_waiver, whichopen_settlementcharges0fee via its ownstorage::is_fee_waivedcheck. Any integrator previewing cost for a waived anchor viaquote_feetoday gets an overstated number.π§© Requirements and context
quote_fee_for_anchor(env, anchor, asset, amount) -> Result<i128, Error>that checksstorage::is_fee_waivedfirst, mirroringopen_settlement's fee branch, and falls back to the existingeffective_fee_bpscalculation otherwise.quote_fee's existing (anchor-agnostic) signature and behavior unchanged for backward compatibility.quote_fee_for_anchorreturns0for a waived anchor and matchesquote_feefor a non-waived one.π οΈ Suggested execution
src/lib.rs, sharing logic withquote_feeandopen_settlement's fee computation where practical.src/test.rscoverage for a waived anchor, a non-waived anchor, and an asset with aset_asset_feeoverride combined with a waiver.quote_feeis anchor-agnostic whilequote_fee_for_anchoraccounts for waivers.β Acceptance criteria
quote_fee_for_anchorreturns0whenever the anchor holds an active fee waiver, regardless of the asset's configured rate.quote_fee_for_anchormatchesquote_fee's existing result.open_settlement/execute_settlementmatches 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