Skip to content

Commit

Permalink
getStakeAtEpoch needs no explicit mention for epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
apenzk committed Feb 18, 2025
1 parent c9210be commit 0880086
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ contract MCR is Initializable, BaseSettlement, MCRStorage, IMCR {
}

// gets the stake for a given attester at a given epoch
function getStakeAtEpoch(
function getStake(
uint256 epoch,
address custodian,
address attester
) public view returns (uint256) {
return
stakingContract.getStakeAtEpoch(
stakingContract.getStake(
address(this),
epoch,
custodian,
Expand All @@ -107,7 +107,7 @@ contract MCR is Initializable, BaseSettlement, MCRStorage, IMCR {
uint256 totalStake = 0;
for (uint256 i = 0; i < custodians.length; i++) {
// for now, each custodian has weight of 1
totalStake += getStakeAtEpoch(epoch, custodians[i], attester);
totalStake += getStake(epoch, custodians[i], attester);
}
return totalStake;
}
Expand All @@ -117,7 +117,7 @@ contract MCR is Initializable, BaseSettlement, MCRStorage, IMCR {
address custodian,
address attester
) public view returns (uint256) {
return getStakeAtEpoch(getAcceptingEpoch(), custodian, attester);
return getStake(getAcceptingEpoch(), custodian, attester);
}

function computeAllStakeFromAcceptingEpoch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ contract MovementStaking is
address custodian = custodiansByDomain[domain].at(j);

// get the genesis stake for the attester
uint256 attesterStake = getStakeAtEpoch(
uint256 attesterStake = getStake(
domain,
0,
custodian,
Expand Down Expand Up @@ -173,7 +173,7 @@ contract MovementStaking is
}

// gets the stake for a given attester at a given epoch
function getStakeAtEpoch(
function getStake(
address domain,
uint256 epoch,
address custodian,
Expand All @@ -189,7 +189,7 @@ contract MovementStaking is
address attester
) public view returns (uint256) {
return
getStakeAtEpoch(
getStake(
domain,
getAcceptingEpoch(domain),
custodian,
Expand All @@ -208,7 +208,7 @@ contract MovementStaking is
}

// gets the unstake for a given attester at the current epoch
function getAcceptingEpochUnstake(
function getUnstakeForAcceptingEpoch(
address domain,
address custodian,
address attester
Expand Down Expand Up @@ -318,7 +318,7 @@ contract MovementStaking is
address attester
) internal {
// the amount of stake rolled over is stake[currentAcceptingEpoch] - unstake[nextEpoch]
uint256 stakeAmount = getStakeAtEpoch(
uint256 stakeAmount = getStake(
domain,
epochNumber,
custodian,
Expand Down Expand Up @@ -392,7 +392,7 @@ contract MovementStaking is
) internal {
// stake slash will always target this epoch
uint256 targetEpoch = epoch;
uint256 stakeForEpoch = getStakeAtEpoch(
uint256 stakeForEpoch = getStake(
domain,
targetEpoch,
custodian,
Expand Down Expand Up @@ -427,7 +427,7 @@ contract MovementStaking is
address attester
) internal {
// unstake slash will always target the next epoch
uint256 stakeForEpoch = getStakeAtEpoch(
uint256 stakeForEpoch = getStake(
domain,
epoch,
custodian,
Expand Down Expand Up @@ -465,7 +465,7 @@ contract MovementStaking is
// issue a refund that is the min of the stake balance, the amount to be slashed, and the refund amount
// this is to prevent a Domain from trying to have this contract pay out more than has been staked
uint256 refundAmount = Math.min(
getStakeAtEpoch(
getStake(
msg.sender,
getAcceptingEpoch(attesters[i]),
custodians[i],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface IMovementStaking {
function getAcceptingEpoch(address) external view returns (uint256);
function getNextAcceptingEpoch(address) external view returns (uint256);
function getNextPresentEpochWithException(address) external view returns (uint256);
function getStakeAtEpoch(
function getStake(
address domain,
uint256 epoch,
address custodian,
Expand All @@ -30,7 +30,7 @@ interface IMovementStaking {
address custodian,
address attester
) external view returns (uint256);
function getAcceptingEpochUnstake(
function getUnstakeForAcceptingEpoch(
address domain,
address custodian,
address attester
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ contract MovementStakingTest is Test {
vm.prank(staker);
staking.stake(domain, moveToken, 100);
assertEq(moveToken.balanceOf(staker), 0);
assertEq(staking.getStakeAtEpoch(domain, 0, address(moveToken), staker), 100);
assertEq(staking.getStake(domain, 0, address(moveToken), staker), 100);
}

function testSimpleGenesisCeremony() public {
Expand Down Expand Up @@ -333,8 +333,8 @@ contract MovementStakingTest is Test {
assertEq(moveToken.balanceOf(bob), 0);
assertEq(moveToken.balanceOf(address(staking)), 1100);
assertEq(staking.getCustodianStake(domain, 0, address(moveToken)), 1100);
assertEq(staking.getStakeAtEpoch(domain, 0, address(moveToken), alice), 1000);
assertEq(staking.getStakeAtEpoch(domain, 0, address(moveToken), bob), 100);
assertEq(staking.getStake(domain, 0, address(moveToken), alice), 1000);
assertEq(staking.getStake(domain, 0, address(moveToken), bob), 100);

// Charlie calls reward with himself only to steal tokens
address charlie = vm.addr(4);
Expand Down

0 comments on commit 0880086

Please sign in to comment.