Compare commits

..

2 Commits

Author SHA1 Message Date
f3df5c0b14 Add parameter for denominator for uint256 -> TORN 2023-05-27 17:31:54 +03:00
fd57f13e63 Remove nonce log 2023-05-27 17:29:32 +03:00
5 changed files with 26 additions and 18 deletions

@ -9,4 +9,5 @@ contract Parameters {
address constant _tokenAddress = 0x77777FeDdddFfC19Ff86DB637967013e6C6A116C;
uint256 constant _tornMaximumSupply = 10_000_000;
uint256 constant _tornDecimals = 1e18;
}

@ -57,8 +57,6 @@ contract ProposalUtils is Mock, Parameters, Test {
uint256 lockTimestamp = block.timestamp + PROPOSAL_DURATION;
uint256 accountNonce = ERC20Permit(_tokenAddress).nonces(voter);
console2.log("Account nonce: %s", accountNonce);
bytes32 messageHash = keccak256(
abi.encodePacked(
PERMIT_FUNC_SELECTOR,

@ -11,12 +11,12 @@ import { TornadoStakingRewards } from "@root/v4-patch/TornadoStakingRewards.sol"
contract TestContractsState is MockProposal {
function testLockedBalanceSaved() public {
uint256 lockedBalanceBeforeExecution = governance.lockedBalance(TEST_REAL_ADDRESS_WITH_BALANCE);
console2.log("User locked balance before execution: %s TORN", lockedBalanceBeforeExecution / 10 ** 18);
console2.log("User locked balance before execution: %s TORN", lockedBalanceBeforeExecution / _tornDecimals);
createAndExecuteProposal();
uint256 lockedBalanceAfterExecution = governance.lockedBalance(TEST_REAL_ADDRESS_WITH_BALANCE);
console2.log("User locked balance before execution: %s TORN", lockedBalanceAfterExecution / 10 ** 18);
console2.log("User locked balance before execution: %s TORN", lockedBalanceAfterExecution / _tornDecimals);
require(lockedBalanceBeforeExecution == lockedBalanceAfterExecution, "Wrong locked balance after execution");
}
@ -24,7 +24,7 @@ contract TestContractsState is MockProposal {
function testGovernanceStakingStateChanged() public {
TornadoStakingRewards oldStaking = TornadoStakingRewards(getStakingProxyAddress());
uint256 accumulatedRewardsBeforeExecution = oldStaking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
console2.log("User rewards balance (bugged) before execution: %s TORN", accumulatedRewardsBeforeExecution / 10 ** 18);
console2.log("User rewards balance (bugged) before execution: %s TORN", accumulatedRewardsBeforeExecution / _tornDecimals);
console2.log("Bugged value of accumulated rewards per TORN: %s", oldStaking.accumulatedRewardPerTorn());
createAndExecuteProposal();
@ -33,7 +33,7 @@ contract TestContractsState is MockProposal {
uint256 accumulatedRewardsPerTORNAfterExecution = newStaking.accumulatedRewardPerTorn();
uint256 accumulatedRewardsAfterExecution = newStaking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
console2.log("User rewards balance before execution: %s TORN", accumulatedRewardsAfterExecution / 10 ** 18);
console2.log("User rewards balance before execution: %s TORN", accumulatedRewardsAfterExecution / _tornDecimals);
console2.log("Value of accumulated rewards per TORN after contract redeployment: %s", accumulatedRewardsPerTORNAfterExecution);
require(accumulatedRewardsBeforeExecution >= accumulatedRewardsAfterExecution, "Wtf");
@ -48,7 +48,7 @@ contract TestContractsState is MockProposal {
uint256 relayerStakedBalanceBeforeExecution = registry.getRelayerBalance(TEST_RELAYER_ADDRESS);
console2.log(
"Relayer balance in relayer registry contract before proposal execution: %s TORN",
relayerStakedBalanceBeforeExecution / 10 ** 18
relayerStakedBalanceBeforeExecution / _tornDecimals
);
require(isRelayerRegisteredBeforeExecution, "Relayer not registered");
@ -59,7 +59,8 @@ contract TestContractsState is MockProposal {
uint256 relayerStakedBalanceAfterExecution = registry.getRelayerBalance(TEST_RELAYER_ADDRESS);
console2.log(
"Relayer balance in relayer registry contract after proposal execution: %s TORN", relayerStakedBalanceAfterExecution / 10 ** 18
"Relayer balance in relayer registry contract after proposal execution: %s TORN",
relayerStakedBalanceAfterExecution / _tornDecimals
);
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++) {
uint256 currentRelayerBalance = registry.getRelayerBalance(allRelayersAddresses[i]);
relayersBalancesSum += currentRelayerBalance;
console2.log("Relayer %s, relayer balance: %s TORN", allRelayersAddresses[i], currentRelayerBalance / 10e17);
console2.log("Relayer %s, relayer balance: %s TORN", allRelayersAddresses[i], currentRelayerBalance / _tornDecimals);
}
console2.log("\nSum of relayer balances on block %s: %s TORN", block.number, relayersBalancesSum / 10e17);
console2.log("\nSum of relayer balances on block %s: %s TORN", block.number, relayersBalancesSum / _tornDecimals);
require(relayersBalancesSum > 0);
}

@ -22,13 +22,17 @@ contract TestGovernanceStakingRewards is MockProposal {
uint256 accumulatedRewardPerTornBeforeBurning = staking.accumulatedRewardPerTorn() / _tornMaximumSupply;
console2.log("Accumulated reward per TORN right after proposal execution: %s TORN", accumulatedRewardPerTornBeforeBurning / 10e17);
console2.log(
"Accumulated reward per TORN right after proposal execution: %s TORN", accumulatedRewardPerTornBeforeBurning / _tornDecimals
);
burnTokens(_governanceAddress, 10_000_000 ether, staking);
uint256 accumulatedRewardPerTornAfterBurning = staking.accumulatedRewardPerTorn() / _tornMaximumSupply;
console2.log("Accumulated reward per TORN after burning 10 000 000 TORN: ~ %s TORN", accumulatedRewardPerTornAfterBurning / 10e17);
console2.log(
"Accumulated reward per TORN after burning 10 000 000 TORN: ~ %s TORN", accumulatedRewardPerTornAfterBurning / _tornDecimals
);
require(accumulatedRewardPerTornAfterBurning > accumulatedRewardPerTornBeforeBurning, "Staking rewards isn't updated");
}
@ -44,12 +48,12 @@ contract TestGovernanceStakingRewards is MockProposal {
require(stakerLockedBalance == 25_000 ether, "Invalid test staker locked balance");
uint256 stakerRewardsBeforeBurning = staking.checkReward(TEST_ADDRESS_ONE);
console2.log("Staking rewards before burning: %s TORN", stakerRewardsBeforeBurning / 10e17);
console2.log("Staking rewards before burning: %s TORN", stakerRewardsBeforeBurning / _tornDecimals);
burnTokens(_governanceAddress, toBurn, staking);
uint256 stakerRewardsAfterBurning = staking.checkReward(TEST_ADDRESS_ONE);
console2.log("Staking rewards after burning 10 000 TORN: %s TORN\n", stakerRewardsAfterBurning / 10e17);
console2.log("Staking rewards after burning 10 000 TORN: %s TORN\n", stakerRewardsAfterBurning / _tornDecimals);
require(stakerRewardsAfterBurning > stakerRewardsBeforeBurning, "Rewards isn't changed after burning");
// All TORN, locked by users in Governance, is on the userVault contract balance
@ -57,20 +61,24 @@ contract TestGovernanceStakingRewards is MockProposal {
uint256 receivedReward = stakerRewardsAfterBurning - stakerRewardsBeforeBurning;
uint256 expectedRewards = stakerLockedBalance * toBurn / governanceLockedAmount;
console2.log("Expected staking rewards: %s TORN", expectedRewards / 10e17);
console2.log("Staker received rewards: %s TORN\n", receivedReward / 10e17);
console2.log("Expected staking rewards: %s TORN", expectedRewards / _tornDecimals);
console2.log("Staker received rewards: %s TORN\n", receivedReward / _tornDecimals);
require(receivedReward == expectedRewards, "Expected and received rewards don't match");
uint256 stakerTORNbalanceBeforeGettingRewards = TORN.balanceOf(TEST_ADDRESS_ONE);
console2.log("Staker balance before getting (withdrawal) collected rewards: %s TORN", stakerTORNbalanceBeforeGettingRewards / 10e17);
console2.log(
"Staker balance before getting (withdrawal) collected rewards: %s TORN", stakerTORNbalanceBeforeGettingRewards / _tornDecimals
);
vm.startPrank(TEST_ADDRESS_ONE);
staking.getReward();
vm.stopPrank();
uint256 stakerTORNbalanceAfterGettingRewards = TORN.balanceOf(TEST_ADDRESS_ONE);
console2.log("Staker balance after getting (withdrawal) collected rewards: %s TORN", stakerTORNbalanceAfterGettingRewards / 10e17);
console2.log(
"Staker balance after getting (withdrawal) collected rewards: %s TORN", stakerTORNbalanceAfterGettingRewards / _tornDecimals
);
require(stakerTORNbalanceAfterGettingRewards > stakerTORNbalanceBeforeGettingRewards, "Rewards isn't withdrawed");
require(