From 7c60353213539875313ee224aee90101fb705970 Mon Sep 17 00:00:00 2001 From: Bill Clippy Date: Tue, 11 Jul 2023 20:02:39 -0700 Subject: [PATCH] Update deployment scripts --- .env.example | 7 +- config.ts | 3 +- hardhat.config.ts | 4 +- tasks/deploy_anyswap_chess_pool.ts | 33 --- tasks/deploy_chess_pool.ts | 32 ++ tasks/deploy_chess_schedule_relayer.ts | 17 +- tasks/deploy_data_aggregator.ts | 18 +- tasks/deploy_governance.ts | 30 +- tasks/deploy_sub_governance.ts | 45 +-- tasks/deploy_voting_escrow_impl.ts | 30 +- tasks/dev_deploy_anyswap.ts | 328 --------------------- tasks/dev_deploy_lz.ts | 391 +++++++++++++++++++++++++ tasks/test_deploy.ts | 11 +- 13 files changed, 492 insertions(+), 457 deletions(-) delete mode 100644 tasks/deploy_anyswap_chess_pool.ts create mode 100644 tasks/deploy_chess_pool.ts delete mode 100644 tasks/dev_deploy_anyswap.ts create mode 100644 tasks/dev_deploy_lz.ts diff --git a/.env.example b/.env.example index ef1d6903..4e2e45bf 100644 --- a/.env.example +++ b/.env.example @@ -22,8 +22,5 @@ GOVERNANCE_TIMELOCK_DELAY=86400 # Launch date (YYYY-MM-DD). It must be a Thursday. GOVERNANCE_LAUNCH_DATE=1970-01-01 -# Anyswap Router address -ANYSWAP_ROUTER=0x0000000000000000000000000000000000000000; - -# AnyCall proxy address -ANY_CALL_PROXY=0x0000000000000000000000000000000000000000; +# LayerZero endpoint. +LZ_ENDPOINT=0x0000000000000000000000000000000000000000; diff --git a/config.ts b/config.ts index 18ffdb24..30dc5f5b 100644 --- a/config.ts +++ b/config.ts @@ -22,6 +22,5 @@ export const GOVERNANCE_CONFIG = { LAUNCH_TIMESTAMP: endOfWeek( new Date(process.env.GOVERNANCE_LAUNCH_DATE ?? "1970-01-01").getTime() / 1000 ), - ANYSWAP_ROUTER: process.env.ANYSWAP_ROUTER, - ANY_CALL_PROXY: process.env.ANY_CALL_PROXY, + LZ_ENDPOINT: process.env.LZ_ENDPOINT, }; diff --git a/hardhat.config.ts b/hardhat.config.ts index 083f72f7..94f3343a 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -4,7 +4,7 @@ import "@nomiclabs/hardhat-etherscan"; import "solidity-coverage"; import "./tasks/accounts"; import "./tasks/deploy_address_whitelist"; -import "./tasks/deploy_anyswap_chess_pool"; +import "./tasks/deploy_chess_pool"; import "./tasks/deploy_bsc_apr_oracle"; import "./tasks/deploy_bsc_staking_strategy"; import "./tasks/deploy_chess_controller_impl"; @@ -27,7 +27,7 @@ import "./tasks/deploy_sub_governance"; import "./tasks/deploy_swap_router"; import "./tasks/deploy_flash_swap_router"; import "./tasks/deploy_data_aggregator"; -import "./tasks/dev_deploy_anyswap"; +import "./tasks/dev_deploy_lz"; import "./tasks/dev_deploy_curve"; import "./tasks/dev_deploy_deposit_contract"; import "./tasks/dev_deploy_token_hub"; diff --git a/tasks/deploy_anyswap_chess_pool.ts b/tasks/deploy_anyswap_chess_pool.ts deleted file mode 100644 index ed49f5f8..00000000 --- a/tasks/deploy_anyswap_chess_pool.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { task } from "hardhat/config"; -import { Addresses, saveAddressFile, loadAddressFile, newAddresses } from "./address_file"; -import type { GovernanceAddresses } from "./deploy_governance"; -import { updateHreSigner } from "./signers"; - -export interface AnyswapChessPoolAddresses extends Addresses { - anyswapChessPool: string; -} - -task("deploy_anyswap_chess_pool", "Deploy AnyswapChessPool") - .addOptionalParam("chess", "Chess contract address", "") - .setAction(async function (args, hre) { - await updateHreSigner(hre); - const { ethers } = hre; - await hre.run("compile"); - - const chessAddress = - args.chess || loadAddressFile(hre, "governance").chess; - - const AnyswapChessPool = await ethers.getContractFactory("AnyswapChessPool"); - const anyswapChessPool = await AnyswapChessPool.deploy( - "Anyswap Wrapped CHESS", - "anyCHESS", - chessAddress - ); - console.log(`AnyswapChessPool: ${anyswapChessPool.address}`); - - const addresses: AnyswapChessPoolAddresses = { - ...newAddresses(hre), - anyswapChessPool: anyswapChessPool.address, - }; - saveAddressFile(hre, `anyswap_chess_pool`, addresses); - }); diff --git a/tasks/deploy_chess_pool.ts b/tasks/deploy_chess_pool.ts new file mode 100644 index 00000000..f075c233 --- /dev/null +++ b/tasks/deploy_chess_pool.ts @@ -0,0 +1,32 @@ +import { task } from "hardhat/config"; +import { GOVERNANCE_CONFIG } from "../config"; +import { Addresses, loadAddressFile, newAddresses, saveAddressFile } from "./address_file"; +import type { GovernanceAddresses } from "./deploy_governance"; +import { updateHreSigner } from "./signers"; + +export interface ChessPoolAddresses extends Addresses { + chessPool: string; +} + +task("deploy_chess_pool", "Deploy LzChessPool") + .addOptionalParam("chess", "Chess contract address", "") + .setAction(async function (args, hre) { + await updateHreSigner(hre); + const { ethers } = hre; + await hre.run("compile"); + + const chessAddress = + args.chess || loadAddressFile(hre, "governance").chess; + + const ChessPool = await ethers.getContractFactory("ProxyOFTPool"); + const chessPool = await ChessPool.deploy(GOVERNANCE_CONFIG.LZ_ENDPOINT, chessAddress); + console.log(`ChessPool: ${chessPool.address}`); + + await chessPool.setUseCustomAdapterParams(true); + + const addresses: ChessPoolAddresses = { + ...newAddresses(hre), + chessPool: chessPool.address, + }; + saveAddressFile(hre, `chess_pool`, addresses); + }); diff --git a/tasks/deploy_chess_schedule_relayer.ts b/tasks/deploy_chess_schedule_relayer.ts index 80c0e221..8b92a11c 100644 --- a/tasks/deploy_chess_schedule_relayer.ts +++ b/tasks/deploy_chess_schedule_relayer.ts @@ -11,7 +11,7 @@ export interface ChessScheduleRelayerAddresses extends Addresses { task("deploy_chess_schedule_relayer", "Deploy ChessScheduleRelayer") .addFlag("dry", "Get contract address without deploying it") - .addParam("chainId", "Sub chain ID") + .addParam("lzChainId", "LayerZero sub chain ID") .addParam("subSchedule", "Address of ChessSubSchedule on the sub chain") .setAction(async function (args, hre) { await updateHreSigner(hre); @@ -28,25 +28,26 @@ task("deploy_chess_schedule_relayer", "Deploy ChessScheduleRelayer") return; } - const chainId = parseInt(args.chainId); - assert.ok(chainId > 0 && chainId < 1e9, "Invalid sub chain ID"); + const lzChainId = parseInt(args.lzChainId); + assert.ok(lzChainId > 0 && lzChainId < 1e9, "Invalid sub chain ID"); const subSchedule = args.subSchedule; const governanceAddresses = loadAddressFile(hre, "governance"); const ChessScheduleRelayer = await ethers.getContractFactory("ChessScheduleRelayer"); const relayer = await ChessScheduleRelayer.deploy( - chainId, - subSchedule, + lzChainId, governanceAddresses.chessSchedule, governanceAddresses.chessController, - governanceAddresses.anyswapChessPool, - GOVERNANCE_CONFIG.ANY_CALL_PROXY + governanceAddresses.chessPool, + GOVERNANCE_CONFIG.LZ_ENDPOINT ); console.log(`ChessScheduleRelayer: ${relayer.address}`); + await relayer.setTrustedRemoteAddress(lzChainId, subSchedule); + const addresses: ChessScheduleRelayerAddresses = { ...newAddresses(hre), relayer: relayer.address, }; - saveAddressFile(hre, `chess_schedule_relayer_${chainId}`, addresses); + saveAddressFile(hre, `chess_schedule_relayer_${lzChainId}`, addresses); }); diff --git a/tasks/deploy_data_aggregator.ts b/tasks/deploy_data_aggregator.ts index 9b3d9ffa..f7985524 100644 --- a/tasks/deploy_data_aggregator.ts +++ b/tasks/deploy_data_aggregator.ts @@ -1,11 +1,9 @@ -import { strict as assert } from "assert"; import { task } from "hardhat/config"; -import { Addresses, saveAddressFile, loadAddressFile, newAddresses } from "./address_file"; +import { Addresses, loadAddressFile, newAddresses, saveAddressFile } from "./address_file"; +import type { FlashSwapRouterAddresses } from "./deploy_flash_swap_router"; import type { GovernanceAddresses } from "./deploy_governance"; import type { StableSwapAddresses } from "./deploy_stable_swap"; import type { SwapRouterAddresses } from "./deploy_swap_router"; -import type { FlashSwapRouterAddresses } from "./deploy_flash_swap_router"; -import { GOVERNANCE_CONFIG } from "../config"; import { updateHreSigner } from "./signers"; export interface DataAggregatorAddresses extends Addresses { @@ -14,20 +12,12 @@ export interface DataAggregatorAddresses extends Addresses { task("deploy_data_aggregator", "Deploy data aggregator") .addParam("firstUnderlyingSymbol", "Fund0 underlying symbols") - .addParam("otherChainIds", "Comma-separated chain IDs") .setAction(async function (args, hre) { await updateHreSigner(hre); const { ethers } = hre; await hre.run("compile"); const firstUnderlyingSymbol = args.firstUnderlyingSymbol; - const otherChainIds: number[] = args.otherChainIds - .split(",") - .filter(Boolean) - .map((x: string) => parseInt(x)); - for (const chainId of otherChainIds) { - assert.ok(chainId > 0 && chainId < 1e9, "Invalid chain ID"); - } const governanceAddresses = loadAddressFile(hre, "governance"); const swapRouterAddresses = loadAddressFile(hre, "swap_router"); @@ -49,8 +39,8 @@ task("deploy_data_aggregator", "Deploy data aggregator") swapRouterAddresses.swapRouter, flashSwapRouterAddresses.flashSwapRouter, bishopStableSwapAddress.quote, - GOVERNANCE_CONFIG.ANY_CALL_PROXY, - otherChainIds + ethers.constants.AddressZero, + [] ); console.log(`Data Aggregator: ${dataAggregator.address}`); diff --git a/tasks/deploy_governance.ts b/tasks/deploy_governance.ts index acb3ef41..ba2fd3ff 100644 --- a/tasks/deploy_governance.ts +++ b/tasks/deploy_governance.ts @@ -4,7 +4,7 @@ import type { ChessScheduleImplAddresses } from "./deploy_chess_schedule_impl"; import type { VotingEscrowImplAddresses } from "./deploy_voting_escrow_impl"; import type { ControllerBallotAddresses } from "./deploy_controller_ballot"; import type { ChessControllerImplAddresses } from "./deploy_chess_controller_impl"; -import type { AnyswapChessPoolAddresses } from "./deploy_anyswap_chess_pool"; +import type { ChessPoolAddresses } from "./deploy_chess_pool"; import { GOVERNANCE_CONFIG } from "../config"; import { updateHreSigner } from "./signers"; @@ -12,7 +12,7 @@ export interface GovernanceAddresses extends Addresses { timelockController: string; proxyAdmin: string; chess: string; - anyswapChessPool: string; + chessPool: string; chessScheduleImpl: string; chessSchedule: string; votingEscrowImpl: string; @@ -79,24 +79,24 @@ task("deploy_governance", "Deploy governance contracts", async function (_args, const chessSchedule = ChessSchedule.attach(chessScheduleProxy.address); console.log(`ChessSchedule: ${chessSchedule.address}`); - await hre.run("deploy_anyswap_chess_pool", { + await hre.run("deploy_chess_pool", { chess: chess.address, }); - const anyswapChessPool = await ethers.getContractAt( - "AnyswapChessPool", - loadAddressFile(hre, "anyswap_chess_pool").anyswapChessPool + const chessPool = await ethers.getContractAt( + "ProxyOFTPool", + loadAddressFile(hre, "chess_pool").chessPool ); - console.log(`AnyswapChessPool: ${anyswapChessPool.address}`); + console.log(`ChessPool: ${chessPool.address}`); await hre.run("deploy_voting_escrow_impl", { chess: chess.address, - anyswapChess: anyswapChessPool.address, + chessPool: chessPool.address, }); const votingEscrowImplAddresses = loadAddressFile( hre, - "voting_escrow_v3_impl" + "voting_escrow_v4_impl" ); - const VotingEscrow = await ethers.getContractFactory("VotingEscrowV3"); + const VotingEscrow = await ethers.getContractFactory("VotingEscrowV4"); const votingEscrowImpl = VotingEscrow.attach(votingEscrowImplAddresses.votingEscrowImpl); const votingEscrowInitTx = await votingEscrowImpl.populateTransaction.initialize( @@ -155,14 +155,12 @@ task("deploy_governance", "Deploy governance contracts", async function (_args, const chessController = ChessController.attach(chessControllerProxy.address); console.log(`ChessController: ${chessController.address}`); - console.log("Set VotingEscrow and AnyswapRouter to be CHESS minters"); - await anyswapChessPool.addMinter(votingEscrow.address); - await anyswapChessPool.addMinter(GOVERNANCE_CONFIG.ANYSWAP_ROUTER); - // TODO transfer owner + console.log("Set VotingEscrow to be CHESS minters"); + await chessPool.addMinter(votingEscrow.address); console.log("Transfering ownership to TimelockController"); await proxyAdmin.transferOwnership(timelockController.address); - await anyswapChessPool.transferOwnership(timelockController.address); + await chessPool.transferOwnership(timelockController.address); await votingEscrow.transferOwnership(timelockController.address); const addresses: GovernanceAddresses = { @@ -170,7 +168,7 @@ task("deploy_governance", "Deploy governance contracts", async function (_args, timelockController: timelockController.address, proxyAdmin: proxyAdmin.address, chess: chess.address, - anyswapChessPool: anyswapChessPool.address, + chessPool: chessPool.address, chessScheduleImpl: chessScheduleImpl.address, chessSchedule: chessSchedule.address, votingEscrowImpl: votingEscrowImpl.address, diff --git a/tasks/deploy_sub_governance.ts b/tasks/deploy_sub_governance.ts index f5c62292..db9b8e00 100644 --- a/tasks/deploy_sub_governance.ts +++ b/tasks/deploy_sub_governance.ts @@ -4,12 +4,12 @@ import type { GovernanceAddresses } from "./deploy_governance"; import type { VotingEscrowImplAddresses } from "./deploy_voting_escrow_impl"; import type { ControllerBallotAddresses } from "./deploy_controller_ballot"; import type { ChessControllerImplAddresses } from "./deploy_chess_controller_impl"; -import type { AnyswapChessPoolAddresses } from "./deploy_anyswap_chess_pool"; +import type { ChessPoolAddresses } from "./deploy_chess_pool"; import { GOVERNANCE_CONFIG } from "../config"; import { updateHreSigner } from "./signers"; task("deploy_sub_governance", "Deploy sub chain governance contracts") - .addParam("mainChainId", "Main chain ID") + .addParam("mainLzChainId", "Main LayerZero chain ID") .addParam("mainChainRelayer", "ChessScheduleRelayer address on the main chain") .setAction(async function (args, hre) { await updateHreSigner(hre); @@ -18,7 +18,7 @@ task("deploy_sub_governance", "Deploy sub chain governance contracts") await hre.run("compile"); const [deployer] = await ethers.getSigners(); - const mainChainId = parseInt(args.mainChainId); + const mainLzChainId = parseInt(args.mainLzChainId); const mainChainRelayer = args.mainChainRelayer; const TimelockController = await ethers.getContractFactory("TimelockController"); @@ -44,24 +44,24 @@ task("deploy_sub_governance", "Deploy sub chain governance contracts") ); console.log(`Chess: ${chess.address}`); - await hre.run("deploy_anyswap_chess_pool", { + await hre.run("deploy_chess_pool", { chess: chess.address, }); - const anyswapChessPool = await ethers.getContractAt( - "AnyswapChessPool", - loadAddressFile(hre, "anyswap_chess_pool").anyswapChessPool + const chessPool = await ethers.getContractAt( + "ProxyOFTPool", + loadAddressFile(hre, "chess_pool").chessPool ); - console.log(`AnyswapChessPool: ${anyswapChessPool.address}`); + console.log(`ChessPool: ${chessPool.address}`); await hre.run("deploy_voting_escrow_impl", { chess: chess.address, - anyswapChess: chess.address, + chessPool: chessPool.address, }); const votingEscrowImplAddresses = loadAddressFile( hre, - "voting_escrow_v3_impl" + "voting_escrow_v4_impl" ); - const VotingEscrow = await ethers.getContractFactory("VotingEscrowV3"); + const VotingEscrow = await ethers.getContractFactory("VotingEscrowV4"); const votingEscrowImpl = VotingEscrow.attach(votingEscrowImplAddresses.votingEscrowImpl); const votingEscrowInitTx = await votingEscrowImpl.populateTransaction.initialize( @@ -125,11 +125,10 @@ task("deploy_sub_governance", "Deploy sub chain governance contracts") const ChessSubSchedule = await ethers.getContractFactory("ChessSubSchedule"); const chessSubScheduleImpl = await ChessSubSchedule.deploy( - mainChainId, - mainChainRelayer, + mainLzChainId, controllerBallot.address, - chess.address, - GOVERNANCE_CONFIG.ANY_CALL_PROXY + chessPool.address, + GOVERNANCE_CONFIG.LZ_ENDPOINT ); console.log(`ChessSubSchedule implementation: ${chessSubScheduleImpl.address}`); @@ -143,17 +142,19 @@ task("deploy_sub_governance", "Deploy sub chain governance contracts") const chessSubSchedule = ChessSubSchedule.attach(chessSubScheduleProxy.address); console.log(`ChessSubSchedule: ${chessSubSchedule.address}`); - console.log("Set VotingEscrow, ChessSubSchedule and AnyswapRouter to be CHESS minters"); - await chess.addMinter(votingEscrow.address); - await chess.addMinter(chessSubSchedule.address); + console.log("Set ChessSubSchedule's trusted remote address"); + await chessSubSchedule.setTrustedRemoteAddress(mainLzChainId, mainChainRelayer); + + console.log("Set VotingEscrow, ChessSubSchedule to be CHESS minters"); + await chessPool.addMinter(votingEscrow.address); + await chessPool.addMinter(chessSubSchedule.address); await chess.addMinter(timelockController.address); - await anyswapChessPool.addMinter(GOVERNANCE_CONFIG.ANYSWAP_ROUTER); - await anyswapChessPool.addMinter(timelockController.address); + await chessPool.addMinter(timelockController.address); console.log("Transfering ownership to TimelockController"); await chess.transferOwnership(timelockController.address); await proxyAdmin.transferOwnership(timelockController.address); - await anyswapChessPool.transferOwnership(timelockController.address); + await chessPool.transferOwnership(timelockController.address); await votingEscrow.transferOwnership(timelockController.address); const addresses: GovernanceAddresses = { @@ -161,7 +162,7 @@ task("deploy_sub_governance", "Deploy sub chain governance contracts") timelockController: timelockController.address, proxyAdmin: proxyAdmin.address, chess: chess.address, - anyswapChessPool: anyswapChessPool.address, + chessPool: chessPool.address, chessScheduleImpl: chessSubScheduleImpl.address, chessSchedule: chessSubSchedule.address, votingEscrowImpl: votingEscrowImpl.address, diff --git a/tasks/deploy_voting_escrow_impl.ts b/tasks/deploy_voting_escrow_impl.ts index dae0832f..a66296ed 100644 --- a/tasks/deploy_voting_escrow_impl.ts +++ b/tasks/deploy_voting_escrow_impl.ts @@ -1,8 +1,7 @@ -import { strict as assert } from "assert"; import { task } from "hardhat/config"; -import { Addresses, saveAddressFile, loadAddressFile, newAddresses } from "./address_file"; -import type { GovernanceAddresses } from "./deploy_governance"; import { GOVERNANCE_CONFIG } from "../config"; +import { Addresses, loadAddressFile, newAddresses, saveAddressFile } from "./address_file"; +import type { GovernanceAddresses } from "./deploy_governance"; import { updateHreSigner } from "./signers"; export interface VotingEscrowImplAddresses extends Addresses { @@ -11,7 +10,7 @@ export interface VotingEscrowImplAddresses extends Addresses { task("deploy_voting_escrow_impl", "Deploy VotingEscrow implementation") .addOptionalParam("chess", "Chess contract address", "") - .addOptionalParam("anyswapChess", "AnyswapChess or AnyswapChessPool contract address", "") + .addOptionalParam("chessPool", "ProxyOFTPool contract address", "") .setAction(async function (args, hre) { await updateHreSigner(hre); const { ethers } = hre; @@ -19,26 +18,15 @@ task("deploy_voting_escrow_impl", "Deploy VotingEscrow implementation") const chessAddress = args.chess || loadAddressFile(hre, "governance").chess; - let anyswapChessAddress = args.anyswapChess; - if (!anyswapChessAddress) { - try { - const chess = await ethers.getContractAt("AnyswapChessPool", chessAddress); - assert.strictEqual(await chess.underlying(), ethers.constants.AddressZero); - anyswapChessAddress = chess.address; - } catch { - anyswapChessAddress = loadAddressFile( - hre, - "governance" - ).anyswapChessPool; - } - } + const chessPoolAddress = + args.chessPool || loadAddressFile(hre, "governance").chessPool; - const VotingEscrow = await ethers.getContractFactory("VotingEscrowV3"); + const VotingEscrow = await ethers.getContractFactory("VotingEscrowV4"); const votingEscrowImpl = await VotingEscrow.deploy( chessAddress, 208 * 7 * 86400, // 208 weeks - anyswapChessAddress, - GOVERNANCE_CONFIG.ANY_CALL_PROXY + chessPoolAddress, + GOVERNANCE_CONFIG.LZ_ENDPOINT ); console.log(`VotingEscrow implementation: ${votingEscrowImpl.address}`); @@ -50,5 +38,5 @@ task("deploy_voting_escrow_impl", "Deploy VotingEscrow implementation") ...newAddresses(hre), votingEscrowImpl: votingEscrowImpl.address, }; - saveAddressFile(hre, "voting_escrow_v3_impl", addresses); + saveAddressFile(hre, "voting_escrow_v4_impl", addresses); }); diff --git a/tasks/dev_deploy_anyswap.ts b/tasks/dev_deploy_anyswap.ts deleted file mode 100644 index 4122b3df..00000000 --- a/tasks/dev_deploy_anyswap.ts +++ /dev/null @@ -1,328 +0,0 @@ -import { strict as assert } from "assert"; -import { task } from "hardhat/config"; -import { endOfWeek } from "../config"; -import { Addresses, loadAddressFile, newAddresses, saveAddressFile } from "./address_file"; -import type { GovernanceAddresses } from "./deploy_governance"; -import type { ChessScheduleRelayerAddresses } from "./deploy_chess_schedule_relayer"; - -export interface AnyswapAddresses extends Addresses { - router: string; - anyCallProxy: string; - anyCallExecutor: string; - mpc: string; -} - -const DEV_CHAIN_ID_BSC = 5777; -const DEV_CHAIN_ID_ETH = 5701; - -export const ROUTER_ABI = [ - "constructor(address _factory, address _wNATIVE, address _mpc)", - "function mpc() view returns (address)", - "function anySwapOut(address token, address to, uint amount, uint toChainID)", - "function anySwapOutUnderlying(address token, address to, uint amount, uint toChainID)", - "function anySwapIn(bytes32 txs, address token, address to, uint amount, uint fromChainID)", - "function anySwapInUnderlying(bytes32 txs, address token, address to, uint amount, uint fromChainID)", - "function anySwapInAuto(bytes32 txs, address token, address to, uint amount, uint fromChainID)", -]; -export const ANY_CALL_PROXY_ABI = [ - "constructor(address admin, address mpc, uint128 premium, uint256 mode)", - "function executor() view returns (address)", - "function mpc() view returns (address)", - "function calcSrcFees(address app, uint256 toChainID, uint256 dataLength) view returns (uint256)", - "function setDefaultSrcFees(uint256[] toChainIDs, uint256[] baseFees, uint256[] feesPerByte)", - "function deposit(address account) payable", - "function withdraw(uint256 amount)", - `function anyExec( - address to, - bytes data, - address fallback, - string appID, - tuple( - bytes32 txhash, - address from, - uint256 fromChainID, - uint256 nonce, - uint256 flags - ) ctx - )`, -]; -export const ANY_CALL_EXECUTOR_ABI = [ - "function context() view returns (address, uint256, uint256)", - "function creator() view returns (address)", - "function execute(address to, bytes data, address from, uint256 fromChainID, uint256 nonce)", -]; - -const enum Bytecode { - // https://etherscan.io/address/0x6b7a87899490EcE95443e979cA9485CBE7E71522 - // https://bscscan.com/address/0xABd380327Fe66724FFDa91A87c772FB8D00bE488 - ROUTER = `60c06040523480156200001157600080fd5b506040516200499c3803806200499c833981016040819052620000349162000095565b600180546001600160a01b039092166001600160a01b0319909216919091179055426002556001600160601b0319606092831b8116608052911b1660a052620000de565b80516001600160a01b03811681146200009057600080fd5b919050565b600080600060608486031215620000aa578283fd5b620000b58462000078565b9250620000c56020850162000078565b9150620000d56040850162000078565b90509250925092565b60805160601c60a05160601c61484c62000150600039600081816101ec01528181611499015281816116380152611e3d015260008181610aef01528181610cda01528181610dc8015281816115230152818161254b015281816128a7015281816133220152613380015261484c6000f3fe6080604052600436106101dc5760003560e01c8063825bb13c11610102578063ad615dec11610095578063d8b9f61011610064578063d8b9f610146105aa578063dcfb77b1146105ca578063edbdf5e2146105ea578063f75c26641461060a57610229565b8063ad615dec14610535578063c45a015514610555578063c8e174f61461056a578063d06ca61f1461058a57610229565b80638fd903f5116100d15780638fd903f5146104be57806399a2f2d7146104e057806399cd84b5146104f55780639aa1ac611461051557610229565b8063825bb13c1461043e57806385f8c2591461045e57806387cc6e2f1461047e5780638d7d3eea1461049e57610229565b80632fc1e7281161017a57806352a397d51161014957806352a397d5146103be5780635b7b018c146103de57806365782f56146103fe5780636a4539721461041e57610229565b80632fc1e728146103315780633f88de8914610351578063456862aa146103715780634d93bb941461039e57610229565b80631b91a934116101b65780631b91a934146102a45780631f00ca74146102c4578063241dc2df146102f157806325121b761461031157610229565b80630175b1c41461022e578063054d50d41461024e5780630bb572031461028457610229565b3661022957336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461022757634e487b7160e01b600052600160045260246000fd5b005b600080fd5b34801561023a57600080fd5b50610227610249366004613d21565b61061f565b34801561025a57600080fd5b5061026e610269366004613fa8565b61080b565b60405161027b9190614660565b60405180910390f35b34801561029057600080fd5b5061022761029f366004613f2d565b610820565b3480156102b057600080fd5b506102276102bf3660046139aa565b610954565b3480156102d057600080fd5b506102e46102df366004613e5b565b610ae8565b60405161027b91906141f3565b3480156102fd57600080fd5b5061022761030c366004613a34565b610b1e565b34801561031d57600080fd5b5061022761032c366004613c16565b610b31565b34801561033d57600080fd5b506102e461034c366004613d72565b610c7a565b34801561035d57600080fd5b5061022761036c366004613d21565b610ed3565b34801561037d57600080fd5b5061039161038c366004613972565b610fa0565b60405161027b9190614237565b3480156103aa57600080fd5b506102276103b9366004613aa4565b61107e565b3480156103ca57600080fd5b506102e46103d9366004613d72565b611434565b3480156103ea57600080fd5b506103916103f9366004613933565b611726565b34801561040a57600080fd5b50610227610419366004613f2d565b611829565b34801561042a57600080fd5b50610227610439366004613f2d565b611938565b34801561044a57600080fd5b50610227610459366004613d21565b611b16565b34801561046a57600080fd5b5061026e610479366004613fa8565b611b62565b34801561048a57600080fd5b50610227610499366004613a79565b611b6f565b3480156104aa57600080fd5b506102276104b93660046139aa565b611cb5565b3480156104ca57600080fd5b506104d3611e3b565b60405161027b919061406c565b3480156104ec57600080fd5b5061026e611e5f565b34801561050157600080fd5b50610227610510366004613aa4565b611e63565b34801561052157600080fd5b50610227610530366004613aa4565b6121e0565b34801561054157600080fd5b5061026e610550366004613fa8565b61253c565b34801561056157600080fd5b506104d3612549565b34801561057657600080fd5b50610227610585366004613aa4565b61256d565b34801561059657600080fd5b506102e46105a5366004613e5b565b6128a0565b3480156105b657600080fd5b506102276105c5366004613f2d565b6128cd565b3480156105d657600080fd5b506102276105e5366004613b57565b6129e9565b3480156105f657600080fd5b50610227610605366004613a34565b612ac7565b34801561061657600080fd5b506104d3612bd1565b610627612bd1565b6001600160a01b0316336001600160a01b0316146106605760405162461bcd60e51b815260040161065790614452565b60405180910390fd5b61066d8585858585612bff565b60008490506000816001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156106ad57600080fd5b505afa1580156106c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e59190613956565b90506001600160a01b0381161580159061077b57506040516370a0823160e01b815284906001600160a01b038316906370a0823190610728908a9060040161406c565b60206040518083038186803b15801561074057600080fd5b505afa158015610754573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107789190613e43565b10155b1561080257604051620e75bb60e21b81526001600160a01b038316906239d6ec906107ae908890889082906004016140fe565b602060405180830381600087803b1580156107c857600080fd5b505af11580156107dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108009190613e43565b505b50505050505050565b6000610818848484612cde565b949350505050565b81428110156108415760405162461bcd60e51b815260040161065790614575565b8585600081811061086257634e487b7160e01b600052603260045260246000fd5b90506020020160208101906108779190613933565b6001600160a01b0316639dc29fac338a6040518363ffffffff1660e01b81526004016108a49291906140e5565b602060405180830381600087803b1580156108be57600080fd5b505af11580156108d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f69190613d01565b506001600160a01b038416337ffea6abdf4fd32f20966dff7619354cd82cd43dc78a3bee479f04c74dbfc585b388888c8c61092f611e5f565b8960405161094296959493929190614121565b60405180910390a35050505050505050565b876001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561098d57600080fd5b505afa1580156109a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c59190613956565b6001600160a01b031663605629d68a8a89898989896040518863ffffffff1660e01b81526004016109fc97969594939291906140a4565b602060405180830381600087803b158015610a1657600080fd5b505af1158015610a2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a4e9190613d01565b50604051630bebbf4d60e41b81526001600160a01b0389169063bebbf4d090610a7d9089908d90600401614669565b602060405180830381600087803b158015610a9757600080fd5b505af1158015610aab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610acf9190613e43565b50610add8989898985612d78565b505050505050505050565b6060610b157f00000000000000000000000000000000000000000000000000000000000000008484612e51565b90505b92915050565b610b2b3385858585612d78565b50505050565b610b39612bd1565b6001600160a01b0316336001600160a01b031614610b695760405162461bcd60e51b815260040161065790614452565b60005b87811015610c6d57610c5b8b8b83818110610b9757634e487b7160e01b600052603260045260246000fd5b905060200201358a8a84818110610bbe57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610bd39190613933565b898985818110610bf357634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610c089190613933565b888886818110610c2857634e487b7160e01b600052603260045260246000fd5b90506020020135878787818110610c4f57634e487b7160e01b600052603260045260246000fd5b90506020020135612bff565b80610c6581614797565b915050610b6c565b5050505050505050505050565b6060610c84612bd1565b6001600160a01b0316336001600160a01b031614610cb45760405162461bcd60e51b815260040161065790614452565b8242811015610cd55760405162461bcd60e51b815260040161065790614575565b610d337f00000000000000000000000000000000000000000000000000000000000000008a89898080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061300b92505050565b9150878260018451610d45919061473d565b81518110610d6357634e487b7160e01b600052603260045260246000fd5b60200260200101511015610d895760405162461bcd60e51b8152600401610657906143bf565b610e878a88886000818110610dae57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610dc39190613933565b610e587f00000000000000000000000000000000000000000000000000000000000000008b8b6000818110610e0857634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610e1d9190613933565b8c8c6001818110610e3e57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610e539190613933565b6131a5565b85600081518110610e7957634e487b7160e01b600052603260045260246000fd5b602002602001015187612bff565b610ec6828888808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508a9250613215915050565b5098975050505050505050565b610edb612bd1565b6001600160a01b0316336001600160a01b031614610f0b5760405162461bcd60e51b815260040161065790614452565b610f188585858585612bff565b604051620e75bb60e21b81526001600160a01b038516906239d6ec90610f46908690869082906004016140fe565b602060405180830381600087803b158015610f6057600080fd5b505af1158015610f74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f989190613e43565b505050505050565b6000610faa612bd1565b6001600160a01b0316336001600160a01b031614610fda5760405162461bcd60e51b815260040161065790614452565b6001600160a01b0382166110005760405162461bcd60e51b8152600401610657906142f0565b6040516360e232a960e01b81526001600160a01b038416906360e232a99061102c90859060040161406c565b602060405180830381600087803b15801561104657600080fd5b505af115801561105a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b159190613d01565b844281101561109f5760405162461bcd60e51b815260040161065790614575565b6000898960008181106110c257634e487b7160e01b600052603260045260246000fd5b90506020020160208101906110d79190613933565b6001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561110f57600080fd5b505afa158015611123573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111479190613956565b9050806001600160a01b031663d505accf8e308f8b8b8b8b6040518863ffffffff1660e01b815260040161118197969594939291906140a4565b600060405180830381600087803b15801561119b57600080fd5b505af11580156111af573d6000803e3d6000fd5b505050506111f4818e8c8c60008181106111d957634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111ee9190613933565b8f61344f565b8989600081811061121557634e487b7160e01b600052603260045260246000fd5b905060200201602081019061122a9190613933565b6001600160a01b031663bebbf4d08d8f6040518363ffffffff1660e01b8152600401611257929190614669565b602060405180830381600087803b15801561127157600080fd5b505af1158015611285573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112a99190613e43565b50898960008181106112cb57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906112e09190613933565b6001600160a01b0316639dc29fac8e8e6040518363ffffffff1660e01b815260040161130d9291906140e5565b602060405180830381600087803b15801561132757600080fd5b505af115801561133b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061135f9190613d01565b5060008a8a80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050905060008e905060008a905060008f905060008f905060006113c4611e5f565b90506000899050846001600160a01b0316866001600160a01b03167f278277e0209c347189add7bd92411973b5f6b8644f7ac62ea1be984ce993f8f4898787878760405161141695949392919061418b565b60405180910390a35050505050505050505050505050505050505050565b606061143e612bd1565b6001600160a01b0316336001600160a01b03161461146e5760405162461bcd60e51b815260040161065790614452565b824281101561148f5760405162461bcd60e51b815260040161065790614575565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001687876114c660018261473d565b8181106114e357634e487b7160e01b600052603260045260246000fd5b90506020020160208101906114f89190613933565b6001600160a01b03161461151e5760405162461bcd60e51b8152600401610657906144be565b61157c7f00000000000000000000000000000000000000000000000000000000000000008a89898080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061300b92505050565b915087826001845161158e919061473d565b815181106115ac57634e487b7160e01b600052603260045260246000fd5b602002602001015110156115d25760405162461bcd60e51b8152600401610657906144f5565b6115f78a88886000818110610dae57634e487b7160e01b600052603260045260246000fd5b61163682888880806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250309250613215915050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632e1a7d4d8360018551611674919061473d565b8151811061169257634e487b7160e01b600052603260045260246000fd5b60200260200101516040518263ffffffff1660e01b81526004016116b69190614660565b600060405180830381600087803b1580156116d057600080fd5b505af11580156116e4573d6000803e3d6000fd5b50505050610ec68583600185516116fb919061473d565b8151811061171957634e487b7160e01b600052603260045260246000fd5b6020026020010151613537565b6000611730612bd1565b6001600160a01b0316336001600160a01b0316146117605760405162461bcd60e51b815260040161065790614452565b6001600160a01b0382166117865760405162461bcd60e51b8152600401610657906142f0565b61178e612bd1565b600080546001600160a01b03199081166001600160a01b0393841617909155600180549091169184169190911790556117ca426202a3006146e6565b60028190556001546000546001600160a01b0391821691167fcda32bc39904597666dfa9f9c845714756e1ffffad55b52e0d344673a219812161180b611e5f565b6040516118189190614660565b60405180910390a45060015b919050565b814281101561184a5760405162461bcd60e51b815260040161065790614575565b8585600081811061186b57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906118809190613933565b6001600160a01b0316639dc29fac338a6040518363ffffffff1660e01b81526004016118ad9291906140e5565b602060405180830381600087803b1580156118c757600080fd5b505af11580156118db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ff9190613d01565b506001600160a01b038416337f278277e0209c347189add7bd92411973b5f6b8644f7ac62ea1be984ce993f8f488888c8c61092f611e5f565b81428110156119595760405162461bcd60e51b815260040161065790614575565b611a3f8686600081811061197d57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906119929190613933565b6001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156119ca57600080fd5b505afa1580156119de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a029190613956565b3388886000818110611a2457634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611a399190613933565b8b61344f565b85856000818110611a6057634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611a759190613933565b6001600160a01b031663bebbf4d089336040518363ffffffff1660e01b8152600401611aa2929190614669565b602060405180830381600087803b158015611abc57600080fd5b505af1158015611ad0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af49190613e43565b508585600081811061186b57634e487b7160e01b600052603260045260246000fd5b611b1e612bd1565b6001600160a01b0316336001600160a01b031614611b4e5760405162461bcd60e51b815260040161065790614452565b611b5b8585858585612bff565b5050505050565b60006108188484846135c9565b611b77612bd1565b6001600160a01b0316336001600160a01b031614611ba75760405162461bcd60e51b815260040161065790614452565b6000611bb1612bd1565b6040516340c10f1960e01b81529091506001600160a01b038416906340c10f1990611be290849086906004016140e5565b602060405180830381600087803b158015611bfc57600080fd5b505af1158015611c10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c349190613d01565b50604051620e75bb60e21b81526001600160a01b038416906239d6ec90611c63908490869082906004016140fe565b602060405180830381600087803b158015611c7d57600080fd5b505af1158015611c91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b2b9190613e43565b6000886001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015611cf057600080fd5b505afa158015611d04573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d289190613956565b60405163d505accf60e01b81529091506001600160a01b0382169063d505accf90611d63908d9030908c908c908c908c908c906004016140a4565b600060405180830381600087803b158015611d7d57600080fd5b505af1158015611d91573d6000803e3d6000fd5b50505050611da1818b8b8a61344f565b604051630bebbf4d60e41b81526001600160a01b038a169063bebbf4d090611dcf908a908e90600401614669565b602060405180830381600087803b158015611de957600080fd5b505af1158015611dfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e219190613e43565b50611e2f8a8a8a8a86612d78565b50505050505050505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b4690565b8442811015611e845760405162461bcd60e51b815260040161065790614575565b600089896000818110611ea757634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611ebc9190613933565b6001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015611ef457600080fd5b505afa158015611f08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f2c9190613956565b9050806001600160a01b031663d505accf8e308f8b8b8b8b6040518863ffffffff1660e01b8152600401611f6697969594939291906140a4565b600060405180830381600087803b158015611f8057600080fd5b505af1158015611f94573d6000803e3d6000fd5b50505050611fbe818e8c8c60008181106111d957634e487b7160e01b600052603260045260246000fd5b89896000818110611fdf57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611ff49190613933565b6001600160a01b031663bebbf4d08d8f6040518363ffffffff1660e01b8152600401612021929190614669565b602060405180830381600087803b15801561203b57600080fd5b505af115801561204f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120739190613e43565b508989600081811061209557634e487b7160e01b600052603260045260246000fd5b90506020020160208101906120aa9190613933565b6001600160a01b0316639dc29fac8e8e6040518363ffffffff1660e01b81526004016120d79291906140e5565b602060405180830381600087803b1580156120f157600080fd5b505af1158015612105573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121299190613d01565b5060008a8a80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f82011690508083019250505050505050905060008e905060008a905060008f905060008f9050600061218e611e5f565b90506000899050846001600160a01b0316866001600160a01b03167ffea6abdf4fd32f20966dff7619354cd82cd43dc78a3bee479f04c74dbfc585b3898787878760405161141695949392919061418b565b84428110156122015760405162461bcd60e51b815260040161065790614575565b8888600081811061222257634e487b7160e01b600052603260045260246000fd5b90506020020160208101906122379190613933565b6001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b15801561226f57600080fd5b505afa158015612283573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122a79190613956565b6001600160a01b031663605629d68d8b8b60008181106122d757634e487b7160e01b600052603260045260246000fd5b90506020020160208101906122ec9190613933565b8e8a8a8a8a6040518863ffffffff1660e01b815260040161231397969594939291906140a4565b602060405180830381600087803b15801561232d57600080fd5b505af1158015612341573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123659190613d01565b508888600081811061238757634e487b7160e01b600052603260045260246000fd5b905060200201602081019061239c9190613933565b6001600160a01b031663bebbf4d08c8e6040518363ffffffff1660e01b81526004016123c9929190614669565b602060405180830381600087803b1580156123e357600080fd5b505af11580156123f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061241b9190613e43565b508888600081811061243d57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906124529190613933565b6001600160a01b0316639dc29fac8d8d6040518363ffffffff1660e01b815260040161247f9291906140e5565b602060405180830381600087803b15801561249957600080fd5b505af11580156124ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124d19190613d01565b50866001600160a01b03168c6001600160a01b03167ffea6abdf4fd32f20966dff7619354cd82cd43dc78a3bee479f04c74dbfc585b38b8b8f8f612513611e5f565b8960405161252696959493929190614121565b60405180910390a3505050505050505050505050565b600061081884848461365d565b7f000000000000000000000000000000000000000000000000000000000000000081565b844281101561258e5760405162461bcd60e51b815260040161065790614575565b888860008181106125af57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906125c49190613933565b6001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b1580156125fc57600080fd5b505afa158015612610573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126349190613956565b6001600160a01b031663605629d68d8b8b600081811061266457634e487b7160e01b600052603260045260246000fd5b90506020020160208101906126799190613933565b8e8a8a8a8a6040518863ffffffff1660e01b81526004016126a097969594939291906140a4565b602060405180830381600087803b1580156126ba57600080fd5b505af11580156126ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126f29190613d01565b508888600081811061271457634e487b7160e01b600052603260045260246000fd5b90506020020160208101906127299190613933565b6001600160a01b031663bebbf4d08c8e6040518363ffffffff1660e01b8152600401612756929190614669565b602060405180830381600087803b15801561277057600080fd5b505af1158015612784573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a89190613e43565b50888860008181106127ca57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906127df9190613933565b6001600160a01b0316639dc29fac8d8d6040518363ffffffff1660e01b815260040161280c9291906140e5565b602060405180830381600087803b15801561282657600080fd5b505af115801561283a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061285e9190613d01565b50866001600160a01b03168c6001600160a01b03167f278277e0209c347189add7bd92411973b5f6b8644f7ac62ea1be984ce993f8f48b8b8f8f612513611e5f565b6060610b157f0000000000000000000000000000000000000000000000000000000000000000848461300b565b81428110156128ee5760405162461bcd60e51b815260040161065790614575565b6129128686600081811061197d57634e487b7160e01b600052603260045260246000fd5b8585600081811061293357634e487b7160e01b600052603260045260246000fd5b90506020020160208101906129489190613933565b6001600160a01b031663bebbf4d089336040518363ffffffff1660e01b8152600401612975929190614669565b602060405180830381600087803b15801561298f57600080fd5b505af11580156129a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c79190613e43565b508585600081811061086257634e487b7160e01b600052603260045260246000fd5b60005b87811015610add57612ab5338a8a84818110612a1857634e487b7160e01b600052603260045260246000fd5b9050602002016020810190612a2d9190613933565b898985818110612a4d57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190612a629190613933565b888886818110612a8257634e487b7160e01b600052603260045260246000fd5b90506020020135878787818110612aa957634e487b7160e01b600052603260045260246000fd5b90506020020135612d78565b80612abf81614797565b9150506129ec565b612b43846001600160a01b0316636f307dc36040518163ffffffff1660e01b815260040160206040518083038186803b158015612b0357600080fd5b505afa158015612b17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3b9190613956565b33868561344f565b604051630bebbf4d60e41b81526001600160a01b0385169063bebbf4d090612b719085903390600401614669565b602060405180830381600087803b158015612b8b57600080fd5b505af1158015612b9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc39190613e43565b50610b2b3385858585612d78565b60006002544210612bee57506001546001600160a01b0316612bfc565b506000546001600160a01b03165b90565b6040516340c10f1960e01b81526001600160a01b038516906340c10f1990612c2d90869086906004016140e5565b602060405180830381600087803b158015612c4757600080fd5b505af1158015612c5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c7f9190613d01565b50826001600160a01b0316846001600160a01b0316867faac9ce45fe3adf5143598c4f18a369591a20a3384aedaf1b525d29127e1fcd558585612cc0611e5f565b604051612ccf939291906146d0565b60405180910390a45050505050565b6000808411612cff5760405162461bcd60e51b8152600401610657906145ac565b600083118015612d0f5750600082115b612d2b5760405162461bcd60e51b815260040161065790614242565b6000612d39856103e56136bf565b90506000612d4782856136bf565b90506000612d6183612d5b886103e86136bf565b906136ff565b9050612d6d81836146fe565b979650505050505050565b604051632770a7eb60e21b81526001600160a01b03851690639dc29fac90612da690889086906004016140e5565b602060405180830381600087803b158015612dc057600080fd5b505af1158015612dd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612df89190613d01565b50826001600160a01b0316856001600160a01b0316856001600160a01b03167f97116cf6cd4f6412bb47914d6db18da9e16ab2142f543b86e207c24fbd16b23a85612e41611e5f565b86604051612ccf939291906146d0565b6060600282511015612e755760405162461bcd60e51b81526004016106579061462b565b815167ffffffffffffffff811115612e9d57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015612ec6578160200160208202803683370190505b509050828160018351612ed9919061473d565b81518110612ef757634e487b7160e01b600052603260045260246000fd5b602002602001018181525050600060018351612f13919061473d565b90505b801561300357600080612f828786612f2f60018761473d565b81518110612f4d57634e487b7160e01b600052603260045260246000fd5b6020026020010151878681518110612f7557634e487b7160e01b600052603260045260246000fd5b602002602001015161372d565b91509150612fb8848481518110612fa957634e487b7160e01b600052603260045260246000fd5b602002602001015183836135c9565b84612fc460018661473d565b81518110612fe257634e487b7160e01b600052603260045260246000fd5b60200260200101818152505050508080612ffb90614780565b915050612f16565b509392505050565b606060028251101561302f5760405162461bcd60e51b81526004016106579061462b565b815167ffffffffffffffff81111561305757634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015613080578160200160208202803683370190505b50905082816000815181106130a557634e487b7160e01b600052603260045260246000fd5b60200260200101818152505060005b600183516130c2919061473d565b81101561300357600080613124878685815181106130f057634e487b7160e01b600052603260045260246000fd5b60200260200101518786600161310691906146e6565b81518110612f7557634e487b7160e01b600052603260045260246000fd5b9150915061315a84848151811061314b57634e487b7160e01b600052603260045260246000fd5b60200260200101518383612cde565b846131668560016146e6565b8151811061318457634e487b7160e01b600052603260045260246000fd5b6020026020010181815250505050808061319d90614797565b9150506130b4565b60008060006131b48585613806565b915091508582826040516020016131cc929190613fd3565b604051602081830303815290604052805190602001206040516020016131f3929190614016565b60408051601f1981840301815291905280516020909101209695505050505050565b60005b60018351613226919061473d565b811015610b2b5760008084838151811061325057634e487b7160e01b600052603260045260246000fd5b60200260200101518584600161326691906146e6565b8151811061328457634e487b7160e01b600052603260045260246000fd5b602002602001015191509150600061329c8383613806565b5090506000876132ad8660016146e6565b815181106132cb57634e487b7160e01b600052603260045260246000fd5b60200260200101519050600080836001600160a01b0316866001600160a01b0316146132f9578260006132fd565b6000835b91509150600060028a51613311919061473d565b881061331d5788613379565b6133797f0000000000000000000000000000000000000000000000000000000000000000878c61334e8c60026146e6565b8151811061336c57634e487b7160e01b600052603260045260246000fd5b60200260200101516131a5565b90506133a67f000000000000000000000000000000000000000000000000000000000000000088886131a5565b6001600160a01b031663022c0d9f84848460006040519080825280601f01601f1916602001820160405280156133e3576020820181803683370190505b506040518563ffffffff1660e01b81526004016134039493929190614680565b600060405180830381600087803b15801561341d57600080fd5b505af1158015613431573d6000803e3d6000fd5b5050505050505050505050808061344790614797565b915050613218565b600080856001600160a01b03166323b872dd86868660405160240161347693929190614080565b6040516020818303038152906040529060e01b6020820180516001600160e01b0383818316178352505050506040516134af9190613ffa565b6000604051808303816000865af19150503d80600081146134ec576040519150601f19603f3d011682016040523d82523d6000602084013e6134f1565b606091505b509150915081801561351b57508051158061351b57508080602001905181019061351b9190613d01565b610f985760405162461bcd60e51b8152600401610657906145e7565b604080516000808252602082019092526001600160a01b0384169083906040516135619190613ffa565b60006040518083038185875af1925050503d806000811461359e576040519150601f19603f3d011682016040523d82523d6000602084013e6135a3565b606091505b50509050806135c45760405162461bcd60e51b81526004016106579061440c565b505050565b60008084116135ea5760405162461bcd60e51b815260040161065790614355565b6000831180156135fa5750600082115b6136165760405162461bcd60e51b815260040161065790614242565b600061362e6103e861362886886136bf565b906136bf565b905060006136426103e56136288689613890565b90506136536001612d5b83856146fe565b9695505050505050565b600080841161367e5760405162461bcd60e51b815260040161065790614540565b60008311801561368e5750600082115b6136aa5760405162461bcd60e51b815260040161065790614242565b826136b585846136bf565b61081891906146fe565b60008115806136e3575082826136d5818361471e565b92506136e190836146fe565b145b610b185760405162461bcd60e51b815260040161065790614327565b60008261370c83826146e6565b9150811015610b185760405162461bcd60e51b815260040161065790614391565b600080600061373c8585613806565b50905060008061374d8888886131a5565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561378557600080fd5b505afa158015613799573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137bd9190613df5565b506001600160701b031691506001600160701b03169150826001600160a01b0316876001600160a01b0316146137f45780826137f7565b81815b90999098509650505050505050565b600080826001600160a01b0316846001600160a01b0316141561383b5760405162461bcd60e51b8152600401610657906142a9565b826001600160a01b0316846001600160a01b03161061385b57828461385e565b83835b90925090506001600160a01b0382166138895760405162461bcd60e51b815260040161065790614489565b9250929050565b60008261389d838261473d565b9150811115610b185760405162461bcd60e51b81526004016106579061427a565b8035611824816147de565b60008083601f8401126138da578081fd5b50813567ffffffffffffffff8111156138f1578182fd5b602083019150836020808302850101111561388957600080fd5b80516001600160701b038116811461182457600080fd5b803560ff8116811461182457600080fd5b600060208284031215613944578081fd5b813561394f816147de565b9392505050565b600060208284031215613967578081fd5b815161394f816147de565b60008060408385031215613984578081fd5b823561398f816147de565b9150602083013561399f816147de565b809150509250929050565b60008060008060008060008060006101208a8c0312156139c8578485fd5b89356139d3816147de565b985060208a01356139e3816147de565b975060408a01356139f3816147de565b965060608a0135955060808a01359450613a0f60a08b01613922565b935060c08a0135925060e08a013591506101008a013590509295985092959850929598565b60008060008060808587031215613a49578384fd5b8435613a54816147de565b93506020850135613a64816147de565b93969395505050506040820135916060013590565b60008060408385031215613a8b578182fd5b8235613a96816147de565b946020939093013593505050565b60008060008060008060008060008060006101408c8e031215613ac5578182fd5b8b35613ad0816147de565b9a5060208c0135995060408c0135985060608c013567ffffffffffffffff811115613af9578283fd5b613b058e828f016138c9565b90995097505060808c0135613b19816147de565b955060a08c01359450613b2e60c08d01613922565b935060e08c013592506101008c013591506101208c013590509295989b509295989b9093969950565b6000806000806000806000806080898b031215613b72578182fd5b883567ffffffffffffffff80821115613b89578384fd5b613b958c838d016138c9565b909a50985060208b0135915080821115613bad578384fd5b613bb98c838d016138c9565b909850965060408b0135915080821115613bd1578384fd5b613bdd8c838d016138c9565b909650945060608b0135915080821115613bf5578384fd5b50613c028b828c016138c9565b999c989b5096995094979396929594505050565b60008060008060008060008060008060a08b8d031215613c34578384fd5b8a3567ffffffffffffffff80821115613c4b578586fd5b613c578e838f016138c9565b909c509a5060208d0135915080821115613c6f578586fd5b613c7b8e838f016138c9565b909a50985060408d0135915080821115613c93578586fd5b613c9f8e838f016138c9565b909850965060608d0135915080821115613cb7578586fd5b613cc38e838f016138c9565b909650945060808d0135915080821115613cdb578384fd5b50613ce88d828e016138c9565b915080935050809150509295989b9194979a5092959850565b600060208284031215613d12578081fd5b8151801515811461394f578182fd5b600080600080600060a08688031215613d38578283fd5b853594506020860135613d4a816147de565b93506040860135613d5a816147de565b94979396509394606081013594506080013592915050565b60008060008060008060008060e0898b031215613d8d578182fd5b883597506020890135965060408901359550606089013567ffffffffffffffff811115613db8578283fd5b613dc48b828c016138c9565b9096509450506080890135613dd8816147de565b979a969950949793969295929450505060a08201359160c0013590565b600080600060608486031215613e09578081fd5b613e128461390b565b9250613e206020850161390b565b9150604084015163ffffffff81168114613e38578182fd5b809150509250925092565b600060208284031215613e54578081fd5b5051919050565b60008060408385031215613e6d578182fd5b8235915060208084013567ffffffffffffffff80821115613e8c578384fd5b818601915086601f830112613e9f578384fd5b813581811115613eb157613eb16147c8565b838102604051601f19603f83011681018181108582111715613ed557613ed56147c8565b604052828152858101935084860182860187018b1015613ef3578788fd5b8795505b83861015613f1c57613f08816138be565b855260019590950194938601938601613ef7565b508096505050505050509250929050565b600080600080600080600060c0888a031215613f47578081fd5b8735965060208801359550604088013567ffffffffffffffff811115613f6b578182fd5b613f778a828b016138c9565b9096509450506060880135613f8b816147de565b969995985093969295946080840135945060a09093013592915050565b600080600060608486031215613fbc578081fd5b505081359360208301359350604090920135919050565b6bffffffffffffffffffffffff19606093841b811682529190921b16601482015260280190565b6000825161400c818460208701614754565b9190910192915050565b6001600160f81b0319815260609290921b6bffffffffffffffffffffffff1916600183015260158201527fe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303603582015260550190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0397881681529590961660208601526040850193909352606084019190915260ff16608083015260a082015260c081019190915260e00190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b60a0808252810186905260008760c08301825b89811015614164578235614147816147de565b6001600160a01b0316825260209283019290910190600101614134565b50602084019790975250506040810193909352606083019190915260809091015292915050565b60a0808252865190820181905260009060209060c0840190828a01845b828110156141cd5781516001600160a01b0316845292840192908401906001016141a8565b505050908301969096525060408101939093526060830191909152608090910152919050565b6020808252825182820181905260009190848201906040850190845b8181101561422b5783518352928401929184019160010161420f565b50909695505050505050565b901515815260200190565b6020808252602a908201526000805160206147f78339815191526040820152695f4c495155494449545960b01b606082015260800190565b60208082526015908201527464732d6d6174682d7375622d756e646572666c6f7760581b604082015260600190565b60208082526027908201527f53757368697377617056324c6962726172793a204944454e544943414c5f41446040820152664452455353455360c81b606082015260800190565b6020808252601d908201527f416e79737761705633526f757465723a20616464726573732830783029000000604082015260600190565b60208082526014908201527364732d6d6174682d6d756c2d6f766572666c6f7760601b604082015260600190565b6020808252602e908201526000805160206147f783398151915260408201526d17d3d55514155517d05353d5539560921b606082015260800190565b60208082526014908201527364732d6d6174682d6164642d6f766572666c6f7760601b604082015260600190565b6020808252602d908201527f5375736869737761705632526f757465723a20494e53554646494349454e545f60408201526c13d55514155517d05353d55395609a1b606082015260800190565b60208082526026908201527f5472616e7366657248656c7065723a204e41544956455f5452414e534645525f60408201526511905253115160d21b606082015260800190565b6020808252601a908201527f416e79737761705633526f757465723a20464f5242494444454e000000000000604082015260600190565b6020808252818101527f53757368697377617056324c6962726172793a205a45524f5f41444452455353604082015260600190565b6020808252601d908201527f416e79737761705633526f757465723a20494e56414c49445f50415448000000604082015260600190565b6020808252602b908201527f416e79737761705633526f757465723a20494e53554646494349454e545f4f5560408201526a1514155517d05353d5539560aa1b606082015260800190565b60208082526027908201526000805160206147f783398151915260408201526617d05353d5539560ca1b606082015260800190565b60208082526018908201527f416e79737761705633526f757465723a20455850495245440000000000000000604082015260600190565b6020808252602d908201526000805160206147f783398151915260408201526c17d25394155517d05353d55395609a1b606082015260800190565b60208082526024908201527f5472616e7366657248656c7065723a205452414e534645525f46524f4d5f46416040820152631253115160e21b606082015260800190565b6020808252818101527f53757368697377617056324c6962726172793a20494e56414c49445f50415448604082015260600190565b90815260200190565b9182526001600160a01b0316602082015260400190565b600085825284602083015260018060a01b03841660408301526080606083015282518060808401526146b98160a0850160208701614754565b601f01601f19169190910160a00195945050505050565b9283526020830191909152604082015260600190565b600082198211156146f9576146f96147b2565b500190565b60008261471957634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615614738576147386147b2565b500290565b60008282101561474f5761474f6147b2565b500390565b60005b8381101561476f578181015183820152602001614757565b83811115610b2b5750506000910152565b60008161478f5761478f6147b2565b506000190190565b60006000198214156147ab576147ab6147b2565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146147f357600080fd5b5056fe53757368697377617056324c6962726172793a20494e53554646494349454e54a26469706673582212201b3b5eed332d3cf385271e4302952bced8a897a420bb7ac2494f41ff570dd8d564736f6c63430008010033`, - // https://bscscan.com/address/0xC10Ef9F491C9B59f936957026020C321651ac078 - ANY_CALL_PROXY = `608060405260016016553480156200001657600080fd5b506040516200518d3803806200518d833981016040819052620000399162000290565b6001600160a01b038316620000875760405162461bcd60e51b815260206004820152601060248201526f7a65726f206d7063206164647265737360801b604482015260640160405180910390fd5b6001600160a01b03841615620000ec576001600160a01b0384166000818152600960205260408120805460ff19166001908117909155600a805491820181559091526000805160206200516d8339815191520180546001600160a01b03191690911790555b836001600160a01b0316836001600160a01b0316146200015b576001600160a01b0383166000818152600960205260408120805460ff19166001908117909155600a805491820181559091526000805160206200516d8339815191520180546001600160a01b03191690911790555b600b80546001600160a01b0385166001600160a01b0319909116179055601180546001600160801b03808516600160801b029116179055600d819055604051620001a59062000265565b604051809103906000f080158015620001c2573d6000803e3d6000fd5b50601280546001600160a01b0319166001600160a01b03928316179055604051428152908416906000907fa2e29fe96457476993f3188189d22408c86df0c977ec90a31b979c899800d0659060200160405180910390a360408051600081526001600160801b03841660208201527fec6b0785fd83ba51c66ca8c8bb1e4fbdd02a0cced0457a21583fdf399eb3e000910160405180910390a150505050620002f0565b6104d28062004c9b83390190565b80516001600160a01b03811681146200028b57600080fd5b919050565b60008060008060808587031215620002a757600080fd5b620002b28562000273565b9350620002c26020860162000273565b60408601519093506001600160801b0381168114620002e057600080fd5b6060959095015193969295505050565b61499b80620003006000396000f3fe60806040526004361061038b5760003560e01c806384271a6c116101dc578063bd45c4e711610102578063d8f1bd68116100a0578063f340fa011161006f578063f340fa0114610b98578063f75c266414610bab578063f830e7b414610bcb578063fadd10a214610beb57600080fd5b8063d8f1bd6814610b0e578063dfde3fdb14610b2e578063e0a73a9314610b5e578063e9523c9714610b8357600080fd5b8063c1e26e33116100dc578063c1e26e3314610aae578063c3294bb5146105bb578063c34c08e514610ace578063d72dd3b414610aee57600080fd5b8063bd45c4e714610a7b578063bf5d3f2414610a8e578063c0ab8899146109af57600080fd5b8063ab818db71161017a578063afdd2aed11610149578063afdd2aed146109f9578063b041758714610a19578063b63b38d014610a46578063b854bb5614610a5b57600080fd5b8063ab818db71461098f578063ac61b46f146109af578063ada82c7d146109c4578063aeb79211146109d957600080fd5b806395ec1be8116101b657806395ec1be8146105bb57806397f8a94f146109045780639a295d4914610924578063a86529d81461094457600080fd5b806384271a6c1461087557806389168e1814610895578063908c07c5146108b557600080fd5b806354b09ac5116102c1578063682c20581161025f578063732a8eda1161022e578063732a8eda146107c357806374bdda60146107fb578063796a9e43146108285780637a67bbf91461085557600080fd5b8063682c2058146107095780636c0cf7b71461073b5780636e6e8a021461078357806370480275146107a357600080fd5b80635c975abb1161029b5780635c975abb146106665780635ffdc9ca14610680578063667cb4b7146106c957806366c96b37146106e957600080fd5b806354b09ac5146106105780635689f039146106305780635b7b018c1461064657600080fd5b80632898bff81161032e578063304281cb11610308578063304281cb1461053c5780633083d598146105bb578063439b3e1c146105d05780634a578150146105f057600080fd5b80632898bff8146104d8578063295a5212146104f85780632e1a7d4d1461051c57600080fd5b80631785f53c1161036a5780631785f53c1461043a57806322b6a4e11461045a57806324d7806c146104885780632687b2b1146104b857600080fd5b80626a5fa11461039057806314bfd6d0146103e057806316c38b3c14610418575b600080fd5b34801561039c57600080fd5b506103cb6103ab366004613b0a565b805160208183018101805160048252928201919093012091525460ff1681565b60405190151581526020015b60405180910390f35b3480156103ec57600080fd5b506104006103fb366004613b3e565b610c0b565b6040516001600160a01b0390911681526020016103d7565b34801561042457600080fd5b50610438610433366004613b65565b610c35565b005b34801561044657600080fd5b50610438610455366004613b9e565b610c80565b34801561046657600080fd5b5061047a610475366004613b3e565b610e43565b6040516103d7929190613c11565b34801561049457600080fd5b506103cb6104a3366004613b9e565b60096020526000908152604090205460ff1681565b3480156104c457600080fd5b506104386104d3366004613cc9565b610ef2565b3480156104e457600080fd5b506104386104f3366004613d66565b611207565b34801561050457600080fd5b5061050e600d5481565b6040519081526020016103d7565b34801561052857600080fd5b50610438610537366004613b3e565b611244565b34801561054857600080fd5b50610595610557366004613b0a565b805180820160209081018051600180835293830192909401919091209290528154908201546002909201546001600160a01b03918216929091169083565b604080516001600160a01b039485168152939092166020840152908201526060016103d7565b3480156105c757600080fd5b5061050e600181565b3480156105dc57600080fd5b506104386105eb366004613d66565b611302565b3480156105fc57600080fd5b5061043861060b366004613d8f565b61139e565b34801561061c57600080fd5b5061050e61062b366004613e86565b611a8f565b34801561063c57600080fd5b5061050e600f5481565b34801561065257600080fd5b50610438610661366004613b9e565b611ad6565b34801561067257600080fd5b50600e546103cb9060ff1681565b34801561068c57600080fd5b506106b461069b366004613b3e565b6005602052600090815260409020805460019091015482565b604080519283526020830191909152016103d7565b3480156106d557600080fd5b506104386106e4366004613ec1565b611b5c565b3480156106f557600080fd5b5061050e610704366004613ef4565b611d69565b34801561071557600080fd5b506011546001600160801b03165b6040516001600160801b0390911681526020016103d7565b34801561074757600080fd5b5061050e610756366004613f44565b81516020818401810180516008825292820194820194909420919093529091526000908152604090205481565b34801561078f57600080fd5b5061043861079e366004613f88565b611db7565b3480156107af57600080fd5b506104386107be366004613b9e565b611f12565b3480156107cf57600080fd5b5061050e6107de366004613b0a565b805160208183018101805160078252928201919093012091525481565b34801561080757600080fd5b5061050e610816366004613b9e565b60106020526000908152604090205481565b34801561083457600080fd5b50610848610843366004613b0a565b611ffe565b6040516103d79190614048565b34801561086157600080fd5b50610438610870366004614095565b612078565b34801561088157600080fd5b50610438610890366004613e86565b612140565b3480156108a157600080fd5b506104386108b03660046140eb565b6123b7565b3480156108c157600080fd5b506106b46108d0366004613f44565b8151602081840181018051600682529282019482019490942091909352909152600090815260409020805460019091015482565b34801561091057600080fd5b5061040061091f366004613f44565b6124a7565b34801561093057600080fd5b5061043861093f366004614184565b6124ee565b34801561095057600080fd5b506103cb61095f3660046141ee565b81516020818401810180516002825292820194820194909420919093529091526000908152604090205460ff1681565b34801561099b57600080fd5b5061050e6109aa366004614232565b6126e1565b3480156109bb57600080fd5b5061050e600281565b3480156109d057600080fd5b5061043861279d565b3480156109e557600080fd5b506104386109f4366004614265565b6127de565b348015610a0557600080fd5b50610438610a143660046142d3565b6129f7565b348015610a2557600080fd5b50610a39610a34366004613b9e565b612c58565b6040516103d7919061435d565b348015610a5257600080fd5b50610438612cf2565b348015610a6757600080fd5b506103cb610a76366004613f44565b612d79565b610438610a89366004614370565b612df1565b348015610a9a57600080fd5b50610438610aa93660046143e6565b61316a565b348015610aba57600080fd5b50610438610ac9366004613b0a565b61320b565b348015610ada57600080fd5b50601254610400906001600160a01b031681565b348015610afa57600080fd5b50610438610b09366004613b3e565b61338d565b348015610b1a57600080fd5b50610438610b29366004613f88565b6133c1565b348015610b3a57600080fd5b506103cb610b49366004613b3e565b60146020526000908152604090205460ff1681565b348015610b6a57600080fd5b50601154600160801b90046001600160801b0316610723565b348015610b8f57600080fd5b50610848613516565b610438610ba6366004613b9e565b613578565b348015610bb757600080fd5b50600b54610400906001600160a01b031681565b348015610bd757600080fd5b50600c54610400906001600160a01b031681565b348015610bf757600080fd5b5061050e610c06366004613b0a565b6135e6565b600a8181548110610c1b57600080fd5b6000918252602090912001546001600160a01b0316905081565b3360009081526009602052604090205460ff16610c6d5760405162461bcd60e51b8152600401610c649061441d565b60405180910390fd5b600e805460ff1916911515919091179055565b600b546001600160a01b03163314610caa5760405162461bcd60e51b8152600401610c6490614441565b6001600160a01b03811660009081526009602052604090205460ff16610ccf57600080fd5b6001600160a01b0381166000908152600960205260408120805460ff19169055600a54905b610cff600183614479565b811015610dcc57826001600160a01b0316600a8281548110610d2357610d23614490565b6000918252602090912001546001600160a01b03161415610dba57600a610d4b600184614479565b81548110610d5b57610d5b614490565b600091825260209091200154600a80546001600160a01b039092169183908110610d8757610d87614490565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550610dcc565b80610dc4816144a6565b915050610cf4565b50600a805480610dde57610dde6144c1565b6000828152602090819020600019908301810180546001600160a01b03191690559091019091556040516001600160a01b03841681527f753f40ca3312b2408759a67875b367955e7baa221daf08aa3d643d96202ac12b910160405180910390a15050565b601360205260009081526040902080546001820180546001600160a01b039092169291610e6f906144d7565b80601f0160208091040260200160405190810160405280929190818152602001828054610e9b906144d7565b8015610ee85780601f10610ebd57610100808354040283529160200191610ee8565b820191906000526020600020905b815481529060010190602001808311610ecb57829003601f168201915b5050505050905082565b3360009081526009602052604090205460ff16610f215760405162461bcd60e51b8152600401610c649061441d565b85610f5c5760405162461bcd60e51b815260206004820152600b60248201526a195b5c1d1e48185c1c125160aa1b6044820152606401610c64565b6001600160a01b038516610fa55760405162461bcd60e51b815260206004820152601060248201526f7a65726f20617070206164647265737360801b6044820152606401610c64565b600060018888604051610fb9929190614512565b90815260405190819003602001902080549091506001600160a01b03161561100f5760405162461bcd60e51b8152602060048201526009602482015268185c1c08195e1a5cdd60ba1b6044820152606401610c64565b6001600160a01b0386166000908152602081905260409020611032908989613909565b5080546001600160a01b038088166001600160a01b031992831617835560018084018054928916929093169190911790915560028201859055600090611079908490614522565b6001600160401b0381111561109057611090613a16565b6040519080825280602002602001820160405280156110b9578160200160208202803683370190505b50905086816000815181106110d0576110d0614490565b60200260200101906001600160a01b031690816001600160a01b03168152505060005b838110156111685784848281811061110d5761110d614490565b90506020020160208101906111229190613b9e565b8261112e836001614522565b8151811061113e5761113e614490565b6001600160a01b039092166020928302919091019091015280611160816144a6565b9150506110f3565b506111ad89898080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508592506001915061360e9050565b856001600160a01b0316876001600160a01b03167fe6814e9c971e79d8cfa0cb8a20ef274c921710f5df7a6e19ca62fb272dc45cf58b8b896040516111f493929190614563565b60405180910390a3505050505050505050565b3360009081526009602052604090205460ff166112365760405162461bcd60e51b8152600401610c649061441d565b6001600160801b0316600f55565b3360009081526010602052604081208054839290611263908490614479565b909155505060405181815233907f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243649060200160405180910390a26000336001600160a01b0316826040515b60006040518083038185875af1925050503d80600081146112eb576040519150601f19603f3d011682016040523d82523d6000602084013e6112f0565b606091505b50509050806112fe57600080fd5b5050565b3360009081526009602052604090205460ff166113315760405162461bcd60e51b8152600401610c649061441d565b60115460408051600160801b9092046001600160801b039081168352831660208301527fec6b0785fd83ba51c66ca8c8bb1e4fbdd02a0cced0457a21583fdf399eb3e000910160405180910390a1601180546001600160801b03928316600160801b029216919091179055565b6016546001146113ad57600080fd5b6000601655600e5460ff16156113ee5760405162461bcd60e51b81526020600482015260066024820152651c185d5cd95960d21b6044820152606401610c64565b806020015181608001516000611409600d5460029081161490565b61148a5760028083161461148a57600f546001600160a01b03841660009081526010602052604090205410156114785760405162461bcd60e51b81526020600482015260146024820152731b195cdcc81d1a185b881b5a5b88189d5919d95d60621b6044820152606401610c64565b620186a05a6114879190614522565b90505b600b546001600160a01b031633146114b45760405162461bcd60e51b8152600401610c6490614441565b60208401516001600160a01b03871615806114e05750806001600160a01b0316876001600160a01b0316145b61151d5760405162461bcd60e51b815260206004820152600e60248201526d77726f6e672066616c6c6261636b60901b6044820152606401610c64565b60048660405161152d9190614587565b9081526040519081900360200190205460ff16156115795760405162461bcd60e51b8152602060048201526009602482015268189b1858dadb1a5cdd60ba1b6044820152606401610c64565b600d546001908116146115fa576002866040516115969190614587565b90815260408051602092819003830190206001600160a01b038c166000908152925290205460ff166115fa5760405162461bcd60e51b815260206004820152600d60248201526c3737903832b936b4b9b9b4b7b760991b6044820152606401610c64565b600061161486600001518388604001518960600151611a8f565b60008181526014602052604090205490915060ff16156116675760405162461bcd60e51b815260206004820152600e60248201526d195e1958c818dbdb5c1b195d195960921b6044820152606401610c64565b60006060601260009054906101000a90046001600160a01b03166001600160a01b031663978802398d8d878c604001518d606001516040518663ffffffff1660e01b81526004016116bc9594939291906145a3565b6000604051808303816000875af19250505080156116fc57506040513d6000823e601f3d908101601f191682016040526116f991908101906145e1565b60015b61176857611708614678565b806308c379a0141561172f575061171d614694565b806117285750611731565b905061176e565b505b3d80801561175b576040519150601f19603f3d011682016040523d82523d6000602084013e611760565b606091505b50905061176e565b90925090505b8b6001600160a01b0316846001600160a01b031689600001517f0a2dd9a3c77dd69c3b4a5c5ef91fe5f43dfa5365029792e918b9db16ad2c35aa8b604001518c6060015187876040516117c4949392919061471d565b60405180910390a45080156117f1576000828152601460205260409020805460ff1916600117905561197b565b6001600160a01b0389166118bd576040805180820182526001600160a01b038d8116825260208083018e815260008781526013835294909420835181546001600160a01b03191693169290921782559251805192939192611858926001850192019061398d565b509050508a6001600160a01b0316836001600160a01b031688600001517fdad73de9dcb4c7934ccf673a532ca1547846f401631886090cb5c83c2e9ccd498a604001518b606001518f6040516118b09392919061474e565b60405180910390a461197b565b601580549060006118cd836144a6565b91905055508660400151896001600160a01b0316846001600160a01b03167fa17aef042e1a5dd2b8e68f0d0d92f9a6a0b35dc25be1d12c0cb3135bfd8951c963a35fe8bf60e01b8f8f604051602401611927929190613c11565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506000808e60155460405161197295949392919061476d565b60405180910390a45b505081159050611a80576011546000906119a590600160801b90046001600160801b03163a614522565b5a6119b09084614479565b6119ba91906147bb565b6001600160a01b038516600090815260106020526040902054909150818111611a185760405162461bcd60e51b815260206004820152601060248201526f1b9bc8195b9bdd59da08189d5919d95d60821b6044820152606401610c64565b611a228282614479565b6001600160a01b03861660009081526010602052604081209190915560118054849290611a599084906001600160801b03166147da565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555050505b50506001601655505050505050565b604080516020808201969096526001600160a01b03949094168482015260608401929092526080808401919091528151808403909101815260a09092019052805191012090565b600b546001600160a01b03163314611b005760405162461bcd60e51b8152600401610c6490614441565b600c80546001600160a01b0319166001600160a01b03838116918217909255600b54604051428152919216907f587ad0bc9a6955b6c850bc4f90ab8c66b32e2a6919d4244e459ac74ffa4a88849060200160405180910390a350565b6001600160a01b03821660009081526020819052604081208054611b7f906144d7565b80601f0160208091040260200160405190810160405280929190818152602001828054611bab906144d7565b8015611bf85780601f10611bcd57610100808354040283529160200191611bf8565b820191906000526020600020905b815481529060010190602001808311611bdb57829003601f168201915b505050505090506000600182604051611c119190614587565b90815260405190819003602001902080549091506001600160a01b03908116908516148015611c4857506001600160a01b03841615155b611c645760405162461bcd60e51b8152600401610c6490614805565b600b546001600160a01b0316331480611c89575060018101546001600160a01b031633145b611ca55760405162461bcd60e51b8152600401610c649061482c565b6001600160a01b03831660009081526020819052604090208054611cc8906144d7565b159050611d0b5760405162461bcd60e51b81526020600482015260116024820152701b995dc8185c1c081a5cc81a5b9a5d1959607a1b6044820152606401610c64565b80546001600160a01b0319166001600160a01b038481169182178355604051908616907fd037ce9f8e96b2c7cdea421a50a484949e5f9e1e4914834059493cbfbf65862290611d5b90869061435d565b60405180910390a350505050565b6000611dae85858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508792508691506137509050565b95945050505050565b6001600160a01b03821660009081526020819052604081208054611dda906144d7565b80601f0160208091040260200160405190810160405280929190818152602001828054611e06906144d7565b8015611e535780601f10611e2857610100808354040283529160200191611e53565b820191906000526020600020905b815481529060010190602001808311611e3657829003601f168201915b505050505090506000600182604051611e6c9190614587565b90815260405190819003602001902080549091506001600160a01b03908116908516148015611ea357506001600160a01b03841615155b611ebf5760405162461bcd60e51b8152600401610c6490614805565b600b546001600160a01b0316331480611ee4575060018101546001600160a01b031633145b611f005760405162461bcd60e51b8152600401610c649061482c565b611f0c8284600161360e565b50505050565b600b546001600160a01b03163314611f3c5760405162461bcd60e51b8152600401610c6490614441565b6001600160a01b03811660009081526009602052604090205460ff1615611f6257600080fd5b6001600160a01b0381166000818152600960209081526040808320805460ff19166001908117909155600a805491820181559093527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a890920180546001600160a01b0319168417905590519182527fad6de4452a631e641cb59902236607946ce9272b9b981f2f80e8d129cb9084ba910160405180910390a150565b60606003826040516120109190614587565b908152604080519182900360209081018320805480830285018301909352828452919083018282801561206c57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161204e575b50505050509050919050565b3360009081526009602052604090205460ff166120a75760405162461bcd60e51b8152600401610c649061441d565b60005b82811015611f0c573063bf5d3f248585848181106120ca576120ca614490565b90506020028101906120dc919061484c565b856040518463ffffffff1660e01b81526004016120fb93929190614892565b600060405180830381600087803b15801561211557600080fd5b505af1158015612129573d6000803e3d6000fd5b505050508080612138906144a6565b9150506120aa565b600061214e85858585611a8f565b60008181526014602052604090205490915060ff16156121a15760405162461bcd60e51b815260206004820152600e60248201526d195e1958c818dbdb5c1b195d195960921b6044820152606401610c64565b600081815260136020526040902080546001600160a01b03166121f85760405162461bcd60e51b815260206004820152600f60248201526e1b9bc81c995d1c9e481c9958dbdc99608a1b6044820152606401610c64565b80546001820180546001600160a01b039092169160009190612219906144d7565b80601f0160208091040260200160405190810160405280929190818152602001828054612245906144d7565b80156122925780601f1061226757610100808354040283529160200191612292565b820191906000526020600020905b81548152906001019060200180831161227557829003601f168201915b505086546001600160a01b031916875550506040805160208101918290526000908190529293506122c89260018701925061398d565b50601254604051639788023960e01b81526000916001600160a01b03169063978802399061230290869086908d908d908d906004016145a3565b6000604051808303816000875af1158015612321573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261234991908101906145e1565b5090508061235657600080fd5b60008581526014602052604090819020805460ff19166001179055516001600160a01b038916908a907f819e22d91cf6246af3647f0722340d66b71cae69d9c6b1cbbf015ed0ec46c9c4906111f4908b908b90918252602082015260400190565b3360009081526009602052604090205460ff166123e65760405162461bcd60e51b8152600401610c649061441d565b8483811480156123f557508082145b6123fe57600080fd5b60005b8181101561249d57604051806040016040528087878481811061242657612426614490565b90506020020135815260200185858481811061244457612444614490565b90506020020135815250600560008a8a8581811061246457612464614490565b60209081029290920135835250818101929092526040016000208251815591015160019091015580612495816144a6565b915050612401565b5050505050505050565b815160208184018101805160038252928201918501919091209190528054829081106124d257600080fd5b6000918252602090912001546001600160a01b03169150829050565b3360009081526009602052604090205460ff1661251d5760405162461bcd60e51b8152600401610c649061441d565b6001600160a01b03861660009081526020819052604081208054612540906144d7565b80601f016020809104026020016040519081016040528092919081815260200182805461256c906144d7565b80156125b95780601f1061258e576101008083540402835291602001916125b9565b820191906000526020600020905b81548152906001019060200180831161259c57829003601f168201915b5050505050905060006001826040516125d29190614587565b90815260405190819003602001902080549091506001600160a01b0390811690891614801561260957506001600160a01b03881615155b6126255760405162461bcd60e51b8152600401610c6490614805565b8483811461263257600080fd5b876007846040516126439190614587565b9081526040519081900360200190205560005b818110156126d55785858281811061267057612670614490565b905060200201356008856040516126879190614587565b908152602001604051809103902060008a8a858181106126a9576126a9614490565b9050602002013581526020019081526020016000208190555080806126cd906144a6565b915050612656565b50505050505050505050565b6001600160a01b03831660009081526020819052604081208054829190612707906144d7565b80601f0160208091040260200160405190810160405280929190818152602001828054612733906144d7565b80156127805780601f1061275557610100808354040283529160200191612780565b820191906000526020600020905b81548152906001019060200180831161276357829003601f168201915b50505050509050612792818585613750565b9150505b9392505050565b601180546fffffffffffffffffffffffffffffffff198116909155600b546040516001600160801b03909216916000916001600160a01b03169083906112ae565b6001600160a01b03851660009081526020819052604081208054612801906144d7565b80601f016020809104026020016040519081016040528092919081815260200182805461282d906144d7565b801561287a5780601f1061284f5761010080835404028352916020019161287a565b820191906000526020600020905b81548152906001019060200180831161285d57829003601f168201915b5050505050905060006001826040516128939190614587565b90815260405190819003602001902080549091506001600160a01b039081169088161480156128ca57506001600160a01b03871615155b6128e65760405162461bcd60e51b8152600401610c6490614805565b600b546001600160a01b031633148061290b575060018101546001600160a01b031633145b6129275760405162461bcd60e51b8152600401610c649061482c565b6001600160a01b03861615612954576001810180546001600160a01b0319166001600160a01b0388161790555b6002810185905582156129a1576129a1828585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506001925061360e915050565b856001600160a01b0316876001600160a01b03167fe6814e9c971e79d8cfa0cb8a20ef274c921710f5df7a6e19ca62fb272dc45cf584886040516129e69291906148b8565b60405180910390a350505050505050565b3360009081526009602052604090205460ff16612a265760405162461bcd60e51b8152600401610c649061441d565b6001600160a01b03871660009081526020819052604081208054612a49906144d7565b80601f0160208091040260200160405190810160405280929190818152602001828054612a75906144d7565b8015612ac25780601f10612a9757610100808354040283529160200191612ac2565b820191906000526020600020905b815481529060010190602001808311612aa557829003601f168201915b505050505090506000600182604051612adb9190614587565b90815260405190819003602001902080549091506001600160a01b03908116908a16148015612b1257506001600160a01b03891615155b612b2e5760405162461bcd60e51b8152600401610c6490614805565b600280820154811614612b725760405162461bcd60e51b815260206004820152600c60248201526b199b1859c81b9bdd081cd95d60a21b6044820152606401610c64565b868581148015612b8157508084145b612b8a57600080fd5b6000600684604051612b9c9190614587565b9081526020016040518091039020905060005b82811015612c4a5760405180604001604052808a8a84818110612bd457612bd4614490565b905060200201358152602001888884818110612bf257612bf2614490565b905060200201358152508260008d8d85818110612c1157612c11614490565b60209081029290920135835250818101929092526040016000208251815591015160019091015580612c42816144a6565b915050612baf565b505050505050505050505050565b60006020819052908152604090208054612c71906144d7565b80601f0160208091040260200160405190810160405280929190818152602001828054612c9d906144d7565b8015612cea5780601f10612cbf57610100808354040283529160200191612cea565b820191906000526020600020905b815481529060010190602001808311612ccd57829003601f168201915b505050505081565b600c546001600160a01b03163314612d0957600080fd5b600c54600b546040514281526001600160a01b0392831692909116907fa2e29fe96457476993f3188189d22408c86df0c977ec90a31b979c899800d0659060200160405180910390a3600c8054600b80546001600160a01b03199081166001600160a01b03841617909155169055565b600080600884604051612d8c9190614587565b908152604080516020928190038301902060008681529252902054905060018082161415612dbe576001915050612deb565b600784604051612dce9190614587565b9081526040519081900360200190205490506001808216145b9150505b92915050565b601654600114612e0057600080fd5b6000601655600e5460ff1615612e415760405162461bcd60e51b81526020600482015260066024820152651c185d5cd95960d21b6044820152606401610c64565b6001600160a01b0383161580612e5f57506001600160a01b03831633145b612e9c5760405162461bcd60e51b815260206004820152600e60248201526d77726f6e672066616c6c6261636b60901b6044820152606401610c64565b3360009081526020819052604081208054612eb6906144d7565b80601f0160208091040260200160405190810160405280929190818152602001828054612ee2906144d7565b8015612f2f5780601f10612f0457610100808354040283529160200191612f2f565b820191906000526020600020905b815481529060010190602001808311612f1257829003601f168201915b50505050509050600481604051612f469190614587565b9081526040519081900360200190205460ff1615612f925760405162461bcd60e51b8152602060048201526009602482015268189b1858dadb1a5cdd60ba1b6044820152606401610c64565b6000612fa3600d5460019081161490565b90508061301557600282604051612fba9190614587565b9081526040805160209281900383019020336000908152925290205460ff166130155760405162461bcd60e51b815260206004820152600d60248201526c3737903832b936b4b9b9b4b7b760991b6044820152606401610c64565b600d546002908116146130ee5760006001836040516130349190614587565b90815260200160405180910390209050818015613059575080546001600160a01b0316155b8061306d575080546001600160a01b031633145b6130895760405162461bcd60e51b8152600401610c6490614805565b60018085161480156130a4575080546001600160a01b031633145b156130b3578060020154841793505b600280851614156130dc5760006130cb84878a613750565b90506130d68161383d565b506130ec565b34156130ec576130ec600061383d565b505b601580549060006130fe836144a6565b919050555083886001600160a01b0316336001600160a01b03167fa17aef042e1a5dd2b8e68f0d0d92f9a6a0b35dc25be1d12c0cb3135bfd8951c98a8a8a8989601554604051613153969594939291906148da565b60405180910390a450506001601655505050505050565b3360009081526009602052604090205460ff166131995760405162461bcd60e51b8152600401610c649061441d565b80600484846040516131ac929190614512565b908152604051908190036020018120805492151560ff19909316929092179091557f8450ad9faca1edf7a8a033ed0adf98a354d14b22658565ca76f3e11e881947c1906131fe90859085908590614892565b60405180910390a1505050565b600060028260405161321d9190614587565b90815260200160405180910390209050600060038360405161323f9190614587565b9081526040519081900360200190208054909150806000805b828110156133355784818154811061327257613272614490565b60009182526020808320909101546001600160a01b03168083529088905260409091205490925060ff16156132b357806132ab816144a6565b915050613258565b826132bd8161492a565b9350508483815481106132d2576132d2614490565b9060005260206000200160009054906101000a90046001600160a01b031685828154811061330257613302614490565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550613258565b50815b838110156133845784805480613350576133506144c1565b600082815260209020810160001990810180546001600160a01b03191690550190558061337c816144a6565b915050613338565b50505050505050565b3360009081526009602052604090205460ff166133bc5760405162461bcd60e51b8152600401610c649061441d565b600d55565b6001600160a01b038216600090815260208190526040812080546133e4906144d7565b80601f0160208091040260200160405190810160405280929190818152602001828054613410906144d7565b801561345d5780601f106134325761010080835404028352916020019161345d565b820191906000526020600020905b81548152906001019060200180831161344057829003601f168201915b5050505050905060006001826040516134769190614587565b90815260405190819003602001902080549091506001600160a01b039081169085161480156134ad57506001600160a01b03841615155b6134c95760405162461bcd60e51b8152600401610c6490614805565b600b546001600160a01b03163314806134ee575060018101546001600160a01b031633145b61350a5760405162461bcd60e51b8152600401610c649061482c565b611f0c8284600061360e565b6060600a80548060200260200160405190810160405280929190818152602001828054801561356e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613550575b5050505050905090565b6001600160a01b038116600090815260106020526040812080543492906135a0908490614522565b90915550506040513481526001600160a01b038216907fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c9060200160405180910390a250565b60006003826040516135f89190614587565b9081526040519081900360200190205492915050565b60006002846040516136209190614587565b9081526020016040518091039020905060006003856040516136429190614587565b90815260405190819003602001902090506000805b85518110156133845785818151811061367257613672614490565b6020908102919091018101516001600160a01b03811660009081529186905260409091205490925060ff16151585151514156136ad5761373e565b84156136df5782546001810184556000848152602090200180546001600160a01b0319166001600160a01b0384161790555b6001600160a01b03821660008181526020869052604090819020805460ff1916881515179055517f5059f2158bd5a3ba277fdb58bf30871e09bae3987abede6055be2e87bbf7f79690613735908a908990614941565b60405180910390a25b80613748816144a6565b915050613657565b6000806006856040516137639190614587565b9081526040805160209281900383018120600088815290845282902081830190925281548082526001909201549281018390529250906137a38787612d79565b156137c6576137b281866147bb565b6137bc9083614522565b9350505050612796565b60008681526005602090815260408083208151808301909252805480835260019091015492820183905290929091908286116138025782613804565b855b905060008286116138155782613817565b855b9050613823818b6147bb565b61382d9083614522565b9c9b505050505050505050505050565b803410156138815760405162461bcd60e51b81526020600482015260116024820152706e6f20656e6f756768207372632066656560781b6044820152606401610c64565b80156138e957600b546040516000916001600160a01b03169083908381818185875af1925050503d80600081146138d4576040519150601f19603f3d011682016040523d82523d6000602084013e6138d9565b606091505b50509050806138e757600080fd5b505b80341115613906576000336138fe8334614479565b6040516112ae565b50565b828054613915906144d7565b90600052602060002090601f016020900481019282613937576000855561397d565b82601f106139505782800160ff1982351617855561397d565b8280016001018555821561397d579182015b8281111561397d578235825591602001919060010190613962565b50613989929150613a01565b5090565b828054613999906144d7565b90600052602060002090601f0160209004810192826139bb576000855561397d565b82601f106139d457805160ff191683800117855561397d565b8280016001018555821561397d579182015b8281111561397d5782518255916020019190600101906139e6565b5b808211156139895760008155600101613a02565b634e487b7160e01b600052604160045260246000fd5b60a081018181106001600160401b0382111715613a4b57613a4b613a16565b60405250565b601f8201601f191681016001600160401b0381118282101715613a7657613a76613a16565b6040525050565b60006001600160401b03821115613a9657613a96613a16565b50601f01601f191660200190565b6000613aaf83613a7d565b604051613abc8282613a51565b809250848152858585011115613ad157600080fd5b8484602083013760006020868301015250509392505050565b600082601f830112613afb57600080fd5b61279683833560208501613aa4565b600060208284031215613b1c57600080fd5b81356001600160401b03811115613b3257600080fd5b612de784828501613aea565b600060208284031215613b5057600080fd5b5035919050565b801515811461390657600080fd5b600060208284031215613b7757600080fd5b813561279681613b57565b80356001600160a01b0381168114613b9957600080fd5b919050565b600060208284031215613bb057600080fd5b61279682613b82565b60005b83811015613bd4578181015183820152602001613bbc565b83811115611f0c5750506000910152565b60008151808452613bfd816020860160208601613bb9565b601f01601f19169290920160200192915050565b6001600160a01b0383168152604060208201819052600090613c3590830184613be5565b949350505050565b60008083601f840112613c4f57600080fd5b5081356001600160401b03811115613c6657600080fd5b602083019150836020828501011115613c7e57600080fd5b9250929050565b60008083601f840112613c9757600080fd5b5081356001600160401b03811115613cae57600080fd5b6020830191508360208260051b8501011115613c7e57600080fd5b600080600080600080600060a0888a031215613ce457600080fd5b87356001600160401b0380821115613cfb57600080fd5b613d078b838c01613c3d565b9099509750879150613d1b60208b01613b82565b9650613d2960408b01613b82565b955060608a0135945060808a0135915080821115613d4657600080fd5b50613d538a828b01613c85565b989b979a50959850939692959293505050565b600060208284031215613d7857600080fd5b81356001600160801b038116811461279657600080fd5b6000806000806000858703610120811215613da957600080fd5b613db287613b82565b955060208701356001600160401b0380821115613dce57600080fd5b818901915089601f830112613de257600080fd5b613df18a833560208501613aa4565b9650613dff60408a01613b82565b95506060890135915080821115613e1557600080fd5b50613e2289828a01613aea565b93505060a0607f1982011215613e3757600080fd5b50604051613e4481613a2c565b60808701358152613e5760a08801613b82565b602082015260c0870135604082015260e087013560608201526101009096013560808701525092959194509290565b60008060008060808587031215613e9c57600080fd5b84359350613eac60208601613b82565b93969395505050506040820135916060013590565b60008060408385031215613ed457600080fd5b613edd83613b82565b9150613eeb60208401613b82565b90509250929050565b60008060008060608587031215613f0a57600080fd5b84356001600160401b03811115613f2057600080fd5b613f2c87828801613c3d565b90989097506020870135966040013595509350505050565b60008060408385031215613f5757600080fd5b82356001600160401b03811115613f6d57600080fd5b613f7985828601613aea565b95602094909401359450505050565b60008060408385031215613f9b57600080fd5b613fa483613b82565b91506020808401356001600160401b0380821115613fc157600080fd5b818601915086601f830112613fd557600080fd5b813581811115613fe757613fe7613a16565b8060051b9150604051613ffc85840182613a51565b8181529183018401918481018984111561401557600080fd5b938501935b838510156140385761402b85613b82565b815293850193850161401a565b5080955050505050509250929050565b6020808252825182820181905260009190848201906040850190845b818110156140895783516001600160a01b031683529284019291840191600101614064565b50909695505050505050565b6000806000604084860312156140aa57600080fd5b83356001600160401b038111156140c057600080fd5b6140cc86828701613c85565b90945092505060208401356140e081613b57565b809150509250925092565b6000806000806000806060878903121561410457600080fd5b86356001600160401b038082111561411b57600080fd5b6141278a838b01613c85565b9098509650602089013591508082111561414057600080fd5b61414c8a838b01613c85565b9096509450604089013591508082111561416557600080fd5b5061417289828a01613c85565b979a9699509497509295939492505050565b6000806000806000806080878903121561419d57600080fd5b6141a687613b82565b95506020870135945060408701356001600160401b03808211156141c957600080fd5b6141d58a838b01613c85565b9096509450606089013591508082111561416557600080fd5b6000806040838503121561420157600080fd5b82356001600160401b0381111561421757600080fd5b61422385828601613aea565b925050613eeb60208401613b82565b60008060006060848603121561424757600080fd5b61425084613b82565b95602085013595506040909401359392505050565b60008060008060006080868803121561427d57600080fd5b61428686613b82565b945061429460208701613b82565b93506040860135925060608601356001600160401b038111156142b657600080fd5b6142c288828901613c85565b969995985093965092949392505050565b60008060008060008060006080888a0312156142ee57600080fd5b6142f788613b82565b965060208801356001600160401b038082111561431357600080fd5b61431f8b838c01613c85565b909850965060408a013591508082111561433857600080fd5b6143448b838c01613c85565b909650945060608a0135915080821115613d4657600080fd5b6020815260006127966020830184613be5565b60008060008060008060a0878903121561438957600080fd5b61439287613b82565b955060208701356001600160401b038111156143ad57600080fd5b6143b989828a01613c3d565b90965094506143cc905060408801613b82565b925060608701359150608087013590509295509295509295565b6000806000604084860312156143fb57600080fd5b83356001600160401b0381111561441157600080fd5b6140cc86828701613c3d565b6020808252600a908201526937b7363c9030b236b4b760b11b604082015260600190565b6020808252600890820152676f6e6c79204d504360c01b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60008282101561448b5761448b614463565b500390565b634e487b7160e01b600052603260045260246000fd5b60006000198214156144ba576144ba614463565b5060010190565b634e487b7160e01b600052603160045260246000fd5b600181811c908216806144eb57607f821691505b6020821081141561450c57634e487b7160e01b600052602260045260246000fd5b50919050565b8183823760009101908152919050565b6000821982111561453557614535614463565b500190565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60408152600061457760408301858761453a565b9050826020830152949350505050565b60008251614599818460208701613bb9565b9190910192915050565b600060018060a01b03808816835260a060208401526145c560a0840188613be5565b9516604083015250606081019290925260809091015292915050565b600080604083850312156145f457600080fd5b82516145ff81613b57565b60208401519092506001600160401b0381111561461b57600080fd5b8301601f8101851361462c57600080fd5b805161463781613a7d565b6040516146448282613a51565b82815287602084860101111561465957600080fd5b61466a836020830160208701613bb9565b809450505050509250929050565b600060033d11156146915760046000803e5060005160e01c5b90565b600060443d10156146a25790565b6040516003193d81016004833e81513d6001600160401b0381602484011181841117156146d157505050505090565b82850191508151818111156146e95750505050505090565b843d87010160208285010111156147035750505050505090565b61471260208286010187613a51565b509095945050505050565b84815283602082015282151560408201526080606082015260006147446080830184613be5565b9695505050505050565b838152826020820152606060408201526000611dae6060830184613be5565b60a08152600061478060a0830188613be5565b6001600160a01b03871660208401526040830186905282810360608401526147a88186613be5565b9150508260808301529695505050505050565b60008160001904831182151516156147d5576147d5614463565b500290565b60006001600160801b038083168185168083038211156147fc576147fc614463565b01949350505050565b6020808252600d908201526c185c1c081b9bdd08195e1a5cdd609a1b604082015260600190565b602080825260069082015265199bdc989a5960d21b604082015260600190565b6000808335601e1984360301811261486357600080fd5b8301803591506001600160401b0382111561487d57600080fd5b602001915036819003821315613c7e57600080fd5b6040815260006148a660408301858761453a565b90508215156020830152949350505050565b6040815260006148cb6040830185613be5565b90508260208301529392505050565b60a0815260006148ee60a08301888a61453a565b6001600160a01b03871660208401526040830186905282810360608401526149168186613be5565b915050826080830152979650505050505050565b60008161493957614939614463565b506000190190565b6040815260006149546040830185613be5565b90508215156020830152939250505056fea26469706673582212204e1b96aa8e938dce9d9038624fb950883d1b48c45135400861d92998f26661f864736f6c634300080a0033608060405234801561001057600080fd5b50600380546001600160a01b031916331790556104a0806100326000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806302d05d3f146100465780639788023914610076578063d0496d6a14610097575b600080fd5b600354610059906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b610089610084366004610221565b6100d7565b60405161006d9291906102f7565b6000546001546002546100b2926001600160a01b0316919083565b604080516001600160a01b03909416845260208401929092529082015260600161006d565b6003546000906060906001600160a01b031633146101135760006040518060600160405280602a8152602001610441602a9139915091506101fa565b604080516060810182526001600160a01b0380881680835260208301889052918301869052600080546001600160a01b031916909217909155600186905560028590559051639abaf47960e01b815290891690639abaf4799061017c908a908a90600401610333565b6000604051808303816000875af115801561019b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526101c39190810190610378565b60408051606081018252600080825260208201819052910181905280546001600160a01b0319168155600181905560025590925090505b965096945050505050565b80356001600160a01b038116811461021c57600080fd5b919050565b60008060008060008060a0878903121561023a57600080fd5b61024387610205565b9550602087013567ffffffffffffffff8082111561026057600080fd5b818901915089601f83011261027457600080fd5b81358181111561028357600080fd5b8a602082850101111561029557600080fd5b6020830197508096505050506102ad60408801610205565b925060608701359150608087013590509295509295509295565b60005b838110156102e25781810151838201526020016102ca565b838111156102f1576000848401525b50505050565b8215158152604060208201526000825180604084015261031e8160608501602087016102c7565b601f01601f1916919091016060019392505050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561038b57600080fd5b8251801515811461039b57600080fd5b602084015190925067ffffffffffffffff808211156103b957600080fd5b818501915085601f8301126103cd57600080fd5b8151818111156103df576103df610362565b604051601f8201601f19908116603f0116810190838211818310171561040757610407610362565b8160405282815288602084870101111561042057600080fd5b6104318360208301602088016102c7565b8095505050505050925092905056fe416e7943616c6c4578656375746f723a2063616c6c6572206973206e6f74207468652063726561746f72a2646970667358221220ba584322a3bbbe0ff4a3893e9de722b0475cfd58467a20f7d12e2d9998b0f81764736f6c634300080a0033c65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a8`, -} - -task("dev_deploy_anyswap", "Deploy Anyswap contracts").setAction(async function (_args, hre) { - const { ethers } = hre; - const { parseEther } = ethers.utils; - const [deployer] = await ethers.getSigners(); - - const Router = await ethers.getContractFactory(ROUTER_ABI, Bytecode.ROUTER); - const router = await Router.deploy( - ethers.constants.AddressZero, - ethers.constants.AddressZero, - deployer.address - ); - - const AnyCallProxy = await ethers.getContractFactory( - ANY_CALL_PROXY_ABI, - Bytecode.ANY_CALL_PROXY - ); - const anyCallProxy = await AnyCallProxy.deploy(deployer.address, deployer.address, 0, 1); - await anyCallProxy.deposit(deployer.address, { value: parseEther("10") }); - if (hre.network.config.chainId === DEV_CHAIN_ID_BSC) { - await anyCallProxy.setDefaultSrcFees( - [DEV_CHAIN_ID_ETH], - [parseEther("0.14")], - [parseEther("0.0000035")] - ); - } else { - await anyCallProxy.setDefaultSrcFees( - [DEV_CHAIN_ID_BSC], - [parseEther("0.0005")], - [parseEther("0.00000053")] - ); - } - - const addresses: AnyswapAddresses = { - ...newAddresses(hre), - router: router.address, - anyCallProxy: anyCallProxy.address, - anyCallExecutor: await anyCallProxy.executor(), - mpc: deployer.address, - }; - saveAddressFile(hre, `dev_anyswap`, addresses); -}); - -task("dev_anyswap_out", "Anyswap transfer CHESS to the other dev chain") - .addParam("to", "Target address") - .addParam("amount", "Amount of CHESS") - .setAction(async function (args, hre) { - const { ethers } = hre; - const { parseEther, formatEther } = ethers.utils; - - const to: string = args.to; - const amount = parseEther(args.amount); - - const router = await ethers.getContractAt( - ROUTER_ABI, - loadAddressFile(hre, "dev_anyswap").router - ); - const governanceAddresses = loadAddressFile(hre, "governance"); - const chess = await ethers.getContractAt("ERC20", governanceAddresses.chess); - - const targetChain = - hre.network.config.chainId === DEV_CHAIN_ID_BSC ? DEV_CHAIN_ID_ETH : DEV_CHAIN_ID_BSC; - console.log(`Transferring ${formatEther(amount)} CHESS to ${to} on Chain ${targetChain}`); - await chess.approve(router.address, amount); - await router.anySwapOutUnderlying( - governanceAddresses.anyswapChessPool, - to, - amount, - targetChain - ); - }); - -task("dev_anyswap_in", "Anyswap transfer CHESS from the other dev chain") - .addParam("to", "Target address") - .addParam("amount", "Amount of CHESS") - .setAction(async function (args, hre) { - const { ethers } = hre; - const { parseEther, formatEther } = ethers.utils; - - const to: string = args.to; - const amount = parseEther(args.amount); - - const router = await ethers.getContractAt( - ROUTER_ABI, - loadAddressFile(hre, "dev_anyswap").router - ); - const governanceAddresses = loadAddressFile(hre, "governance"); - - const sourceChain = - hre.network.config.chainId === DEV_CHAIN_ID_BSC ? DEV_CHAIN_ID_ETH : DEV_CHAIN_ID_BSC; - console.log(`Transferring ${formatEther(amount)} CHESS to ${to} from Chain ${sourceChain}`); - await router.anySwapInAuto( - ethers.constants.HashZero, - governanceAddresses.anyswapChessPool, - to, - amount, - sourceChain - ); - }); - -task("dev_vechess_out", "Transfer veCHESS to the other dev chain") - .addParam("amount", "Amount of CHESS") - .setAction(async function (args, hre) { - const { ethers } = hre; - const { parseEther, formatEther } = ethers.utils; - - const amount = parseEther(args.amount); - - const anyCallProxy = await ethers.getContractAt( - ANY_CALL_PROXY_ABI, - loadAddressFile(hre, "dev_anyswap").anyCallProxy - ); - const votingEscrow = await ethers.getContractAt( - "VotingEscrowV3", - loadAddressFile(hre, "governance").votingEscrow - ); - - const targetChain = - hre.network.config.chainId === DEV_CHAIN_ID_BSC ? DEV_CHAIN_ID_ETH : DEV_CHAIN_ID_BSC; - const fee = await anyCallProxy.calcSrcFees(votingEscrow.address, targetChain, 96); - console.log( - `Transferring ${formatEther( - amount - )} locked CHESS to the other dev chain with fee ${formatEther(fee)}` - ); - await votingEscrow.veChessCrossChain(amount, targetChain, { value: fee }); - }); - -task("dev_vechess_in", "Transfer veCHESS from the other dev chain") - .addParam("to", "Target address") - .addParam("amount", "Amount of CHESS") - .addParam("unlockDate", "Unlock date (YYYY-MM-DD)") - .setAction(async function (args, hre) { - const { ethers } = hre; - const { parseEther, formatEther } = ethers.utils; - - const to: string = args.to; - const amount = parseEther(args.amount); - const unlockTimestamp = endOfWeek(new Date(args.unlockDate).getTime() / 1000); - - const anyCallProxy = await ethers.getContractAt( - ANY_CALL_PROXY_ABI, - loadAddressFile(hre, "dev_anyswap").anyCallProxy - ); - const votingEscrow = await ethers.getContractAt( - "VotingEscrowV3", - loadAddressFile(hre, "governance").votingEscrow - ); - - const sourceChain = - hre.network.config.chainId === DEV_CHAIN_ID_BSC ? DEV_CHAIN_ID_ETH : DEV_CHAIN_ID_BSC; - const peerAddress = await votingEscrow.crossChainVotingEscrows(sourceChain); - const payload = ethers.utils.defaultAbiCoder.encode( - ["address", "uint256", "uint256"], - [to, amount, unlockTimestamp] - ); - console.log( - `Transferring ${formatEther( - amount - )} locked CHESS (unlocked at ${unlockTimestamp}) to ${to} from the other dev chain` - ); - await anyCallProxy.anyExec( - votingEscrow.address, - payload, - ethers.constants.AddressZero, - "", - [ - ethers.utils.hashMessage(Math.random().toString()), // source tx hash - peerAddress, - sourceChain, - 0, // nonce - 2, // flag: pay on source - ] - ); - }); - -task("dev_mint_emission", "Mint CHESS emission on sub chain") - .addParam("amount", "Amount of CHESS") - .setAction(async function (args, hre) { - const { ethers } = hre; - const { parseEther, formatEther } = ethers.utils; - const [deployer] = await ethers.getSigners(); - - assert.notStrictEqual( - hre.network.config.chainId, - DEV_CHAIN_ID_BSC, - "Cannot mint emission on the main chain" - ); - const amount = parseEther(args.amount); - - const anyCallProxy = await ethers.getContractAt( - ANY_CALL_PROXY_ABI, - loadAddressFile(hre, "dev_anyswap").anyCallProxy - ); - const chessSchedule = await ethers.getContractAt( - "ChessSubSchedule", - loadAddressFile(hre, "governance").chessSchedule - ); - - const payload = ethers.utils.defaultAbiCoder.encode(["uint256"], [amount]); - console.log(`Minting ${formatEther(amount)} CHESS emission`); - await anyCallProxy.anyExec( - chessSchedule.address, - payload, - ethers.constants.AddressZero, - "", - [ - ethers.utils.hashMessage(Math.random().toString()), // source tx hash - deployer.address, - DEV_CHAIN_ID_BSC, - 0, // nonce - 0, // flag: pay on source - ] - ); - }); - -task("dev_sync_relayer", "Set total vote in schedule relayer") - .addParam("amount", "Amount of veCHESS at the end of this week") - .addParam("nextAmount", "Amount of veCHESS at the end of the next week") - .setAction(async function (args, hre) { - const { ethers } = hre; - const { parseEther } = ethers.utils; - const [deployer] = await ethers.getSigners(); - - assert.strictEqual( - hre.network.config.chainId, - DEV_CHAIN_ID_BSC, - "Cannot sync vote on sub chain" - ); - const amount = parseEther(args.amount); - const nextAmount = parseEther(args.nextAmount); - const sourceChain = DEV_CHAIN_ID_ETH; - const week = endOfWeek((await ethers.provider.getBlock("latest")).timestamp); - - const anyCallProxy = await ethers.getContractAt( - ANY_CALL_PROXY_ABI, - loadAddressFile(hre, "dev_anyswap").anyCallProxy - ); - const chessScheduleRelayer = await ethers.getContractAt( - "ChessScheduleRelayer", - loadAddressFile( - hre, - `chess_schedule_relayer_${sourceChain}` - ).relayer - ); - - const payload = ethers.utils.defaultAbiCoder.encode( - ["uint256", "uint256", "uint256"], - [week, amount, nextAmount] - ); - console.log( - `Syncing total vote to relayer of chain ${sourceChain}: week ${week}, supply ${amount}, nextWeekSupply ${nextAmount}` - ); - await anyCallProxy.anyExec( - chessScheduleRelayer.address, - payload, - ethers.constants.AddressZero, - "", - [ - ethers.utils.hashMessage(Math.random().toString()), // source tx hash - deployer.address, - sourceChain, - 0, // nonce - 0, // flag: pay on source - ] - ); - }); diff --git a/tasks/dev_deploy_lz.ts b/tasks/dev_deploy_lz.ts new file mode 100644 index 00000000..154e17a7 --- /dev/null +++ b/tasks/dev_deploy_lz.ts @@ -0,0 +1,391 @@ +import { strict as assert } from "assert"; +import { task } from "hardhat/config"; +import { endOfWeek } from "../config"; +import { Addresses, loadAddressFile, newAddresses, saveAddressFile } from "./address_file"; +import { ChessScheduleRelayerAddresses } from "./deploy_chess_schedule_relayer"; +import type { GovernanceAddresses } from "./deploy_governance"; + +export interface LzAddresses extends Addresses { + endpoint: string; +} + +const DEV_CHAIN_ID_BSC = 5777; +const DEV_CHAIN_ID_ETH = 5701; + +const CHESS_PAYLOAD_LENGTH = 160; +const CHESS_GAS_LIMIT = 90000; +const VECHESS_PAYLOAD_LENGTH = 96; +const VECHESS_GAS_ESTIMATION = 200000; +const SYNC_PAYLOAD_LENGTH = 96; +const SYNC_GAS_LIMIT = 90000; +const MINT_PAYLOAD_LENGTH = 32; +const MINT_GAS_LIMIT = 100000; + +task("dev_deploy_lz", "Deploy LayerZero mock contracts").setAction(async function (_args, hre) { + const { ethers } = hre; + + const LZEndpointMock = await ethers.getContractFactory("LZEndpointMock"); + const endpoint = await LZEndpointMock.deploy(hre.network.config.chainId); + + const addresses: LzAddresses = { + ...newAddresses(hre), + endpoint: endpoint.address, + }; + saveAddressFile(hre, `dev_lz`, addresses); +}); + +task("dev_chess_out", "Send CHESS to the other dev chain") + .addParam("to", "Target address") + .addParam("amount", "Amount of CHESS") + .setAction(async function (args, hre) { + const { ethers } = hre; + const [deployer] = await ethers.getSigners(); + const { parseEther, formatEther } = ethers.utils; + + const to: string = args.to; + const amount = parseEther(args.amount); + + const governanceAddresses = loadAddressFile(hre, "governance"); + const chess = await ethers.getContractAt("ERC20", governanceAddresses.chess); + const chessPool = await ethers.getContractAt("ProxyOFTPool", governanceAddresses.chessPool); + const lzEndpoint = await ethers.getContractAt( + "ILayerZeroEndpoint", + loadAddressFile(hre, "dev_lz").endpoint + ); + + const targetChain = + hre.network.config.chainId === DEV_CHAIN_ID_BSC ? DEV_CHAIN_ID_ETH : DEV_CHAIN_ID_BSC; + const adapterParams = ethers.utils.solidityPack(["uint16", "uint"], [1, CHESS_GAS_LIMIT]); + const fee = ( + await lzEndpoint.estimateFees( + targetChain, + chessPool.address, + ethers.utils.hexZeroPad("0x", CHESS_PAYLOAD_LENGTH), + false, + adapterParams + ) + ).nativeFee; + console.log( + `Transferring ${formatEther( + amount + )} CHESS to ${to} on Chain ${targetChain} with fee ${formatEther(fee)}` + ); + await chess.approve(chessPool.address, amount); + await chessPool.sendFrom( + deployer.address, + targetChain, + ethers.utils.solidityPack(["address"], [to]), + amount, + deployer.address, + ethers.constants.AddressZero, + adapterParams, + { value: fee } + ); + }); + +task("dev_chess_in", "Receive CHESS from the other dev chain") + .addParam("to", "Target address") + .addParam("amount", "Amount of CHESS") + .setAction(async function (args, hre) { + const { ethers } = hre; + const [deployer] = await ethers.getSigners(); + const { parseEther, formatEther } = ethers.utils; + + const to: string = args.to; + const amount = parseEther(args.amount); + + const governanceAddresses = loadAddressFile(hre, "governance"); + const chessPool = await ethers.getContractAt("ProxyOFTPool", governanceAddresses.chessPool); + const lzEndpoint = await ethers.getContractAt( + "ILayerZeroEndpoint", + loadAddressFile(hre, "dev_lz").endpoint + ); + + const sourceChain = + hre.network.config.chainId === DEV_CHAIN_ID_BSC ? DEV_CHAIN_ID_ETH : DEV_CHAIN_ID_BSC; + const path = ethers.utils.solidityPack( + ["address", "address"], + [deployer.address, chessPool.address] + ); + const nonce = (await lzEndpoint.getInboundNonce(sourceChain, path)).add(1); + const payload = ethers.utils.defaultAbiCoder.encode( + ["uint16", "bytes", "uint256"], + [0, ethers.utils.solidityPack(["address"], [to]), amount] + ); + console.log(`Transferring ${formatEther(amount)} CHESS to ${to} from Chain ${sourceChain}`); + await lzEndpoint.receivePayload( + sourceChain, + path, + chessPool.address, + nonce, + CHESS_GAS_LIMIT, + payload, + { gasLimit: CHESS_GAS_LIMIT + 2e5 } + ); + }); + +task("dev_vechess_out", "Send veCHESS to the other dev chain") + .addParam("amount", "Amount of CHESS") + .setAction(async function (args, hre) { + const { ethers } = hre; + const { parseEther, formatEther } = ethers.utils; + + const amount = parseEther(args.amount); + + const lzEndpoint = await ethers.getContractAt( + "ILayerZeroEndpoint", + loadAddressFile(hre, "dev_lz").endpoint + ); + const votingEscrow = await ethers.getContractAt( + "VotingEscrowV4", + loadAddressFile(hre, "governance").votingEscrow + ); + + const targetChain = + hre.network.config.chainId === DEV_CHAIN_ID_BSC ? DEV_CHAIN_ID_ETH : DEV_CHAIN_ID_BSC; + const adapterParams = ethers.utils.solidityPack( + ["uint16", "uint"], + [1, VECHESS_GAS_ESTIMATION] + ); + const fee = ( + await lzEndpoint.estimateFees( + targetChain, + votingEscrow.address, + ethers.utils.hexZeroPad("0x", VECHESS_PAYLOAD_LENGTH), + false, + adapterParams + ) + ).nativeFee; + console.log( + `Transferring ${formatEther( + amount + )} locked CHESS to the other dev chain with fee ${formatEther(fee)}` + ); + await votingEscrow.veChessCrossChain(amount, targetChain, adapterParams, { value: fee }); + }); + +task("dev_vechess_in", "Receive veCHESS from the other dev chain") + .addParam("to", "Target address") + .addParam("amount", "Amount of CHESS") + .addParam("unlockDate", "Unlock date (YYYY-MM-DD)") + .setAction(async function (args, hre) { + const { ethers } = hre; + const { parseEther, formatEther } = ethers.utils; + const [deployer] = await ethers.getSigners(); + + const to: string = args.to; + const amount = parseEther(args.amount); + const unlockTimestamp = endOfWeek(new Date(args.unlockDate).getTime() / 1000); + + const lzEndpoint = await ethers.getContractAt( + "ILayerZeroEndpoint", + loadAddressFile(hre, "dev_lz").endpoint + ); + const votingEscrow = await ethers.getContractAt( + "VotingEscrowV4", + loadAddressFile(hre, "governance").votingEscrow + ); + + const sourceChain = + hre.network.config.chainId === DEV_CHAIN_ID_BSC ? DEV_CHAIN_ID_ETH : DEV_CHAIN_ID_BSC; + const path = ethers.utils.solidityPack( + ["address", "address"], + [deployer.address, votingEscrow.address] + ); + const nonce = (await lzEndpoint.getInboundNonce(sourceChain, path)).add(1); + const payload = ethers.utils.defaultAbiCoder.encode( + ["address", "uint256", "uint256"], + [to, amount, unlockTimestamp] + ); + const gasEstimation = ( + await ethers.provider.estimateGas({ + ...(await votingEscrow.populateTransaction.lzReceive( + sourceChain, + path, + nonce, + payload + )), + from: lzEndpoint.address, + }) + ).toNumber(); + const gas = Math.ceil(gasEstimation * 1.05) + 30000; + console.log( + `Transferring ${formatEther( + amount + )} locked CHESS (unlocked at ${unlockTimestamp}) to ${to} from the other dev chain` + ); + console.log(`Gas estimation: ${gas}`); + await lzEndpoint.receivePayload( + sourceChain, + path, + votingEscrow.address, + nonce, + gas, + payload, + { gasLimit: gas + 2e5 } + ); + }); + +task("dev_sync_out", "Send total vote to the main chain").setAction(async function (args, hre) { + const { ethers } = hre; + const { formatEther } = ethers.utils; + + assert.strictEqual( + hre.network.config.chainId, + DEV_CHAIN_ID_ETH, + "Should send sub chain vote only on the sub chain" + ); + const targetChain = DEV_CHAIN_ID_BSC; + + const lzEndpoint = await ethers.getContractAt( + "ILayerZeroEndpoint", + loadAddressFile(hre, "dev_lz").endpoint + ); + const chessSubSchedule = await ethers.getContractAt( + "ChessSubSchedule", + loadAddressFile(hre, "governance").chessSchedule + ); + + const adapterParams = ethers.utils.solidityPack(["uint16", "uint"], [1, SYNC_GAS_LIMIT]); + const fee = ( + await lzEndpoint.estimateFees( + targetChain, + chessSubSchedule.address, + ethers.utils.hexZeroPad("0x", SYNC_PAYLOAD_LENGTH), + false, + adapterParams + ) + ).nativeFee; + console.log(`Sending total vote to chain ${targetChain} with fee ${formatEther(fee)}`); + await chessSubSchedule.crossChainSync(adapterParams, { value: fee }); +}); + +task("dev_sync_in", "Receive total vote from the sub chain") + .addParam("amount", "Amount of veCHESS at the end of this week") + .addParam("nextAmount", "Amount of veCHESS at the end of the next week") + .setAction(async function (args, hre) { + const { ethers } = hre; + const { parseEther } = ethers.utils; + const [deployer] = await ethers.getSigners(); + + assert.strictEqual( + hre.network.config.chainId, + DEV_CHAIN_ID_BSC, + "Should receive sub chain vote only on the main chain" + ); + const sourceChain = DEV_CHAIN_ID_ETH; + const amount = parseEther(args.amount); + const nextAmount = parseEther(args.nextAmount); + const week = endOfWeek((await ethers.provider.getBlock("latest")).timestamp); + + const lzEndpoint = await ethers.getContractAt( + "ILayerZeroEndpoint", + loadAddressFile(hre, "dev_lz").endpoint + ); + const chessScheduleRelayer = await ethers.getContractAt( + "ChessScheduleRelayer", + loadAddressFile( + hre, + `chess_schedule_relayer_${sourceChain}` + ).relayer + ); + + const path = ethers.utils.solidityPack( + ["address", "address"], + [deployer.address, chessScheduleRelayer.address] + ); + const nonce = (await lzEndpoint.getInboundNonce(sourceChain, path)).add(1); + const payload = ethers.utils.defaultAbiCoder.encode( + ["uint256", "uint256", "uint256"], + [week, amount, nextAmount] + ); + console.log( + `Receiving total vote of chain ${sourceChain}: week ${week}, supply ${amount}, nextWeekSupply ${nextAmount}` + ); + await lzEndpoint.receivePayload( + sourceChain, + path, + chessScheduleRelayer.address, + nonce, + SYNC_GAS_LIMIT, + payload, + { gasLimit: SYNC_GAS_LIMIT + 2e5 } + ); + }); + +task("dev_mint_out", "Send CHESS emission to the sub chain").setAction(async function (args, hre) { + const { ethers } = hre; + const { formatEther } = ethers.utils; + + assert.strictEqual( + hre.network.config.chainId, + DEV_CHAIN_ID_BSC, + "Should send emission only on the main chain" + ); + const targetChain = DEV_CHAIN_ID_ETH; + + const lzEndpoint = await ethers.getContractAt( + "ILayerZeroEndpoint", + loadAddressFile(hre, "dev_lz").endpoint + ); + const chessScheduleRelayer = await ethers.getContractAt( + "ChessScheduleRelayer", + loadAddressFile(hre, `chess_schedule_relayer_${targetChain}`) + .relayer + ); + + const adapterParams = ethers.utils.solidityPack(["uint16", "uint"], [1, MINT_GAS_LIMIT]); + const fee = ( + await lzEndpoint.estimateFees( + targetChain, + chessScheduleRelayer.address, + ethers.utils.hexZeroPad("0x", MINT_PAYLOAD_LENGTH), + false, + adapterParams + ) + ).nativeFee; + console.log(`Sending CHESS emission to the sub chain with fee ${formatEther(fee)}`); + await chessScheduleRelayer.crossChainMint(adapterParams, { value: fee }); +}); + +task("dev_mint_in", "Receive CHESS emission from the main chain") + .addParam("amount", "Amount of CHESS") + .setAction(async function (args, hre) { + const { ethers } = hre; + const { parseEther } = ethers.utils; + const [deployer] = await ethers.getSigners(); + + assert.strictEqual( + hre.network.config.chainId, + DEV_CHAIN_ID_ETH, + "Should receive CHESS emission only on the sub chain" + ); + const sourceChain = DEV_CHAIN_ID_BSC; + const amount = parseEther(args.amount); + + const lzEndpoint = await ethers.getContractAt( + "ILayerZeroEndpoint", + loadAddressFile(hre, "dev_lz").endpoint + ); + const chessSubSchedule = await ethers.getContractAt( + "ChessSubSchedule", + loadAddressFile(hre, "governance").chessSchedule + ); + + const path = ethers.utils.solidityPack( + ["address", "address"], + [deployer.address, chessSubSchedule.address] + ); + const nonce = (await lzEndpoint.getInboundNonce(sourceChain, path)).add(1); + const payload = ethers.utils.defaultAbiCoder.encode(["uint256"], [amount]); + console.log(`Receiving CHESS emission from chain ${sourceChain}: amount ${amount}`); + await lzEndpoint.receivePayload( + sourceChain, + path, + chessSubSchedule.address, + nonce, + MINT_GAS_LIMIT, + payload, + { gasLimit: MINT_GAS_LIMIT + 2e5 } + ); + }); diff --git a/tasks/test_deploy.ts b/tasks/test_deploy.ts index c41c128e..cbf1fb52 100644 --- a/tasks/test_deploy.ts +++ b/tasks/test_deploy.ts @@ -1,7 +1,7 @@ import { task } from "hardhat/config"; import { loadAddressFile } from "./address_file"; import type { MockAddresses } from "./deploy_mock"; -import type { AnyswapAddresses } from "./dev_deploy_anyswap"; +import type { LzAddresses } from "./dev_deploy_lz"; import { endOfWeek, GOVERNANCE_CONFIG } from "../config"; task("test_deploy", "Run all deployment scripts on a temp Hardhat node", async (_args, hre) => { @@ -15,11 +15,10 @@ task("test_deploy", "Run all deployment scripts on a temp Hardhat node", async ( const mockAddresses = loadAddressFile(hre, "mock"); console.log(); - console.log("[+] Deploying Anyswap"); - await hre.run("dev_deploy_anyswap"); - const anyswapAddresses = loadAddressFile(hre, "dev_anyswap"); - GOVERNANCE_CONFIG.ANYSWAP_ROUTER = anyswapAddresses.router; - GOVERNANCE_CONFIG.ANY_CALL_PROXY = anyswapAddresses.anyCallProxy; + console.log("[+] Deploying LayerZero"); + await hre.run("dev_deploy_lz"); + const lzAddresses = loadAddressFile(hre, "dev_lz"); + GOVERNANCE_CONFIG.LZ_ENDPOINT = lzAddresses.endpoint; console.log(); console.log("[+] Deploying mock TwapOracle");