Skip to content

Commit

Permalink
feat: Add Zerion config generator (#4870)
Browse files Browse the repository at this point in the history
### Description
Adds Zero config generators for USDB, WBTC, BNB, Pol

### Drive-by changes
- Conditional for address zero check

### Backward compatibility
Yes

### Testing
Manual
  • Loading branch information
ltyu authored Nov 19, 2024
1 parent 23a2679 commit 250853e
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/metal-clocks-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hyperlane-xyz/infra': minor
'@hyperlane-xyz/sdk': minor
---

Add Zerion deployments: WBTC, POL, BNB, USDB
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ethers } from 'ethers';

import {
ChainMap,
RouterConfig,
TokenRouterConfig,
TokenType,
} from '@hyperlane-xyz/sdk';

import { tokens } from '../../../../../src/config/warp.js';

export const getBlastZeroNetworkUSDBWarpConfig = async (
routerConfig: ChainMap<RouterConfig>,
): Promise<ChainMap<TokenRouterConfig>> => {
const blast: TokenRouterConfig = {
...routerConfig.blast,
type: TokenType.collateral,
token: tokens.blast.usdb,
interchainSecurityModule: ethers.constants.AddressZero,
};

const zeronetwork: TokenRouterConfig = {
...routerConfig.zeronetwork,
type: TokenType.synthetic,
interchainSecurityModule: ethers.constants.AddressZero,
};
return {
blast,
zeronetwork,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ethers } from 'ethers';

import {
ChainMap,
RouterConfig,
TokenRouterConfig,
TokenType,
} from '@hyperlane-xyz/sdk';

export const getBscZeroNetworkBNBWarpConfig = async (
routerConfig: ChainMap<RouterConfig>,
): Promise<ChainMap<TokenRouterConfig>> => {
const bsc: TokenRouterConfig = {
...routerConfig.bsc,
type: TokenType.native,
interchainSecurityModule: ethers.constants.AddressZero,
};

const zeronetwork: TokenRouterConfig = {
...routerConfig.zeronetwork,
type: TokenType.synthetic,
interchainSecurityModule: ethers.constants.AddressZero,
};
return {
bsc,
zeronetwork,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { ethers } from 'ethers';

import {
ChainMap,
RouterConfig,
TokenRouterConfig,
TokenType,
} from '@hyperlane-xyz/sdk';
import { Address } from '@hyperlane-xyz/utils';

const collateralAddresses: ChainMap<Address> = {
ethereum: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
mode: '0xcDd475325D6F564d27247D1DddBb0DAc6fA0a5CF',
scroll: '0x3C1BCa5a656e69edCD0D4E36BEbb3FcDAcA60Cf1',
};

export const getEthereumModeScrollZeronetworkWBTCConfig = async (
routerConfig: ChainMap<RouterConfig>,
): Promise<ChainMap<TokenRouterConfig>> => {
const ethereum: TokenRouterConfig = {
...routerConfig.ethereum,
type: TokenType.collateral,
token: collateralAddresses.ethereum,
interchainSecurityModule: ethers.constants.AddressZero,
};

const mode: TokenRouterConfig = {
...routerConfig.mode,
type: TokenType.collateral,
token: collateralAddresses.mode,
interchainSecurityModule: ethers.constants.AddressZero,
};

const scroll: TokenRouterConfig = {
...routerConfig.scroll,
type: TokenType.collateral,
token: collateralAddresses.scroll,
interchainSecurityModule: ethers.constants.AddressZero,
};

const zeronetwork: TokenRouterConfig = {
...routerConfig.zeronetwork,
type: TokenType.synthetic,
interchainSecurityModule: ethers.constants.AddressZero,
};

return {
ethereum,
mode,
scroll,
zeronetwork,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ethers } from 'ethers';

import {
ChainMap,
RouterConfig,
TokenRouterConfig,
TokenType,
} from '@hyperlane-xyz/sdk';

export const getPolygonZeroNetworkPolWarpConfig = async (
routerConfig: ChainMap<RouterConfig>,
): Promise<ChainMap<TokenRouterConfig>> => {
const polygon: TokenRouterConfig = {
...routerConfig.polygon,
type: TokenType.native,
interchainSecurityModule: ethers.constants.AddressZero,
};

const zeronetwork: TokenRouterConfig = {
...routerConfig.zeronetwork,
type: TokenType.synthetic,
interchainSecurityModule: ethers.constants.AddressZero,
};
return {
polygon,
zeronetwork,
};
};
4 changes: 4 additions & 0 deletions typescript/infra/config/environments/mainnet3/warp/warpIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export enum WarpRouteIds {
ArbitrumEthereumZircuitAMPHRETH = 'AMPHRETH/arbitrum-ethereum-zircuit',
ArbitrumNeutronEclip = 'ECLIP/arbitrum-neutron',
ArbitrumNeutronTIA = 'TIA/arbitrum-neutron',
BlastZeroNetworkUSDB = 'USDB/blast-zeronetwork',
BscZeroNetworkBNB = 'BNB/bsc-zeronetwork',
EclipseEthereumSolanaUSDC = 'USDC/eclipsemainnet-ethereum-solanamainnet',
EclipseEthereumSolanaUSDT = 'USDT/eclipsemainnet-ethereum-solanamainnet',
EclipseEthereumTETH = 'tETH/eclipsemainnet-ethereum',
Expand All @@ -23,6 +25,8 @@ export enum WarpRouteIds {
EthereumVictionUSDT = 'USDT/ethereum-viction',
EthereumZircuitPZETH = 'PZETH/ethereum-zircuit',
EthereumBscLumiaLUMIA = 'LUMIA/bsc-ethereum-lumia',
EthereumModeScrollZeroNetworkWBTC = 'WBTC/ethereum-mode-scroll-zeronetwork',
InevmInjectiveINJ = 'INJ/inevm-injective',
MantapacificNeutronTIA = 'TIA/mantapacific-neutron',
PolygonZeroNetworkPOL = 'POL/polygon-zeronetwork',
}
9 changes: 9 additions & 0 deletions typescript/infra/config/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { getAncient8EthereumUSDCWarpConfig } from './environments/mainnet3/warp/
import { getArbitrumEthereumZircuitAmphrETHWarpConfig } from './environments/mainnet3/warp/configGetters/getArbitrumEthereumZircuitAmphrETHWarpConfig.js';
import { getArbitrumNeutronEclipWarpConfig } from './environments/mainnet3/warp/configGetters/getArbitrumNeutronEclipWarpConfig.js';
import { getArbitrumNeutronTiaWarpConfig } from './environments/mainnet3/warp/configGetters/getArbitrumNeutronTiaWarpConfig.js';
import { getBlastZeroNetworkUSDBWarpConfig } from './environments/mainnet3/warp/configGetters/getBlastZeroNetworkUSDBWarpConfig.js';
import { getBscZeroNetworkBNBWarpConfig } from './environments/mainnet3/warp/configGetters/getBscZeroNetworkBNBConfig.js';
import { getEclipseEthereumSolanaUSDTWarpConfig } from './environments/mainnet3/warp/configGetters/getEclipseEthereumSolanaUSDTWarpConfig.js';
import { getEclipseEthereumWBTCWarpConfig } from './environments/mainnet3/warp/configGetters/getEclipseEthereumWBTCWarpConfig.js';
import { getEclipseEthereumWeEthsWarpConfig } from './environments/mainnet3/warp/configGetters/getEclipseEthereumWeETHsWarpConfig.js';
Expand All @@ -23,12 +25,14 @@ import { getEclipseStrideStTiaWarpConfig } from './environments/mainnet3/warp/co
import { getEthereumBscLUMIAWarpConfig } from './environments/mainnet3/warp/configGetters/getEthereumBscLumiaLUMIAWarpConfig.js';
import { getEthereumInevmUSDCWarpConfig } from './environments/mainnet3/warp/configGetters/getEthereumInevmUSDCWarpConfig.js';
import { getEthereumInevmUSDTWarpConfig } from './environments/mainnet3/warp/configGetters/getEthereumInevmUSDTWarpConfig.js';
import { getEthereumModeScrollZeronetworkWBTCConfig } from './environments/mainnet3/warp/configGetters/getEthereumModeScrollZeronetworkWBTCConfig.js';
import { getEthereumSeiFastUSDWarpConfig } from './environments/mainnet3/warp/configGetters/getEthereumSeiFastUSDWarpConfig.js';
import { getEthereumVictionETHWarpConfig } from './environments/mainnet3/warp/configGetters/getEthereumVictionETHWarpConfig.js';
import { getEthereumVictionUSDCWarpConfig } from './environments/mainnet3/warp/configGetters/getEthereumVictionUSDCWarpConfig.js';
import { getEthereumVictionUSDTWarpConfig } from './environments/mainnet3/warp/configGetters/getEthereumVictionUSDTWarpConfig.js';
import { getInevmInjectiveINJWarpConfig } from './environments/mainnet3/warp/configGetters/getInevmInjectiveINJWarpConfig.js';
import { getMantapacificNeutronTiaWarpConfig } from './environments/mainnet3/warp/configGetters/getMantapacificNeutronTiaWarpConfig.js';
import { getPolygonZeroNetworkPolWarpConfig } from './environments/mainnet3/warp/configGetters/getPolygonZeroNetworkPolConfig.js';
import { getRenzoEZETHWarpConfig } from './environments/mainnet3/warp/configGetters/getRenzoEZETHWarpConfig.js';
import { getRenzoPZETHWarpConfig } from './environments/mainnet3/warp/configGetters/getRenzoPZETHWarpConfig.js';
import { WarpRouteIds } from './environments/mainnet3/warp/warpIds.js';
Expand All @@ -52,20 +56,25 @@ export const warpConfigGetterMap: Record<
[WarpRouteIds.ArbitrumNeutronTIA]: getArbitrumNeutronTiaWarpConfig,
[WarpRouteIds.ArbitrumBaseBlastBscEthereumFraxtalLineaModeOptimismSeiTaikoZircuitEZETH]:
getRenzoEZETHWarpConfig,
[WarpRouteIds.BlastZeroNetworkUSDB]: getBlastZeroNetworkUSDBWarpConfig,
[WarpRouteIds.BscZeroNetworkBNB]: getBscZeroNetworkBNBWarpConfig,
[WarpRouteIds.InevmInjectiveINJ]: getInevmInjectiveINJWarpConfig,
[WarpRouteIds.EthereumSeiFastUSD]: getEthereumSeiFastUSDWarpConfig,
[WarpRouteIds.EthereumVictionETH]: getEthereumVictionETHWarpConfig,
[WarpRouteIds.EthereumVictionUSDC]: getEthereumVictionUSDCWarpConfig,
[WarpRouteIds.EthereumVictionUSDT]: getEthereumVictionUSDTWarpConfig,
[WarpRouteIds.EthereumZircuitPZETH]: getRenzoPZETHWarpConfig,
[WarpRouteIds.EthereumBscLumiaLUMIA]: getEthereumBscLUMIAWarpConfig,
[WarpRouteIds.EthereumModeScrollZeroNetworkWBTC]:
getEthereumModeScrollZeronetworkWBTCConfig,
[WarpRouteIds.MantapacificNeutronTIA]: getMantapacificNeutronTiaWarpConfig,
[WarpRouteIds.EclipseStrideTIA]: getEclipseStrideTiaWarpConfig,
[WarpRouteIds.EclipseStrideSTTIA]: getEclipseStrideStTiaWarpConfig,
[WarpRouteIds.EclipseEthereumSolanaUSDT]:
getEclipseEthereumSolanaUSDTWarpConfig,
[WarpRouteIds.EclipseEthereumWBTC]: getEclipseEthereumWBTCWarpConfig,
[WarpRouteIds.EclipseEthereumWeETHs]: getEclipseEthereumWeEthsWarpConfig,
[WarpRouteIds.PolygonZeroNetworkPOL]: getPolygonZeroNetworkPolWarpConfig,
};

export async function getWarpConfig(
Expand Down
3 changes: 3 additions & 0 deletions typescript/infra/src/config/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ export const tokens: ChainMap<Record<string, Address>> = {
sei: {
fastUSD: '0x37a4dD9CED2b19Cfe8FAC251cd727b5787E45269',
},
blast: {
usdb: '0x4300000000000000000000000000000000000003',
},
};
6 changes: 5 additions & 1 deletion typescript/sdk/src/router/HyperlaneRouterChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
addressToBytes32,
assert,
eqAddress,
isZeroishAddress,
rootLogger,
} from '@hyperlane-xyz/utils';

Expand Down Expand Up @@ -104,7 +105,10 @@ export class HyperlaneRouterChecker<

let expectedConfig = config.interchainSecurityModule;

if (typeof expectedConfig === 'string') {
if (
typeof expectedConfig === 'string' &&
!isZeroishAddress(expectedConfig)
) {
expectedConfig = await ismReader.deriveIsmConfig(expectedConfig);
}

Expand Down

0 comments on commit 250853e

Please sign in to comment.