Skip to content

Commit

Permalink
feat(testnet): add new testnet query classes (#539)
Browse files Browse the repository at this point in the history
Signed-off-by: james-a-morris <jaamorris@cs.stonybrook.edu>
  • Loading branch information
james-a-morris authored Feb 12, 2024
1 parent 56d371d commit 6ba5c42
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@across-protocol/sdk-v2",
"author": "UMA Team",
"version": "0.20.5",
"version": "0.20.6",
"license": "AGPL-3.0",
"homepage": "https://docs.across.to/v/developer-docs/developers/across-sdk",
"files": [
Expand Down Expand Up @@ -97,7 +97,7 @@
},
"dependencies": {
"@across-protocol/across-token": "^1.0.0",
"@across-protocol/constants-v2": "^1.0.9",
"@across-protocol/constants-v2": "^1.0.11",
"@across-protocol/contracts-v2": "2.5.0-beta.5",
"@eth-optimism/sdk": "^3.1.8",
"@pinata/sdk": "^2.1.0",
Expand Down
26 changes: 24 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as acxConstants from "@across-protocol/constants-v2";
import { constants as ethersConstants, BigNumber, utils } from "ethers";
export { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "@across-protocol/constants-v2";

Expand Down Expand Up @@ -27,8 +28,29 @@ export const TRANSFER_THRESHOLD_MAX_CONFIG_STORE_VERSION = 1;
export const PROTOCOL_DEFAULT_CHAIN_ID_INDICES = [1, 10, 137, 288, 42161];

// See src/utils/NetworkUtils for helpers.
export const PRODUCTION_CHAIN_IDS = [1, 10, 137, 324, 8453, 42161];
export const TESTNET_CHAIN_IDS = [5, 280, 420, 80001, 84531, 421613];
export const PRODUCTION_CHAIN_IDS = [
acxConstants.MAINNET_CHAIN_IDs.MAINNET,
acxConstants.MAINNET_CHAIN_IDs.OPTIMISM,
acxConstants.MAINNET_CHAIN_IDs.POLYGON,
acxConstants.MAINNET_CHAIN_IDs.ZK_SYNC,
acxConstants.MAINNET_CHAIN_IDs.BASE,
acxConstants.MAINNET_CHAIN_IDs.ARBITRUM,
];

export const TESTNET_CHAIN_IDS = [
acxConstants.TESTNET_CHAIN_IDs.GOERLI,
acxConstants.TESTNET_CHAIN_IDs.ZK_SYNC_GOERLI,
acxConstants.TESTNET_CHAIN_IDs.ZK_SYNC_SEPOLIA,
acxConstants.TESTNET_CHAIN_IDs.OPTIMISM_GOERLI,
acxConstants.TESTNET_CHAIN_IDs.MUMBAI,
acxConstants.TESTNET_CHAIN_IDs.POLYGON_AMOY,
acxConstants.TESTNET_CHAIN_IDs.BASE_GOERLI,
acxConstants.TESTNET_CHAIN_IDs.BASE_SEPOLIA,
acxConstants.TESTNET_CHAIN_IDs.ARBITRUM_GOERLI,
acxConstants.TESTNET_CHAIN_IDs.ARBITRUM_SEPOLIA,
acxConstants.TESTNET_CHAIN_IDs.SEPOLIA,
acxConstants.TESTNET_CHAIN_IDs.OPTIMISM_SEPOLIA,
];

export const PUBLIC_NETWORKS: { [chainId: number]: { name: string; etherscan: string } } = {
1: {
Expand Down
17 changes: 17 additions & 0 deletions src/relayFeeCalculator/chain-queries/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export class ArbitrumQueries extends QueryBase {
}
}

/**
* @deprecated Use ArbitrumSepoliaQueries instead
*/
export class ArbitrumGoerliQueries extends QueryBase {
constructor(
provider: providers.Provider,
Expand All @@ -36,3 +39,17 @@ export class ArbitrumGoerliQueries extends QueryBase {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}

export class ArbitrumSepoliaQueries extends QueryBase {
constructor(
provider: providers.Provider,
symbolMapping = TOKEN_SYMBOLS_MAP,
spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.ARBITRUM_SEPOLIA),
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST,
coingeckoProApiKey?: string,
logger: Logger = DEFAULT_LOGGER,
gasMarkup = 0
) {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}
18 changes: 18 additions & 0 deletions src/relayFeeCalculator/chain-queries/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class EthereumQueries extends QueryBase {

/**
* Query class for Ethereum Görli.
* @deprecated Use EthereumSepoliaQueries instead.
*/
export class EthereumGoerliQueries extends QueryBase {
constructor(
Expand All @@ -39,3 +40,20 @@ export class EthereumGoerliQueries extends QueryBase {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}

/**
* Query class for Ethereum Sepolia.
*/
export class EthereumSepoliaQueries extends QueryBase {
constructor(
provider: providers.Provider,
symbolMapping = TOKEN_SYMBOLS_MAP,
spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.SEPOLIA),
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST,
coingeckoProApiKey?: string,
logger: Logger = DEFAULT_LOGGER,
gasMarkup = 0
) {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}
26 changes: 26 additions & 0 deletions src/relayFeeCalculator/chain-queries/optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export class OptimismQueries extends QueryBase {
}
}

/**
* Queries for the Optimism Goerli chain
* @deprecated Use OptimismSepoliaQueries instead
*/
export class OptimismGoerliQueries extends QueryBase {
constructor(
provider: providers.Provider,
Expand All @@ -53,3 +57,25 @@ export class OptimismGoerliQueries extends QueryBase {
);
}
}

export class OptimismSepoliaQueries extends QueryBase {
constructor(
provider: providers.Provider,
symbolMapping = TOKEN_SYMBOLS_MAP,
spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.OPTIMISM_SEPOLIA),
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST,
coingeckoProApiKey?: string,
logger: Logger = DEFAULT_LOGGER,
gasMarkup = 0
) {
super(
asL2Provider(provider),
symbolMapping,
spokePoolAddress,
simulatedRelayerAddress,
gasMarkup,
logger,
coingeckoProApiKey
);
}
}
18 changes: 18 additions & 0 deletions src/relayFeeCalculator/chain-queries/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export class PolygonQueries extends QueryBase {
}
}

/**
* Queries for the Polygon Mumbai chain (based against Goerli)
* @deprecated Use PolygonAmoyQueries instead
*/
export class PolygonMumbaiQueries extends PolygonQueries {
constructor(
provider: providers.Provider,
Expand All @@ -62,3 +66,17 @@ export class PolygonMumbaiQueries extends PolygonQueries {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, coingeckoProApiKey, logger, gasMarkup);
}
}

export class PolygonAmoyQueries extends PolygonQueries {
constructor(
provider: providers.Provider,
symbolMapping = TOKEN_SYMBOLS_MAP,
spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.POLYGON_AMOY),
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST,
coingeckoProApiKey?: string,
logger: Logger = DEFAULT_LOGGER,
gasMarkup = 0
) {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, coingeckoProApiKey, logger, gasMarkup);
}
}
18 changes: 18 additions & 0 deletions src/relayFeeCalculator/chain-queries/zksync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class ZkSyncQueries extends QueryBase {

/**
* Query class for zkSync Görli.
* @deprecated Use zkSyncSepoliaQueries instead
*/
export class zkSyncGoerliQueries extends QueryBase {
constructor(
Expand All @@ -39,3 +40,20 @@ export class zkSyncGoerliQueries extends QueryBase {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}

/**
* Query class for zkSync Sepolia.
*/
export class zkSyncSepoliaQueries extends QueryBase {
constructor(
provider: providers.Provider,
symbolMapping = TOKEN_SYMBOLS_MAP,
spokePoolAddress = getDeployedAddress("SpokePool", CHAIN_IDs.ZK_SYNC_SEPOLIA),
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
coingeckoProApiKey?: string,
logger: Logger = DEFAULT_LOGGER,
gasMarkup = 0
) {
super(provider, symbolMapping, spokePoolAddress, simulatedRelayerAddress, gasMarkup, logger, coingeckoProApiKey);
}
}
3 changes: 3 additions & 0 deletions src/utils/NetworkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ const networkIdMap: Record<number, string> = {
666: "Hardhat1",
1337: "Hardhat2",
421613: "ArbitrumGoerli",
421614: "ArbitrumSepolia",
324: "ZkSync",
280: "ZkSync-Goerli",
300: "ZKSync-Sepolia",
8453: "Base",
84531: "BaseGoerli",
84532: "BaseSepolia",
11155111: "EthSepolia",
11155420: "OptimismSepolia",
};

/**
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
"@uma/common" "^2.17.0"
hardhat "^2.9.3"

"@across-protocol/constants-v2@^1.0.11":
version "1.0.11"
resolved "https://registry.yarnpkg.com/@across-protocol/constants-v2/-/constants-v2-1.0.11.tgz#58d34b5cb50351d097f2ca43c5a30b5908faed7c"
integrity sha512-RpseYB2QxGyfyrfXtUeFxUSCUW1zqu442QFzsdD1LBZtymuzdHuL2MwtTdmRRnJSvzRTFTtlRh4bYDoExSb5zQ==

"@across-protocol/constants-v2@^1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@across-protocol/constants-v2/-/constants-v2-1.0.4.tgz#df31c81038982a25de2b1b8f7604875f3de1186c"
integrity sha512-Nzl8Z1rZFvcpuKQu7CmBVfvgB13/NoulcsRVYBSkG90imS/e6mugxzqD9UrUb+WOL0ODMCANCAoDw54ZBBzNiQ==

"@across-protocol/constants-v2@^1.0.9":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@across-protocol/constants-v2/-/constants-v2-1.0.9.tgz#bf1b8daa9fc57de29f7561bee288fa3406324787"
integrity sha512-Zc+EzT6Cbbxp1tL1lJTl9QCy8RoOySAmetQeMSfMdm6yE7HpLw05wvxUEx0qGNImwGg2ioaceefnm+Gg1MLgIQ==

"@across-protocol/contracts-v2@2.5.0-beta.5":
version "2.5.0-beta.5"
resolved "https://registry.yarnpkg.com/@across-protocol/contracts-v2/-/contracts-v2-2.5.0-beta.5.tgz#d053facf0408047da4a25b25a54143f2944cda0f"
Expand Down

0 comments on commit 6ba5c42

Please sign in to comment.