-
-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Labels
somedayGood idea but not planned yetGood idea but not planned yet
Description
Most DEX pools (e.g. UniswapV3 Pool) are not verified, but they all have the same ABI. Instead of returning an empty abi, we can add support for common DEX pools. We can identify which pool they belong to using their contractFactory address. A rough sketch below:
import { abi as UniswapV3PoolAbi } from "@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json";
const UNISWAP_V3_CONTRACT_FACTORY = "0x1f98431c8ad98523631ae4a59f267346ea31f984"
...
const contractFactory = await this.getContractFactory(target);
if (contractFactory === UNISWAP_V3_CONTRACT_FACTORY) {
abi = UniswapV3PoolAbi;
}
private async getContractFactory(address: string): Promise<string | null> {
const url = `https://api.etherscan.io/v2/api?chainid=1&module=contract&action=getcontractcreation&contractaddresses=${address}&apikey=${this.etherscanApiKey}`;
const res = await fetch(url);
const data = (await res.json()) as any;
if (data.result && data.result.length > 0) {
return data.result[0].contractFactory;
}
return null;
}
Metadata
Metadata
Assignees
Labels
somedayGood idea but not planned yetGood idea but not planned yet