Pool Initialization
Learn the conditions ERC4626WrapperHook enforces before a wrapper pool can exist, and how swap direction maps to wrap or unwrap.
_beforeInitialize enforces two conditions before the pool can exist:
currency0andcurrency1are the wrapper and underlying currencies, in the order fixed bywrapZeroForOne (InvalidPoolToken).fee == 0 (InvalidPoolFee).
wrapZeroForOne is an immutable set in the constructor to underlyingCurrency < wrapperCurrency (by address). It records which token is currency0:
wrapZeroForOne == true:currency0is the underlying,currency1is the wrapper. AzeroForOneswap wraps.wrapZeroForOne == false:currency0is the wrapper,currency1is the underlying. AzeroForOneswap unwraps.
This maps a swap direction to wrap or unwrap deterministically, regardless of how the two token addresses sort.