Skip to content

Commit 4bb8383

Browse files
james-a-morrispxrl
andauthored
feat(ink): configure and deploy Ink contracts (#808)
* chore: bump constants Signed-off-by: james-a-morris <[email protected]> * chore: update ESLint configuration to disable naming convention rule Signed-off-by: james-a-morris <[email protected]> * feat: add support for Ink network in Hardhat configuration Signed-off-by: james-a-morris <[email protected]> * feat: add Ink SpokePool and Adapter contracts with deployment scripts Signed-off-by: james-a-morris <[email protected]> * improve: use worldchain as starting point for ink spoke Signed-off-by: james-a-morris <[email protected]> * improve: defer to 056 OP adapter Signed-off-by: james-a-morris <[email protected]> * nit: zero address Signed-off-by: james-a-morris <[email protected]> * improve: bump constants Signed-off-by: james-a-morris <[email protected]> * chore: remove redundant Signed-off-by: james-a-morris <[email protected]> * feat: deploy ink adapter Signed-off-by: james-a-morris <[email protected]> * feat: deploy spokepool Signed-off-by: james-a-morris <[email protected]> * docs: readme Signed-off-by: james-a-morris <[email protected]> * feat: deploy ink multicallhandler (#813) * feat: deploy ink multicallhandler --------- Signed-off-by: james-a-morris <[email protected]> * chore: bump contracts Signed-off-by: james-a-morris <[email protected]> * chore: Deploy Ink SpokePoolVerifier (#814) --------- Signed-off-by: james-a-morris <[email protected]> Co-authored-by: Paul <[email protected]>
1 parent e0cc5a2 commit 4bb8383

17 files changed

+3673
-11
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ module.exports = {
1515
"node/no-unsupported-features/es-syntax": ["error", { ignores: ["modules"] }],
1616
"mocha/no-exclusive-tests": "error",
1717
"@typescript-eslint/no-var-requires": 0,
18+
"@typescript-eslint/naming-convention": "none",
1819
},
1920
};

contracts/Ink_SpokePool.sol

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.0;
3+
import "@eth-optimism/contracts/libraries/constants/Lib_PredeployAddresses.sol";
4+
5+
import "./Ovm_SpokePool.sol";
6+
import "./external/interfaces/CCTPInterfaces.sol";
7+
import { IOpUSDCBridgeAdapter } from "./external/interfaces/IOpUSDCBridgeAdapter.sol";
8+
9+
/**
10+
* @notice Ink Spoke pool.
11+
* @custom:security-contact [email protected]
12+
*/
13+
contract Ink_SpokePool is Ovm_SpokePool {
14+
using SafeERC20 for IERC20;
15+
16+
// Address of the custom L2 USDC bridge.
17+
address private constant USDC_BRIDGE = address(0);
18+
19+
/// @custom:oz-upgrades-unsafe-allow constructor
20+
constructor(
21+
address _wrappedNativeTokenAddress,
22+
uint32 _depositQuoteTimeBuffer,
23+
uint32 _fillDeadlineBuffer,
24+
IERC20 _l2Usdc,
25+
ITokenMessenger _cctpTokenMessenger
26+
)
27+
Ovm_SpokePool(
28+
_wrappedNativeTokenAddress,
29+
_depositQuoteTimeBuffer,
30+
_fillDeadlineBuffer,
31+
_l2Usdc,
32+
_cctpTokenMessenger
33+
)
34+
{} // solhint-disable-line no-empty-blocks
35+
36+
/**
37+
* @notice Construct the OVM World Chain SpokePool.
38+
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
39+
* relay hash collisions.
40+
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
41+
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
42+
*/
43+
function initialize(
44+
uint32 _initialDepositId,
45+
address _crossDomainAdmin,
46+
address _withdrawalRecipient
47+
) public initializer {
48+
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient, Lib_PredeployAddresses.OVM_ETH);
49+
}
50+
51+
/**
52+
* @notice Ink-specific logic to bridge tokens back to the hub pool contract on L1.
53+
* @param amountToReturn Amount of the token to bridge back.
54+
* @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`,
55+
* or via the canonical mapping defined in the bridge contract retrieved from `tokenBridges`.
56+
* @dev This implementation deviates slightly from `_bridgeTokensToHubPool` in the `Ovm_SpokePool` contract since World Chain has a USDC bridge which uses
57+
* 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.
58+
*/
59+
function _bridgeTokensToHubPool(uint256 amountToReturn, address l2TokenAddress) internal virtual override {
60+
// 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
61+
// 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
62+
// WorldChain, this block of code will be unused.
63+
if (l2TokenAddress == address(usdcToken) && !_isCCTPEnabled()) {
64+
usdcToken.safeIncreaseAllowance(USDC_BRIDGE, amountToReturn);
65+
IOpUSDCBridgeAdapter(USDC_BRIDGE).sendMessage(
66+
withdrawalRecipient, // _to. Withdraw, over the bridge, to the l1 hub pool contract.
67+
amountToReturn, // _amount.
68+
l1Gas // _minGasLimit. Same value used in other OpStack bridges.
69+
);
70+
} else super._bridgeTokensToHubPool(amountToReturn, l2TokenAddress);
71+
}
72+
}

deploy/056_deploy_op_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
3636
from: deployer,
3737
log: true,
3838
skipIfAlreadyDeployed: true,
39-
constructorArguments,
39+
args: constructorArguments,
4040
});
4141

4242
await hre.run("verify:verify", { address: deployment, constructorArguments });

deploy/057_deploy_ink_spokepool.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { DeployFunction } from "hardhat-deploy/types";
2+
import { HardhatRuntimeEnvironment } from "hardhat/types";
3+
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
4+
import { FILL_DEADLINE_BUFFER, WETH, QUOTE_TIME_BUFFER, ZERO_ADDRESS } from "./consts";
5+
6+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
7+
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
8+
9+
const initArgs = [
10+
1,
11+
// Set hub pool as cross domain admin since it delegatecalls the Adapter logic.
12+
hubPool.address,
13+
hubPool.address,
14+
];
15+
const constructorArgs = [
16+
WETH[spokeChainId],
17+
QUOTE_TIME_BUFFER,
18+
FILL_DEADLINE_BUFFER,
19+
ZERO_ADDRESS,
20+
// L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
21+
// For now, we are not using the CCTP bridge and can disable by setting
22+
// the cctpTokenMessenger to the zero address.
23+
ZERO_ADDRESS,
24+
];
25+
await deployNewProxy("Ink_SpokePool", constructorArgs, initArgs);
26+
};
27+
module.exports = func;
28+
func.tags = ["InkSpokePool", "ink"];

deploy/consts.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
export { ZERO_ADDRESS } from "@uma/common";
2-
1+
import { ZERO_ADDRESS } from "@uma/common";
32
import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "../utils";
43

4+
export { ZERO_ADDRESS } from "@uma/common";
5+
56
export const USDC = TOKEN_SYMBOLS_MAP.USDC.addresses;
67
export const USDCe = TOKEN_SYMBOLS_MAP["USDC.e"].addresses;
78
export const WETH = TOKEN_SYMBOLS_MAP.WETH.addresses;
@@ -80,6 +81,11 @@ export const OP_STACK_ADDRESS_MAP: {
8081
L1CrossDomainMessenger: "0x5D4472f31Bd9385709ec61305AFc749F0fA8e9d0",
8182
L1StandardBridge: "0x697402166Fbf2F22E970df8a6486Ef171dbfc524",
8283
},
84+
[CHAIN_IDs.INK]: {
85+
L1CrossDomainMessenger: "0x69d3cf86b2bf1a9e99875b7e2d9b6a84426c171f",
86+
L1StandardBridge: "0x88ff1e5b602916615391f55854588efcbb7663f0",
87+
L1OpUSDCBridgeAdapter: ZERO_ADDRESS,
88+
},
8389
[CHAIN_IDs.LISK]: {
8490
L1CrossDomainMessenger: "0x31B72D76FB666844C41EdF08dF0254875Dbb7edB",
8591
L1StandardBridge: "0x2658723Bf70c7667De6B25F99fcce13A16D25d08",

deployments/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,10 @@ This is because this `deployments.json` file is used by bots in [`@across-protoc
130130
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
131131
| AlephZero_SpokePool | [0x13fDac9F9b4777705db45291bbFF3c972c6d1d97](https://evm-explorer.alephzero.org/address/0x13fDac9F9b4777705db45291bbFF3c972c6d1d97) |
132132
| MulticallHandler | [0x924a9f036260DdD5808007E1AA95f08eD08aA569](https://evm-explorer.alephzero.org/address/0x924a9f036260DdD5808007E1AA95f08eD08aA569) |
133+
134+
## Ink mainnet (57073)
135+
136+
| Contract Name | Address |
137+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------- |
138+
| Ink_SpokePool | [0xeF684C38F94F48775959ECf2012D7E864ffb9dd4](https://explorer.inkonchain.com/address/0xeF684C38F94F48775959ECf2012D7E864ffb9dd4) |
139+
| MulticallHandler | [0x924a9f036260DdD5808007E1AA95f08eD08aA569](https://explorer.inkonchain.com/address/0x924a9f036260DdD5808007E1AA95f08eD08aA569) |

deployments/deployments.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"Redstone_Adapter": { "address": "0x188F8C95B7cfB7993B53a4F643efa687916f73fA", "blockNumber": 20432774 },
2929
"Zora_Adapter": { "address": "0x024f2fc31cbdd8de17194b1892c834f98ef5169b", "blockNumber": 20512287 },
3030
"WorldChain_Adapter": { "address": "0xA8399e221a583A57F54Abb5bA22f31b5D6C09f32", "blockNumber": 20963234 },
31-
"AlephZero_Adapter": { "address": "0x6F4083304C2cA99B077ACE06a5DcF670615915Af", "blockNumber": 21131132 }
31+
"AlephZero_Adapter": { "address": "0x6F4083304C2cA99B077ACE06a5DcF670615915Af", "blockNumber": 21131132 },
32+
"Ink_Adapter": { "address": "0x7e90a40c7519b041a7df6498fbf5662e8cfc61d2", "blockNumber": 21438590 }
3233
},
3334
"10": {
3435
"SpokePool": { "address": "0x6f26Bf09B1C792e3228e5467807a900A503c0281", "blockNumber": 93903076 },
@@ -157,5 +158,10 @@
157158
"41455": {
158159
"SpokePool": { "address": "0x13fDac9F9b4777705db45291bbFF3c972c6d1d97", "blockNumber": 4240318 },
159160
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 4112529 }
161+
},
162+
"57073": {
163+
"SpokePool": { "address": "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4", "blockNumber": 1139240 },
164+
"SpokePoolVerifier": { "address": "0xB4A8d45647445EA9FC3E1058096142390683dBC2", "blockNumber": 1152853 },
165+
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 1145284 }
160166
}
161167
}

deployments/ink/.chainId

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
57073

0 commit comments

Comments
 (0)