Back
Challenge 4 - Fee Adjusted Swap Input
MediumCPMMFees4 / 20

Challenge 4: Fee Adjusted Swap Input

Real CPMMs usually apply a fee before the input amount touches the swap formula.

Task

Implement fee_adjusted_input(x_in).

Rules

  • Fee = 30 basis points.
  • 10_000 basis points = 100%.
  • Effective input = x_in * 9_970 / 10_000.

Example

x_in = 1000
1000 * 9970 / 10000 = 997

This challenge isolates fee math so you can reuse it in later swap logic.

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 4 - Fee Adjusted Swap Input · CPMM Exercise | learn.sol