MCPcopy
hub / github.com/Uniswap/v2-core / getCreate2Address

Function getCreate2Address

test/shared/utilities.ts:36–50  ·  view source on GitHub ↗
(
  factoryAddress: string,
  [tokenA, tokenB]: [string, string],
  bytecode: string
)

Source from the content-addressed store, hash-verified

34}
35
36export function getCreate2Address(
37 factoryAddress: string,
38 [tokenA, tokenB]: [string, string],
39 bytecode: string
40): string {
41 const [token0, token1] = tokenA < tokenB ? [tokenA, tokenB] : [tokenB, tokenA]
42 const create2Inputs = [
43 '0xff',
44 factoryAddress,
45 keccak256(solidityPack(['address', 'address'], [token0, token1])),
46 keccak256(bytecode)
47 ]
48 const sanitizedInputs = `0x${create2Inputs.map(i => i.slice(2)).join('')}`
49 return getAddress(`0x${keccak256(sanitizedInputs).slice(-40)}`)
50}
51
52export async function getApprovalDigest(
53 token: Contract,

Callers 1

createPairFunction · 0.90

Calls

no outgoing calls

Tested by 1

createPairFunction · 0.72