Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
21 changes: 21 additions & 0 deletions contracts/Boba_SpokePool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.0;

import "./Optimism_SpokePool.sol";

/**
* @notice Boba Spoke pool. Exact copy of the Optimism_SpokePool with no modifications.
*/
contract Boba_SpokePool is Optimism_SpokePool {
/**
* @notice Construct the OVM Boba SpokePool.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param timerAddress Timer address to set.
*/
constructor(
address _crossDomainAdmin,
address _hubPool,
address timerAddress
) Optimism_SpokePool(_crossDomainAdmin, _hubPool, timerAddress) {}
}
1 change: 1 addition & 0 deletions contracts/PolygonTokenBridger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ contract PolygonTokenBridger is Lockable {
* @param _l1PolygonRegistry L1 registry that stores updated addresses of polygon contracts. This should always be
* set to the L1 registry regardless if whether it's deployed on L2 or L1.
* @param _l1Weth L1 WETH address.
* @param _l2WrappedMatic L2 address of wrapped matic token.
* @param _l1ChainId the chain id for the L1 in this environment.
* @param _l2ChainId the chain id for the L2 in this environment.
*/
Expand Down
83 changes: 83 additions & 0 deletions contracts/chain-adapters/Boba_Adapter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

import "../interfaces/AdapterInterface.sol";
import "../interfaces/WETH9.sol";

// @dev Use local modified CrossDomainEnabled contract instead of one exported by eth-optimism because we need
// this contract's state variables to be `immutable` because of the delegateCall call.
import "./CrossDomainEnabled.sol";
import "@eth-optimism/contracts/L1/messaging/IL1StandardBridge.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
* @notice Contract containing logic to send messages from L1 to Boba. This is a modified version of the Optimism adapter
* that excludes the custom bridging logic.
* @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be
* called via delegatecall, which will execute this contract's logic within the context of the originating contract.
* For example, the HubPool will delegatecall these functions, therefore its only necessary that the HubPool's methods
* that call this contract's logic guard against reentrancy.
*/

// solhint-disable-next-line contract-name-camelcase
contract Boba_Adapter is CrossDomainEnabled, AdapterInterface {
using SafeERC20 for IERC20;
uint32 public immutable l2GasLimit = 2_000_000;

WETH9 public immutable l1Weth;

IL1StandardBridge public immutable l1StandardBridge;

/**
* @notice Constructs new Adapter.
* @param _l1Weth WETH address on L1.
* @param _crossDomainMessenger XDomainMessenger Boba system contract.
* @param _l1StandardBridge Standard bridge contract.
*/
constructor(
WETH9 _l1Weth,
address _crossDomainMessenger,
IL1StandardBridge _l1StandardBridge
) CrossDomainEnabled(_crossDomainMessenger) {
l1Weth = _l1Weth;
l1StandardBridge = _l1StandardBridge;
}

/**
* @notice Send cross-chain message to target on Boba.
* @param target Contract on Boba that will receive message.
* @param message Data to send to target.
*/
function relayMessage(address target, bytes calldata message) external payable override {
sendCrossDomainMessage(target, uint32(l2GasLimit), message);
emit MessageRelayed(target, message);
}

/**
* @notice Bridge tokens to Boba.
* @param l1Token L1 token to deposit.
* @param l2Token L2 token to receive.
* @param amount Amount of L1 tokens to deposit and L2 tokens to receive.
* @param to Bridge recipient.
*/
function relayTokens(
address l1Token,
address l2Token,
uint256 amount,
address to
) external payable override {
// If the l1Token is weth then unwrap it to ETH then send the ETH to the standard bridge.
if (l1Token == address(l1Weth)) {
l1Weth.withdraw(amount);
l1StandardBridge.depositETHTo{ value: amount }(to, l2GasLimit, "");
} else {
IL1StandardBridge _l1StandardBridge = l1StandardBridge;

IERC20(l1Token).safeIncreaseAllowance(address(_l1StandardBridge), amount);
_l1StandardBridge.depositERC20To(l1Token, l2Token, to, amount, l2GasLimit, "");
}
emit TokensRelayed(l1Token, l2Token, amount, to);
}
}
1 change: 0 additions & 1 deletion deploy/001_deploy_hubpool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { L1_ADDRESS_MAP } from "./consts";

// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand Down
4 changes: 0 additions & 4 deletions deploy/002_deploy_optimism_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Cross Domain Messengers grabbed from
// https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts/deployments

import { L1_ADDRESS_MAP } from "./consts";

// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand Down
3 changes: 1 addition & 2 deletions deploy/003_deploy_optimism_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand All @@ -20,7 +19,7 @@ const func = async function (hre: HardhatRuntimeEnvironment) {
args: [
hubPool.address, // Set hub pool as cross domain admin since it delegatecalls the Optimism_Adapter logic.
hubPool.address,
"0x0000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000", // timer
],
});
};
Expand Down
3 changes: 0 additions & 3 deletions deploy/004_deploy_arbitrum_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// l1Arbitrum Inbox and L1ERC20 Gateway taken from: https://developer.offchainlabs.com/docs/public_testnet

import { L1_ADDRESS_MAP } from "./consts";

// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand Down
3 changes: 1 addition & 2 deletions deploy/005_deploy_arbitrum_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand Down Expand Up @@ -26,7 +25,7 @@ const func = async function (hre: HardhatRuntimeEnvironment) {
hubPool.address, // Set hub pool as cross domain admin since it delegatecalls the Optimism_Adapter logic.
hubPool.address,
L2_ADDRESS_MAP[chainId].l2Weth, // l2Weth
"0x0000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000", // timer
],
});
};
Expand Down
1 change: 0 additions & 1 deletion deploy/006_deploy_ethereum_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand Down
1 change: 0 additions & 1 deletion deploy/007_deploy_ethereum_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand Down
2 changes: 1 addition & 1 deletion deploy/008_deploy_polygon_token_bridger_mainnet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand All @@ -21,6 +20,7 @@ const func = async function (hre: HardhatRuntimeEnvironment) {
hubPool.address,
L1_ADDRESS_MAP[chainId].polygonRegistry,
L1_ADDRESS_MAP[chainId].weth,
L1_ADDRESS_MAP[chainId].l2WrappedMatic,
chainId,
POLYGON_CHAIN_IDS[chainId],
],
Expand Down
1 change: 0 additions & 1 deletion deploy/009_deploy_polygon_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand Down
2 changes: 1 addition & 1 deletion deploy/010_deploy_polygon_token_bridger_polygon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand All @@ -22,6 +21,7 @@ const func = async function (hre: HardhatRuntimeEnvironment) {
l1HubPool.address,
L1_ADDRESS_MAP[l1ChainId].polygonRegistry,
L1_ADDRESS_MAP[l1ChainId].weth,
L1_ADDRESS_MAP[l1ChainId].l2WrappedMatic,
l1ChainId,
chainId,
],
Expand Down
1 change: 0 additions & 1 deletion deploy/011_deploy_polygon_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand Down
28 changes: 28 additions & 0 deletions deploy/012_deploy_boba_adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { L1_ADDRESS_MAP } from "./consts";

import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

const func = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre;
const { deploy } = deployments;

const { deployer } = await getNamedAccounts();

const chainId = parseInt(await getChainId());

await deploy("Boba_Adapter", {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
args: [
L1_ADDRESS_MAP[chainId].weth,
L1_ADDRESS_MAP[chainId].bobaCrossDomainMessenger,
L1_ADDRESS_MAP[chainId].bobaStandardBridge,
],
});
};

module.exports = func;
func.dependencies = ["HubPool"];
func.tags = ["BobaAdapter", "mainnet"];
28 changes: 28 additions & 0 deletions deploy/013_deploy_boba_spokepool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

const func = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, companionNetworks } = hre;
const { deploy } = deployments;

const { deployer } = await getNamedAccounts();

// Grab L1 addresses:
const { deployments: l1Deployments } = companionNetworks.l1;
const hubPool = await l1Deployments.get("HubPool");
console.log(`Using l1 hub pool @ ${hubPool.address}`);

// Boba Spoke pool uses the same implementation as optimism, with no changes.
await deploy("Boba_SpokePool", {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
args: [
hubPool.address, // Set hub pool as cross domain admin since it delegatecalls the Optimism_Adapter logic.
hubPool.address,
"0x0000000000000000000000000000000000000000", // timer
],
});
};
module.exports = func;
func.tags = ["BobaSpokePool", "boba"];
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This import is needed to override the definition of the HardhatRuntimeEnvironment type.
import "hardhat-deploy";
import { HardhatRuntimeEnvironment } from "hardhat/types/runtime";

Expand All @@ -8,12 +7,12 @@ const func = async function (hre: HardhatRuntimeEnvironment) {

const { deployer } = await getNamedAccounts();

await deploy("RateModelStore", {
await deploy("AcrossConfigStore", {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
});
};

module.exports = func;
func.tags = ["RateModelStore", "mainnet"];
func.tags = ["AcrossConfigStore", "mainnet"];
15 changes: 10 additions & 5 deletions deploy/consts.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// Source: // https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts/deployments
// Note that L2 optimism addresses are deterministic and constant, so they usually don't need an
// address map like this.
export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string } } = {
1: {
optimismCrossDomainMessenger: "0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1",
weth: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
optimismCrossDomainMessenger: "0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1", // Source: https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts/deployments
optimismStandardBridge: "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1",
bobaCrossDomainMessenger: "0x6D4528d192dB72E282265D6092F4B872f9Dff69e",
bobaStandardBridge: "0xdc1664458d2f0B6090bEa60A8793A4E66c2F1c00",
weth: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
finder: "0x40f941E48A552bF496B154Af6bf55725f18D77c3",
l1ArbitrumInbox: "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f",
l1ERC20GatewayRouter: "0x72Ce9c846789fdB6fC1f34aC4AD25Dd9ef7031ef",
polygonRootChainManager: "0xA0c68C638235ee32657e8f720a23ceC1bFc77C77",
polygonFxRoot: "0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2",
polygonERC20Predicate: "0x40ec5B33f54e0E8A33A975908C5BA1c14e5BbbDf",
polygonRegistry: "0x33a02E6cC863D393d6Bf231B697b82F6e499cA71",
polygonDepositManager: "0x401F6c983eA34274ec46f84D70b31C151321188b",
matic: "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0",
l2WrappedMatic: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
},
4: {
weth: "0xc778417E063141139Fce010982780140Aa0cD5Ab",
Expand All @@ -25,6 +27,7 @@ export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
polygonRegistry: "0xeE11713Fe713b2BfF2942452517483654078154D", // Dummy: Polygon's testnet is goerli
polygonDepositManager: "0x7850ec290A2e2F40B82Ed962eaf30591bb5f5C96", // Dummy: Polygon's testnet is goerli
matic: "0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae", // Dummy: Polygon's testnet is goerli
l2WrappedMatic: "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", // Dummy: Polygon's testnet is goerli
},
5: {
optimismCrossDomainMessenger: "0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1", // dummy: Optimism's testnet is kovan
Expand All @@ -39,6 +42,7 @@ export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
polygonRegistry: "0xeE11713Fe713b2BfF2942452517483654078154D",
polygonDepositManager: "0x7850ec290A2e2F40B82Ed962eaf30591bb5f5C96",
matic: "0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae",
l2WrappedMatic: "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889",
},
42: {
l1ArbitrumInbox: "0x578BAde599406A8fE3d24Fd7f7211c0911F5B29e", // dummy: Arbitrum's testnet is rinkeby
Expand All @@ -53,6 +57,7 @@ export const L1_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
polygonRegistry: "0xeE11713Fe713b2BfF2942452517483654078154D", // Dummy: Polygon's testnet is goerli
polygonDepositManager: "0x7850ec290A2e2F40B82Ed962eaf30591bb5f5C96", // Dummy: Polygon's testnet is goerli
matic: "0x499d11E0b6eAC7c0593d8Fb292DCBbF815Fb29Ae", // Dummy: Polygon's testnet is goerli
l2WrappedMatic: "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", // Dummy: Polygon's testnet is goerli
},
};

Expand Down
41 changes: 41 additions & 0 deletions deployments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Across Mainnet Deployment Addresses
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewers! see this file


## Mainnet (1)

| Contract Name | Address |
| ------------------- | --------------------------------------------------------------------------------------------------------------------- |
| LPTokenFactory | [0x7dB69eb9F52eD773E9b03f5068A1ea0275b2fD9d](https://etherscan.io/address/0x7dB69eb9F52eD773E9b03f5068A1ea0275b2fD9d) |
| HubPool | [0x6Bb9910c5529Cb3b32c4f0e13E8bC38F903b2534](https://etherscan.io/address/0x6Bb9910c5529Cb3b32c4f0e13E8bC38F903b2534) |
| Optimism_Adapter | [0x22eD83A9eE26236486F57cE8385A247E5bFB71fF](https://etherscan.io/address/0x22eD83A9eE26236486F57cE8385A247E5bFB71fF) |
| Boba_Adapter | [0x33B0Ec794c15D6Cc705818E70d4CaCe7bCfB5Af3](https://etherscan.io/address/0x33B0Ec794c15D6Cc705818E70d4CaCe7bCfB5Af3) |
| Arbitrum_Adapter | [0x937958992799bF4A9a656E6596FD10d7Da5c2216](https://etherscan.io/address/0x937958992799bF4A9a656E6596FD10d7Da5c2216) |
| Ethereum_Adapter | [0x527E872a5c3f0C7c24Fe33F2593cFB890a285084](https://etherscan.io/address/0x527E872a5c3f0C7c24Fe33F2593cFB890a285084) |
| Ethereum_SpokePool | [0x931A43528779034ac9eb77df799d133557406176](https://etherscan.io/address/0x931A43528779034ac9eb77df799d133557406176) |
| PolygonTokenBridger | [0x48d990AbDA20afa1fD1da713AbC041B60a922c65](https://etherscan.io/address/0x48d990AbDA20afa1fD1da713AbC041B60a922c65) |
| Polygon_Adapter | [0x3E94e8d4316a1eBfb2245E45E6F0B8724094CE1A](https://etherscan.io/address/0x3E94e8d4316a1eBfb2245E45E6F0B8724094CE1A) |
| AcrossConfigStore | [0x3B03509645713718B78951126E0A6de6f10043f5](https://etherscan.io/address/0x3B03509645713718B78951126E0A6de6f10043f5) |

## Optimism mainnet (10)

| Contract Name | Address |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| Optimism_SpokePool | [0x59485d57EEcc4058F7831f46eE83a7078276b4AE](https://optimistic.etherscan.io/address/0x59485d57EEcc4058F7831f46eE83a7078276b4AE) |

## Polygon mainnet(137)

| Contract Name | Address |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| PolygonTokenBridger | [0x48d990AbDA20afa1fD1da713AbC041B60a922c65](https://polygonscan.com/address/0x48d990AbDA20afa1fD1da713AbC041B60a922c65) |
| Polygon_SpokePool | [0xD3ddAcAe5aFb00F9B9cD36EF0Ed7115d7f0b584c](https://polygonscan.com/address/0xD3ddAcAe5aFb00F9B9cD36EF0Ed7115d7f0b584c) |

## Boba mainnet (288)

| Contract Name | Address |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Boba_SpokePool | [0x7229405a2f0c550Ce35182EE1658302B65672443](https://blockexplorer.boba.network/address/0x7229405a2f0c550Ce35182EE1658302B65672443/contracts) |

## Arbitrum mainnet (42161)

| Contract Name | Address |
| ------------------ | -------------------------------------------------------------------------------------------------------------------- |
| Arbitrum_SpokePool | [0xe1C367e2b576Ac421a9f46C9cC624935730c36aa](https://arbiscan.io/address/0xe1C367e2b576Ac421a9f46C9cC624935730c36aa) |
1 change: 1 addition & 0 deletions deployments/arbitrum/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42161
Loading