Skip to content

Commit

Permalink
Merge pull request #29 from euler-xyz/cantina-and-yAudit-code-competi…
Browse files Browse the repository at this point in the history
…tion

Cantina code competition and yAudit fixes
  • Loading branch information
kasperpawlowski authored Nov 29, 2024
2 parents a90cf55 + 101136f commit 7eb6e3f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
version: nightly-c99854277c346fa6de7a8f9837230b36fd85850e

- name: Run foundry fmt check
run: |
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Run foundry tests
# --ast tests enables inline configs to work https://github.com/foundry-rs/foundry/issues/7310#issuecomment-1978088200
run: |
forge test -vvv --gas-report --ast
forge test -vvv --ast
id: test

coverage:
Expand Down
Binary file added audits/Euler Cantina Code Competition report.pdf
Binary file not shown.
Binary file not shown.
7 changes: 3 additions & 4 deletions test/unit/Scenarios.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2366,10 +2366,9 @@ contract ScenarioTest is Test {
address _receiver,
bool _forfeitRecentReward
) external {
_rewarded = boundAddr(_rewarded);
_reward = boundAddr(_reward);
_receiver = boundAddr(_receiver);
vm.assume(uint160(_receiver) > 256);
_rewarded = boundAddr(address(uint160(bound(uint160(_rewarded), 257, type(uint160).max))));
_reward = boundAddr(address(uint160(bound(uint160(_reward), 257, type(uint160).max))));
_receiver = boundAddr(address(uint160(bound(uint160(_receiver), 257, type(uint160).max))));

vm.etch(_reward, address(reward).code);
MockERC20(_reward).mint(address(stakingDistributor), 100e18);
Expand Down
8 changes: 4 additions & 4 deletions test/unit/Staking.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@ contract StakingTest is Test {
}

// but if owner is the recipient, it should work
uint256 snapshot = vm.snapshot();
uint256 snapshot = vm.snapshotState();
preBalanceRecipient = MockERC20(rewarded).balanceOf(recipient);
preBalanceDistributor = MockERC20(rewarded).balanceOf(address(distributor));
distributor.unstake(rewarded, type(uint256).max, recipient, false);
assertEq(MockERC20(rewarded).balanceOf(recipient), preBalanceRecipient + preBalanceDistributor);
assertEq(MockERC20(rewarded).balanceOf(address(distributor)), 0);

// it should also work if the rewarded token is EVC-compatible
vm.revertTo(snapshot);
vm.revertToState(snapshot);
vm.mockCall(rewarded, abi.encodeWithSignature("EVC()"), abi.encode(address(evc)));

for (uint160 i = 1; i < 256; ++i) {
snapshot = vm.snapshot();
snapshot = vm.snapshotState();

address _recipient = address(uint160(recipient) ^ i);

Expand All @@ -130,7 +130,7 @@ contract StakingTest is Test {
assertEq(MockERC20(rewarded).balanceOf(_recipient), preBalanceRecipient + preBalanceDistributor);
assertEq(MockERC20(rewarded).balanceOf(address(distributor)), 0);

vm.revertTo(snapshot);
vm.revertToState(snapshot);
}

vm.stopPrank();
Expand Down

0 comments on commit 7eb6e3f

Please sign in to comment.