diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..da9447b10 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,249 @@ +version: 2.1 + +parameters: + node-version: + type: string + default: "18.18.0" + +commands: + yarn-install: + steps: + - run: yarn install --immutable + + install-anvil: + steps: + - restore_cache: + keys: + - foundry-{{ .Environment.FOUNDRY_CACHE_VERSION }} + + - run: + name: "Install Foundry" + working_directory: ~/ + environment: + SHELL: /bin/bash + command: |- + export PATH="$PATH:$HOME/.foundry/bin" + echo 'export PATH=$PATH:$HOME/.foundry/bin' >> $BASH_ENV + + if command -v anvil; then + echo "Anvil already installed" + anvil --version + else + curl -L https://foundry.paradigm.xyz | bash + foundryup + fi + + - save_cache: + key: foundry-{{ .Environment.FOUNDRY_CACHE_VERSION }} + paths: + - "~/.foundry" + + run-anvil: + parameters: + provider-url: + type: string + port: + type: integer + default: 8545 + steps: + - run: + name: Run anvil on 127.0.0.1:<< parameters.port >> + command: | + anvil \ + --port << parameters.port >> \ + --fork-url << parameters.provider-url >> + background: true + + wait-for-anvil: + parameters: + port: + type: integer + default: 8545 + steps: + - run: + name: Wait for anvil ready on 127.0.0.1:<< parameters.port >> + command: wget -q -O - --retry-connrefused --waitretry=20 --read-timeout=20 --timeout=15 -t 10 --post-data='{"method":"eth_chainId","params":[],"id":1,"jsonrpc":"2.0"}' --header='Content-Type:application/json' http://127.0.0.1:<< parameters.port >> + + install-ipfs: + steps: + - restore_cache: + keys: + - ipfs-{{ .Environment.IPFS_CACHE_VERSION }} + + - run: + name: "Install IPFS" + working_directory: ~/ + command: | + export PATH="$PATH:$HOME/go-ipfs" + echo 'export PATH=$PATH:$HOME/go-ipfs' >> $BASH_ENV + + if command -v ipfs; then + echo "IPFS already installed" + ipfs version + ipfs id + else + LATEST_VERSION=$(curl -sSL https://dist.ipfs.tech/go-ipfs/versions | tail -n 1) + LATEST_VERSION_NUMBER=${LATEST_VERSION#*v} + DOWNLOAD_URL="https://dist.ipfs.tech/go-ipfs/${LATEST_VERSION}/go-ipfs_${LATEST_VERSION}_linux-amd64.tar.gz" + echo "DOWNLOAD_URL=$DOWNLOAD_URL" + curl -sSL -o ipfs.tar.gz $DOWNLOAD_URL + tar -xzf ipfs.tar.gz + rm -rf ~/.ipfs + ipfs init + fi + + - save_cache: + key: ipfs-{{ .Environment.IPFS_CACHE_VERSION }} + paths: + - "~/go-ipfs" + - "~/.ipfs" + + run-ipfs: + steps: + - run: + command: ipfs daemon + background: true + + wait-for-ipfs: + steps: + - run: + name: "Wait for IPFS daemon to start" + command: wget --output-document - --retry-connrefused --waitretry=20 --read-timeout=20 --timeout=15 -t 10 --post-data '' "http://localhost:5001/api/v0/version" + +jobs: + lint: + docker: + - image: cimg/node:<< pipeline.parameters.node-version >> + steps: + - checkout + - yarn-install + - run: yarn dedupe --check + - run: yarn pretty:check + + fork-test: + parameters: + toml: + type: string + preset: + type: string + default: "main" + chain-id: + type: integer + provider-url: + type: string + upgrade-from: + type: string + default: "synthetix-omnibus:latest" + docker: + - image: cimg/node:<< pipeline.parameters.node-version >> + steps: + - checkout + - install-anvil + - run-anvil: + provider-url: << parameters.provider-url >> + #- install-ipfs + #- run-ipfs + - yarn-install + - wait-for-anvil + #- wait-for-ipfs + + - run: + name: "Generate upgrade transactions" + command: | + yarn cannon build << parameters.toml >> \ + --dry-run \ + --preset << parameters.preset >> \ + --upgrade-from << parameters.upgrade-from >> \ + --chain-id << parameters.chain-id >> \ + --provider-url << parameters.provider-url >> \ + --write-script ./e2e/deployments/upgrade.ndjson \ + --write-script-format json | tee ./cannon-build.log + + - run: grep '💥' ./cannon-build.log + - run: + name: "Halt if no changes detected" + command: | + [ -s ./e2e/deployments/upgrade.ndjson ] || circleci-agent step halt + + - store_artifacts: + path: "./e2e/deployments/upgrade.ndjson" + + - run: + name: "Check for Proxies redeployment" + environment: + - PROXIES: "contract.InitialCoreProxy contract.InitialProxy contract.InitialSpotMarketProxy" + command: | + for PROXY in $PROXIES; do + echo "grep -c "Executing [$PROXY]" ./cannon-build.log" + if [ $(grep -c "Executing [$PROXY]" ./cannon-build.log) -gt 0 ]; then + echo "Proxy $PROXY was modified" + exit 1 + fi + done + + - run: + name: "Generate deployments" + command: node e2e/fetch-local-deployment.js ./cannon-build.log + + - store_artifacts: + path: "./e2e/deployments" + + - run: + name: "Upgrade on local fork" + command: node e2e/deploy.js ./e2e/deployments/upgrade.ndjson + + - run: + name: "Run tests" + environment: + - DEBUG: "tasks:*" + command: yarn mocha e2e/tests/<< parameters.toml >>/*.e2e.js + +workflows: + version: 2.1 + + tests: + jobs: + - lint + + - fork-test: + name: base-goerli-andromeda + toml: omnibus-base-goerli-andromeda.toml + preset: andromeda + chain-id: 84531 + provider-url: https://base-goerli.infura.io/v3/$INFURA_API_KEY + + - fork-test: + name: base-goerli + toml: omnibus-base-goerli.toml + chain-id: 84531 + provider-url: https://base-goerli.infura.io/v3/$INFURA_API_KEY + + - fork-test: + name: goerli + toml: omnibus-goerli.toml + chain-id: 5 + provider-url: https://goerli.infura.io/v3/$INFURA_API_KEY + + - fork-test: + name: mainnet + toml: omnibus-mainnet.toml + chain-id: 1 + provider-url: https://mainnet.infura.io/v3/$INFURA_API_KEY + + - fork-test: + name: optimism-mainnet + toml: omnibus-optimism-mainnet.toml + chain-id: 10 + provider-url: https://optimism-mainnet.infura.io/v3/$INFURA_API_KEY + + - fork-test: + name: sepolia + toml: omnibus-sepolia.toml + chain-id: 11155111 + provider-url: https://sepolia.infura.io/v3/$INFURA_API_KEY + + - fork-test: + name: polygon-mumbai + toml: omnibus-polygon-mumbai.toml + chain-id: 80001 + provider-url: https://polygon-mumbai.infura.io/v3/$INFURA_API_KEY diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index 5422d429c..000000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: e2e - -on: - pull_request: {} - push: - branches: - - "main" - -jobs: - test: - runs-on: ubuntu-latest - env: - INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} - strategy: - fail-fast: false - matrix: - toml: - - "omnibus-mainnet.toml" - - "omnibus-optimism-mainnet.toml" - - "omnibus-goerli.toml" - - "omnibus-optimism-goerli.toml" - - "omnibus-base-goerli-andromeda.toml" - - include: - - toml: "omnibus-mainnet.toml" - chainId: 1 - providerUrl: "https://mainnet.infura.io/v3/$INFURA_API_KEY" - - - toml: "omnibus-optimism-mainnet.toml" - chainId: 10 - providerUrl: "https://optimism-mainnet.infura.io/v3/$INFURA_API_KEY" - - - toml: "omnibus-goerli.toml" - chainId: 5 - providerUrl: "https://goerli.infura.io/v3/$INFURA_API_KEY" - - - toml: "omnibus-optimism-goerli.toml" - chainId: 420 - providerUrl: "https://optimism-goerli.infura.io/v3/$INFURA_API_KEY" - - - toml: "omnibus-base-goerli-andromeda.toml" - chainId: 84531 - providerUrl: "https://base-goerli.infura.io/v3/$INFURA_API_KEY" - - steps: - - name: Install Foundry (Cannon) - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - run: anvil -V - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: "18" - cache: "yarn" - - run: yarn --version - - run: yarn install --immutable - - run: yarn build ${{ matrix.chainId }} ${{ matrix.toml }} - - name: "Tests" - run: | - echo "Run anvil" - anvil --fork-url ${{ matrix.providerUrl }} & - - echo "Wait for anvil 127.0.0.1:8545" - wget -q -O - --retry-connrefused --waitretry=20 --read-timeout=20 --timeout=15 -t 10 --post-data='{"method":"eth_chainId","params":[],"id":1,"jsonrpc":"2.0"}' --header='Content-Type:application/json' http://127.0.0.1:8545 - - echo "Execute tests" - TEST_TOML="${{ matrix.toml }}" yarn test e2e/tests/${{ matrix.toml }}/*.e2e.js diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index a56afb598..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: lint - -on: - pull_request: {} - push: - branches: - - "test" - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: "18" - cache: "yarn" - - run: yarn --version - - run: yarn install --immutable - - run: yarn dedupe --check - - run: yarn pretty:check diff --git a/.github/workflows/simulate-release.yml b/.github/workflows/simulate-release.yml deleted file mode 100644 index eba65c7cb..000000000 --- a/.github/workflows/simulate-release.yml +++ /dev/null @@ -1,133 +0,0 @@ -name: Simulate Release - -on: - pull_request: {} - push: - branches: - - "main" - -jobs: - test: - runs-on: ubuntu-latest - env: - CANNON_SETTINGS: ${{ secrets.CANNON_SETTINGS }} - INFURA_API_KEY: ${{ secrets.INFURA_API_KEY }} - strategy: - fail-fast: false - matrix: - toml: - - "omnibus-mainnet.toml" - - "omnibus-optimism-mainnet.toml" - - "omnibus-goerli.toml" - # - "omnibus-optimism-goerli.toml" # TODO: enable when deployed - - "omnibus-base-goerli-andromeda.toml" - # - "omnibus-optimism-goerli-dev.toml" # TODO: enable when deployed - - "omnibus-base-goerli.toml" - # - "omnibus-base-mainnet.toml" # TODO: enable when deployed - - "omnibus-base-goerli-competition.toml" - - "omnibus-sepolia.toml" - - "omnibus-polygon-mumbai.toml" - # - "omnibus-arbitrum-goerli.toml" # Arbitrum Goerli always fails on dry run - - include: - - toml: "omnibus-mainnet.toml" - preset: "main" - chainId: 1 - providerUrl: "https://mainnet.infura.io/v3/$INFURA_API_KEY" - upgradeFrom: "synthetix-omnibus:latest" - - - toml: "omnibus-optimism-mainnet.toml" - preset: "main" - chainId: 10 - providerUrl: "https://optimism-mainnet.infura.io/v3/$INFURA_API_KEY" - upgradeFrom: "synthetix-omnibus:latest" - - - toml: "omnibus-goerli.toml" - preset: "main" - chainId: 5 - providerUrl: "https://goerli.infura.io/v3/$INFURA_API_KEY" - upgradeFrom: "synthetix-omnibus:latest" - - #- toml: "omnibus-optimism-goerli.toml" - # preset: "main" - # chainId: 420 - # providerUrl: "https://optimism-goerli.infura.io/v3/$INFURA_API_KEY" - - #- toml: "omnibus-optimism-goerli-dev.toml" - # preset: "dev" - # chainId: 420 - # providerUrl: "https://optimism-goerli.infura.io/v3/$INFURA_API_KEY" - - - toml: "omnibus-base-goerli-andromeda.toml" - preset: "andromeda" - chainId: 84531 - providerUrl: "https://base-goerli.infura.io/v3/$INFURA_API_KEY" - upgradeFrom: "synthetix-omnibus:3.3.3-dev.e141cd8c" - - #- toml: "omnibus-base-mainnet.toml" - # preset: "main" - # chainId: 8453 - # providerUrl: "https://base-mainnet.infura.io/v3/$INFURA_API_KEY" - - - toml: "omnibus-base-goerli.toml" - preset: "main" - chainId: 84531 - providerUrl: "https://base-goerli.infura.io/v3/$INFURA_API_KEY" - upgradeFrom: "synthetix-omnibus:latest" - - - toml: "omnibus-base-goerli-competition.toml" - preset: "competition" - chainId: 84531 - providerUrl: "https://base-goerli.infura.io/v3/$INFURA_API_KEY" - upgradeFrom: "synthetix-omnibus:latest" - - - toml: "omnibus-sepolia.toml" - preset: "main" - chainId: 11155111 - providerUrl: "https://sepolia.infura.io/v3/$INFURA_API_KEY" - upgradeFrom: "synthetix-omnibus:latest" - - - toml: "omnibus-polygon-mumbai.toml" - preset: "main" - chainId: 80001 - providerUrl: "https://polygon-mumbai.infura.io/v3/$INFURA_API_KEY" - upgradeFrom: "synthetix-omnibus:latest" - - # - toml: "omnibus-arbitrum-goerli.toml" - # preset: "main" - # chainId: 421613 - # providerUrl: "https://arbitrum-goerli.infura.io/v3/$INFURA_API_KEY" - - steps: - - name: Install Foundry (Cannon) - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - run: anvil -V - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: "18" - cache: "yarn" - - run: yarn --version - - run: yarn install --immutable - - run: | - yarn cannon build \ - ${{ matrix.toml }} \ - --upgrade-from ${{ matrix.upgradeFrom }} \ - --preset ${{ matrix.preset }} \ - --provider-url ${{ matrix.providerUrl }} \ - --chain-id ${{ matrix.chainId }} \ - --dry-run | tee deployment.log - - echo "grep '💥' deployment.log" - grep '💥' deployment.log - - export PROXIES="contract.InitialCoreProxy contract.InitialProxy contract.InitialSpotMarketProxy" - for PROXY in $PROXIES; do - echo "grep -c "Executing [$PROXY]" deployment.log" - if [ $(grep -c "Executing [$PROXY]" deployment.log) -gt 0 ]; then - echo "Proxy $PROXY was modified" - exit 1 - fi - done diff --git a/e2e/deploy.js b/e2e/deploy.js new file mode 100644 index 000000000..6ad965510 --- /dev/null +++ b/e2e/deploy.js @@ -0,0 +1,54 @@ +const util = require('util'); +const path = require('path'); +const fs = require('fs/promises'); +const { ethers } = require('ethers'); + +util.inspect.defaultOptions.depth = null; +util.inspect.defaultOptions.maxArrayLength = null; + +const fgReset = '\x1b[0m'; +const fgRed = '\x1b[31m'; +const fgGreen = '\x1b[32m'; +const fgYellow = '\x1b[33m'; +const fgCyan = '\x1b[36m'; + +ethers.BigNumber.prototype[util.inspect.custom] = function (depth, inspectOptions, inspect) { + return `${fgCyan}BigNumber( ${fgYellow}${fgGreen}${this.toHexString()} ${fgYellow}${this.toString()}${fgCyan} )${fgReset}`; +}; + +const [ndjsonTxnsFile] = process.argv.slice(2); +if (!ndjsonTxnsFile) { + console.error(`${fgRed}ERROR: Expected 1 argument${fgReset}`); + console.error(`Usage: ${fgGreen}node e2e/deploy.js ${fgCyan}"ndjsonTxnsFile"${fgReset}`); + console.error( + `Example: ${fgGreen}node e2e/deploy.js ${fgCyan}"./e2e/deployments/upgrade.ndjson"${fgReset}` + ); + process.exit(1); +} + +async function run() { + console.log(`Loading update transactions from ${fgCyan}"${ndjsonTxnsFile}"${fgReset}`); + const ndjson = await fs.readFile(path.resolve(ndjsonTxnsFile), 'utf8'); + const txns = ndjson + .split('\n') + .filter(Boolean) + .flatMap((line) => JSON.parse(line).txns); + + const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); + for (const { hash, from, to, data, value } of txns) { + console.log(); + console.log(); + console.log(); + console.log('============================================================================'); + console.log({ hash, from, to, data, value }); + await provider.send('anvil_setBalance', [from, ethers.utils.parseEther('10').toHexString()]); + await provider.send('anvil_impersonateAccount', [from]); + const signer = provider.getSigner(from); + const tx = await signer.sendTransaction({ to, data, value }); + const result = await tx.wait(); + console.log(result); + await provider.send('anvil_stopImpersonatingAccount', [from]); + console.log('============================================================================'); + } +} +run(); diff --git a/e2e/fetch-deployments.js b/e2e/fetch-deployments.js deleted file mode 100755 index d094f1142..000000000 --- a/e2e/fetch-deployments.js +++ /dev/null @@ -1,163 +0,0 @@ -#!/usr/bin/env node - -const path = require('path'); -const fs = require('fs/promises'); -const toml = require('@iarna/toml'); -const { ethers } = require('ethers'); -const { OnChainRegistry, IPFSLoader } = require('@usecannon/builder'); - -const DEFAULT_REGISTRY_ADDRESS = '0x8E5C7EFC9636A6A0408A46BB7F617094B81e5dba'; -const CURRENT_DIR = __dirname; -const ROOT = path.resolve(`${CURRENT_DIR}/..`); - -async function fetchDeployment({ chainId, deploymentFile, registry, loader }) { - const config = await fs.readFile(deploymentFile, 'utf8'); - const { name, version, setting } = toml.parse(config); - const preset = setting?.target_preset?.defaultValue ?? 'main'; - - await fs.mkdir(`${CURRENT_DIR}/deployments/${chainId}-${preset}`, { recursive: true }); - - const snxAddress = setting?.snx_address?.defaultValue ?? ethers.constants.AddressZero; - await fs.writeFile( - `${CURRENT_DIR}/deployments/${chainId}-${preset}/snx.json`, - JSON.stringify({ address: snxAddress }, null, 2) - ); - - const ipfs = await registry.getUrl(`${name}:${version}`, `${chainId}-${preset}`); - - const meta = { - name, - version, - preset, - ipfs, - chainId, - deploymentFile: path.relative(ROOT, deploymentFile), - }; - await fs.writeFile( - `${CURRENT_DIR}/deployments/${chainId}-${preset}/meta.json`, - JSON.stringify(meta, null, 2) - ); - - const deployments = await loader.read(ipfs); - - const system = deployments.state['provision.system'].artifacts.imports.system; - - // TODO: extract other contracts as necessary - // See https://github.com/Synthetixio/synthetix-v3/blob/main/utils/docgen/abis.js for details - - await fs.writeFile( - `${CURRENT_DIR}/deployments/${chainId}-${preset}/CoreProxy.json`, - JSON.stringify( - { - address: system.contracts.CoreProxy.address, - abi: new ethers.utils.Interface(system.contracts.CoreProxy.abi).format( - ethers.utils.FormatTypes.full - ), - }, - null, - 2 - ) - ); - - async function mintableToken(provisionStep) { - const fakeCollateral = - deployments?.state?.[`provision.${provisionStep}`]?.artifacts?.imports?.[provisionStep]; - if (fakeCollateral) { - const [, ticker] = fakeCollateral.contracts.MintableToken.constructorArgs; - await fs.writeFile( - `${CURRENT_DIR}/deployments/${chainId}-${preset}/FakeCollateral${ticker}.json`, - JSON.stringify( - { - address: fakeCollateral.contracts.MintableToken.address, - abi: new ethers.utils.Interface(fakeCollateral.contracts.MintableToken.abi).format( - ethers.utils.FormatTypes.full - ), - }, - null, - 2 - ) - ); - } - } - await mintableToken('usdc_mock_collateral'); - await mintableToken('mintableToken'); -} - -async function run() { - const registry = new OnChainRegistry({ - signerOrProvider: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`, - address: DEFAULT_REGISTRY_ADDRESS, - }); - const loader = new IPFSLoader('https://ipfs.synthetix.io'); - - const [chainId, deploymentFile] = process.argv.slice(2); - if (chainId && deploymentFile) { - await fetchDeployment({ registry, loader, chainId, deploymentFile }); - return; - } - - await Promise.all([ - fetchDeployment({ - registry, - loader, - chainId: 1, - deploymentFile: `${ROOT}/omnibus-mainnet.toml`, - }), - fetchDeployment({ - registry, - loader, - chainId: 10, - deploymentFile: `${ROOT}/omnibus-optimism-mainnet.toml`, - }), - fetchDeployment({ - registry, - loader, - chainId: 5, - deploymentFile: `${ROOT}/omnibus-goerli.toml`, - }), - fetchDeployment({ - registry, - loader, - chainId: 420, - deploymentFile: `${ROOT}/omnibus-optimism-goerli.toml`, - }), - fetchDeployment({ - registry, - loader, - chainId: 84531, - deploymentFile: `${ROOT}/omnibus-base-goerli.toml`, - }), - fetchDeployment({ - registry, - loader, - chainId: 84531, - deploymentFile: `${ROOT}/omnibus-base-goerli-competition.toml`, - }), - fetchDeployment({ - registry, - loader, - chainId: 84531, - deploymentFile: `${ROOT}/omnibus-base-goerli-andromeda.toml`, - }), - fetchDeployment({ - registry, - loader, - chainId: 11155111, - deploymentFile: `${ROOT}/omnibus-sepolia.toml`, - }), - fetchDeployment({ - registry, - loader, - chainId: 80001, - deploymentFile: `${ROOT}/omnibus-polygon-mumbai.toml`, - }), - fetchDeployment({ - registry, - loader, - chainId: 421613, - deploymentFile: `${ROOT}/omnibus-arbitrum-goerli.toml`, - }), - ]); -} - -run(); diff --git a/e2e/fetch-local-deployment.js b/e2e/fetch-local-deployment.js new file mode 100755 index 000000000..67e1fe367 --- /dev/null +++ b/e2e/fetch-local-deployment.js @@ -0,0 +1,99 @@ +#!/usr/bin/env node + +const os = require('os'); +const path = require('path'); +const fs = require('fs/promises'); +const { ethers } = require('ethers'); +const { CliLoader } = require('@usecannon/cli/dist/src/loader'); +const CANNON_DIRECTORY = path.join(os.homedir(), '.local', 'share', 'cannon'); + +const fgReset = '\x1b[0m'; +const fgRed = '\x1b[31m'; +const fgGreen = '\x1b[32m'; +const fgYellow = '\x1b[33m'; +const fgCyan = '\x1b[36m'; + +const [buildLog] = process.argv.slice(2); +if (!buildLog) { + console.error(`${fgRed}ERROR: Expected 1 argument${fgReset}`); + console.error(`Usage: ${fgGreen}node e2e/fetch-local-deployment.js ${fgCyan}buildLog${fgReset}`); + console.error( + `Example: ${fgGreen}node e2e/fetch-local-deployment.js ${fgCyan}e2e/cannon-build.log${fgReset}` + ); + process.exit(1); +} + +function readableAbi(abi) { + return new ethers.utils.Interface(abi).format(ethers.utils.FormatTypes.full); +} + +async function run() { + console.log('Resolving Deployment Data URL from log', { buildLog }); + const log = await fs.readFile(buildLog, 'utf8'); + + const [, url] = log.match(/Deployment Data\s*│\s*(ipfs:\/\/Qm\S+)/im) || []; + console.log(`Resolved URL:`, { url }); + + const hash = CliLoader.getCacheHash(url); + console.log(`Resolved FileName hash:`, { hash }); + + const deployments = JSON.parse( + await fs.readFile(`${CANNON_DIRECTORY}/ipfs_cache/${CliLoader.getCacheHash(url)}.json`, 'utf8') + ); + + await fs.mkdir(`${__dirname}/deployments`, { recursive: true }); + + const meta = { + chainId: deployments.chainId, + name: deployments.def.name, + version: deployments.def.version, + generator: deployments.generator, + timestamp: deployments.timestamp, + miscUrl: deployments.miscUrl, + }; + console.log('Generating deployments info for', meta); + + const system = deployments.state['provision.system'].artifacts.imports.system; + console.log('Writing', 'deployments/CoreProxy.json', { + address: system.contracts.CoreProxy.address, + }); + await fs.writeFile( + `${__dirname}/deployments/CoreProxy.json`, + JSON.stringify( + { + ...meta, + address: system.contracts.CoreProxy.address, + abi: readableAbi(system.contracts.CoreProxy.abi), + }, + null, + 2 + ) + ); + + async function mintableToken(provisionStep) { + const fakeCollateral = + deployments?.state?.[`provision.${provisionStep}`]?.artifacts?.imports?.[provisionStep]; + if (fakeCollateral) { + const [, ticker] = fakeCollateral.contracts.MintableToken.constructorArgs; + console.log('Writing', `deployments/FakeCollateral${ticker}.json`, { + address: fakeCollateral.contracts.MintableToken.address, + }); + await fs.writeFile( + `${__dirname}/deployments/FakeCollateral${ticker}.json`, + JSON.stringify( + { + ...meta, + address: fakeCollateral.contracts.MintableToken.address, + abi: readableAbi(fakeCollateral.contracts.MintableToken.abi), + }, + null, + 2 + ) + ); + } + } + await mintableToken('usdc_mock_collateral'); + await mintableToken('mintableToken'); +} + +run(); diff --git a/e2e/tasks/approveCollateral.js b/e2e/tasks/approveCollateral.js index 5042609ad..a7340277d 100644 --- a/e2e/tasks/approveCollateral.js +++ b/e2e/tasks/approveCollateral.js @@ -1,11 +1,10 @@ const { ethers } = require('ethers'); -const { importCoreProxy } = require('./importCoreProxy'); const { getCollateralConfig } = require('./getCollateralConfig'); +const CoreProxy = require('../deployments/CoreProxy.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); async function approveCollateral({ privateKey, symbol }) { - const CoreProxy = await importCoreProxy(); const config = await getCollateralConfig(symbol); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const wallet = new ethers.Wallet(privateKey, provider); diff --git a/e2e/tasks/borrowUsd.js b/e2e/tasks/borrowUsd.js index 2645cb5dd..65f2d6354 100644 --- a/e2e/tasks/borrowUsd.js +++ b/e2e/tasks/borrowUsd.js @@ -1,11 +1,10 @@ const { ethers } = require('ethers'); -const { importCoreProxy } = require('./importCoreProxy'); const { getCollateralConfig } = require('./getCollateralConfig'); +const CoreProxy = require('../deployments/CoreProxy.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); async function borrowUsd({ privateKey, accountId, symbol, amount, poolId }) { - const CoreProxy = await importCoreProxy(); const config = await getCollateralConfig(symbol); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const wallet = new ethers.Wallet(privateKey, provider); diff --git a/e2e/tasks/createAccount.js b/e2e/tasks/createAccount.js index b2a38b7bf..673f9d277 100644 --- a/e2e/tasks/createAccount.js +++ b/e2e/tasks/createAccount.js @@ -1,12 +1,11 @@ const { ethers } = require('ethers'); -const crypto = require('crypto'); -const { importCoreProxy } = require('./importCoreProxy'); +// const crypto = require('crypto'); const { getAccountOwner } = require('./getAccountOwner'); +const CoreProxy = require('../deployments/CoreProxy.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); async function createAccount({ privateKey, accountId }) { - const CoreProxy = await importCoreProxy(); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const wallet = new ethers.Wallet(privateKey, provider); const coreProxy = new ethers.Contract(CoreProxy.address, CoreProxy.abi, wallet); diff --git a/e2e/tasks/delegateCollateral.js b/e2e/tasks/delegateCollateral.js index 2ff6d855e..33e6164ce 100644 --- a/e2e/tasks/delegateCollateral.js +++ b/e2e/tasks/delegateCollateral.js @@ -1,11 +1,10 @@ const { ethers } = require('ethers'); const { getCollateralConfig } = require('./getCollateralConfig'); -const { importCoreProxy } = require('./importCoreProxy'); +const CoreProxy = require('../deployments/CoreProxy.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); async function delegateCollateral({ privateKey, accountId, symbol, amount, poolId }) { - const CoreProxy = await importCoreProxy(); const config = await getCollateralConfig(symbol); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const wallet = new ethers.Wallet(privateKey, provider); diff --git a/e2e/tasks/depositCollateral.js b/e2e/tasks/depositCollateral.js index 415c7c699..dd867e564 100644 --- a/e2e/tasks/depositCollateral.js +++ b/e2e/tasks/depositCollateral.js @@ -1,11 +1,10 @@ const { ethers } = require('ethers'); const { getCollateralConfig } = require('./getCollateralConfig'); -const { importCoreProxy } = require('./importCoreProxy'); +const CoreProxy = require('../deployments/CoreProxy.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); async function depositCollateral({ privateKey, accountId, symbol, amount }) { - const CoreProxy = await importCoreProxy(); const config = await getCollateralConfig(symbol); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const wallet = new ethers.Wallet(privateKey, provider); diff --git a/e2e/tasks/getAccountCollateral.js b/e2e/tasks/getAccountCollateral.js index 09abe9257..75d99126a 100644 --- a/e2e/tasks/getAccountCollateral.js +++ b/e2e/tasks/getAccountCollateral.js @@ -1,9 +1,8 @@ const { ethers } = require('ethers'); const { getCollateralConfig } = require('./getCollateralConfig'); -const { importCoreProxy } = require('./importCoreProxy'); +const CoreProxy = require('../deployments/CoreProxy.json'); async function getAccountCollateral({ accountId, symbol }) { - const CoreProxy = await importCoreProxy(); const config = await getCollateralConfig(symbol); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const coreProxy = new ethers.Contract(CoreProxy.address, CoreProxy.abi, provider); diff --git a/e2e/tasks/getAccountOwner.js b/e2e/tasks/getAccountOwner.js index 972f6edaf..4acd24010 100644 --- a/e2e/tasks/getAccountOwner.js +++ b/e2e/tasks/getAccountOwner.js @@ -1,8 +1,7 @@ const { ethers } = require('ethers'); -const { importCoreProxy } = require('./importCoreProxy'); +const CoreProxy = require('../deployments/CoreProxy.json'); async function getAccountOwner({ accountId }) { - const CoreProxy = await importCoreProxy(); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const coreProxy = new ethers.Contract(CoreProxy.address, CoreProxy.abi, provider); diff --git a/e2e/tasks/getCollateralAllowance.js b/e2e/tasks/getCollateralAllowance.js index 1c384327c..1dac52927 100644 --- a/e2e/tasks/getCollateralAllowance.js +++ b/e2e/tasks/getCollateralAllowance.js @@ -1,9 +1,8 @@ const { ethers } = require('ethers'); const { getCollateralConfig } = require('./getCollateralConfig'); -const { importCoreProxy } = require('./importCoreProxy'); +const CoreProxy = require('../deployments/CoreProxy.json'); async function getCollateralAllowance({ address, symbol }) { - const CoreProxy = await importCoreProxy(); const config = await getCollateralConfig(symbol); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const Token = new ethers.Contract( diff --git a/e2e/tasks/getCollateralConfig.js b/e2e/tasks/getCollateralConfig.js index 07452e22b..d1b4d8800 100644 --- a/e2e/tasks/getCollateralConfig.js +++ b/e2e/tasks/getCollateralConfig.js @@ -1,8 +1,7 @@ const { ethers } = require('ethers'); -const { importCoreProxy } = require('./importCoreProxy'); +const CoreProxy = require('../deployments/CoreProxy.json'); async function getCollateralConfig(symbol) { - const CoreProxy = await importCoreProxy(); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const coreProxy = new ethers.Contract(CoreProxy.address, CoreProxy.abi, provider); diff --git a/e2e/tasks/getConfigUint.js b/e2e/tasks/getConfigUint.js index 33b76cc8a..563d2381b 100644 --- a/e2e/tasks/getConfigUint.js +++ b/e2e/tasks/getConfigUint.js @@ -1,8 +1,7 @@ const { ethers } = require('ethers'); -const { importCoreProxy } = require('./importCoreProxy'); +const CoreProxy = require('../deployments/CoreProxy.json'); async function getConfigUint(key) { - const CoreProxy = await importCoreProxy(); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const coreProxy = new ethers.Contract(CoreProxy.address, CoreProxy.abi, provider); const value = await coreProxy.getConfigUint(ethers.utils.formatBytes32String(key)); diff --git a/e2e/tasks/getFakeCollateralTKNBalance.js b/e2e/tasks/getFakeCollateralTKNBalance.js index 289c46018..b34c3155d 100644 --- a/e2e/tasks/getFakeCollateralTKNBalance.js +++ b/e2e/tasks/getFakeCollateralTKNBalance.js @@ -1,13 +1,11 @@ const { ethers } = require('ethers'); -const { importFakeCollateralTKN } = require('./importFakeCollateralTKN'); +const FakeCollateralTKN = require('../deployments/FakeCollateralTKN.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); async function getFakeCollateralTKNBalance({ address }) { const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); - const FakeCollateralTKN = await importFakeCollateralTKN(); const erc20 = new ethers.Contract(FakeCollateralTKN.address, FakeCollateralTKN.abi, provider); - const balance = parseFloat(ethers.utils.formatUnits(await erc20.balanceOf(address))); return balance; } diff --git a/e2e/tasks/getPreset.js b/e2e/tasks/getPreset.js deleted file mode 100644 index a455195da..000000000 --- a/e2e/tasks/getPreset.js +++ /dev/null @@ -1,17 +0,0 @@ -const path = require('path'); -const fs = require('fs/promises'); -const toml = require('@iarna/toml'); - -const ROOT = path.resolve(`${__dirname}/../..`); -async function getPreset() { - if (!process.env.TEST_TOML) { - return 'main'; - } - const config = await fs.readFile(`${ROOT}/${process.env.TEST_TOML}`, 'utf8'); - const { setting } = toml.parse(config); - return setting?.target_preset?.defaultValue ?? 'main'; -} - -module.exports = { - getPreset, -}; diff --git a/e2e/tasks/importCoreProxy.js b/e2e/tasks/importCoreProxy.js deleted file mode 100644 index f8f9140cc..000000000 --- a/e2e/tasks/importCoreProxy.js +++ /dev/null @@ -1,13 +0,0 @@ -const { ethers } = require('ethers'); -const { getPreset } = require('./getPreset'); - -async function importCoreProxy() { - const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); - const network = await provider.getNetwork(); - const preset = await getPreset(); - return require(`../deployments/${network.chainId}-${preset}/CoreProxy.json`); -} - -module.exports = { - importCoreProxy, -}; diff --git a/e2e/tasks/importFakeCollateralTKN.js b/e2e/tasks/importFakeCollateralTKN.js deleted file mode 100644 index b301d51f7..000000000 --- a/e2e/tasks/importFakeCollateralTKN.js +++ /dev/null @@ -1,13 +0,0 @@ -const { ethers } = require('ethers'); -const { getPreset } = require('./getPreset'); - -async function importFakeCollateralTKN() { - const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); - const network = await provider.getNetwork(); - const preset = await getPreset(); - return require(`../deployments/${network.chainId}-${preset}/FakeCollateralTKN.json`); -} - -module.exports = { - importFakeCollateralTKN, -}; diff --git a/e2e/tasks/importSnx.js b/e2e/tasks/importSnx.js deleted file mode 100644 index 7be36b4d7..000000000 --- a/e2e/tasks/importSnx.js +++ /dev/null @@ -1,13 +0,0 @@ -const ethers = require('ethers'); -const { getPreset } = require('./getPreset'); - -async function importSnx() { - const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); - const network = await provider.getNetwork(); - const preset = await getPreset(); - return require(`../deployments/${network.chainId}-${preset}/snx.json`); -} - -module.exports = { - importSnx, -}; diff --git a/e2e/tasks/index.js b/e2e/tasks/index.js deleted file mode 100644 index 5f5ba7455..000000000 --- a/e2e/tasks/index.js +++ /dev/null @@ -1,26 +0,0 @@ -module.exports = { - ...require('./approveCollateral'), - ...require('./borrowUsd'), - ...require('./createAccount'), - ...require('./delegateCollateral'), - ...require('./depositCollateral'), - ...require('./getAccountCollateral'), - ...require('./getAccountOwner'), - ...require('./getCollateralAllowance'), - ...require('./getCollateralBalance'), - ...require('./getCollateralConfig'), - ...require('./getConfigUint'), - ...require('./getEthBalance'), - ...require('./getFakeCollateralTKNBalance'), - ...require('./getPreset'), - ...require('./importCoreProxy'), - ...require('./importFakeCollateralTKN'), - ...require('./importSnx'), - ...require('./index'), - ...require('./setConfigUint'), - ...require('./setEthBalance'), - ...require('./setFakeCollateralTKNBalance'), - ...require('./setSnxBalance'), - ...require('./withdrawCollateral'), - ...require('./wrapEth'), -}; diff --git a/e2e/tasks/setConfigUint.js b/e2e/tasks/setConfigUint.js index cc938bf68..2b34664c6 100644 --- a/e2e/tasks/setConfigUint.js +++ b/e2e/tasks/setConfigUint.js @@ -1,13 +1,12 @@ const { ethers } = require('ethers'); -const { importCoreProxy } = require('./importCoreProxy'); const { setEthBalance } = require('./setEthBalance'); const { getConfigUint } = require('./getConfigUint'); const { hexlify, hexZeroPad } = require('@ethersproject/bytes'); +const CoreProxy = require('../deployments/CoreProxy.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); async function setConfigUint({ key, value }) { - const CoreProxy = await importCoreProxy(); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const coreProxy = new ethers.Contract(CoreProxy.address, CoreProxy.abi, provider); const owner = await coreProxy.owner(); diff --git a/e2e/tasks/setFakeCollateralTKNBalance.js b/e2e/tasks/setFakeCollateralTKNBalance.js index ab48261a1..414d500ff 100644 --- a/e2e/tasks/setFakeCollateralTKNBalance.js +++ b/e2e/tasks/setFakeCollateralTKNBalance.js @@ -1,7 +1,5 @@ const { ethers } = require('ethers'); -const { getCollateralConfig } = require('./getCollateralConfig'); -const { setEthBalance } = require('./setEthBalance'); -const { importFakeCollateralTKN } = require('./importFakeCollateralTKN'); +const FakeCollateralTKN = require('../deployments/FakeCollateralTKN.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); @@ -9,7 +7,6 @@ async function setFakeCollateralTKNBalance({ privateKey, balance }) { const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const wallet = new ethers.Wallet(privateKey, provider); - const FakeCollateralTKN = await importFakeCollateralTKN(); const erc20 = new ethers.Contract(FakeCollateralTKN.address, FakeCollateralTKN.abi, wallet); const oldBalance = parseFloat(ethers.utils.formatUnits(await erc20.balanceOf(wallet.address))); diff --git a/e2e/tasks/withdrawCollateral.js b/e2e/tasks/withdrawCollateral.js index b4ed360b5..cdfb42a2a 100644 --- a/e2e/tasks/withdrawCollateral.js +++ b/e2e/tasks/withdrawCollateral.js @@ -1,11 +1,10 @@ const { ethers } = require('ethers'); const { getCollateralConfig } = require('./getCollateralConfig'); -const { importCoreProxy } = require('./importCoreProxy'); +const CoreProxy = require('../deployments/CoreProxy.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); async function withdrawCollateral({ privateKey, accountId, symbol, amount }) { - const CoreProxy = await importCoreProxy(); const config = await getCollateralConfig(symbol); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const wallet = new ethers.Wallet(privateKey, provider); diff --git a/e2e/tasks/wrapEth.js b/e2e/tasks/wrapEth.js index b7806b4f8..e3510a5b4 100644 --- a/e2e/tasks/wrapEth.js +++ b/e2e/tasks/wrapEth.js @@ -1,5 +1,5 @@ const { ethers } = require('ethers'); -const { importCoreProxy } = require('./importCoreProxy'); +const CoreProxy = require('../deployments/CoreProxy.json'); const log = require('debug')(`tasks:${require('path').basename(__filename, '.js')}`); @@ -10,7 +10,6 @@ const erc20Abi = [ ]; async function wrapEth({ privateKey, amount }) { - const CoreProxy = await importCoreProxy(); const provider = new ethers.providers.JsonRpcProvider('http://127.0.0.1:8545'); const wallet = new ethers.Wallet(privateKey, provider); diff --git a/e2e/tests/Staking.js b/e2e/tests/Staking.js index 4db179962..e606f6211 100644 --- a/e2e/tests/Staking.js +++ b/e2e/tests/Staking.js @@ -1,22 +1,20 @@ const assert = require('assert'); const { ethers } = require('ethers'); const crypto = require('crypto'); -const { - approveCollateral, - createAccount, - delegateCollateral, - depositCollateral, - getAccountCollateral, - getAccountOwner, - getCollateralAllowance, - getCollateralBalance, - getConfigUint, - getEthBalance, - setConfigUint, - setEthBalance, - setSnxBalance, - withdrawCollateral, -} = require('../tasks'); +const { approveCollateral } = require('../tasks/approveCollateral'); +const { createAccount } = require('../tasks/createAccount'); +const { delegateCollateral } = require('../tasks/delegateCollateral'); +const { depositCollateral } = require('../tasks/depositCollateral'); +const { getAccountCollateral } = require('../tasks/getAccountCollateral'); +const { getAccountOwner } = require('../tasks/getAccountOwner'); +const { getCollateralAllowance } = require('../tasks/getCollateralAllowance'); +const { getCollateralBalance } = require('../tasks/getCollateralBalance'); +const { getConfigUint } = require('../tasks/getConfigUint'); +const { getEthBalance } = require('../tasks/getEthBalance'); +const { setConfigUint } = require('../tasks/setConfigUint'); +const { setEthBalance } = require('../tasks/setEthBalance'); +const { setSnxBalance } = require('../tasks/setSnxBalance'); +const { withdrawCollateral } = require('../tasks/withdrawCollateral'); exports.run = function () { let address; diff --git a/e2e/tests/omnibus-base-goerli-andromeda.toml/Collateral Limits.e2e.js b/e2e/tests/omnibus-base-goerli-andromeda.toml/Collateral Limits.e2e.js index af9476814..8e8a94c06 100644 --- a/e2e/tests/omnibus-base-goerli-andromeda.toml/Collateral Limits.e2e.js +++ b/e2e/tests/omnibus-base-goerli-andromeda.toml/Collateral Limits.e2e.js @@ -1,13 +1,11 @@ const assert = require('assert'); const { ethers } = require('ethers'); -const { - getFakeCollateralTKNBalance, - getEthBalance, - setEthBalance, - setFakeCollateralTKNBalance, -} = require('../../tasks'); +const { getFakeCollateralTKNBalance } = require('../../tasks/getFakeCollateralTKNBalance'); +const { getEthBalance } = require('../../tasks/getEthBalance'); +const { setEthBalance } = require('../../tasks/setEthBalance'); +const { setFakeCollateralTKNBalance } = require('../../tasks/setFakeCollateralTKNBalance'); -describe('base-goerli-andromeda: Collateral Limits', function () { +describe('Collateral Limits', function () { let address; let privateKey; diff --git a/e2e/tests/omnibus-goerli.toml/Staking.e2e.js b/e2e/tests/omnibus-goerli.toml/Staking.e2e.js index a0caa12f7..75695f67c 100644 --- a/e2e/tests/omnibus-goerli.toml/Staking.e2e.js +++ b/e2e/tests/omnibus-goerli.toml/Staking.e2e.js @@ -1,5 +1,5 @@ const { run } = require('../Staking'); -describe('goerli: Staking', function () { +describe('Staking', function () { run(); }); diff --git a/e2e/tests/omnibus-mainnet.toml/Staking.e2e.js b/e2e/tests/omnibus-mainnet.toml/Staking.e2e.js index 9382b2ab4..75695f67c 100644 --- a/e2e/tests/omnibus-mainnet.toml/Staking.e2e.js +++ b/e2e/tests/omnibus-mainnet.toml/Staking.e2e.js @@ -1,5 +1,5 @@ const { run } = require('../Staking'); -describe('mainnet: Staking', function () { +describe('Staking', function () { run(); }); diff --git a/e2e/tests/omnibus-optimism-goerli.toml/Staking.e2e.js b/e2e/tests/omnibus-optimism-goerli.toml/Staking.e2e.js index c623faed6..75695f67c 100644 --- a/e2e/tests/omnibus-optimism-goerli.toml/Staking.e2e.js +++ b/e2e/tests/omnibus-optimism-goerli.toml/Staking.e2e.js @@ -1,5 +1,5 @@ const { run } = require('../Staking'); -describe('optimism-goerli: Staking', function () { +describe('Staking', function () { run(); }); diff --git a/e2e/tests/omnibus-optimism-mainnet.toml/Staking.e2e.js b/e2e/tests/omnibus-optimism-mainnet.toml/Staking.e2e.js index fd30b86f9..75695f67c 100644 --- a/e2e/tests/omnibus-optimism-mainnet.toml/Staking.e2e.js +++ b/e2e/tests/omnibus-optimism-mainnet.toml/Staking.e2e.js @@ -1,5 +1,5 @@ const { run } = require('../Staking'); -describe('optimism-mainnet: Staking', function () { +describe('Staking', function () { run(); }); diff --git a/e2e/tests/omnibus-polygon-mumbai.toml/Stub.e2e.js b/e2e/tests/omnibus-polygon-mumbai.toml/Stub.e2e.js new file mode 100644 index 000000000..3d6b34d2e --- /dev/null +++ b/e2e/tests/omnibus-polygon-mumbai.toml/Stub.e2e.js @@ -0,0 +1,22 @@ +const assert = require('assert'); +const { ethers } = require('ethers'); +const { getEthBalance } = require('../../tasks/getEthBalance'); +const { setEthBalance } = require('../../tasks/setEthBalance'); + +describe('Stub', function () { + let address; + let privateKey; + + it('should create new random wallet', async () => { + const wallet = ethers.Wallet.createRandom(); + address = wallet.address; + privateKey = wallet.privateKey; + assert.ok(address); + }); + + it('should set ETH balance to 100', async () => { + assert.equal(await getEthBalance({ address }), 0, 'New wallet has 0 ETH balance'); + await setEthBalance({ address, balance: 100 }); + assert.equal(await getEthBalance({ address }), 100); + }); +}); diff --git a/e2e/tests/omnibus-sepolia.toml/Stub.e2e.js b/e2e/tests/omnibus-sepolia.toml/Stub.e2e.js new file mode 100644 index 000000000..3d6b34d2e --- /dev/null +++ b/e2e/tests/omnibus-sepolia.toml/Stub.e2e.js @@ -0,0 +1,22 @@ +const assert = require('assert'); +const { ethers } = require('ethers'); +const { getEthBalance } = require('../../tasks/getEthBalance'); +const { setEthBalance } = require('../../tasks/setEthBalance'); + +describe('Stub', function () { + let address; + let privateKey; + + it('should create new random wallet', async () => { + const wallet = ethers.Wallet.createRandom(); + address = wallet.address; + privateKey = wallet.privateKey; + assert.ok(address); + }); + + it('should set ETH balance to 100', async () => { + assert.equal(await getEthBalance({ address }), 0, 'New wallet has 0 ETH balance'); + await setEthBalance({ address, balance: 100 }); + assert.equal(await getEthBalance({ address }), 100); + }); +}); diff --git a/omnibus-base-goerli-andromeda.toml b/omnibus-base-goerli-andromeda.toml index dc3457965..b9a1479af 100644 --- a/omnibus-base-goerli-andromeda.toml +++ b/omnibus-base-goerli-andromeda.toml @@ -65,7 +65,7 @@ defaultValue = "0x9172995177A9A10FE1b7Df76E2A3266c0cFc71c7" defaultValue = "0x9172995177A9A10FE1b7Df76E2A3266c0cFc71c7" [setting.minimum_liquidity_ratio] -defaultValue = "1250000000000000000" # 125% min market collateralization +defaultValue = "<%= parseEther('1.25') %>" # 125% min market collateralization [setting.account_timeout_withdraw] defaultValue = "86400" # 1 day