## Calculate Pool Trident ``` // SPDX-License-Identifier: GPL-3 pragma solidity ^0.8.7; bytes32 constant bytecodeHash = 0xf12c5d0bd466e168fefdf789d5c48040e038cb71f6b1bcc741e9ae57205f3906; address constant STABLE_FACTORY = 0xc2fB256ABa36852DCcEA92181eC6b355f09A0288; contract Calc { function calculatePoolAddress( address token0, address token1, uint256 swapFee ) external pure returns (bytes32, bytes32, uint256, address) { bytes32 salt = keccak256(abi.encode(token0, token1, swapFee)); bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), STABLE_FACTORY, salt, bytecodeHash)); return (salt, hash, uint256(hash), address(uint160(uint256(hash)))); } } ``` ![](https://i.imgur.com/eyvAHCm.png) - Each step in python ![](https://i.imgur.com/VaMHJZS.png) ![](https://i.imgur.com/fnbwYwp.png) ![](https://i.imgur.com/vn6pzfd.png) ![](https://i.imgur.com/9U2hf6a.png) ![](https://i.imgur.com/2y1lqjB.png) ![](https://i.imgur.com/rMAUQFp.png) ![](https://i.imgur.com/hhGcROV.png) ![](https://i.imgur.com/gVKN5w9.png) ## Calculate Pool Legacy Same thing but using v2 factory address and init hash ``` return getCreate2Address( Bytes.fromByteArray(Bytes.fromHexString('{{ legacy.factory.address }}')), Bytes.fromByteArray(crypto.keccak256(ByteArray.fromHexString('0x' + tokens[0].slice(2) + tokens[1].slice(2)))), Bytes.fromByteArray(Bytes.fromHexString('{{ legacy.factory.initCodeHash }}')) ).toHex() }) ``` ``` bytes32 salt = keccak256(abi.encodePacked(token0, token1)); ``` No fee needed: ![](https://i.imgur.com/ZjHQsC4.png) ``` >>> w3.solidityKeccak(['address','address'], [Web3.toChecksumAddress('0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9'),Web3.toChecksumAddress('0xff970a61a04b1ca14834a43f5de4533ebddb5cc8')]) HexBytes('0x4e5db125a564d62ef8ac77108269a37abb6d3ca5524569441095fdd256ac9a0b') >>> >>> w3.solidityKeccak(['bytes1','address','bytes32','bytes32'], ['0xff', '0xc35DADB65012eC5796536bD9864eD8773aBc74C4', '0x4e5db125a564d62ef8ac77108269a37abb6d3ca5524569441095fdd256ac9a0 b', '0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303']) HexBytes('0xe3977f33673cce35c7f809cb8165c70b01b7807351ef0c5ffd3ef010cabc16fb') >>> >>> 0xe3977f33673cce35c7f809cb8165c70b01b7807351ef0c5ffd3ef010cabc16fb 102942688442798508597843236823529409339217359047515382357316390602785670567675 >>> >>> str(hex(102942688442798508597843236823529409339217359047515382357316390602785670567675)[26:]) '8165c70b01b7807351ef0c5ffd3ef010cabc16fb' >>> ``` USDT-ETH: https://arbiscan.io/address/0x8165c70b01b7807351EF0c5ffD3EF010cAbC16fB#readContract Info's: - v2 factory address: '**0xc35dadb65012ec5796536bd9864ed8773abc74c4**', https://arbiscan.io/address/0xc35dadb65012ec5796536bd9864ed8773abc74c4#readContract - initCodeHash: '**0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303**' ![](https://i.imgur.com/4iZ7U8U.png) https://github.com/sushiswap/subgraphs/blob/2d4ee3970618d6f3a1c661ece1c86bceaa9a97cd/config/arbitrum.js