JBBuybackHook
Inherits: JBPermissioned, IJBBuybackHook
The buyback hook allows beneficiaries of a payment to a project to either:
- Get tokens by paying the project through its terminal OR
- Buy tokens from the configured Uniswap v3 pool. Depending on which route would yield more tokens for the beneficiary. The project's reserved rate applies to either route.
Compatible with any JBTerminal
and any project token that can be pooled on Uniswap v3.
Note: benediction: DEVS BENEDICAT ET PROTEGAT CONTRACTVS MEAM
State Variables
MAX_TWAP_SLIPPAGE_TOLERANCE
Projects cannot specify a TWAP slippage tolerance larger than this constant (out of MAX_SLIPPAGE
).
This prevents TWAP slippage tolerances so high that they would result in highly unfavorable trade conditions for the payer unless a quote was specified in the payment metadata.
uint256 public constant override MAX_TWAP_SLIPPAGE_TOLERANCE = 9000;
MIN_TWAP_SLIPPAGE_TOLERANCE
Projects cannot specify a TWAP slippage tolerance smaller than this constant (out of MAX_SLIPPAGE
).
This prevents TWAP slippage tolerances so low that the swap always reverts to default behavior unless a quote is specified in the payment metadata.
uint256 public constant override MIN_TWAP_SLIPPAGE_TOLERANCE = 100;
MAX_TWAP_WINDOW
Projects cannot specify a TWAP window longer than this constant.
This serves to avoid excessively long TWAP windows that could lead to outdated pricing information and higher gas costs due to increased computational requirements.
uint256 public constant override MAX_TWAP_WINDOW = 2 days;
MIN_TWAP_WINDOW
Projects cannot specify a TWAP window shorter than this constant.
This serves to avoid extremely short TWAP windows that could be manipulated or subject to high volatility.
uint256 public constant override MIN_TWAP_WINDOW = 2 minutes;
TWAP_SLIPPAGE_DENOMINATOR
The denominator used when calculating TWAP slippage percent values.
uint256 public constant override TWAP_SLIPPAGE_DENOMINATOR = 10_000;
CONTROLLER
The controller used to mint and burn tokens.
IJBController public immutable override CONTROLLER;
DIRECTORY
The directory of terminals and controllers.
IJBDirectory public immutable override DIRECTORY;
PRICES
The contract that exposes price feeds.
IJBPrices public immutable override PRICES;