Skip to content

Commit

Permalink
zksync era support (#238)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
matteenm and matteenm authored Jul 11, 2024
1 parent 99a325a commit 1394f59
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
6 changes: 6 additions & 0 deletions networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@
"address": "0x1F98431c8aD98523631AE4a59f267346ea31F984",
"startBlock": 0
}
},
"zksync-era": {
"Factory": {
"address": "0x8FdA5a7a8dCA67BBcDd10F02Fa0649A937215422",
"startBlock": 12637075
}
}
}
32 changes: 32 additions & 0 deletions src/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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')
}
Expand Down
8 changes: 4 additions & 4 deletions subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,7 +39,7 @@ dataSources:
templates:
- kind: ethereum/contract
name: Pool
network: base
network: mainnet
source:
abi: Pool
mapping:
Expand Down

0 comments on commit 1394f59

Please sign in to comment.