JBSwapTerminal
Inherits: JBPermissioned, Ownable, IJBTerminal, IJBPermitTerminal, IJBSwapTerminal, IUniswapV3SwapCallback
The JBSwapTerminal
accepts payments in any token. When the JBSwapTerminal
is paid, it uses a Uniswap
pool to exchange the tokens it received for tokens that another one of its project's terminals can accept. Then, it
pays that terminal with the tokens it got from the pool, forwarding the specified beneficiary to receive any tokens
or NFTs minted by that payment, as well as payment metadata and other arguments.
To prevent excessive slippage, the user/client can specify a minimum quote and a pool to use in their payment's
metadata using the JBMetadataResolver
format. If they don't, a quote is calculated for them based on the TWAP
oracle for the project's default pool for that token (set by the project's owner).
Notes:
-
metadata-id-used: quoteForSwap and permit2
-
benediction: DEVS BENEDICAT ET PROTEGAT CONTRACTVS MEAM
State Variables
DEFAULT_PROJECT_ID
The ID to store default values in.
uint256 public constant override DEFAULT_PROJECT_ID = 0;
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;