import { encodeAbiParameters, keccak256 } from "viem";
// v4 sorts currencies by address. Native ETH is the zero address, so it is
// always currency0.
const [currency0, currency1] =
launch.pairToken.toLowerCase() < launch.token.toLowerCase()
? [launch.pairToken, launch.token]
: [launch.token, launch.pairToken];
const poolKey = {
currency0,
currency1,
fee: launch.poolFee, // 0: the hook charges the fee, not the pool
tickSpacing: launch.tickSpacing, // 200
hooks: memeHook, // the hook of the token's own stack
};
const poolId = keccak256(
encodeAbiParameters(
[{ type: "address" }, { type: "address" }, { type: "uint24" }, { type: "int24" }, { type: "address" }],
[poolKey.currency0, poolKey.currency1, poolKey.fee, poolKey.tickSpacing, poolKey.hooks],
),
);