Skip to content

Instantly share code, notes, and snippets.

@BlockmanCodes
Created June 7, 2023 12:32
Show Gist options
  • Save BlockmanCodes/dee31bd9abbdf0f6eba0a5e4c8e44233 to your computer and use it in GitHub Desktop.
Save BlockmanCodes/dee31bd9abbdf0f6eba0a5e4c8e44233 to your computer and use it in GitHub Desktop.
Kyber: get dmm pool addresses
const ethers = require('ethers');
const dmmFactoryAbi = require("../abis/dmmFactory.json")
WETH_ADDRESS= '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
USDT_ADDRESS= '0xdAC17F958D2ee523a2206206994597C13D831ec7'
DMM_FACTORY_ADDRESS='0x833e4083B7ae46CeA85695c4f7ed25CDAd8886dE'
const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545/')
const factory = new ethers.Contract(DMM_FACTORY_ADDRESS, dmmFactoryAbi, provider)
const main = async () => {
const res = await factory.getPools(WETH_ADDRESS, USDT_ADDRESS)
console.log('res', res)
}
main()
/*
node scripts/00_findPools.js
*/
[{
"inputs": [{
"internalType": "address",
"name": "_feeToSetter",
"type": "address"
}],
"stateMutability": "nonpayable",
"type": "constructor"
}, {
"anonymous": false,
"inputs": [{
"indexed": true,
"internalType": "contract IERC20",
"name": "token0",
"type": "address"
}, {
"indexed": true,
"internalType": "contract IERC20",
"name": "token1",
"type": "address"
}, {
"indexed": false,
"internalType": "address",
"name": "pool",
"type": "address"
}, {
"indexed": false,
"internalType": "uint32",
"name": "ampBps",
"type": "uint32"
}, {
"indexed": false,
"internalType": "uint256",
"name": "totalPool",
"type": "uint256"
}],
"name": "PoolCreated",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": false,
"internalType": "address",
"name": "feeTo",
"type": "address"
}, {
"indexed": false,
"internalType": "uint16",
"name": "governmentFeeBps",
"type": "uint16"
}],
"name": "SetFeeConfiguration",
"type": "event"
}, {
"anonymous": false,
"inputs": [{
"indexed": false,
"internalType": "address",
"name": "feeToSetter",
"type": "address"
}],
"name": "SetFeeToSetter",
"type": "event"
}, {
"inputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"name": "allPools",
"outputs": [{
"internalType": "address",
"name": "",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "allPoolsLength",
"outputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "contract IERC20",
"name": "tokenA",
"type": "address"
}, {
"internalType": "contract IERC20",
"name": "tokenB",
"type": "address"
}, {
"internalType": "uint32",
"name": "ampBps",
"type": "uint32"
}],
"name": "createPool",
"outputs": [{
"internalType": "address",
"name": "pool",
"type": "address"
}],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [],
"name": "feeToSetter",
"outputs": [{
"internalType": "address",
"name": "",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [],
"name": "getFeeConfiguration",
"outputs": [{
"internalType": "address",
"name": "_feeTo",
"type": "address"
}, {
"internalType": "uint16",
"name": "_governmentFeeBps",
"type": "uint16"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "contract IERC20",
"name": "token0",
"type": "address"
}, {
"internalType": "contract IERC20",
"name": "token1",
"type": "address"
}, {
"internalType": "uint256",
"name": "index",
"type": "uint256"
}],
"name": "getPoolAtIndex",
"outputs": [{
"internalType": "address",
"name": "pool",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "contract IERC20",
"name": "token0",
"type": "address"
}, {
"internalType": "contract IERC20",
"name": "token1",
"type": "address"
}],
"name": "getPools",
"outputs": [{
"internalType": "address[]",
"name": "_tokenPools",
"type": "address[]"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "contract IERC20",
"name": "token0",
"type": "address"
}, {
"internalType": "contract IERC20",
"name": "token1",
"type": "address"
}],
"name": "getPoolsLength",
"outputs": [{
"internalType": "uint256",
"name": "",
"type": "uint256"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "contract IERC20",
"name": "",
"type": "address"
}, {
"internalType": "contract IERC20",
"name": "",
"type": "address"
}],
"name": "getUnamplifiedPool",
"outputs": [{
"internalType": "address",
"name": "",
"type": "address"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "contract IERC20",
"name": "token0",
"type": "address"
}, {
"internalType": "contract IERC20",
"name": "token1",
"type": "address"
}, {
"internalType": "address",
"name": "pool",
"type": "address"
}],
"name": "isPool",
"outputs": [{
"internalType": "bool",
"name": "",
"type": "bool"
}],
"stateMutability": "view",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "_feeTo",
"type": "address"
}, {
"internalType": "uint16",
"name": "_governmentFeeBps",
"type": "uint16"
}],
"name": "setFeeConfiguration",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}, {
"inputs": [{
"internalType": "address",
"name": "_feeToSetter",
"type": "address"
}],
"name": "setFeeToSetter",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}]
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.18",
networks: {
hardhat: {
forking: {
url: "https://mainnet.infura.io/v3/abc"
}
}
}
};
{
"name": "classic-swap",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"ethers": "^5.7.2",
"hardhat": "^2.14.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment