Last active
July 14, 2025 12:44
-
-
Save zengzengzenghuy/78535c53ac406e808e34209392a3203f to your computer and use it in GitHub Desktop.
Read token limits on Omnibridge Gnosis Chain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"token":[{ | |
| "bridge_type": "omni", | |
| "foreign_address": "0x6810e776880C02933D47DB1b9fc05908e5386b96", | |
| "origin_chain_id": "1", | |
| "address": "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb", | |
| "decimals": "18", | |
| "symbol": "GNO" | |
| }, | |
| { | |
| "bridge_type": "omni", | |
| "foreign_address": "0xEF826da5AaDAE742ce32cE0C460F30Ab281e51a2", | |
| "origin_chain_id": "1", | |
| "address": "0xD7cd100056B477C08B419a28E976D8Ade354251a", | |
| "decimals": "8", | |
| "symbol": "WBTC" | |
| }, | |
| { | |
| "bridge_type": "omni", | |
| "foreign_address": "0xb1A7F8b3AdA1Cbd7752c1306725b07D2F8B4e726", | |
| "origin_chain_id": "1", | |
| "address": "0x9ba1E2F45aC86b88926a9E6F43120f42BB7eDe40", | |
| "decimals": "18", | |
| "symbol": "WETH" | |
| }, | |
| { | |
| "bridge_type": "omni", | |
| "foreign_address": "0x5aFE3855358E112B5647B952709E6165e1c1eEEe", | |
| "origin_chain_id": "1", | |
| "address": "0x4d18815D14fe5c3304e87B3FA18318baa5c23820", | |
| "decimals": "18", | |
| "symbol": "SAFE" | |
| }, | |
| { | |
| "bridge_type": "omni", | |
| "foreign_address": "0xDEf1CA1fb7FBcDC777520aa7f396b4E015F497aB", | |
| "origin_chain_id": "1", | |
| "address": "0x177127622c4A00F3d409B75571e12cB3c8973d3c", | |
| "decimals": "18", | |
| "symbol": "COW" | |
| }, | |
| { | |
| "bridge_type": "omni", | |
| "foreign_address": "0xF5581dFeFD8Fb0e4aeC526bE659CFaB1f8c781dA", | |
| "origin_chain_id": "1", | |
| "address": "0xD057604A14982FE8D88c5fC25Aac3267eA142a08", | |
| "decimals": "18", | |
| "symbol": "HOPR" | |
| }, | |
| { | |
| "bridge_type": "omni", | |
| "foreign_address": "0xdAC17F958D2ee523a2206206994597C13D831ec7", | |
| "origin_chain_id": "1", | |
| "address": "0x4ECaBa5870353805a9F068101A40E0f32ed605C6", | |
| "decimals": "6", | |
| "symbol": "USDT" | |
| }, | |
| { | |
| "bridge_type": "omni", | |
| "foreign_address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", | |
| "origin_chain_id": "1", | |
| "address": "0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83", | |
| "decimals": "6", | |
| "symbol": "USDC" | |
| }, | |
| { | |
| "bridge_type": "omni", | |
| "foreign_address": "0x0001A500A6B18995B03f44bb040A5fFc28E45CB0", | |
| "origin_chain_id": "1", | |
| "address": "0xcE11e14225575945b8E6Dc0D4F2dD4C570f79d9f", | |
| "decimals": "18", | |
| "symbol": "OLAS" | |
| } | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createPublicClient, http, parseAbiItem } from "viem"; | |
| import { mainnet, gnosis } from "viem/chains"; | |
| import { readFileSync, writeFileSync } from "fs"; | |
| import { fileURLToPath } from "url"; | |
| import { dirname, join } from "path"; | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = dirname(__filename); | |
| // Step 1: Initialize publicClient for Ethereum and Gnosis Chain | |
| const ethereumClient = createPublicClient({ | |
| chain: mainnet, | |
| transport: http(), | |
| }); | |
| const gnosisClient = createPublicClient({ | |
| chain: gnosis, | |
| transport: http(), | |
| }); | |
| // Step 2: Read tokens from bridge_token.json | |
| const tokensData = JSON.parse( | |
| readFileSync(join(__dirname, "bridged_token.json"), "utf8") | |
| ); | |
| const tokens = tokensData.token; | |
| // Contract addresses | |
| const ETHEREUM_CONTRACT = "0x88ad09518695c6c3712AC10a214bE5109a655671"; | |
| const GNOSIS_CONTRACT = "0xf6A78083ca3e2a662D6dd1703c939c8aCE2e268d"; | |
| // Function ABIs | |
| const minPerTxAbi = parseAbiItem( | |
| "function minPerTx(address token) view returns (uint256)" | |
| ); | |
| const maxPerTxAbi = parseAbiItem( | |
| "function maxPerTx(address token) view returns (uint256)" | |
| ); | |
| const dailyLimitAbi = parseAbiItem( | |
| "function dailyLimit(address token) view returns (uint256)" | |
| ); | |
| const executionDailyLimitAbi = parseAbiItem( | |
| "function executionDailyLimit(address token) view returns (uint256)" | |
| ); | |
| // Step 3: Read contract functions for each token | |
| async function readTokenLimits() { | |
| const results = []; | |
| for (const token of tokens) { | |
| try { | |
| const [ethMinPerTx, ethMaxPerTx, ethDailyLimit, ethExecutionDailyLimit] = | |
| await Promise.all([ | |
| ethereumClient.readContract({ | |
| address: ETHEREUM_CONTRACT, | |
| abi: [minPerTxAbi], | |
| functionName: "minPerTx", | |
| args: [token.foreign_address], | |
| }), | |
| ethereumClient.readContract({ | |
| address: ETHEREUM_CONTRACT, | |
| abi: [maxPerTxAbi], | |
| functionName: "maxPerTx", | |
| args: [token.foreign_address], | |
| }), | |
| ethereumClient.readContract({ | |
| address: ETHEREUM_CONTRACT, | |
| abi: [dailyLimitAbi], | |
| functionName: "dailyLimit", | |
| args: [token.foreign_address], | |
| }), | |
| ethereumClient.readContract({ | |
| address: ETHEREUM_CONTRACT, | |
| abi: [executionDailyLimitAbi], | |
| functionName: "executionDailyLimit", | |
| args: [token.foreign_address], | |
| }), | |
| ]); | |
| const [ | |
| gnosisMinPerTx, | |
| gnosisMaxPerTx, | |
| gnosisDailyLimit, | |
| gnosisExecutionDailyLimit, | |
| ] = await Promise.all([ | |
| gnosisClient.readContract({ | |
| address: GNOSIS_CONTRACT, | |
| abi: [minPerTxAbi], | |
| functionName: "minPerTx", | |
| args: [token.address], | |
| }), | |
| gnosisClient.readContract({ | |
| address: GNOSIS_CONTRACT, | |
| abi: [maxPerTxAbi], | |
| functionName: "maxPerTx", | |
| args: [token.address], | |
| }), | |
| gnosisClient.readContract({ | |
| address: GNOSIS_CONTRACT, | |
| abi: [dailyLimitAbi], | |
| functionName: "dailyLimit", | |
| args: [token.address], | |
| }), | |
| gnosisClient.readContract({ | |
| address: GNOSIS_CONTRACT, | |
| abi: [executionDailyLimitAbi], | |
| functionName: "executionDailyLimit", | |
| args: [token.address], | |
| }), | |
| ]); | |
| const decimals = BigInt(10 ** parseInt(token.decimals)); | |
| results.push({ | |
| symbol: token.symbol, | |
| ethereum_address: token.foreign_address, | |
| gnosis_address: token.address, | |
| decimals: token.decimals, | |
| Ethereum: { | |
| minPerTx: Number(ethMinPerTx / decimals), | |
| maxPerTx: Number(ethMaxPerTx / decimals), | |
| dailyLimit: Number(ethDailyLimit / decimals), | |
| executionDailyLimit: Number(ethExecutionDailyLimit / decimals), | |
| }, | |
| Gnosis: { | |
| minPerTx: Number(gnosisMinPerTx / decimals), | |
| maxPerTx: Number(gnosisMaxPerTx / decimals), | |
| dailyLimit: Number(gnosisDailyLimit / decimals), | |
| executionDailyLimit: Number(gnosisExecutionDailyLimit / decimals), | |
| }, | |
| }); | |
| } catch (error) { | |
| console.error(`Error reading limits for token ${token.symbol}:`, error); | |
| } | |
| } | |
| return results; | |
| } | |
| // Execute and save results to JSON file | |
| readTokenLimits() | |
| .then((results) => { | |
| const outputPath = join(__dirname, "token_limit.json"); | |
| writeFileSync( | |
| outputPath, | |
| JSON.stringify( | |
| results, | |
| (key, value) => (typeof value === "bigint" ? value.toString() : value), | |
| 2 | |
| ) | |
| ); | |
| console.log(`Token limits saved to ${outputPath}`); | |
| }) | |
| .catch((error) => { | |
| console.error("Error reading token limits:", error); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Data source: https://github.com/gnosischain/bridge-monitor/blob/90144a3e4a0adfa998b89f48a259d664de97d359/app/src/constants/bridged_tokens.json