Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Override Fee Library #114

Closed
saucepoint opened this issue May 20, 2024 · 3 comments
Closed

Add Override Fee Library #114

saucepoint opened this issue May 20, 2024 · 3 comments
Labels
good first issue Good for newcomers revisit issues that were closed prior to cantina, but may be revisited v4 deployer comp

Comments

@saucepoint
Copy link
Collaborator

saucepoint commented May 20, 2024

Component

General design optimization (improving efficiency, cleanliness, or developer experience)

Describe the suggested feature and problem it solves.

Uniswap/v4-core#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.

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());
    }
}

Describe alternatives.

No response

Additional context.

No response

@saucepoint saucepoint added the good first issue Good for newcomers label May 20, 2024
Copy link

linear bot commented May 20, 2024

@Jun1on Jun1on linked a pull request Jun 27, 2024 that will close this issue
@saucepoint
Copy link
Collaborator Author

to revisit but kinda meh

@saucepoint saucepoint added the revisit issues that were closed prior to cantina, but may be revisited label Sep 4, 2024
@azflin
Copy link
Contributor

azflin commented Sep 6, 2024

gm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers revisit issues that were closed prior to cantina, but may be revisited v4 deployer comp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants