Skip to content

Add some additional tests and utility functions pre production deploy#6

Closed
jkilpatr wants to merge 1 commit intomainfrom
jkilpatr/polish-up-incentives
Closed

Add some additional tests and utility functions pre production deploy#6
jkilpatr wants to merge 1 commit intomainfrom
jkilpatr/polish-up-incentives

Conversation

@jkilpatr
Copy link
Copy Markdown
Collaborator

@jkilpatr jkilpatr commented Oct 29, 2025

This patch adds a significant amount of new test scope and some new utility functions

  • token withdraw from the incentives program, provides an upgrade flow if needed where tokens can be sent to a new version of the contract, which would be deployed initialized with rewards counters
  • fixes for some missing events, either that where not emitted or didn't exist in some scenarios
  • additional validation for inputs and other parameters
  • paginates total owed, so that it can be called with a large number of users
  • prevents the user from re-registering for rewards without claiming and losing rewards they have otherwise earned (it's still possible to modify their liquidity position and lose rewards, but at least we can avoid this footgun)
  • Added a test that validates under even a worst case scenario overflow will not prevent a user from claiming earned rewards.

@jkilpatr jkilpatr force-pushed the jkilpatr/polish-up-incentives branch from 3ff6a2c to 9c88716 Compare October 29, 2025 19:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reorganizes and expands test coverage for the AltheaDex incentives system while adding several critical improvements to the main contract:

  • Reorganizes tests from flat files into a structured test/incentives/ directory
  • Adds comprehensive validation tests, overflow tests, and edge case coverage
  • Implements emergency withdrawal functionality and validation checks in the contract
  • Adds pagination to the totalOwed function to prevent gas issues with large user sets

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 40 comments.

Show a summary per file
File Description
test/incentives/Validation.ts New comprehensive validation and edge case tests including emergency withdrawal, overflow handling, concurrency, and deactivation scenarios
test/incentives/TestRewardCalculations.ts New overflow/underflow tests verifying reward calculations with realistic DEX liquidity values
test/incentives/ConcentratedIncentives.ts Reorganized concentrated rewards tests with proper BigNumber usage and pagination tests
test/incentives/ClaimAndWithdraw.ts New tests for claim/withdraw variants, event emission, and liquidity tracking
test/incentives/AmbientIncentives.ts Reorganized ambient rewards tests with proper BigNumber usage and pagination tests
test/incentives/AccessControl.ts New comprehensive access control, deactivation, and constructor tests
test/TestConcentratedIncentives.ts Deleted old flat test file (code moved to organized structure)
test/TestAmbientIncentives.ts Deleted old flat test file (code moved to organized structure)
contracts/AltheaDexIncentivesContinuousMulti.sol Added validation checks, emergency withdrawal, pagination for totalOwed, unclaimed rewards check on registration, and new events
Comments suppressed due to low confidence (1)

contracts/AltheaDexIncentivesContinuousMulti.sol:206

  • The require check at lines 206 and 216 is now redundant since the same validation is performed earlier in the public functions at lines 164 and 187. Consider removing these duplicate checks from the internal helper functions.
        require(program.p.rewardRateDenominator != 0, "Zero denominator");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread contracts/AltheaDexIncentivesContinuousMulti.sol Outdated
Comment thread test/incentives/AccessControl.ts Outdated
Comment thread test/incentives/AccessControl.ts Outdated
Comment thread test/incentives/AccessControl.ts Outdated
Comment thread test/incentives/AccessControl.ts Outdated
Comment thread test/incentives/AmbientIncentives.ts Outdated
Comment thread test/incentives/AmbientIncentives.ts Outdated
Comment thread test/incentives/ConcentratedIncentives.ts Outdated
Comment thread test/incentives/ConcentratedIncentives.ts Outdated
Comment thread test/incentives/ConcentratedIncentives.ts Outdated
@jkilpatr jkilpatr force-pushed the jkilpatr/polish-up-incentives branch from b10a67e to 2a758e2 Compare October 31, 2025 04:40
This modifies the structure of the incentives contract we have been
working with to solve a key problem. Namely the accuracy was either
unacceptable or the management of the contract (funding expectations)
where intractable.

This has now been resolved with a new delegated claiming model that can
be added to the existing althea l1 gassless tx ecosystem. This provides
consistent updates that and allows for efficient operation and
management in one package.
@jkilpatr jkilpatr force-pushed the jkilpatr/polish-up-incentives branch from 2a758e2 to 03bd8e3 Compare November 1, 2025 06:13
@jkilpatr jkilpatr closed this Nov 1, 2025
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.

2 participants