Skip to content

Conversation

@edilsonGoncalvesR
Copy link

Summary

Tasks for protocol staking currently convert numeric environment variables with
parseInt(...) and then wrap them in BigInt(...). Since parseInt returns a
JavaScript Number, this may lose precision for large 256-bit values (e.g. token
amounts in 18 decimals).

This PR updates the staking tasks to convert env vars directly to BigInt
using the string returned by getRequiredEnvVar.

Changes

  • protocol-contracts/staking/tasks/setRewardRate.ts:

    • Use BigInt(getRequiredEnvVar(...)) for PROTOCOL_STAKING_COPRO_REWARD_RATE
      and PROTOCOL_STAKING_KMS_REWARD_RATE.
  • protocol-contracts/staking/tasks/deposit.ts:

    • Use BigInt(getRequiredEnvVar(...)) for
      OPERATOR_STAKING_COPRO_INITIAL_DEPOSIT_ASSETS_* and
      OPERATOR_STAKING_KMS_INITIAL_DEPOSIT_ASSETS_*.
  • protocol-contracts/staking/tasks/setOwnerFee.ts:

    • Use BigInt(getRequiredEnvVar(...)) for
      OPERATOR_REWARDER_COPRO_OWNER_FEE_* and
      OPERATOR_REWARDER_KMS_OWNER_FEE_*.

Rationale

  • getRequiredEnvVar already returns a string, which is a valid input to BigInt.
  • Avoids going through Number and the associated precision limits.
  • Safer for large values expressed in smallest token units (18 decimals).

Testing

  • Type-checks and builds the staking tasks with:
    • cd protocol-contracts/staking
    • npm test / pnpm test (as used in the repo)
  • Manually verified example Hardhat commands with small values still work as expected.

@edilsonGoncalvesR edilsonGoncalvesR requested a review from a team as a code owner December 10, 2025 12:55
@cla-bot
Copy link

cla-bot bot commented Dec 10, 2025

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @edilsonGoncalvesR on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

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