I have few question:
1.
bool zeroForOne = params.tokenIn < params.tokenOut;
This code means: if params.tokenIn
is less than params.tokenOut
then make zeroForOne
true, am i right?
2.
There is a library named Path.sol
in libraries directory, it has a function named numPools()
. In a contract this library was imported and used forbytes
, using Path for bytes
, how this code is working then:
sqrtPriceX96AfterList = new uint160[](path.numPools());
we are imported Path.sol but how path came in path.numPools()
? Should not it be Path.numPools()
?
3. A code is :
import "./libraries/Path.sol"
contract Check {
using Path for bytes;
struct SwapCallbackData {
bytes path; // swap path
address payer; // address who provides inout token in swaps
}
function _swap(
uint256 amountIn,
address recipient,
uint160 sqrtPriceLimitX96,
SwapCallbackData memory data
) internal returns (uint256 amountOut) {
(address tokenIn, address tokenOut, uint24 tickSpacing) = data
.path
.decodeFirstPool();
}
}
Here decodeFirstPool()
is a function of Path.sol library, how data.path.decodeFirstPool()
is working? I asked about the path in question 2, i am confused on how the connection was made between data and path??