Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support Zora #1731

Merged
merged 10 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"node": ">=20"
},
"dependencies": {
"@across-protocol/constants": "^3.1.11",
"@across-protocol/contracts": "^3.0.6",
"@across-protocol/sdk": "^3.1.14",
"@across-protocol/constants": "^3.1.13",
"@across-protocol/contracts": "^3.0.8",
pxrl marked this conversation as resolved.
Show resolved Hide resolved
"@across-protocol/sdk": "^3.1.17",
"@arbitrum/sdk": "^3.1.3",
"@consensys/linea-sdk": "^0.2.1",
"@defi-wonderland/smock": "^2.3.5",
Expand Down
11 changes: 10 additions & 1 deletion src/clients/bridges/AdapterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class AdapterManager {
);
};

const { OPTIMISM, ARBITRUM, POLYGON, ZK_SYNC, BASE, MODE, LINEA, LISK, BLAST, SCROLL } = CHAIN_IDs;
const { OPTIMISM, ARBITRUM, POLYGON, ZK_SYNC, BASE, MODE, LINEA, LISK, BLAST, SCROLL, ZORA } = CHAIN_IDs;
if (this.spokePoolClients[OPTIMISM] !== undefined) {
this.adapters[OPTIMISM] = new OpStackAdapter(
OPTIMISM,
Expand Down Expand Up @@ -100,6 +100,15 @@ export class AdapterManager {
if (this.spokePoolClients[SCROLL] !== undefined) {
this.adapters[SCROLL] = new ScrollAdapter(logger, spokePoolClients, filterMonitoredAddresses(SCROLL));
}
if (this.spokePoolClients[ZORA] !== undefined) {
this.adapters[ZORA] = new OpStackAdapter(
ZORA,
logger,
SUPPORTED_TOKENS[ZORA],
spokePoolClients,
filterMonitoredAddresses(ZORA)
);
}

logger.debug({
at: "AdapterManager#constructor",
Expand Down
18 changes: 18 additions & 0 deletions src/common/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const DATAWORKER_FAST_LOOKBACK: { [chainId: number]: number } = {
[CHAIN_IDs.POLYGON]: 138240,
[CHAIN_IDs.SCROLL]: 115200, // 4 * 24 * 20 * 60,
[CHAIN_IDs.ZK_SYNC]: 345600, // 4 * 24 * 60 * 60,
[CHAIN_IDs.ZORA]: 172800, // OP stack
};

// Target ~14 days per chain. Should cover all events that could be finalized, so 2x the optimistic
Expand Down Expand Up @@ -83,6 +84,7 @@ export const MIN_DEPOSIT_CONFIRMATIONS: { [threshold: number | string]: { [chain
[CHAIN_IDs.POLYGON]: 128, // Commonly used finality level for CEX's that accept Polygon deposits
[CHAIN_IDs.SCROLL]: 30,
[CHAIN_IDs.ZK_SYNC]: 120,
[CHAIN_IDs.ZORA]: 120,
},
1000: {
[CHAIN_IDs.ARBITRUM]: 0,
Expand All @@ -96,6 +98,7 @@ export const MIN_DEPOSIT_CONFIRMATIONS: { [threshold: number | string]: { [chain
[CHAIN_IDs.POLYGON]: 100, // Probabilistically safe level based on historic Polygon reorgs
[CHAIN_IDs.SCROLL]: 1,
[CHAIN_IDs.ZK_SYNC]: 0,
[CHAIN_IDs.ZORA]: 60,
},
100: {
[CHAIN_IDs.ARBITRUM]: 0,
Expand All @@ -109,6 +112,7 @@ export const MIN_DEPOSIT_CONFIRMATIONS: { [threshold: number | string]: { [chain
[CHAIN_IDs.POLYGON]: 80,
[CHAIN_IDs.SCROLL]: 1,
[CHAIN_IDs.ZK_SYNC]: 0,
[CHAIN_IDs.ZORA]: 60,
},
};

Expand All @@ -132,6 +136,7 @@ export const CHAIN_MAX_BLOCK_LOOKBACK = {
[CHAIN_IDs.POLYGON]: 10000,
[CHAIN_IDs.SCROLL]: 10000,
[CHAIN_IDs.ZK_SYNC]: 10000,
[CHAIN_IDs.ZORA]: 10000,
// Testnets:
[CHAIN_IDs.ARBITRUM_SEPOLIA]: 10000,
[CHAIN_IDs.BASE_SEPOLIA]: 10000,
Expand Down Expand Up @@ -160,6 +165,7 @@ export const BUNDLE_END_BLOCK_BUFFERS = {
[CHAIN_IDs.POLYGON]: 128, // 2s/block. Polygon reorgs often so this number is set larger than the largest observed reorg.
[CHAIN_IDs.SCROLL]: 40, // ~3s/block
[CHAIN_IDs.ZK_SYNC]: 120, // ~1s/block. ZkSync is a centralized sequencer but is relatively unstable so this is kept higher than 0
[CHAIN_IDs.ZORA]: 60, // 2s/block
// Testnets:
[CHAIN_IDs.ARBITRUM_SEPOLIA]: 0,
[CHAIN_IDs.BASE_SEPOLIA]: 0,
Expand Down Expand Up @@ -202,6 +208,7 @@ export const CHAIN_CACHE_FOLLOW_DISTANCE: { [chainId: number]: number } = {
[CHAIN_IDs.POLYGON]: 256,
[CHAIN_IDs.SCROLL]: 100,
[CHAIN_IDs.ZK_SYNC]: 512,
[CHAIN_IDs.ZORA]: 120,
// Testnets:
[CHAIN_IDs.ARBITRUM_SEPOLIA]: 0,
[CHAIN_IDs.BASE_SEPOLIA]: 0,
Expand Down Expand Up @@ -229,6 +236,7 @@ export const DEFAULT_NO_TTL_DISTANCE: { [chainId: number]: number } = {
[CHAIN_IDs.POLYGON]: 86400,
[CHAIN_IDs.SCROLL]: 57600,
[CHAIN_IDs.ZK_SYNC]: 172800,
[CHAIN_IDs.ZORA]: 86400,
};

// Reasonable default maxFeePerGas and maxPriorityFeePerGas scalers for each chain.
Expand All @@ -241,6 +249,7 @@ export const DEFAULT_GAS_FEE_SCALERS: {
[CHAIN_IDs.MAINNET]: { maxFeePerGasScaler: 3, maxPriorityFeePerGasScaler: 1.2 },
[CHAIN_IDs.MODE]: { maxFeePerGasScaler: 2, maxPriorityFeePerGasScaler: 0.01 },
[CHAIN_IDs.OPTIMISM]: { maxFeePerGasScaler: 2, maxPriorityFeePerGasScaler: 0.01 },
[CHAIN_IDs.ZORA]: { maxFeePerGasScaler: 2, maxPriorityFeePerGasScaler: 0.01 },
};

// This is how many seconds stale the block number can be for us to use it for evaluating the reorg distance in the cache provider.
Expand All @@ -263,6 +272,7 @@ export const multicall3Addresses = {
[CHAIN_IDs.POLYGON]: "0xcA11bde05977b3631167028862bE2a173976CA11",
[CHAIN_IDs.SCROLL]: "0xcA11bde05977b3631167028862bE2a173976CA11",
[CHAIN_IDs.ZK_SYNC]: "0xF9cda624FBC7e059355ce98a31693d299FACd963",
[CHAIN_IDs.ZORA]: "0xcA11bde05977b3631167028862bE2a173976CA11",
// Testnet:
[CHAIN_IDs.POLYGON_AMOY]: "0xcA11bde05977b3631167028862bE2a173976CA11",
[CHAIN_IDs.BASE_SEPOLIA]: "0xcA11bde05977b3631167028862bE2a173976CA11",
Expand All @@ -288,6 +298,7 @@ export const spokesThatHoldEthAndWeth = [
CHAIN_IDs.OPTIMISM,
CHAIN_IDs.SCROLL,
CHAIN_IDs.ZK_SYNC,
CHAIN_IDs.ZORA,
];

/**
Expand Down Expand Up @@ -321,6 +332,7 @@ export const SUPPORTED_TOKENS: { [chainId: number]: string[] } = {
[CHAIN_IDs.POLYGON]: ["USDC", "USDT", "WETH", "DAI", "WBTC", "UMA", "BAL", "ACX", "POOL"],
[CHAIN_IDs.SCROLL]: ["WETH", "USDC", "USDT", "WBTC"],
[CHAIN_IDs.ZK_SYNC]: ["USDC", "USDT", "WETH", "WBTC", "DAI"],
[CHAIN_IDs.ZORA]: ["USDC", "WETH"],

// Testnets:
[CHAIN_IDs.ARBITRUM_SEPOLIA]: ["USDC", "USDT", "WETH", "DAI", "WBTC", "UMA", "ACX"],
Expand Down Expand Up @@ -371,6 +383,7 @@ export const CANONICAL_BRIDGE: {
[CHAIN_IDs.POLYGON]: PolygonERC20Bridge,
[CHAIN_IDs.SCROLL]: ScrollERC20Bridge,
[CHAIN_IDs.ZK_SYNC]: ZKSyncBridge,
[CHAIN_IDs.ZORA]: OpStackDefaultERC20Bridge,
};

// Custom Bridges are all bridges between chains which only support a small number (typically one) of tokens.
Expand Down Expand Up @@ -422,6 +435,9 @@ export const CUSTOM_BRIDGE: {
[CHAIN_IDs.ZK_SYNC]: {
[TOKEN_SYMBOLS_MAP.WETH.addresses[CHAIN_IDs.MAINNET]]: ZKSyncWethBridge,
},
[CHAIN_IDs.ZORA]: {
[TOKEN_SYMBOLS_MAP.WETH.addresses[CHAIN_IDs.MAINNET]]: OpStackWethBridge,
},
};

// Path to the external SpokePool indexer. Must be updated if src/libexec/* files are relocated or if the `outputDir` on TSC has been modified.
Expand Down Expand Up @@ -480,6 +496,7 @@ export const EXPECTED_L1_TO_L2_MESSAGE_TIME = {
[CHAIN_IDs.POLYGON]: 60 * 60,
[CHAIN_IDs.SCROLL]: 60 * 60,
[CHAIN_IDs.ZK_SYNC]: 60 * 60,
[CHAIN_IDs.ZORA]: 20 * 60,
};

export const OPSTACK_CONTRACT_OVERRIDES = {
Expand Down Expand Up @@ -523,4 +540,5 @@ export const DEFAULT_GAS_MULTIPLIER: { [chainId: number]: number } = {
[CHAIN_IDs.OPTIMISM]: 1.5,
[CHAIN_IDs.BASE]: 1.5,
[CHAIN_IDs.MODE]: 1.5,
[CHAIN_IDs.ZORA]: 1.5,
};
14 changes: 14 additions & 0 deletions src/common/ContractAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CHAIN_IDs } from "../utils";
import CCTP_MESSAGE_TRANSMITTER_ABI from "./abi/CctpMessageTransmitter.json";
import CCTP_TOKEN_MESSENGER_ABI from "./abi/CctpTokenMessenger.json";
import ATOMIC_DEPOSITOR_ABI from "./abi/AtomicDepositor.json";
Expand Down Expand Up @@ -96,6 +97,10 @@ export const CONTRACT_ADDRESSES: {
address: "0x697402166Fbf2F22E970df8a6486Ef171dbfc524",
abi: OVM_L1_STANDARD_BRIDGE_ABI,
},
ovmStandardBridge_7777777: {
address: "0xbF6acaF315477b15D638bf4d91eA48FA79b58335",
bmzig marked this conversation as resolved.
Show resolved Hide resolved
abi: OVM_L1_STANDARD_BRIDGE_ABI,
},
polygonRootChainManager: {
address: "0xA0c68C638235ee32657e8f720a23ceC1bFc77C77",
abi: POLYGON_ROOT_CHAIN_MANAGER_ABI,
Expand Down Expand Up @@ -297,6 +302,15 @@ export const CONTRACT_ADDRESSES: {
address: "0x0000000000000000000000000000000000000000",
},
},
[CHAIN_IDs.ZORA]: {
ovmStandardBridge: {
address: "0x4200000000000000000000000000000000000010",
abi: OVM_L2_STANDARD_BRIDGE_ABI,
},
eth: {
address: "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000",
},
},
// Testnets
11155111: {
cctpMessageTransmitter: {
Expand Down
35 changes: 15 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,10 @@
"@uma/common" "^2.17.0"
hardhat "^2.9.3"

"@across-protocol/constants@^3.1.11":
version "3.1.11"
resolved "https://registry.yarnpkg.com/@across-protocol/constants/-/constants-3.1.11.tgz#8a55347fd058e1bfad6320f69f13eb5a06399bc6"
integrity sha512-AevN1x1acJVbi6zlH6M8eEKqzANO+H7nfLCChXlrS5vZi8QINs9RvSZX/U/j0UDW1tCbEKszKZcnL1ZM+Pgb0A==

"@across-protocol/constants@^3.1.9":
version "3.1.10"
resolved "https://registry.yarnpkg.com/@across-protocol/constants/-/constants-3.1.10.tgz#37d4f391dc68719c224634073dc8e1ef0445b75d"
integrity sha512-sG1QXVIZAMFsxURMz8U0ZJ2dfX72yjnE/0OGJTcDNcPvuK0MMDU9mFdSZWBtMwIxt0UZSIG/A5059UstT7+Cfg==
"@across-protocol/constants@^3.1.13":
version "3.1.13"
resolved "https://registry.yarnpkg.com/@across-protocol/constants/-/constants-3.1.13.tgz#b4caf494e9d9fe50290cca91b7883ea408fdb90a"
integrity sha512-EsTJgQL5p+XXs40aBxOSbMOpQr/f4ty+Iyget8Oh6MT/cncCa2+W8a78fbqYqTtSpH6Sm7E8nvT8gPuSS6ef1w==

"@across-protocol/contracts@^0.1.4":
version "0.1.4"
Expand All @@ -30,12 +25,12 @@
"@openzeppelin/contracts" "4.1.0"
"@uma/core" "^2.18.0"

"@across-protocol/contracts@^3.0.6":
version "3.0.6"
resolved "https://registry.yarnpkg.com/@across-protocol/contracts/-/contracts-3.0.6.tgz#7508fc52db50cfa670edc7c4e9e615ad25cdd56c"
integrity sha512-hN/Qbg3YlZyVnJfqhK97WJHlvUv2Agncm0eaLOPlRy++CZ1rP++cDWPa2souE8iYEl0APj1c4U4REe8qSw9zlA==
"@across-protocol/contracts@^3.0.8":
version "3.0.8"
resolved "https://registry.yarnpkg.com/@across-protocol/contracts/-/contracts-3.0.8.tgz#ec9f72584048e5db3ee3a4dc5e214561101a5ffb"
integrity sha512-JG3Jt+itG+f9ZcUK1K/SFy6xlmCjCxsf99+Ffp11rPN6FUvDNgscRCoizLlBmibzRbXkR6r6r5F2iPbIPX/gxw==
dependencies:
"@across-protocol/constants" "^3.1.9"
"@across-protocol/constants" "^3.1.13"
"@defi-wonderland/smock" "^2.3.4"
"@eth-optimism/contracts" "^0.5.40"
"@ethersproject/abstract-provider" "5.7.0"
Expand All @@ -50,14 +45,14 @@
axios "^1.6.2"
zksync-web3 "^0.14.3"

"@across-protocol/sdk@^3.1.14":
version "3.1.14"
resolved "https://registry.yarnpkg.com/@across-protocol/sdk/-/sdk-3.1.14.tgz#511bba54fcc26daaeeafecf7418f18ef1cc845d9"
integrity sha512-qLq3C8SJnZb5r3n2YBNXDQekgwVw06oRjpGmm3lsZq76kiTtTvb8v5E6nnZEYAbqxCnVJOk5f0GyGxfUzLsCaw==
"@across-protocol/sdk@^3.1.17":
version "3.1.17"
resolved "https://registry.yarnpkg.com/@across-protocol/sdk/-/sdk-3.1.17.tgz#492e4e734015a5c8473674b69b2878162fd467f6"
integrity sha512-szc8o3sEcfRlP2K6vQ2Jl9YhEMjS8Ckt/xpj8/R5fY3f46su553kucoxBEe3kUq7P9J9aqgQu1RSvPR1q9gfeA==
dependencies:
"@across-protocol/across-token" "^1.0.0"
"@across-protocol/constants" "^3.1.11"
"@across-protocol/contracts" "^3.0.6"
"@across-protocol/constants" "^3.1.13"
"@across-protocol/contracts" "^3.0.8"
"@eth-optimism/sdk" "^3.3.1"
"@pinata/sdk" "^2.1.0"
"@types/mocha" "^10.0.1"
Expand Down