From 1394f592aa84970ab5c4e30e2f7d0b5a02c57b89 Mon Sep 17 00:00:00 2001 From: matteen Date: Thu, 11 Jul 2024 09:49:43 -0400 Subject: [PATCH] zksync era support (#238) * zksync support * fix(lint): auto-fix [ci] * fix usdt address * fix(lint): auto-fix [ci] * update yaml file * keep yaml file on mainnet * override for usdc.e --------- Co-authored-by: matteenm --- networks.json | 6 ++++++ src/utils/chains.ts | 32 ++++++++++++++++++++++++++++++++ subgraph.yaml | 8 ++++---- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/networks.json b/networks.json index 68d113ad..b0238833 100644 --- a/networks.json +++ b/networks.json @@ -52,5 +52,11 @@ "address": "0x1F98431c8aD98523631AE4a59f267346ea31F984", "startBlock": 0 } + }, + "zksync-era": { + "Factory": { + "address": "0x8FdA5a7a8dCA67BBcDd10F02Fa0649A937215422", + "startBlock": 12637075 + } } } diff --git a/src/utils/chains.ts b/src/utils/chains.ts index 205f2655..6f9123cc 100644 --- a/src/utils/chains.ts +++ b/src/utils/chains.ts @@ -13,6 +13,7 @@ export enum ChainId { MAINNET = 1, MATIC = 137, OPTIMISM = 10, + ZKSYNC_ERA = 324, } // subgraph does not support string enums, hence these constants @@ -25,6 +26,7 @@ const CELO_NETWORK_NAME = 'celo' const MAINNET_NETWORK_NAME = 'mainnet' const MATIC_NETWORK_NAME = 'matic' const OPTIMISM_NETWORK_NAME = 'optimism' +const ZKSYNC_ERA_NETWORK_NAME = 'zksync-era' // Note: All token and pool addresses should be lowercased! export class SubgraphConfig { @@ -358,6 +360,36 @@ export function getSubgraphConfig(): SubgraphConfig { ], poolMappings: OPTIMISM_POOL_MAPPINGS, } + } else if (selectedNetwork == ZKSYNC_ERA_NETWORK_NAME) { + return { + factoryAddress: '0x8fda5a7a8dca67bbcdd10f02fa0649a937215422', + stablecoinWrappedNativePoolAddress: '0x3e3dd517fec2e70eddba2a626422a4ba286e8c38', // USDC.e/WETH 0.05% pool + stablecoinIsToken0: true, + wrappedNativeAddress: '0x5aea5775959fbc2557cc8789bc1bf90a239d9a91', // WETH + minimumNativeLocked: BigDecimal.fromString('1'), + stablecoinAddresses: [ + '0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4', // USDC.e + '0x493257fd37edb34451f62edf8d2a0c418852ba4c', // USDT + '0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4', // USDC + ], + whitelistTokens: [ + '0x5aea5775959fbc2557cc8789bc1bf90a239d9a91', // WETH + '0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4', // USDC.e + '0x493257fd37edb34451f62edf8d2a0c418852ba4c', // USDT + '0x1d17cbcf0d6d143135ae902365d2e5e2a16538d4', // USDC + '0x5a7d6b2f92c77fad6ccabd7ee0624e64907eaf3e', // ZK + ], + tokenOverrides: [ + { + address: Address.fromString('0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4'), + symbol: 'USDC.e', + name: 'Bridged USDC (zkSync)', + decimals: BigInt.fromI32(6), + }, + ], + poolsToSkip: [], + poolMappings: [], + } } else { throw new Error('Unsupported Network') } diff --git a/subgraph.yaml b/subgraph.yaml index d4024c55..395f99b4 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -9,11 +9,11 @@ features: dataSources: - kind: ethereum/contract name: Factory - network: base + network: mainnet source: + address: '0x1F98431c8aD98523631AE4a59f267346ea31F984' abi: Factory - address: "0x33128a8fC17869897dcE68Ed026d694621f6FDfD" - startBlock: 2009445 + startBlock: 12369621 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -39,7 +39,7 @@ dataSources: templates: - kind: ethereum/contract name: Pool - network: base + network: mainnet source: abi: Pool mapping: