-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add external uniswap address to data file
- Loading branch information
1 parent
fea512c
commit 048d61a
Showing
8 changed files
with
50 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,14 @@ | ||
import { getAddress as getAddressLib, NetworkName, ZetaAddress, ZetaNetworkName } from "@zetachain/addresses"; | ||
import { network } from "hardhat"; | ||
import { ZetaProtocolNetwork } from "./address.tools"; | ||
|
||
import { isProtocolNetworkName, ZetaProtocolNetwork } from "./address.tools"; | ||
export declare type TestAddress = "dai" | "usdc"; | ||
|
||
const MissingZetaNetworkError = new Error( | ||
"ZETA_NETWORK is not defined, please set the environment variable (e.g.: ZETA_NETWORK=athens <command>)" | ||
); | ||
|
||
export const ProtocolNetworkNetworkNameMap: Record<ZetaProtocolNetwork, NetworkName> = { | ||
baobab_testnet: "klaytn-baobab", | ||
bsc_mainnet: "bsc-mainnet", | ||
bsc_testnet: "bsc-testnet", | ||
eth_mainnet: "eth-mainnet", | ||
goerli_testnet: "goerli", | ||
mumbai_testnet: "polygon-mumbai", | ||
zeta_testnet: "athens", | ||
}; | ||
|
||
export const getExternalAddress = ( | ||
address: ZetaAddress, | ||
{ | ||
customNetworkName, | ||
customZetaNetwork, | ||
}: { customNetworkName?: ZetaProtocolNetwork; customZetaNetwork?: ZetaNetworkName } = {} | ||
): string => { | ||
const { name: _networkName } = network; | ||
|
||
const protocolNetworkName = customNetworkName || _networkName; | ||
|
||
if (!isProtocolNetworkName(protocolNetworkName)) { | ||
throw new Error(`network.name: ${protocolNetworkName} isn't supported.`); | ||
export const getTestAddress = (address: TestAddress, networkName: ZetaProtocolNetwork): string => { | ||
if (networkName !== "eth_mainnet") throw new Error("Invalid network name"); | ||
if (address === "dai") { | ||
return "0x6b175474e89094c44da98b954eedeac495271d0f"; | ||
} else if (address === "usdc") { | ||
return "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"; | ||
} | ||
|
||
const networkName = ProtocolNetworkNetworkNameMap[protocolNetworkName]; | ||
|
||
const { ZETA_NETWORK: _ZETA_NETWORK } = process.env; | ||
const zetaNetwork = customZetaNetwork || _ZETA_NETWORK; | ||
|
||
if (!zetaNetwork) throw MissingZetaNetworkError; | ||
return getAddressLib({ address, networkName, zetaNetwork }); | ||
throw new Error(`Unknown external address ${address} for network ${networkName}`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters