-
Notifications
You must be signed in to change notification settings - Fork 56
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: superseed deployment #716
Open
bmzig
wants to merge
6
commits into
audit-latest
Choose a base branch
from
bz/superseed
base: audit-latest
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3421788
feat: superseed deployment
bmzig 2925cc3
bump package
bmzig 1d9505a
remove incorrect multicall handler deployment
bmzig f4da713
public superseed RPC
bmzig 0e81625
make comments general
bmzig bce40bf
add hardhat info
bmzig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
import "@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol"; | ||
|
||
import "./Ovm_SpokePool.sol"; | ||
import "./external/interfaces/CCTPInterfaces.sol"; | ||
import { IOpUSDCBridgeAdapter } from "./external/interfaces/IOpUSDCBridgeAdapter.sol"; | ||
|
||
/** | ||
* @notice Superseed Spoke pool. | ||
* @custom:security-contact [email protected] | ||
*/ | ||
contract Superseed_SpokePool is Ovm_SpokePool { | ||
using SafeERC20 for IERC20; | ||
|
||
// Address of the custom L2 USDC bridge. | ||
address private constant USDC_BRIDGE = 0x88259017B7271EfbCA33cE6Fd2D9EDD9C2b2d995; | ||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor( | ||
address _wrappedNativeTokenAddress, | ||
uint32 _depositQuoteTimeBuffer, | ||
uint32 _fillDeadlineBuffer, | ||
IERC20 _l2Usdc, | ||
ITokenMessenger _cctpTokenMessenger | ||
) | ||
Ovm_SpokePool( | ||
_wrappedNativeTokenAddress, | ||
_depositQuoteTimeBuffer, | ||
_fillDeadlineBuffer, | ||
_l2Usdc, | ||
_cctpTokenMessenger | ||
) | ||
{} // solhint-disable-line no-empty-blocks | ||
|
||
/** | ||
* @notice Construct the OVM Superseed SpokePool. | ||
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate | ||
* relay hash collisions. | ||
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin. | ||
* @param _hubPool Hub pool address to set. Can be changed by admin. | ||
*/ | ||
function initialize( | ||
uint32 _initialDepositId, | ||
address _crossDomainAdmin, | ||
address _hubPool | ||
) public initializer { | ||
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, Lib_PredeployAddresses.OVM_ETH); | ||
} | ||
|
||
/** | ||
* @notice Superseed-specific logic to bridge tokens back to the hub pool contract on L1. | ||
* @param amountToReturn Amount of the token to bridge back. | ||
* @param l2TokenAddress Address of the l2 Token to bridge back. This token will either be bridged back to the token defined in the mapping `remoteL1Tokens`, | ||
* or via the canonical mapping defined in the bridge contract retrieved from `tokenBridges`. | ||
* @dev This implementation deviates slightly from `_bridgeTokensToHubPool` in the `Ovm_SpokePool` contract since Superseed has a USDC bridge which uses | ||
* a custom interface. This is because the USDC token on Superseed is meant to be upgraded to a native, CCTP supported version in the future. | ||
*/ | ||
function _bridgeTokensToHubPool(uint256 amountToReturn, address l2TokenAddress) internal virtual override { | ||
// Handle custom USDC bridge which doesn't conform to the standard bridge interface. In the future, CCTP may be used to bridge USDC to mainnet, in which | ||
// case bridging logic is handled by the Ovm_SpokePool code. In the meantime, if CCTP is not enabled, then use the USDC bridge. Once CCTP is activated on | ||
// Superseed, this block of code will be unused. | ||
if (l2TokenAddress == address(usdcToken) && !_isCCTPEnabled()) { | ||
usdcToken.safeIncreaseAllowance(USDC_BRIDGE, amountToReturn); | ||
IOpUSDCBridgeAdapter(USDC_BRIDGE).sendMessage( | ||
hubPool, // _to. Withdraw, over the bridge, to the l1 hub pool contract. | ||
amountToReturn, // _amount. | ||
l1Gas // _minGasLimit. Same value used in other OpStack bridges. | ||
); | ||
} else super._bridgeTokensToHubPool(amountToReturn, l2TokenAddress); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
import { L1_ADDRESS_MAP, USDC, WETH } from "./consts"; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { deployer } = await hre.getNamedAccounts(); | ||
const chainId = parseInt(await hre.getChainId()); | ||
|
||
await hre.deployments.deploy("OP_Adapter", { | ||
from: deployer, | ||
log: true, | ||
skipIfAlreadyDeployed: true, | ||
args: [ | ||
WETH[chainId], | ||
USDC[chainId], | ||
L1_ADDRESS_MAP[chainId].superseedCrossDomainMessenger, | ||
L1_ADDRESS_MAP[chainId].superseedStandardBridge, | ||
L1_ADDRESS_MAP[chainId].superseedOpUSDCBridge, | ||
], | ||
}); | ||
}; | ||
|
||
module.exports = func; | ||
func.tags = ["SuperseedAdapter", "mainnet"]; |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre"; | ||
import { FILL_DEADLINE_BUFFER, WETH, QUOTE_TIME_BUFFER, ZERO_ADDRESS, USDCe } from "./consts"; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre); | ||
|
||
const initArgs = [ | ||
1, | ||
// Set hub pool as cross domain admin since it delegatecalls the Adapter logic. | ||
hubPool.address, | ||
hubPool.address, | ||
]; | ||
const constructorArgs = [ | ||
WETH[spokeChainId], | ||
QUOTE_TIME_BUFFER, | ||
FILL_DEADLINE_BUFFER, | ||
// Superseed's bridged USDC is upgradeable to native. There are not two different | ||
// addresses for bridges/native USDC. This address is also used in the spoke pool | ||
// to determine whether to use CCTP (in the future) or the custom USDC bridge. | ||
USDCe[spokeChainId], | ||
// L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger, | ||
// For now, we are not using the CCTP bridge and can disable by setting | ||
// the cctpTokenMessenger to the zero address. | ||
ZERO_ADDRESS, | ||
]; | ||
await deployNewProxy("Superseed_SpokePool", constructorArgs, initArgs); | ||
}; | ||
module.exports = func; | ||
func.tags = ["SuperseedSpokePool", "superseed"]; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5330 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might be able to drop this one in anticipation of #714 being merged.