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(ink): configure and deploy Ink contracts #808

Merged
merged 15 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ module.exports = {
"node/no-unsupported-features/es-syntax": ["error", { ignores: ["modules"] }],
"mocha/no-exclusive-tests": "error",
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/naming-convention": "none",
},
};
72 changes: 72 additions & 0 deletions contracts/Ink_SpokePool.sol
james-a-morris marked this conversation as resolved.
Show resolved Hide resolved
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 Ink Spoke pool.
* @custom:security-contact [email protected]
*/
contract Ink_SpokePool is Ovm_SpokePool {
using SafeERC20 for IERC20;

// Address of the custom L2 USDC bridge.
address private constant USDC_BRIDGE = address(0);

/// @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 World Chain SpokePool.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably just drop any chain-specific mentions here; they just cause unnecessary changes on each deployment.

Suggested change
* @notice Construct the OVM World Chain SpokePool.
* @notice Construct the 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 _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _withdrawalRecipient
) public initializer {
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient, Lib_PredeployAddresses.OVM_ETH);
}

/**
* @notice Ink-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 World Chain has a USDC bridge which uses
* a custom interface. This is because the USDC token on World Chain is meant to be upgraded to a native, CCTP supported version in the future.
Comment on lines +56 to +57
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @dev This implementation deviates slightly from `_bridgeTokensToHubPool` in the `Ovm_SpokePool` contract since World Chain has a USDC bridge which uses
* a custom interface. This is because the USDC token on World Chain is meant to be upgraded to a native, CCTP supported version in the future.
* @dev This implementation deviates slightly from `_bridgeTokensToHubPool` in the `Ovm_SpokePool` contract since
* this chain uses Circle's bridged (upgradable to native) USDC standard, which uses a custom interface.

*/
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
// WorldChain, this block of code will be unused.
Comment on lines +60 to +62
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// 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
// WorldChain, this block of code will be unused.
// Handle Circle's bridge for upgradable USDC, which doesn't conform to the standard OP 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 this chain, this block of code will be unused.

if (l2TokenAddress == address(usdcToken) && !_isCCTPEnabled()) {
usdcToken.safeIncreaseAllowance(USDC_BRIDGE, amountToReturn);
IOpUSDCBridgeAdapter(USDC_BRIDGE).sendMessage(
withdrawalRecipient, // _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);
}
}
2 changes: 1 addition & 1 deletion deploy/056_deploy_op_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
constructorArguments,
args: constructorArguments,
});

await hre.run("verify:verify", { address: deployment, constructorArguments });
Expand Down
28 changes: 28 additions & 0 deletions deploy/057_deploy_ink_spokepool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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 } 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,
ZERO_ADDRESS,
// 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("Ink_SpokePool", constructorArgs, initArgs);
};
module.exports = func;
func.tags = ["InkSpokePool", "ink"];
10 changes: 8 additions & 2 deletions deploy/consts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export { ZERO_ADDRESS } from "@uma/common";

import { ZERO_ADDRESS } from "@uma/common";
import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "../utils";

export { ZERO_ADDRESS } from "@uma/common";

export const USDC = TOKEN_SYMBOLS_MAP.USDC.addresses;
export const USDCe = TOKEN_SYMBOLS_MAP["USDC.e"].addresses;
export const WETH = TOKEN_SYMBOLS_MAP.WETH.addresses;
Expand Down Expand Up @@ -80,6 +81,11 @@ export const OP_STACK_ADDRESS_MAP: {
L1CrossDomainMessenger: "0x5D4472f31Bd9385709ec61305AFc749F0fA8e9d0",
L1StandardBridge: "0x697402166Fbf2F22E970df8a6486Ef171dbfc524",
},
[CHAIN_IDs.INK]: {
L1CrossDomainMessenger: "0x69d3cf86b2bf1a9e99875b7e2d9b6a84426c171f",
L1StandardBridge: "0x88ff1e5b602916615391f55854588efcbb7663f0",
L1OpUSDCBridgeAdapter: ZERO_ADDRESS,
james-a-morris marked this conversation as resolved.
Show resolved Hide resolved
},
[CHAIN_IDs.LISK]: {
L1CrossDomainMessenger: "0x31B72D76FB666844C41EdF08dF0254875Dbb7edB",
L1StandardBridge: "0x2658723Bf70c7667De6B25F99fcce13A16D25d08",
Expand Down
6 changes: 5 additions & 1 deletion deployments/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"Redstone_Adapter": { "address": "0x188F8C95B7cfB7993B53a4F643efa687916f73fA", "blockNumber": 20432774 },
"Zora_Adapter": { "address": "0x024f2fc31cbdd8de17194b1892c834f98ef5169b", "blockNumber": 20512287 },
"WorldChain_Adapter": { "address": "0xA8399e221a583A57F54Abb5bA22f31b5D6C09f32", "blockNumber": 20963234 },
"AlephZero_Adapter": { "address": "0x6F4083304C2cA99B077ACE06a5DcF670615915Af", "blockNumber": 21131132 }
"AlephZero_Adapter": { "address": "0x6F4083304C2cA99B077ACE06a5DcF670615915Af", "blockNumber": 21131132 },
"Ink_Adapter": { "address": "0x7e90a40c7519b041a7df6498fbf5662e8cfc61d2", "blockNumber": 21438590 }
},
"10": {
"SpokePool": { "address": "0x6f26Bf09B1C792e3228e5467807a900A503c0281", "blockNumber": 93903076 },
Expand Down Expand Up @@ -157,5 +158,8 @@
"41455": {
"SpokePool": { "address": "0x13fDac9F9b4777705db45291bbFF3c972c6d1d97", "blockNumber": 4240318 },
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 4112529 }
},
"57073": {
"SpokePool": { "address": "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4", "blockNumber": 1139240 }
}
}
1 change: 1 addition & 0 deletions deployments/ink/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
57073
Loading
Loading