-
Notifications
You must be signed in to change notification settings - Fork 13
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
_gasSwapIn()
and _gasSwapOut()
could end up with partial swaps due to insufficient slippage protection
#637
Comments
trust1995 marked the issue as unsatisfactory: |
Please see below for further clarifications on this issue. Point 1 - Explanation of issue - partial swap in
|
Lines of code
https://github.com/code-423n4/2023-05-maia/blob/main/src/ulysses-omnichain/RootBridgeAgent.sol#L684-L695
https://github.com/code-423n4/2023-05-maia/blob/main/src/ulysses-omnichain/RootBridgeAgent.sol#L727-L734
Vulnerability details
_gasSwapIn()
and_gasSwapOut()
are lacking a check to verify that the swap amount received is greater than a specified minimum.Relying on the
sqrtPriceLimitX96
parameter forswap()
as a slippage protection is not sufficient. That is becauseUniswapV3Pool
will not revert even whensqrtPriceLimitX96
is hit, which means that it will continue with a partial swap. (see UniswapV3Pool.sol#L641)Impact
When a partial swap occur for
_gasSwapIn()
and_gasSwapOut()
, the remaining gas token will be stuck inRootBridgeAgent
while the crosschain execution will fail with insufficient gas.Detailed Explanation
Both
_gasSwapIn()
and_gasSwapOut()
only usesqrtPriceLimitX96
as a measure for slippage protection. That will result in partial swaps whensqrtPriceLimitX96
is hit and the input token amountint256(_amount)
is not entirely used up.https://github.com/code-423n4/2023-05-maia/blob/main/src/ulysses-omnichain/RootBridgeAgent.sol#L684-L695
https://github.com/code-423n4/2023-05-maia/blob/main/src/ulysses-omnichain/RootBridgeAgent.sol#L727-L734
Recommended Mitigation Steps
Check that that the swap amount received is greater than the minimum based on the price limit. Refer to UniswapV3's
SwapRouter.sol
https://github.com/Uniswap/v3-periphery/blob/main/contracts/SwapRouter.sol#L128
Assessed type
Uniswap
The text was updated successfully, but these errors were encountered: