Skip to content

Commit

Permalink
test: show that operation still succeeds even with stray token
Browse files Browse the repository at this point in the history
  • Loading branch information
xenide committed Dec 6, 2024
1 parent 2506058 commit 04dfc95
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/integration/Euler.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1145,4 +1145,36 @@ contract EulerIntegrationTest is BaseTest {
assertGe(lPair2Shares, lPair2SharesBefore);
assertGe(lPair3Shares, lPair3SharesBefore);
}

function testDoSAttack_Supply() external allNetworks allPairs {
// arrange
_deal(address(USDC), _alice, 1_000_000e6);
vm.prank(_alice);
USDC.transfer(address(_manager), 1231232);

// act - adjustManagement should still succeed despite extra tokens
int256 lAmtToManage = 2e6;
_manager.adjustManagement(_pair, USDC == _pair.token0() ? lAmtToManage : int256(0), USDC == _pair.token1() ? lAmtToManage : int256(0));

// assert
assertGt(USDC.balanceOf(address(_manager)), 0);
assertApproxEqAbs(_manager.getBalance(_pair, USDC), uint256(lAmtToManage), 1);
}

function testDoSAttack_Withdraw() external allNetworks allPairs {
// arrange
int256 lAmtToManage = 2e6;
_increaseManagementOneToken(lAmtToManage);
uint256 lUnexpectedTokens = 33222;
_deal(address(USDC), address(_manager), lUnexpectedTokens);

// act
uint256 lBalance = _manager.getBalance(_pair, USDC);
_manager.adjustManagement(_pair, _pair.token0() == USDC ? -int256(lBalance) : int256(0), _pair.token1() == USDC ? -int256(lBalance) : int256(0));

// assert
assertEq(_manager.getBalance(_pair, USDC), 0);
assertEq(USDCVault.balanceOf(address(_manager)), 0);
assertEq(USDC.balanceOf(address(_manager)), lUnexpectedTokens);
}
}

0 comments on commit 04dfc95

Please sign in to comment.