Auto-compounder functionality for Uniswap v3 is provided by the Revert Compoundor protocol which allows for the automation through awarding executors (compoundors) a small fee to compensate for their gas costs, and a simple mechanism that incentivizes the compounding of positions as close to optimal as possible. Unlike its predecessor, in Uniswap v3, swap fees taken by the protocol for LPs do not accumulate inside the pool, but in a separate balance for each position. One consequence of this is that fees are not compounded automatically back into the position. Manual compounding of fees is possible, but it is a cumbersome process composed of the following steps:
- 1.Collecting fees via the NFT Manager contract.
- 2.Checking the amounts of token0/token1 required to swap so as to maximize the amount of liquidity added to the position.
- 3.Perform the swap without getting sandwiched.
- 4.Add the swapped amounts as liquidity to the position.
Costs associated with compounding fees Given the above described contract interactions, compounding fees can result in high gas costs. The decision of when to compound fees falls on a protocol mechanism that incentivizes frequency of compounding fees without the costs being a significant portion of the collected fees. The protocol allows any account, at any point, to call the autoCompound function. The caller will have to pay for the gas costs of making this transaction, and in exchange will receive 1% of the liquidity deposited into the position.
Any account that adds his Uniswap v3 position to the Compounder contract and benefits from auto-compounding.
Any account that participates in auto-compounding positions deposited in the Compounder contract. Compoundors monitor collected fees, token prices and gas price to decide when to execute auto-compound operations, and win a part of the compounded fees as a reward (and to account for the gas cost of calling the auto-compounding function). Some guidelines on how to become a Compoundor can be found here.
Contract owner account controlled by Revert. It can modify 4 configuration parameters, and can transfer ownership of the contract to another account or contract.
- totalRewardX64: Total reward paid to the protocol, including the compounder reward. This value starts at 2% (of the compounded fees) and can only be reduced, never increased.
- compounderRewardX64: Reward paid to compounder. Must always be less than totalRewardX64.
- maxTWAPTickDifference: Max amount of ticks the current tick may differ from the Oracle TWAP tick to allow swaps. A sanity check to provide price manipulation protection.
- TWAPSeconds: How many seconds should be used to calculate TWAP.