Feat: 🛠️ fix protocol release action (#652)
* 🔧 fix and clean up foundry tests
* fix foundry tests import paths
This commit is contained in:
parent
f87f5a40c0
commit
3a7a5d22a2
@ -1,372 +0,0 @@
|
|||||||
version: 2.1
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
cache_version:
|
|
||||||
type: string
|
|
||||||
default: v5
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
environment:
|
|
||||||
NODE_OPTIONS: '--max-old-space-size=16384'
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run: git submodule update --init --recursive
|
|
||||||
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-feat/NerveMixinArbitrum
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run:
|
|
||||||
name: install-yarn
|
|
||||||
command: npm install --force --global yarn@1.22.0
|
|
||||||
- run:
|
|
||||||
name: yarn
|
|
||||||
command: yarn --frozen-lockfile --ignore-engines install || yarn --frozen-lockfile --ignore-engines install
|
|
||||||
- setup_remote_docker
|
|
||||||
- run: yarn build:ci
|
|
||||||
- save_cache:
|
|
||||||
key: cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
paths:
|
|
||||||
- ~/project/node_modules
|
|
||||||
- ~/.cache/yarn
|
|
||||||
- save_cache:
|
|
||||||
key: lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
paths:
|
|
||||||
- ~/project/contracts/erc20/generated-artifacts/
|
|
||||||
- ~/project/contracts/erc20/generated-wrappers/
|
|
||||||
- ~/project/contracts/erc20/lib/
|
|
||||||
- ~/project/contracts/erc20/node_modules
|
|
||||||
- ~/project/contracts/erc20/test/generated-artifacts/
|
|
||||||
- ~/project/contracts/erc20/test/generated-wrappers/
|
|
||||||
- ~/project/contracts/test-utils/lib/
|
|
||||||
- ~/project/contracts/test-utils/node_modules
|
|
||||||
- ~/project/contracts/treasury/generated-artifacts/
|
|
||||||
- ~/project/contracts/treasury/generated-wrappers/
|
|
||||||
- ~/project/contracts/treasury/lib/
|
|
||||||
- ~/project/contracts/treasury/node_modules
|
|
||||||
- ~/project/contracts/treasury/test/generated-artifacts/
|
|
||||||
- ~/project/contracts/treasury/test/generated-wrappers/
|
|
||||||
- ~/project/contracts/utils/generated-artifacts/
|
|
||||||
- ~/project/contracts/utils/generated-wrappers/
|
|
||||||
- ~/project/contracts/utils/lib/
|
|
||||||
- ~/project/contracts/utils/node_modules
|
|
||||||
- ~/project/contracts/utils/test/generated-artifacts/
|
|
||||||
- ~/project/contracts/utils/test/generated-wrappers/
|
|
||||||
- ~/project/contracts/zero-ex/generated-artifacts/
|
|
||||||
- ~/project/contracts/zero-ex/generated-wrappers/
|
|
||||||
- ~/project/contracts/zero-ex/lib/
|
|
||||||
- ~/project/contracts/zero-ex/node_modules
|
|
||||||
- ~/project/contracts/zero-ex/test/generated-artifacts/
|
|
||||||
- ~/project/contracts/zero-ex/test/generated-wrappers/
|
|
||||||
- ~/project/packages/asset-swapper/node_modules
|
|
||||||
- ~/project/packages/contract-addresses/lib/
|
|
||||||
- ~/project/packages/contract-addresses/node_modules
|
|
||||||
- ~/project/packages/contract-artifacts/lib/
|
|
||||||
- ~/project/packages/contract-artifacts/node_modules
|
|
||||||
- ~/project/packages/contract-wrappers/lib/
|
|
||||||
- ~/project/packages/contract-wrappers/node_modules
|
|
||||||
- ~/project/packages/protocol-utils/lib/
|
|
||||||
- ~/project/packages/protocol-utils/node_modules
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/packages/abi-gen/test-cli/output
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/repo/packages/contract-wrappers/generated_docs
|
|
||||||
test-exchange-ganache:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run: yarn wsrun -p @0x/contracts-exchange -m --serial -c test:circleci
|
|
||||||
test-integrations-ganache:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run: yarn wsrun -p @0x/contracts-integrations -m --serial -c test:circleci
|
|
||||||
test-contracts-staking-ganache:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run: yarn wsrun -p @0x/contracts-staking -m --serial -c test:circleci
|
|
||||||
test-contracts-extra-ganache:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run: yarn wsrun -p @0x/contracts-exchange-forwarder -p @0x/contracts-coordinator -m --serial -c test:circleci
|
|
||||||
test-contracts-rest-ganache:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run: |
|
|
||||||
git diff --name-only development >> changed.txt
|
|
||||||
if ! grep -q \.sol changed.txt; then
|
|
||||||
circleci-agent step halt
|
|
||||||
fi
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run: |
|
|
||||||
yarn wsrun \
|
|
||||||
-p @0x/contracts-multisig \
|
|
||||||
-p @0x/contracts-utils \
|
|
||||||
-p @0x/contracts-exchange-libs \
|
|
||||||
-p @0x/contracts-erc20 \
|
|
||||||
-p @0x/contracts-erc721 \
|
|
||||||
-p @0x/contracts-erc1155 \
|
|
||||||
-p @0x/contracts-asset-proxy \
|
|
||||||
-p @0x/contracts-broker \
|
|
||||||
-p @0x/contracts-zero-ex \
|
|
||||||
-m --serial -c test:circleci
|
|
||||||
test-foundry-local:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
# Using nightly as foundry:latest is ~2 months old
|
|
||||||
# which seems to cause an issue with latest forge-std
|
|
||||||
# https://github.com/foundry-rs/forge-std/issues/230
|
|
||||||
- image: ghcr.io/foundry-rs/foundry:nightly
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run: |
|
|
||||||
git diff --name-only development >> changed.txt
|
|
||||||
cat changed.txt
|
|
||||||
if ! grep -q \.sol changed.txt; then
|
|
||||||
circleci-agent step halt
|
|
||||||
fi
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- run:
|
|
||||||
command: git submodule update --init --recursive
|
|
||||||
- run:
|
|
||||||
command: FOUNDRY_PROFILE=local && forge test
|
|
||||||
working_directory: ~/project/contracts/zero-ex
|
|
||||||
test-foundry-forked:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
# Using nightly as foundry:latest is ~2 months old
|
|
||||||
# which seems to cause an issue with latest forge-std
|
|
||||||
# https://github.com/foundry-rs/forge-std/issues/230
|
|
||||||
- image: ghcr.io/foundry-rs/foundry:nightly
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run: |
|
|
||||||
git diff --name-only development >> changed.txt
|
|
||||||
cat changed.txt
|
|
||||||
if ! grep -q \.sol changed.txt; then
|
|
||||||
circleci-agent step halt
|
|
||||||
fi
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
|
||||||
- run:
|
|
||||||
command: git submodule update --init --recursive
|
|
||||||
- run:
|
|
||||||
command: FOUNDRY_PROFILE=forked && forge test
|
|
||||||
working_directory: ~/project/contracts/zero-ex
|
|
||||||
test-publish:
|
|
||||||
resource_class: large
|
|
||||||
environment:
|
|
||||||
NODE_OPTIONS: '--max-old-space-size=6442'
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
- image: 0xorg/verdaccio
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run: |
|
|
||||||
git diff --name-only development >> changed.txt
|
|
||||||
cat changed.txt
|
|
||||||
if ! grep -q packages/ changed.txt; then
|
|
||||||
circleci-agent step halt
|
|
||||||
fi
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run:
|
|
||||||
command: yarn test:publish:circleci
|
|
||||||
no_output_timeout: 1800
|
|
||||||
- store_artifacts:
|
|
||||||
path: ~/.npm/_logs
|
|
||||||
test-doc-generation:
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run:
|
|
||||||
command: yarn test:generate_docs:circleci
|
|
||||||
no_output_timeout: 1200
|
|
||||||
test-rest:
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
environment:
|
|
||||||
RUST_ROUTER: 'true'
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run: yarn wsrun -p @0x/contracts-test-utils -m --serial -c test:circleci
|
|
||||||
- run: yarn wsrun -p @0x/contract-addresses -m --serial -c test:circleci
|
|
||||||
- run: yarn wsrun -p @0x/contract-artifacts -m --serial -c test:circleci
|
|
||||||
- run: yarn wsrun -p @0x/contract-wrappers-test -m --serial -c test:circleci
|
|
||||||
- run: yarn wsrun -p @0x/order-utils -m --serial -c test:circleci
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-contract-wrappers-test-{{ checksum "yarn.lock" }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/contract-wrappers-test/coverage/lcov.info
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-order-utils-{{ checksum "yarn.lock" }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/order-utils/coverage/lcov.info
|
|
||||||
- save_cache:
|
|
||||||
key: coverage-web3-wrapper-{{ checksum "yarn.lock" }}
|
|
||||||
paths:
|
|
||||||
- ~/repo/packages/web3-wrapper/coverage/lcov.info
|
|
||||||
static-tests:
|
|
||||||
resource_class: large
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- run:
|
|
||||||
command: yarn lerna run lint
|
|
||||||
- run:
|
|
||||||
command: yarn prettier:ci
|
|
||||||
- run:
|
|
||||||
command: yarn deps_versions:ci
|
|
||||||
- run:
|
|
||||||
command: yarn diff_md_docs:ci
|
|
||||||
- run:
|
|
||||||
command: yarn test:links
|
|
||||||
submit-coverage:
|
|
||||||
docker:
|
|
||||||
- image: node:16
|
|
||||||
steps:
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- cache-{{ checksum "yarn.lock" }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- lib-{{ .Environment.CIRCLE_SHA1 }}-<< pipeline.parameters.cache_version >>
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-contract-wrappers-test-{{ checksum "yarn.lock" }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-order-utils-{{ checksum "yarn.lock" }}
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- coverage-contracts-{{ checksum "yarn.lock" }}
|
|
||||||
- run: yarn report_coverage
|
|
||||||
workflows:
|
|
||||||
version: 2
|
|
||||||
main:
|
|
||||||
jobs:
|
|
||||||
- build
|
|
||||||
# Disabled until we begin actively developing on these packages again.
|
|
||||||
# - test-exchange-ganache:
|
|
||||||
# requires:
|
|
||||||
# - build
|
|
||||||
# - test-integrations-ganache:
|
|
||||||
# requires:
|
|
||||||
# - build
|
|
||||||
# - test-contracts-staking-ganache:
|
|
||||||
# requires:
|
|
||||||
# - build
|
|
||||||
# - test-contracts-extra-ganache:
|
|
||||||
# requires:
|
|
||||||
# - build
|
|
||||||
- test-foundry-local:
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
- test-foundry-forked:
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
- test-contracts-rest-ganache:
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
- test-rest:
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
- static-tests:
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
- test-publish:
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
- test-doc-generation:
|
|
||||||
requires:
|
|
||||||
- build
|
|
||||||
# Disabled until this repo has a coveralls API key
|
|
||||||
# - submit-coverage:
|
|
||||||
# requires:
|
|
||||||
# # Disabled until we begin actively developing on these packages again.
|
|
||||||
# # - test-exchange-ganache
|
|
||||||
# # - test-integrations-ganache
|
|
||||||
# # - test-contracts-staking-ganache
|
|
||||||
# # - test-contracts-extra-ganache
|
|
||||||
# - test-contracts-rest-ganache
|
|
||||||
# - test-rest
|
|
||||||
# - static-tests
|
|
@ -1,92 +1,6 @@
|
|||||||
lib
|
lib
|
||||||
deps
|
deps
|
||||||
.nyc_output
|
.nyc_output
|
||||||
/contracts/broker/generated-wrappers
|
|
||||||
/contracts/broker/test/generated-wrappers
|
|
||||||
/contracts/broker/generated-artifacts
|
|
||||||
/contracts/broker/test/generated-artifacts
|
|
||||||
/contracts/integrations/generated-wrappers
|
|
||||||
/contracts/integrations/test/generated-wrappers
|
|
||||||
/contracts/integrations/generated-artifacts
|
|
||||||
/contracts/integrations/test/generated-artifacts
|
|
||||||
/contracts/staking/generated-wrappers
|
|
||||||
/contracts/staking/test/generated-wrappers
|
|
||||||
/contracts/staking/generated-artifacts
|
|
||||||
/contracts/staking/test/generated-artifacts
|
|
||||||
/contracts/coordinator/generated-wrappers
|
|
||||||
/contracts/coordinator/test/generated-wrappers
|
|
||||||
/contracts/coordinator/generated-artifacts
|
|
||||||
/contracts/coordinator/test/generated-artifacts
|
|
||||||
/contracts/exchange/generated-wrappers
|
|
||||||
/contracts/exchange/test/generated-wrappers
|
|
||||||
/contracts/exchange/generated-artifacts
|
|
||||||
/contracts/exchange/test/generated-artifacts
|
|
||||||
/contracts/asset-proxy/generated-wrappers
|
|
||||||
/contracts/asset-proxy/test/generated-wrappers
|
|
||||||
/contracts/asset-proxy/generated-artifacts
|
|
||||||
/contracts/asset-proxy/test/generated-artifacts
|
|
||||||
/contracts/multisig/generated-wrappers
|
|
||||||
/contracts/multisig/test/generated-wrappers
|
|
||||||
/contracts/multisig/generated-artifacts
|
|
||||||
/contracts/multisig/test/generated-artifacts
|
|
||||||
/contracts/utils/generated-wrappers
|
|
||||||
/contracts/utils/test/generated-wrappers
|
|
||||||
/contracts/utils/generated-artifacts
|
|
||||||
/contracts/utils/test/generated-artifacts
|
|
||||||
/contracts/exchange-libs/generated-wrappers
|
|
||||||
/contracts/exchange-libs/test/generated-wrappers
|
|
||||||
/contracts/exchange-libs/generated-artifacts
|
|
||||||
/contracts/exchange-libs/test/generated-artifacts
|
|
||||||
/contracts/erc20/generated-wrappers
|
|
||||||
/contracts/erc20/test/generated-wrappers
|
|
||||||
/contracts/erc20/generated-artifacts
|
|
||||||
/contracts/erc20/test/generated-artifacts
|
|
||||||
/contracts/erc721/generated-wrappers
|
|
||||||
/contracts/erc721/test/generated-wrappers
|
|
||||||
/contracts/erc721/generated-artifacts
|
|
||||||
/contracts/erc721/test/generated-artifacts
|
|
||||||
/contracts/erc1155/generated-wrappers
|
|
||||||
/contracts/erc1155/test/generated-wrappers
|
|
||||||
/contracts/erc1155/generated-artifacts
|
|
||||||
/contracts/erc1155/test/generated-artifacts
|
|
||||||
/contracts/extensions/generated-wrappers
|
|
||||||
/contracts/extensions/test/generated-wrappers
|
|
||||||
/contracts/extensions/generated-artifacts
|
|
||||||
/contracts/extensions/test/generated-artifacts
|
|
||||||
/contracts/exchange-forwarder/generated-wrappers
|
|
||||||
/contracts/exchange-forwarder/test/generated-wrappers
|
|
||||||
/contracts/exchange-forwarder/generated-artifacts
|
|
||||||
/contracts/exchange-forwarder/test/generated-artifacts
|
|
||||||
/contracts/dev-utils/generated-wrappers
|
|
||||||
/contracts/dev-utils/test/generated-wrappers
|
|
||||||
/contracts/dev-utils/generated-artifacts
|
|
||||||
/contracts/dev-utils/test/generated-artifacts
|
|
||||||
/contracts/zero-ex/foundry-artifacts
|
|
||||||
/contracts/zero-ex/generated-wrappers
|
|
||||||
/contracts/zero-ex/test/generated-wrappers
|
|
||||||
/contracts/zero-ex/generated-artifacts
|
|
||||||
/contracts/zero-ex/test/generated-artifacts
|
|
||||||
/contracts/treasury/generated-wrappers
|
|
||||||
/contracts/treasury/test/generated-wrappers
|
|
||||||
/contracts/treasury/generated-artifacts
|
|
||||||
/contracts/treasury/test/generated-artifacts
|
|
||||||
/contracts/staking/build/
|
|
||||||
/contracts/coordinator/build/
|
|
||||||
/contracts/exchange/build/
|
|
||||||
/contracts/asset-proxy/build/
|
|
||||||
/contracts/multisig/build/
|
|
||||||
/contracts/utils/build/
|
|
||||||
/contracts/exchange-libs/build/
|
|
||||||
/contracts/erc20/build/
|
|
||||||
/contracts/erc721/build/
|
|
||||||
/contracts/erc1155/build/
|
|
||||||
/contracts/zero-ex/foundry-artifacts
|
|
||||||
/contracts/zero-ex/foundry-cache
|
|
||||||
/contracts/zero-ex/contracts/deps
|
|
||||||
/contracts/extensions/build/
|
|
||||||
/contracts/exchange-forwarder/build/
|
|
||||||
/packages/asset-swapper/
|
|
||||||
/packages/contract-wrappers/src/generated-wrappers/
|
|
||||||
generated-artifacts/
|
generated-artifacts/
|
||||||
generated-wrappers/
|
generated-wrappers/
|
||||||
foundry-artifacts/
|
foundry-artifacts/
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
pragma solidity ^0.6.5;
|
pragma solidity ^0.6.5;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "./BaseTest.sol";
|
import "utils/BaseTest.sol";
|
||||||
import "../contracts/src/external/FlashWallet.sol";
|
import "../contracts/src/external/FlashWallet.sol";
|
||||||
import "./mocks/TestCallTarget.sol";
|
import "./mocks/TestCallTarget.sol";
|
||||||
|
|
||||||
|
@ -35,14 +35,11 @@ import "src/transformers/bridges/CeloBridgeAdapter.sol";
|
|||||||
import "src/features/OtcOrdersFeature.sol";
|
import "src/features/OtcOrdersFeature.sol";
|
||||||
|
|
||||||
contract ForkUtilsTest is Test, ForkUtils, TestUtils {
|
contract ForkUtilsTest is Test, ForkUtils, TestUtils {
|
||||||
/*//////////////////////////////////////////////////////////////
|
|
||||||
Rpc Setup
|
|
||||||
//////////////////////////////////////////////////////////////*/
|
|
||||||
function setUp() public {
|
function setUp() public {
|
||||||
_setup();
|
_setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_transformERC20Forked() public {}
|
function test_addressesExist() public {}
|
||||||
|
|
||||||
function logAddresses(string memory chainName, string memory chainId) public {
|
function logAddresses(string memory chainName, string memory chainId) public {
|
||||||
bytes memory details = json.parseRaw(chainId);
|
bytes memory details = json.parseRaw(chainId);
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
pragma solidity ^0.6;
|
pragma solidity ^0.6;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "./utils/ForkUtils.sol";
|
import "utils/ForkUtils.sol";
|
||||||
import "./utils/TestUtils.sol";
|
import "utils/TestUtils.sol";
|
||||||
import "./utils/DeployZeroEx.sol";
|
import "utils/DeployZeroEx.sol";
|
||||||
import "forge-std/Test.sol";
|
import "forge-std/Test.sol";
|
||||||
import "src/IZeroEx.sol";
|
import "src/IZeroEx.sol";
|
||||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
pragma solidity ^0.6.5;
|
pragma solidity ^0.6.5;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "./BaseTest.sol";
|
import "utils/BaseTest.sol";
|
||||||
import "../contracts/src/ZeroEx.sol";
|
import "../contracts/src/ZeroEx.sol";
|
||||||
import "./mocks/TestZeroExFeature.sol";
|
import "./mocks/TestZeroExFeature.sol";
|
||||||
|
|
||||||
|
@ -65,10 +65,6 @@ contract RfqtV2Test is Test, ForkUtils, TestUtils {
|
|||||||
// Create our list of transformations, let's do WethTransformer and FillQuoteTransformer
|
// Create our list of transformations, let's do WethTransformer and FillQuoteTransformer
|
||||||
ITransformERC20Feature.Transformation[] memory transformations = new ITransformERC20Feature.Transformation[](2);
|
ITransformERC20Feature.Transformation[] memory transformations = new ITransformERC20Feature.Transformation[](2);
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////
|
|
||||||
WethTransformer
|
|
||||||
//////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
// Use our cheeky search helper to find the nonce rather than hardcode it
|
// Use our cheeky search helper to find the nonce rather than hardcode it
|
||||||
transformations[0].deploymentNonce = _findTransformerNonce(
|
transformations[0].deploymentNonce = _findTransformerNonce(
|
||||||
address(addresses.transformers.wethTransformer),
|
address(addresses.transformers.wethTransformer),
|
||||||
@ -79,10 +75,6 @@ contract RfqtV2Test is Test, ForkUtils, TestUtils {
|
|||||||
// Set the first transformation to transform ETH into WETH
|
// Set the first transformation to transform ETH into WETH
|
||||||
transformations[0].data = abi.encode(LibERC20Transformer.ETH_TOKEN_ADDRESS, 1e18);
|
transformations[0].data = abi.encode(LibERC20Transformer.ETH_TOKEN_ADDRESS, 1e18);
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////
|
|
||||||
FillQuoteTransformer
|
|
||||||
//////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
transformations[1].deploymentNonce = _findTransformerNonce(
|
transformations[1].deploymentNonce = _findTransformerNonce(
|
||||||
address(fillQuoteTransformer),
|
address(fillQuoteTransformer),
|
||||||
address(addresses.exchangeProxyTransformerDeployer)
|
address(addresses.exchangeProxyTransformerDeployer)
|
||||||
|
@ -166,15 +166,12 @@ contract SwapEthForERC20Test is Test, ForkUtils, TestUtils {
|
|||||||
);
|
);
|
||||||
assert(IERC20TokenV06(tokens.USDT).balanceOf(address(this)) > 0);
|
assert(IERC20TokenV06(tokens.USDT).balanceOf(address(this)) > 0);
|
||||||
} else {
|
} else {
|
||||||
emit log_string("Liquidity Source Not available on this chain");
|
emit log_string("Liquidity Source not available on this chain");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* solhint-enable function-max-lines */
|
/* solhint-enable function-max-lines */
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////
|
|
||||||
Sampler Dispatch
|
|
||||||
//////////////////////////////////////////////////////////////*/
|
|
||||||
// get a real quote from uniswap
|
// get a real quote from uniswap
|
||||||
function sampleLiquiditySource(
|
function sampleLiquiditySource(
|
||||||
uint256 amount,
|
uint256 amount,
|
||||||
|
@ -13,11 +13,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pragma solidity ^0.6;
|
pragma solidity ^0.6;
|
||||||
|
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "../utils/ForkUtils.sol";
|
import "../utils/ForkUtils.sol";
|
||||||
import "../utils/TestUtils.sol";
|
import "../utils/TestUtils.sol";
|
||||||
|
import "../utils/DeployZeroEx.sol";
|
||||||
|
import "forge-std/Test.sol";
|
||||||
import "src/IZeroEx.sol";
|
import "src/IZeroEx.sol";
|
||||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||||
import "src/features/TransformERC20Feature.sol";
|
import "src/features/TransformERC20Feature.sol";
|
||||||
@ -26,72 +27,43 @@ import "src/transformers/WethTransformer.sol";
|
|||||||
import "src/transformers/FillQuoteTransformer.sol";
|
import "src/transformers/FillQuoteTransformer.sol";
|
||||||
import "src/transformers/bridges/BridgeProtocols.sol";
|
import "src/transformers/bridges/BridgeProtocols.sol";
|
||||||
import "src/transformers/bridges/EthereumBridgeAdapter.sol";
|
import "src/transformers/bridges/EthereumBridgeAdapter.sol";
|
||||||
import "src/transformers/bridges/PolygonBridgeAdapter.sol";
|
import "src/IZeroEx.sol";
|
||||||
import "src/transformers/bridges/ArbitrumBridgeAdapter.sol";
|
|
||||||
import "src/transformers/bridges/OptimismBridgeAdapter.sol";
|
contract WrapEth is Test, ForkUtils, TestUtils {
|
||||||
import "src/transformers/bridges/AvalancheBridgeAdapter.sol";
|
DeployZeroEx.ZeroExDeployed zeroExDeployed;
|
||||||
import "src/transformers/bridges/FantomBridgeAdapter.sol";
|
|
||||||
import "src/transformers/bridges/CeloBridgeAdapter.sol";
|
|
||||||
import "src/features/OtcOrdersFeature.sol";
|
|
||||||
|
|
||||||
contract WrapEthTest is Test, ForkUtils, TestUtils {
|
|
||||||
/*//////////////////////////////////////////////////////////////
|
|
||||||
Rpc Setup
|
|
||||||
//////////////////////////////////////////////////////////////*/
|
|
||||||
function setUp() public {
|
function setUp() public {
|
||||||
_setup();
|
zeroExDeployed = new DeployZeroEx().deployZeroEx();
|
||||||
}
|
|
||||||
|
|
||||||
function test_transformERC20Forked() public {
|
|
||||||
log_string("TransformERC20Tests");
|
|
||||||
for (uint256 i = 0; i < chains.length; i++) {
|
|
||||||
vm.selectFork(forkIds[chains[i]]);
|
|
||||||
log_named_string(" Selecting Fork On", chains[i]);
|
|
||||||
_wrapNativeToken(chains[i], indexChainsByChain[chains[i]]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function logAddresses(string memory chainName, string memory chainId) public {
|
|
||||||
bytes memory details = json.parseRaw(chainId);
|
|
||||||
addresses = abi.decode(details, (ContractAddresses));
|
|
||||||
}
|
|
||||||
|
|
||||||
function _wrapNativeToken(string memory chainName, string memory chainId) public onlyForked {
|
|
||||||
bytes memory details = json.parseRaw(chainId);
|
|
||||||
addresses = abi.decode(details, (ContractAddresses));
|
|
||||||
|
|
||||||
vm.deal(address(this), 1e19);
|
vm.deal(address(this), 1e19);
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_transformERC20() public {
|
||||||
emit log_string("-----Preparing ETH->WETH transformation through TransformERC20()-----");
|
emit log_string("-----Preparing ETH->WETH transformation through TransformERC20()-----");
|
||||||
emit log_string(" --Building Up Transformations--");
|
emit log_string(" --Building Up Transformations--");
|
||||||
ITransformERC20Feature.Transformation[] memory transformations = new ITransformERC20Feature.Transformation[](1);
|
ITransformERC20Feature.Transformation[] memory transformations = new ITransformERC20Feature.Transformation[](1);
|
||||||
|
|
||||||
emit log_named_address(
|
emit log_named_address(" Finding TransformerDeployer nonce @", address(zeroExDeployed.transformerDeployer));
|
||||||
" Finding TransformerDeployer nonce @",
|
|
||||||
address(addresses.exchangeProxyTransformerDeployer)
|
|
||||||
);
|
|
||||||
emit log_named_uint(
|
emit log_named_uint(
|
||||||
" Deployer nonce",
|
" Deployer nonce",
|
||||||
_findTransformerNonce(
|
_findTransformerNonce(
|
||||||
address(addresses.transformers.wethTransformer),
|
address(zeroExDeployed.transformers.wethTransformer),
|
||||||
address(addresses.exchangeProxyTransformerDeployer)
|
address(zeroExDeployed.transformerDeployer)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
transformations[0].deploymentNonce = _findTransformerNonce(
|
transformations[0].deploymentNonce = _findTransformerNonce(
|
||||||
address(addresses.transformers.wethTransformer),
|
address(zeroExDeployed.transformers.wethTransformer),
|
||||||
address(addresses.exchangeProxyTransformerDeployer)
|
address(zeroExDeployed.transformerDeployer)
|
||||||
);
|
);
|
||||||
transformations[0].data = abi.encode(LibERC20Transformer.ETH_TOKEN_ADDRESS, 1e18);
|
transformations[0].data = abi.encode(LibERC20Transformer.ETH_TOKEN_ADDRESS, 1e18);
|
||||||
|
|
||||||
emit log_string(" ---Calling TransformERC20()---");
|
emit log_string(" ---Calling TransformERC20()---");
|
||||||
uint256 balanceETHBefore = address(this).balance;
|
uint256 balanceETHBefore = address(this).balance;
|
||||||
uint256 balanceWETHBefore = IERC20TokenV06(addresses.etherToken).balanceOf(address(this));
|
uint256 balanceWETHBefore = zeroExDeployed.weth.balanceOf(address(this));
|
||||||
|
zeroExDeployed.zeroEx.transformERC20{value: 1e18}(
|
||||||
IZeroEx(payable(addresses.exchangeProxy)).transformERC20{value: 1e18}(
|
|
||||||
// input token
|
// input token
|
||||||
IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS),
|
IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS),
|
||||||
// output token
|
// output token
|
||||||
IERC20TokenV06(address(addresses.etherToken)),
|
IERC20TokenV06(address(zeroExDeployed.weth)),
|
||||||
// input token amount
|
// input token amount
|
||||||
1e18,
|
1e18,
|
||||||
// min output token amount
|
// min output token amount
|
||||||
@ -99,12 +71,11 @@ contract WrapEthTest is Test, ForkUtils, TestUtils {
|
|||||||
// list of transform
|
// list of transform
|
||||||
transformations
|
transformations
|
||||||
);
|
);
|
||||||
log_named_uint(" NativeAsset balance before", balanceETHBefore);
|
assert(zeroExDeployed.weth.balanceOf(address(this)) == 1e18);
|
||||||
log_named_uint(" ERC-20 balance before", balanceWETHBefore);
|
emit log_string(" Successful Transformation Complete");
|
||||||
log_named_uint(" NativeAsset balance after", balanceETHBefore - address(this).balance);
|
emit log_named_uint(" ETH BALANCE BEFORE:", balanceETHBefore);
|
||||||
log_named_uint(
|
emit log_named_uint(" ETH BALANCE AFTER:", address(this).balance);
|
||||||
" ERC-20 balance after",
|
emit log_named_uint(" WETH BALANCE BEFORE:", balanceWETHBefore);
|
||||||
IERC20TokenV06(addresses.etherToken).balanceOf(address(this)) - balanceWETHBefore
|
emit log_named_uint(" WETH BALANCE AFTER:", zeroExDeployed.weth.balanceOf(address(this)));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ pragma solidity ^0.6.5;
|
|||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "forge-std/Test.sol";
|
import "forge-std/Test.sol";
|
||||||
import "../contracts/src/ZeroEx.sol";
|
import "../../contracts/src/ZeroEx.sol";
|
||||||
import "../contracts/src/migrations/InitialMigration.sol";
|
import "../../contracts/src/migrations/InitialMigration.sol";
|
||||||
|
|
||||||
contract BaseTest is Test {
|
contract BaseTest is Test {
|
||||||
address payable internal account1 = payable(vm.addr(1));
|
address payable internal account1 = payable(vm.addr(1));
|
@ -1,195 +0,0 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
/*
|
|
||||||
Copyright 2023 ZeroEx Intl.
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.6;
|
|
||||||
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "../utils/ForkUtils.sol";
|
|
||||||
import "../utils/TestUtils.sol";
|
|
||||||
import "src/IZeroEx.sol";
|
|
||||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
|
||||||
import "src/features/TransformERC20Feature.sol";
|
|
||||||
import "src/external/TransformerDeployer.sol";
|
|
||||||
import "src/transformers/WethTransformer.sol";
|
|
||||||
import "src/transformers/FillQuoteTransformer.sol";
|
|
||||||
import "src/transformers/bridges/BridgeProtocols.sol";
|
|
||||||
import "src/features/OtcOrdersFeature.sol";
|
|
||||||
|
|
||||||
contract SwapEthForERC20Test is Test, ForkUtils, TestUtils {
|
|
||||||
function setUp() public {
|
|
||||||
//get out addresses.json file that defines contract addresses for each chain we are currently deployed on
|
|
||||||
_setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_swapEthForERC20OnUniswap() public {
|
|
||||||
log_string("SwapEthForERC20OnUniswap");
|
|
||||||
for (uint256 i = 0; i < chains.length; i++) {
|
|
||||||
//skip fantom/avax failing test
|
|
||||||
if (i == 3 || i == 4) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
vm.selectFork(forkIds[chains[i]]);
|
|
||||||
log_named_string(" Selecting Fork On", chains[i]);
|
|
||||||
labelAddresses(
|
|
||||||
chains[i],
|
|
||||||
indexChainsByChain[chains[i]],
|
|
||||||
getTokens(i),
|
|
||||||
getContractAddresses(i),
|
|
||||||
getLiquiditySourceAddresses(i)
|
|
||||||
);
|
|
||||||
swapOnUniswap(getTokens(i), getContractAddresses(i), getLiquiditySourceAddresses(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* solhint-disable function-max-lines */
|
|
||||||
function swapOnUniswap(
|
|
||||||
TokenAddresses memory tokens,
|
|
||||||
ContractAddresses memory addresses,
|
|
||||||
LiquiditySources memory sources
|
|
||||||
) public onlyForked {
|
|
||||||
if (sources.UniswapV2Router != address(0)) {
|
|
||||||
// Create our list of transformations, let's do WethTransformer and FillQuoteTransformer
|
|
||||||
ITransformERC20Feature.Transformation[]
|
|
||||||
memory transformations = new ITransformERC20Feature.Transformation[](2);
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////
|
|
||||||
WethTransformer
|
|
||||||
//////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
// Use our cheeky search helper to find the nonce rather than hardcode it
|
|
||||||
transformations[0].deploymentNonce = _findTransformerNonce(
|
|
||||||
address(addresses.transformers.wethTransformer),
|
|
||||||
address(addresses.exchangeProxyTransformerDeployer)
|
|
||||||
);
|
|
||||||
emit log_named_uint(" WethTransformer nonce", transformations[0].deploymentNonce);
|
|
||||||
createNewFQT(
|
|
||||||
tokens.WrappedNativeToken,
|
|
||||||
addresses.exchangeProxy,
|
|
||||||
addresses.exchangeProxyTransformerDeployer
|
|
||||||
);
|
|
||||||
// Set the first transformation to transform ETH into WETH
|
|
||||||
transformations[0].data = abi.encode(LibERC20Transformer.ETH_TOKEN_ADDRESS, 1e18);
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////
|
|
||||||
FillQuoteTransformer
|
|
||||||
//////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
transformations[1].deploymentNonce = _findTransformerNonce(
|
|
||||||
address(fillQuoteTransformer),
|
|
||||||
address(addresses.exchangeProxyTransformerDeployer)
|
|
||||||
);
|
|
||||||
emit log_named_uint(" FillQuoteTransformer nonce", transformations[1].deploymentNonce);
|
|
||||||
// Set up the FillQuoteTransformer data
|
|
||||||
FillQuoteTransformer.TransformData memory fqtData;
|
|
||||||
fqtData.side = FillQuoteTransformer.Side.Sell;
|
|
||||||
fqtData.sellToken = IERC20TokenV06(address(tokens.WrappedNativeToken));
|
|
||||||
fqtData.buyToken = IERC20TokenV06(address(tokens.USDT));
|
|
||||||
// the FQT has a sequence, e.g first RFQ then Limit then Bridge
|
|
||||||
// since solidity doesn't support arrays of different types, this is one simple solution
|
|
||||||
// We use a Bridge order type here as we will fill on UniswapV2
|
|
||||||
fqtData.fillSequence = new FillQuoteTransformer.OrderType[](1);
|
|
||||||
fqtData.fillSequence[0] = FillQuoteTransformer.OrderType.Bridge;
|
|
||||||
// The amount to fill
|
|
||||||
fqtData.fillAmount = 1e18;
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////
|
|
||||||
Sampling
|
|
||||||
//////////////////////////////////////////////////////////////*/
|
|
||||||
|
|
||||||
uint256 amountOut = sampleLiquiditySource(
|
|
||||||
fqtData.fillAmount,
|
|
||||||
address(fqtData.sellToken),
|
|
||||||
address(fqtData.buyToken),
|
|
||||||
sources.UniswapV2Router
|
|
||||||
);
|
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////
|
|
||||||
BridgeAdapter
|
|
||||||
//////////////////////////////////////////////////////////////*/
|
|
||||||
// Now let's set up a UniswapV2 fill
|
|
||||||
fqtData.bridgeOrders = new IBridgeAdapter.BridgeOrder[](1);
|
|
||||||
IBridgeAdapter.BridgeOrder memory order;
|
|
||||||
// The ID is shifted so we can concat <PROTOCOL><NAME>
|
|
||||||
// e.g <UniswapV2Protocol><UniswapV2>
|
|
||||||
// or <UniswapV2Protocol><SushiSwap> for forks
|
|
||||||
order.source = bytes32(uint256(BridgeProtocols.UNISWAPV2) << 128);
|
|
||||||
// How much we want to fill on this order, which can be different to the total
|
|
||||||
// e.g 50/50 split this would be half
|
|
||||||
order.takerTokenAmount = 1e18;
|
|
||||||
// Set this low as the price of ETH/USDT can change
|
|
||||||
order.makerTokenAmount = amountOut;
|
|
||||||
// The data needed specifically for the source to fill,
|
|
||||||
// e.g for UniswapV2 it is the router contract and a path. See MixinUniswapV2
|
|
||||||
address[] memory uniPath = new address[](2);
|
|
||||||
uniPath[0] = address(tokens.WrappedNativeToken);
|
|
||||||
uniPath[1] = address(tokens.USDT);
|
|
||||||
order.bridgeData = abi.encode(address(sources.UniswapV2Router), uniPath);
|
|
||||||
fqtData.bridgeOrders[0] = order;
|
|
||||||
// Now encode the FQT data into the transformation
|
|
||||||
transformations[1].data = abi.encode(fqtData);
|
|
||||||
|
|
||||||
vm.deal(address(this), 1e18);
|
|
||||||
uint256 balanceETHBefore = address(this).balance;
|
|
||||||
uint256 balanceERC20Before = IERC20TokenV06(tokens.USDT).balanceOf(address(this));
|
|
||||||
|
|
||||||
IZeroEx(payable(addresses.exchangeProxy)).transformERC20{value: 1e18}(
|
|
||||||
// input token
|
|
||||||
IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS),
|
|
||||||
// output token
|
|
||||||
IERC20TokenV06(address(tokens.USDT)),
|
|
||||||
// input token amount
|
|
||||||
1e18,
|
|
||||||
// min output token amount
|
|
||||||
order.makerTokenAmount,
|
|
||||||
// list of transform
|
|
||||||
transformations
|
|
||||||
);
|
|
||||||
|
|
||||||
log_named_uint(" NativeAsset balance before", balanceETHBefore);
|
|
||||||
log_named_uint(" ERC-20 balance before", balanceERC20Before);
|
|
||||||
log_named_uint(" NativeAsset balance after", balanceETHBefore - address(this).balance);
|
|
||||||
log_named_uint(
|
|
||||||
" ERC-20 balance after",
|
|
||||||
IERC20TokenV06(tokens.USDT).balanceOf(address(this)) - balanceERC20Before
|
|
||||||
);
|
|
||||||
assert(IERC20TokenV06(tokens.USDT).balanceOf(address(this)) > 0);
|
|
||||||
} else {
|
|
||||||
emit log_string("Liquidity Source not available on this chain");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* solhint-enable function-max-lines */
|
|
||||||
|
|
||||||
// get a real quote from uniswap
|
|
||||||
function sampleLiquiditySource(
|
|
||||||
uint256 amount,
|
|
||||||
address takerToken,
|
|
||||||
address makerToken,
|
|
||||||
address router
|
|
||||||
) public returns (uint256 makerTokenAmounts) {
|
|
||||||
address[] memory path = new address[](2);
|
|
||||||
path[0] = address(takerToken);
|
|
||||||
path[1] = address(makerToken);
|
|
||||||
uint256[] memory amounts = new uint256[](1);
|
|
||||||
amounts[0] = amount;
|
|
||||||
uint256 out = sampleSellsFromUniswapV2(router, path, amounts)[0];
|
|
||||||
|
|
||||||
log_string(" Sampling Uniswap for tokens");
|
|
||||||
log_named_address(" ", takerToken);
|
|
||||||
log_string(" -> ");
|
|
||||||
log_named_address(" ", makerToken);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user