Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cantina code competition and yAudit fixes #29

Merged
merged 6 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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