Skip to content

Comments

Feature/77 implement add liquidity amm contract#169

Merged
GoSTEAN merged 5 commits intoNetwalls:mainfrom
dreamgene:feature/77-implement-add-liquidity-amm-contract
Feb 21, 2026
Merged

Feature/77 implement add liquidity amm contract#169
GoSTEAN merged 5 commits intoNetwalls:mainfrom
dreamgene:feature/77-implement-add-liquidity-amm-contract

Conversation

@dreamgene
Copy link
Contributor

Closes #77

Summary

Implements the add_liquidity function in the AMM contract, allowing liquidity providers (LPs) to deposit USDC into prediction market pools and receive LP tokens proportional to their pool share.


File Changed

  • contracts/contracts/boxmeout/src/amm.rs

Changes

  • Implemented add_liquidity instruction to accept USDC deposits from LPs
  • LP tokens minted proportionally based on current pool share; first provider receives tokens 1:1
  • Updated usdc_reserve and k constant after each liquidity deposit
  • Emitted LiquidityAdded event with provider, amount, minted tokens, new reserve, and updated k
  • Added unit tests covering first provider, proportional minting, reserve updates, and k constant recalculation

Event Emitted

LiquidityAdded {
    provider: Pubkey,
    usdc_amount: u64,
    lp_tokens_minted: u64,
    new_reserve: u64,
    k: u64,
}

Acceptance Criteria

  • Accept USDC from LP, mint LP tokens proportional to pool share
  • Update reserves and k constant
  • Emit LiquidityAdded event
  • Unit tests

Testing

  • First LP receives tokens 1:1
  • Subsequent LPs receive proportional share
  • Reserves correctly updated after deposit
  • k constant recalculated after liquidity added
cargo test

@GoSTEAN GoSTEAN merged commit da4c9a3 into Netwalls:main Feb 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Contract] Implement add_liquidity in AMM Contract

2 participants