Compare commits
No commits in common. "f3df5c0b14dd1f89182553363d36df436cae2a06" and "ff9f10c5b319b413574a4bffb00f1811d03dd550" have entirely different histories.
f3df5c0b14
...
ff9f10c5b3
@ -9,5 +9,4 @@ contract Parameters {
|
|||||||
address constant _tokenAddress = 0x77777FeDdddFfC19Ff86DB637967013e6C6A116C;
|
address constant _tokenAddress = 0x77777FeDdddFfC19Ff86DB637967013e6C6A116C;
|
||||||
|
|
||||||
uint256 constant _tornMaximumSupply = 10_000_000;
|
uint256 constant _tornMaximumSupply = 10_000_000;
|
||||||
uint256 constant _tornDecimals = 1e18;
|
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,8 @@ contract ProposalUtils is Mock, Parameters, Test {
|
|||||||
uint256 lockTimestamp = block.timestamp + PROPOSAL_DURATION;
|
uint256 lockTimestamp = block.timestamp + PROPOSAL_DURATION;
|
||||||
uint256 accountNonce = ERC20Permit(_tokenAddress).nonces(voter);
|
uint256 accountNonce = ERC20Permit(_tokenAddress).nonces(voter);
|
||||||
|
|
||||||
|
console2.log("Account nonce: %s", accountNonce);
|
||||||
|
|
||||||
bytes32 messageHash = keccak256(
|
bytes32 messageHash = keccak256(
|
||||||
abi.encodePacked(
|
abi.encodePacked(
|
||||||
PERMIT_FUNC_SELECTOR,
|
PERMIT_FUNC_SELECTOR,
|
||||||
|
@ -11,12 +11,12 @@ import { TornadoStakingRewards } from "@root/v4-patch/TornadoStakingRewards.sol"
|
|||||||
contract TestContractsState is MockProposal {
|
contract TestContractsState is MockProposal {
|
||||||
function testLockedBalanceSaved() public {
|
function testLockedBalanceSaved() public {
|
||||||
uint256 lockedBalanceBeforeExecution = governance.lockedBalance(TEST_REAL_ADDRESS_WITH_BALANCE);
|
uint256 lockedBalanceBeforeExecution = governance.lockedBalance(TEST_REAL_ADDRESS_WITH_BALANCE);
|
||||||
console2.log("User locked balance before execution: %s TORN", lockedBalanceBeforeExecution / _tornDecimals);
|
console2.log("User locked balance before execution: %s TORN", lockedBalanceBeforeExecution / 10 ** 18);
|
||||||
|
|
||||||
createAndExecuteProposal();
|
createAndExecuteProposal();
|
||||||
|
|
||||||
uint256 lockedBalanceAfterExecution = governance.lockedBalance(TEST_REAL_ADDRESS_WITH_BALANCE);
|
uint256 lockedBalanceAfterExecution = governance.lockedBalance(TEST_REAL_ADDRESS_WITH_BALANCE);
|
||||||
console2.log("User locked balance before execution: %s TORN", lockedBalanceAfterExecution / _tornDecimals);
|
console2.log("User locked balance before execution: %s TORN", lockedBalanceAfterExecution / 10 ** 18);
|
||||||
|
|
||||||
require(lockedBalanceBeforeExecution == lockedBalanceAfterExecution, "Wrong locked balance after execution");
|
require(lockedBalanceBeforeExecution == lockedBalanceAfterExecution, "Wrong locked balance after execution");
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ contract TestContractsState is MockProposal {
|
|||||||
function testGovernanceStakingStateChanged() public {
|
function testGovernanceStakingStateChanged() public {
|
||||||
TornadoStakingRewards oldStaking = TornadoStakingRewards(getStakingProxyAddress());
|
TornadoStakingRewards oldStaking = TornadoStakingRewards(getStakingProxyAddress());
|
||||||
uint256 accumulatedRewardsBeforeExecution = oldStaking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
|
uint256 accumulatedRewardsBeforeExecution = oldStaking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
|
||||||
console2.log("User rewards balance (bugged) before execution: %s TORN", accumulatedRewardsBeforeExecution / _tornDecimals);
|
console2.log("User rewards balance (bugged) before execution: %s TORN", accumulatedRewardsBeforeExecution / 10 ** 18);
|
||||||
console2.log("Bugged value of accumulated rewards per TORN: %s", oldStaking.accumulatedRewardPerTorn());
|
console2.log("Bugged value of accumulated rewards per TORN: %s", oldStaking.accumulatedRewardPerTorn());
|
||||||
|
|
||||||
createAndExecuteProposal();
|
createAndExecuteProposal();
|
||||||
@ -33,7 +33,7 @@ contract TestContractsState is MockProposal {
|
|||||||
uint256 accumulatedRewardsPerTORNAfterExecution = newStaking.accumulatedRewardPerTorn();
|
uint256 accumulatedRewardsPerTORNAfterExecution = newStaking.accumulatedRewardPerTorn();
|
||||||
uint256 accumulatedRewardsAfterExecution = newStaking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
|
uint256 accumulatedRewardsAfterExecution = newStaking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
|
||||||
|
|
||||||
console2.log("User rewards balance before execution: %s TORN", accumulatedRewardsAfterExecution / _tornDecimals);
|
console2.log("User rewards balance before execution: %s TORN", accumulatedRewardsAfterExecution / 10 ** 18);
|
||||||
console2.log("Value of accumulated rewards per TORN after contract redeployment: %s", accumulatedRewardsPerTORNAfterExecution);
|
console2.log("Value of accumulated rewards per TORN after contract redeployment: %s", accumulatedRewardsPerTORNAfterExecution);
|
||||||
|
|
||||||
require(accumulatedRewardsBeforeExecution >= accumulatedRewardsAfterExecution, "Wtf");
|
require(accumulatedRewardsBeforeExecution >= accumulatedRewardsAfterExecution, "Wtf");
|
||||||
@ -48,7 +48,7 @@ contract TestContractsState is MockProposal {
|
|||||||
uint256 relayerStakedBalanceBeforeExecution = registry.getRelayerBalance(TEST_RELAYER_ADDRESS);
|
uint256 relayerStakedBalanceBeforeExecution = registry.getRelayerBalance(TEST_RELAYER_ADDRESS);
|
||||||
console2.log(
|
console2.log(
|
||||||
"Relayer balance in relayer registry contract before proposal execution: %s TORN",
|
"Relayer balance in relayer registry contract before proposal execution: %s TORN",
|
||||||
relayerStakedBalanceBeforeExecution / _tornDecimals
|
relayerStakedBalanceBeforeExecution / 10 ** 18
|
||||||
);
|
);
|
||||||
|
|
||||||
require(isRelayerRegisteredBeforeExecution, "Relayer not registered");
|
require(isRelayerRegisteredBeforeExecution, "Relayer not registered");
|
||||||
@ -59,8 +59,7 @@ contract TestContractsState is MockProposal {
|
|||||||
uint256 relayerStakedBalanceAfterExecution = registry.getRelayerBalance(TEST_RELAYER_ADDRESS);
|
uint256 relayerStakedBalanceAfterExecution = registry.getRelayerBalance(TEST_RELAYER_ADDRESS);
|
||||||
|
|
||||||
console2.log(
|
console2.log(
|
||||||
"Relayer balance in relayer registry contract after proposal execution: %s TORN",
|
"Relayer balance in relayer registry contract after proposal execution: %s TORN", relayerStakedBalanceAfterExecution / 10 ** 18
|
||||||
relayerStakedBalanceAfterExecution / _tornDecimals
|
|
||||||
);
|
);
|
||||||
|
|
||||||
require(isRelayerRegisteredAfterExecution, "Relayer isn't registered after proposal execution");
|
require(isRelayerRegisteredAfterExecution, "Relayer isn't registered after proposal execution");
|
||||||
|
@ -113,10 +113,10 @@ contract TestRelayerBalance is MockProposal {
|
|||||||
for (uint256 i = 0; i < allRelayersAddresses.length; i++) {
|
for (uint256 i = 0; i < allRelayersAddresses.length; i++) {
|
||||||
uint256 currentRelayerBalance = registry.getRelayerBalance(allRelayersAddresses[i]);
|
uint256 currentRelayerBalance = registry.getRelayerBalance(allRelayersAddresses[i]);
|
||||||
relayersBalancesSum += currentRelayerBalance;
|
relayersBalancesSum += currentRelayerBalance;
|
||||||
console2.log("Relayer %s, relayer balance: %s TORN", allRelayersAddresses[i], currentRelayerBalance / _tornDecimals);
|
console2.log("Relayer %s, relayer balance: %s TORN", allRelayersAddresses[i], currentRelayerBalance / 10e17);
|
||||||
}
|
}
|
||||||
|
|
||||||
console2.log("\nSum of relayer balances on block %s: %s TORN", block.number, relayersBalancesSum / _tornDecimals);
|
console2.log("\nSum of relayer balances on block %s: %s TORN", block.number, relayersBalancesSum / 10e17);
|
||||||
|
|
||||||
require(relayersBalancesSum > 0);
|
require(relayersBalancesSum > 0);
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,13 @@ contract TestGovernanceStakingRewards is MockProposal {
|
|||||||
|
|
||||||
uint256 accumulatedRewardPerTornBeforeBurning = staking.accumulatedRewardPerTorn() / _tornMaximumSupply;
|
uint256 accumulatedRewardPerTornBeforeBurning = staking.accumulatedRewardPerTorn() / _tornMaximumSupply;
|
||||||
|
|
||||||
console2.log(
|
console2.log("Accumulated reward per TORN right after proposal execution: %s TORN", accumulatedRewardPerTornBeforeBurning / 10e17);
|
||||||
"Accumulated reward per TORN right after proposal execution: %s TORN", accumulatedRewardPerTornBeforeBurning / _tornDecimals
|
|
||||||
);
|
|
||||||
|
|
||||||
burnTokens(_governanceAddress, 10_000_000 ether, staking);
|
burnTokens(_governanceAddress, 10_000_000 ether, staking);
|
||||||
|
|
||||||
uint256 accumulatedRewardPerTornAfterBurning = staking.accumulatedRewardPerTorn() / _tornMaximumSupply;
|
uint256 accumulatedRewardPerTornAfterBurning = staking.accumulatedRewardPerTorn() / _tornMaximumSupply;
|
||||||
|
|
||||||
console2.log(
|
console2.log("Accumulated reward per TORN after burning 10 000 000 TORN: ~ %s TORN", accumulatedRewardPerTornAfterBurning / 10e17);
|
||||||
"Accumulated reward per TORN after burning 10 000 000 TORN: ~ %s TORN", accumulatedRewardPerTornAfterBurning / _tornDecimals
|
|
||||||
);
|
|
||||||
|
|
||||||
require(accumulatedRewardPerTornAfterBurning > accumulatedRewardPerTornBeforeBurning, "Staking rewards isn't updated");
|
require(accumulatedRewardPerTornAfterBurning > accumulatedRewardPerTornBeforeBurning, "Staking rewards isn't updated");
|
||||||
}
|
}
|
||||||
@ -48,12 +44,12 @@ contract TestGovernanceStakingRewards is MockProposal {
|
|||||||
require(stakerLockedBalance == 25_000 ether, "Invalid test staker locked balance");
|
require(stakerLockedBalance == 25_000 ether, "Invalid test staker locked balance");
|
||||||
|
|
||||||
uint256 stakerRewardsBeforeBurning = staking.checkReward(TEST_ADDRESS_ONE);
|
uint256 stakerRewardsBeforeBurning = staking.checkReward(TEST_ADDRESS_ONE);
|
||||||
console2.log("Staking rewards before burning: %s TORN", stakerRewardsBeforeBurning / _tornDecimals);
|
console2.log("Staking rewards before burning: %s TORN", stakerRewardsBeforeBurning / 10e17);
|
||||||
|
|
||||||
burnTokens(_governanceAddress, toBurn, staking);
|
burnTokens(_governanceAddress, toBurn, staking);
|
||||||
|
|
||||||
uint256 stakerRewardsAfterBurning = staking.checkReward(TEST_ADDRESS_ONE);
|
uint256 stakerRewardsAfterBurning = staking.checkReward(TEST_ADDRESS_ONE);
|
||||||
console2.log("Staking rewards after burning 10 000 TORN: %s TORN\n", stakerRewardsAfterBurning / _tornDecimals);
|
console2.log("Staking rewards after burning 10 000 TORN: %s TORN\n", stakerRewardsAfterBurning / 10e17);
|
||||||
require(stakerRewardsAfterBurning > stakerRewardsBeforeBurning, "Rewards isn't changed after burning");
|
require(stakerRewardsAfterBurning > stakerRewardsBeforeBurning, "Rewards isn't changed after burning");
|
||||||
|
|
||||||
// All TORN, locked by users in Governance, is on the userVault contract balance
|
// All TORN, locked by users in Governance, is on the userVault contract balance
|
||||||
@ -61,24 +57,20 @@ contract TestGovernanceStakingRewards is MockProposal {
|
|||||||
uint256 receivedReward = stakerRewardsAfterBurning - stakerRewardsBeforeBurning;
|
uint256 receivedReward = stakerRewardsAfterBurning - stakerRewardsBeforeBurning;
|
||||||
uint256 expectedRewards = stakerLockedBalance * toBurn / governanceLockedAmount;
|
uint256 expectedRewards = stakerLockedBalance * toBurn / governanceLockedAmount;
|
||||||
|
|
||||||
console2.log("Expected staking rewards: %s TORN", expectedRewards / _tornDecimals);
|
console2.log("Expected staking rewards: %s TORN", expectedRewards / 10e17);
|
||||||
console2.log("Staker received rewards: %s TORN\n", receivedReward / _tornDecimals);
|
console2.log("Staker received rewards: %s TORN\n", receivedReward / 10e17);
|
||||||
|
|
||||||
require(receivedReward == expectedRewards, "Expected and received rewards don't match");
|
require(receivedReward == expectedRewards, "Expected and received rewards don't match");
|
||||||
|
|
||||||
uint256 stakerTORNbalanceBeforeGettingRewards = TORN.balanceOf(TEST_ADDRESS_ONE);
|
uint256 stakerTORNbalanceBeforeGettingRewards = TORN.balanceOf(TEST_ADDRESS_ONE);
|
||||||
console2.log(
|
console2.log("Staker balance before getting (withdrawal) collected rewards: %s TORN", stakerTORNbalanceBeforeGettingRewards / 10e17);
|
||||||
"Staker balance before getting (withdrawal) collected rewards: %s TORN", stakerTORNbalanceBeforeGettingRewards / _tornDecimals
|
|
||||||
);
|
|
||||||
|
|
||||||
vm.startPrank(TEST_ADDRESS_ONE);
|
vm.startPrank(TEST_ADDRESS_ONE);
|
||||||
staking.getReward();
|
staking.getReward();
|
||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
|
|
||||||
uint256 stakerTORNbalanceAfterGettingRewards = TORN.balanceOf(TEST_ADDRESS_ONE);
|
uint256 stakerTORNbalanceAfterGettingRewards = TORN.balanceOf(TEST_ADDRESS_ONE);
|
||||||
console2.log(
|
console2.log("Staker balance after getting (withdrawal) collected rewards: %s TORN", stakerTORNbalanceAfterGettingRewards / 10e17);
|
||||||
"Staker balance after getting (withdrawal) collected rewards: %s TORN", stakerTORNbalanceAfterGettingRewards / _tornDecimals
|
|
||||||
);
|
|
||||||
|
|
||||||
require(stakerTORNbalanceAfterGettingRewards > stakerTORNbalanceBeforeGettingRewards, "Rewards isn't withdrawed");
|
require(stakerTORNbalanceAfterGettingRewards > stakerTORNbalanceBeforeGettingRewards, "Rewards isn't withdrawed");
|
||||||
require(
|
require(
|
||||||
|
Loading…
Reference in New Issue
Block a user