Skip to content
Open
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
15 changes: 13 additions & 2 deletions deploy/110_deploy_universal_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { DeployFunction } from "hardhat-deploy/types";
import { getOftEid, toWei } from "../utils/utils";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { CIRCLE_DOMAIN_IDs, L1_ADDRESS_MAP, USDC, ZERO_ADDRESS } from "./consts";
import { CCTP_NO_DOMAIN } from "@across-protocol/constants";
import { CIRCLE_UNINITIALIZED_DOMAIN_ID } from "./consts";
import assert from "assert";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
Expand All @@ -14,11 +17,19 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// unique addresses, since the relayed message `targets` are part of the unique data hash.
const hubPoolStore = await hre.deployments.get("HubPoolStore");

// todo: implement similar treatment to `CIRCLE_DOMAIN_IDs`
const oftDstEid = getOftEid(Number(SPOKE_CHAIN_ID));
const oftFeeCap = toWei("1"); // 1 eth transfer fee cap

const cctpDomainId = CIRCLE_DOMAIN_IDs[Number(SPOKE_CHAIN_ID)] ?? CCTP_NO_DOMAIN;
const args = [
hubPoolStore.address,
USDC[chainId],
CIRCLE_DOMAIN_IDs[SPOKE_CHAIN_ID] ? L1_ADDRESS_MAP[chainId].cctpTokenMessenger : ZERO_ADDRESS,
CIRCLE_DOMAIN_IDs[SPOKE_CHAIN_ID] ?? 4294967295, // maxUint32,
cctpDomainId === CCTP_NO_DOMAIN ? ZERO_ADDRESS : L1_ADDRESS_MAP[chainId].cctpTokenMessenger,
cctpDomainId === CCTP_NO_DOMAIN ? CIRCLE_UNINITIALIZED_DOMAIN_ID : cctpDomainId,
L1_ADDRESS_MAP[chainId].adapterStore,
oftDstEid,
oftFeeCap,
];
const instance = await deployments.deploy("Universal_Adapter", {
from: deployer,
Expand Down
16 changes: 15 additions & 1 deletion deploy/111_deploy_universal_spokepool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
import { FILL_DEADLINE_BUFFER, L1_ADDRESS_MAP, L2_ADDRESS_MAP, QUOTE_TIME_BUFFER, USDC, ZERO_ADDRESS } from "./consts";
import { CHAIN_IDs, PRODUCTION_NETWORKS, TOKEN_SYMBOLS_MAP } from "../utils/constants";
import { getOftEid, toWei } from "../utils/utils";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
const { hubPool, hubChainId, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
if (spokeChainId == CHAIN_IDs.BSC) {
console.log("For BSC deployment to work, `hardhat.config.ts` might need a tweak");
// Set these in hardhat.config.ts networks.bsc
// gas: "auto",
// gasPrice: 3e8, // 0.3 GWEI
// gasMultiplier: 4.0,
}

const initArgs = [1, hubPool.address, hubPool.address];

Expand All @@ -18,6 +26,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
throw new Error(`Wrapped native token not found for ${wrappedNativeSymbol} on chainId ${spokeChainId}`);
}

const oftEid = getOftEid(hubChainId);
// ! Notice. Deployed has to adjust this fee cap based on dst chain's native token. 4.4 BNB for BSC
const oftFeeCap = toWei(4.4); // ~1 ETH fee cap
Copy link
Member

Choose a reason for hiding this comment

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

What would happen if the BNB:ETH exchange rate moved sharply? Would we need to redeploy or does our fee cap give us a wide room for error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is extremely wide. A normal quote is never > $10. We give a HUGE buffer here

The fee cap is meant to prevent a single incorreect quote from draining our (potentially big?) native token balance, we cap it at like $3-4K. IMO 4.4 BNB is fine here


const constructorArgs = [
24 * 60 * 60, // 1 day; Helios latest head timestamp must be 1 day old before an admin can force execute a message.
L2_ADDRESS_MAP[spokeChainId]?.helios,
Expand All @@ -27,6 +39,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
FILL_DEADLINE_BUFFER,
USDC[spokeChainId] ?? ZERO_ADDRESS,
L2_ADDRESS_MAP[spokeChainId]?.cctpTokenMessenger ?? ZERO_ADDRESS,
oftEid,
oftFeeCap,
];
console.log(`Deploying new Universal SpokePool on ${spokeChainId} with args:`, constructorArgs);

Expand Down
2 changes: 1 addition & 1 deletion deploy/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const L2_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
},
[CHAIN_IDs.BSC]: {
helios: "0xB04926aF663cB52899361B1F6313bcFEa5A58B29",
helios: "0xE58480CA74f1A819faFd777BEDED4E2D5629943d",
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
},
[CHAIN_IDs.POLYGON]: {
Expand Down
164 changes: 158 additions & 6 deletions deployments/bsc/Universal_SpokePool.json

Large diffs are not rendered by default.

168 changes: 168 additions & 0 deletions deployments/bsc/solcInputs/03f0774c8f215de67810f48bdf2a5cfe.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deployments/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"Mode_Adapter": { "address": "0xf1B59868697f3925b72889ede818B9E7ba0316d0", "blockNumber": 19914094 },
"MulticallHandler": { "address": "0x924a9f036260DdD5808007E1AA95f08eD08aA569", "blockNumber": 20277013 },
"Lisk_Adapter": { "address": "0xF039AdCC74936F90fE175e8b3FE0FdC8b8E0c73b", "blockNumber": 22474211 },
"Universal_Adapter": { "address": "0x22001f37B586792F25Ef9d19d99537C6446e0833", "blockNumber": 22368546 },
"Universal_Adapter": { "address": "0x6f1C9d3bcDF51316E7b515a62C02F601500b084b", "blockNumber": 23251254 },
"Blast_Adapter": { "address": "0xF2bEf5E905AAE0295003ab14872F811E914EdD81", "blockNumber": 20221494 },
"Scroll_Adapter": { "address": "0x2DA799c2223c6ffB595e578903AE6b95839160d8", "blockNumber": 22325451 },
"Blast_DaiRetriever": { "address": "0x98Dd57048d7d5337e92D9102743528ea4Fea64aB", "blockNumber": 20378862 },
Expand Down
160 changes: 144 additions & 16 deletions deployments/mainnet/Universal_Adapter.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as dotenv from "dotenv";
dotenv.config();
import { HardhatUserConfig } from "hardhat/config";
import { CHAIN_IDs, PUBLIC_NETWORKS } from "./utils/constants";

Expand Down Expand Up @@ -47,8 +48,6 @@ const tasks = [
// eslint-disable-next-line node/no-missing-require
tasks.forEach((task) => require(`./tasks/${task}`));

dotenv.config();

const isTest = process.env.IS_TEST === "true" || process.env.CI === "true";

// To compile with zksolc, `hardhat` must be the default network and its `zksync` property must be true.
Expand Down Expand Up @@ -199,6 +198,10 @@ const config: HardhatUserConfig = {
companionNetworks: { l1: "mainnet" },
},
bsc: {
// ! Notice. Params below helped deploy Universal_Spoke on BSC, but might not be desirable always
// gas: "auto",
// gasPrice: 3e8, // 0.3 GWEI
// gasMultiplier: 4.0,
chainId: CHAIN_IDs.BSC,
url: getNodeUrl(CHAIN_IDs.BSC),
saveDeployments: true,
Expand Down
Loading