Skip to content

Commit

Permalink
feat: Import updated BAL address and import token addresses from sdk-…
Browse files Browse the repository at this point in the history
…v2 instead of contracts-v2

This PR updates the sdk-v2 and contracts-v2 versions that include the updated BAL address but also change all imports of TOKEN_SYMBOLS_MAP to the sdk-v2's version so that future updates only need to bump the sdk-v2
  • Loading branch information
nicholaspai committed Oct 2, 2023
1 parent 2da16b5 commit 676f223
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 42 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"node": ">=16.18.0"
},
"dependencies": {
"@across-protocol/contracts-v2": "2.4.3",
"@across-protocol/sdk-v2": "0.16.4",
"@across-protocol/contracts-v2": "2.4.4",
"@across-protocol/sdk-v2": "0.16.5",
"@arbitrum/sdk": "^3.1.3",
"@defi-wonderland/smock": "^2.3.5",
"@eth-optimism/sdk": "^3.1.0",
Expand Down
6 changes: 3 additions & 3 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert";
import { Contract, ethers, utils as ethersUtils } from "ethers";
import readline from "readline";
import * as contracts from "@across-protocol/contracts-v2";
import { constants } from "@across-protocol/sdk-v2";
import { getDeployedContract, getNodeUrlList } from "../src/utils";

type ERC20 = {
Expand Down Expand Up @@ -51,9 +51,9 @@ export function resolveToken(token: string, chainId: number): ERC20 {
// `token` may be an address or a symbol. Normalise it to a symbol for easy lookup.
const symbol = !ethersUtils.isAddress(token)
? token.toUpperCase()
: Object.values(contracts.TOKEN_SYMBOLS_MAP).find(({ addresses }) => addresses[chainId] === token)?.symbol;
: Object.values(constants.TOKEN_SYMBOLS_MAP).find(({ addresses }) => addresses[chainId] === token)?.symbol;

const _token = contracts.TOKEN_SYMBOLS_MAP[symbol];
const _token = constants.TOKEN_SYMBOLS_MAP[symbol];
if (_token === undefined) {
throw new Error(`Token ${token} on chain ID ${chainId} unrecognised`);
}
Expand Down
5 changes: 2 additions & 3 deletions src/clients/bridges/ZKSyncAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import { SpokePoolClient } from "../SpokePoolClient";
import assert from "assert";
import * as zksync from "zksync-web3";
import { CONTRACT_ADDRESSES } from "../../common";
import { TOKEN_SYMBOLS_MAP } from "@across-protocol/contracts-v2";
import { isDefined } from "../../utils/TypeGuards";
import { gasPriceOracle, utils } from "@across-protocol/sdk-v2";
import { gasPriceOracle, utils, constants } from "@across-protocol/sdk-v2";
import { zkSync as zkSyncUtils } from "../../utils/chains";

/**
Expand Down Expand Up @@ -233,7 +232,7 @@ export class ZKSyncAdapter extends BaseAdapter {
const { chainId } = this;
assert(chainId === 324, `chainId ${chainId} is not supported`);

const l2WethAddress = TOKEN_SYMBOLS_MAP.WETH.addresses[chainId];
const l2WethAddress = constants.TOKEN_SYMBOLS_MAP.WETH.addresses[chainId];
const ethBalance = await this.getSigner(chainId).getBalance();
if (ethBalance.gt(threshold)) {
const l2Signer = this.getSigner(chainId);
Expand Down
10 changes: 5 additions & 5 deletions src/utils/AddressUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TOKEN_SYMBOLS_MAP } from "@across-protocol/contracts-v2";
import { constants } from "@across-protocol/sdk-v2";
import { BigNumber, ethers } from ".";

export function compareAddresses(addressA: string, addressB: string): 1 | -1 | 0 {
Expand Down Expand Up @@ -28,7 +28,7 @@ export function compareAddressesSimple(addressA: string, addressB: string): bool
*/
export function matchTokenSymbol(tokenAddress: string, chainId: number): string[] {
// We can match one l1 token address on multiple symbols in some special cases, like ETH/WETH.
return Object.values(TOKEN_SYMBOLS_MAP)
return Object.values(constants.TOKEN_SYMBOLS_MAP)
.filter(({ addresses }) => addresses[chainId]?.toLowerCase() === tokenAddress.toLowerCase())
.map(({ symbol }) => symbol);
}
Expand All @@ -39,7 +39,7 @@ export function matchTokenSymbol(tokenAddress: string, chainId: number): string[
* @returns The number of ERC20 decimals configured for the requested token.
*/
export function resolveTokenDecimals(tokenSymbol: string): number {
const decimals = TOKEN_SYMBOLS_MAP[tokenSymbol]?.decimals;
const decimals = constants.TOKEN_SYMBOLS_MAP[tokenSymbol]?.decimals;
if (decimals === undefined) {
throw new Error(`Unrecognized token symbol: ${tokenSymbol}`);
}
Expand All @@ -53,7 +53,7 @@ export function resolveTokenDecimals(tokenSymbol: string): number {
* @returns The token symbols for the given token addresses and chain ID. Undefined symbols are filtered out.
*/
export function resolveTokenSymbols(tokenAddresses: string[], chainId: number): string[] {
const tokenSymbols = Object.values(TOKEN_SYMBOLS_MAP);
const tokenSymbols = Object.values(constants.TOKEN_SYMBOLS_MAP);
return tokenAddresses
.map((tokenAddress) => {
return tokenSymbols.find(({ addresses }) => addresses[chainId]?.toLowerCase() === tokenAddress.toLowerCase())
Expand All @@ -64,7 +64,7 @@ export function resolveTokenSymbols(tokenAddresses: string[], chainId: number):

export function getTokenAddress(tokenAddress: string, chainId: number, targetChainId: number): string {
const tokenSymbol = resolveTokenSymbols([tokenAddress], chainId)[0];
const targetAddress = TOKEN_SYMBOLS_MAP[tokenSymbol]?.addresses[targetChainId];
const targetAddress = constants.TOKEN_SYMBOLS_MAP[tokenSymbol]?.addresses[targetChainId];
if (!targetAddress) {
throw new Error(`Could not resolve token address for token symbol ${tokenSymbol} on chain ${targetChainId}`);
}
Expand Down
48 changes: 19 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
"@uma/common" "^2.17.0"
hardhat "^2.9.3"

"@across-protocol/contracts-v2@2.4.3", "@across-protocol/contracts-v2@^2.4.3":
version "2.4.3"
resolved "https://registry.yarnpkg.com/@across-protocol/contracts-v2/-/contracts-v2-2.4.3.tgz#9cc0b1f52b4f819b32ca1524ef84af9dfed8687a"
integrity sha512-NT5zBhTMYk7jUgZ6Q+xXz0p3ukXth8F6lBTiNCIrrzFSBl5JLVrhk00+TIIIOfwtpGSiG+MGkKuwCOKWMhwOMg==
"@across-protocol/contracts-v2@2.4.4", "@across-protocol/contracts-v2@^2.4.4":
version "2.4.4"
resolved "https://registry.yarnpkg.com/@across-protocol/contracts-v2/-/contracts-v2-2.4.4.tgz#face03ecb7c9f3c2e3171996eb4af432a718dcef"
integrity sha512-6HVAXhff9GhIny0XfXQYHbaply+sTG/hffaoN+/qygoX59wOduNdokjicV095tDOgVqoVEFpI8m3P/fMM08bcw==
dependencies:
"@defi-wonderland/smock" "^2.3.4"
"@eth-optimism/contracts" "^0.5.40"
"@ethersproject/abstract-provider" "5.7.0"
"@ethersproject/abstract-signer" "5.7.0"
"@ethersproject/bignumber" "5.7.0"
"@openzeppelin/contracts" "4.9.2"
"@openzeppelin/contracts-upgradeable" "4.9.2"
"@openzeppelin/contracts" "4.9.3"
"@openzeppelin/contracts-upgradeable" "4.9.3"
"@uma/common" "^2.34.0"
"@uma/contracts-node" "^0.4.17"
"@uma/core" "^2.56.0"
Expand All @@ -37,13 +37,13 @@
"@openzeppelin/contracts" "4.1.0"
"@uma/core" "^2.18.0"

"@across-protocol/sdk-v2@0.16.4":
version "0.16.4"
resolved "https://registry.yarnpkg.com/@across-protocol/sdk-v2/-/sdk-v2-0.16.4.tgz#89ef2dc46fae9647ed46fda50a4de270f925f68e"
integrity sha512-mpPYiW4Kb2uQXmPOmsnCqer/iSuRuixSJM91svIxwA2z3kw1xk57G94LeVSufFPzVD/5urUS/sYm7Ea0z75WSw==
"@across-protocol/sdk-v2@0.16.5":
version "0.16.5"
resolved "https://registry.yarnpkg.com/@across-protocol/sdk-v2/-/sdk-v2-0.16.5.tgz#081b0f449aa5b7d2276e2695ad25c0e60821a554"
integrity sha512-hF1c0DH94xLpm9oAbW2Fnol+imKlaN22XbDL4MDPSfHElsqgC2fXWo5OUv9+lP8kr+XAv7zljd3u2IZ+20u5wQ==
dependencies:
"@across-protocol/across-token" "^1.0.0"
"@across-protocol/contracts-v2" "^2.4.3"
"@across-protocol/contracts-v2" "^2.4.4"
"@eth-optimism/sdk" "^2.1.0"
"@pinata/sdk" "^2.1.0"
"@uma/sdk" "^0.34.1"
Expand Down Expand Up @@ -2061,21 +2061,16 @@
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.7.3.tgz#f1d606e2827d409053f3e908ba4eb8adb1dd6995"
integrity sha512-+wuegAMaLcZnLCJIvrVUDzA9z/Wp93f0Dla/4jJvIhijRrPabjQbZe6fWiECLaJyfn5ci9fqf9vTw3xpQOad2A==

"@openzeppelin/contracts-upgradeable@4.9.2":
version "4.9.2"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.9.2.tgz#a817c75688f8daede420052fbcb34e52482e769e"
integrity sha512-siviV3PZV/fHfPaoIC51rf1Jb6iElkYWnNYZ0leO23/ukXuvOyoC/ahy8jqiV7g+++9Nuo3n/rk5ajSN/+d/Sg==
"@openzeppelin/contracts-upgradeable@4.9.3", "@openzeppelin/contracts-upgradeable@^4.8.1":
version "4.9.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.9.3.tgz#ff17a80fb945f5102571f8efecb5ce5915cc4811"
integrity sha512-jjaHAVRMrE4UuZNfDwjlLGDxTHWIOwTJS2ldnc278a0gevfXfPr8hxKEVBGFBE96kl2G3VHDZhUimw/+G3TG2A==

"@openzeppelin/contracts-upgradeable@^4.2.0":
version "4.8.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.8.3.tgz#6b076a7b751811b90fe3a172a7faeaa603e13a3f"
integrity sha512-SXDRl7HKpl2WDoJpn7CK/M9U4Z8gNXDHHChAKh0Iz+Wew3wu6CmFYBeie3je8V0GSXZAIYYwUktSrnW/kwVPtg==

"@openzeppelin/contracts-upgradeable@^4.8.1":
version "4.9.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.9.3.tgz#ff17a80fb945f5102571f8efecb5ce5915cc4811"
integrity sha512-jjaHAVRMrE4UuZNfDwjlLGDxTHWIOwTJS2ldnc278a0gevfXfPr8hxKEVBGFBE96kl2G3VHDZhUimw/+G3TG2A==

"@openzeppelin/contracts@3.4.1-solc-0.7-2":
version "3.4.1-solc-0.7-2"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-3.4.1-solc-0.7-2.tgz#371c67ebffe50f551c3146a9eec5fe6ffe862e92"
Expand All @@ -2096,21 +2091,16 @@
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.7.3.tgz#939534757a81f8d69cc854c7692805684ff3111e"
integrity sha512-dGRS0agJzu8ybo44pCIf3xBaPQN/65AIXNgK8+4gzKd5kbvlqyxryUYVLJv7fK98Seyd2hDZzVEHSWAh0Bt1Yw==

"@openzeppelin/contracts@4.9.2":
version "4.9.2"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.2.tgz#1cb2d5e4d3360141a17dbc45094a8cad6aac16c1"
integrity sha512-mO+y6JaqXjWeMh9glYVzVu8HYPGknAAnWyxTRhGeckOruyXQMNnlcW6w/Dx9ftLeIQk6N+ZJFuVmTwF7lEIFrg==
"@openzeppelin/contracts@4.9.3", "@openzeppelin/contracts@^4.8.1":
version "4.9.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.3.tgz#00d7a8cf35a475b160b3f0293a6403c511099364"
integrity sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg==

"@openzeppelin/contracts@^4.2.0", "@openzeppelin/contracts@^4.3.2", "@openzeppelin/contracts@^4.7.3":
version "4.8.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.3.tgz#cbef3146bfc570849405f59cba18235da95a252a"
integrity sha512-bQHV8R9Me8IaJoJ2vPG4rXcL7seB7YVuskr4f+f5RyOStSZetwzkWtoqDMl5erkBJy0lDRUnIR2WIkPiC0GJlg==

"@openzeppelin/contracts@^4.8.1":
version "4.9.3"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.3.tgz#00d7a8cf35a475b160b3f0293a6403c511099364"
integrity sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg==

"@openzeppelin/defender-base-client@^1.46.0":
version "1.46.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/defender-base-client/-/defender-base-client-1.46.0.tgz#aa5177f8fbad23fd03d78f3dbe06664bbe9333ff"
Expand Down

0 comments on commit 676f223

Please sign in to comment.