diff --git a/.travis.yml b/.travis.yml index 18b3817..82d81f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ dist: trusty sudo: required language: node_js node_js: - - '12' + - '16' cache: directories: - node_modules diff --git a/hardhat.config.js b/hardhat.config.js index e2aecdf..9dffe84 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -10,6 +10,7 @@ require('@nomiclabs/hardhat-etherscan'); require('./tasks/deploy/ampleforth'); require('./tasks/deploy/chain_bridge'); require('./tasks/deploy/matic'); +require('./tasks/deploy/arbitrum'); require('./tasks/deploy/rebase_reporter'); require('./tasks/ops/rebase'); @@ -26,94 +27,114 @@ module.exports = { solidity: { compilers: [ { - version: '0.4.24' + version: '0.4.24', }, { - version: '0.7.6' + version: '0.5.12', }, { - version: '0.6.4' + version: '0.6.4', }, { - version: '0.6.8' + version: '0.6.8', }, { - version: '0.5.12' + version: '0.6.11', + settings: { + optimizer: { + enabled: true, + runs: 200, + }, + }, }, { version: '0.7.3', settings: { optimizer: { enabled: true, - runs: 200 - } - } - } - ] + runs: 200, + }, + }, + }, + { + version: '0.7.6', + settings: { + optimizer: { + enabled: true, + runs: 200, + }, + }, + }, + ], }, mocha: { - timeout: 1000000 + timeout: 1000000, }, gasReporter: { currency: 'USD', enabled: !!process.env.REPORT_GAS, excludeContracts: ['_mocks', '_external', 'uFragments'], - coinmarketcap: process.env.COINMARKETCAP_API_KEY + coinmarketcap: process.env.COINMARKETCAP_API_KEY, }, etherscan: { - apiKey: process.env.ETHERSCAN_API_KEY + apiKey: process.env.ETHERSCAN_API_KEY, }, bscscan: { - apiKey: process.env.BSCSCAN_API_KEY + apiKey: process.env.BSCSCAN_API_KEY, }, networks: { localGethBaseChain: { - url: 'http://localhost:7545' + url: 'http://localhost:7545', }, localGethSatChain1: { - url: 'http://localhost:7550' + url: 'http://localhost:7550', }, localGethSatChain2: { - url: 'http://localhost:7555' + url: 'http://localhost:7555', }, // meter-passport dev1RopstenBaseChain: { - url: 'https://eth-ropsten.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET + url: 'https://eth-ropsten.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET, }, dev1BscTestnetSatChain: { - url: 'https://data-seed-prebsc-1-s1.binance.org:8545' + url: 'https://data-seed-prebsc-1-s1.binance.org:8545', }, dev1MeterTestnetSatChain: { - url: 'https://rpctest.meter.io' + url: 'https://rpctest.meter.io', }, // matic dev2GoerliBaseChain: { - url: 'https://eth-goerli.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET + url: 'https://eth-goerli.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET, }, dev2MumbaiSatChain: { - url: 'https://polygon-mumbai.infura.io/v3/' + process.env.INFURA_SECRET + url: 'https://polygon-mumbai.infura.io/v3/' + process.env.INFURA_SECRET, + }, + + // arbitrum + dev3RinkebyBaseChain: { + url: 'https://eth-rinkeby.alchemyapi.io/v2/' + process.env.ALCHEMY_SECRET, + }, + dev3RinkebyArbitrumSatChain: { + url: 'https://rinkeby.arbitrum.io/rpc', }, // prod prodEthereumBaseChain: { - url: 'https://mainnet.infura.io/v3/' + process.env.INFURA_SECRET + url: 'https://mainnet.infura.io/v3/' + process.env.INFURA_SECRET, }, prodBscSatChain: { - url: 'https://bsc-dataseed.binance.org' - }, - prodAvaxSatChain: { - url: 'https://api.avax.network/ext/bc/C/rpc' + url: 'https://bsc-dataseed.binance.org', }, prodMeterSatChain: { - url: 'https://rpc.meter.io' + url: 'https://rpc.meter.io', }, prodMaticSatChain: { - url: 'https://polygon-mainnet.infura.io/v3/' + process.env.INFURA_SECRET - } - } + url: 'https://polygon-mainnet.infura.io/v3/' + process.env.INFURA_SECRET, + }, + }, }; diff --git a/helpers/contracts.js b/helpers/contracts.js index 46cee2c..ee6a290 100644 --- a/helpers/contracts.js +++ b/helpers/contracts.js @@ -40,6 +40,9 @@ const ContractABIPaths = { MaticXCAmpleRebaseGateway: 'contracts/satellite-chain/bridge-gateways', MaticXCAmpleTransferGateway: 'contracts/satellite-chain/bridge-gateways', + AMPLArbitrumGateway: 'contracts/base-chain/bridge-gateways', + ArbitrumXCAmpleGateway: 'contracts/satellite-chain/bridge-gateways', + // utilities ChainBridgeBatchRebaseReport: 'contracts/_utilities', }; @@ -54,11 +57,18 @@ const getCompiledContractFactory = (ethers, contract) => { ); }; -const deployContract = async (ethers, contractName, signer, args, txParams) => { +const deployContract = async ( + ethers, + contractName, + signer, + args, + txParams, + waitBlocks = 0, +) => { // console.log('Deploying', contractName); const Factory = await getCompiledContractFactory(ethers, contractName); const contract = await Factory.connect(signer).deploy(...args, txParams); - await contract.deployTransaction.wait(); + await contract.deployTransaction.wait(waitBlocks); // console.log('Deployed'); return contract; }; @@ -75,6 +85,7 @@ const deployProxyContract = async ( args, initializerDef, txParams, + waitBlocks = 0, ) => { // console.log('Deploying proxy', contractName); const ProxyAdminFactory = await getCompiledContractFactory( @@ -88,7 +99,7 @@ const deployProxyContract = async ( initializerDef, txParams, ); - await contract.deployTransaction.wait(); + await contract.deployTransaction.wait(waitBlocks); // console.log('Deployed'); const defaultProxyAdmin = ProxyAdminFactory.connect(signer).attach( @@ -99,7 +110,7 @@ const deployProxyContract = async ( newProxyAdmin.address, txParams, ); - await refChangeTx.wait(); + await refChangeTx.wait(waitBlocks); return contract; }; @@ -111,7 +122,7 @@ const upgradeProxyContract = async ( deployedContractRef, signer, txParams, - force=false, + force = false, ) => { const proxyAdmin = await getDeployedContractInstance( network, @@ -125,25 +136,24 @@ const upgradeProxyContract = async ( ethers.provider, ); - const currentImplAddr = await proxyAdmin.getProxyImplementation(proxy.address); - console.log(`Current implementation for ${contractName} is at`, currentImplAddr); + const currentImplAddr = await proxyAdmin.getProxyImplementation( + proxy.address, + ); + console.log( + `Current implementation for ${contractName} is at`, + currentImplAddr, + ); // deploy new implementation let newImpl; - if(!force) { + if (!force) { const Factory = await getCompiledContractFactory(ethers, contractName); newImpl = await upgrades.prepareUpgrade(proxy.address, Factory); } else { - console.log(`CAUTION: Skpping storage layout verification!`) - console.log(`CANCEL NOW to stop, this action is not reversable`) + console.log(`CAUTION: Skpping storage layout verification!`); + console.log(`CANCEL NOW to stop, this action is not reversable`); await sleep(10); - newImpl = await deployContract( - ethers, - contractName, - signer, - [], - txParams, - ); + newImpl = await deployContract(ethers, contractName, signer, [], txParams); } console.log(`New implementation for ${contractName} is at`, newImpl.address); diff --git a/helpers/deploy/ampl.js b/helpers/deploy/ampl.js new file mode 100644 index 0000000..a53d331 --- /dev/null +++ b/helpers/deploy/ampl.js @@ -0,0 +1,169 @@ +const { AMPL_BASE_RATE, AMPL_BASE_CPI } = require('../../sdk/ampleforth'); + +const { + deployContract, + deployProxyAdminContract, + deployProxyContract, +} = require('../contracts'); + +async function deployAMPLContracts( + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const deployerAddress = await deployer.getAddress(); + + const proxyAdmin = await deployProxyAdminContract(ethers, deployer, txParams); + + const ampl = await deployProxyContract( + ethers, + 'UFragments', + proxyAdmin, + deployer, + [deployerAddress], + { initializer: 'initialize(address)' }, + txParams, + waitBlocks, + ); + + const rateOracle = await deployContract( + ethers, + 'MedianOracle', + deployer, + [3600 * 24 * 365, 0, 1], + txParams, + waitBlocks, + ); + await ( + await rateOracle.connect(deployer).addProvider(deployerAddress, txParams) + ).wait(waitBlocks); + await ( + await rateOracle.connect(deployer).pushReport(AMPL_BASE_RATE, txParams) + ).wait(waitBlocks); + + const cpiOracle = await deployContract( + ethers, + 'MedianOracle', + deployer, + [3600 * 24 * 365, 0, 1], + txParams, + waitBlocks, + ); + await ( + await cpiOracle.addProvider(deployerAddress, txParams) + ).wait(waitBlocks); + await ( + await cpiOracle.connect(deployer).pushReport(AMPL_BASE_CPI, txParams) + ).wait(waitBlocks); + + const policy = await deployProxyContract( + ethers, + 'UFragmentsPolicy', + proxyAdmin, + deployer, + [deployerAddress, ampl.address, AMPL_BASE_CPI.toString()], + { + initializer: 'initialize(address,address,uint256)', + }, + txParams, + waitBlocks, + ); + await ( + await policy.connect(deployer).setMarketOracle(rateOracle.address, txParams) + ).wait(waitBlocks); + await ( + await policy.connect(deployer).setCpiOracle(cpiOracle.address, txParams) + ).wait(waitBlocks); + await ( + await policy.connect(deployer).setRebaseLag(1, txParams) + ).wait(waitBlocks); + await ( + await policy + .connect(deployer) + .setRebaseTimingParameters(1, 0, 3600, txParams) + ).wait(waitBlocks); + await ( + await ampl.connect(deployer).setMonetaryPolicy(policy.address, txParams) + ).wait(waitBlocks); + + const orchestrator = await deployContract( + ethers, + 'Orchestrator', + deployer, + [policy.address], + txParams, + waitBlocks, + ); + await ( + await policy + .connect(deployer) + .setOrchestrator(orchestrator.address, txParams) + ).wait(waitBlocks); + + return { + proxyAdmin, + ampl, + policy, + orchestrator, + rateOracle, + cpiOracle, + }; +} + +async function deployXCAmpleContracts( + { tokenSymbol, tokenName, globalAmpleforthEpoch, globalAMPLSupply }, + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const proxyAdmin = await deployProxyAdminContract(ethers, deployer, txParams); + + const xcAmple = await deployProxyContract( + ethers, + 'XCAmple', + proxyAdmin, + deployer, + [tokenName, tokenSymbol, globalAMPLSupply], + { initializer: 'initialize(string,string,uint256)' }, + txParams, + waitBlocks, + ); + + const xcAmpleController = await deployProxyContract( + ethers, + 'XCAmpleController', + proxyAdmin, + deployer, + [xcAmple.address, globalAmpleforthEpoch], + { + initializer: 'initialize(address,uint256)', + }, + txParams, + waitBlocks, + ); + + const rebaseRelayer = await deployContract( + ethers, + 'BatchTxExecutor', + deployer, + [], + txParams, + waitBlocks, + ); + + await ( + await xcAmple.setController(xcAmpleController.address, txParams) + ).wait(waitBlocks); + await ( + await xcAmpleController.setRebaseRelayer(rebaseRelayer.address, txParams) + ).wait(waitBlocks); + + return { proxyAdmin, xcAmple, xcAmpleController, rebaseRelayer }; +} + +module.exports = { + deployAMPLContracts, + deployXCAmpleContracts, +}; diff --git a/helpers/deploy/arbitrum.js b/helpers/deploy/arbitrum.js new file mode 100644 index 0000000..eda95b3 --- /dev/null +++ b/helpers/deploy/arbitrum.js @@ -0,0 +1,72 @@ +const { deployContract } = require('../contracts'); + +async function deployArbitrumBaseChainGatewayContracts( + { ampl, policy, tokenVault }, + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const gateway = await deployContract( + ethers, + 'AMPLArbitrumGateway', + deployer, + [ampl.address, policy.address, tokenVault.address], + txParams, + waitBlocks, + ); + + const deployerAddress = await deployer.getAddress(); + if ((await tokenVault.owner()) == deployerAddress) { + await ( + await tokenVault.connect(deployer).addBridgeGateway(gateway.address) + ).wait(waitBlocks); + } else { + console.log( + 'Failed to add whitelist transfer gateway to vault as deployer not vault owner', + ); + console.log('Execute the following on-chain'); + console.log('addBridgeGateway', [gateway.address]); + } + + return { gateway }; +} + +async function deployArbitrumSatelliteChainGatewayContracts( + { xcAmple, xcAmpleController }, + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const gateway = await deployContract( + ethers, + 'ArbitrumXCAmpleGateway', + deployer, + [xcAmple.address, xcAmpleController.address], + txParams, + waitBlocks, + ); + + const deployerAddress = await deployer.getAddress(); + if ((await xcAmpleController.owner()) == deployerAddress) { + await ( + await xcAmpleController + .connect(deployer) + .addBridgeGateway(gateway.address) + ).wait(waitBlocks); + } else { + console.log( + 'Failed to add whitelist transfer gateway to XCAmpleController as deployer owner', + ); + console.log('Execute the following on-chain'); + console.log('addBridgeGateway', [gateway.address]); + } + + return { gateway }; +} + +module.exports = { + deployArbitrumBaseChainGatewayContracts, + deployArbitrumSatelliteChainGatewayContracts, +}; diff --git a/helpers/deploy/chain_bridge.js b/helpers/deploy/chain_bridge.js new file mode 100644 index 0000000..fdd01d5 --- /dev/null +++ b/helpers/deploy/chain_bridge.js @@ -0,0 +1,270 @@ +const { + XC_REBASE_RESOURCE_ID, + XC_TRANSFER_RESOURCE_ID, + CB_FUNCTION_SIG_baseChainReportRebase, + CB_FUNCTION_SIG_satelliteChainReportRebase, + CB_FUNCTION_SIG_baseChainTransfer, + CB_FUNCTION_SIG_satelliteChainTransfer, +} = require('../../sdk/chain_bridge'); + +const { deployContract } = require('../contracts'); + +async function deployChainBridgeHelpers( + bridge, + { chainId, relayers, relayerThreshold, fee, expiry }, + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const batchRebaseReporter = await deployContract( + ethers, + 'ChainBridgeBatchRebaseReport', + deployer, + [], + txParams, + waitBlocks, + ); + + return { + batchRebaseReporter, + }; +} + +async function deployChainBridgeContracts( + { chainId, relayers, relayerThreshold, fee, expiry }, + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const bridge = await deployContract( + ethers, + 'Bridge', + deployer, + [chainId, relayers, relayerThreshold, fee, expiry], + txParams, + waitBlocks, + ); + + const genericHandler = await deployContract( + ethers, + 'GenericHandler', + deployer, + [bridge.address, [], [], [], [], []], + txParams, + waitBlocks, + ); + + const helpers = await deployChainBridgeHelpers( + bridge, + { chainId, relayers, relayerThreshold, fee, expiry }, + ethers, + deployer, + txParams, + waitBlocks, + ); + + return { + bridge, + genericHandler, + ...helpers, + }; +} + +async function deployChainBridgeBaseChainGatewayContracts( + { ampl, policy, bridge, genericHandler, tokenVault }, + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const rebaseGateway = await deployContract( + ethers, + 'AMPLChainBridgeGateway', + deployer, + [genericHandler.address, ampl.address, policy.address, tokenVault.address], + txParams, + waitBlocks, + ); + const transferGateway = await deployContract( + ethers, + 'AMPLChainBridgeGateway', + deployer, + [genericHandler.address, ampl.address, policy.address, tokenVault.address], + txParams, + waitBlocks, + ); + + const deployerAddress = await deployer.getAddress(); + const adminRole = await bridge.DEFAULT_ADMIN_ROLE(); + const isAdmin = await bridge.hasRole(adminRole, deployerAddress); + + const reportRebaseFnSig = + CB_FUNCTION_SIG_baseChainReportRebase(rebaseGateway); + + if (isAdmin) { + await ( + await bridge + .connect(deployer) + .adminSetGenericResource( + genericHandler.address, + XC_REBASE_RESOURCE_ID, + rebaseGateway.address, + ...reportRebaseFnSig, + txParams, + ) + ).wait(waitBlocks); + } else { + console.log( + 'Failed adding generic resource to bridge, deployer key not bridge owner', + ); + console.log('Execute the following on-chain'); + console.log('adminSetGenericResource', [ + genericHandler.address, + XC_REBASE_RESOURCE_ID, + rebaseGateway.address, + ...reportRebaseFnSig, + ]); + } + + const transferFnSig = CB_FUNCTION_SIG_baseChainTransfer(transferGateway); + if (isAdmin) { + await ( + await bridge + .connect(deployer) + .adminSetGenericResource( + genericHandler.address, + XC_TRANSFER_RESOURCE_ID, + transferGateway.address, + ...transferFnSig, + txParams, + ) + ).wait(waitBlocks); + } else { + console.log( + 'Failed adding generic resource to bridge, deployer key not bridge owner', + ); + console.log('Execute the following on-chain'); + console.log('adminSetGenericResource', [ + genericHandler.address, + XC_TRANSFER_RESOURCE_ID, + transferGateway.address, + ...transferFnSig, + ]); + } + + if ((await tokenVault.owner()) == deployerAddress) { + await ( + await tokenVault + .connect(deployer) + .addBridgeGateway(transferGateway.address) + ).wait(waitBlocks); + } else { + console.log( + 'Failed to add whitelist transfer gateway to vault as deployer not vault owner', + ); + console.log('Execute the following on-chain'); + console.log('addBridgeGateway', [transferGateway.address]); + } + + return { rebaseGateway, transferGateway }; +} + +async function deployChainBridgeSatelliteChainGatewayContracts( + { xcAmple, xcAmpleController, bridge, genericHandler }, + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const rebaseGateway = await deployContract( + ethers, + 'ChainBridgeXCAmpleGateway', + deployer, + [genericHandler.address, xcAmple.address, xcAmpleController.address], + txParams, + waitBlocks, + ); + const transferGateway = await deployContract( + ethers, + 'ChainBridgeXCAmpleGateway', + deployer, + [genericHandler.address, xcAmple.address, xcAmpleController.address], + txParams, + waitBlocks, + ); + + await ( + await xcAmpleController + .connect(deployer) + .addBridgeGateway(rebaseGateway.address, txParams) + ).wait(waitBlocks); + + await ( + await xcAmpleController + .connect(deployer) + .addBridgeGateway(transferGateway.address, txParams) + ).wait(waitBlocks); + + const adminRole = await bridge.DEFAULT_ADMIN_ROLE(); + const isAdmin = await bridge.hasRole(adminRole, await deployer.getAddress()); + + const reportRebaseFnSig = + CB_FUNCTION_SIG_satelliteChainReportRebase(rebaseGateway); + if (isAdmin) { + await ( + await bridge.adminSetGenericResource( + genericHandler.address, + XC_REBASE_RESOURCE_ID, + rebaseGateway.address, + ...reportRebaseFnSig, + txParams, + ) + ).wait(waitBlocks); + } else { + console.log( + 'Failed adding generic resource to bridge, deployer key not bridge owner', + ); + console.log('Execute the following on-chain'); + console.log('adminSetGenericResource', [ + genericHandler.address, + XC_REBASE_RESOURCE_ID, + rebaseGateway.address, + ...reportRebaseFnSig, + ]); + } + + const transferFnSig = CB_FUNCTION_SIG_satelliteChainTransfer(transferGateway); + if (isAdmin) { + await ( + await bridge.adminSetGenericResource( + genericHandler.address, + XC_TRANSFER_RESOURCE_ID, + transferGateway.address, + ...transferFnSig, + txParams, + ) + ).wait(waitBlocks); + } else { + console.log( + 'Failed adding generic resource to bridge, deployer key not bridge owner', + ); + console.log('Execute the following on-chain'); + console.log('adminSetGenericResource', [ + genericHandler.address, + XC_TRANSFER_RESOURCE_ID, + transferGateway.address, + ...transferFnSig, + ]); + } + + return { rebaseGateway, transferGateway }; +} + +module.exports = { + deployChainBridgeContracts, + deployChainBridgeHelpers, + deployChainBridgeBaseChainGatewayContracts, + deployChainBridgeSatelliteChainGatewayContracts, +}; diff --git a/helpers/deploy/index.js b/helpers/deploy/index.js new file mode 100644 index 0000000..7b94ec1 --- /dev/null +++ b/helpers/deploy/index.js @@ -0,0 +1,13 @@ +const ampl = require('./ampl'); +const vault = require('./vault'); +const chainBridge = require('./chain_bridge'); +const matic = require('./matic'); +const arbitrum = require('./arbitrum'); + +module.exports = { + ...ampl, + ...vault, + ...chainBridge, + ...matic, + ...arbitrum, +}; diff --git a/helpers/deploy/matic.js b/helpers/deploy/matic.js new file mode 100644 index 0000000..28e3598 --- /dev/null +++ b/helpers/deploy/matic.js @@ -0,0 +1,100 @@ +const { deployContract } = require('../contracts'); + +async function deployMaticBaseChainGatewayContracts( + { ampl, policy, tokenVault, checkpointManagerAddress, fxRootAddress }, + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const rebaseGateway = await deployContract( + ethers, + 'AMPLMaticRebaseGateway', + deployer, + [checkpointManagerAddress, fxRootAddress, ampl.address, policy.address], + txParams, + waitBlocks, + ); + const transferGateway = await deployContract( + ethers, + 'AMPLMaticTransferGateway', + deployer, + [checkpointManagerAddress, fxRootAddress, ampl.address, tokenVault.address], + txParams, + waitBlocks, + ); + + const deployerAddress = await deployer.getAddress(); + if ((await tokenVault.owner()) == deployerAddress) { + await ( + await tokenVault.connect(deployer).addBridgeGateway(rebaseGateway.address) + ).wait(waitBlocks); + await ( + await tokenVault + .connect(deployer) + .addBridgeGateway(transferGateway.address) + ).wait(waitBlocks); + } else { + console.log( + 'Failed to add whitelist transfer gateway to vault as deployer not vault owner', + ); + console.log('Execute the following on-chain'); + console.log('addBridgeGateway', [rebaseGateway.address]); + console.log('addBridgeGateway', [transferGateway.address]); + } + + return { rebaseGateway, transferGateway }; +} + +async function deployMaticSatelliteChainGatewayContracts( + { xcAmple, xcAmpleController, fxChildAddress }, + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const rebaseGateway = await deployContract( + ethers, + 'MaticXCAmpleRebaseGateway', + deployer, + [fxChildAddress, xcAmple.address, xcAmpleController.address], + txParams, + waitBlocks, + ); + const transferGateway = await deployContract( + ethers, + 'MaticXCAmpleTransferGateway', + deployer, + [fxChildAddress, xcAmple.address, xcAmpleController.address], + txParams, + waitBlocks, + ); + + const deployerAddress = await deployer.getAddress(); + if ((await xcAmpleController.owner()) == deployerAddress) { + await ( + await xcAmpleController + .connect(deployer) + .addBridgeGateway(rebaseGateway.address) + ).wait(waitBlocks); + await ( + await xcAmpleController + .connect(deployer) + .addBridgeGateway(transferGateway.address) + ).wait(waitBlocks); + } else { + console.log( + 'Failed to add whitelist transfer gateway to XCAmpleController as deployer owner', + ); + console.log('Execute the following on-chain'); + console.log('addBridgeGateway', [rebaseGateway.address]); + console.log('addBridgeGateway', [transferGateway.address]); + } + + return { rebaseGateway, transferGateway }; +} + +module.exports = { + deployMaticBaseChainGatewayContracts, + deployMaticSatelliteChainGatewayContracts, +}; diff --git a/helpers/deploy/vault.js b/helpers/deploy/vault.js new file mode 100644 index 0000000..0de056e --- /dev/null +++ b/helpers/deploy/vault.js @@ -0,0 +1,23 @@ +const { deployContract } = require('../contracts'); + +async function deployTokenVault( + ethers, + deployer, + txParams = {}, + waitBlocks = 0, +) { + const tokenVault = await deployContract( + ethers, + 'TokenVault', + deployer, + [], + txParams, + waitBlocks, + ); + + return tokenVault; +} + +module.exports = { + deployTokenVault, +}; diff --git a/tasks/deploy/ampleforth.js b/tasks/deploy/ampleforth.js index 9dc52ef..1b1f4bb 100644 --- a/tasks/deploy/ampleforth.js +++ b/tasks/deploy/ampleforth.js @@ -103,7 +103,7 @@ txTask('testnet:deploy:ampleforth', 'Deploy ampleforth contract suite') console.log('Deployer:', deployerAddress); const { proxyAdmin, ampl, policy, orchestrator, rateOracle, cpiOracle } = - await deployAMPLContracts(hre.ethers, deployer, txParams); + await deployAMPLContracts(hre.ethers, deployer, txParams, 2); for (const w in args.fundingWallets) { await ampl.transfer(args.fundingWallets[w], toAmplFixedPt(args.amount)); } @@ -177,6 +177,7 @@ txTask('deploy:ampleforth_xc', 'Deploy cross chain ampleforth contract suite') hre.ethers, deployer, txParams, + 2, ); console.log('------------------------------------------------------------'); @@ -224,7 +225,12 @@ txTask('deploy:token_vault', 'Deploy the token vault contract on base chain') console.log('------------------------------------------------------------'); console.log('Deploying TokenVault on base chain'); - const tokenVault = await deployTokenVault(hre.ethers, deployer, txParams); + const tokenVault = await deployTokenVault( + hre.ethers, + deployer, + txParams, + 2, + ); console.log('------------------------------------------------------------'); console.log('Writing data to file'); diff --git a/tasks/deploy/chain_bridge.js b/tasks/deploy/chain_bridge.js index d415c8e..c802383 100644 --- a/tasks/deploy/chain_bridge.js +++ b/tasks/deploy/chain_bridge.js @@ -8,7 +8,6 @@ const { } = require('../../helpers/tasks'); const { getEthersProvider } = require('../../helpers/utils'); const { - deployContract, getDeployedContractInstance, readDeploymentData, writeDeploymentData, @@ -100,6 +99,7 @@ cbDeployTask( hre.ethers, deployer, txParams, + 2, ); bridge = chainBridge.bridge; genericHandler = chainBridge.genericHandler; @@ -129,6 +129,7 @@ cbDeployTask( hre.ethers, deployer, txParams, + 2, ); const { rebaseGateway, transferGateway } = @@ -143,6 +144,7 @@ cbDeployTask( hre.ethers, deployer, txParams, + 2, ); console.log('------------------------------------------------------------'); @@ -263,6 +265,7 @@ cbDeployTask( hre.ethers, deployer, txParams, + 2, ); console.log('------------------------------------------------------------'); @@ -373,7 +376,7 @@ txTask( ...reportRebaseFnSig, txParams, ) - ).wait(); + ).wait(2); await ( await bridge @@ -385,7 +388,7 @@ txTask( ...transferFnSig, txParams, ) - ).wait(); + ).wait(2); } else { console.log('Execute the following on-chain', network); console.log('adminSetGenericResource', [ @@ -450,7 +453,7 @@ txTask( ...reportRebaseFnSig, txParams, ) - ).wait(); + ).wait(2); await ( await bridge .connect(deployer) @@ -461,7 +464,7 @@ txTask( ...transferFnSig, txParams, ) - ).wait(); + ).wait(2); } else { console.log('Execute the following on-chain', network); console.log('adminSetGenericResource', [ diff --git a/tasks/deploy/matic.js b/tasks/deploy/matic.js index d8cccf1..ba3930b 100644 --- a/tasks/deploy/matic.js +++ b/tasks/deploy/matic.js @@ -68,6 +68,7 @@ txTask( hre.ethers, deployer, txParams, + 2, ); console.log('------------------------------------------------------------'); @@ -136,6 +137,7 @@ txTask( hre.ethers, deployer, txParams, + 2, ); console.log('------------------------------------------------------------'); @@ -209,22 +211,22 @@ txTask('deploy:matic_connection', 'Connects the two gateway contracts') await baseRebaseGateway .connect(baseChainSigner) .setFxChildTunnel(satRebaseGateway.address, txParams) - ).wait(); + ).wait(2); await ( await satRebaseGateway .connect(satChainSigner) .setFxRootTunnel(baseRebaseGateway.address, txParams) - ).wait(); + ).wait(2); await ( await baseTransferGateway .connect(baseChainSigner) .setFxChildTunnel(satTransferGateway.address, txParams) - ).wait(); + ).wait(2); await ( await satTransferGateway .connect(satChainSigner) .setFxRootTunnel(baseTransferGateway.address, txParams) - ).wait(); + ).wait(2); }); diff --git a/tasks/deploy/rebase_reporter.js b/tasks/deploy/rebase_reporter.js index 5365fa8..46cce43 100644 --- a/tasks/deploy/rebase_reporter.js +++ b/tasks/deploy/rebase_reporter.js @@ -37,8 +37,9 @@ txTask( deployer, [], txParams, + 2, ); - await batchRebaseReporter.deployTransaction.wait(5); + await batchRebaseReporter.deployTransaction.wait(2); console.log('------------------------------------------------------------'); console.log('Writing data to file'); diff --git a/tasks/info/ampl.js b/tasks/info/ampl.js index 5458587..cc3da42 100644 --- a/tasks/info/ampl.js +++ b/tasks/info/ampl.js @@ -225,10 +225,7 @@ task( 'XCAmpleController:implementation', await proxyAdmin.getProxyImplementation(xcAmple.address), ); - console.log( - 'XCAmpleController:owner', - await xcAmpleController.owner(), - ); + console.log('XCAmpleController:owner', await xcAmpleController.owner()); console.log( 'XCAmpleController:xcAmple', await xcAmpleController.xcAmple(), diff --git a/tasks/ops/rebase.js b/tasks/ops/rebase.js index cdc7461..8cf1667 100644 --- a/tasks/ops/rebase.js +++ b/tasks/ops/rebase.js @@ -1,5 +1,7 @@ const { txTask, types, loadSignerSync } = require('../../helpers/tasks'); const { getEthersProvider } = require('../../helpers/utils'); +const { Bridge } = require('arb-ts'); +const { hexDataLength } = require('@ethersproject/bytes'); const { readDeploymentData, @@ -97,7 +99,7 @@ txTask( ); const satelliteChainIDs = []; - let totalFee = hre.ethers.BigNumber.from('0'); + let totalFee = BigNumber.from('0'); for (let n in args.satelliteChainNetworks) { const network = args.satelliteChainNetworks[n]; const provider = await getEthersProvider(network); @@ -113,8 +115,6 @@ txTask( } console.log('Initiating cross-chain rebase', satelliteChainIDs); - console.log('totalFee', totalFee); - const tx = await batchRebaseReporter .connect(sender) .execute( @@ -131,7 +131,7 @@ txTask( txTask( 'matic:report_rebase', - 'Reports most recent rebase to bridge on base chain for list of given satellite chains through matic bridge', + 'Reports most recent rebase to bridge on base chain to the matic satellite chain', ).setAction(async (args, hre) => { const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit }; if (txParams.gasPrice == 0) { @@ -149,12 +149,71 @@ txTask( 'matic/rebaseGateway', baseChainProvider, ); - const tx = await rebaseGateway.connect(sender).reportRebase(txParams); + const tx = await rebaseGateway.connect(sender).reportRebaseInit(txParams); const txR = await tx.wait(); console.log(txR.transactionHash); }); +txTask( + 'arbitrum:report_rebase', + 'Reports most recent rebase to bridge on base chain to the arbitrum, satellite chain', +) + .addParam( + 'satChainNetwork', + 'The network name of the satellite chain network', + ) + .setAction(async (args, hre) => { + const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit }; + if (txParams.gasPrice == 0) { + txParams.gasPrice = await hre.ethers.provider.getGasPrice(); + } + const sender = await loadSignerSync(args, hre.ethers.provider); + const senderAddress = await sender.getAddress(); + console.log('Sender:', senderAddress); + console.log(txParams); + + const baseChainNetwork = hre.network.name; + const baseChainProvider = hre.ethers.provider; + const baseChainSigner = loadSignerSync(args, baseChainProvider); + + const satChainProvider = getEthersProvider(args.satChainNetwork); + const satChainSigner = loadSignerSync(args, satChainProvider); + + const policy = await getDeployedContractInstance( + hre.network.name, + 'policy', + hre.ethers.provider, + ); + + const rebaseGateway = await getDeployedContractInstance( + baseChainNetwork, + 'arbitrum/rebaseGateway', + baseChainProvider, + ); + + const arb = await Bridge.init(baseChainSigner, satChainSigner); + const fnDataBytes = ethers.utils.defaultAbiCoder.encode( + ['uint256', 'uint256'], + await policy.globalAmpleforthEpochAndAMPLSupply(), + ); + const fnBytesLength = hexDataLength(fnDataBytes) + 4; + const [_submissionPriceWei, nextUpdateTimestamp] = + await arb.l2Bridge.getTxnSubmissionPrice(fnBytesLength); + const submissionPriceWei = _submissionPriceWei.mul(5); // buffer can be reduced + const maxGas = 500000; + const gasPriceBid = await satChainProvider.getGasPrice(); + const callValue = submissionPriceWei.add(gasPriceBid.mul(maxGas)); + txParams.value = callValue; + + const tx = await rebaseGateway + .connect(sender) + .reportRebaseInit(submissionPriceWei, maxGas, gasPriceBid, txParams); + + const txR = await tx.wait(); + console.log(txR.transactionHash); + }); + txTask( 'rebase:satellite_chain', 'Executes rebase on the list of given satellite chains', diff --git a/tasks/upgrade.js b/tasks/upgrade.js index 8f7617b..019ce9a 100644 --- a/tasks/upgrade.js +++ b/tasks/upgrade.js @@ -1,38 +1,41 @@ const { types } = require('hardhat/config'); const { txTask, loadSignerSync, etherscanVerify } = require('../helpers/tasks'); -const { getDeployedContractInstance, upgradeProxyContract } = require('../helpers/contracts'); +const { + getDeployedContractInstance, + upgradeProxyContract, +} = require('../helpers/contracts'); txTask( 'upgrade:xc_ample', 'Uprades the implementation of the xc-ample ERC-20 contract', ) -.addParam('force', 'Skip storage layout verification', false, types.boolean) -.setAction(async (args, hre) => { - const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit }; - if (txParams.gasPrice == 0) { - txParams.gasPrice = await hre.ethers.provider.getGasPrice(); - } + .addParam('force', 'Skip storage layout verification', false, types.boolean) + .setAction(async (args, hre) => { + const txParams = { gasPrice: args.gasPrice, gasLimit: args.gasLimit }; + if (txParams.gasPrice == 0) { + txParams.gasPrice = await hre.ethers.provider.getGasPrice(); + } - const deployer = await loadSignerSync(args, hre.ethers.provider); - const deployerAddress = await deployer.getAddress(); + const deployer = await loadSignerSync(args, hre.ethers.provider); + const deployerAddress = await deployer.getAddress(); - console.log('------------------------------------------------------------'); - console.log('Deployer:', deployerAddress); - console.log(txParams); + console.log('------------------------------------------------------------'); + console.log('Deployer:', deployerAddress); + console.log(txParams); - console.log('------------------------------------------------------------'); - console.log('Upgrading xc-ample contract'); - const newImpl = await upgradeProxyContract( - hre.ethers, - hre.network.name, - 'XCAmple', - 'xcAmple', - deployer, - txParams, - args.force - ); + console.log('------------------------------------------------------------'); + console.log('Upgrading xc-ample contract'); + const newImpl = await upgradeProxyContract( + hre.ethers, + hre.network.name, + 'XCAmple', + 'xcAmple', + deployer, + txParams, + args.force, + ); - console.log('------------------------------------------------------------'); - console.log('Verify on etherscan'); - await etherscanVerify(hre, newImpl.address); -}); + console.log('------------------------------------------------------------'); + console.log('Verify on etherscan'); + await etherscanVerify(hre, newImpl.address); + }); diff --git a/test/helpers/ethers.js b/test/helpers/ethers.js index facd3c7..3559fb3 100644 --- a/test/helpers/ethers.js +++ b/test/helpers/ethers.js @@ -1,22 +1,22 @@ const { ethers } = require('hardhat'); -async function getBlockTime () { +async function getBlockTime() { return (await ethers.provider.getBlock('latest')).timestamp; } -async function mineEmpty () { +async function mineEmpty() { return ethers.provider.send('evm_mine'); } -async function increaseTime (seconds) { +async function increaseTime(seconds) { await ethers.provider.send('evm_mine', [ ethers.BigNumber.from(seconds) .add(await getBlockTime()) - .toNumber() + .toNumber(), ]); } -async function parseEventFromLogs (contract, tx, event) { +async function parseEventFromLogs(contract, tx, event) { const txR = await contract.provider.getTransactionReceipt(tx.hash); for (const l in txR.logs) { if (txR.logs.hasOwnProperty(l)) { @@ -35,5 +35,5 @@ module.exports = { getBlockTime, increaseTime, mineEmpty, - parseEventFromLogs + parseEventFromLogs, }; diff --git a/test/integration/chain_bridge.js b/test/integration/chain_bridge.js index 1b78739..494620c 100644 --- a/test/integration/chain_bridge.js +++ b/test/integration/chain_bridge.js @@ -10,7 +10,7 @@ const { executeXCRebase, executeXCTransfer, XC_TRANSFER_RESOURCE_ID, - packXCTransferData + packXCTransferData, } = require('../../sdk/chain_bridge'); const { execRebase, toAmplFixedPt } = require('../../sdk/ampleforth'); @@ -20,7 +20,7 @@ const { deployTokenVault, deployChainBridgeContracts, deployChainBridgeBaseChainGatewayContracts, - deployChainBridgeSatelliteChainGatewayContracts + deployChainBridgeSatelliteChainGatewayContracts, } = require('../../helpers/deploy'); let accounts, @@ -41,7 +41,7 @@ let accounts, userASatChain2Wallet, userBSatChain2Wallet; -async function setupContracts () { +async function setupContracts() { accounts = await ethers.getSigners(); deployer = accounts[0]; relayer = accounts[1]; @@ -64,7 +64,7 @@ async function setupContracts () { relayers: [await deployer.getAddress(), await relayer.getAddress()], relayerThreshold: RELAYER_TRESHOLD, fee: 0, - expiry: 1000 + expiry: 1000, }, ethers, deployer, @@ -89,7 +89,7 @@ async function setupContracts () { tokenSymbol: 'satChain1XCAmple', tokenName: 'satChain1XCAmple', globalAmpleforthEpoch, - globalAMPLSupply + globalAMPLSupply, }, ethers, deployer, @@ -100,7 +100,7 @@ async function setupContracts () { relayers: [await deployer.getAddress(), await relayer.getAddress()], relayerThreshold: RELAYER_TRESHOLD, fee: 0, - expiry: 1000 + expiry: 1000, }, ethers, deployer, @@ -121,7 +121,7 @@ async function setupContracts () { tokenSymbol: 'satChain2XCAmple', tokenName: 'satChain2XCAmple', globalAmpleforthEpoch, - globalAMPLSupply + globalAMPLSupply, }, ethers, deployer, @@ -132,7 +132,7 @@ async function setupContracts () { relayers: [await deployer.getAddress(), await relayer.getAddress()], relayerThreshold: RELAYER_TRESHOLD, fee: 0, - expiry: 1000 + expiry: 1000, }, ethers, deployer, @@ -151,13 +151,13 @@ async function setupContracts () { bridgeContractsMap = { base: baseChainBridgeContracts, sat1: satChain1BridgeContracts, - sat2: satChain2BridgeContracts + sat2: satChain2BridgeContracts, }; amplContractsMap = { base: baseChainAmplContracts, sat1: satChain1AmplContracts, - sat2: satChain2AmplContracts + sat2: satChain2AmplContracts, }; // On the main-chain userA and userB have 100k AMPLs each @@ -170,7 +170,7 @@ async function setupContracts () { .transfer(await userBBaseChainWallet.getAddress(), toAmplFixedPt('100000')); } -async function mockOffchain ( +async function mockOffchain( toChainBridge, fromChainID, depositNonce, @@ -192,7 +192,7 @@ async function mockOffchain ( // console.log((await toChainBridge.getProposal(fromChainID, depositNonce, dataHash))._status); } -async function execXCReportRebase (chain) { +async function execXCReportRebase(chain) { // Triggering rebase report to sat chain const { data, dataHash, depositNonce, resourceID } = await executeXCRebase( deployer, @@ -214,7 +214,7 @@ async function execXCReportRebase (chain) { } // Executes rebase end to end -async function execXCRebaseE2E (perc, chainSubset = []) { +async function execXCRebaseE2E(perc, chainSubset = []) { const chains = chainSubset.length === 0 ? Object.keys(bridgeContractsMap) : chainSubset; @@ -245,7 +245,7 @@ async function execXCRebaseE2E (perc, chainSubset = []) { } } -async function execXCSend ( +async function execXCSend( fromChain, toChain, fromAccount, @@ -292,7 +292,7 @@ async function execXCSend ( ); } -async function getBalancesAndSupply () { +async function getBalancesAndSupply() { const userAEthBal = await baseChainAmplContracts.ampl.balanceOf( await userABaseChainWallet.getAddress(), ); @@ -322,11 +322,11 @@ async function getBalancesAndSupply () { sat1Balances: [userATronBal, userBTronBal], sat2Balances: [userAAcalaBal, userBAcalaBal], sat1Supply, - sat2Supply + sat2Supply, }; } -async function checkBalancesAndSupply ( +async function checkBalancesAndSupply( baseBalances, sat1Balances, sat1Supply, diff --git a/test/unit/_utilities/batch_tx_executor.js b/test/unit/_utilities/batch_tx_executor.js index 562fee9..1ab13a4 100644 --- a/test/unit/_utilities/batch_tx_executor.js +++ b/test/unit/_utilities/batch_tx_executor.js @@ -2,7 +2,7 @@ const { ethers } = require('hardhat'); const { expect } = require('chai'); let accounts, deployer, user, batchExecutor, mockDownstream, r; -async function setupContracts () { +async function setupContracts() { // prepare signers accounts = await ethers.getSigners(); deployer = accounts[0]; @@ -140,12 +140,12 @@ describe('BatchTxExecutor', function () { await expect( await batchExecutor.callStatic.checkExecution(0, { - value: '1000000000000000000' + value: '1000000000000000000', }), ).to.be.true; await expect( await batchExecutor.callStatic.executeAll({ - value: '1000000000000000000' + value: '1000000000000000000', }), ).to.be.true; expect(await batchExecutor.totalValue()).to.be.eq('1000000000000000000'); diff --git a/test/unit/_utilities/signatures.js b/test/unit/_utilities/signatures.js index f8192cf..7aa082a 100644 --- a/test/unit/_utilities/signatures.js +++ b/test/unit/_utilities/signatures.js @@ -3,7 +3,7 @@ const { keccak256, defaultAbiCoder, toUtf8Bytes, - solidityPack + solidityPack, } = require('ethers/lib/utils'); const { ecsign } = require('ethereumjs-util'); @@ -17,7 +17,7 @@ const EIP712_DOMAIN_TYPE = [ { name: 'name', type: 'string' }, { name: 'version', type: 'string' }, { name: 'chainId', type: 'uint256' }, - { name: 'verifyingContract', type: 'address' } + { name: 'verifyingContract', type: 'address' }, ]; const EIP2612_PERMIT_TYPEHASH = keccak256( @@ -31,11 +31,11 @@ const EIP2612_PERMIT_TYPE = [ { name: 'spender', type: 'address' }, { name: 'value', type: 'uint256' }, { name: 'nonce', type: 'uint256' }, - { name: 'deadline', type: 'uint256' } + { name: 'deadline', type: 'uint256' }, ]; // Gets the EIP712 domain separator -function getDomainSeparator (version, name, contractAddress, chainId) { +function getDomainSeparator(version, name, contractAddress, chainId) { return keccak256( defaultAbiCoder.encode( ['bytes32', 'bytes32', 'bytes32', 'uint256', 'address'], @@ -44,7 +44,7 @@ function getDomainSeparator (version, name, contractAddress, chainId) { keccak256(toUtf8Bytes(name)), keccak256(toUtf8Bytes(version)), chainId, - contractAddress + contractAddress, ], ), ); @@ -52,7 +52,7 @@ function getDomainSeparator (version, name, contractAddress, chainId) { // Returns the EIP712 hash which should be signed by the user // in order to make a call to `permit` -function getPermitDigest ( +function getPermitDigest( version, name, address, @@ -115,5 +115,5 @@ module.exports = { EIP2612_PERMIT_TYPE, getDomainSeparator, getPermitDigest, - signEIP712Permission + signEIP712Permission, }; diff --git a/test/unit/base-chain/bridge-gateways/ampl_chain_bridge_gateway.js b/test/unit/base-chain/bridge-gateways/ampl_chain_bridge_gateway.js index d7660bf..c4e4bfd 100644 --- a/test/unit/base-chain/bridge-gateways/ampl_chain_bridge_gateway.js +++ b/test/unit/base-chain/bridge-gateways/ampl_chain_bridge_gateway.js @@ -12,7 +12,7 @@ let accounts, policy, vault, gateway; -async function setupContracts () { +async function setupContracts() { accounts = await ethers.getSigners(); deployer = accounts[0]; depositorAddress = await deployer.getAddress(); diff --git a/test/unit/base-chain/token_vault.js b/test/unit/base-chain/token_vault.js index 5f5f66f..0d33576 100644 --- a/test/unit/base-chain/token_vault.js +++ b/test/unit/base-chain/token_vault.js @@ -10,7 +10,7 @@ let accounts, otherBridgeAddress, vault, mockToken; -async function setupContracts () { +async function setupContracts() { accounts = await ethers.getSigners(); deployer = accounts[0]; bridge = accounts[1]; diff --git a/test/unit/satellite-chain/bridge-gateways/chain_bridge_xcampl_gateway.js b/test/unit/satellite-chain/bridge-gateways/chain_bridge_xcampl_gateway.js index d3a7182..f8d2706 100644 --- a/test/unit/satellite-chain/bridge-gateways/chain_bridge_xcampl_gateway.js +++ b/test/unit/satellite-chain/bridge-gateways/chain_bridge_xcampl_gateway.js @@ -11,7 +11,7 @@ let accounts, xcAmple, xcController, gateway; -async function setupContracts () { +async function setupContracts() { accounts = await ethers.getSigners(); deployer = accounts[0]; depositorAddress = await deployer.getAddress(); diff --git a/test/unit/satellite-chain/xc-ampleforth/xc_ample.js b/test/unit/satellite-chain/xc-ampleforth/xc_ample.js index 2f998cb..180e978 100644 --- a/test/unit/satellite-chain/xc-ampleforth/xc_ample.js +++ b/test/unit/satellite-chain/xc-ampleforth/xc_ample.js @@ -5,7 +5,7 @@ const { expect } = require('chai'); // https://github.com/ampleforth/uFragments/blob/master/test/unit/UFragments.js const DECIMALS = 9; -const toUFrgDenomination = ample => ethers.utils.parseUnits(ample, DECIMALS); +const toUFrgDenomination = (ample) => ethers.utils.parseUnits(ample, DECIMALS); const INITIAL_AMPL_SUPPLY = ethers.utils.parseUnits('50', 6 + DECIMALS); const REBASE_AMT = INITIAL_AMPL_SUPPLY.div(10); @@ -21,7 +21,7 @@ const unitTokenAmount = toUFrgDenomination('1'); let accounts, deployer, xcAmple; -async function setupContracts () { +async function setupContracts() { // prepare signers accounts = await ethers.getSigners(); deployer = accounts[0]; diff --git a/test/unit/satellite-chain/xc-ampleforth/xc_ample_burn.js b/test/unit/satellite-chain/xc-ampleforth/xc_ample_burn.js index e7ed609..7928d6e 100644 --- a/test/unit/satellite-chain/xc-ampleforth/xc_ample_burn.js +++ b/test/unit/satellite-chain/xc-ampleforth/xc_ample_burn.js @@ -2,7 +2,7 @@ const { ethers, upgrades } = require('hardhat'); const { expect } = require('chai'); const DECIMALS = 9; -const toUFrgDenomination = ample => ethers.utils.parseUnits(ample, DECIMALS); +const toUFrgDenomination = (ample) => ethers.utils.parseUnits(ample, DECIMALS); const INITIAL_SUPPLY = ethers.utils.parseUnits('50', 6 + DECIMALS); const MAX_SUPPLY = ethers.BigNumber.from('2').pow(128).sub(1); @@ -10,7 +10,7 @@ const unitTokenAmount = toUFrgDenomination('1'); let accounts, deployer, otherUser, xcAmple; -async function setupContracts () { +async function setupContracts() { // prepare signers accounts = await ethers.getSigners(); deployer = accounts[0]; @@ -24,7 +24,7 @@ async function setupContracts () { factory.connect(deployer), ['XCAmple', 'xcAMPL', INITIAL_SUPPLY], { - initializer: 'initialize(string,string,uint256)' + initializer: 'initialize(string,string,uint256)', }, ); await xcAmple.setController(deployer.getAddress()); diff --git a/test/unit/satellite-chain/xc-ampleforth/xc_ample_elastic_behavior.js b/test/unit/satellite-chain/xc-ampleforth/xc_ample_elastic_behavior.js index 1e7d89d..e9e58ea 100644 --- a/test/unit/satellite-chain/xc-ampleforth/xc_ample_elastic_behavior.js +++ b/test/unit/satellite-chain/xc-ampleforth/xc_ample_elastic_behavior.js @@ -6,12 +6,12 @@ const INITIAL_SUPPLY = ethers.utils.parseUnits('50', 6 + DECIMALS); const MAX_UINT256 = ethers.BigNumber.from(2).pow(256).sub(1); const TOTAL_GONS = MAX_UINT256.sub(MAX_UINT256.mod(INITIAL_SUPPLY)); -const toUFrgDenomination = ample => ethers.utils.parseUnits(ample, DECIMALS); +const toUFrgDenomination = (ample) => ethers.utils.parseUnits(ample, DECIMALS); const unitTokenAmount = toUFrgDenomination('1'); let token, owner, anotherAccount, recipient; -async function upgradeableToken () { +async function upgradeableToken() { const [owner, recipient, anotherAccount] = await ethers.getSigners(); const factory = await ethers.getContractFactory( 'contracts/satellite-chain/xc-ampleforth/XCAmple.sol:XCAmple', @@ -20,7 +20,7 @@ async function upgradeableToken () { factory.connect(owner), ['XCAmple', 'xcAMPL', INITIAL_SUPPLY], { - initializer: 'initialize(string,string,uint256)' + initializer: 'initialize(string,string,uint256)', }, ); await token.setController(owner.getAddress()); diff --git a/test/unit/satellite-chain/xc-ampleforth/xc_ample_erc20_behavior.js b/test/unit/satellite-chain/xc-ampleforth/xc_ample_erc20_behavior.js index e6a7df6..df035c7 100644 --- a/test/unit/satellite-chain/xc-ampleforth/xc_ample_erc20_behavior.js +++ b/test/unit/satellite-chain/xc-ampleforth/xc_ample_erc20_behavior.js @@ -29,7 +29,7 @@ const { ethers, upgrades, waffle } = require('hardhat'); const { expect } = require('chai'); -function toUFrgDenomination (x) { +function toUFrgDenomination(x) { return ethers.utils.parseUnits(x, DECIMALS); } @@ -44,7 +44,7 @@ const transferAmountPlusOne = transferAmount.add(unitTokenAmount); const transferAmountMinusOne = transferAmount.sub(unitTokenAmount); let token, owner, anotherAccount, recipient; -async function upgradeableToken () { +async function upgradeableToken() { const [owner, recipient, anotherAccount] = await ethers.getSigners(); const factory = await ethers.getContractFactory( 'contracts/satellite-chain/xc-ampleforth/XCAmple.sol:XCAmple', @@ -53,7 +53,7 @@ async function upgradeableToken () { factory.connect(owner), ['XCAmple', 'xcAMPL', INITIAL_SUPPLY], { - initializer: 'initialize(string,string,uint256)' + initializer: 'initialize(string,string,uint256)', }, ); await token.setController(owner.getAddress()); diff --git a/test/unit/satellite-chain/xc-ampleforth/xc_ample_mint.js b/test/unit/satellite-chain/xc-ampleforth/xc_ample_mint.js index 09d92eb..88595f5 100644 --- a/test/unit/satellite-chain/xc-ampleforth/xc_ample_mint.js +++ b/test/unit/satellite-chain/xc-ampleforth/xc_ample_mint.js @@ -2,7 +2,7 @@ const { ethers, upgrades } = require('hardhat'); const { expect } = require('chai'); const DECIMALS = 9; -const toUFrgDenomination = ample => ethers.utils.parseUnits(ample, DECIMALS); +const toUFrgDenomination = (ample) => ethers.utils.parseUnits(ample, DECIMALS); const INITIAL_SUPPLY = ethers.utils.parseUnits('50', 6 + DECIMALS); const MAX_SUPPLY = ethers.BigNumber.from('2').pow(128).sub(1); @@ -10,7 +10,7 @@ const unitTokenAmount = toUFrgDenomination('1'); let accounts, deployer, otherUser, xcAmple, initialSupply; -async function setupContracts () { +async function setupContracts() { // prepare signers accounts = await ethers.getSigners(); deployer = accounts[0]; @@ -24,7 +24,7 @@ async function setupContracts () { factory.connect(deployer), ['XCAmple', 'xcAMPL', INITIAL_SUPPLY], { - initializer: 'initialize(string,string,uint256)' + initializer: 'initialize(string,string,uint256)', }, ); await xcAmple.setController(deployer.getAddress()); diff --git a/test/unit/satellite-chain/xc-ampleforth/xc_ample_permit.js b/test/unit/satellite-chain/xc-ampleforth/xc_ample_permit.js index d16304f..3bfe981 100644 --- a/test/unit/satellite-chain/xc-ampleforth/xc_ample_permit.js +++ b/test/unit/satellite-chain/xc-ampleforth/xc_ample_permit.js @@ -9,7 +9,7 @@ const { EIP712_DOMAIN_TYPEHASH, EIP2612_PERMIT_TYPEHASH, getDomainSeparator, - signEIP712Permission + signEIP712Permission, } = require('../../_utilities/signatures'); const EIP712_REVISION = '1'; @@ -25,7 +25,7 @@ let accounts, spenderAddress, xcAmple; -async function setupContracts () { +async function setupContracts() { accounts = await ethers.getSigners(); deployer = accounts[0]; diff --git a/test/unit/satellite-chain/xc-ampleforth/xc_controller.js b/test/unit/satellite-chain/xc-ampleforth/xc_controller.js index 9c079b7..95d527d 100644 --- a/test/unit/satellite-chain/xc-ampleforth/xc_controller.js +++ b/test/unit/satellite-chain/xc-ampleforth/xc_controller.js @@ -2,7 +2,7 @@ const { ethers, upgrades } = require('hardhat'); const { expect } = require('chai'); let accounts, deployer, controller, mockToken; -async function setupContracts () { +async function setupContracts() { // prepare signers accounts = await ethers.getSigners(); deployer = accounts[0]; @@ -25,7 +25,7 @@ async function setupContracts () { factory.connect(deployer), [mockToken.address, 1], { - initializer: 'initialize(address,uint256)' + initializer: 'initialize(address,uint256)', }, ); } diff --git a/test/unit/satellite-chain/xc-ampleforth/xc_controller_bridge.js b/test/unit/satellite-chain/xc-ampleforth/xc_controller_bridge.js index c250837..dcdde6e 100644 --- a/test/unit/satellite-chain/xc-ampleforth/xc_controller_bridge.js +++ b/test/unit/satellite-chain/xc-ampleforth/xc_controller_bridge.js @@ -8,7 +8,7 @@ let accounts, beneficiaryAddress, controller, mockToken; -async function setupContracts () { +async function setupContracts() { // prepare signers accounts = await ethers.getSigners(); deployer = accounts[0]; @@ -32,14 +32,14 @@ async function setupContracts () { factory.connect(deployer), [mockToken.address, 1], { - initializer: 'initialize(address,uint256)' + initializer: 'initialize(address,uint256)', }, ); await controller.connect(deployer).addBridgeGateway(bridge.getAddress()); await controller.connect(deployer).addBridgeGateway(bridgeOther.getAddress()); } -async function getBlockTime (b = 'latest') { +async function getBlockTime(b = 'latest') { return (await ethers.provider.getBlock(b)).timestamp; } diff --git a/test/unit/satellite-chain/xc-ampleforth/xc_controller_rebase.js b/test/unit/satellite-chain/xc-ampleforth/xc_controller_rebase.js index f259247..72e157a 100644 --- a/test/unit/satellite-chain/xc-ampleforth/xc_controller_rebase.js +++ b/test/unit/satellite-chain/xc-ampleforth/xc_controller_rebase.js @@ -9,7 +9,7 @@ let accounts, controller, mockToken, mockRebaseRelayer; -async function setupContracts () { +async function setupContracts() { // prepare signers accounts = await ethers.getSigners(); deployer = accounts[0]; @@ -39,7 +39,7 @@ async function setupContracts () { factory.connect(deployer), [mockToken.address, 1], { - initializer: 'initialize(address,uint256)' + initializer: 'initialize(address,uint256)', }, ); await controller.connect(deployer).addBridgeGateway(bridge.getAddress());