fix: Support Euler in swapExactInput
Do the token transfers before calling swap on the pool manager Took 13 minutes Took 10 seconds
This commit is contained in:
@@ -332,6 +332,7 @@ contract UniswapV4Executor is
|
||||
uint128 amountOut = 0;
|
||||
Currency swapCurrencyIn = currencyIn;
|
||||
uint256 swapAmountIn = amountIn;
|
||||
_settle(currencyIn, amountIn, transferType);
|
||||
unchecked {
|
||||
uint256 pathLength = path.length;
|
||||
PathKey calldata pathKey;
|
||||
@@ -353,12 +354,6 @@ contract UniswapV4Executor is
|
||||
}
|
||||
}
|
||||
|
||||
uint256 amount = _getFullDebt(currencyIn);
|
||||
if (amount > amountIn) {
|
||||
revert UniswapV4Executor__V4TooMuchRequested(amountIn, amount);
|
||||
}
|
||||
_settle(currencyIn, amount, transferType);
|
||||
|
||||
_take(
|
||||
swapCurrencyIn, // at the end of the loop this is actually currency out
|
||||
receiver,
|
||||
@@ -409,21 +404,6 @@ contract UniswapV4Executor is
|
||||
amount = uint256(_amount);
|
||||
}
|
||||
|
||||
/// @notice Obtain the full amount owed by this contract (negative delta)
|
||||
/// @param currency Currency to get the delta for
|
||||
/// @return amount The amount owed by this contract as a uint256
|
||||
function _getFullDebt(Currency currency)
|
||||
internal
|
||||
view
|
||||
returns (uint256 amount)
|
||||
{
|
||||
int256 _amount = poolManager.currencyDelta(address(this), currency);
|
||||
// If the amount is positive, it should be taken not settled.
|
||||
if (_amount > 0) revert UniswapV4Executor__DeltaNotNegative(currency);
|
||||
// Casting is safe due to limits on the total supply of a pool
|
||||
amount = uint256(-_amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice Pays and settles a currency to the pool manager.
|
||||
* @dev The implementing contract must ensure that the `payer` is a secure address.
|
||||
|
||||
Reference in New Issue
Block a user