Skip to content

Commit

Permalink
use msg.data instead of params
Browse files Browse the repository at this point in the history
  • Loading branch information
Jun1on committed Jul 15, 2024
1 parent 802f466 commit feb48f2
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions contracts/middleware/MiddlewareRemove.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,15 @@ contract MiddlewareRemove is BaseMiddleware {
IPoolManager.ModifyLiquidityParams calldata params,
bytes calldata hookData
) external returns (bytes4) {
(bool success,) = address(this).delegatecall{gas: GAS_LIMIT}(
abi.encodeWithSelector(this._callAndEnsurePrice.selector, sender, key, params, hookData)
);
address(this).delegatecall{gas: GAS_LIMIT}(abi.encodeWithSelector(this._callAndEnsurePrice.selector, msg.data));
return BaseHook.beforeRemoveLiquidity.selector;
}

function _callAndEnsurePrice(
address sender,
PoolKey calldata key,
IPoolManager.ModifyLiquidityParams calldata params,
bytes calldata hookData
) external {
function _callAndEnsurePrice(bytes calldata data) external {
(, PoolKey memory key,,) = abi.decode(data[4:], (address, PoolKey, IPoolManager.ModifyLiquidityParams, bytes));

(uint160 priceBefore,,,) = manager.getSlot0(key.toId());
(bool success,) = address(implementation).delegatecall(
abi.encodeWithSelector(this.beforeRemoveLiquidity.selector, sender, key, params, hookData)
);
(bool success,) = address(implementation).delegatecall(data);
if (!success) {
revert();
}
Expand Down

0 comments on commit feb48f2

Please sign in to comment.