feat: Refactor callback to use transient storage
With this, we don't need the univ3 specific method in the router contract. This should be flexible enough for most protocols that integrate TODO: is this safe enough?? --- don't change below this line --- ENG-4411 Took 1 hour 52 minutes Took 4 minutes Took 5 minutes
This commit is contained in:
@@ -52,7 +52,7 @@ contract Dispatcher {
|
||||
* @dev Calls an executor, assumes swap.protocolData contains
|
||||
* protocol-specific data required by the executor.
|
||||
*/
|
||||
// slither-disable-next-line delegatecall-loop
|
||||
// slither-disable-next-line delegatecall-loop,assembly
|
||||
function _callExecutor(
|
||||
address executor,
|
||||
uint256 amount,
|
||||
@@ -62,6 +62,10 @@ contract Dispatcher {
|
||||
revert Dispatcher__UnapprovedExecutor();
|
||||
}
|
||||
|
||||
assembly {
|
||||
tstore(0, executor)
|
||||
}
|
||||
|
||||
// slither-disable-next-line controlled-delegatecall,low-level-calls
|
||||
(bool success, bytes memory result) = executor.delegatecall(
|
||||
abi.encodeWithSelector(IExecutor.swap.selector, amount, data)
|
||||
@@ -80,8 +84,12 @@ contract Dispatcher {
|
||||
calculatedAmount = abi.decode(result, (uint256));
|
||||
}
|
||||
|
||||
// slither-disable-next-line assembly
|
||||
function _handleCallback(bytes calldata data) internal {
|
||||
address executor = address(uint160(bytes20(data[data.length - 20:])));
|
||||
address executor;
|
||||
assembly {
|
||||
executor := tload(0)
|
||||
}
|
||||
|
||||
if (!executors[executor]) {
|
||||
revert Dispatcher__UnapprovedExecutor();
|
||||
|
||||
Reference in New Issue
Block a user