A shared fungible (ERC20) position for Uniswap V3 passive liquidity providers. G-UNI pools are auto-compounded by gelato network to reinvest accrued fees into the position. The position bounds are static and immutable by default, unless creating a "managed" pool, in which case an executiveRebalance can be performed by the governance/manager account which will redeposit liquidity into a new range (see docs for more info).
function mint(uint256 mintAmount, address receiver)
external
nonReentrant
returns (
uint256 amount0,
uint256 amount1,
uint128 liquidityMinted
)
Arguments:
mintAmountamount of G-UNI tokens to mintreceiveraccount that receives the G-UNI tokens
Returns:
amount0amount of token0 actually deposited into G-UNIamount1amount of token1 actually deposited into G-UNIliquidityMintedamount of liqudiity added to G-UNI position
Note: to find out the amount of token0 and token1 you would owe by minting that many G-UNI tokens use getMintAmounts method.
function burn(uint256 _burnAmount, address _receiver)
external
nonReentrant
returns (
uint256 amount0,
uint256 amount1,
uint128 liquidityBurned
)
Arguments:
_burnAmountnumber of G-UNI tokens to burn_receiveraccount that receives the remitted token0 and token1
Returns:
amount0amount of token0 remitted to _receiveramount1amount of token1 remitted to _receiverliquidityBurnedamount of liquidity burned from G-UNI positon
function getMintAmounts(uint256 amount0Max, uint256 amount1Max)
external
view
returns (
uint256 amount0,
uint256 amount1,
uint256 mintAmount
)
Arguments:
amount0Maxmaximum amount of token0 to deposit into G-UNIamount1Maxmaximum amount of token1 to deposit into G-UNI
Returns:
amount0actual amount of token0 to deposit into G-UNIamount1actual amount of token1 to deposit into G-UNImintAmountamount of G-UNI tokens to pass to mint function (will cost exactlyamount0andamount1)
function rebalance(
uint160 _swapThresholdPrice,
uint256 _swapAmountBPS,
uint256 _feeAmount,
address _paymentToken
) external gelatofy(_feeAmount, _paymentToken) {
Arguments:
_swapThresholdPricea sqrtPriceX96 which is used as the slippage parameter in uniswap v3 swaps._swapAmountBPSamount to swap passed as basis points of current amount of leftover token held (e.g. "swap 50% of balance" would be a value of 5000)_feeAmountamount that gelato will take as a fee (GelatoDiamondchecks against gas consumption so bot is not allowed to overcharge)_paymentTokenthe token in which_feeAmountis collected
Note: This method can only be called by gelato executors
If governance/admin wants to change bounds of the underlying position, or wants to force a rebalance for any other reason, they are allowed to call this executive rebalance function.
function executiveRebalance(
int24 _newLowerTick,
int24 _newUpperTick,
uint160 _swapThresholdPrice,
uint256 _swapAmountBPS,
bool _zeroForOne
) external onlyOwner {
Arguments:
_newLowerTickthe tick to use as position lower bound on reinvestment_newUpperTickthe tick to use as position upper bound on reinvestment_swapThresholdPricea sqrtPriceX96 which is used as the slippage parameter in uniswap v3 swaps._swapAmountBPSamount to swap passed as basis points of current amount of leftover token held (e.g. "swap 50% of balance" would be a value of 5000)_zeroForOnewhich token to input into the swap (true = token0, false = token1)
yarn
yarn test