Back
Challenge 7 - Trading Fee Collected
EasyCPMMFees7 / 20

Challenge 7: Trading Fee Collected

Every swap has two related numbers:

  • the user input amount
  • the fee taken from that input

Task

Implement trading_fee(x_in).

Rules

  • Fee rate = 30 basis points.
  • 10_000 basis points = 100%.
  • For x_in = 1000, fee = 1000 * 30 / 10_000 = 3.

Why it matters

A CPMM often needs to track the fee separately from the fee-adjusted input used in the quote formula.

LanguageRust
Loading editor...
Run works without login. Submit requires sign-in so completion can be saved.
Run cases to compare your output against each configured input. Submit saves progress only when every case passes.
    Challenge 7 - Trading Fee Collected · CPMM Exercise | learn.sol