Library
#
Code#
Internal Functions#
sortTokensSorts token addresses.
#
pairForCalculates the address for a pair without making any external calls (see Pair Addresses.
#
getReservesCalls getReserves on the pair for the passed tokens, and returns the results sorted in the order that the parameters were passed in.
#
quoteGiven some asset amount and reserves, returns an amount of the other asset representing equivalent value.
- Useful for calculating optimal token amounts before calling mint.
#
getAmountOutGiven an input asset amount, returns the maximum output amount of the other asset (accounting for fees) given reserves.
- Used in getAmountsOut.
#
getAmountInReturns the minimum input asset amount required to buy the given output asset amount (accounting for fees) given reserves.
- Used in getAmountsIn.
#
getAmountsOutGiven an input asset amount and an array of token addresses, calculates all subsequent maximum output token amounts by calling getReserves for each pair of token addresses in the path in turn, and using these to call getAmountOut.
- Useful for calculating optimal token amounts before calling swap.
#
getAmountsInGiven an output asset amount and an array of token addresses, calculates all preceding minimum input token amounts by calling getReserves for each pair of token addresses in the path in turn, and using these to call getAmountIn.
- Useful for calculating optimal token amounts before calling swap.