The fee is 24 bits, and the 2nd highest bit must be set to 1 in order for the override to apply. A helper library that provides syntatic sugar will be nice
Describe the desired implementation.
library OverrideFeeLibrary {
uint24 public constant OVERRIDE_FEE_FLAG = 0x400000;
function asOverrideFee(uint24 self) internal returns (uint24) {
return self | OVERRIDE_FEE_FLAG;
}
}
contract ExampleHook {
using OverrideFeeLibrary for uint24;
// ....
function beforeSwap(address, PoolKey calldata, IPoolManager.SwapParams calldata, bytes calldata)
external
view
override
returns (bytes4, BeforeSwapDelta, uint24)
{
// attach the override flag to `fee` to enable overriding the pool's stored fee
return (IHooks.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, fee.asOverrideFee());
}
}
Component
General design optimization (improving efficiency, cleanliness, or developer experience)
Describe the suggested feature and problem it solves.
https://github.com/Uniswap/v4-core/pull/648 introduced a feature where
beforeSwap
can return and set the LP fee.The fee is 24 bits, and the 2nd highest bit must be set to 1 in order for the override to apply. A helper library that provides syntatic sugar will be nice
Describe the desired implementation.
Describe alternatives.
No response
Additional context.
No response