Back
Challenge 8 - Effective Execution Price
MediumCPMMPricing8 / 20

Challenge 8: Effective Execution Price

Spot price is not the same as execution price.

Task

Implement execution_price_bps(x_in, y_out).

Formula

If a trader spends x_in units of X and receives y_out units of Y, then the average price in Y-per-X is:

y_out / x_in

Scale by 10_000 so the result stays in integer math:

y_out * 10_000 / x_in

Example

For x_in = 100 and y_out = 181:

181 * 10_000 / 100 = 18_100
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 8 - Effective Execution Price · CPMM Exercise | learn.sol