You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered a compilation error when trying to inherit and override the beforeSwap function as instructed in the test case README. The README example directly inherits and implements the beforeSwap function, but compilation fails in practice.
Root Cause
After examining the code, I found the issue in the main/src/utils/BaseHook.sol file. The beforeSwap function lacks the virtual modifier, preventing child contracts from properly overriding this function.
// Current implementation (problematic):function beforeSwap(...) returns (...) {
// function implementation
}
// Expected implementation:function beforeSwap(...) virtualreturns (...) {
// function implementation
}
Steps to Reproduce
Create a new contract that inherits from BaseHook following the test case README example
Attempt to override the beforeSwap function
Compile the contract
Observe the compilation error indicating that a non-virtual function cannot be overridden
Impact
This issue prevents developers from correctly extending and customizing hook logic as shown in the documentation examples, hindering the development of new hooks.
Proposed Solution
Add the virtual modifier to the beforeSwap function in the main/src/utils/BaseHook.sol file to allow it to be overridden by child contracts.
Additional Notes
I discovered this issue while learning from the official documentation. The examples in the docs imply these functions are meant to be overridable, but the actual implementation doesn't support this behavior.
Describe the bug
Description
I encountered a compilation error when trying to inherit and override the
beforeSwap
function as instructed in the test case README. The README example directly inherits and implements thebeforeSwap
function, but compilation fails in practice.Root Cause
After examining the code, I found the issue in the
main/src/utils/BaseHook.sol
file. ThebeforeSwap
function lacks thevirtual
modifier, preventing child contracts from properly overriding this function.Steps to Reproduce
BaseHook
following the test case README examplebeforeSwap
functionImpact
This issue prevents developers from correctly extending and customizing hook logic as shown in the documentation examples, hindering the development of new hooks.
Proposed Solution
Add the
virtual
modifier to thebeforeSwap
function in themain/src/utils/BaseHook.sol
file to allow it to be overridden by child contracts.Additional Notes
I discovered this issue while learning from the official documentation. The examples in the docs imply these functions are meant to be overridable, but the actual implementation doesn't support this behavior.
Expected Behavior
// ... existing code ...
function beforeSwap(
address sender,
PoolKey calldata key,
IPoolManager.SwapParams calldata params,
bytes calldata hookData
) external virtual returns (bytes4, BeforeSwapDelta, uint24) {
// ... existing code ...
}
// ... existing code ...
To Reproduce
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: