Skip to content

feat(contract): implement reputation tests and LP token calculator#484

Merged
Olowodarey merged 1 commit intoArena1X:mainfrom
JoyLight00:feature/323-370-improvements
Mar 29, 2026
Merged

feat(contract): implement reputation tests and LP token calculator#484
Olowodarey merged 1 commit intoArena1X:mainfrom
JoyLight00:feature/323-370-improvements

Conversation

@JoyLight00
Copy link
Copy Markdown
Contributor

Description

This Pull Request addresses the open source assignments for InsightArena, finalizing both #323 and #370. It cleans up the smart contract test logic and incorporates the crucial core AMM LP math.

Changes Made

1. Reputation Testing Framework (Resolves #323)

  • Refactoring: Extracted the entire #[cfg(test)] inline module from contract/src/reputation.rs.
  • New Test Module: Set up contract/tests/reputation_tests.rs with correct imports pointing to the exposed crate elements (use insightarena_contract::*). This aligns the codebase with idiomatic Rust integration test patterns.
  • New Test logic: Added test_reputation_decay_over_time() to verify bounds and time calculations relative to Env::default().

2. LP Token Calculator (Resolves #370)

  • Method Implementation: Implemented overflow-protected calculate_lp_tokens(deposit, liquidity, supply) internally within contract/src/liquidity.rs.
  • AMM Math Protection: Handles the zero-state genesis initialization case precisely (1:1 mapping on first liquidity deposit) while ensuring strict proportional mapping (via multiplication bounds checking) for subsequent additions.
  • Validation: Added four new mathematical assert queries ensuring perfect proportionality for first_deposit, second_deposit_equal, second_deposit_half, and second_deposit_double.

Verification Steps

  • Formatted via cargo fmt.
  • Validated tests and syntactic analysis (runs successfully).

Closes : #323
Closes : #370

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 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 29, 2026 6:50pm

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 29, 2026

@JoyLight00 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 7db535c into Arena1X:main Mar 29, 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

Development

Successfully merging this pull request may close these issues.

[contract] Implement LP Token Calculation Function [contract] Move Reputation Tests and Add New Test

2 participants