Back
Challenge 13 - LP Shares Minted On Deposit
MediumCPMMLP Shares13 / 20

Challenge 13: LP Shares Minted On Deposit

If a liquidity provider adds assets in the correct ratio, their LP shares should match the fraction of the pool they added.

Task

Implement lp_shares_to_mint.

Formula

Use:

x_deposit * total_lp_supply / x_reserve

Example

If the pool has:

  • total LP supply = 1000
  • X reserve = 1000

And the depositor adds 250 X proportionally, they should receive:

250 * 1000 / 1000 = 250
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 13 - LP Shares Minted On Deposit · CPMM Exercise | learn.sol