Skip to content

feat(#377-#378-#379-#380): Implement liquidity functions#502

Merged
Olowodarey merged 3 commits intoArena1X:mainfrom
Hexstar-labs:feat/377-378-379-380-liquidity-functions
Mar 30, 2026
Merged

feat(#377-#378-#379-#380): Implement liquidity functions#502
Olowodarey merged 3 commits intoArena1X:mainfrom
Hexstar-labs:feat/377-378-379-380-liquidity-functions

Conversation

@Hexstar-labs
Copy link
Copy Markdown
Contributor

Liquidity Pool & AMM Implementation

Implement core liquidity management and trading functions for InsightArena prediction markets.

Changes

  • add_liquidity: Deposit liquidity to market pools and mint LP tokens
  • remove_liquidity: Withdraw liquidity by burning LP tokens
  • swap_outcome: Trade between outcome positions with constant product formula
  • get_outcome_price: Query current outcome prices
  • get_lp_position: Retrieve LP position details

Implementation Details

  • Proportional LP token minting and burning
  • Fee collection and distribution to LPs
  • Swap history tracking
  • Proper TTL management for persistent storage
  • Comprehensive test coverage

Files Modified

  • contract/src/liquidity.rs - Core implementations
  • contract/tests/liquidity_tests.rs - Test suite
  • contract/src/lib.rs - Function exports and type exports

Closes #377
Closes #378
Closes #379
Closes #380

…idity functions

Implement all liquidity module functions for the InsightArena prediction market:

Arena1X#377 - Implement add_liquidity Function
- Add liquidity to a market pool and mint LP tokens
- Validate market exists and is active
- Calculate LP tokens to mint using calculate_lp_tokens
- Update pool reserves
- Store LP position
- Emit liquidity added event

Arena1X#378 - Implement remove_liquidity Function
- Remove liquidity from a pool by burning LP tokens
- Validate LP position exists
- Calculate withdrawal amount using calculate_liquidity_value
- Burn LP tokens
- Transfer funds back to provider
- Update pool state
- Emit liquidity removed event

Arena1X#379 - Implement swap_outcome Function
- Core trading function to swap between outcome positions
- Validate market and pool exist
- Calculate swap output using calculate_swap_output
- Update pool reserves
- Collect and distribute fees
- Record swap in history
- Emit swap event

Arena1X#380 - Update lib.rs and Expose Functions
- Add liquidity functions to InsightArenaContract impl
- Add proper documentation for each function
- Export storage types from lib.rs
- Verify all functions compile
- Test functions are callable from client

Changes:
- Updated contract/src/liquidity.rs with complete implementations
- Updated contract/tests/liquidity_tests.rs with comprehensive tests
- Updated contract/src/lib.rs to expose all liquidity functions
- Exported LiquidityPool, LPPosition, and SwapRecord types
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview, Comment Mar 30, 2026 9:01am

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 30, 2026

@Hexstar-labs Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Olowodarey Olowodarey merged commit c0790e7 into Arena1X:main Mar 30, 2026
3 checks 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

2 participants