Add bonus rewards polling with fault-tolerant cron scheduling#6294
Add bonus rewards polling with fault-tolerant cron scheduling#6294
Conversation
|
I don't appreciete how this tool: greptile-apps just changes my pr description. @hasanalqassab comments are fine but it should not be able to change (or share space) what I have written |
3cf05b9 to
d46abad
Compare
|
I will probably squash merge this lol |
709e4ff to
9de2730
Compare
Rewards Bonus Math Confirmation (Testnet)User
Personal Emission Rate
How Bonus Is Calculated
With Last 4 Successful Bonus Runs (Exact Check)
Quick Breakdown of Current Daily Personal Rate (by contributing activities)
Total: Conclusion: the bonus payouts for the last 4 successful runs match the rewards-poller math exactly. |
When a user who holds a community token performs any rewarded action, the
poller now also emits a one-time bonus event for that community's activity
on the Rewards contract. This is configurable via the COMMUNITY_BONUSES
env var (JSON array of {tokenAddress, eventName} entries) and scales to
N communities.
Holder sets are bulk-fetched in a single Cirrus query at startup and
refreshed each polling cycle in parallel with event fetching, so the
bonus check is a synchronous set lookup with zero added latency.
Co-authored-by: Cursor <cursoragent@cursor.com>
Undo the prior rewards-poller implementation so this branch can proceed with the Rewards.sol contract-side bonus approach only. Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce a new CommunityBonusConfig struct to manage community token bonuses. Implement the setCommunityBonusMultiplier function to allow the owner to configure bonus multipliers for community tokens. Update the unclaimed rewards calculation to apply these bonuses based on user token holdings. Add corresponding tests to ensure correct application of bonuses for both position and one-time activities, verifying that holders of community tokens receive the expected multipliers. Co-authored-by: Cursor <cursoragent@cursor.com>
…ogic Update the Rewards contract to include a try-catch block for calculating total rewards with bonuses. This change ensures that if an error occurs during the calculation, the function will return the base rewards instead of failing. Additionally, the logic for applying community bonuses has been streamlined for clarity. Enhance the test suite by adding new ClaimActor contracts to simulate user actions and verify the correct settlement of rewards, both with and without bonuses, upon position closure and reward claims. Co-authored-by: Cursor <cursoragent@cursor.com>
…rement and updating related events. - Introduced `minBalance` to `CommunityBonusConfig` struct to set a minimum token balance for bonus eligibility. - Updated `CommunityBonusMultiplierUpdated` event to include old and new minimum balance values. - Modified `setCommunityBonusMultiplier` function to accept and handle the new `minBalance` parameter. - Adjusted reward claiming logic to check for minimum balance before applying community bonuses. - Updated tests to validate new functionality and ensure correct reward distribution based on minimum balance.
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- Bonus credits computed every 6h via cron, with pending retry on next run - Eligible users determined by token holdings with max bonus percentage - Cirrus and balance check calls wrapped with retryWithBackoff - Revert Rewards.sol contract changes (already on separate PR) Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- Add directPayout flag to Activity struct - Add addOneTimeDirectPayoutActivity() function for registering direct payout activities - Direct payout activities credit rewards immediately to unclaimedRewards (no accrual) - Add DirectPayoutApplied event for tracking - Add validation: directPayout only allowed for OneTime activities with zero emission rate
- Updated bonus token configuration to use `bonusBps` instead of `bonusPercentage` for clarity and consistency. - Introduced `parseBonusTokenConfigs` function to validate and parse bonus token configurations from JSON. - Enhanced bonus credit processing to include validation for bonus credits, ensuring all required fields are present before applying bonuses. - Refactored `batchAddBonus` method to handle additional parameters for source contracts and event names. This change improves the robustness of the bonus system and ensures that bonus configurations are correctly validated before use.
Co-authored-by: Cursor <cursoragent@cursor.com>
- Added `PRICE_ORACLE_ADDRESS` to the environment configuration. - Adjusted `POLLING_INTERVAL` to 600000 milliseconds and `MAX_BATCH_SIZE` to 50. - Introduced `BONUS_CRON_SCHEDULE` for scheduled bonus processing. - Updated `WARNING_TRANSACTIONS_THRESHOLD` to 100 in the configuration. - Refactored imports in `index.ts` to align with new directory structure. - Removed unused `bonusTokenConfig.json` and related configuration logic. - Added new features for bonus credit calculation and processing, including validation and emission rate handling. These changes enhance the configuration clarity and improve the bonus processing logic, ensuring better maintainability and functionality.
- Add directPayout flag to Activity struct - Add addOneTimeDirectPayoutActivity() function for registering direct payout activities - Direct payout activities credit rewards immediately to unclaimedRewards (no accrual) - Add DirectPayoutApplied event for tracking - Add validation: directPayout only allowed for OneTime activities with zero emission rate
e4acf27 to
2607d94
Compare
Admin parametersAdmins control:
Example target:
Ethereum holder context:
FormulaExample outputsAssuming
For a
Anti-gaming exampleIf someone had For the same
|
…into feature/rewards-multiplier-6228
- Query DirectPayoutApplied events from Cirrus to get per-user bonus totals - Break down bonus by source activity (e.g. BOOE) via activityId mapping - Show Community Bonus card on My Rewards tab with token source badges - Card only renders when user has bonus rewards > 0 Made-with: Cursor
…am line) Made-with: Cursor

Summary
maxBonusBpsandbalanceForMaxBoostlastBonusRun.jsonRelated issue