LBQuoter
Last updated
Last updated
Author: Trader Joe
Helper contract to determine best path through multiple markets This contract shouldn't be used on-chain as it consumes a lot of gas It should be used for off-chain purposes, like calculating the best path for a swap
Constructor
Parameters
factoryV1
address
Dex V1 factory address
legacyFactoryV2
address
Dex V2 factory address
factoryV2_1
address
Dex V2.1 factory address
factoryV2_2
address
Dex V2.2 factory address
legacyRouterV2
address
Dex V2 router address
routerV2_1
address
Dex V2.1 router address
routerV2_2
address
Dex V2.2 router address
Returns the Dex V1 factory address
Returns
factoryV1
address
Dex V1 factory address
Returns the Dex V2 factory address
Returns
legacyFactoryV2
address
Dex V2 factory address
Returns the Dex V2.1 factory address
Returns
factoryV2_1
address
Dex V2.1 factory address
Returns the Dex V2.2 factory address
Returns
factoryV2_2
address
Dex V2.2 factory address
Returns the Dex V2 router address
Returns
legacyRouterV2
address
Dex V2 router address
Returns the Dex V2.1 router address
Returns
routerV2_1
address
Dex V2.1 router address
Returns the Dex V2.2 router address
Returns
routerV2_2
address
Dex V2.2 router address
Finds the best path given a list of tokens and the input amount wanted from the swap
Parameters
route
address[]
List of the tokens to go through
amountIn
uint128
Swap amount in
Returns
quote
Quote
The Quote structure containing the necessary element to perform the swap
Finds the best path given a list of tokens and the output amount wanted from the swap
Parameters
route
address[]
List of the tokens to go through
amountOut
uint128
Swap amount out
Returns
quote
Quote
The Quote structure containing the necessary element to perform the swap
Forked from JoeLibrary
Doesn't rely on the init code hash of the factory
Parameters
pair
address
Address of the pair
tokenA
address
Address of token A
tokenB
address
Address of token B
Returns
reserveA
uint256
Reserve of token A in the pair
reserveB
uint256
Reserve of token B in the pair
Calculates a quote for a V2 pair
Parameters
amount
uint256
Amount in to consider
activeId
uint24
Current active Id of the considred pair
binStep
uint256
Bin step of the considered pair
swapForY
bool
Boolean describing if we are swapping from X to Y or the opposite
Returns
quote
uint128
Amount Out if _amount was swapped with no slippage and no fees
*The quote struct returned by the quoter
route: address array of the token to go through
pairs: address array of the pairs to go through
binSteps: The bin step to use for each pair
versions: The version to use for each pair
amounts: The amounts of every step of the swap
virtualAmountsWithoutSlippage: The virtual amounts of every step of the swap without slippage
fees: The fees to pay for every step of the swap*