From 2cd8322f8625cb15092fd99be2ac78737fd7156a Mon Sep 17 00:00:00 2001 From: Jeremy Parish Date: Mon, 7 Nov 2022 19:32:35 -0700 Subject: [PATCH 1/5] Fix Network Display Name --- packages/web/config/ibc-assets.ts | 1 + .../axelar/source-chain-config.ts | 20 ++-- packages/web/integrations/axelar/transfer.tsx | 38 +++++--- packages/web/integrations/axelar/types.ts | 93 ++++++++++++------- 4 files changed, 101 insertions(+), 51 deletions(-) diff --git a/packages/web/config/ibc-assets.ts b/packages/web/config/ibc-assets.ts index ac471143b1..484bacb0f3 100644 --- a/packages/web/config/ibc-assets.ts +++ b/packages/web/config/ibc-assets.ts @@ -39,6 +39,7 @@ export const IBCAssetInfos: (IBCAsset & { method: "deposit-address" as const, sourceChains: [ AxelarSourceChainConfigs.usdc.ethereum, + AxelarSourceChainConfigs.usdc.binance, AxelarSourceChainConfigs.usdc.moonbeam, ], }, diff --git a/packages/web/integrations/axelar/source-chain-config.ts b/packages/web/integrations/axelar/source-chain-config.ts index 7054a429b6..9b9c1fa0ed 100644 --- a/packages/web/integrations/axelar/source-chain-config.ts +++ b/packages/web/integrations/axelar/source-chain-config.ts @@ -11,7 +11,7 @@ export const SourceChainConfigs: { usdc: { ethereum: { id: IS_TESTNET - ? ("ethereum-2" as const) + ? ("Ethereum Goerli Testnet" as const) : ("Ethereum" as const), erc20ContractAddress: IS_TESTNET ? "0x254d06f33bDc5b8ee05b2ea472107E300226659A" @@ -28,7 +28,9 @@ export const SourceChainConfigs: { transferFeeMinAmount: IS_TESTNET ? "150000" : "1500000", }, binance: { - id: "binance" as const, + id: IS_TESTNET + ? ("Binance Smart Chain Testnet" as const) + : ("Binance Smart Chain" as const), erc20ContractAddress: IS_TESTNET ? "0xc2fA98faB811B785b81c64Ac875b31CC9E40F9D2" : "0x4268B8F0B87b6Eae5d897996E6b845ddbD99Adf3", @@ -44,7 +46,9 @@ export const SourceChainConfigs: { transferFeeMinAmount: IS_TESTNET ? "150000" : "1500000", }, moonbeam: { - id: "Moonbeam" as const, + id: IS_TESTNET + ? ("Moonbase Alpha" as const) + : ("Moonbeam" as const), erc20ContractAddress: IS_TESTNET ? "0xD1633F7Fb3d716643125d6415d4177bC36b7186b" : "0xCa01a1D0993565291051daFF390892518ACfAD3A", @@ -63,7 +67,7 @@ export const SourceChainConfigs: { weth: { ethereum: { id: IS_TESTNET - ? ("ethereum-2" as const) + ? ("Ethereum Goerli Testnet" as const) : ("Ethereum" as const), erc20ContractAddress: IS_TESTNET ? "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6" @@ -74,7 +78,9 @@ export const SourceChainConfigs: { }, wglmr: { moonbeam: { - id: "Moonbeam" as const, + id: IS_TESTNET + ? ("Moonbase Alpha" as const) + : ("Moonbeam" as const), erc20ContractAddress: IS_TESTNET ? "0x1436aE0dF0A8663F18c0Ec51d7e2E46591730715" : "0xAcc15dC74880C9944775448304B263D191c6077F", @@ -196,7 +202,9 @@ export const SourceChainConfigs: { }, wbnb: { binance: { - id: ("binance" as const), + id: IS_TESTNET + ? ("Binance Smart Chain Testnet" as const) + : ("Binance Smart Chain" as const), erc20ContractAddress: IS_TESTNET ? "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd" : "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", diff --git a/packages/web/integrations/axelar/transfer.tsx b/packages/web/integrations/axelar/transfer.tsx index cd835d353d..fe947c47f5 100644 --- a/packages/web/integrations/axelar/transfer.tsx +++ b/packages/web/integrations/axelar/transfer.tsx @@ -30,7 +30,8 @@ import { useDepositAddress } from "./hooks"; import { AxelarBridgeConfig, SourceChain, - EthClientChainIds_AxelarChainIdsMap, + EthClientChainIds_SourceChainMap, + AxelarChainIds_SourceChainMap, waitBySourceChain, } from "."; import { useAmplitudeAnalytics } from "../../hooks/use-amplitude-analytics"; @@ -74,28 +75,39 @@ const AxelarTransfer: FunctionComponent< // notify eth wallet of prev selected preferred chain useEffect(() => { + + console.log(selectedSourceChainKey); + + let ethChainId: string | undefined = getKeyByValue( + EthClientChainIds_SourceChainMap, + selectedSourceChainKey + ) ?? selectedSourceChainKey + + console.log(selectedSourceChainKey); + console.log(ethChainId); + let hexChainId: string | undefined = getKeyByValue( ChainNames, - selectedSourceChainKey + ethChainId ) - ? selectedSourceChainKey + ? ethChainId : undefined; - if (!hexChainId) { - hexChainId = getKeyByValue( - EthClientChainIds_AxelarChainIdsMap, - selectedSourceChainKey - ); - } + console.log(selectedSourceChainKey); + console.log(ethChainId); + console.log(hexChainId); + if (!hexChainId) return; ethWalletClient.setPreferredSourceChain(hexChainId); }, [selectedSourceChainKey, ethWalletClient]); /** Chain key that Axelar accepts in APIs. */ - const selectedSourceChainAxelarKey = - EthClientChainIds_AxelarChainIdsMap[selectedSourceChainKey] ?? - selectedSourceChainKey; + const selectedSourceChainAxelarKey = getKeyByValue( + AxelarChainIds_SourceChainMap, + selectedSourceChainKey + ) + ?? selectedSourceChainKey; const sourceChainConfig = sourceChains.find( ({ id }) => id === selectedSourceChainKey @@ -217,7 +229,7 @@ const AxelarTransfer: FunctionComponent< }, [ethWalletClient.isConnected, userDisconnectedEthWallet]); const correctChainSelected = - (EthClientChainIds_AxelarChainIdsMap[ethWalletClient.chainId as string] ?? + (EthClientChainIds_SourceChainMap[ethWalletClient.chainId as string] ?? ethWalletClient.chainId) === selectedSourceChainAxelarKey; const { depositAddress, isLoading: isDepositAddressLoading } = diff --git a/packages/web/integrations/axelar/types.ts b/packages/web/integrations/axelar/types.ts index 4f5f7c9e48..6a5ddb7321 100644 --- a/packages/web/integrations/axelar/types.ts +++ b/packages/web/integrations/axelar/types.ts @@ -22,53 +22,82 @@ export interface AxelarBridgeConfig { }; } -/** See: https://docs.axelar.dev/dev/build/chain-names/mainnet - * See: https://docs.axelar.dev/dev/build/chain-names/testnet - * Testnet: https://axelartest-lcd.quickapi.com/axelar/nexus/v1beta1/chains?status=1 - */ +/** Intermediate source chain identifiers */ export type SourceChain = - | "aurora" + | "Aurora Testnet" | "Avalanche" - | "binance" + | "Avalanche Fuji Testnet" + | "Binance Smart Chain" + | "Binance Smart Chain Testnet" | "Ethereum" - | "ethereum-2" + | "Ethereum Goerli Testnet" | "Fantom" + | "Fantom Testnet" | "Moonbeam" - | "Polygon"; + | "Moonbase Alpha" + | "Polygon" + | "Mumbai"; -/** Maps eth client chainIDs => axelar chain ids. - * - * ethClientChainIDs must be specified in ../ethereuem/types.ts::ChainNames{} to map the name to a chainID, which is in turn used to add the network to EVM-compatible wallets, like Metamask. - * - * AxelarChainIds must be specified in SourceChain{} and are used in ./source-chain-configs.ts::SourceChainConfigs{} as ::::id values. - * - * Values not included as keys are assumed to be the same across chainlist and Axelar. + +/** Maps Axelar chain id agruments => source chain ids. + * SourceChain (IDs) are used in ./source-chain-configs.ts::SourceChainConfigs{} as ::::id values. + * Axelar Chain IDs are accepted as arguments in Axelar's APIs. + * Mainnet Docs: https://docs.axelar.dev/dev/build/chain-names/mainnet + * Testnet Docs: https://docs.axelar.dev/dev/build/chain-names/testnet + * Testnet API: https://axelartest-lcd.quickapi.com/axelar/nexus/v1beta1/chains?status=1 */ -export const EthClientChainIds_AxelarChainIdsMap: { - [ethClientChainIds: string]: SourceChain; +export const AxelarChainIds_SourceChainMap: { + [axelarChainIds: string]: SourceChain; } = IS_TESTNET ? { - "Aurora Testnet": "aurora", - "Avalanche Fuji Testnet": "Avalanche", - "Binance Smart Chain Testnet": "binance", - "Goerli Test Network": "ethereum-2", - "Fantom Testnet": "Fantom", - "Moonbase Alpha": "Moonbeam", - Mumbai: "Polygon", + "aurora": "Aurora Testnet", + "Avalanche": "Avalanche Fuji Testnet", + "binance": "Binance Smart Chain Testnet", + "ethereum-2": "Ethereum Goerli Testnet", + "Fantom": "Fantom Testnet", + "Moonbeam": "Moonbase Alpha", + "Polygon": "Mumbai" } : { - "Avalanche C-Chain": "Avalanche", - "Binance Smart Chain Mainnet": "binance", - "Ethereum Main Network": "Ethereum", - "Fantom Opera": "Fantom", - "Moonbeam Mainnet": "Moonbeam", - "Polygon Mainnet": "Polygon", + "Avalanche": "Avalanche", + "binance": "Binance Smart Chain", + "Ethereum": "Ethereum", + "Fantom": "Fantom", + "Moonbeam": "Moonbeam", + "Polygon": "Polygon" }; + +/** Maps eth client chainIDs => source chain ids. + * + * ethClientChainIDs must be specified in ../ethereuem/types.ts::ChainNames{} to map the name to a chainID, which is in turn used to add the network to EVM-compatible wallets, like Metamask. + * SourceChain (IDs) are used in ./source-chain-configs.ts::SourceChainConfigs{} as ::::id values. + */ +export const EthClientChainIds_SourceChainMap: { + [ethClientChainIds: string]: SourceChain; +} = { + "Aurora Testnet": "Aurora Testnet", + "Avalanche Fuji Testnet": "Avalanche Fuji Testnet", + "Binance Smart Chain Testnet": "Binance Smart Chain Testnet", + "Goerli Test Network": "Ethereum Goerli Testnet", + "Fantom Testnet": "Fantom Testnet", + "Moonbase Alpha": "Moonbase Alpha", + "Mumbai": "Mumbai", + "Avalanche C-Chain": "Avalanche", + "Binance Smart Chain Mainnet": "Binance Smart Chain", + "Ethereum Main Network": "Ethereum", + "Fantom Opera": "Fantom", + "Moonbeam Mainnet": "Moonbeam", + "Polygon Mainnet": "Polygon", +}; + export type SourceChainConfig = { - /** Axelar-defined identifier. */ + + /** Source Chain identifier. */ id: SourceChain; - /** Address of origin ERC20 token for that origin chain. Leave blank to prefer native ETH currency if `id` is not a Cosmos chain in `ChainInfo`. + + /** Address of origin ERC20 token for that origin chain. Leave blank to + * prefer native ETH currency if `id` is not a Cosmos chain in `ChainInfo`. */ erc20ContractAddress?: string; From 892aff19b66a0cb7d619613027b66ed78bfdc021 Mon Sep 17 00:00:00 2001 From: Jeremy Parish Date: Tue, 8 Nov 2022 02:09:49 -0700 Subject: [PATCH 2/5] Minor change --- packages/web/modals/transfer-asset-select.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/web/modals/transfer-asset-select.tsx b/packages/web/modals/transfer-asset-select.tsx index abdf817ebe..e854f522c4 100644 --- a/packages/web/modals/transfer-asset-select.tsx +++ b/packages/web/modals/transfer-asset-select.tsx @@ -13,6 +13,8 @@ import type { SourceChain } from "../integrations/axelar"; import { useConnectWalletModalRedirect, useWindowSize } from "../hooks"; import { ModalBase, ModalBaseProps } from "./base"; +const IS_TESTNET = process.env.NEXT_PUBLIC_IS_TESTNET === "true"; + /** Intermediate step to allow a user to select & config an asset before deposit/withdraw. */ export const TransferAssetSelectModal: FunctionComponent< ModalBaseProps & { @@ -47,7 +49,7 @@ export const TransferAssetSelectModal: FunctionComponent< token: { currency: { coinDenom }, }, - }) => coinDenom === "USDC" + }) => coinDenom === (IS_TESTNET ? "aUSDC" : "USDC"), )?.token.denom) || tokens[0].token.denom ); const [selectedSourceChainKey, setSelectedSourceChainKey] = From c1643c8f13b98f23f6da6b1f24b373747ca50b8f Mon Sep 17 00:00:00 2001 From: Jeremy Parish Date: Tue, 8 Nov 2022 16:09:16 -0700 Subject: [PATCH 3/5] Fix testnet Metamask network detection --- .../axelar/source-chain-config.ts | 8 ++++---- packages/web/integrations/axelar/transfer.tsx | 19 ++++++------------- packages/web/integrations/axelar/types.ts | 12 ++++++------ 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/packages/web/integrations/axelar/source-chain-config.ts b/packages/web/integrations/axelar/source-chain-config.ts index 9b9c1fa0ed..6066e196fa 100644 --- a/packages/web/integrations/axelar/source-chain-config.ts +++ b/packages/web/integrations/axelar/source-chain-config.ts @@ -11,7 +11,7 @@ export const SourceChainConfigs: { usdc: { ethereum: { id: IS_TESTNET - ? ("Ethereum Goerli Testnet" as const) + ? ("Goerli Testnet" as const) : ("Ethereum" as const), erc20ContractAddress: IS_TESTNET ? "0x254d06f33bDc5b8ee05b2ea472107E300226659A" @@ -29,7 +29,7 @@ export const SourceChainConfigs: { }, binance: { id: IS_TESTNET - ? ("Binance Smart Chain Testnet" as const) + ? ("BSC Testnet" as const) : ("Binance Smart Chain" as const), erc20ContractAddress: IS_TESTNET ? "0xc2fA98faB811B785b81c64Ac875b31CC9E40F9D2" @@ -67,7 +67,7 @@ export const SourceChainConfigs: { weth: { ethereum: { id: IS_TESTNET - ? ("Ethereum Goerli Testnet" as const) + ? ("Goerli Testnet" as const) : ("Ethereum" as const), erc20ContractAddress: IS_TESTNET ? "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6" @@ -203,7 +203,7 @@ export const SourceChainConfigs: { wbnb: { binance: { id: IS_TESTNET - ? ("Binance Smart Chain Testnet" as const) + ? ("BSC Testnet" as const) : ("Binance Smart Chain" as const), erc20ContractAddress: IS_TESTNET ? "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd" diff --git a/packages/web/integrations/axelar/transfer.tsx b/packages/web/integrations/axelar/transfer.tsx index fe947c47f5..8e79116a2d 100644 --- a/packages/web/integrations/axelar/transfer.tsx +++ b/packages/web/integrations/axelar/transfer.tsx @@ -76,27 +76,18 @@ const AxelarTransfer: FunctionComponent< // notify eth wallet of prev selected preferred chain useEffect(() => { - console.log(selectedSourceChainKey); - - let ethChainId: string | undefined = getKeyByValue( + let ethClientChainName: string | undefined = getKeyByValue( EthClientChainIds_SourceChainMap, selectedSourceChainKey ) ?? selectedSourceChainKey - console.log(selectedSourceChainKey); - console.log(ethChainId); - let hexChainId: string | undefined = getKeyByValue( ChainNames, - ethChainId + ethClientChainName ) - ? ethChainId + ? ethClientChainName : undefined; - console.log(selectedSourceChainKey); - console.log(ethChainId); - console.log(hexChainId); - if (!hexChainId) return; ethWalletClient.setPreferredSourceChain(hexChainId); @@ -230,7 +221,9 @@ const AxelarTransfer: FunctionComponent< const correctChainSelected = (EthClientChainIds_SourceChainMap[ethWalletClient.chainId as string] ?? - ethWalletClient.chainId) === selectedSourceChainAxelarKey; + ethWalletClient.chainId) === + (AxelarChainIds_SourceChainMap[selectedSourceChainAxelarKey] ?? + selectedSourceChainAxelarKey); const { depositAddress, isLoading: isDepositAddressLoading } = useDepositAddress( diff --git a/packages/web/integrations/axelar/types.ts b/packages/web/integrations/axelar/types.ts index 6a5ddb7321..606aedb4ab 100644 --- a/packages/web/integrations/axelar/types.ts +++ b/packages/web/integrations/axelar/types.ts @@ -28,9 +28,9 @@ export type SourceChain = | "Avalanche" | "Avalanche Fuji Testnet" | "Binance Smart Chain" - | "Binance Smart Chain Testnet" + | "BSC Testnet" | "Ethereum" - | "Ethereum Goerli Testnet" + | "Goerli Testnet" | "Fantom" | "Fantom Testnet" | "Moonbeam" @@ -52,8 +52,8 @@ export const AxelarChainIds_SourceChainMap: { ? { "aurora": "Aurora Testnet", "Avalanche": "Avalanche Fuji Testnet", - "binance": "Binance Smart Chain Testnet", - "ethereum-2": "Ethereum Goerli Testnet", + "binance": "BSC Testnet", + "ethereum-2": "Goerli Testnet", "Fantom": "Fantom Testnet", "Moonbeam": "Moonbase Alpha", "Polygon": "Mumbai" @@ -78,8 +78,8 @@ export const EthClientChainIds_SourceChainMap: { } = { "Aurora Testnet": "Aurora Testnet", "Avalanche Fuji Testnet": "Avalanche Fuji Testnet", - "Binance Smart Chain Testnet": "Binance Smart Chain Testnet", - "Goerli Test Network": "Ethereum Goerli Testnet", + "Binance Smart Chain Testnet": "BSC Testnet", + "Goerli Test Network": "Goerli Testnet", "Fantom Testnet": "Fantom Testnet", "Moonbase Alpha": "Moonbase Alpha", "Mumbai": "Mumbai", From 81e85b1ea0e20bd80d06c7454007bf84062f6500 Mon Sep 17 00:00:00 2001 From: Jeremy Parish Date: Wed, 9 Nov 2022 14:10:20 -0700 Subject: [PATCH 4/5] Fix transfer fees --- .../axelar/source-chain-config.ts | 32 +++++++------- packages/web/integrations/axelar/transfer.tsx | 6 ++- packages/web/integrations/axelar/types.ts | 41 +---------------- packages/web/integrations/axelar/utils.ts | 2 +- packages/web/integrations/bridge-info.ts | 44 ++++++++++++++++++- packages/web/modals/transfer-asset-select.tsx | 2 +- 6 files changed, 67 insertions(+), 60 deletions(-) diff --git a/packages/web/integrations/axelar/source-chain-config.ts b/packages/web/integrations/axelar/source-chain-config.ts index 79516ed168..036caadf31 100644 --- a/packages/web/integrations/axelar/source-chain-config.ts +++ b/packages/web/integrations/axelar/source-chain-config.ts @@ -17,7 +17,7 @@ export const SourceChainConfigs: { ? "0x254d06f33bDc5b8ee05b2ea472107E300226659A" : "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // test: 'aUSDC' on metamask/etherscan logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: IS_TESTNET ? "150000" : "10500000", // From https://docs.axelar.dev/resources/mainnet#cross-chain-relayer-gas-fee + transferFeeMinAmount: IS_TESTNET ? "150000" : "20500000", // From https://docs.axelar.dev/resources/mainnet#cross-chain-relayer-gas-fee }, avalanche: { id: "Avalanche" as const, @@ -73,7 +73,7 @@ export const SourceChainConfigs: { ? "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6" : "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: IS_TESTNET ? "100000000000000" : "6300000000000000", + transferFeeMinAmount: IS_TESTNET ? "100000000000000" : "20400000000000000", }, }, wglmr: { @@ -87,7 +87,7 @@ export const SourceChainConfigs: { logoUrl: "/networks/moonbeam.svg", transferFeeMinAmount: IS_TESTNET ? "40000000000000000" - : "2000000000000000000", + : "2900000000000000000", }, }, wbtc: { @@ -103,7 +103,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0x6B175474E89094C44Da98b954EedeAC495271d0F", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "10000000000000000000", + transferFeeMinAmount: "20500000000000000000", }, }, dot: { @@ -111,7 +111,7 @@ export const SourceChainConfigs: { id: "Moonbeam" as const, erc20ContractAddress: "0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080", logoUrl: "/networks/moonbeam.svg", - transferFeeMinAmount: "1000000000", + transferFeeMinAmount: "1700000000", }, }, usdt: { @@ -119,7 +119,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0xdAC17F958D2ee523a2206206994597C13D831ec7", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "10000000", + transferFeeMinAmount: "20500000000000000000", }, }, frax: { @@ -127,7 +127,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0x853d955aCEf822Db058eb8505911ED77F175b99e", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "10000000000000000000", + transferFeeMinAmount: "20500000000000000000", }, }, link: { @@ -135,7 +135,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0x514910771AF9Ca656af840dff83E8264EcF986CA", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "2000000000000000000", + transferFeeMinAmount: "3080000000000000000", }, }, aave: { @@ -143,7 +143,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "200000000000000000", + transferFeeMinAmount: "308000000000000000", }, }, ape: { @@ -151,7 +151,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0x4d224452801ACEd8B2F0aebE155379bb5D594381", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "2000000000000000000", + transferFeeMinAmount: "4100000000000000000", }, }, axs: { @@ -159,7 +159,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0xBB0E17EF65F82Ab018d8EDd776e8DD940327B28b", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "700000000000000000", + transferFeeMinAmount: "1030000000000000000", }, }, mkr: { @@ -167,7 +167,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "10000000000000000", + transferFeeMinAmount: "20600000000000000", }, }, rai: { @@ -175,7 +175,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0x03ab458634910AaD20eF5f1C8ee96F1D6ac54919", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "3000000000000000000", + transferFeeMinAmount: "7200000000000000000", }, }, shib: { @@ -183,7 +183,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "1000000000000000000000000", + transferFeeMinAmount: "2050000000000000000000000", }, }, uni: { @@ -191,7 +191,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "2000000000000000000", + transferFeeMinAmount: "4100000000000000000", }, }, xcn: { @@ -199,7 +199,7 @@ export const SourceChainConfigs: { id: "Ethereum" as const, erc20ContractAddress: "0xA2cd3D43c775978A96BdBf12d733D5A1ED94fb18", logoUrl: "/networks/ethereum.svg", - transferFeeMinAmount: "100000000000000000000", + transferFeeMinAmount: "206000000000000000000", }, }, wbnb: { diff --git a/packages/web/integrations/axelar/transfer.tsx b/packages/web/integrations/axelar/transfer.tsx index 95b89ba3ea..192b633b0a 100644 --- a/packages/web/integrations/axelar/transfer.tsx +++ b/packages/web/integrations/axelar/transfer.tsx @@ -29,11 +29,13 @@ import { useGeneralAmountConfig } from "../use-general-amount-config"; import { useDepositAddress } from "./hooks"; import { AxelarBridgeConfig, - SourceChain, - EthClientChainIds_SourceChainMap, AxelarChainIds_SourceChainMap, waitBySourceChain, } from "."; +import { + SourceChain, + EthClientChainIds_SourceChainMap +} from "../bridge-info"; import { useAmplitudeAnalytics } from "../../hooks/use-amplitude-analytics"; import { EventName } from "../../config/user-analytics-v2"; import { useTranslation } from "react-multi-lang"; diff --git a/packages/web/integrations/axelar/types.ts b/packages/web/integrations/axelar/types.ts index ad9c46c8eb..3d9a3e5362 100644 --- a/packages/web/integrations/axelar/types.ts +++ b/packages/web/integrations/axelar/types.ts @@ -1,3 +1,5 @@ +import { SourceChain } from "../bridge-info"; + const IS_TESTNET = process.env.NEXT_PUBLIC_IS_TESTNET === "true"; export interface AxelarBridgeConfig { @@ -24,22 +26,6 @@ export interface AxelarBridgeConfig { }; } -/** Intermediate source chain identifiers */ -export type SourceChain = - | "Aurora Testnet" - | "Avalanche" - | "Avalanche Fuji Testnet" - | "Binance Smart Chain" - | "BSC Testnet" - | "Ethereum" - | "Goerli Testnet" - | "Fantom" - | "Fantom Testnet" - | "Moonbeam" - | "Moonbase Alpha" - | "Polygon" - | "Mumbai"; - /** Maps Axelar chain id agruments => source chain ids. * SourceChain (IDs) are used in ./source-chain-configs.ts::SourceChainConfigs{} as ::::id values. @@ -70,29 +56,6 @@ export const AxelarChainIds_SourceChainMap: { }; -/** Maps eth client chainIDs => source chain ids. - * - * ethClientChainIDs must be specified in ../ethereuem/types.ts::ChainNames{} to map the name to a chainID, which is in turn used to add the network to EVM-compatible wallets, like Metamask. - * SourceChain (IDs) are used in ./source-chain-configs.ts::SourceChainConfigs{} as ::::id values. - */ -export const EthClientChainIds_SourceChainMap: { - [ethClientChainIds: string]: SourceChain; -} = { - "Aurora Testnet": "Aurora Testnet", - "Avalanche Fuji Testnet": "Avalanche Fuji Testnet", - "Binance Smart Chain Testnet": "BSC Testnet", - "Goerli Test Network": "Goerli Testnet", - "Fantom Testnet": "Fantom Testnet", - "Moonbase Alpha": "Moonbase Alpha", - "Mumbai": "Mumbai", - "Avalanche C-Chain": "Avalanche", - "Binance Smart Chain Mainnet": "Binance Smart Chain", - "Ethereum Main Network": "Ethereum", - "Fantom Opera": "Fantom", - "Moonbeam Mainnet": "Moonbeam", - "Polygon Mainnet": "Polygon", -}; - export type SourceChainConfig = { /** Source Chain identifier. */ diff --git a/packages/web/integrations/axelar/utils.ts b/packages/web/integrations/axelar/utils.ts index 5113e3ddba..b0437d0bed 100644 --- a/packages/web/integrations/axelar/utils.ts +++ b/packages/web/integrations/axelar/utils.ts @@ -1,4 +1,4 @@ -import { SourceChain } from "./types"; +import { SourceChain } from "../bridge-info"; import { t } from "react-multi-lang"; export function waitBySourceChain(sourceChain: SourceChain) { diff --git a/packages/web/integrations/bridge-info.ts b/packages/web/integrations/bridge-info.ts index 67cf2d66e6..999c7c7330 100644 --- a/packages/web/integrations/bridge-info.ts +++ b/packages/web/integrations/bridge-info.ts @@ -1,4 +1,4 @@ -import { AxelarBridgeConfig, SourceChain } from "./axelar/types"; +import { AxelarBridgeConfig } from "./axelar/types"; import { WalletKey } from "./wallets"; // Add to these types as more bridges are integrated @@ -8,9 +8,51 @@ export type OriginBridgeInfo = { wallets: WalletKey[]; } & AxelarBridgeConfig; +/** Human-displayable global source chain identifiers */ +export type SourceChain = + | "Aurora Testnet" + | "Avalanche" + | "Avalanche Fuji Testnet" + | "Binance Smart Chain" + | "BSC Testnet" + | "Ethereum" + | "Goerli Testnet" + | "Fantom" + | "Fantom Testnet" + | "Moonbeam" + | "Moonbase Alpha" + | "Polygon" + | "Mumbai"; + /** String literal identifiers for a source chain. */ export type SourceChainKey = SourceChain; + +/** Maps eth client chainIDs => source chain ids. + * + * ethClientChainIDs must be specified in ../ethereuem/types.ts::ChainNames{} + * to map the name to a chainID, which is in turn used to add the network to + * EVM-compatible wallets, like Metamask. + */ +export const EthClientChainIds_SourceChainMap: { + [ethClientChainIds: string]: SourceChain; +} = { + "Aurora Testnet": "Aurora Testnet", + "Avalanche Fuji Testnet": "Avalanche Fuji Testnet", + "Binance Smart Chain Testnet": "BSC Testnet", + "Goerli Test Network": "Goerli Testnet", + "Fantom Testnet": "Fantom Testnet", + "Moonbase Alpha": "Moonbase Alpha", + "Mumbai": "Mumbai", + "Avalanche C-Chain": "Avalanche", + "Binance Smart Chain Mainnet": "Binance Smart Chain", + "Ethereum Main Network": "Ethereum", + "Fantom Opera": "Fantom", + "Moonbeam Mainnet": "Moonbeam", + "Polygon Mainnet": "Polygon", +}; + + // Fiat on/off ramps export type FiatRampKey = "kado" | "transak"; diff --git a/packages/web/modals/transfer-asset-select.tsx b/packages/web/modals/transfer-asset-select.tsx index 516eb8c9d6..2de8ed2168 100644 --- a/packages/web/modals/transfer-asset-select.tsx +++ b/packages/web/modals/transfer-asset-select.tsx @@ -9,7 +9,7 @@ import type { OriginBridgeInfo, SourceChainKey, } from "../integrations/bridge-info"; -import type { SourceChain } from "../integrations/axelar"; +import type { SourceChain } from "../integrations/bridge-info"; import { useConnectWalletModalRedirect } from "../hooks"; import { ModalBase, ModalBaseProps } from "./base"; import { useTranslation } from "react-multi-lang"; From 92de5d32915c7ae53e9df333f68b921e44724d81 Mon Sep 17 00:00:00 2001 From: Jeremy Parish Date: Wed, 9 Nov 2022 14:18:02 -0700 Subject: [PATCH 5/5] minor fix to testnet fees --- packages/web/integrations/axelar/source-chain-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/integrations/axelar/source-chain-config.ts b/packages/web/integrations/axelar/source-chain-config.ts index 036caadf31..e50b27fd72 100644 --- a/packages/web/integrations/axelar/source-chain-config.ts +++ b/packages/web/integrations/axelar/source-chain-config.ts @@ -86,7 +86,7 @@ export const SourceChainConfigs: { : "0xAcc15dC74880C9944775448304B263D191c6077F", logoUrl: "/networks/moonbeam.svg", transferFeeMinAmount: IS_TESTNET - ? "40000000000000000" + ? "60000000000000000" : "2900000000000000000", }, },