How to Auto-Compound
The basics
Positions managed by the Compoundor contract can be auto-compounded by anyone. The autoCompound() function converts the available fees of a position to the ratio required given the position range and the current pool price, and adds it as liquidity to the position. A performance fee, of max 2% of the compounded liquidity, is paid as a protocol fee and to compensate the accounts that perform the auto-compounding for their gas costs incurred.
The caller can decide to receive the reward payment in either both, token0 or token1, and if he wants to transfer the tokens immediately (or at a later moment to optimize gas usage).
Keeping track of positions
The following two events are emitted when a token is deposited into or withdrawn from the Compoundor contract. They can be used by compoundors to decide which positions need to be monitored.
autoCompound() function
The autoCompound() function can be called by anyone, with a parameter of type AutoCompoundParams
tokenID - the id of the NFT for the Uniswap V3 position to auto-compound
rewardConversion - should the reward be paid out in both tokens (in the proportion of how the fees were collected), or one of the tokens exclusively
withdrawReward - should the reward tokens (and previously accumulated tokens) be transferred to msg.sender immediately, or remain in the contract for later collection
doSwap - should compound be done with or without a swap. It might be optimal to avoid swaps which increase the gas cost which could permit more frequent compounds.
Bot implementation
A basic implementation of an auto-compound bot can be found on our Github.
There are many other ways this can be automated (e.g. using Chainlink Keepers)
Last updated