Back
Challenge 14 - Withdraw Amounts From LP Burn
MediumCPMMWithdrawals14 / 20

Challenge 14: Withdraw Amounts From LP Burn

Burning LP shares returns the same fraction of each reserve.

Task

Implement withdraw_amounts.

Formula

Use:

x_out = lp_burn * x_reserve / total_lp_supply
y_out = lp_burn * y_reserve / total_lp_supply

Example

Burning 250 LP out of 1000 total supply means burning 25% of the pool.

So from reserves (1200, 2400) the provider receives:

300 600
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 14 - Withdraw Amounts From LP Burn · CPMM Exercise | learn.sol