Repository navigation
Fix staking precompile interface. #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mijovic
wants to merge
1
commit into
main
Choose a base branch
from
fix/staking-precompile-interface
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| [submodule "lib/forge-std"] | ||
| path = lib/forge-std | ||
| url = https://github.com/foundry-rs/forge-std | ||
| [submodule "lib/monad-std"] | ||
| path = lib/monad-std | ||
| url = https://github.com/category-labs/monad-std |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,132 +1,100 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.28; | ||
| pragma solidity ^0.8.15; | ||
|
|
||
| /** | ||
| * @title IMonadStaking | ||
| * @notice Interface for the Monad Staking Precompile at address 0x0000000000000000000000000000000000001000 | ||
| * @dev This precompile manages validator registration, delegation, and rewards | ||
| */ | ||
| interface IMonadStaking { | ||
| /** | ||
| * @notice Complete validator information from the precompile | ||
| * @dev Matches Python SDK format: 12 fields returned from getValidator | ||
| * @param authority Address that controls this validator | ||
| * @param flags Validator flags/status | ||
| * @param consensusStake Stake used for consensus | ||
| * @param snapshotStake Snapshot stake value | ||
| * @param stake Total stake delegated to this validator | ||
| * @param accRewardPerToken Accumulator value for reward calculations | ||
| * @param consensusCommission Commission rate for consensus | ||
| * @param snapshotCommission Commission rate snapshot | ||
| * @param commission Current commission rate | ||
| * @param unclaimedRewards Rewards earned but not yet claimed | ||
| * @param secpPubKey SECP256k1 public key for execution layer | ||
| * @param blsPubKey BLS public key for consensus layer | ||
| */ | ||
| struct ValidatorInfo { | ||
| address authority; | ||
| uint256 flags; | ||
| uint256 consensusStake; | ||
| uint256 snapshotStake; | ||
| uint256 stake; | ||
| uint256 accRewardPerToken; | ||
| uint256 consensusCommission; | ||
| uint256 snapshotCommission; | ||
| uint256 commission; | ||
| uint256 unclaimedRewards; | ||
| bytes secpPubKey; | ||
| bytes blsPubKey; | ||
| } | ||
|
|
||
| /** | ||
| * @notice Delegator information for a specific validator | ||
| * @param stake Amount of MON delegated | ||
| * @param accumulator Accumulator value at time of last update | ||
| * @param unclaimedRewards Rewards earned but not yet claimed | ||
| */ | ||
| struct DelegatorInfo { | ||
| uint256 stake; | ||
| uint256 accumulator; | ||
| uint256 unclaimedRewards; | ||
| } | ||
|
|
||
| /** | ||
| * @notice Register a new validator with SECP and BLS public keys | ||
| * @return success Whether the registration was successful | ||
| */ | ||
| function addValidator() external returns (bool success); | ||
|
|
||
| /** | ||
| * @notice Delegate MON tokens to a validator | ||
| * @param validatorId The ID of the validator to delegate to | ||
| * @return success Whether the delegation was successful | ||
| */ | ||
| function addValidator(bytes calldata payload, bytes calldata signedSecpMessage, bytes calldata signedBlsMessage) | ||
| external | ||
| payable | ||
| returns (uint64 validatorId); | ||
|
|
||
| function delegate(uint64 validatorId) external payable returns (bool success); | ||
|
|
||
| /** | ||
| * @notice Initiate undelegation of staked MON | ||
| * @param validatorId The ID of the validator to undelegate from | ||
| * @param amount Amount of MON to undelegate | ||
| * @param withdrawalType Type of withdrawal (0 = standard, 1 = expedited) | ||
| * @return success Whether the undelegation was initiated successfully | ||
| */ | ||
| function undelegate(uint64 validatorId, uint256 amount, uint8 withdrawalType) external returns (bool success); | ||
|
|
||
| /** | ||
| * @notice Complete undelegation after withdrawal delay | ||
| * @param validatorId The ID of the validator | ||
| * @param withdrawalType Type of withdrawal that was initiated | ||
| * @return success Whether the withdrawal was successful | ||
| */ | ||
| function withdraw(uint64 validatorId, uint8 withdrawalType) external returns (bool success); | ||
|
|
||
| /** | ||
| * @notice Convert accumulated rewards into additional stake | ||
| * @param validatorId The ID of the validator | ||
| * @return success Whether compounding was successful | ||
| */ | ||
| function undelegate(uint64 validatorId, uint256 amount, uint8 withdrawId) external returns (bool success); | ||
|
|
||
| function compound(uint64 validatorId) external returns (bool success); | ||
|
|
||
| /** | ||
| * @notice Claim accumulated rewards | ||
| * @param validatorId The ID of the validator | ||
| * @return success Whether the claim was successful | ||
| */ | ||
| function withdraw(uint64 validatorId, uint8 withdrawId) external returns (bool success); | ||
|
|
||
| function claimRewards(uint64 validatorId) external returns (bool success); | ||
|
|
||
| /** | ||
| * @notice Change validator commission rate | ||
| * @param validatorId The ID of the validator | ||
| * @param newCommission New commission rate in basis points | ||
| * @return success Whether the commission change was successful | ||
| */ | ||
| function changeCommission(uint64 validatorId, uint256 newCommission) external returns (bool success); | ||
|
|
||
| /** | ||
| * @notice Distribute external rewards (tips) to delegators | ||
| * @param validatorId The ID of the validator | ||
| * @return success Whether the reward distribution was successful | ||
| */ | ||
| function changeCommission(uint64 validatorId, uint256 commission) external returns (bool success); | ||
|
|
||
| function externalReward(uint64 validatorId) external payable returns (bool success); | ||
|
|
||
| /** | ||
| * @notice Get complete validator information | ||
| * @param validatorId The ID of the validator | ||
| * @return info Complete validator information | ||
| */ | ||
| function getValidator(uint64 validatorId) external returns (ValidatorInfo memory info); | ||
|
|
||
| /** | ||
| * @notice Get delegator information for a specific validator | ||
| * @param validatorId The ID of the validator | ||
| * @param delegator Address of the delegator | ||
| * @return info Delegator stake and rewards information | ||
| */ | ||
| function getDelegator(uint64 validatorId, address delegator) external returns (DelegatorInfo memory info); | ||
|
|
||
| /** | ||
| * @notice Get current epoch information | ||
| * @return epoch Current epoch number | ||
| */ | ||
| function getEpoch() external returns (uint256 epoch); | ||
| function getValidator(uint64 validatorId) | ||
| external | ||
| returns ( | ||
| address authAddress, | ||
| uint64 flags, | ||
| uint256 stake, | ||
| uint256 accRewardPerToken, | ||
| uint256 commission, | ||
| uint256 unclaimedRewards, | ||
| uint256 consensusStake, | ||
| uint256 consensusCommission, | ||
| uint256 snapshotStake, | ||
| uint256 snapshotCommission, | ||
| bytes memory secpPubkey, | ||
| bytes memory blsPubkey | ||
| ); | ||
|
|
||
| function getDelegator(uint64 validatorId, address delegator) | ||
| external | ||
| returns ( | ||
| uint256 stake, | ||
| uint256 accRewardPerToken, | ||
| uint256 unclaimedRewards, | ||
| uint256 deltaStake, | ||
| uint256 nextDeltaStake, | ||
| uint64 deltaEpoch, | ||
| uint64 nextDeltaEpoch | ||
| ); | ||
|
|
||
| function getWithdrawalRequest(uint64 validatorId, address delegator, uint8 withdrawId) | ||
| external | ||
| returns (uint256 withdrawalAmount, uint256 accRewardPerToken, uint64 withdrawEpoch); | ||
|
|
||
| function getConsensusValidatorSet(uint32 startIndex) | ||
| external | ||
| returns (bool isDone, uint32 nextIndex, uint64[] memory valIds); | ||
|
|
||
| function getSnapshotValidatorSet(uint32 startIndex) | ||
| external | ||
| returns (bool isDone, uint32 nextIndex, uint64[] memory valIds); | ||
|
|
||
| function getExecutionValidatorSet(uint32 startIndex) | ||
| external | ||
| returns (bool isDone, uint32 nextIndex, uint64[] memory valIds); | ||
|
|
||
| function getDelegations(address delegator, uint64 startValId) | ||
| external | ||
| returns (bool isDone, uint64 nextValId, uint64[] memory valIds); | ||
|
|
||
| function getDelegators(uint64 validatorId, address startDelegator) | ||
| external | ||
| returns (bool isDone, address nextDelegator, address[] memory delegators); | ||
|
|
||
| function getEpoch() external returns (uint64 epoch, bool inEpochDelayPeriod); | ||
|
|
||
| function getProposerValId() external returns (uint64 val_id); | ||
|
|
||
| function syscallOnEpochChange(uint64 epoch) external; | ||
|
|
||
| function syscallReward(address blockAuthor) external; | ||
|
|
||
| function syscallSnapshot() external; | ||
|
|
||
| event ValidatorRewarded(uint64 indexed validatorId, address indexed from, uint256 amount, uint64 epoch); | ||
| event ValidatorCreated(uint64 indexed validatorId, address indexed authAddress, uint256 commission); | ||
| event ValidatorStatusChanged(uint64 indexed validatorId, uint64 flags); | ||
| event Delegate(uint64 indexed validatorId, address indexed delegator, uint256 amount, uint64 activationEpoch); | ||
| event Undelegate( | ||
| uint64 indexed validatorId, address indexed delegator, uint8 withdrawId, uint256 amount, uint64 activationEpoch | ||
| ); | ||
| event Withdraw( | ||
| uint64 indexed validatorId, address indexed delegator, uint8 withdrawId, uint256 amount, uint64 withdrawEpoch | ||
| ); | ||
| event ClaimRewards(uint64 indexed validatorId, address indexed delegator, uint256 amount, uint64 epoch); | ||
| event CommissionChanged(uint64 indexed validatorId, uint256 oldCommission, uint256 newCommission); | ||
| event EpochChanged(uint64 oldEpoch, uint64 newEpoch); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.