diff --git a/.github/workflows/vmTokens.yml b/.github/workflows/vmTokens.yml index ba50899..073af5b 100644 --- a/.github/workflows/vmTokens.yml +++ b/.github/workflows/vmTokens.yml @@ -5,9 +5,6 @@ on: schedule: - cron: '0 0 * * *' -env: - AGNOSTIC_API_KEY: ${{ secrets.AGNOSTIC_API_KEY }} - jobs: build: # make sure build/ci work properly runs-on: ubuntu-latest diff --git a/data/vmTokens.json b/data/vmTokens.json index 2f6f157..12a6a37 100644 --- a/data/vmTokens.json +++ b/data/vmTokens.json @@ -1 +1,450 @@ -[{"symbol":"Silo","name":"Silo Governance Token","decimals":18,"address":"0x6f80310ca7f2c654691d1383149fa1a57d8ab1f8","chainId":1},{"symbol":"BAL","name":"Balancer","decimals":18,"address":"0xba100000625a3754423978a60c9317c58a424e3d","chainId":1},{"symbol":"USDC","name":"USD Coin","decimals":6,"address":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","chainId":1},{"symbol":"INV","name":"Inverse DAO","decimals":18,"address":"0x41d5d79431a913c4ae7d69a668ecdfe5ff9dfb68","chainId":1},{"symbol":"IQ","name":"Everipedia IQ","decimals":18,"address":"0x579cea1889991f68acc35ff5c3dd0621ff29b0c9","chainId":1},{"symbol":"FXS","name":"Frax Share","decimals":18,"address":"0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0","chainId":1},{"symbol":"CRV","name":"Curve DAO Token","decimals":18,"address":"0xd533a949740bb3306d119cc777fa900ba034cd52","chainId":1},{"symbol":"OGV","name":"Origin DeFi Governance","decimals":18,"address":"0x9c354503c38481a7a7a51629142963f98ecc12d0","chainId":1},{"symbol":"WETH","name":"Wrapped Ether","decimals":18,"address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","chainId":1},{"symbol":"PYUSD","name":"PayPal USD","decimals":6,"address":"0x6c3ea9036406852006290770bedfcaba0e23a0e8","chainId":1},{"symbol":"ALCX","name":"Alchemix","decimals":18,"address":"0xdbdb4d16eda451d0503b854cf79d55697f90c8df","chainId":1},{"symbol":"GNO","name":"Gnosis Token","decimals":18,"address":"0x6810e776880c02933d47db1b9fc05908e5386b96","chainId":1},{"symbol":"SDT","name":"Stake DAO Token","decimals":18,"address":"0x73968b9a57c6e53d41345fd57a6e6ae27d6cdb2f","chainId":1},{"symbol":"MET","name":"Metronome2","decimals":18,"address":"0x2ebd53d035150f328bd754d6dc66b99b0edb89aa","chainId":1},{"symbol":"PENDLE","name":"Pendle","decimals":18,"address":"0x808507121b80c02388fad14726482e061b8da827","chainId":1},{"symbol":"RBN","name":"Ribbon","decimals":18,"address":"0x6123b0049f904d730db3c36a31167d9d4121fa6b","chainId":1},{"symbol":"BobrCRV","name":"CURVEBOBR","decimals":18,"address":"0x8f22779662ad253844013d8e99eccb4d80e31417","chainId":1},{"symbol":"BSN","name":"Blockswap Network","decimals":18,"address":"0x534d1f5e617e0f72a6b06a04aa599839af776a5e","chainId":1},{"symbol":"CVG","name":"Convergence","decimals":18,"address":"0x97effb790f2fbb701d88f89db4521348a2b77be8","chainId":1},{"symbol":"FIS","name":"StaFi","decimals":18,"address":"0xef3a930e1ffffacd2fc13434ac81bd278b0ecc8d","chainId":1},{"symbol":"DAI","name":"Dai Stablecoin","decimals":18,"address":"0x6b175474e89094c44da98b954eedeac495271d0f","chainId":1},{"symbol":"sdFXS","name":"Stake DAO FXS","decimals":18,"address":"0x402f878bdd1f5c66fdaf0fababcf74741b68ac36","chainId":1},{"symbol":"VSP","name":"VesperToken","decimals":18,"address":"0x1b40183efb4dd766f11bda7a7c3ad8982e998421","chainId":1},{"symbol":"LDO","name":"Lido DAO Token","decimals":18,"address":"0x5a98fcbea516cf06857215779fd812ca3bef1b32","chainId":1},{"symbol":"WACME","name":"Wrapped ACME","decimals":8,"address":"0xdf4ef6ee483953fe3b84abd08c6a060445c01170","chainId":1},{"symbol":"eCFX","name":"ethereum Conflux","decimals":18,"address":"0xa1f82e14bc09a1b42710df1a8a999b62f294e592","chainId":1},{"symbol":"VEUR","name":"VNX Euro","decimals":18,"address":"0x6ba75d640bebfe5da1197bb5a2aff3327789b5d3","chainId":1},{"symbol":"SPR","name":"Spiral","decimals":18,"address":"0x85b6acaba696b9e4247175274f8263f99b4b9180","chainId":1},{"symbol":"swETH","name":"swETH","decimals":18,"address":"0xf951e335afb289353dc249e82926178eac7ded78","chainId":1},{"symbol":"AXL","name":"Axelar","decimals":6,"address":"0x467719ad09025fcc6cf6f8311755809d45a5e5f3","chainId":1},{"symbol":"ANKR","name":"Ankr Network","decimals":18,"address":"0x8290333cef9e6d528dd5618fb97a76f268f3edd4","chainId":1},{"symbol":"pxETH","name":"Pirex Ether","decimals":18,"address":"0x04c154b66cb340f3ae24111cc767e0184ed00cc6","chainId":1},{"symbol":"QI","name":"QiDao","decimals":18,"address":"0x559b7bfc48a5274754b08819f75c5f27af53d53b","chainId":1},{"symbol":"SD","name":"Stader","decimals":18,"address":"0x30d20208d987713f46dfd34ef128bb16c404d10f","chainId":1},{"symbol":"VEC","name":"Vector","decimals":9,"address":"0x1bb9b64927e0c5e207c9db4093b3738eef5d8447","chainId":1},{"symbol":"ZETA","name":"Zeta","decimals":18,"address":"0xf091867ec603a6628ed83d274e835539d82e9cc8","chainId":1},{"symbol":"LUSD","name":"LUSD Stablecoin","decimals":18,"address":"0x5f98805a4e8be255a32880fdec7f6728c6568ba0","chainId":1},{"symbol":"FRAX","name":"Frax","decimals":18,"address":"0x853d955acef822db058eb8505911ed77f175b99e","chainId":1},{"symbol":"ZUN","name":"Zunami Token","decimals":18,"address":"0x6b5204b0be36771253cc38e88012e02b752f0f36","chainId":1},{"symbol":"CVX","name":"Convex Token","decimals":18,"address":"0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b","chainId":1},{"symbol":"OGN","name":"OriginToken","decimals":18,"address":"0x8207c1ffc5b6804f6024322ccf34f29c3541ae26","chainId":1},{"symbol":"ETHFI","name":"ether.fi governance token","decimals":18,"address":"0xfe0c30065b384f05761f15d0cc899d4f9f9cc0eb","chainId":1},{"symbol":"weETH","name":"Wrapped eETH","decimals":18,"address":"0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee","chainId":1},{"symbol":"ZUSD","name":"Z.com USD","decimals":6,"address":"0xc56c2b7e71b54d38aab6d52e94a04cbfa8f604fa","chainId":1},{"symbol":"USDT","name":"Tether USD","decimals":6,"address":"0xdac17f958d2ee523a2206206994597c13d831ec7","chainId":1},{"symbol":"SPELL","name":"Spell Token","decimals":18,"address":"0x090185f2135308bad17527004364ebcc2d37e5f6","chainId":1},{"symbol":"cvxPrisma","name":"Convex Prisma","decimals":18,"address":"0x34635280737b5bfe6c7dc2fc3065d60d66e78185","chainId":1},{"symbol":"BaoUSD","name":"BaoUSD","decimals":18,"address":"0x7945b0a6674b175695e5d1d08ae1e6f13744abb0","chainId":1},{"symbol":"LFT","name":"LendFlare DAO Token","decimals":18,"address":"0xb620be8a1949aa9532e6a3510132864ef9bc3f82","chainId":1}] \ No newline at end of file +[ + { + "symbol": "USDC", + "name": "USD Coin", + "decimals": 6, + "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", + "chainId": 1 + }, + { + "symbol": "GNO", + "name": "Gnosis Token", + "decimals": 18, + "address": "0x6810e776880C02933D47DB1b9fc05908e5386b96", + "chainId": 1 + }, + { + "symbol": "SDT", + "name": "Stake DAO Token", + "decimals": 18, + "address": "0x73968b9a57c6E53d41345FD57a6E6ae27d6CDB2F", + "chainId": 1 + }, + { + "symbol": "MET", + "name": "Metronome2", + "decimals": 18, + "address": "0x2Ebd53d035150f328bd754D6DC66B99B0eDB89aa", + "chainId": 1 + }, + { + "symbol": "FXS", + "name": "Frax Share", + "decimals": 18, + "address": "0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0", + "chainId": 1 + }, + { + "symbol": "CRV", + "name": "Curve DAO Token", + "decimals": 18, + "address": "0xD533a949740bb3306d119CC777fa900bA034cd52", + "chainId": 1 + }, + { + "symbol": "LDO", + "name": "Lido DAO Token", + "decimals": 18, + "address": "0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32", + "chainId": 1 + }, + { + "symbol": "WACME", + "name": "Wrapped ACME", + "decimals": 8, + "address": "0xDF4Ef6EE483953fE3B84ABd08C6A060445c01170", + "chainId": 1 + }, + { + "symbol": "FIS", + "name": "StaFi", + "decimals": 18, + "address": "0xef3A930e1FfFFAcd2fc13434aC81bD278B0ecC8d", + "chainId": 1 + }, + { + "symbol": "eCFX", + "name": "ethereum Conflux", + "decimals": 18, + "address": "0xA1f82E14bc09A1b42710dF1A8a999B62f294e592", + "chainId": 1 + }, + { + "symbol": "VEUR", + "name": "VNX Euro", + "decimals": 18, + "address": "0x6bA75D640bEbfe5dA1197bb5A2aff3327789b5d3", + "chainId": 1 + }, + { + "symbol": "OGV", + "name": "Origin DeFi Governance", + "decimals": 18, + "address": "0x9c354503C38481a7A7a51629142963F98eCC12D0", + "chainId": 1 + }, + { + "symbol": "ALCX", + "name": "Alchemix", + "decimals": 18, + "address": "0xdBdb4d16EdA451D0503b854CF79D55697F90c8DF", + "chainId": 1 + }, + { + "symbol": "SPR", + "name": "Spiral", + "decimals": 18, + "address": "0x85b6ACaBa696B9E4247175274F8263F99b4B9180", + "chainId": 1 + }, + { + "symbol": "AXL", + "name": "Axelar", + "decimals": 6, + "address": "0x467719aD09025FcC6cF6F8311755809d45a5E5f3", + "chainId": 1 + }, + { + "symbol": "QI", + "name": "QiDao", + "decimals": 18, + "address": "0x559b7bfC48a5274754b08819F75C5F27aF53D53b", + "chainId": 1 + }, + { + "symbol": "WETH", + "name": "Wrapped Ether", + "decimals": 18, + "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + "chainId": 1 + }, + { + "symbol": "ZUSD", + "name": "Z.com USD", + "decimals": 6, + "address": "0xc56c2b7e71B54d38Aab6d52E94a04Cbfa8F604fA", + "chainId": 1 + }, + { + "symbol": "BSN", + "name": "Blockswap Network", + "decimals": 18, + "address": "0x534D1F5E617e0f72A6b06a04Aa599839AF776A5e", + "chainId": 1 + }, + { + "symbol": "USDT", + "name": "Tether USD", + "decimals": 6, + "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", + "chainId": 1 + }, + { + "symbol": "SPELL", + "name": "Spell Token", + "decimals": 18, + "address": "0x090185f2135308BaD17527004364eBcC2D37e5F6", + "chainId": 1 + }, + { + "symbol": "FRAX", + "name": "Frax", + "decimals": 18, + "address": "0x853d955aCEf822Db058eb8505911ED77F175b99e", + "chainId": 1 + }, + { + "symbol": "LFT", + "name": "LendFlare DAO Token", + "decimals": 18, + "address": "0xB620Be8a1949AA9532e6a3510132864EF9Bc3F82", + "chainId": 1 + }, + { + "symbol": "SD", + "name": "Stader", + "decimals": 18, + "address": "0x30D20208d987713f46DFD34EF128Bb16C404D10f", + "chainId": 1 + }, + { + "symbol": "cvxPrisma", + "name": "Convex Prisma", + "decimals": 18, + "address": "0x34635280737b5BFe6c7DC2FC3065D60d66e78185", + "chainId": 1 + }, + { + "symbol": "weETH", + "name": "Wrapped eETH", + "decimals": 18, + "address": "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee", + "chainId": 1 + }, + { + "symbol": "PYUSD", + "name": "PayPal USD", + "decimals": 6, + "address": "0x6c3ea9036406852006290770BEdFcAbA0e23A0e8", + "chainId": 1 + }, + { + "symbol": "INV", + "name": "Inverse DAO", + "decimals": 18, + "address": "0x41D5D79431A913C4aE7d69a668ecdfE5fF9DFB68", + "chainId": 1 + }, + { + "symbol": "BobrCRV", + "name": "CURVEBOBR", + "decimals": 18, + "address": "0x8F22779662Ad253844013D8E99EcCB4d80e31417", + "chainId": 1 + }, + { + "symbol": "CVG", + "name": "Convergence", + "decimals": 18, + "address": "0x97efFB790f2fbB701D88f89DB4521348A2B77be8", + "chainId": 1 + }, + { + "symbol": "swETH", + "name": "swETH", + "decimals": 18, + "address": "0xf951E335afb289353dc249e82926178EaC7DEd78", + "chainId": 1 + }, + { + "symbol": "pxETH", + "name": "Pirex Ether", + "decimals": 18, + "address": "0x04C154b66CB340F3Ae24111CC767e0184Ed00Cc6", + "chainId": 1 + }, + { + "symbol": "VEC", + "name": "Vector", + "decimals": 9, + "address": "0x1BB9b64927e0C5e207C9DB4093b3738Eef5D8447", + "chainId": 1 + }, + { + "symbol": "ZETA", + "name": "Zeta", + "decimals": 18, + "address": "0xf091867EC603A6628eD83D274E835539D82e9cc8", + "chainId": 1 + }, + { + "symbol": "ETHFI", + "name": "ether.fi governance token", + "decimals": 18, + "address": "0xFe0c30065B384F05761f15d0CC899D4F9F9Cc0eB", + "chainId": 1 + }, + { + "symbol": "OGN", + "name": "OriginToken", + "decimals": 18, + "address": "0x8207c1FfC5B6804F6024322CcF34F29c3541Ae26", + "chainId": 1 + }, + { + "symbol": "ZUN", + "name": "Zunami Token", + "decimals": 18, + "address": "0x6b5204B0Be36771253Cc38e88012E02B752f0f36", + "chainId": 1 + }, + { + "symbol": "CVX", + "name": "Convex Token", + "decimals": 18, + "address": "0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B", + "chainId": 1 + }, + { + "symbol": "Silo", + "name": "Silo Governance Token", + "decimals": 18, + "address": "0x6f80310CA7F2C654691D1383149Fa1A57d8AB1f8", + "chainId": 1 + }, + { + "symbol": "ANKR", + "name": "Ankr Network", + "decimals": 18, + "address": "0x8290333ceF9e6D528dD5618Fb97a76f268f3EDD4", + "chainId": 1 + }, + { + "symbol": "BAL", + "name": "Balancer", + "decimals": 18, + "address": "0xba100000625a3754423978a60c9317c58a424e3D", + "chainId": 1 + }, + { + "symbol": "BaoUSD", + "name": "BaoUSD", + "decimals": 18, + "address": "0x7945b0A6674b175695e5d1D08aE1e6F13744Abb0", + "chainId": 1 + }, + { + "symbol": "LUSD", + "name": "LUSD Stablecoin", + "decimals": 18, + "address": "0x5f98805A4E8be255a32880FDeC7F6728C6568bA0", + "chainId": 1 + }, + { + "symbol": "PENDLE", + "name": "Pendle", + "decimals": 18, + "address": "0x808507121B80c02388fAd14726482e061B8da827", + "chainId": 1 + }, + { + "symbol": "RBN", + "name": "Ribbon", + "decimals": 18, + "address": "0x6123B0049F904d730dB3C36a31167D9d4121fA6B", + "chainId": 1 + }, + { + "symbol": "DAI", + "name": "Dai Stablecoin", + "decimals": 18, + "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F", + "chainId": 1 + }, + { + "symbol": "sdFXS", + "name": "Stake DAO FXS", + "decimals": 18, + "address": "0x402F878BDd1f5C66FdAF0fabaBcF74741B68ac36", + "chainId": 1 + }, + { + "symbol": "VSP", + "name": "VesperToken", + "decimals": 18, + "address": "0x1b40183EFB4Dd766f11bDa7A7c3AD8982e998421", + "chainId": 1 + }, + { + "symbol": "IQ", + "name": "Everipedia IQ", + "decimals": 18, + "address": "0x579CEa1889991f68aCc35Ff5c3dd0621fF29b0C9", + "chainId": 1 + }, + { + "symbol": "sdCAKE", + "name": "Stake DAO CAKE", + "decimals": 18, + "address": "0x6a1c1447F97B27dA23dC52802F5f1435b5aC821A", + "chainId": 56 + }, + { + "symbol": "Cake", + "name": "PancakeSwap Token", + "decimals": 18, + "address": "0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82", + "chainId": 56 + }, + { + "symbol": "PEPE", + "name": "Pepe", + "decimals": 18, + "address": "0x25d887Ce7a35172C62FeBFD67a1856F20FaEbB00", + "chainId": 56 + }, + { + "symbol": "INSP", + "name": "INSPECT", + "decimals": 18, + "address": "0x8D279274789CceC8af94a430A5996eAaCE9609A9", + "chainId": 56 + }, + { + "symbol": "XCAD", + "name": "XCAD Token", + "decimals": 18, + "address": "0xa026Ad2ceDa16Ca5FC28fd3C72f99e2C332c8a26", + "chainId": 56 + }, + { + "symbol": "BUSD", + "name": "BUSD Token", + "decimals": 18, + "address": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56", + "chainId": 56 + }, + { + "symbol": "USDT", + "name": "Tether USD", + "decimals": 18, + "address": "0x55d398326f99059fF775485246999027B3197955", + "chainId": 56 + }, + { + "symbol": "OSAK", + "name": "Osaka Protocol", + "decimals": 18, + "address": "0x11cd72f7A4B699c67f225ca8aBb20bC9F8DB90c7", + "chainId": 56 + }, + { + "symbol": "OVN", + "name": "OVN", + "decimals": 18, + "address": "0x259B30C916e440FB79747cD559207FfdaBBae057", + "chainId": 56 + }, + { + "symbol": "AITECH", + "name": "AITECH", + "decimals": 18, + "address": "0x2D060Ef4d6BF7f9e5edDe373Ab735513c0e4F944", + "chainId": 56 + }, + { + "symbol": "USDC", + "name": "USD Coin", + "decimals": 18, + "address": "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d", + "chainId": 56 + }, + { + "symbol": "PSTAKE", + "name": "pStake Finance", + "decimals": 18, + "address": "0x4C882ec256823eE773B25b414d36F92ef58a7c0C", + "chainId": 56 + }, + { + "symbol": "WBNB", + "name": "Wrapped BNB", + "decimals": 18, + "address": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", + "chainId": 56 + }, + { + "symbol": "DNT", + "name": "DemoNewToken", + "decimals": 18, + "address": "0xE9C7047FF6F37301316498e0e61C62F53F6Fe169", + "chainId": 56 + }, + { + "symbol": "USDV", + "name": "USDV", + "decimals": 6, + "address": "0x323665443CEf804A3b5206103304BD4872EA4253", + "chainId": 56 + } +] \ No newline at end of file diff --git a/src/utils/agnosticUtils.ts b/src/utils/agnosticUtils.ts deleted file mode 100644 index 3e37a9f..0000000 --- a/src/utils/agnosticUtils.ts +++ /dev/null @@ -1,20 +0,0 @@ -import axios from "axios"; - -const AGNOSTIC_ENDPOINT = "https://proxy.eu-02.agnostic.engineering/query"; - -export const agnosticFetch = async (query: string): Promise => { - try { - const response = await axios.post(AGNOSTIC_ENDPOINT, query, { - headers: { - 'Authorization': `${process.env.AGNOSTIC_API_KEY}`, - "Cache-Control": "max-age=300" - } - }); - - return response.data.rows; - } - catch (e) { - //console.error(e); - return []; - } -} \ No newline at end of file diff --git a/src/vmTokens.ts b/src/vmTokens.ts index 1471649..3f954db 100644 --- a/src/vmTokens.ts +++ b/src/vmTokens.ts @@ -1,110 +1,162 @@ import fs from "fs"; import dotenv from "dotenv"; -import { agnosticFetch } from "./utils/agnosticUtils"; import { createPublicClient, http } from 'viem' -import { mainnet } from 'viem/chains' +import { bsc, mainnet } from 'viem/chains' import { parseAbi } from 'viem' dotenv.config(); -const client = createPublicClient({ - chain: mainnet, - transport: http("https://eth.llamarpc.com"), - batch: { - multicall: true - } -}); - const abi = parseAbi([ 'function symbol() view returns (string)', 'function name() view returns (string)', 'function decimals() view returns (uint8)', + 'function nextID() view returns (uint256)', + 'function bounties(uint256 i) view returns ((address,address,address,uint8,uint256,uint256,uint256))', +]); + +const abiBsc = parseAbi([ + 'function bounties(uint256 i) view returns ((address,uint256,address,address,uint8,uint256,uint256,uint256))', ]); -const CONTRACTS = [ - "0x0000000895cB182E6f983eb4D8b4E0Aa0B31Ae4c", - "0x00000004E4FB0C3017b543EF66cC8A89F5dE74Ff", - "0x0000000446b28e4c90dbf08ead10f3904eb27606", - "0x00000008eF298e2B6dc47E88D72eeB1Fc2b1CA7f", - "0x000000060e56DEfD94110C1a9497579AD7F5b254", - "0x000000071a273073c824E2a8B0192963e0eEA68b" -]; +const CONTRACTS_PER_CHAIN_ID = [ + { + chain: mainnet, + rpc: "https://eth.drpc.org", + contracts: [ + "0x0000000895cB182E6f983eb4D8b4E0Aa0B31Ae4c", + "0x00000004E4FB0C3017b543EF66cC8A89F5dE74Ff", + "0x0000000446b28e4c90dbf08ead10f3904eb27606", + "0x00000008eF298e2B6dc47E88D72eeB1Fc2b1CA7f", + "0x000000060e56DEfD94110C1a9497579AD7F5b254", + "0x000000071a273073c824E2a8B0192963e0eEA68b" + ] + }, + { + chain: bsc, + rpc: "https://bsc-rpc.publicnode.com", + contracts: [ + "0x0fD2d686C02D686c65804ff45E4e570386E3595f", + "0x62c5D779f5e56F6BC7578066546527fEE590032c", + "0xa77889DA8fEDC7FD65D37Af60d0744B954E3bAf0" + ] + } +] + const main = async () => { - const rewardTokensResp = (await agnosticFetch(` - with - ( - ${CONTRACTS.map((contract: string) => "'" + contract + "'")} - ) as bribe_contracts - select - distinct(input_3_value_address as rewardToken) - from evm_events_ethereum_mainnet - where - address IN bribe_contracts and - signature = 'BountyCreated(uint256,address,address,address,uint8,uint256,uint256,uint256,bool)' - `)) - .flat(); - - const contracts = rewardTokensResp.map((rewardToken: string) => { - return [ - { - address: rewardToken, - abi, - functionName: "symbol" - }, - { - address: rewardToken, - abi, - functionName: "name" - }, - { - address: rewardToken, - abi, - functionName: "decimals" + let allTokenRewardsData: any[] = []; + + for (const contractPerChainIdData of CONTRACTS_PER_CHAIN_ID) { + const client = createPublicClient({ + chain: contractPerChainIdData.chain, + transport: http(contractPerChainIdData.rpc), + batch: { + multicall: true } - ] - }) - .flat(); - - const results = await client.multicall({ contracts }); - const data = rewardTokensResp.map((address: string) => { - let symbol = ""; - let name = ""; - let decimals = 0; - - let data = results.shift(); - if (data && data.status === 'failure') { - return null; - } - symbol = data?.result as string; + }); - data = results.shift(); - if (data && data.status === 'failure') { - return null; - } - name = data?.result as string; + const isBsc = contractPerChainIdData.chain === bsc; + const tokenRewardAddresses: Record = {}; - data = results.shift(); - if (data && data.status === 'failure') { - return null; - } - decimals = data?.result as number; - - return { - symbol, - name, - decimals, - address, - chainId: 1, + for (const contract of contractPerChainIdData.contracts) { + const nextId = await client.readContract({ + address: contract as `0x${string}`, + abi: abi, + functionName: 'nextID', + }); + + const calls: any[] = []; + for (let i = 0; i < Number(nextId); i++) { + calls.push({ + address: contract as `0x${string}`, + abi: isBsc ? abiBsc : abi, + functionName: 'bounties', + args: [BigInt(i)] + }); + } + + const results = await client.multicall({ contracts: calls }); + + for (const result of results) { + if (result.status === "failure") { + continue; + } + + let tokenRewardAddress = ""; + const bounty = result.result as any; + if (isBsc) { + tokenRewardAddress = bounty[3]; + } else { + tokenRewardAddress = bounty[2]; + } + + if (tokenRewardAddress.length > 0) { + tokenRewardAddresses[tokenRewardAddress] = true; + } + } } - }) - .filter((res: any) => res !== null); - if (data.length !== rewardTokensResp.length) { - return; - } + const tokenRewards = Object.keys(tokenRewardAddresses); + if (tokenRewards.length > 0) { + const contracts = tokenRewards.map((rewardToken: string) => { + return [ + { + address: rewardToken, + abi, + functionName: "symbol" + }, + { + address: rewardToken, + abi, + functionName: "name" + }, + { + address: rewardToken, + abi, + functionName: "decimals" + } + ] + }) + .flat() as any[]; - fs.writeFileSync("./data/vmTokens.json", JSON.stringify(data)); + const results = await client.multicall({ contracts }); + const tokenRewardsData = tokenRewards.map((address: string) => { + let symbol = ""; + let name = ""; + let decimals = 0; + + let data = results.shift(); + if (data && data.status === 'failure') { + return null; + } + symbol = data?.result as string; + + data = results.shift(); + if (data && data.status === 'failure') { + return null; + } + name = data?.result as string; + + data = results.shift(); + if (data && data.status === 'failure') { + return null; + } + decimals = data?.result as number; + + return { + symbol, + name, + decimals, + address, + chainId: contractPerChainIdData.chain.id, + } + }) + .filter((res: any) => res !== null); + + allTokenRewardsData = allTokenRewardsData.concat(tokenRewardsData); + } + } + fs.writeFileSync("./data/vmTokens.json", JSON.stringify(allTokenRewardsData)); }; main().catch((error) => {