Path library #114
Unanswered
langjiyunmie
asked this question in
Milestone 4. Multi-pool Swaps
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
``//SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.14;
import "bytes-utils/BytesLib.sol";
library BytesLibExt {
function toUint24(bytes memory _bytes, uint256 _start)
internal
pure
returns (uint24)
{
require(_bytes.length >= _start + 3, "toUint24_outOfBounds");
uint24 tempUint;
}
library Path {
using BytesLib for bytes;
using BytesLibExt for bytes;
}
I don't understand the assembly in the BytesLibExt library, expecially why use 0x3 in the sentence
"tempUint := mload(add(add(_bytes, 0x3), _start)) "; I think it should use 0x20 to skip the length of array in the bytes types. Although I don't really understand this part of the code, I know clearly that it is to convert tick to uint24. Does anyone know why 0x3 is used here?
Beta Was this translation helpful? Give feedback.
All reactions