Skip to content

Add reward notifier script - #44

Merged
rsolari merged 20 commits into
mainfrom
add-reward-notifier-script
Dec 28, 2025
Merged

Add reward notifier script#44
rsolari merged 20 commits into
mainfrom
add-reward-notifier-script

Conversation

@rsolari

@rsolari rsolari commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

Note

Introduces a complete reward minting workflow with delay support and recovery tooling.

  • Adds RequestMint.ts to compute target APR and submit delayed mint requests to ZkMinterDelayV1 for ZkStaker
  • Adds ExecuteMints.ts to scan DelayMod for ready requests, execute executeMint, and call staker.notifyRewardAmount, with dry-run mode
  • Adds NotifyReward.ts disaster-recovery script to manually call notifyRewardAmount if notify fails post-mint
  • Includes script/rewards/README.md (usage, cron patterns, recovery steps) and .env.template for RPC/contract/Turnkey config
  • Uses Turnkey signer integration for transaction execution

Written by Cursor Bugbot for commit bc1f215. This will update automatically on new commits. Configure here.

@cursor

cursor Bot commented Oct 29, 2025

Copy link
Copy Markdown

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on November 1.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@rsolari
rsolari marked this pull request as draft November 4, 2025 02:04

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

const mintRequestId = BigInt(nextId.toString()) - 1n;
console.log(` Mint Request ID: ${mintRequestId}`);

const executeAfter = new Date((Number(mintRequestReceipt.blockTimestamp) + mintDelaySeconds) * 1000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Invalid date from missing blockTimestamp in receipts

The script attempts to read blockTimestamp directly from the transaction receipt. Ethers.js v5 transaction receipts do not include this property, only blockNumber. This causes the executeAfter date calculation to use an undefined value, resulting in an invalid date.

Additional Locations (1)

Fix in Cursor Fix in Web

rsolari and others added 11 commits November 3, 2025 21:27
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Resolved conflicts in imports by keeping new imports from main
and applying scopelint formatting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When the current reward rate is above the desired rate, instead of
exiting early, the script now calls notifyRewardAmount(0) directly
to spread existing rewards over a new REWARD_DURATION period,
effectively lowering the APR toward the target.

Changes:
- Add notifyRewardAmount to STAKER_ABI
- Add RATE_TOLERANCE (0.01%) for rate comparison
- Add logic to detect when rate is too high
- Calculate and display projected new rate
- Call notifyRewardAmount(0) directly (bypassing DelayMod)
- Show before/after rates on success

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rsolari
rsolari marked this pull request as ready for review December 27, 2025 16:52

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Comment thread script/rewards/NotifyReward.ts
console.log("scaledRewardRate", scaledRewardRate);
console.log("annualRewards", annualRewards);
const ratePercentage = (Number(annualRewards) / Number(totalEarningPower)) * 100;
console.log("ratePercentage", ratePercentage);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Debug logging statements left in production code

The calculateCurrentRatePercentage function contains debug-style console.log statements that output raw variable names and values (e.g., console.log("scaledRewardRate", scaledRewardRate)). These don't follow the formatting conventions used elsewhere in the file, which use emojis and formatted template strings. Since this function is called multiple times during script execution, these debug statements will clutter the output in production use.

Fix in Cursor Fix in Web

rsolari and others added 4 commits December 27, 2025 12:07
Clarify that NotifyReward.ts is specifically for recovering from failed
notify calls when ExecuteMints.ts successfully mints but fails to notify
the staker contract.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove unused DEPLOYER_PRIVATE_KEY and ZK_TOKEN_ADDRESS. Keep only
variables actually used: ZKSYNC_RPC_URL, ZKSTAKER_ADDRESS,
DELAY_MOD_ADDRESS, and Turnkey configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The older v2.x SDK used deprecated activity types that are no longer
supported by Turnkey's API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Coverage after merging add-reward-notifier-script into main will be

73.33%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   ZkStaker.sol68.42%100%50%73.33%79, 85, 90, 95

@rsolari
rsolari merged commit 024461e into main Dec 28, 2025
5 checks passed
@rsolari
rsolari deleted the add-reward-notifier-script branch December 29, 2025 16:00
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.

1 participant