Internal Swap Pool
Introduction
The Internal Swap Pool (ISP) hook allows for fees to be accumulated that will subsequently be distributed to recipients. The magic of this hook comes in the fact that we convert all donated fees to one of the tokens through intercepting swaps using beforeSwap
.
This hook depends on a desired token (the one that we want to distributed) and undesired token (the one that we don't want to distribute) pairing in pools. In our case the desired token is (fl)ETH and the undesired token is the flaunched memecoin.
When a swap takes place in Uniswap V4, the fee is always taken in the unspecified token. So if I wanted to spend 1 ETH to buy as many memecoin as possible, then the fee would be taken from the memecoin.
The ISP captures and holds any undesired token fees (the memecoin) and then frontruns any subsequent pool swaps to fill from it’s own internal position before hitting Uniswap to request the remainder. This converts memecoin into ETH, which is only then distributed to fee recipients.
The Internal Swap Pool logic is implemented in the beforeSwap
hook, which then alters the BeforeSwapDelta
returned in the hook to Uniswap. This informs Uniswap V4 that we have already facilitated part, or all, of the swap required and reduces the amount swapped on Uniswap.
Public Calls
poolFees
Provides the Claimable Fees for a pool key.
The ClaimableFees struct is defined as:
Key Benefits
Recipients don’t have to swap the token against the pool, reducing detrimental tick movement. We reduce price movement on the actual pool, sometimes negating it entirely if our pool holds the full swap value.
Recipients don’t need to dump tokens or perform any other actions to receive ETH, which would negatively impact the memecoin price.
Last updated