A fun way to to round up your trade at a chance to not pay for swap fees on Pancakeswap V4!
This is a hook for the newly released Pancakeswap V4 via hooks. A lot of people don't know this but as DeFi traders, we end up paying a lot of swap fees to Liquidity Providers. The fee can range from 0.05% to 1% of the value of the swap, which can be quite a bit. Hundreds of millions of dollars have been paid as swap fees in the past year!
What if there's a fun way to potentially get your swap fees back as a trader and also have some fun at the same time? Enter the Transaction Swap Fee Winback Hook!
We allow users to round up their trade (currently to $1 USDT) for a chance to win back their whole swap fee they paid! The chance of winning back the swap fee depends on the amount of round up and also the swap fee paid.
For example, if a user paid a dollar and the swap fee totalled $10, then they would have a 1/10 chance of winning.
We are leveraging the Pancakswap V4 hooks for our purpose. There is a hook for an action after a swap, and we are using this hook here to:
hookData
and then encode/decode it (thanks Chefs for guiding me here):swapRouter.exactInputSingle(
ICLSwapRouterBase.V4CLExactInputSingleParams({
poolKey: key,
zeroForOne: false,
recipient: address(this),
amountIn: 1000 ether,
amountOutMinimum: 0,
sqrtPriceLimitX96: 0,
hookData: abi.encode(address(this)) // later on decode it in the hook by doing abi.decode(hookParams, (address));
}),
block.timestamp);