|
| 1 | +import { |
| 2 | + ChainMap, |
| 3 | + ChainSubmissionStrategy, |
| 4 | + HypTokenRouterConfig, |
| 5 | + SubmissionStrategy, |
| 6 | + TxSubmitterType, |
| 7 | +} from '@hyperlane-xyz/sdk'; |
| 8 | +import { assert } from '@hyperlane-xyz/utils'; |
| 9 | + |
| 10 | +import { RouterConfigWithoutOwner } from '../../../../../src/config/warp.js'; |
| 11 | +import { getChainAddresses } from '../../../../registry.js'; |
| 12 | +import { getWarpFeeOwner } from '../../governance/utils.js'; |
| 13 | +import { WarpRouteIds } from '../warpIds.js'; |
| 14 | + |
| 15 | +import { |
| 16 | + getFixedRoutingFeeConfig, |
| 17 | + getRebalancingUSDCConfigForChain, |
| 18 | + getSyntheticTokenConfigForChain, |
| 19 | + getUSDCRebalancingBridgesConfigFor, |
| 20 | +} from './utils.js'; |
| 21 | + |
| 22 | +// Owner addresses for this deployment (ICA-based, origin chain is ethereum) |
| 23 | +// ethereum: Igra Safe on ethereum (controls all ICAs below) |
| 24 | +// others: ICA deployed on each chain, owned by the ethereum Safe |
| 25 | +const ownersByChain = { |
| 26 | + ethereum: '0x442f580802aDa1B1E83DCaf103682C59dAEe904E', |
| 27 | + arbitrum: '0x01ac140de46b26B698b575a1faF7BDD610676B68', |
| 28 | + avalanche: '0x3dA09321C8eA6936abFA8CeE528341368D6bc374', |
| 29 | + base: '0xba1E27ECE55Ff3B2aCbDB1DD06924C65078D220c', |
| 30 | + optimism: '0x6e0e5642A1359158F9B1B435D84d2C023961b22F', |
| 31 | + polygon: '0x9E0e72A2dCE951c8Dd12aB433EB7a346ce85994d', |
| 32 | + igra: '0xe1C9B631fD776442b7E2c91a58C6d713Bb13FF03', |
| 33 | +} as const; |
| 34 | + |
| 35 | +const collateralChains = [ |
| 36 | + 'ethereum', |
| 37 | + 'arbitrum', |
| 38 | + 'avalanche', |
| 39 | + 'base', |
| 40 | + 'optimism', |
| 41 | + 'polygon', |
| 42 | +] as const; |
| 43 | + |
| 44 | +const ORIGIN_CHAIN = 'ethereum' as const; |
| 45 | + |
| 46 | +const rebalancingConfigByChain = getUSDCRebalancingBridgesConfigFor( |
| 47 | + collateralChains, |
| 48 | + [WarpRouteIds.MainnetCCTPV2Standard, WarpRouteIds.MainnetCCTPV2Fast], |
| 49 | +); |
| 50 | + |
| 51 | +export const getIgraUSDCWarpConfig = async ( |
| 52 | + routerConfig: ChainMap<RouterConfigWithoutOwner>, |
| 53 | +): Promise<ChainMap<HypTokenRouterConfig>> => { |
| 54 | + const feeOwner = getWarpFeeOwner('igra'); |
| 55 | + |
| 56 | + return { |
| 57 | + ...Object.fromEntries( |
| 58 | + collateralChains.map((chain) => [ |
| 59 | + chain, |
| 60 | + getRebalancingUSDCConfigForChain( |
| 61 | + chain, |
| 62 | + routerConfig, |
| 63 | + ownersByChain, |
| 64 | + rebalancingConfigByChain, |
| 65 | + ), |
| 66 | + ]), |
| 67 | + ), |
| 68 | + igra: { |
| 69 | + ...getSyntheticTokenConfigForChain('igra', routerConfig, ownersByChain), |
| 70 | + tokenFee: getFixedRoutingFeeConfig(feeOwner, collateralChains, 10), |
| 71 | + }, |
| 72 | + }; |
| 73 | +}; |
| 74 | + |
| 75 | +export const getIgraUSDCStrategyConfig = (): ChainSubmissionStrategy => { |
| 76 | + const safeAddress = ownersByChain[ORIGIN_CHAIN]; |
| 77 | + const originSafeSubmitter = { |
| 78 | + type: TxSubmitterType.GNOSIS_SAFE as const, |
| 79 | + chain: ORIGIN_CHAIN, |
| 80 | + safeAddress, |
| 81 | + }; |
| 82 | + |
| 83 | + const chainAddress = getChainAddresses(); |
| 84 | + const originInterchainAccountRouter = |
| 85 | + chainAddress[ORIGIN_CHAIN].interchainAccountRouter; |
| 86 | + assert( |
| 87 | + originInterchainAccountRouter, |
| 88 | + `Could not fetch originInterchainAccountRouter for ${ORIGIN_CHAIN}`, |
| 89 | + ); |
| 90 | + |
| 91 | + const icaChains = [...collateralChains, 'igra'].filter( |
| 92 | + (c) => c !== ORIGIN_CHAIN, |
| 93 | + ); |
| 94 | + |
| 95 | + const icaStrategies: [string, SubmissionStrategy][] = icaChains.map( |
| 96 | + (chain) => [ |
| 97 | + chain, |
| 98 | + { |
| 99 | + submitter: { |
| 100 | + type: TxSubmitterType.INTERCHAIN_ACCOUNT as const, |
| 101 | + chain: ORIGIN_CHAIN, |
| 102 | + destinationChain: chain, |
| 103 | + owner: safeAddress, |
| 104 | + originInterchainAccountRouter, |
| 105 | + internalSubmitter: originSafeSubmitter, |
| 106 | + }, |
| 107 | + }, |
| 108 | + ], |
| 109 | + ); |
| 110 | + |
| 111 | + return Object.fromEntries([ |
| 112 | + [ORIGIN_CHAIN, { submitter: originSafeSubmitter }], |
| 113 | + ...icaStrategies, |
| 114 | + ]); |
| 115 | +}; |
0 commit comments