Compare commits

..

6 Commits

Author SHA1 Message Date
Jacob Evans
7bf710f153 Publish
- @0x/contracts-asset-proxy@3.3.0
 - @0x/contracts-broker@1.1.5
 - @0x/contracts-coordinator@3.1.6
 - @0x/contracts-dev-utils@1.3.4
 - @0x/contracts-erc1155@2.1.6
 - @0x/contracts-erc20-bridge-sampler@1.6.0
 - @0x/contracts-erc20@3.2.0
 - @0x/contracts-erc721@3.1.6
 - @0x/contracts-exchange-forwarder@4.2.6
 - @0x/contracts-exchange-libs@4.3.6
 - @0x/contracts-exchange@3.2.6
 - @0x/contracts-extensions@6.2.0
 - @0x/contracts-integrations@2.5.2
 - @0x/contracts-multisig@4.1.6
 - @0x/contracts-staking@2.0.13
 - @0x/contracts-test-utils@5.3.3
 - @0x/contracts-utils@4.5.0
 - @0x/contracts-zero-ex@0.1.1
 - 0x.js@9.1.6
 - @0x/abi-gen@5.3.0
 - @0x/assert@3.0.8
 - @0x/asset-swapper@4.5.0
 - @0x/base-contract@6.2.2
 - @0x/connect@6.0.8
 - @0x/contract-addresses@4.10.0
 - @0x/contract-artifacts@3.7.0
 - @0x/contract-wrappers-test@12.2.15
 - @0x/contract-wrappers@13.7.0
 - @0x/contracts-gen@2.0.9
 - @0x/dev-utils@3.2.2
 - ethereum-types@3.1.1
 - @0x/instant@1.0.52
 - @0x/json-schemas@5.0.8
 - @0x/migrations@6.3.0
 - @0x/monorepo-scripts@1.0.53
 - @0x/order-utils@10.2.5
 - @0x/orderbook@2.2.6
 - @0x/sol-compiler@4.1.0
 - @0x/sol-coverage@4.0.9
 - @0x/sol-doc@3.1.7
 - @0x/sol-profiler@4.0.9
 - @0x/sol-resolver@3.0.4
 - @0x/sol-trace@3.0.9
 - @0x/sol-tracing-utils@7.0.9
 - @0x/sra-spec@3.0.8
 - @0x/subproviders@6.1.0
 - @0x/types@3.1.3
 - @0x/typescript-typings@5.1.0
 - @0x/utils@5.5.0
 - @0x/web3-wrapper@7.1.0
2020-06-24 13:56:20 +10:00
Jacob Evans
e50fd77973 Updated CHANGELOGS & MD docs 2020-06-24 13:55:59 +10:00
Jacob Evans
71cdc8a28f discuss: Continue if protocol fee insufficient 2020-06-23 18:30:22 +10:00
Jacob Evans
549f7bc6ee Initial tests 2020-06-23 18:02:35 +10:00
Jacob Evans
92ec1d6923 Mark as external for try/catch 2020-06-19 18:12:54 +10:00
Jacob Evans
56529180e9 Detect Bridge orders and fill direct 2020-06-19 17:03:06 +10:00
1760 changed files with 150524 additions and 66840 deletions

View File

@@ -4,13 +4,23 @@ jobs:
build:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
environment:
CONTRACTS_COMMIT_HASH: '9ed05f5'
working_directory: ~/repo
steps:
- checkout
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
# HACK(feuGeneA): commented out this hack as we're changing
# from a circleci-maintained container to a different
# container, and this hack may not apply anymore, as
# suggested by the non-existance of `/home/circleci/.bashrc`
# when running the command below.
# - run:
# # HACK(albrow): Without this, yarn commands will sometimes
# # fail with a "permission denied" error.
# name: Set npm path
# command: npm set prefix=/home/circleci/npm && echo 'export PATH=$HOME/circleci/npm/bin:$PATH' >> /home/circleci/.bashrc
- run:
name: install-yarn
command: npm install --force --global yarn@1.17.0
@@ -31,7 +41,7 @@ jobs:
test-exchange-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
@@ -41,7 +51,7 @@ jobs:
test-integrations-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
@@ -51,37 +61,27 @@ jobs:
test-contracts-staking-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-staking
test-contracts-extra-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-exchange-forwarder @0x/contracts-coordinator
test-contracts-rest-ganache:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-asset-proxy @0x/contracts-broker @0x/contracts-zero-ex
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-asset-proxy @0x/contracts-exchange-forwarder @0x/contracts-coordinator @0x/contracts-erc20-bridge-sampler @0x/contracts-broker @0x/contracts-zero-ex
test-publish:
resource_class: medium+
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
- image: 0xorg/verdaccio
working_directory: ~/repo
steps:
@@ -91,11 +91,9 @@ jobs:
- run:
command: yarn test:publish:circleci
no_output_timeout: 1800
- store_artifacts:
path: ~/.npm/_logs
test-doc-generation:
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
@@ -106,35 +104,230 @@ jobs:
no_output_timeout: 1200
test-rest:
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-test-utils
- run: yarn wsrun test:circleci @0x/contract-artifacts
- run: yarn wsrun test:circleci @0x/contract-wrappers-test
- run: yarn wsrun test:circleci @0x/migrations
- run: yarn wsrun test:circleci @0x/order-utils
- run: yarn wsrun test:circleci @0x/abi-gen
- run: yarn wsrun test:circleci @0x/asset-swapper
- run: yarn wsrun test:circleci @0x/contract-artifacts
- run: yarn wsrun test:circleci @0x/assert
- run: yarn wsrun test:circleci @0x/base-contract
- run: yarn wsrun test:circleci @0x/connect
- run: yarn wsrun test:circleci @0x/contract-wrappers-test
- run: yarn wsrun test:circleci @0x/dev-utils
- run: yarn wsrun test:circleci @0x/json-schemas
- run: yarn wsrun test:circleci @0x/order-utils
- run: yarn wsrun test:circleci @0x/orderbook
- run: yarn wsrun test:circleci @0x/sol-compiler
- run: yarn wsrun test:circleci @0x/sol-tracing-utils
- run: yarn wsrun test:circleci @0x/sol-doc
- run: yarn wsrun test:circleci @0x/subproviders
- run: yarn wsrun test:circleci @0x/web3-wrapper
- run: yarn wsrun test:circleci @0x/utils
- run: yarn wsrun test:circleci @0x/instant
- save_cache:
key: coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/abi-gen/coverage/lcov.info
- save_cache:
key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/assert/coverage/lcov.info
- save_cache:
key: coverage-asset-swapper-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/asset-swapper/coverage/lcov.info
- save_cache:
key: coverage-base-contract-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/base-contract/coverage/lcov.info
- save_cache:
key: coverage-connect-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/connect/coverage/lcov.info
- save_cache:
key: coverage-contract-wrappers-test-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/contract-wrappers-test/coverage/lcov.info
- save_cache:
key: coverage-dev-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/dev-utils/coverage/lcov.info
- save_cache:
key: coverage-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/json-schemas/coverage/lcov.info
- save_cache:
key: coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/order-utils/coverage/lcov.info
- save_cache:
key: coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-compiler/coverage/lcov.info
- save_cache:
key: coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-tracing-utils/coverage/lcov.info
- save_cache:
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/sol-doc/coverage/lcov.info
- save_cache:
key: coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/subproviders/coverage/lcov.info
- save_cache:
key: coverage-web3-wrapper-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/web3-wrapper/coverage/lcov.info
test-python:
working_directory: ~/repo
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
- image: 0xorg/ganache-cli:6.0.0
environment:
VERSION: '6.0.0'
- image: 0xorg/mesh:0xV3
environment:
ETHEREUM_RPC_URL: 'http://localhost:8545'
ETHEREUM_CHAIN_ID: '1337'
VERBOSITY: 5
BLOCK_POLLING_INTERVAL: '50ms'
ETHEREUM_RPC_MAX_REQUESTS_PER_24_HR_UTC: '1778000'
command: |
sh -c "waitForGanache () { until printf 'POST /\r\nContent-Length: 26\r\n\r\n{\"method\":\"net_listening\"}' | nc localhost 8545 | grep true; do continue; done }; waitForGanache && ./mesh"
- image: 0xorg/launch-kit-backend:v3
environment:
RPC_URL: 'http://localhost:8545'
CHAIN_ID: 1337
WHITELIST_ALL_TOKENS: True
FEE_RECIPIENT: '0x0000000000000000000000000000000000000001'
MAKER_FEE_UNIT_AMOUNT: 0
TAKER_FEE_UNIT_AMOUNT: 0
MESH_ENDPOINT: 'ws://localhost:60557'
command: |
sh -c "waitForMesh () { sleep 30; }; waitForMesh && node_modules/.bin/forever ts/lib/index.js"
steps:
- checkout
- restore_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
command: |
cd python-packages
python -m ensurepip
./pre_install
./install
- save_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- '/usr/local/bin'
- '/usr/local/lib/python3.7/site-packages'
- run:
command: |
cd python-packages
./parallel coverage run setup.py test
./build_docs
- run:
command: |
# copy generated wrappers into contract_wrappers/build,
# JUST so CircleCI will persist them as build artifacts.
cd python-packages/contract_wrappers/src/zero_ex
for i in contract_wrappers/[^__]*/; do mkdir -p ../../build/$i; cp $i/__init__.py ../../build/$i; done
- save_cache:
key: coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/contract_addresses/.coverage
- save_cache:
key: coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/contract_artifacts/.coverage
- save_cache:
key: coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/contract_demo/.coverage
- save_cache:
key: coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/json_schemas/.coverage
- save_cache:
key: coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/order_utils/.coverage
- save_cache:
key: coverage-python-sra-client-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/python-packages/sra_client/.coverage
- store_artifacts:
path: ~/repo/python-packages/contract_addresses/build
- store_artifacts:
path: ~/repo/python-packages/contract_artifacts/build
- store_artifacts:
path: ~/repo/python-packages/contract_wrappers/build
- store_artifacts:
path: ~/repo/python-packages/json_schemas/build
- store_artifacts:
path: ~/repo/python-packages/middlewares/build
- store_artifacts:
path: ~/repo/python-packages/order_utils/build
- store_artifacts:
path: ~/repo/python-packages/sra_client/build
test-rest-python:
working_directory: ~/repo
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
steps:
- checkout
- restore_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
- run:
command: |
cd python-packages/order_utils
python -m ensurepip
python -m pip install .
- save_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
paths:
- '/usr/local/bin'
- '/usr/local/lib/python3.7/site-packages'
- '.eggs'
- '.mypy_cache'
- '.pytest_cache'
- '.tox'
- run:
command: |
cd python-packages/order_utils
tox
static-tests-python:
working_directory: ~/repo
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs8
steps:
- checkout
- restore_cache:
key: installed-py-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run:
command: |
python -m ensurepip
cd python-packages
./pre_install
./install
./lint
static-tests:
resource_class: large
working_directory: ~/repo
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
steps:
- restore_cache:
keys:
@@ -143,42 +336,94 @@ jobs:
- run: yarn prettier:ci
- run: yarn deps_versions:ci
- run: yarn diff_md_docs:ci
- run: cd packages/0x.js && yarn build:umd:prod
- run: yarn bundlewatch
submit-coverage:
docker:
- image: nikolaik/python-nodejs:python3.7-nodejs10
- image: nikolaik/python-nodejs:python3.7-nodejs8
working_directory: ~/repo
steps:
- restore_cache:
keys:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-asset-swapper-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-base-contract-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-connect-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-contract-wrappers-test-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-dev-utils-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-web3-wrapper-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-contract-addresses-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-contract-artifacts-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-contract-demo-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-sra-client-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
- 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-exchange-ganache:
requires:
- build
- test-integrations-ganache:
requires:
- build
- test-contracts-staking-ganache:
requires:
- build
- test-contracts-rest-ganache:
requires:
- build
@@ -194,14 +439,18 @@ workflows:
- 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
- submit-coverage:
requires:
- test-contracts-rest-ganache
- test-contracts-staking-ganache
- test-exchange-ganache
- test-rest
- static-tests
- test-python:
requires:
- build
- static-tests-python:
requires:
- build
# skip python tox run for now, as we don't yet have multiple test environments to support.
# - test-rest-python

4
.gitattributes vendored
View File

@@ -2,3 +2,7 @@
# Automatically collapse generated files in GitHub.
*.svg linguist-generated=true
packages/contract-artifacts/artifacts/*json linguist-generated=true
packages/abi-gen-wrappers/src/generated-wrappers/*.ts linguist-generated=true
packages/contract-wrappers/src/generated-wrappers/*.ts linguist-generated=true

View File

@@ -1,7 +1,33 @@
python: ['python-packages']
contracts: ['contracts']
@0x/sol-doc: ['packages/sol-doc']
@0x/sol-resolver: ['packages/sol-resolver']
@0x/contracts-gen: ['packages/contracts-gen']
@0x/sra-spec: ['packages/sra-spec']
@0x/subproviders: ['packages/subproviders']
@0x/contract-addresses: ['packages/contract-addresses']
@0x/migrations: ['packages/migrations']
@0x/web3-wrapper: ['packages/web3-wrapper']
@0x/sol-compiler: ['packages/sol-compiler']
@0x/types: ['packages/types']
@0x/instant: ['packages/instant']
@0x/abi-gen-templates: ['packages/abi-gen-templates']
@0x/abi-gen: ['packages/abi-gen']
@0x/sol-coverage: ['packages/sol-coverage']
@0x/sol-profiler: ['packages/sol-profiler']
@0x/sol-trace: ['packages/sol-trace']
@0x/sol-tracing-utils: ['packages/sol-tracing-utils']
@0x/utils: ['packages/utils']
@0x/tslint-config: ['packages/tslint-config']
@0x/asset-swapper: ['packages/asset-swapper']
@0x/order-utils: ['packages/order-utils']
@0x/assert: ['packages/assert']
@0x/base-contract: ['packages/base-contract']
@0x/typescript-typings: ['packages/typescript-typings']
0x.js: ['packages/0x.js']
@0x/contract-artifacts: ['packages/contract-artifacts']
@0x/dev-utils: ['packages/dev-utils']
@0x/contract-wrappers: ['packages/contract-wrappers']
@0x/json-schemas: ['packages/json-schemas']
@0x/ethereum-types: ['ethereum-types']
@0x/connect: ['packages/connect']

View File

@@ -1,48 +0,0 @@
name: publish
on:
workflow_dispatch:
inputs:
ci_status:
description: 'required CI status'
default: 'success'
required: true
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: 'check successful status'
run: |
REF_STATUS=$(curl -s \
'https://api.github.com/repos/${{ github.repository }}/commits/${{ github.ref }}/status' \
| jq .state)
[[ "${REF_STATUS}" == '"${{ github.event.inputs.ci_status }}"' ]] || \
(echo "::error ::${{ github.ref }} does not have a successful CI status" && false)
- uses: actions/checkout@v2
with:
ref: 'development'
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 10
- uses: actions/setup-python@v2
- name: 'configure git'
run: |
git config --global user.email "github-actions@github.com"
git config --global user.name "Github Actions"
- name: 'install dependencies'
run: |
yarn -D
- name: 'build and publish'
run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
npm run run:publish:gha
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
- name: 'merge into main branch'
run: |
git checkout main && \
git merge ${{ github.ref }} && \
git push

20
.gitignore vendored
View File

@@ -113,6 +113,8 @@ contracts/dev-utils/generated-artifacts/
contracts/dev-utils/test/generated-artifacts/
contracts/zero-ex/generated-artifacts/
contracts/zero-ex/test/generated-artifacts/
packages/sol-tracing-utils/test/fixtures/artifacts/
python-packages/contract_artifacts/src/zero_ex/contract_artifacts/artifacts/
# generated truffle contract artifacts/
contracts/broker/build/
@@ -167,6 +169,24 @@ contracts/dev-utils/generated-wrappers/
contracts/dev-utils/test/generated-wrappers/
contracts/zero-ex/generated-wrappers/
contracts/zero-ex/test/generated-wrappers/
python-packages/contract_wrappers/src/zero_ex/contract_wrappers/*/__init__.py
# solc-bin in sol-compiler
packages/sol-compiler/solc_bin/
# python stuff
.eggs
.mypy_cache
.tox
python-packages/*/build
python-packages/*/dist
__pycache__
python-packages/*/src/*.egg-info
python-packages/*/.coverage
# python keeps package-local copies of json schemas and contract addresses
python-packages/json_schemas/src/zero_ex/json_schemas/schemas
python-packages/contract_addresses/src/zero_ex/contract_addresses/addresses.json
# Doc README copy
packages/*/docs/README.md

View File

@@ -40,6 +40,10 @@ lib
/contracts/erc20/test/generated-wrappers
/contracts/erc20/generated-artifacts
/contracts/erc20/test/generated-artifacts
/contracts/erc20-bridge-sampler/generated-wrappers
/contracts/erc20-bridge-sampler/test/generated-wrappers
/contracts/erc20-bridge-sampler/generated-artifacts
/contracts/erc20-bridge-sampler/test/generated-artifacts
/contracts/erc721/generated-wrappers
/contracts/erc721/test/generated-wrappers
/contracts/erc721/generated-artifacts
@@ -76,11 +80,19 @@ lib
/contracts/erc1155/build/
/contracts/extensions/build/
/contracts/exchange-forwarder/build/
/packages/asset-swapper/generated-artifacts
/packages/asset-swapper/generated-wrappers
/packages/asset-swapper/test/generated-artifacts
/packages/asset-swapper/test/generated-wrappers
/contracts/dev-utils/build/
/packages/abi-gen/test-cli/output
/packages/json-schemas/schemas
/python-packages/json_schemas/src/zero_ex/json_schemas/schemas
/packages/sra-spec/public/
package.json
scripts/postpublish_utils.js
packages/sol-coverage/test/fixtures/artifacts
.pytest_cache
.mypy_cache
.tox
packages/abi-gen/test-cli/fixtures/artifacts/AbiGenDummy.json
packages/abi-gen/test-cli/fixtures/artifacts/LibDummy.json
packages/abi-gen/test-cli/fixtures/artifacts/TestLibDummy.json
packages/*/docs
docs/
*.sol

View File

@@ -2,6 +2,5 @@
"printWidth": 120,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true
"trailingComma": "all"
}

View File

@@ -1,23 +0,0 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml
# Optionally build your docs in additional formats such as PDF
#formats:
# - pdf
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt

View File

@@ -9,10 +9,30 @@ packages/asset-swapper/ @BMillman19 @fragosti @dave4506
packages/instant/ @BMillman19 @fragosti @dave4506
# Dev tools & setup
.circleci/ @dorothy-zbornak
.circleci/ @LogvinovLeon
packages/abi-gen/ @feuGeneA
packages/base-contract/ @xianny
packages/connect/ @fragosti
packages/abi-gen-templates/ @feuGeneA @xianny
packages/contract-addresses/ @abandeali1
packages/contract-artifacts/ @abandeali1
packages/order-utils/ @dorothy-zbornak
packages/dev-utils/ @LogvinovLeon @fabioberger
packages/devnet/ @albrow
packages/ethereum-types/ @LogvinovLeon
packages/monorepo-scripts/ @fabioberger
packages/order-utils/ @fabioberger @LogvinovLeon
packages/python-contract-wrappers/ @feuGeneA
packages/sol-compiler/ @LogvinovLeon
packages/sol-coverage/ @LogvinovLeon
packages/sol-profiler/ @LogvinovLeon
packages/sol-trace/ @LogvinovLeon
packages/sol-tracing-utils/ @LogvinovLeon
packages/sol-resolver/ @LogvinovLeon
packages/subproviders/ @fabioberger @dekz
packages/verdaccio/ @albrow
packages/web3-wrapper/ @LogvinovLeon @fabioberger
python-packages/ @feuGeneA
packages/utils/ @hysz
# Protocol/smart contracts
contracts/ @abandeali1 @hysz @dorothy-zbornak @mzhu25
contracts/ @abandeali1 @hysz

View File

@@ -4,9 +4,9 @@ We welcome contributions from anyone on the internet and are grateful for even t
### Getting started
1. Fork `0xproject/0x-tools`
1. Fork `0xproject/0x-monorepo`
2. Clone your fork
3. Follow the [installation & build steps](https://github.com/0xProject/0x-tools#install-dependencies) in the repo's top-level README.
3. Follow the [installation & build steps](https://github.com/0xProject/0x-monorepo#install-dependencies) in the repo's top-level README.
4. Setup the recommended [Development Tooling](#development-tooling).
5. Open a PR with the `[WIP]` flag against the `development` branch and describe the change you are intending to undertake in the PR description. (see [our branch naming conventions](#branch-structure))
@@ -59,11 +59,11 @@ We strongly recommend you use the [VSCode](https://code.visualstudio.com/) text
#### Linter
We use [TSLint](https://palantir.github.io/tslint/) with [custom configs](https://github.com/0xProject/0x-tools/tree/development/packages/tslint-config) to keep our code-style consistent.
We use [TSLint](https://palantir.github.io/tslint/) with [custom configs](https://github.com/0xProject/0x-monorepo/tree/development/packages/tslint-config) to keep our code-style consistent.
Use `yarn:lint` to lint the entire monorepo, and `PKG={PACKAGE_NAME} yarn lint` to lint a specific package.
If you want to change a rule, or add a custom rule, please make these changes to our [tslint-config](https://github.com/0xProject/0x-tools/tree/development/packages/tslint-config) package. All other packages have it as a dependency.
If you want to change a rule, or add a custom rule, please make these changes to our [tslint-config](https://github.com/0xProject/0x-monorepo/tree/development/packages/tslint-config) package. All other packages have it as a dependency.
Integrate it into your text editor:
@@ -94,12 +94,12 @@ A few of our coding conventions are not yet enforced by the linter/auto-formatte
### Fix `submit-coverage` CI failure
If you simply fork the repo and then create a PR from it, your PR will fail the `submit-coverage` check on CI. This is because the 0x CircleCI configuration sets the `COVERALLS_REPO_TOKEN` environment variable to the token for `0xProject/0x-tools`, but when running the check against your fork the token needs to match your repo's name `your-username/0x-tools`.
If you simply fork the repo and then create a PR from it, your PR will fail the `submit-coverage` check on CI. This is because the 0x CircleCI configuration sets the `COVERALLS_REPO_TOKEN` environment variable to the token for `0xProject/0x-monorepo`, but when running the check against your fork the token needs to match your repo's name `your-username/0x-monorepo`.
To facilitate this check, after creating your fork, but before creating the branch for your PR, do the following:
1. Log in to [coveralls.io](https://coveralls.io/), go to `Add Repos`, and enable your fork. Then go to the settings for that repo, and copy the `Repo Token` identifier.
2. Log in to [CircleCI](https://circleci.com/login), go to `Add Projects`, click the `Set Up Project` button corresponding to your fork, and then click `Start Building`. (Aside from step 3 below, no actual set up is needed, since it will use the `.circleci/config.yml` file in 0x-tools, so you can ignore all of the instruction/explanation given on the page with the `Start Building` button.)
2. Log in to [CircleCI](https://circleci.com/login), go to `Add Projects`, click the `Set Up Project` button corresponding to your fork, and then click `Start Building`. (Aside from step 3 below, no actual set up is needed, since it will use the `.circleci/config.yml` file in 0x-monorepo, so you can ignore all of the instruction/explanation given on the page with the `Start Building` button.)
3. In CircleCI, configure your project to add an environment variable, with name `COVERALLS_REPO_TOKEN`, and for the value paste in the `Repo Token` you copied in step 1.
Now, when you push to your branch, CircleCI will automatically run all of the checks in your own instance, and the coverage check will work since it has the proper `Repo Token`, and the PR will magically refer to your own checks rather than running them in the 0x CircleCI instance.

View File

@@ -1,4 +1,4 @@
Copyright 2020 ZeroEx Labs
Copyright 2017 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -8,7 +8,7 @@ This repository is a monorepo including the 0x protocol smart contracts and nume
[website-url]: https://0x.org
[![CircleCI](https://circleci.com/gh/0xProject/protocol.svg?style=svg&circle-token=61bf7cd8c9b4e11b132089dfcffdd1be277d1e0c)](https://circleci.com/gh/0xProject/protocool)
[![CircleCI](https://circleci.com/gh/0xProject/0x-monorepo.svg?style=svg&circle-token=61bf7cd8c9b4e11b132089dfcffdd1be277d1e0c)](https://circleci.com/gh/0xProject/0x-monorepo)
[![Coverage Status](https://coveralls.io/repos/github/0xProject/0x-monorepo/badge.svg?branch=development)](https://coveralls.io/github/0xProject/0x-monorepo?branch=development)
[![Discord](https://img.shields.io/badge/chat-discord.chat-yellow.svg?style=flat)](https://discordapp.com/invite/d3FTX3M)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
@@ -17,6 +17,17 @@ This repository is a monorepo including the 0x protocol smart contracts and nume
Visit our [developer portal](https://0x.org/docs/tools/order-utils) for a comprehensive list of core & community maintained packages. All packages maintained with this monorepo are listed below.
### Python Packages
| Package | Version | Description |
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [`0x-contract-addresses`](/python-packages/contract_addresses) | [![PyPI](https://img.shields.io/pypi/v/0x-contract-addresses.svg)](https://pypi.org/project/0x-contract-addresses/) | A tiny utility library for getting known deployed contract addresses for a particular network |
| [`0x-contract-artifacts`](/python-packages/contract_artifacts) | [![PyPI](https://img.shields.io/pypi/v/0x-contract-artifacts.svg)](https://pypi.org/project/0x-contract-artifacts/) | 0x smart contract compilation artifacts |
| [`0x-contract-wrappers`](/python-packages/contract_wrappers) | [![PyPI](https://img.shields.io/pypi/v/0x-contract-wrappers.svg)](https://pypi.org/project/0x-contract-wrappers/) | 0x smart contract wrappers |
| [`0x-json-schemas`](/python-packages/json_schemas) | [![PyPI](https://img.shields.io/pypi/v/0x-json-schemas.svg)](https://pypi.org/project/0x-json-schemas/) | 0x-related JSON schemas |
| [`0x-order-utils`](/python-packages/order_utils) | [![PyPI](https://img.shields.io/pypi/v/0x-order-utils.svg)](https://pypi.org/project/0x-order-utils/) | A set of utilities for generating, parsing, signing and validating 0x orders |
| [`0x-sra-client`](/python-packages/sra_client) | [![PyPI](https://img.shields.io/pypi/v/0x-sra-client.svg)](https://pypi.org/project/0x-sra-client/) | A Python client for interacting with servers conforming to the Standard Relayer API specification |
### Solidity Packages
These packages are all under development. See [/contracts/README.md](/contracts/README.md) for a list of deployed packages.
@@ -42,13 +53,50 @@ These packages are all under development. See [/contracts/README.md](/contracts/
#### 0x-specific packages
| Package | Version | Description |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| [`@0x/contract-addresses`](/packages/contract-addresses) | [![npm](https://img.shields.io/npm/v/@0x/contract-addresses.svg)](https://www.npmjs.com/package/@0x/contract-addresses) | A tiny utility library for getting known deployed contract addresses for a particular network. |
| [`@0x/contract-wrappers`](/packages/contract-wrappers) | [![npm](https://img.shields.io/npm/v/@0x/contract-wrappers.svg)](https://www.npmjs.com/package/@0x/contract-wrappers) | JS/TS wrappers for interacting with the 0x smart contracts |
| [`@0x/order-utils`](/packages/order-utils) | [![npm](https://img.shields.io/npm/v/@0x/order-utils.svg)](https://www.npmjs.com/package/@0x/order-utils) | A set of utilities for generating, parsing, signing and validating 0x orders |
| [`@0x/migrations`](/packages/migrations) | [![npm](https://img.shields.io/npm/v/@0x/migrations.svg)](https://www.npmjs.com/package/@0x/migrations) | Migration tool for deploying 0x smart contracts on private testnets |
| [`@0x/contract-artifacts`](/packages/contract-artifacts) | [![npm](https://img.shields.io/npm/v/@0x/contract-artifacts.svg)](https://www.npmjs.com/package/@0x/contract-artifacts) | 0x smart contract compilation artifacts | |
| Package | Version | Description |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [`0x.js`](/packages/0x.js) | [![npm](https://img.shields.io/npm/v/0x.js.svg)](https://www.npmjs.com/package/0x.js) | An aggregate package combining many smaller utility packages for interacting with the 0x protocol |
| [`@0x/contract-addresses`](/packages/contract-addresses) | [![npm](https://img.shields.io/npm/v/@0x/contract-addresses.svg)](https://www.npmjs.com/package/@0x/contract-addresses) | A tiny utility library for getting known deployed contract addresses for a particular network. |
| [`@0x/contract-wrappers`](/packages/contract-wrappers) | [![npm](https://img.shields.io/npm/v/@0x/contract-wrappers.svg)](https://www.npmjs.com/package/@0x/contract-wrappers) | JS/TS wrappers for interacting with the 0x smart contracts |
| [`@0x/order-utils`](/packages/order-utils) | [![npm](https://img.shields.io/npm/v/@0x/order-utils.svg)](https://www.npmjs.com/package/@0x/order-utils) | A set of utilities for generating, parsing, signing and validating 0x orders |
| [`@0x/json-schemas`](/packages/json-schemas) | [![npm](https://img.shields.io/npm/v/@0x/json-schemas.svg)](https://www.npmjs.com/package/@0x/json-schemas) | 0x-related JSON schemas | |
| [`@0x/migrations`](/packages/migrations) | [![npm](https://img.shields.io/npm/v/@0x/migrations.svg)](https://www.npmjs.com/package/@0x/migrations) | Migration tool for deploying 0x smart contracts on private testnets |
| [`@0x/contract-artifacts`](/packages/contract-artifacts) | [![npm](https://img.shields.io/npm/v/@0x/contract-artifacts.svg)](https://www.npmjs.com/package/@0x/contract-artifacts) | 0x smart contract compilation artifacts | |
| [`@0x/sra-spec`](/packages/sra-spec) | [![npm](https://img.shields.io/npm/v/@0x/sra-spec.svg)](https://www.npmjs.com/package/@0x/sra-spec) | OpenAPI specification for the Standard Relayer API |
| [`@0x/connect`](/packages/connect) | [![npm](https://img.shields.io/npm/v/@0x/connect.svg)](https://www.npmjs.com/package/@0x/connect) | An HTTP/WS client for interacting with the Standard Relayer API |
| [`@0x/asset-swapper`](/packages/asset-swapper) | [![npm](https://img.shields.io/npm/v/@0x/asset-swapper.svg)](https://www.npmjs.com/package/@0x/asset-swapper) | Convenience package for discovering and performing swaps for any ERC20 Assets |
#### Ethereum tooling
| Package | Version | Description |
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`@0x/web3-wrapper`](/packages/web3-wrapper) | [![npm](https://img.shields.io/npm/v/@0x/web3-wrapper.svg)](https://www.npmjs.com/package/@0x/web3-wrapper) | An Ethereum JSON RPC client |
| [`@0x/sol-compiler`](/packages/sol-compiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-compiler.svg)](https://www.npmjs.com/package/@0x/sol-compiler) | A wrapper around solc-js that adds smart re-compilation, ability to compile an entire project, Solidity version specific compilation, standard input description support and much more. |
| [`@0x/sol-coverage`](/packages/sol-coverage) | [![npm](https://img.shields.io/npm/v/@0x/sol-coverage.svg)](https://www.npmjs.com/package/@0x/sol-coverage) | A solidity test coverage tool |
| [`@0x/sol-profiler`](/packages/sol-profiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-profiler.svg)](https://www.npmjs.com/package/@0x/sol-profiler) | A solidity gas cost profiler |
| [`@0x/sol-trace`](/packages/sol-trace) | [![npm](https://img.shields.io/npm/v/@0x/sol-trace.svg)](https://www.npmjs.com/package/@0x/sol-trace) | A solidity stack trace tool |
| [`@0x/sol-resolver`](/packages/sol-resolver) | [![npm](https://img.shields.io/npm/v/@0x/sol-resolver.svg)](https://www.npmjs.com/package/@0x/sol-resolver) | Import resolver for smart contracts dependencies |
| [`@0x/subproviders`](/packages/subproviders) | [![npm](https://img.shields.io/npm/v/@0x/subproviders.svg)](https://www.npmjs.com/package/@0x/subproviders) | Web3 provider middlewares (e.g. LedgerSubprovider) |
| [`@0x/sol-doc`](/packages/sol-doc) | [![npm](https://img.shields.io/npm/v/@0x/sol-doc.svg)](https://www.npmjs.com/package/@0x/sol-doc) | Solidity documentation generator |
#### Utilities
| Package | Version | Description |
| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| [`@0x/abi-gen`](/packages/abi-gen) | [![npm](https://img.shields.io/npm/v/@0x/abi-gen.svg)](https://www.npmjs.com/package/@0x/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
| [`@0x/tslint-config`](/packages/tslint-config) | [![npm](https://img.shields.io/npm/v/@0x/tslint-config.svg)](https://www.npmjs.com/package/@0x/tslint-config) | Custom TSLint rules used by the 0x core team |
| [`@0x/types`](/packages/types) | [![npm](https://img.shields.io/npm/v/@0x/types.svg)](https://www.npmjs.com/package/@0x/types) | Shared type declarations |
| [`@0x/typescript-typings`](/packages/typescript-typings) | [![npm](https://img.shields.io/npm/v/@0x/typescript-typings.svg)](https://www.npmjs.com/package/@0x/typescript-typings) | Repository of types for external packages |
| [`@0x/utils`](/packages/utils) | [![npm](https://img.shields.io/npm/v/@0x/utils.svg)](https://www.npmjs.com/package/@0x/utils) | Shared utilities |
| [`@0x/assert`](/packages/assert) | [![npm](https://img.shields.io/npm/v/@0x/assert.svg)](https://www.npmjs.com/package/@0x/assert) | Type and schema assertions used by our packages |
| [`@0x/base-contract`](/packages/base-contract) | [![npm](https://img.shields.io/npm/v/@0x/base-contract.svg)](https://www.npmjs.com/package/@0x/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts |
| [`@0x/dev-utils`](/packages/dev-utils) | [![npm](https://img.shields.io/npm/v/@0x/dev-utils.svg)](https://www.npmjs.com/package/@0x/dev-utils) | Dev utils to be shared across 0x packages |
#### Private Packages
| Package | Description |
| ---------------------------------- | -------------------------------------------------------------------------------- |
| [`@0x/instant`](/packages/instant) | A free and flexible way to offer simple crypto purchasing in any app or website. |
## Usage
@@ -81,6 +129,8 @@ Then install dependencies
yarn install
```
You will also need to have Python 3 installed, in order to build and run the tests of `abi-gen`'s command-line interface, which is integrated with the yarn build, yarn test, and yarn lint commands described below. More specifically, your local pip should resolve to the Python 3 version of pip, not a Python 2.x version.
### Build
To build all packages:
@@ -92,7 +142,7 @@ yarn build
To build a specific package:
```bash
PKG=@0x/contract-wrappers yarn build
PKG=@0x/web3-wrapper yarn build
```
To build all contracts packages:
@@ -115,7 +165,7 @@ To watch a specific package and all it's dependent packages:
PKG=[NPM_PACKAGE_NAME] yarn watch
e.g
PKG=@0x/contract-wrappers yarn watch
PKG=@0x/web3-wrapper yarn watch
```
### Clean
@@ -143,7 +193,7 @@ yarn rebuild
To re-build (clean & build) a specific package & it's deps:
```bash
PKG=@0x/contract-wrappers yarn rebuild
PKG=0x.js yarn rebuild
```
### Lint
@@ -157,7 +207,7 @@ yarn lint
Lint a specific package:
```bash
PKG=@0x/contract-wrappers yarn lint
PKG=0x.js yarn lint
```
### Run Tests
@@ -171,7 +221,7 @@ yarn test
Run a specific package's test:
```bash
PKG=@0x/contract-wrappers yarn test
PKG=@0x/web3-wrapper yarn test
```
Run all contracts packages tests:

View File

@@ -13,11 +13,9 @@
"indent": ["error", 4],
"max-line-length": ["warn", 160],
"no-inline-assembly": false,
"no-empty-blocks": false,
"quotes": ["error", "double"],
"separate-by-one-line-in-contract": "error",
"space-after-comma": "error",
"statement-indent": "error",
"no-empty-blocks": false
"statement-indent": "error"
}
}

View File

@@ -1,206 +1,4 @@
[
{
"timestamp": 1611648096,
"version": "3.7.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1610510890,
"version": "3.7.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1609802516,
"version": "3.7.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608692071,
"version": "3.7.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608245516,
"version": "3.7.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.7.0",
"changes": [
{
"note": "Fix Bancor support of ETH",
"pr": 88
}
],
"timestamp": 1608105788
},
{
"timestamp": 1607485227,
"version": "3.6.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "3.6.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "3.6.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605763885,
"version": "3.6.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605302002,
"version": "3.6.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604385937,
"version": "3.6.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604376968,
"version": "3.6.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604355662,
"version": "3.6.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603851023,
"version": "3.6.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.6.0",
"changes": [
{
"note": "Add `SwerveBridge` and `SnowSwapBridge` (duplicate of `CurveBridge`)",
"pr": 2707
}
],
"timestamp": 1603833198
},
{
"version": "3.5.0",
"changes": [
{
"note": "Update `CurveBridge` to support more varied curves",
"pr": 2633
},
{
"note": "Export DexForwarderBridgeContract",
"pr": 2656
},
{
"note": "Add BancorBridge and IBancorNetwork, ",
"pr": 2650
},
{
"note": "Added `MStableBridge`",
"pr": 2662
},
{
"note": "Added `MooniswapBridge`",
"pr": 2675
},
{
"note": "Reworked `KyberBridge`",
"pr": 2683
},
{
"note": "Added `CreamBridge`",
"pr": 2715
},
{
"note": "Added `ShellBridge`",
"pr": 2722
},
{
"note": "Added `DODOBridge`",
"pr": 2701
}
],
"timestamp": 1603265572
},
{
"version": "3.4.0",
"changes": [
{
"note": "Fix instability with DFB.",
"pr": 2616
},
{
"note": "Add `BalancerBridge`",
"pr": 2613
}
],
"timestamp": 1594788383
},
{
"version": "3.3.0",
"changes": [

View File

@@ -5,87 +5,6 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.7.5 - _January 26, 2021_
* Dependencies updated
## v3.7.4 - _January 13, 2021_
* Dependencies updated
## v3.7.3 - _January 4, 2021_
* Dependencies updated
## v3.7.2 - _December 23, 2020_
* Dependencies updated
## v3.7.1 - _December 17, 2020_
* Dependencies updated
## v3.7.0 - _December 16, 2020_
* Fix Bancor support of ETH (#88)
## v3.6.9 - _December 9, 2020_
* Dependencies updated
## v3.6.8 - _December 7, 2020_
* Dependencies updated
## v3.6.7 - _December 3, 2020_
* Dependencies updated
## v3.6.6 - _November 19, 2020_
* Dependencies updated
## v3.6.5 - _November 13, 2020_
* Dependencies updated
## v3.6.4 - _November 3, 2020_
* Dependencies updated
## v3.6.3 - _November 3, 2020_
* Dependencies updated
## v3.6.2 - _November 2, 2020_
* Dependencies updated
## v3.6.1 - _October 28, 2020_
* Dependencies updated
## v3.6.0 - _October 27, 2020_
* Add `SwerveBridge` and `SnowSwapBridge` (duplicate of `CurveBridge`) (#2707)
## v3.5.0 - _October 21, 2020_
* Update `CurveBridge` to support more varied curves (#2633)
* Export DexForwarderBridgeContract (#2656)
* Add BancorBridge and IBancorNetwork, (#2650)
* Added `MStableBridge` (#2662)
* Added `MooniswapBridge` (#2675)
* Reworked `KyberBridge` (#2683)
* Added `CreamBridge` (#2715)
* Added `ShellBridge` (#2722)
* Added `DODOBridge` (#2701)
## v3.4.0 - _July 15, 2020_
* Fix instability with DFB. (#2616)
* Add `BalancerBridge` (#2613)
## v3.3.0 - _June 24, 2020_
* Use `LibERC20Token.approveIfBelow()` in DEX bridges for for approvals. (#2512)

View File

@@ -1,103 +0,0 @@
/*
Copyright 2020 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/IBalancerPool.sol";
contract BalancerBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data, then transfers the bought
/// tokens to `to`.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded addresses of the "from" token and Balancer pool.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// Decode the bridge data.
(address fromTokenAddress, address poolAddress) = abi.decode(
bridgeData,
(address, address)
);
require(toTokenAddress != fromTokenAddress, "BalancerBridge/INVALID_PAIR");
uint256 fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approveIfBelow(fromTokenAddress, poolAddress, fromTokenBalance);
// Sell all of this contract's `fromTokenAddress` token balance.
(uint256 boughtAmount,) = IBalancerPool(poolAddress).swapExactAmountIn(
fromTokenAddress, // tokenIn
fromTokenBalance, // tokenAmountIn
toTokenAddress, // tokenOut
amount, // minAmountOut
uint256(-1) // maxPrice
);
// Transfer the converted `toToken`s to `to`.
LibERC20Token.transfer(toTokenAddress, to, boughtAmount);
emit ERC20BridgeTransfer(
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Magic success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,144 +0,0 @@
/*
Copyright 2020 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/IBancorNetwork.sol";
contract BancorBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
struct TransferState {
address bancorNetworkAddress;
address[] path;
IEtherToken weth;
}
/// @dev Bancor ETH pseudo-address.
address constant public BANCOR_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// solhint-disable no-empty-blocks
/// @dev Payable fallback to receive ETH from Bancor/WETH.
function ()
external
payable
{
// Poor man's receive in 0.5.9
require(msg.data.length == 0);
}
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data, then transfers the bought
/// tokens to `to`.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded conversion path addresses and Bancor network address
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// hold variables to get around stack depth limitations
TransferState memory state;
// Decode the bridge data.
(
state.path,
state.bancorNetworkAddress
// solhint-disable indent
) = abi.decode(bridgeData, (address[], address));
// solhint-enable indent
state.weth = IEtherToken(_getWethAddress());
require(state.path.length >= 2, "BancorBridge/PATH_LENGTH_MUST_BE_GREATER_THAN_TWO");
// Grant an allowance to the Bancor Network to spend `fromTokenAddress` token.
uint256 fromTokenBalance;
uint256 payableAmount = 0;
// If it's ETH in the path then withdraw from WETH
// The Bancor path will have ETH as the 0xeee address
// Bancor expects to be paid in ETH not WETH
if (state.path[0] == BANCOR_ETH_ADDRESS) {
fromTokenBalance = state.weth.balanceOf(address(this));
state.weth.withdraw(fromTokenBalance);
payableAmount = fromTokenBalance;
} else {
fromTokenBalance = IERC20Token(state.path[0]).balanceOf(address(this));
LibERC20Token.approveIfBelow(state.path[0], state.bancorNetworkAddress, fromTokenBalance);
}
// Convert the tokens
uint256 boughtAmount = IBancorNetwork(state.bancorNetworkAddress).convertByPath.value(payableAmount)(
state.path, // path originating with source token and terminating in destination token
fromTokenBalance, // amount of source token to trade
amount, // minimum amount of destination token expected to receive
state.path[state.path.length-1] == BANCOR_ETH_ADDRESS ? address(this) : to, // beneficiary
address(0), // affiliateAccount; no fee paid
0 // affiliateFee; no fee paid
);
if (state.path[state.path.length-1] == BANCOR_ETH_ADDRESS) {
state.weth.deposit.value(boughtAmount)();
state.weth.transfer(to, boughtAmount);
}
emit ERC20BridgeTransfer(
state.path[0] == BANCOR_ETH_ADDRESS ? address(state.weth) : state.path[0],
toTokenAddress,
fromTokenBalance,
boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Magic success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,103 +0,0 @@
/*
Copyright 2020 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/IBalancerPool.sol";
contract CreamBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data, then transfers the bought
/// tokens to `to`.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded addresses of the "from" token and Balancer pool.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// Decode the bridge data.
(address fromTokenAddress, address poolAddress) = abi.decode(
bridgeData,
(address, address)
);
require(toTokenAddress != fromTokenAddress, "CreamBridge/INVALID_PAIR");
uint256 fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approveIfBelow(fromTokenAddress, poolAddress, fromTokenBalance);
// Sell all of this contract's `fromTokenAddress` token balance.
(uint256 boughtAmount,) = IBalancerPool(poolAddress).swapExactAmountIn(
fromTokenAddress, // tokenIn
fromTokenBalance, // tokenAmountIn
toTokenAddress, // tokenOut
amount, // minAmountOut
uint256(-1) // maxPrice
);
// Transfer the converted `toToken`s to `to`.
LibERC20Token.transfer(toTokenAddress, to, boughtAmount);
emit ERC20BridgeTransfer(
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Magic success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,136 +0,0 @@
/*
Copyright 2020 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IUniswapV2Router01.sol";
import "../interfaces/IERC20Bridge.sol";
// solhint-disable space-after-comma
// solhint-disable not-rely-on-time
contract CryptoComBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
struct TransferState {
address[] path;
address router;
uint256 fromTokenBalance;
}
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded path of token addresses. Last element must be toTokenAddress
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// hold variables to get around stack depth limitations
TransferState memory state;
// Decode the bridge data to get the `fromTokenAddress`.
// solhint-disable indent
(state.path, state.router) = abi.decode(bridgeData, (address[], address));
// solhint-enable indent
require(state.path.length >= 2, "CryptoComBridge/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
require(state.path[state.path.length - 1] == toTokenAddress, "CryptoComBridge/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN");
// Just transfer the tokens if they're the same.
if (state.path[0] == toTokenAddress) {
LibERC20Token.transfer(state.path[0], to, amount);
return BRIDGE_SUCCESS;
}
// Get our balance of `fromTokenAddress` token.
state.fromTokenBalance = IERC20Token(state.path[0]).balanceOf(address(this));
// Grant the SushiSwap router an allowance.
LibERC20Token.approveIfBelow(
state.path[0],
state.router,
state.fromTokenBalance
);
// Buy as much `toTokenAddress` token with `fromTokenAddress` token
// and transfer it to `to`.
IUniswapV2Router01 router = IUniswapV2Router01(state.router);
uint[] memory amounts = router.swapExactTokensForTokens(
// Sell all tokens we hold.
state.fromTokenBalance,
// Minimum buy amount.
amount,
// Convert `fromTokenAddress` to `toTokenAddress`.
state.path,
// Recipient is `to`.
to,
// Expires after this block.
block.timestamp
);
emit ERC20BridgeTransfer(
// input token
state.path[0],
// output token
toTokenAddress,
// input token amount
state.fromTokenBalance,
// output token amount
amounts[amounts.length - 1],
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -26,6 +26,7 @@ import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/ICurve.sol";
import "./MixinGasToken.sol";
// solhint-disable not-rely-on-time
@@ -33,14 +34,14 @@ import "../interfaces/ICurve.sol";
contract CurveBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
DeploymentConstants,
MixinGasToken
{
struct CurveBridgeData {
address curveAddress;
bytes4 exchangeFunctionSelector;
address fromTokenAddress;
int128 fromCoinIdx;
int128 toCoinIdx;
int128 version;
}
/// @dev Callback for `ICurve`. Tries to buy `amount` of
@@ -61,31 +62,39 @@ contract CurveBridge is
bytes calldata bridgeData
)
external
freesGasTokensFromCollector
returns (bytes4 success)
{
// Decode the bridge data to get the Curve metadata.
CurveBridgeData memory data = abi.decode(bridgeData, (CurveBridgeData));
require(toTokenAddress != data.fromTokenAddress, "CurveBridge/INVALID_PAIR");
uint256 fromTokenBalance = IERC20Token(data.fromTokenAddress).balanceOf(address(this));
address fromTokenAddress = ICurve(data.curveAddress).underlying_coins(data.fromCoinIdx);
require(toTokenAddress != fromTokenAddress, "CurveBridge/INVALID_PAIR");
uint256 fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approveIfBelow(data.fromTokenAddress, data.curveAddress, fromTokenBalance);
LibERC20Token.approveIfBelow(fromTokenAddress, data.curveAddress, fromTokenBalance);
// Try to sell all of this contract's `fromTokenAddress` token balance.
{
(bool didSucceed, bytes memory resultData) =
data.curveAddress.call(abi.encodeWithSelector(
data.exchangeFunctionSelector,
data.fromCoinIdx,
data.toCoinIdx,
// dx
fromTokenBalance,
// min dy
amount
));
if (!didSucceed) {
assembly { revert(add(resultData, 32), mload(resultData)) }
}
if (data.version == 0) {
ICurve(data.curveAddress).exchange_underlying(
data.fromCoinIdx,
data.toCoinIdx,
// dx
fromTokenBalance,
// min dy
amount,
// expires
block.timestamp + 1
);
} else {
ICurve(data.curveAddress).exchange_underlying(
data.fromCoinIdx,
data.toCoinIdx,
// dx
fromTokenBalance,
// min dy
amount
);
}
uint256 toTokenBalance = IERC20Token(toTokenAddress).balanceOf(address(this));
@@ -93,7 +102,7 @@ contract CurveBridge is
LibERC20Token.transfer(toTokenAddress, to, toTokenBalance);
emit ERC20BridgeTransfer(
data.fromTokenAddress,
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
toTokenBalance,

View File

@@ -1,147 +0,0 @@
/*
Copyright 2020 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
interface IDODOHelper {
function querySellQuoteToken(address dodo, uint256 amount) external view returns (uint256);
}
interface IDODO {
function sellBaseToken(uint256 amount, uint256 minReceiveQuote, bytes calldata data) external returns (uint256);
function buyBaseToken(uint256 amount, uint256 maxPayQuote, bytes calldata data) external returns (uint256);
}
contract DODOBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
struct TransferState {
address fromTokenAddress;
uint256 fromTokenBalance;
address pool;
bool isSellBase;
}
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded path of token addresses. Last element must be toTokenAddress
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
TransferState memory state;
// Decode the bridge data to get the `fromTokenAddress`.
(state.fromTokenAddress, state.pool, state.isSellBase) = abi.decode(bridgeData, (address, address, bool));
require(state.pool != address(0), "DODOBridge/InvalidPool");
IDODO exchange = IDODO(state.pool);
// Get our balance of `fromTokenAddress` token.
state.fromTokenBalance = IERC20Token(state.fromTokenAddress).balanceOf(address(this));
// Grant the pool an allowance.
LibERC20Token.approveIfBelow(
state.fromTokenAddress,
address(exchange),
state.fromTokenBalance
);
uint256 boughtAmount;
if (state.isSellBase) {
boughtAmount = exchange.sellBaseToken(
// amount to sell
state.fromTokenBalance,
// min receive amount
1,
new bytes(0)
);
} else {
// Need to re-calculate the sell quote amount into buyBase
boughtAmount = IDODOHelper(_getDODOHelperAddress()).querySellQuoteToken(
address(exchange),
state.fromTokenBalance
);
exchange.buyBaseToken(
// amount to buy
boughtAmount,
// max pay amount
state.fromTokenBalance,
new bytes(0)
);
}
// Transfer funds to `to`
IERC20Token(toTokenAddress).transfer(to, boughtAmount);
emit ERC20BridgeTransfer(
// input token
state.fromTokenAddress,
// output token
toTokenAddress,
// input token amount
state.fromTokenBalance,
// output token amount
boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -75,18 +75,14 @@ contract DexForwarderBridge is
freesGasTokensFromCollector
returns (bytes4 success)
{
require(
msg.sender == _getERC20BridgeProxyAddress(),
"DexForwarderBridge/SENDER_NOT_AUTHORIZED"
);
require(msg.sender == _getERC20BridgeProxyAddress(), "DexForwarderBridge/SENDER_NOT_AUTHORIZED");
TransferFromState memory state;
(
state.inputToken,
state.calls
) = abi.decode(bridgeData, (address, BridgeCall[]));
state.initialInputTokenBalance =
IERC20Token(state.inputToken).balanceOf(address(this));
state.initialInputTokenBalance = IERC20Token(state.inputToken).balanceOf(address(this));
for (uint256 i = 0; i < state.calls.length; ++i) {
// Stop if the we've sold all our input tokens.
@@ -126,6 +122,11 @@ contract DexForwarderBridge is
);
}
}
// Revert if we were not able to sell our entire input token balance.
require(
state.totalInputTokenSold >= state.initialInputTokenBalance,
"DexForwarderBridge/INCOMPLETE_FILL"
);
// Always succeed.
return BRIDGE_SUCCESS;
}

View File

@@ -1,6 +1,6 @@
/*
Copyright 2020 ZeroEx Intl.
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -45,7 +45,6 @@ contract KyberBridge is
uint256 fromTokenBalance;
uint256 payableAmount;
uint256 conversionRate;
bytes hint;
}
/// @dev Kyber ETH pseudo-address.
@@ -56,14 +55,11 @@ contract KyberBridge is
uint256 constant private KYBER_RATE_BASE = 10 ** 18;
// solhint-disable no-empty-blocks
/// @dev Payable fallback to receive ETH from Kyber/WETH.
/// @dev Payable fallback to receive ETH from Kyber.
function ()
external
payable
{
// Poor man's receive in 0.5.9
require(msg.data.length == 0);
}
{}
/// @dev Callback for `IKyberBridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the opposing asset
@@ -89,35 +85,47 @@ contract KyberBridge is
state.kyber = IKyberNetworkProxy(_getKyberNetworkProxyAddress());
state.weth = IEtherToken(_getWethAddress());
// Decode the bridge data to get the `fromTokenAddress`.
(state.fromTokenAddress, state.hint) = abi.decode(bridgeData, (address, bytes));
(state.fromTokenAddress) = abi.decode(bridgeData, (address));
// Query the balance of "from" tokens.
state.fromTokenBalance = IERC20Token(state.fromTokenAddress).balanceOf(address(this));
if (state.fromTokenBalance == 0) {
// Return failure if no input tokens.
return BRIDGE_FAILED;
}
// Compute the conversion rate, expressed in 18 decimals.
// The sequential notation is to get around stack limits.
state.conversionRate = KYBER_RATE_BASE;
state.conversionRate = state.conversionRate.safeMul(amount);
state.conversionRate = state.conversionRate.safeMul(
10 ** uint256(LibERC20Token.decimals(state.fromTokenAddress))
);
state.conversionRate = state.conversionRate.safeDiv(state.fromTokenBalance);
state.conversionRate = state.conversionRate.safeDiv(
10 ** uint256(LibERC20Token.decimals(toTokenAddress))
);
if (state.fromTokenAddress == toTokenAddress) {
// Just transfer the tokens if they're the same.
LibERC20Token.transfer(state.fromTokenAddress, to, state.fromTokenBalance);
return BRIDGE_SUCCESS;
}
if (state.fromTokenAddress == address(state.weth)) {
// From WETH
state.fromTokenAddress = KYBER_ETH_ADDRESS;
state.payableAmount = state.fromTokenBalance;
state.weth.withdraw(state.fromTokenBalance);
} else {
} else if (state.fromTokenAddress != address(state.weth)) {
// If the input token is not WETH, grant an allowance to the exchange
// to spend them.
LibERC20Token.approveIfBelow(
state.fromTokenAddress,
address(state.kyber),
state.fromTokenBalance
);
} else {
// If the input token is WETH, unwrap it and attach it to the call.
state.fromTokenAddress = KYBER_ETH_ADDRESS;
state.payableAmount = state.fromTokenBalance;
state.weth.withdraw(state.fromTokenBalance);
}
bool isToTokenWeth = toTokenAddress == address(state.weth);
// Try to sell all of this contract's input token balance through
// `KyberNetworkProxy.trade()`.
uint256 boughtAmount = state.kyber.tradeWithHint.value(state.payableAmount)(
uint256 boughtAmount = state.kyber.trade.value(state.payableAmount)(
// Input token.
state.fromTokenAddress,
// Sell amount.
@@ -129,11 +137,11 @@ contract KyberBridge is
isToTokenWeth ? address(uint160(address(this))) : address(uint160(to)),
// Buy as much as possible.
uint256(-1),
// The minimum conversion rate
1,
// Compute the minimum conversion rate, which is expressed in units with
// 18 decimal places.
state.conversionRate,
// No affiliate address.
address(0),
state.hint
address(0)
);
// Wrap ETH output and transfer to recipient.
if (isToTokenWeth) {
@@ -165,5 +173,4 @@ contract KyberBridge is
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,94 +0,0 @@
/*
Copyright 2019 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/IMStable.sol";
contract MStableBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
/// @dev Swaps specified tokens against the mStable mUSD contract
/// @param toTokenAddress The token to give to `to` (i.e DAI, USDC, USDT).
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded "from" token address.
/// @return success The magic bytes if successful.
// solhint-disable no-unused-vars
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// Decode the bridge data to get the `fromTokenAddress`.
(address fromTokenAddress) = abi.decode(bridgeData, (address));
IMStable exchange = IMStable(_getMUsdAddress());
uint256 fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approveIfBelow(fromTokenAddress, address(exchange), fromTokenBalance);
// Try to sell all of this contract's `fromTokenAddress` token balance.
uint256 boughtAmount = exchange.swap(
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
to
);
emit ERC20BridgeTransfer(
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Magic success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,148 +0,0 @@
/*
Copyright 2020 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/IMooniswap.sol";
// solhint-disable space-after-comma
// solhint-disable not-rely-on-time
contract MooniswapBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
struct TransferState {
IMooniswap pool;
uint256 fromTokenBalance;
IEtherToken weth;
uint256 boughtAmount;
address fromTokenAddress;
address toTokenAddress;
}
// solhint-disable no-empty-blocks
/// @dev Payable fallback to receive ETH from uniswap.
function ()
external
payable
{}
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded path of token addresses. Last element must be toTokenAddress
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// State memory object to avoid stack overflows.
TransferState memory state;
// Decode the bridge data to get the `fromTokenAddress`.
address fromTokenAddress = abi.decode(bridgeData, (address));
// Get the weth contract.
state.weth = IEtherToken(_getWethAddress());
// Get our balance of `fromTokenAddress` token.
state.fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
state.fromTokenAddress = fromTokenAddress == address(state.weth) ? address(0) : fromTokenAddress;
state.toTokenAddress = toTokenAddress == address(state.weth) ? address(0) : toTokenAddress;
state.pool = IMooniswap(
IMooniswapRegistry(_getMooniswapAddress()).pools(
state.fromTokenAddress,
state.toTokenAddress
)
);
// withdraw WETH to ETH
if (state.fromTokenAddress == address(0)) {
state.weth.withdraw(state.fromTokenBalance);
} else {
// Grant the pool an allowance.
LibERC20Token.approveIfBelow(
state.fromTokenAddress,
address(state.pool),
state.fromTokenBalance
);
}
uint256 ethValue = state.fromTokenAddress == address(0) ? state.fromTokenBalance : 0;
state.boughtAmount = state.pool.swap.value(ethValue)(
state.fromTokenAddress,
state.toTokenAddress,
state.fromTokenBalance,
amount,
address(0)
);
// Deposit to WETH
if (state.toTokenAddress == address(0)) {
state.weth.deposit.value(state.boughtAmount)();
}
// Transfer funds to `to`
LibERC20Token.transfer(toTokenAddress, to, state.boughtAmount);
emit ERC20BridgeTransfer(
// input token
fromTokenAddress,
// output token
toTokenAddress,
// input token amount
state.fromTokenBalance,
// output token amount
state.boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,95 +0,0 @@
/*
Copyright 2019 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/IShell.sol";
contract ShellBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
/// @dev Swaps specified tokens against the Shell contract
/// @param toTokenAddress The token to give to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded "from" token address.
/// @return success The magic bytes if successful.
// solhint-disable no-unused-vars
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// Decode the bridge data to get the `fromTokenAddress` and `pool`.
(address fromTokenAddress, address pool) = abi.decode(bridgeData, (address, address));
uint256 fromTokenBalance = IERC20Token(fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approveIfBelow(fromTokenAddress, pool, fromTokenBalance);
// Try to sell all of this contract's `fromTokenAddress` token balance.
uint256 boughtAmount = IShell(pool).originSwap(
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
amount, // min amount
block.timestamp + 1
);
LibERC20Token.transfer(toTokenAddress, to, boughtAmount);
emit ERC20BridgeTransfer(
fromTokenAddress,
toTokenAddress,
fromTokenBalance,
boughtAmount,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Magic success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,119 +0,0 @@
/*
Copyright 2019 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/ICurve.sol";
// solhint-disable not-rely-on-time
// solhint-disable space-after-comma
contract SnowSwapBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
struct SnowSwapBridgeData {
address curveAddress;
bytes4 exchangeFunctionSelector;
address fromTokenAddress;
int128 fromCoinIdx;
int128 toCoinIdx;
}
/// @dev Callback for `ICurve`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the opposing asset
/// (DAI, USDC) to the Curve contract, then transfers the bought
/// tokens to `to`.
/// @param toTokenAddress The token to give to `to` (i.e DAI, USDC, USDT).
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoeded "from" token address.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// Decode the bridge data to get the SnowSwap metadata.
SnowSwapBridgeData memory data = abi.decode(bridgeData, (SnowSwapBridgeData));
require(toTokenAddress != data.fromTokenAddress, "SnowSwapBridge/INVALID_PAIR");
uint256 fromTokenBalance = IERC20Token(data.fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approveIfBelow(data.fromTokenAddress, data.curveAddress, fromTokenBalance);
// Try to sell all of this contract's `fromTokenAddress` token balance.
{
(bool didSucceed, bytes memory resultData) =
data.curveAddress.call(abi.encodeWithSelector(
data.exchangeFunctionSelector,
data.fromCoinIdx,
data.toCoinIdx,
// dx
fromTokenBalance,
// min dy
amount
));
if (!didSucceed) {
assembly { revert(add(resultData, 32), mload(resultData)) }
}
}
uint256 toTokenBalance = IERC20Token(toTokenAddress).balanceOf(address(this));
// Transfer the converted `toToken`s to `to`.
LibERC20Token.transfer(toTokenAddress, to, toTokenBalance);
emit ERC20BridgeTransfer(
data.fromTokenAddress,
toTokenAddress,
fromTokenBalance,
toTokenBalance,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Magic success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,136 +0,0 @@
/*
Copyright 2020 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IUniswapV2Router01.sol";
import "../interfaces/IERC20Bridge.sol";
// solhint-disable space-after-comma
// solhint-disable not-rely-on-time
contract SushiSwapBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
struct TransferState {
address[] path;
address router;
uint256 fromTokenBalance;
}
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the `fromTokenAddress`
/// token encoded in the bridge data.
/// @param toTokenAddress The token to buy and transfer to `to`.
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoded path of token addresses. Last element must be toTokenAddress
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// hold variables to get around stack depth limitations
TransferState memory state;
// Decode the bridge data to get the `fromTokenAddress`.
// solhint-disable indent
(state.path, state.router) = abi.decode(bridgeData, (address[], address));
// solhint-enable indent
require(state.path.length >= 2, "SushiSwapBridge/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
require(state.path[state.path.length - 1] == toTokenAddress, "SushiSwapBridge/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN");
// Just transfer the tokens if they're the same.
if (state.path[0] == toTokenAddress) {
LibERC20Token.transfer(state.path[0], to, amount);
return BRIDGE_SUCCESS;
}
// Get our balance of `fromTokenAddress` token.
state.fromTokenBalance = IERC20Token(state.path[0]).balanceOf(address(this));
// Grant the SushiSwap router an allowance.
LibERC20Token.approveIfBelow(
state.path[0],
state.router,
state.fromTokenBalance
);
// Buy as much `toTokenAddress` token with `fromTokenAddress` token
// and transfer it to `to`.
IUniswapV2Router01 router = IUniswapV2Router01(state.router);
uint[] memory amounts = router.swapExactTokensForTokens(
// Sell all tokens we hold.
state.fromTokenBalance,
// Minimum buy amount.
amount,
// Convert `fromTokenAddress` to `toTokenAddress`.
state.path,
// Recipient is `to`.
to,
// Expires after this block.
block.timestamp
);
emit ERC20BridgeTransfer(
// input token
state.path[0],
// output token
toTokenAddress,
// input token amount
state.fromTokenBalance,
// output token amount
amounts[amounts.length - 1],
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,119 +0,0 @@
/*
Copyright 2019 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
import "../interfaces/IERC20Bridge.sol";
import "../interfaces/ICurve.sol";
// solhint-disable not-rely-on-time
// solhint-disable space-after-comma
contract SwerveBridge is
IERC20Bridge,
IWallet,
DeploymentConstants
{
struct SwerveBridgeData {
address curveAddress;
bytes4 exchangeFunctionSelector;
address fromTokenAddress;
int128 fromCoinIdx;
int128 toCoinIdx;
}
/// @dev Callback for `ICurve`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the opposing asset
/// (DAI, USDC) to the Curve contract, then transfers the bought
/// tokens to `to`.
/// @param toTokenAddress The token to give to `to` (i.e DAI, USDC, USDT).
/// @param from The maker (this contract).
/// @param to The recipient of the bought tokens.
/// @param amount Minimum amount of `toTokenAddress` tokens to buy.
/// @param bridgeData The abi-encoeded "from" token address.
/// @return success The magic bytes if successful.
function bridgeTransferFrom(
address toTokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success)
{
// Decode the bridge data to get the SwerveBridgeData metadata.
SwerveBridgeData memory data = abi.decode(bridgeData, (SwerveBridgeData));
require(toTokenAddress != data.fromTokenAddress, "SwerveBridge/INVALID_PAIR");
uint256 fromTokenBalance = IERC20Token(data.fromTokenAddress).balanceOf(address(this));
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
LibERC20Token.approveIfBelow(data.fromTokenAddress, data.curveAddress, fromTokenBalance);
// Try to sell all of this contract's `fromTokenAddress` token balance.
{
(bool didSucceed, bytes memory resultData) =
data.curveAddress.call(abi.encodeWithSelector(
data.exchangeFunctionSelector,
data.fromCoinIdx,
data.toCoinIdx,
// dx
fromTokenBalance,
// min dy
amount
));
if (!didSucceed) {
assembly { revert(add(resultData, 32), mload(resultData)) }
}
}
uint256 toTokenBalance = IERC20Token(toTokenAddress).balanceOf(address(this));
// Transfer the converted `toToken`s to `to`.
LibERC20Token.transfer(toTokenAddress, to, toTokenBalance);
emit ERC20BridgeTransfer(
data.fromTokenAddress,
toTokenAddress,
fromTokenBalance,
toTokenBalance,
from,
to
);
return BRIDGE_SUCCESS;
}
/// @dev `SignatureType.Wallet` callback, so that this bridge can be the maker
/// and sign for itself in orders. Always succeeds.
/// @return magicValue Magic success bytes, always.
function isValidSignature(
bytes32,
bytes calldata
)
external
view
returns (bytes4 magicValue)
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -1,39 +0,0 @@
/*
Copyright 2020 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.5.9;
interface IBalancerPool {
/// @dev Sell `tokenAmountIn` of `tokenIn` and receive `tokenOut`.
/// @param tokenIn The token being sold
/// @param tokenAmountIn The amount of `tokenIn` to sell.
/// @param tokenOut The token being bought.
/// @param minAmountOut The minimum amount of `tokenOut` to buy.
/// @param maxPrice The maximum value for `spotPriceAfter`.
/// @return tokenAmountOut The amount of `tokenOut` bought.
/// @return spotPriceAfter The new marginal spot price of the given
/// token pair for this pool.
function swapExactAmountIn(
address tokenIn,
uint tokenAmountIn,
address tokenOut,
uint minAmountOut,
uint maxPrice
) external returns (uint tokenAmountOut, uint spotPriceAfter);
}

View File

@@ -1,38 +0,0 @@
/*
Copyright 2020 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.5.9;
contract IContractRegistry {
function addressOf(
bytes32 contractName
) external returns(address);
}
contract IBancorNetwork {
function convertByPath(
address[] calldata _path,
uint256 _amount,
uint256 _minReturn,
address _beneficiary,
address _affiliateAccount,
uint256 _affiliateFee
) external payable returns (uint256);
}

View File

@@ -22,6 +22,22 @@ pragma solidity ^0.5.9;
// solhint-disable func-name-mixedcase
interface ICurve {
/// @dev Sell `sellAmount` of `fromToken` token and receive `toToken` token.
/// This function exists on early versions of Curve (USDC/DAI)
/// @param i The token index being sold.
/// @param j The token index being bought.
/// @param sellAmount The amount of token being bought.
/// @param minBuyAmount The minimum buy amount of the token being bought.
/// @param deadline The time in seconds when this operation should expire.
function exchange_underlying(
int128 i,
int128 j,
uint256 sellAmount,
uint256 minBuyAmount,
uint256 deadline
)
external;
/// @dev Sell `sellAmount` of `fromToken` token and receive `toToken` token.
/// This function exists on later versions of Curve (USDC/DAI/USDT)
/// @param i The token index being sold.

View File

@@ -42,31 +42,5 @@ interface IKyberNetworkProxy {
)
external
payable
returns (uint256 boughtAmount);
/// @dev Sells `sellTokenAddress` tokens for `buyTokenAddress` tokens
/// using a hint for the reserve.
/// @param sellTokenAddress Token to sell.
/// @param sellAmount Amount of tokens to sell.
/// @param buyTokenAddress Token to buy.
/// @param recipientAddress Address to send bought tokens to.
/// @param maxBuyTokenAmount A limit on the amount of tokens to buy.
/// @param minConversionRate The minimal conversion rate. If actual rate
/// is lower, trade is canceled.
/// @param walletId The wallet ID to send part of the fees
/// @param hint The hint for the selective inclusion (or exclusion) of reserves
/// @return boughtAmount Amount of tokens bought.
function tradeWithHint(
address sellTokenAddress,
uint256 sellAmount,
address buyTokenAddress,
address payable recipientAddress,
uint256 maxBuyTokenAmount,
uint256 minConversionRate,
address payable walletId,
bytes calldata hint
)
external
payable
returns (uint256 boughtAmount);
returns(uint256 boughtAmount);
}

View File

@@ -1,247 +0,0 @@
/*
Copyright 2019 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
import "../src/bridges/BancorBridge.sol";
import "../src/interfaces/IBancorNetwork.sol";
contract TestEventsRaiser {
event TokenTransfer(
address token,
address from,
address to,
uint256 amount
);
event TokenApprove(
address spender,
uint256 allowance
);
event ConvertByPathInput(
uint amountIn,
uint amountOutMin,
address toTokenAddress,
address to,
address feeRecipient,
uint256 feeAmount
);
function raiseTokenTransfer(
address from,
address to,
uint256 amount
)
external
{
emit TokenTransfer(
msg.sender,
from,
to,
amount
);
}
function raiseTokenApprove(address spender, uint256 allowance) external {
emit TokenApprove(spender, allowance);
}
function raiseConvertByPathInput(
uint amountIn,
uint amountOutMin,
address toTokenAddress,
address to,
address feeRecipient,
uint256 feeAmount
) external
{
emit ConvertByPathInput(
amountIn,
amountOutMin,
toTokenAddress,
to,
feeRecipient,
feeAmount
);
}
}
/// @dev A minimalist ERC20 token.
contract TestToken {
using LibSafeMath for uint256;
mapping (address => uint256) public balances;
string private _nextRevertReason;
/// @dev Set the balance for `owner`.
function setBalance(address owner, uint256 balance)
external
payable
{
balances[owner] = balance;
}
/// @dev Just emits a TokenTransfer event on the caller
function transfer(address to, uint256 amount)
external
returns (bool)
{
TestEventsRaiser(msg.sender).raiseTokenTransfer(msg.sender, to, amount);
return true;
}
/// @dev Just emits a TokenApprove event on the caller
function approve(address spender, uint256 allowance)
external
returns (bool)
{
TestEventsRaiser(msg.sender).raiseTokenApprove(spender, allowance);
return true;
}
function allowance(address, address) external view returns (uint256) {
return 0;
}
/// @dev Retrieve the balance for `owner`.
function balanceOf(address owner)
external
view
returns (uint256)
{
return balances[owner];
}
}
/// @dev Mock the BancorNetwork contract
contract TestBancorNetwork is
IBancorNetwork
{
string private _nextRevertReason;
/// @dev Set the revert reason for `swapExactTokensForTokens`.
function setRevertReason(string calldata reason)
external
{
_nextRevertReason = reason;
}
function convertByPath(
address[] calldata _path,
uint256 _amount,
uint256 _minReturn,
address _beneficiary,
address _affiliateAccount,
uint256 _affiliateFee
) external payable returns (uint256)
{
_revertIfReasonExists();
TestEventsRaiser(msg.sender).raiseConvertByPathInput(
// tokens sold
_amount,
// tokens bought
_minReturn,
// output token
_path[_path.length - 1],
// recipient
_beneficiary,
// fee recipient
_affiliateAccount,
// fee amount
_affiliateFee
);
}
function _revertIfReasonExists()
private
view
{
if (bytes(_nextRevertReason).length != 0) {
revert(_nextRevertReason);
}
}
}
/// @dev BancorBridge overridden to mock tokens and BancorNetwork
contract TestBancorBridge is
BancorBridge,
TestEventsRaiser
{
// Token address to TestToken instance.
mapping (address => TestToken) private _testTokens;
// TestRouter instance.
TestBancorNetwork private _testNetwork;
constructor() public {
_testNetwork = new TestBancorNetwork();
}
function setNetworkRevertReason(string calldata revertReason)
external
{
_testNetwork.setRevertReason(revertReason);
}
/// @dev Sets the balance of this contract for an existing token.
function setTokenBalance(address tokenAddress, uint256 balance)
external
{
TestToken token = _testTokens[tokenAddress];
token.setBalance(address(this), balance);
}
/// @dev Create a new token
/// @param tokenAddress The token address. If zero, one will be created.
function createToken(
address tokenAddress
)
external
returns (TestToken token)
{
token = TestToken(tokenAddress);
if (tokenAddress == address(0)) {
token = new TestToken();
}
_testTokens[address(token)] = token;
return token;
}
function getNetworkAddress()
external
view
returns (address)
{
return address(_testNetwork);
}
}

View File

@@ -201,33 +201,6 @@ contract TestKyberBridge is
return _nextFillAmount;
}
function tradeWithHint(
address sellTokenAddress,
uint256 sellAmount,
address buyTokenAddress,
address payable recipientAddress,
uint256 maxBuyTokenAmount,
uint256 minConversionRate,
address payable walletId,
bytes calldata hint
)
external
payable
returns (uint256 boughtAmount)
{
emit KyberBridgeTrade(
msg.value,
sellTokenAddress,
sellAmount,
buyTokenAddress,
recipientAddress,
maxBuyTokenAmount,
minConversionRate,
walletId
);
return _nextFillAmount;
}
function createToken(uint8 decimals)
external
returns (address tokenAddress)

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-asset-proxy",
"version": "3.7.5",
"version": "3.3.0",
"engines": {
"node": ">=6.12"
},
@@ -38,31 +38,31 @@
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"abis": "./test/generated-artifacts/@(BalancerBridge|BancorBridge|ChaiBridge|CreamBridge|CryptoComBridge|CurveBridge|DODOBridge|DexForwarderBridge|DydxBridge|ERC1155Proxy|ERC20BridgeProxy|ERC20Proxy|ERC721Proxy|Eth2DaiBridge|IAssetData|IAssetProxy|IAssetProxyDispatcher|IAuthorizable|IBalancerPool|IBancorNetwork|IChai|ICurve|IDydx|IDydxBridge|IERC20Bridge|IEth2Dai|IGasToken|IKyberNetworkProxy|IMStable|IMooniswap|IShell|IUniswapExchange|IUniswapExchangeFactory|IUniswapV2Router01|KyberBridge|MStableBridge|MixinAssetProxyDispatcher|MixinAuthorizable|MixinGasToken|MooniswapBridge|MultiAssetProxy|Ownable|ShellBridge|SnowSwapBridge|StaticCallProxy|SushiSwapBridge|SwerveBridge|TestBancorBridge|TestChaiBridge|TestDexForwarderBridge|TestDydxBridge|TestERC20Bridge|TestEth2DaiBridge|TestKyberBridge|TestStaticCallTarget|TestUniswapBridge|TestUniswapV2Bridge|UniswapBridge|UniswapV2Bridge).json",
"abis": "./test/generated-artifacts/@(ChaiBridge|CurveBridge|DexForwarderBridge|DydxBridge|ERC1155Proxy|ERC20BridgeProxy|ERC20Proxy|ERC721Proxy|Eth2DaiBridge|IAssetData|IAssetProxy|IAssetProxyDispatcher|IAuthorizable|IChai|ICurve|IDydx|IDydxBridge|IERC20Bridge|IEth2Dai|IGasToken|IKyberNetworkProxy|IUniswapExchange|IUniswapExchangeFactory|IUniswapV2Router01|KyberBridge|MixinAssetProxyDispatcher|MixinAuthorizable|MixinGasToken|MultiAssetProxy|Ownable|StaticCallProxy|TestChaiBridge|TestDexForwarderBridge|TestDydxBridge|TestERC20Bridge|TestEth2DaiBridge|TestKyberBridge|TestStaticCallTarget|TestUniswapBridge|TestUniswapV2Bridge|UniswapBridge|UniswapV2Bridge).json",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/protocol.git"
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/protocol/issues"
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/protocol",
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.4.19",
"@0x/contract-wrappers": "^13.12.2",
"@0x/contracts-gen": "^2.0.30",
"@0x/contracts-test-utils": "^5.3.20",
"@0x/contracts-utils": "^4.7.2",
"@0x/dev-utils": "^4.2.1",
"@0x/sol-compiler": "^4.5.2",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/abi-gen": "^5.3.0",
"@0x/contract-wrappers": "^13.7.0",
"@0x/contracts-gen": "^2.0.9",
"@0x/contracts-test-utils": "^5.3.3",
"@0x/contracts-utils": "^4.5.0",
"@0x/dev-utils": "^3.2.2",
"@0x/sol-compiler": "^4.1.0",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
@@ -75,25 +75,24 @@
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.18",
"@0x/contracts-erc1155": "^2.1.23",
"@0x/contracts-erc20": "^3.3.2",
"@0x/contracts-erc721": "^3.1.23",
"@0x/contracts-exchange-libs": "^4.3.23",
"@0x/order-utils": "^10.4.15",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.2.0",
"@0x/web3-wrapper": "^7.4.1",
"ethereum-types": "^3.4.0",
"@0x/base-contract": "^6.2.2",
"@0x/contracts-erc1155": "^2.1.6",
"@0x/contracts-erc20": "^3.2.0",
"@0x/contracts-erc721": "^3.1.6",
"@0x/contracts-exchange-libs": "^4.3.6",
"@0x/order-utils": "^10.2.5",
"@0x/types": "^3.1.3",
"@0x/typescript-typings": "^5.1.0",
"@0x/utils": "^5.5.0",
"@0x/web3-wrapper": "^7.1.0",
"ethereum-types": "^3.1.1",
"lodash": "^4.17.11"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}
}

View File

@@ -5,14 +5,9 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as BalancerBridge from '../generated-artifacts/BalancerBridge.json';
import * as BancorBridge from '../generated-artifacts/BancorBridge.json';
import * as ChaiBridge from '../generated-artifacts/ChaiBridge.json';
import * as CreamBridge from '../generated-artifacts/CreamBridge.json';
import * as CryptoComBridge from '../generated-artifacts/CryptoComBridge.json';
import * as CurveBridge from '../generated-artifacts/CurveBridge.json';
import * as DexForwarderBridge from '../generated-artifacts/DexForwarderBridge.json';
import * as DODOBridge from '../generated-artifacts/DODOBridge.json';
import * as DydxBridge from '../generated-artifacts/DydxBridge.json';
import * as ERC1155Proxy from '../generated-artifacts/ERC1155Proxy.json';
import * as ERC20BridgeProxy from '../generated-artifacts/ERC20BridgeProxy.json';
@@ -23,8 +18,6 @@ import * as IAssetData from '../generated-artifacts/IAssetData.json';
import * as IAssetProxy from '../generated-artifacts/IAssetProxy.json';
import * as IAssetProxyDispatcher from '../generated-artifacts/IAssetProxyDispatcher.json';
import * as IAuthorizable from '../generated-artifacts/IAuthorizable.json';
import * as IBalancerPool from '../generated-artifacts/IBalancerPool.json';
import * as IBancorNetwork from '../generated-artifacts/IBancorNetwork.json';
import * as IChai from '../generated-artifacts/IChai.json';
import * as ICurve from '../generated-artifacts/ICurve.json';
import * as IDydx from '../generated-artifacts/IDydx.json';
@@ -33,9 +26,6 @@ import * as IERC20Bridge from '../generated-artifacts/IERC20Bridge.json';
import * as IEth2Dai from '../generated-artifacts/IEth2Dai.json';
import * as IGasToken from '../generated-artifacts/IGasToken.json';
import * as IKyberNetworkProxy from '../generated-artifacts/IKyberNetworkProxy.json';
import * as IMooniswap from '../generated-artifacts/IMooniswap.json';
import * as IMStable from '../generated-artifacts/IMStable.json';
import * as IShell from '../generated-artifacts/IShell.json';
import * as IUniswapExchange from '../generated-artifacts/IUniswapExchange.json';
import * as IUniswapExchangeFactory from '../generated-artifacts/IUniswapExchangeFactory.json';
import * as IUniswapV2Router01 from '../generated-artifacts/IUniswapV2Router01.json';
@@ -43,16 +33,9 @@ import * as KyberBridge from '../generated-artifacts/KyberBridge.json';
import * as MixinAssetProxyDispatcher from '../generated-artifacts/MixinAssetProxyDispatcher.json';
import * as MixinAuthorizable from '../generated-artifacts/MixinAuthorizable.json';
import * as MixinGasToken from '../generated-artifacts/MixinGasToken.json';
import * as MooniswapBridge from '../generated-artifacts/MooniswapBridge.json';
import * as MStableBridge from '../generated-artifacts/MStableBridge.json';
import * as MultiAssetProxy from '../generated-artifacts/MultiAssetProxy.json';
import * as Ownable from '../generated-artifacts/Ownable.json';
import * as ShellBridge from '../generated-artifacts/ShellBridge.json';
import * as SnowSwapBridge from '../generated-artifacts/SnowSwapBridge.json';
import * as StaticCallProxy from '../generated-artifacts/StaticCallProxy.json';
import * as SushiSwapBridge from '../generated-artifacts/SushiSwapBridge.json';
import * as SwerveBridge from '../generated-artifacts/SwerveBridge.json';
import * as TestBancorBridge from '../generated-artifacts/TestBancorBridge.json';
import * as TestChaiBridge from '../generated-artifacts/TestChaiBridge.json';
import * as TestDexForwarderBridge from '../generated-artifacts/TestDexForwarderBridge.json';
import * as TestDydxBridge from '../generated-artifacts/TestDydxBridge.json';
@@ -74,32 +57,19 @@ export const artifacts = {
ERC721Proxy: ERC721Proxy as ContractArtifact,
MultiAssetProxy: MultiAssetProxy as ContractArtifact,
StaticCallProxy: StaticCallProxy as ContractArtifact,
BalancerBridge: BalancerBridge as ContractArtifact,
BancorBridge: BancorBridge as ContractArtifact,
ChaiBridge: ChaiBridge as ContractArtifact,
CreamBridge: CreamBridge as ContractArtifact,
CryptoComBridge: CryptoComBridge as ContractArtifact,
CurveBridge: CurveBridge as ContractArtifact,
DODOBridge: DODOBridge as ContractArtifact,
DexForwarderBridge: DexForwarderBridge as ContractArtifact,
DydxBridge: DydxBridge as ContractArtifact,
Eth2DaiBridge: Eth2DaiBridge as ContractArtifact,
KyberBridge: KyberBridge as ContractArtifact,
MStableBridge: MStableBridge as ContractArtifact,
MixinGasToken: MixinGasToken as ContractArtifact,
MooniswapBridge: MooniswapBridge as ContractArtifact,
ShellBridge: ShellBridge as ContractArtifact,
SnowSwapBridge: SnowSwapBridge as ContractArtifact,
SushiSwapBridge: SushiSwapBridge as ContractArtifact,
SwerveBridge: SwerveBridge as ContractArtifact,
UniswapBridge: UniswapBridge as ContractArtifact,
UniswapV2Bridge: UniswapV2Bridge as ContractArtifact,
IAssetData: IAssetData as ContractArtifact,
IAssetProxy: IAssetProxy as ContractArtifact,
IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact,
IAuthorizable: IAuthorizable as ContractArtifact,
IBalancerPool: IBalancerPool as ContractArtifact,
IBancorNetwork: IBancorNetwork as ContractArtifact,
IChai: IChai as ContractArtifact,
ICurve: ICurve as ContractArtifact,
IDydx: IDydx as ContractArtifact,
@@ -108,13 +78,9 @@ export const artifacts = {
IEth2Dai: IEth2Dai as ContractArtifact,
IGasToken: IGasToken as ContractArtifact,
IKyberNetworkProxy: IKyberNetworkProxy as ContractArtifact,
IMStable: IMStable as ContractArtifact,
IMooniswap: IMooniswap as ContractArtifact,
IShell: IShell as ContractArtifact,
IUniswapExchange: IUniswapExchange as ContractArtifact,
IUniswapExchangeFactory: IUniswapExchangeFactory as ContractArtifact,
IUniswapV2Router01: IUniswapV2Router01 as ContractArtifact,
TestBancorBridge: TestBancorBridge as ContractArtifact,
TestChaiBridge: TestChaiBridge as ContractArtifact,
TestDexForwarderBridge: TestDexForwarderBridge as ContractArtifact,
TestDydxBridge: TestDydxBridge as ContractArtifact,

View File

@@ -1,6 +1,5 @@
export { artifacts } from './artifacts';
export {
BalancerBridgeContract,
ChaiBridgeContract,
ERC1155ProxyContract,
ERC20BridgeProxyContract,
@@ -18,7 +17,6 @@ export {
TestDydxBridgeContract,
TestStaticCallTargetContract,
UniswapBridgeContract,
DexForwarderBridgeContract,
} from './wrappers';
export { ERC20Wrapper } from './erc20_wrapper';

View File

@@ -3,13 +3,8 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/balancer_bridge';
export * from '../generated-wrappers/bancor_bridge';
export * from '../generated-wrappers/chai_bridge';
export * from '../generated-wrappers/cream_bridge';
export * from '../generated-wrappers/crypto_com_bridge';
export * from '../generated-wrappers/curve_bridge';
export * from '../generated-wrappers/d_o_d_o_bridge';
export * from '../generated-wrappers/dex_forwarder_bridge';
export * from '../generated-wrappers/dydx_bridge';
export * from '../generated-wrappers/erc1155_proxy';
@@ -21,8 +16,6 @@ export * from '../generated-wrappers/i_asset_data';
export * from '../generated-wrappers/i_asset_proxy';
export * from '../generated-wrappers/i_asset_proxy_dispatcher';
export * from '../generated-wrappers/i_authorizable';
export * from '../generated-wrappers/i_balancer_pool';
export * from '../generated-wrappers/i_bancor_network';
export * from '../generated-wrappers/i_chai';
export * from '../generated-wrappers/i_curve';
export * from '../generated-wrappers/i_dydx';
@@ -31,26 +24,16 @@ export * from '../generated-wrappers/i_erc20_bridge';
export * from '../generated-wrappers/i_eth2_dai';
export * from '../generated-wrappers/i_gas_token';
export * from '../generated-wrappers/i_kyber_network_proxy';
export * from '../generated-wrappers/i_m_stable';
export * from '../generated-wrappers/i_mooniswap';
export * from '../generated-wrappers/i_shell';
export * from '../generated-wrappers/i_uniswap_exchange';
export * from '../generated-wrappers/i_uniswap_exchange_factory';
export * from '../generated-wrappers/i_uniswap_v2_router01';
export * from '../generated-wrappers/kyber_bridge';
export * from '../generated-wrappers/m_stable_bridge';
export * from '../generated-wrappers/mixin_asset_proxy_dispatcher';
export * from '../generated-wrappers/mixin_authorizable';
export * from '../generated-wrappers/mixin_gas_token';
export * from '../generated-wrappers/mooniswap_bridge';
export * from '../generated-wrappers/multi_asset_proxy';
export * from '../generated-wrappers/ownable';
export * from '../generated-wrappers/shell_bridge';
export * from '../generated-wrappers/snow_swap_bridge';
export * from '../generated-wrappers/static_call_proxy';
export * from '../generated-wrappers/sushi_swap_bridge';
export * from '../generated-wrappers/swerve_bridge';
export * from '../generated-wrappers/test_bancor_bridge';
export * from '../generated-wrappers/test_chai_bridge';
export * from '../generated-wrappers/test_dex_forwarder_bridge';
export * from '../generated-wrappers/test_dydx_bridge';

View File

@@ -5,14 +5,9 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as BalancerBridge from '../test/generated-artifacts/BalancerBridge.json';
import * as BancorBridge from '../test/generated-artifacts/BancorBridge.json';
import * as ChaiBridge from '../test/generated-artifacts/ChaiBridge.json';
import * as CreamBridge from '../test/generated-artifacts/CreamBridge.json';
import * as CryptoComBridge from '../test/generated-artifacts/CryptoComBridge.json';
import * as CurveBridge from '../test/generated-artifacts/CurveBridge.json';
import * as DexForwarderBridge from '../test/generated-artifacts/DexForwarderBridge.json';
import * as DODOBridge from '../test/generated-artifacts/DODOBridge.json';
import * as DydxBridge from '../test/generated-artifacts/DydxBridge.json';
import * as ERC1155Proxy from '../test/generated-artifacts/ERC1155Proxy.json';
import * as ERC20BridgeProxy from '../test/generated-artifacts/ERC20BridgeProxy.json';
@@ -23,8 +18,6 @@ import * as IAssetData from '../test/generated-artifacts/IAssetData.json';
import * as IAssetProxy from '../test/generated-artifacts/IAssetProxy.json';
import * as IAssetProxyDispatcher from '../test/generated-artifacts/IAssetProxyDispatcher.json';
import * as IAuthorizable from '../test/generated-artifacts/IAuthorizable.json';
import * as IBalancerPool from '../test/generated-artifacts/IBalancerPool.json';
import * as IBancorNetwork from '../test/generated-artifacts/IBancorNetwork.json';
import * as IChai from '../test/generated-artifacts/IChai.json';
import * as ICurve from '../test/generated-artifacts/ICurve.json';
import * as IDydx from '../test/generated-artifacts/IDydx.json';
@@ -33,9 +26,6 @@ import * as IERC20Bridge from '../test/generated-artifacts/IERC20Bridge.json';
import * as IEth2Dai from '../test/generated-artifacts/IEth2Dai.json';
import * as IGasToken from '../test/generated-artifacts/IGasToken.json';
import * as IKyberNetworkProxy from '../test/generated-artifacts/IKyberNetworkProxy.json';
import * as IMooniswap from '../test/generated-artifacts/IMooniswap.json';
import * as IMStable from '../test/generated-artifacts/IMStable.json';
import * as IShell from '../test/generated-artifacts/IShell.json';
import * as IUniswapExchange from '../test/generated-artifacts/IUniswapExchange.json';
import * as IUniswapExchangeFactory from '../test/generated-artifacts/IUniswapExchangeFactory.json';
import * as IUniswapV2Router01 from '../test/generated-artifacts/IUniswapV2Router01.json';
@@ -43,16 +33,9 @@ import * as KyberBridge from '../test/generated-artifacts/KyberBridge.json';
import * as MixinAssetProxyDispatcher from '../test/generated-artifacts/MixinAssetProxyDispatcher.json';
import * as MixinAuthorizable from '../test/generated-artifacts/MixinAuthorizable.json';
import * as MixinGasToken from '../test/generated-artifacts/MixinGasToken.json';
import * as MooniswapBridge from '../test/generated-artifacts/MooniswapBridge.json';
import * as MStableBridge from '../test/generated-artifacts/MStableBridge.json';
import * as MultiAssetProxy from '../test/generated-artifacts/MultiAssetProxy.json';
import * as Ownable from '../test/generated-artifacts/Ownable.json';
import * as ShellBridge from '../test/generated-artifacts/ShellBridge.json';
import * as SnowSwapBridge from '../test/generated-artifacts/SnowSwapBridge.json';
import * as StaticCallProxy from '../test/generated-artifacts/StaticCallProxy.json';
import * as SushiSwapBridge from '../test/generated-artifacts/SushiSwapBridge.json';
import * as SwerveBridge from '../test/generated-artifacts/SwerveBridge.json';
import * as TestBancorBridge from '../test/generated-artifacts/TestBancorBridge.json';
import * as TestChaiBridge from '../test/generated-artifacts/TestChaiBridge.json';
import * as TestDexForwarderBridge from '../test/generated-artifacts/TestDexForwarderBridge.json';
import * as TestDydxBridge from '../test/generated-artifacts/TestDydxBridge.json';
@@ -74,32 +57,19 @@ export const artifacts = {
ERC721Proxy: ERC721Proxy as ContractArtifact,
MultiAssetProxy: MultiAssetProxy as ContractArtifact,
StaticCallProxy: StaticCallProxy as ContractArtifact,
BalancerBridge: BalancerBridge as ContractArtifact,
BancorBridge: BancorBridge as ContractArtifact,
ChaiBridge: ChaiBridge as ContractArtifact,
CreamBridge: CreamBridge as ContractArtifact,
CryptoComBridge: CryptoComBridge as ContractArtifact,
CurveBridge: CurveBridge as ContractArtifact,
DODOBridge: DODOBridge as ContractArtifact,
DexForwarderBridge: DexForwarderBridge as ContractArtifact,
DydxBridge: DydxBridge as ContractArtifact,
Eth2DaiBridge: Eth2DaiBridge as ContractArtifact,
KyberBridge: KyberBridge as ContractArtifact,
MStableBridge: MStableBridge as ContractArtifact,
MixinGasToken: MixinGasToken as ContractArtifact,
MooniswapBridge: MooniswapBridge as ContractArtifact,
ShellBridge: ShellBridge as ContractArtifact,
SnowSwapBridge: SnowSwapBridge as ContractArtifact,
SushiSwapBridge: SushiSwapBridge as ContractArtifact,
SwerveBridge: SwerveBridge as ContractArtifact,
UniswapBridge: UniswapBridge as ContractArtifact,
UniswapV2Bridge: UniswapV2Bridge as ContractArtifact,
IAssetData: IAssetData as ContractArtifact,
IAssetProxy: IAssetProxy as ContractArtifact,
IAssetProxyDispatcher: IAssetProxyDispatcher as ContractArtifact,
IAuthorizable: IAuthorizable as ContractArtifact,
IBalancerPool: IBalancerPool as ContractArtifact,
IBancorNetwork: IBancorNetwork as ContractArtifact,
IChai: IChai as ContractArtifact,
ICurve: ICurve as ContractArtifact,
IDydx: IDydx as ContractArtifact,
@@ -108,13 +78,9 @@ export const artifacts = {
IEth2Dai: IEth2Dai as ContractArtifact,
IGasToken: IGasToken as ContractArtifact,
IKyberNetworkProxy: IKyberNetworkProxy as ContractArtifact,
IMStable: IMStable as ContractArtifact,
IMooniswap: IMooniswap as ContractArtifact,
IShell: IShell as ContractArtifact,
IUniswapExchange: IUniswapExchange as ContractArtifact,
IUniswapExchangeFactory: IUniswapExchangeFactory as ContractArtifact,
IUniswapV2Router01: IUniswapV2Router01 as ContractArtifact,
TestBancorBridge: TestBancorBridge as ContractArtifact,
TestChaiBridge: TestChaiBridge as ContractArtifact,
TestDexForwarderBridge: TestDexForwarderBridge as ContractArtifact,
TestDydxBridge: TestDydxBridge as ContractArtifact,

View File

@@ -1,185 +0,0 @@
import {
blockchainTests,
constants,
expect,
filterLogsToArguments,
getRandomInteger,
randomAddress,
} from '@0x/contracts-test-utils';
import { AssetProxyId } from '@0x/types';
import { AbiEncoder, BigNumber, hexUtils } from '@0x/utils';
import { DecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import { TestBancorBridgeContract } from './generated-wrappers/test_bancor_bridge';
import {
TestBancorBridgeConvertByPathInputEventArgs as ConvertByPathArgs,
TestBancorBridgeEvents as ContractEvents,
TestBancorBridgeTokenApproveEventArgs as TokenApproveArgs,
} from './wrappers';
blockchainTests.resets('Bancor unit tests', env => {
const FROM_TOKEN_DECIMALS = 6;
const TO_TOKEN_DECIMALS = 18;
const FROM_TOKEN_BASE = new BigNumber(10).pow(FROM_TOKEN_DECIMALS);
const TO_TOKEN_BASE = new BigNumber(10).pow(TO_TOKEN_DECIMALS);
let testContract: TestBancorBridgeContract;
before(async () => {
testContract = await TestBancorBridgeContract.deployFrom0xArtifactAsync(
artifacts.TestBancorBridge,
env.provider,
env.txDefaults,
artifacts,
);
});
describe('isValidSignature()', () => {
it('returns success bytes', async () => {
const LEGACY_WALLET_MAGIC_VALUE = '0xb0671381';
const result = await testContract
.isValidSignature(hexUtils.random(), hexUtils.random(_.random(0, 32)))
.callAsync();
expect(result).to.eq(LEGACY_WALLET_MAGIC_VALUE);
});
});
describe('bridgeTransferFrom()', () => {
interface TransferFromOpts {
tokenAddressesPath: string[];
toAddress: string;
// Amount to pass into `bridgeTransferFrom()`
amount: BigNumber;
// Token balance of the bridge.
fromTokenBalance: BigNumber;
// Router reverts with this reason
routerRevertReason: string;
}
interface TransferFromResult {
opts: TransferFromOpts;
result: string;
logs: DecodedLogs;
blocktime: number;
}
function createTransferFromOpts(opts?: Partial<TransferFromOpts>): TransferFromOpts {
const amount = getRandomInteger(1, TO_TOKEN_BASE.times(100));
return {
tokenAddressesPath: Array(3).fill(constants.NULL_ADDRESS),
amount,
toAddress: randomAddress(),
fromTokenBalance: getRandomInteger(1, FROM_TOKEN_BASE.times(100)),
routerRevertReason: '',
...opts,
};
}
const bridgeDataEncoder = AbiEncoder.create('(address[], address)');
async function transferFromAsync(opts?: Partial<TransferFromOpts>): Promise<TransferFromResult> {
const _opts = createTransferFromOpts(opts);
for (let i = 0; i < _opts.tokenAddressesPath.length; i++) {
const createFromTokenFn = testContract.createToken(_opts.tokenAddressesPath[i]);
_opts.tokenAddressesPath[i] = await createFromTokenFn.callAsync();
await createFromTokenFn.awaitTransactionSuccessAsync();
}
// Set the token balance for the token we're converting from.
await testContract
.setTokenBalance(_opts.tokenAddressesPath[0], _opts.fromTokenBalance)
.awaitTransactionSuccessAsync();
// Set revert reason for the router.
await testContract.setNetworkRevertReason(_opts.routerRevertReason).awaitTransactionSuccessAsync();
// Call bridgeTransferFrom().
const bridgeTransferFromFn = testContract.bridgeTransferFrom(
// Output token
_opts.tokenAddressesPath[_opts.tokenAddressesPath.length - 1],
// Random maker address.
randomAddress(),
// Recipient address.
_opts.toAddress,
// Transfer amount.
_opts.amount,
// ABI-encode the input token address as the bridge data.
bridgeDataEncoder.encode([
_opts.tokenAddressesPath,
await testContract.getNetworkAddress().callAsync(),
]),
);
const result = await bridgeTransferFromFn.callAsync();
const receipt = await bridgeTransferFromFn.awaitTransactionSuccessAsync();
return {
opts: _opts,
result,
logs: (receipt.logs as any) as DecodedLogs,
blocktime: await env.web3Wrapper.getBlockTimestampAsync(receipt.blockNumber),
};
}
it('returns magic bytes on success', async () => {
const { result } = await transferFromAsync();
expect(result).to.eq(AssetProxyId.ERC20Bridge);
});
describe('token -> token', async () => {
it('calls BancorNetwork.convertByPath()', async () => {
const { opts, result, logs } = await transferFromAsync();
expect(result).to.eq(AssetProxyId.ERC20Bridge, 'asset proxy id');
const transfers = filterLogsToArguments<ConvertByPathArgs>(logs, ContractEvents.ConvertByPathInput);
expect(transfers.length).to.eq(1);
expect(transfers[0].toTokenAddress).to.eq(
opts.tokenAddressesPath[opts.tokenAddressesPath.length - 1],
'output token address',
);
expect(transfers[0].to).to.eq(opts.toAddress, 'recipient address');
expect(transfers[0].amountIn).to.bignumber.eq(opts.fromTokenBalance, 'input token amount');
expect(transfers[0].amountOutMin).to.bignumber.eq(opts.amount, 'output token amount');
expect(transfers[0].feeRecipient).to.eq(constants.NULL_ADDRESS);
expect(transfers[0].feeAmount).to.bignumber.eq(new BigNumber(0));
});
it('sets allowance for "from" token', async () => {
const { logs } = await transferFromAsync();
const approvals = filterLogsToArguments<TokenApproveArgs>(logs, ContractEvents.TokenApprove);
const networkAddress = await testContract.getNetworkAddress().callAsync();
expect(approvals.length).to.eq(1);
expect(approvals[0].spender).to.eq(networkAddress);
expect(approvals[0].allowance).to.bignumber.eq(constants.MAX_UINT256);
});
it('fails if the router fails', async () => {
const revertReason = 'FOOBAR';
const tx = transferFromAsync({
routerRevertReason: revertReason,
});
return expect(tx).to.eventually.be.rejectedWith(revertReason);
});
});
describe('token -> token -> token', async () => {
it('calls BancorNetwork.convertByPath()', async () => {
const { opts, result, logs } = await transferFromAsync({
tokenAddressesPath: Array(5).fill(constants.NULL_ADDRESS),
});
expect(result).to.eq(AssetProxyId.ERC20Bridge, 'asset proxy id');
const transfers = filterLogsToArguments<ConvertByPathArgs>(logs, ContractEvents.ConvertByPathInput);
expect(transfers.length).to.eq(1);
expect(transfers[0].toTokenAddress).to.eq(
opts.tokenAddressesPath[opts.tokenAddressesPath.length - 1],
'output token address',
);
expect(transfers[0].to).to.eq(opts.toAddress, 'recipient address');
expect(transfers[0].amountIn).to.bignumber.eq(opts.fromTokenBalance, 'input token amount');
expect(transfers[0].amountOutMin).to.bignumber.eq(opts.amount, 'output token amount');
expect(transfers[0].feeRecipient).to.eq(constants.NULL_ADDRESS);
expect(transfers[0].feeAmount).to.bignumber.eq(new BigNumber(0));
});
});
});
});

View File

@@ -30,6 +30,7 @@ blockchainTests.resets('DexForwarderBridge unit tests', env => {
const BRIDGE_SUCCESS = '0xdc1600f3';
const BRIDGE_FAILURE = '0xffffffff';
const BRIDGE_REVERT_ERROR = 'oopsie';
const INCOMPLETE_FILL_REVERT = 'DexForwarderBridge/INCOMPLETE_FILL';
const NOT_AUTHORIZED_REVERT = 'DexForwarderBridge/SENDER_NOT_AUTHORIZED';
const DEFAULTS = {
toAddress: randomAddress(),
@@ -164,26 +165,27 @@ blockchainTests.resets('DexForwarderBridge unit tests', env => {
await callBridgeTransferFromAsync({ bridgeData, sellAmount: ZERO_AMOUNT });
});
it('succeeds with no bridge calls and an input balance', async () => {
it('fails with no bridge calls and an input balance', async () => {
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls: [],
});
await callBridgeTransferFromAsync({
bridgeData,
sellAmount: new BigNumber(1),
});
return expect(callBridgeTransferFromAsync({ bridgeData, sellAmount: new BigNumber(1) })).to.revertWith(
INCOMPLETE_FILL_REVERT,
);
});
it('succeeds if entire input token balance is not consumed', async () => {
it('fails if entire input token balance is not consumed', async () => {
const bridgeData = dexForwarderBridgeDataEncoder.encode({
inputToken,
calls: allBridgeCalls,
});
await callBridgeTransferFromAsync({
bridgeData,
sellAmount: totalFillableInputAmount.plus(1),
});
return expect(
callBridgeTransferFromAsync({
bridgeData,
sellAmount: totalFillableInputAmount.plus(1),
}),
).to.revertWith(INCOMPLETE_FILL_REVERT);
});
it('fails if not authorized', async () => {

View File

@@ -16,8 +16,7 @@ import { artifacts } from './artifacts';
import { TestKyberBridgeContract, TestKyberBridgeEvents } from './wrappers';
// TODO(dorothy-zbornak): Tests need to be updated.
blockchainTests.resets.skip('KyberBridge unit tests', env => {
blockchainTests.resets('KyberBridge unit tests', env => {
const KYBER_ETH_ADDRESS = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
const FROM_TOKEN_DECIMALS = 6;
const TO_TOKEN_DECIMALS = 18;
@@ -116,7 +115,7 @@ blockchainTests.resets.skip('KyberBridge unit tests', env => {
// Transfer amount.
_opts.amount,
// ABI-encode the input token address as the bridge data.
hexUtils.concat(hexUtils.leftPad(_opts.fromTokenAddress), hexUtils.leftPad(32), hexUtils.leftPad(0)),
hexUtils.leftPad(_opts.fromTokenAddress),
);
const result = await bridgeTransferFromFn.callAsync();
const { logs } = await bridgeTransferFromFn.awaitTransactionSuccessAsync();

View File

@@ -3,13 +3,8 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../test/generated-wrappers/balancer_bridge';
export * from '../test/generated-wrappers/bancor_bridge';
export * from '../test/generated-wrappers/chai_bridge';
export * from '../test/generated-wrappers/cream_bridge';
export * from '../test/generated-wrappers/crypto_com_bridge';
export * from '../test/generated-wrappers/curve_bridge';
export * from '../test/generated-wrappers/d_o_d_o_bridge';
export * from '../test/generated-wrappers/dex_forwarder_bridge';
export * from '../test/generated-wrappers/dydx_bridge';
export * from '../test/generated-wrappers/erc1155_proxy';
@@ -21,8 +16,6 @@ export * from '../test/generated-wrappers/i_asset_data';
export * from '../test/generated-wrappers/i_asset_proxy';
export * from '../test/generated-wrappers/i_asset_proxy_dispatcher';
export * from '../test/generated-wrappers/i_authorizable';
export * from '../test/generated-wrappers/i_balancer_pool';
export * from '../test/generated-wrappers/i_bancor_network';
export * from '../test/generated-wrappers/i_chai';
export * from '../test/generated-wrappers/i_curve';
export * from '../test/generated-wrappers/i_dydx';
@@ -31,26 +24,16 @@ export * from '../test/generated-wrappers/i_erc20_bridge';
export * from '../test/generated-wrappers/i_eth2_dai';
export * from '../test/generated-wrappers/i_gas_token';
export * from '../test/generated-wrappers/i_kyber_network_proxy';
export * from '../test/generated-wrappers/i_m_stable';
export * from '../test/generated-wrappers/i_mooniswap';
export * from '../test/generated-wrappers/i_shell';
export * from '../test/generated-wrappers/i_uniswap_exchange';
export * from '../test/generated-wrappers/i_uniswap_exchange_factory';
export * from '../test/generated-wrappers/i_uniswap_v2_router01';
export * from '../test/generated-wrappers/kyber_bridge';
export * from '../test/generated-wrappers/m_stable_bridge';
export * from '../test/generated-wrappers/mixin_asset_proxy_dispatcher';
export * from '../test/generated-wrappers/mixin_authorizable';
export * from '../test/generated-wrappers/mixin_gas_token';
export * from '../test/generated-wrappers/mooniswap_bridge';
export * from '../test/generated-wrappers/multi_asset_proxy';
export * from '../test/generated-wrappers/ownable';
export * from '../test/generated-wrappers/shell_bridge';
export * from '../test/generated-wrappers/snow_swap_bridge';
export * from '../test/generated-wrappers/static_call_proxy';
export * from '../test/generated-wrappers/sushi_swap_bridge';
export * from '../test/generated-wrappers/swerve_bridge';
export * from '../test/generated-wrappers/test_bancor_bridge';
export * from '../test/generated-wrappers/test_chai_bridge';
export * from '../test/generated-wrappers/test_dex_forwarder_bridge';
export * from '../test/generated-wrappers/test_dydx_bridge';

View File

@@ -3,13 +3,8 @@
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"generated-artifacts/BalancerBridge.json",
"generated-artifacts/BancorBridge.json",
"generated-artifacts/ChaiBridge.json",
"generated-artifacts/CreamBridge.json",
"generated-artifacts/CryptoComBridge.json",
"generated-artifacts/CurveBridge.json",
"generated-artifacts/DODOBridge.json",
"generated-artifacts/DexForwarderBridge.json",
"generated-artifacts/DydxBridge.json",
"generated-artifacts/ERC1155Proxy.json",
@@ -21,8 +16,6 @@
"generated-artifacts/IAssetProxy.json",
"generated-artifacts/IAssetProxyDispatcher.json",
"generated-artifacts/IAuthorizable.json",
"generated-artifacts/IBalancerPool.json",
"generated-artifacts/IBancorNetwork.json",
"generated-artifacts/IChai.json",
"generated-artifacts/ICurve.json",
"generated-artifacts/IDydx.json",
@@ -31,26 +24,16 @@
"generated-artifacts/IEth2Dai.json",
"generated-artifacts/IGasToken.json",
"generated-artifacts/IKyberNetworkProxy.json",
"generated-artifacts/IMStable.json",
"generated-artifacts/IMooniswap.json",
"generated-artifacts/IShell.json",
"generated-artifacts/IUniswapExchange.json",
"generated-artifacts/IUniswapExchangeFactory.json",
"generated-artifacts/IUniswapV2Router01.json",
"generated-artifacts/KyberBridge.json",
"generated-artifacts/MStableBridge.json",
"generated-artifacts/MixinAssetProxyDispatcher.json",
"generated-artifacts/MixinAuthorizable.json",
"generated-artifacts/MixinGasToken.json",
"generated-artifacts/MooniswapBridge.json",
"generated-artifacts/MultiAssetProxy.json",
"generated-artifacts/Ownable.json",
"generated-artifacts/ShellBridge.json",
"generated-artifacts/SnowSwapBridge.json",
"generated-artifacts/StaticCallProxy.json",
"generated-artifacts/SushiSwapBridge.json",
"generated-artifacts/SwerveBridge.json",
"generated-artifacts/TestBancorBridge.json",
"generated-artifacts/TestChaiBridge.json",
"generated-artifacts/TestDexForwarderBridge.json",
"generated-artifacts/TestDydxBridge.json",
@@ -62,13 +45,8 @@
"generated-artifacts/TestUniswapV2Bridge.json",
"generated-artifacts/UniswapBridge.json",
"generated-artifacts/UniswapV2Bridge.json",
"test/generated-artifacts/BalancerBridge.json",
"test/generated-artifacts/BancorBridge.json",
"test/generated-artifacts/ChaiBridge.json",
"test/generated-artifacts/CreamBridge.json",
"test/generated-artifacts/CryptoComBridge.json",
"test/generated-artifacts/CurveBridge.json",
"test/generated-artifacts/DODOBridge.json",
"test/generated-artifacts/DexForwarderBridge.json",
"test/generated-artifacts/DydxBridge.json",
"test/generated-artifacts/ERC1155Proxy.json",
@@ -80,8 +58,6 @@
"test/generated-artifacts/IAssetProxy.json",
"test/generated-artifacts/IAssetProxyDispatcher.json",
"test/generated-artifacts/IAuthorizable.json",
"test/generated-artifacts/IBalancerPool.json",
"test/generated-artifacts/IBancorNetwork.json",
"test/generated-artifacts/IChai.json",
"test/generated-artifacts/ICurve.json",
"test/generated-artifacts/IDydx.json",
@@ -90,26 +66,16 @@
"test/generated-artifacts/IEth2Dai.json",
"test/generated-artifacts/IGasToken.json",
"test/generated-artifacts/IKyberNetworkProxy.json",
"test/generated-artifacts/IMStable.json",
"test/generated-artifacts/IMooniswap.json",
"test/generated-artifacts/IShell.json",
"test/generated-artifacts/IUniswapExchange.json",
"test/generated-artifacts/IUniswapExchangeFactory.json",
"test/generated-artifacts/IUniswapV2Router01.json",
"test/generated-artifacts/KyberBridge.json",
"test/generated-artifacts/MStableBridge.json",
"test/generated-artifacts/MixinAssetProxyDispatcher.json",
"test/generated-artifacts/MixinAuthorizable.json",
"test/generated-artifacts/MixinGasToken.json",
"test/generated-artifacts/MooniswapBridge.json",
"test/generated-artifacts/MultiAssetProxy.json",
"test/generated-artifacts/Ownable.json",
"test/generated-artifacts/ShellBridge.json",
"test/generated-artifacts/SnowSwapBridge.json",
"test/generated-artifacts/StaticCallProxy.json",
"test/generated-artifacts/SushiSwapBridge.json",
"test/generated-artifacts/SwerveBridge.json",
"test/generated-artifacts/TestBancorBridge.json",
"test/generated-artifacts/TestChaiBridge.json",
"test/generated-artifacts/TestDexForwarderBridge.json",
"test/generated-artifacts/TestDydxBridge.json",

View File

@@ -1,166 +1,4 @@
[
{
"timestamp": 1611648096,
"version": "1.1.23",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1610510890,
"version": "1.1.22",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1609802516,
"version": "1.1.21",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608692071,
"version": "1.1.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608245516,
"version": "1.1.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608105788,
"version": "1.1.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "1.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "1.1.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "1.1.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605763885,
"version": "1.1.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605302002,
"version": "1.1.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604385937,
"version": "1.1.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604376968,
"version": "1.1.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604355662,
"version": "1.1.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603851023,
"version": "1.1.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603833198,
"version": "1.1.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603265572,
"version": "1.1.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1594788383,
"version": "1.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.1.5",
"changes": [

View File

@@ -5,78 +5,6 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.1.23 - _January 26, 2021_
* Dependencies updated
## v1.1.22 - _January 13, 2021_
* Dependencies updated
## v1.1.21 - _January 4, 2021_
* Dependencies updated
## v1.1.20 - _December 23, 2020_
* Dependencies updated
## v1.1.19 - _December 17, 2020_
* Dependencies updated
## v1.1.18 - _December 16, 2020_
* Dependencies updated
## v1.1.17 - _December 9, 2020_
* Dependencies updated
## v1.1.16 - _December 7, 2020_
* Dependencies updated
## v1.1.15 - _December 3, 2020_
* Dependencies updated
## v1.1.14 - _November 19, 2020_
* Dependencies updated
## v1.1.13 - _November 13, 2020_
* Dependencies updated
## v1.1.12 - _November 3, 2020_
* Dependencies updated
## v1.1.11 - _November 3, 2020_
* Dependencies updated
## v1.1.10 - _November 2, 2020_
* Dependencies updated
## v1.1.9 - _October 28, 2020_
* Dependencies updated
## v1.1.8 - _October 27, 2020_
* Dependencies updated
## v1.1.7 - _October 21, 2020_
* Dependencies updated
## v1.1.6 - _July 15, 2020_
* Dependencies updated
## v1.1.5 - _June 24, 2020_
* Fix broken tests. (#2591)

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-broker",
"version": "1.1.23",
"version": "1.1.5",
"engines": {
"node": ">=6.12"
},
@@ -43,31 +43,31 @@
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/protocol.git"
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/protocol/issues"
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.4.19",
"@0x/contracts-asset-proxy": "^3.7.5",
"@0x/contracts-erc20": "^3.3.2",
"@0x/contracts-erc721": "^3.1.23",
"@0x/contracts-exchange": "^3.2.24",
"@0x/contracts-exchange-libs": "^4.3.23",
"@0x/contracts-gen": "^2.0.30",
"@0x/contracts-test-utils": "^5.3.20",
"@0x/contracts-utils": "^4.7.2",
"@0x/sol-compiler": "^4.5.2",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/web3-wrapper": "^7.4.1",
"@0x/abi-gen": "^5.3.0",
"@0x/contracts-asset-proxy": "^3.3.0",
"@0x/contracts-erc20": "^3.2.0",
"@0x/contracts-erc721": "^3.1.6",
"@0x/contracts-exchange": "^3.2.6",
"@0x/contracts-exchange-libs": "^4.3.6",
"@0x/contracts-gen": "^2.0.9",
"@0x/contracts-test-utils": "^5.3.3",
"@0x/contracts-utils": "^4.5.0",
"@0x/sol-compiler": "^4.1.0",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.3",
"@0x/web3-wrapper": "^7.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
@@ -80,18 +80,17 @@
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.18",
"@0x/order-utils": "^10.4.15",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.2.0",
"ethereum-types": "^3.4.0"
"@0x/base-contract": "^6.2.2",
"@0x/order-utils": "^10.2.5",
"@0x/typescript-typings": "^5.1.0",
"@0x/utils": "^5.5.0",
"ethereum-types": "^3.1.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}
}

View File

@@ -1,166 +1,4 @@
[
{
"timestamp": 1611648096,
"version": "3.1.24",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1610510890,
"version": "3.1.23",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1609802516,
"version": "3.1.22",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608692071,
"version": "3.1.21",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608245516,
"version": "3.1.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608105788,
"version": "3.1.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "3.1.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "3.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "3.1.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605763885,
"version": "3.1.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605302002,
"version": "3.1.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604385937,
"version": "3.1.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604376968,
"version": "3.1.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604355662,
"version": "3.1.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603851023,
"version": "3.1.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603833198,
"version": "3.1.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603265572,
"version": "3.1.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1594788383,
"version": "3.1.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "3.1.6",

View File

@@ -5,78 +5,6 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.24 - _January 26, 2021_
* Dependencies updated
## v3.1.23 - _January 13, 2021_
* Dependencies updated
## v3.1.22 - _January 4, 2021_
* Dependencies updated
## v3.1.21 - _December 23, 2020_
* Dependencies updated
## v3.1.20 - _December 17, 2020_
* Dependencies updated
## v3.1.19 - _December 16, 2020_
* Dependencies updated
## v3.1.18 - _December 9, 2020_
* Dependencies updated
## v3.1.17 - _December 7, 2020_
* Dependencies updated
## v3.1.16 - _December 3, 2020_
* Dependencies updated
## v3.1.15 - _November 19, 2020_
* Dependencies updated
## v3.1.14 - _November 13, 2020_
* Dependencies updated
## v3.1.13 - _November 3, 2020_
* Dependencies updated
## v3.1.12 - _November 3, 2020_
* Dependencies updated
## v3.1.11 - _November 2, 2020_
* Dependencies updated
## v3.1.10 - _October 28, 2020_
* Dependencies updated
## v3.1.9 - _October 27, 2020_
* Dependencies updated
## v3.1.8 - _October 21, 2020_
* Dependencies updated
## v3.1.7 - _July 15, 2020_
* Dependencies updated
## v3.1.6 - _June 24, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-coordinator",
"version": "3.1.24",
"version": "3.1.6",
"engines": {
"node": ">=6.12"
},
@@ -44,28 +44,30 @@
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/protocol.git"
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/protocol/issues"
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.4.19",
"@0x/contracts-asset-proxy": "^3.7.5",
"@0x/contracts-dev-utils": "^1.3.22",
"@0x/contracts-erc20": "^3.3.2",
"@0x/contracts-gen": "^2.0.30",
"@0x/dev-utils": "^4.2.1",
"@0x/order-utils": "^10.4.15",
"@0x/sol-compiler": "^4.5.2",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/web3-wrapper": "^7.4.1",
"@0x/abi-gen": "^5.3.0",
"@0x/contracts-asset-proxy": "^3.3.0",
"@0x/contracts-dev-utils": "^1.3.4",
"@0x/contracts-erc20": "^3.2.0",
"@0x/contracts-exchange": "^3.2.6",
"@0x/contracts-gen": "^2.0.9",
"@0x/contracts-test-utils": "^5.3.3",
"@0x/dev-utils": "^3.2.2",
"@0x/order-utils": "^10.2.5",
"@0x/sol-compiler": "^4.1.0",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/web3-wrapper": "^7.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
@@ -78,25 +80,22 @@
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/assert": "^3.0.21",
"@0x/base-contract": "^6.2.18",
"@0x/contract-addresses": "^5.9.0",
"@0x/contracts-exchange": "^3.2.24",
"@0x/contracts-test-utils": "^5.3.20",
"@0x/contracts-utils": "^4.7.2",
"@0x/json-schemas": "^5.4.1",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.2.0",
"ethereum-types": "^3.4.0",
"@0x/assert": "^3.0.8",
"@0x/base-contract": "^6.2.2",
"@0x/contract-addresses": "^4.10.0",
"@0x/contracts-utils": "^4.5.0",
"@0x/json-schemas": "^5.0.8",
"@0x/types": "^3.1.3",
"@0x/typescript-typings": "^5.1.0",
"@0x/utils": "^5.5.0",
"ethereum-types": "^3.1.1",
"http-status-codes": "^1.3.2"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}
}

View File

@@ -1,166 +1,4 @@
[
{
"timestamp": 1611648096,
"version": "1.3.22",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1610510890,
"version": "1.3.21",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1609802516,
"version": "1.3.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608692071,
"version": "1.3.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608245516,
"version": "1.3.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608105788,
"version": "1.3.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "1.3.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "1.3.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "1.3.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605763885,
"version": "1.3.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605302002,
"version": "1.3.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604385937,
"version": "1.3.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604376968,
"version": "1.3.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604355662,
"version": "1.3.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603851023,
"version": "1.3.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603833198,
"version": "1.3.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603265572,
"version": "1.3.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1594788383,
"version": "1.3.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "1.3.4",

View File

@@ -5,78 +5,6 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.3.22 - _January 26, 2021_
* Dependencies updated
## v1.3.21 - _January 13, 2021_
* Dependencies updated
## v1.3.20 - _January 4, 2021_
* Dependencies updated
## v1.3.19 - _December 23, 2020_
* Dependencies updated
## v1.3.18 - _December 17, 2020_
* Dependencies updated
## v1.3.17 - _December 16, 2020_
* Dependencies updated
## v1.3.16 - _December 9, 2020_
* Dependencies updated
## v1.3.15 - _December 7, 2020_
* Dependencies updated
## v1.3.14 - _December 3, 2020_
* Dependencies updated
## v1.3.13 - _November 19, 2020_
* Dependencies updated
## v1.3.12 - _November 13, 2020_
* Dependencies updated
## v1.3.11 - _November 3, 2020_
* Dependencies updated
## v1.3.10 - _November 3, 2020_
* Dependencies updated
## v1.3.9 - _November 2, 2020_
* Dependencies updated
## v1.3.8 - _October 28, 2020_
* Dependencies updated
## v1.3.7 - _October 27, 2020_
* Dependencies updated
## v1.3.6 - _October 21, 2020_
* Dependencies updated
## v1.3.5 - _July 15, 2020_
* Dependencies updated
## v1.3.4 - _June 24, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-dev-utils",
"version": "1.3.22",
"version": "1.3.4",
"engines": {
"node": ">=6.12"
},
@@ -33,41 +33,40 @@
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/protocol.git"
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/protocol/issues"
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/dev-utils",
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/dev-utils/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.4.19",
"@0x/assert": "^3.0.21",
"@0x/contracts-asset-proxy": "^3.7.5",
"@0x/contracts-erc20": "^3.3.2",
"@0x/contracts-gen": "^2.0.30",
"@0x/contracts-test-utils": "^5.3.20",
"@0x/sol-compiler": "^4.5.2",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/utils": "^6.2.0",
"ethereum-types": "^3.4.0",
"@0x/abi-gen": "^5.3.0",
"@0x/assert": "^3.0.8",
"@0x/contracts-asset-proxy": "^3.3.0",
"@0x/contracts-erc20": "^3.2.0",
"@0x/contracts-gen": "^2.0.9",
"@0x/contracts-test-utils": "^5.3.3",
"@0x/sol-compiler": "^4.1.0",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.3",
"@0x/utils": "^5.5.0",
"@types/node": "*",
"ethereum-types": "^3.1.1",
"ethers": "~4.0.4",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.18",
"@types/node": "12.12.54"
"@0x/base-contract": "^6.2.2"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}
}

View File

@@ -1,157 +1,4 @@
[
{
"timestamp": 1611648096,
"version": "2.1.23",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1610510890,
"version": "2.1.22",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1609802516,
"version": "2.1.21",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608692071,
"version": "2.1.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608245516,
"version": "2.1.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "2.1.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "2.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "2.1.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605763885,
"version": "2.1.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605302002,
"version": "2.1.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604385937,
"version": "2.1.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604376968,
"version": "2.1.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604355662,
"version": "2.1.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603851023,
"version": "2.1.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603833198,
"version": "2.1.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603265572,
"version": "2.1.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1594788383,
"version": "2.1.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "2.1.6",

View File

@@ -5,74 +5,6 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.1.23 - _January 26, 2021_
* Dependencies updated
## v2.1.22 - _January 13, 2021_
* Dependencies updated
## v2.1.21 - _January 4, 2021_
* Dependencies updated
## v2.1.20 - _December 23, 2020_
* Dependencies updated
## v2.1.19 - _December 17, 2020_
* Dependencies updated
## v2.1.18 - _December 9, 2020_
* Dependencies updated
## v2.1.17 - _December 7, 2020_
* Dependencies updated
## v2.1.16 - _December 3, 2020_
* Dependencies updated
## v2.1.15 - _November 19, 2020_
* Dependencies updated
## v2.1.14 - _November 13, 2020_
* Dependencies updated
## v2.1.13 - _November 3, 2020_
* Dependencies updated
## v2.1.12 - _November 3, 2020_
* Dependencies updated
## v2.1.11 - _November 2, 2020_
* Dependencies updated
## v2.1.10 - _October 28, 2020_
* Dependencies updated
## v2.1.9 - _October 27, 2020_
* Dependencies updated
## v2.1.8 - _October 21, 2020_
* Dependencies updated
## v2.1.7 - _July 15, 2020_
* Dependencies updated
## v2.1.6 - _June 24, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc1155",
"version": "2.1.23",
"version": "2.1.6",
"engines": {
"node": ">=6.12"
},
@@ -44,31 +44,31 @@
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/protocol.git"
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/protocol/issues"
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.4.19",
"@0x/contracts-gen": "^2.0.30",
"@0x/contracts-utils": "^4.7.2",
"@0x/dev-utils": "^4.2.1",
"@0x/sol-compiler": "^4.5.2",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/abi-gen": "^5.3.0",
"@0x/contracts-gen": "^2.0.9",
"@0x/contracts-utils": "^4.5.0",
"@0x/dev-utils": "^3.2.2",
"@0x/sol-compiler": "^4.1.0",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.3",
"@0x/typescript-typings": "^5.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereum-types": "^3.4.0",
"ethereum-types": "^3.1.1",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
"npm-run-all": "^4.1.2",
@@ -76,18 +76,17 @@
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.18",
"@0x/contracts-test-utils": "^5.3.20",
"@0x/utils": "^6.2.0",
"@0x/web3-wrapper": "^7.4.1",
"@0x/base-contract": "^6.2.2",
"@0x/contracts-test-utils": "^5.3.3",
"@0x/utils": "^5.5.0",
"@0x/web3-wrapper": "^7.1.0",
"lodash": "^4.17.11"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}
}

View File

@@ -0,0 +1,10 @@
# Blacklist all files
.*
*
# Whitelist lib
!lib/**/*
# Whitelist Solidity contracts
!contracts/src/**/*
# Blacklist tests in lib
/lib/test/*
# Package specific ignore

View File

@@ -0,0 +1,187 @@
[
{
"version": "1.6.0",
"changes": [
{
"note": "Pass in `DevUtils` address as a constructor parameter",
"pr": 2531
},
{
"note": "Sample `Curve` for buy amounts",
"pr": 2551
},
{
"note": "Added `sampleBuysFromKyberNetwork`",
"pr": 2551
},
{
"note": "Use `searchBestRate` in Kyber samples. Return 0 when Uniswap/Eth2Dai reserve",
"pr": 2575
},
{
"note": "Add UniswapV2",
"pr": 2595
},
{
"note": "Sample from MultiBridge",
"pr": 2593
}
],
"timestamp": 1592969527
},
{
"timestamp": 1583220306,
"version": "1.5.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.5.0",
"changes": [
{
"note": "Add generic liquidity provider sampling",
"pr": 2487
},
{
"note": "Use liquidity provider registry in sampler",
"pr": 2499
}
],
"timestamp": 1582837861
},
{
"timestamp": 1582677073,
"version": "1.4.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1582623685,
"version": "1.4.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.4.0",
"changes": [
{
"note": "Added Curve contract sampling",
"pr": 2483
}
],
"timestamp": 1581748629
},
{
"version": "1.3.0",
"changes": [
{
"note": "Catch reverts to `DevUtils` calls",
"pr": 2476
},
{
"note": "Remove wrapper functions and introduce `batchCall()`",
"pr": 2477
}
],
"timestamp": 1581204851
},
{
"timestamp": 1580988106,
"version": "1.2.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.2.0",
"changes": [
{
"note": "Make source IDs static on all networks, not inherited from `DeploymentConstants`.",
"pr": 2459
}
],
"timestamp": 1580811564
},
{
"version": "1.1.0",
"changes": [
{
"note": "Add batch functions to query quotes",
"pr": 2427
},
{
"note": "Early exit if a DEX sample fails",
"pr": 2427
}
],
"timestamp": 1579682890
},
{
"version": "1.0.3",
"changes": [
{
"note": "Add gas limits to external quote calls.",
"pr": 2405
}
],
"timestamp": 1578272714
},
{
"version": "1.0.2",
"changes": [
{
"note": "Do not query empty/unsigned orders. Swallow revets on DEX quotes.",
"pr": 2395
}
],
"timestamp": 1576540892
},
{
"timestamp": 1575931811,
"version": "1.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.0",
"changes": [
{
"note": "Created package.",
"pr": 2344
}
],
"timestamp": 1575296764
},
{
"version": "1.0.0-beta.2",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1575290197
},
{
"version": "1.0.0-beta.1",
"changes": [
{
"note": "Created package.",
"pr": 2344
}
]
}
]

View File

@@ -0,0 +1,78 @@
<!--
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
Edit the package's CHANGELOG.json file only.
-->
CHANGELOG
## v1.6.0 - _June 24, 2020_
* Pass in `DevUtils` address as a constructor parameter (#2531)
* Sample `Curve` for buy amounts (#2551)
* Added `sampleBuysFromKyberNetwork` (#2551)
* Use `searchBestRate` in Kyber samples. Return 0 when Uniswap/Eth2Dai reserve (#2575)
* Add UniswapV2 (#2595)
* Sample from MultiBridge (#2593)
## v1.5.1 - _March 3, 2020_
* Dependencies updated
## v1.5.0 - _February 27, 2020_
* Add generic liquidity provider sampling (#2487)
* Use liquidity provider registry in sampler (#2499)
## v1.4.2 - _February 26, 2020_
* Dependencies updated
## v1.4.1 - _February 25, 2020_
* Dependencies updated
## v1.4.0 - _February 15, 2020_
* Added Curve contract sampling (#2483)
## v1.3.0 - _February 8, 2020_
* Catch reverts to `DevUtils` calls (#2476)
* Remove wrapper functions and introduce `batchCall()` (#2477)
## v1.2.1 - _February 6, 2020_
* Dependencies updated
## v1.2.0 - _February 4, 2020_
* Make source IDs static on all networks, not inherited from `DeploymentConstants`. (#2459)
## v1.1.0 - _January 22, 2020_
* Add batch functions to query quotes (#2427)
* Early exit if a DEX sample fails (#2427)
## v1.0.3 - _January 6, 2020_
* Add gas limits to external quote calls. (#2405)
## v1.0.2 - _December 17, 2019_
* Do not query empty/unsigned orders. Swallow revets on DEX quotes. (#2395)
## v1.0.1 - _December 9, 2019_
* Dependencies updated
## v1.0.0 - _December 2, 2019_
* Created package. (#2344)
## v1.0.0-beta.2 - _December 2, 2019_
* Dependencies updated
## v1.0.0-beta.1 - _Invalid date_
* Created package. (#2344)

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1,67 @@
## ERC20BridgeSampler
This package contains contracts used in DEX aggregation.
This is an MVP implementation, which agnostically samples DEXes for off-chain sorting and order generation. It is entirely read-only and never not touches any funds.
## Installation
**Install**
```bash
npm install @0x/contracts-erc20-bridge-sampler --save
```
## Contributing
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
For proposals regarding the 0x protocol's smart contract architecture, message format, or additional functionality, go to the [0x Improvement Proposals (ZEIPs)](https://github.com/0xProject/ZEIPs) repository and follow the contribution guidelines provided therein.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install Dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
```bash
PKG=@0x/contracts-erc20-bridge-sampler yarn build
```
Or continuously rebuild on change:
```bash
PKG=@0x/contracts-erc20-bridge-sampler yarn watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```
### Run Tests
```bash
yarn test
```

View File

@@ -8,7 +8,7 @@
"evmVersion": "istanbul",
"optimizer": {
"enabled": true,
"runs": 62500,
"runs": 1000000,
"details": { "yul": true, "deduplicate": true, "cse": true, "constantOptimizer": true }
},
"outputSelection": {

View File

@@ -1,5 +1,4 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.6;
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
@@ -36,4 +35,4 @@ contract DummyLiquidityProvider
{
takerTokenAmount = buyAmount + 1;
}
}
}

View File

@@ -0,0 +1,44 @@
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
contract DummyLiquidityProviderRegistry
{
address private constant NULL_ADDRESS = address(0x0);
mapping (address => mapping (address => address)) internal _gAddressBook;
/// @dev Sets address of pool for a market given market (xAsset, yAsset).
/// @param xToken First asset managed by pool.
/// @param yToken Second asset managed by pool.
/// @param poolAddress Address of pool.
function setLiquidityProviderForMarket(
address xToken,
address yToken,
address poolAddress
)
external
{
_gAddressBook[xToken][yToken] = poolAddress;
_gAddressBook[yToken][xToken] = poolAddress;
}
/// @dev Returns the address of pool for a market given market (xAsset, yAsset), or reverts if pool does not exist.
/// @param xToken First asset managed by pool.
/// @param yToken Second asset managed by pool.
/// @return Address of pool.
function getLiquidityProviderForMarket(
address xToken,
address yToken
)
external
view
returns (address poolAddress)
{
poolAddress = _gAddressBook[xToken][yToken];
require(
poolAddress != NULL_ADDRESS,
"Registry/MARKET_PAIR_NOT_SET"
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -17,12 +16,28 @@
*/
pragma solidity ^0.6;
pragma solidity ^0.5.9;
// solhint-disable func-name-mixedcase
interface ICurve {
/// @dev Sell `sellAmount` of `fromToken` token and receive `toToken` token.
/// This function exists on early versions of Curve (USDC/DAI)
/// @param i The token index being sold.
/// @param j The token index being bought.
/// @param sellAmount The amount of token being bought.
/// @param minBuyAmount The minimum buy amount of the token being bought.
/// @param deadline The time in seconds when this operation should expire.
function exchange_underlying(
int128 i,
int128 j,
uint256 sellAmount,
uint256 minBuyAmount,
uint256 deadline
)
external;
/// @dev Sell `sellAmount` of `fromToken` token and receive `toToken` token.
/// This function exists on later versions of Curve (USDC/DAI/USDT)
/// @param i The token index being sold.

View File

@@ -0,0 +1,45 @@
/*
Copyright 2019 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
interface IDevUtils {
/// @dev Fetches all order-relevant information needed to validate if the supplied order is fillable.
/// @param order The order structure.
/// @param signature Signature provided by maker that proves the order's authenticity.
/// `0x01` can always be provided if the signature does not need to be validated.
/// @return The orderInfo (hash, status, and `takerAssetAmount` already filled for the given order),
/// fillableTakerAssetAmount (amount of the order's `takerAssetAmount` that is fillable given all on-chain state),
/// and isValidSignature (validity of the provided signature).
/// NOTE: If the `takerAssetData` encodes data for multiple assets, `fillableTakerAssetAmount` will represent a "scaled"
/// amount, meaning it must be multiplied by all the individual asset amounts within the `takerAssetData` to get the final
/// amount of each asset that can be filled.
function getOrderRelevantState(LibOrder.Order calldata order, bytes calldata signature)
external
view
returns (
LibOrder.OrderInfo memory orderInfo,
uint256 fillableTakerAssetAmount,
bool isValidSignature
);
}

View File

@@ -0,0 +1,289 @@
/*
Copyright 2019 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.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
interface IERC20BridgeSampler {
struct FakeBuyOptions {
uint256 targetSlippageBps;
uint256 maxIterations;
}
/// @dev Call multiple public functions on this contract in a single transaction.
/// @param callDatas ABI-encoded call data for each function call.
/// @return callResults ABI-encoded results data for each call.
function batchCall(bytes[] calldata callDatas)
external
view
returns (bytes[] memory callResults);
/// @dev Queries the fillable taker asset amounts of native orders.
/// @param orders Native orders to query.
/// @param orderSignatures Signatures for each respective order in `orders`.
/// @return orderFillableTakerAssetAmounts How much taker asset can be filled
/// by each order in `orders`.
function getOrderFillableTakerAssetAmounts(
LibOrder.Order[] calldata orders,
bytes[] calldata orderSignatures
)
external
view
returns (uint256[] memory orderFillableTakerAssetAmounts);
/// @dev Queries the fillable maker asset amounts of native orders.
/// @param orders Native orders to query.
/// @param orderSignatures Signatures for each respective order in `orders`.
/// @return orderFillableMakerAssetAmounts How much maker asset can be filled
/// by each order in `orders`.
function getOrderFillableMakerAssetAmounts(
LibOrder.Order[] calldata orders,
bytes[] calldata orderSignatures
)
external
view
returns (uint256[] memory orderFillableMakerAssetAmounts);
/// @dev Sample sell quotes from Kyber.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromKyberNetwork(
address takerToken,
address makerToken,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample buy quotes from Kyber.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @param opts `FakeBuyOptions` specifying target slippage and max iterations.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromKyberNetwork(
address takerToken,
address makerToken,
uint256[] calldata makerTokenAmounts,
FakeBuyOptions calldata opts
)
external
view
returns (uint256[] memory takerTokenAmounts);
/// @dev Sample sell quotes from Eth2Dai/Oasis.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromEth2Dai(
address takerToken,
address makerToken,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample sell quotes from Uniswap.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromUniswap(
address takerToken,
address makerToken,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample buy quotes from Uniswap.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromUniswap(
address takerToken,
address makerToken,
uint256[] calldata makerTokenAmounts
)
external
view
returns (uint256[] memory takerTokenAmounts);
/// @dev Sample buy quotes from Eth2Dai/Oasis.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromEth2Dai(
address takerToken,
address makerToken,
uint256[] calldata makerTokenAmounts
)
external
view
returns (uint256[] memory takerTokenAmounts);
/// @dev Sample sell quotes from Curve.
/// @param curveAddress Address of the Curve contract.
/// @param fromTokenIdx Index of the taker token (what to sell).
/// @param toTokenIdx Index of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromCurve(
address curveAddress,
int128 fromTokenIdx,
int128 toTokenIdx,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample buy quotes from Curve.
/// @param curveAddress Address of the Curve contract.
/// @param fromTokenIdx Index of the taker token (what to sell).
/// @param toTokenIdx Index of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromCurve(
address curveAddress,
int128 fromTokenIdx,
int128 toTokenIdx,
uint256[] calldata makerTokenAmounts
)
external
view
returns (uint256[] memory takerTokenAmounts);
/// @dev Sample sell quotes from an arbitrary on-chain liquidity provider.
/// @param registryAddress Address of the liquidity provider registry contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromLiquidityProviderRegistry(
address registryAddress,
address takerToken,
address makerToken,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample sell quotes from MultiBridge.
/// @param multibridge Address of the MultiBridge contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param intermediateToken The address of the intermediate token to
/// use in an indirect route.
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromMultiBridge(
address multibridge,
address takerToken,
address intermediateToken,
address makerToken,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample buy quotes from an arbitrary on-chain liquidity provider.
/// @param registryAddress Address of the liquidity provider registry contract.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @param opts `FakeBuyOptions` specifying target slippage and max iterations.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromLiquidityProviderRegistry(
address registryAddress,
address takerToken,
address makerToken,
uint256[] calldata makerTokenAmounts,
FakeBuyOptions calldata opts
)
external
view
returns (uint256[] memory takerTokenAmounts);
/// @dev Returns the address of a liquidity provider for the given market
/// (takerToken, makerToken), from a registry of liquidity providers.
/// Returns address(0) if no such provider exists in the registry.
/// @param takerToken Taker asset managed by liquidity provider.
/// @param makerToken Maker asset managed by liquidity provider.
/// @return providerAddress Address of the liquidity provider.
function getLiquidityProviderFromRegistry(
address registryAddress,
address takerToken,
address makerToken
)
external
view
returns (address providerAddress);
/// @dev Sample sell quotes from UniswapV2.
/// @param path Token route.
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromUniswapV2(
address[] calldata path,
uint256[] calldata takerTokenAmounts
)
external
view
returns (uint256[] memory makerTokenAmounts);
/// @dev Sample buy quotes from UniswapV2.
/// @param path Token route.
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromUniswapV2(
address[] calldata path,
uint256[] calldata makerTokenAmounts
)
external
view
returns (uint256[] memory takerTokenAmounts);
}

View File

@@ -1,7 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -17,7 +16,7 @@
*/
pragma solidity ^0.6;
pragma solidity ^0.5.9;
interface IEth2Dai {

View File

@@ -1,6 +1,6 @@
/*
Copyright 2020 ZeroEx Intl.
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -19,16 +19,15 @@
pragma solidity ^0.5.9;
interface IShell {
interface IKyberNetwork {
function originSwap(
address from,
address to,
function searchBestRate(
address fromToken,
address toToken,
uint256 fromAmount,
uint256 minTargetAmount,
uint256 deadline
bool usePermissionless
)
external
returns (uint256 toAmount);
view
returns (address reserve, uint256 expectedRate);
}

View File

@@ -1,6 +1,6 @@
/*
Copyright 2020 ZeroEx Intl.
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -19,14 +19,16 @@
pragma solidity ^0.5.9;
interface IMStable {
interface IKyberNetworkProxy {
function swap(
address _input,
address _output,
uint256 _quantity,
address _recipient
function kyberNetworkContract() external view returns (address);
function getExpectedRate(
address fromToken,
address toToken,
uint256 fromAmount
)
external
returns (uint256 output);
view
returns (uint256 expectedRate, uint256 slippageRate);
}

View File

@@ -0,0 +1,70 @@
/*
Copyright 2019 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.5.9;
interface ILiquidityProvider {
/// @dev Transfers `amount` of the ERC20 `tokenAddress` from `from` to `to`.
/// @param tokenAddress The address of the ERC20 token to transfer.
/// @param from Address to transfer asset from.
/// @param to Address to transfer asset to.
/// @param amount Amount of asset to transfer.
/// @param bridgeData Arbitrary asset data needed by the bridge contract.
/// @return success The magic bytes `0xdc1600f3` if successful.
function bridgeTransferFrom(
address tokenAddress,
address from,
address to,
uint256 amount,
bytes calldata bridgeData
)
external
returns (bytes4 success);
/// @dev Quotes the amount of `makerToken` that would be obtained by
/// selling `sellAmount` of `takerToken`.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param sellAmount Amount of `takerToken` to sell.
/// @return makerTokenAmount Amount of `makerToken` that would be obtained.
function getSellQuote(
address takerToken,
address makerToken,
uint256 sellAmount
)
external
view
returns (uint256 makerTokenAmount);
/// @dev Quotes the amount of `takerToken` that would need to be sold in
/// order to obtain `buyAmount` of `makerToken`.
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param buyAmount Amount of `makerToken` to buy.
/// @return takerTokenAmount Amount of `takerToken` that would need to be sold.
function getBuyQuote(
address takerToken,
address makerToken,
uint256 buyAmount
)
external
view
returns (uint256 takerTokenAmount);
}

View File

@@ -1,6 +1,6 @@
/*
Copyright 2020 ZeroEx Intl.
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -19,22 +19,18 @@
pragma solidity ^0.5.9;
interface IMooniswapRegistry {
interface ILiquidityProviderRegistry {
function pools(address token1, address token2) external view returns(address);
}
interface IMooniswap {
function swap(
address fromToken,
address destToken,
uint256 amount,
uint256 minReturn,
address referral
/// @dev Returns the address of a liquidity provider for the given market
/// (takerToken, makerToken), reverting if the pool does not exist.
/// @param takerToken Taker asset managed by liquidity provider.
/// @param makerToken Maker asset managed by liquidity provider.
/// @return Address of the liquidity provider.
function getLiquidityProviderForMarket(
address takerToken,
address makerToken
)
external
payable
returns(uint256 returnAmount);
view
returns (address providerAddress);
}

View File

@@ -1,4 +1,3 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
@@ -17,7 +16,7 @@
*/
pragma solidity ^0.6;
pragma solidity ^0.5.9;
interface IMultiBridge {

View File

@@ -1,7 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -17,7 +16,7 @@
*/
pragma solidity ^0.6;
pragma solidity ^0.5.9;
interface IUniswapExchangeQuotes {

View File

@@ -1,7 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -17,7 +16,7 @@
*/
pragma solidity ^0.6;
pragma solidity ^0.5.9;
interface IUniswapV2Router01 {

View File

@@ -1,7 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -16,13 +15,17 @@
limitations under the License.
*/
pragma solidity ^0.6;
pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-asset-proxy/contracts/src/interfaces/IUniswapExchangeFactory.sol";
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "../src/ERC20BridgeSampler.sol";
import "../src/interfaces/IEth2Dai.sol";
import "../src/interfaces/IKyberNetwork.sol";
import "../src/interfaces/IUniswapV2Router01.sol";
import "../src/IEth2Dai.sol";
import "../src/IDevUtils.sol";
import "../src/IKyberNetworkProxy.sol";
import "../src/IUniswapV2Router01.sol";
library LibDeterministicQuotes {
@@ -126,7 +129,6 @@ contract TestERC20BridgeSamplerUniswapExchange is
function getEthToTokenInputPrice(
uint256 ethSold
)
override
external
view
returns (uint256 tokensBought)
@@ -144,7 +146,6 @@ contract TestERC20BridgeSamplerUniswapExchange is
function getEthToTokenOutputPrice(
uint256 tokensBought
)
override
external
view
returns (uint256 ethSold)
@@ -162,7 +163,6 @@ contract TestERC20BridgeSamplerUniswapExchange is
function getTokenToEthInputPrice(
uint256 tokensSold
)
override
external
view
returns (uint256 ethBought)
@@ -180,7 +180,6 @@ contract TestERC20BridgeSamplerUniswapExchange is
function getTokenToEthOutputPrice(
uint256 ethBought
)
override
external
view
returns (uint256 tokensSold)
@@ -205,7 +204,6 @@ contract TestERC20BridgeSamplerUniswapV2Router01 is
// Deterministic `IUniswapV2Router01.getAmountsOut()`.
function getAmountsOut(uint256 amountIn, address[] calldata path)
override
external
view
returns (uint256[] memory amounts)
@@ -226,7 +224,6 @@ contract TestERC20BridgeSamplerUniswapV2Router01 is
// Deterministic `IUniswapV2Router01.getAmountsInt()`.
function getAmountsIn(uint256 amountOut, address[] calldata path)
override
external
view
returns (uint256[] memory amounts)
@@ -247,95 +244,35 @@ contract TestERC20BridgeSamplerUniswapV2Router01 is
}
// solhint-disable space-after-comma
contract TestERC20BridgeSamplerKyberNetwork is
IKyberNetwork,
DeploymentConstants,
FailTrigger
{
bytes32 constant private SALT = 0x0ff3ca9d46195c39f9a12afb74207b4970349fb3cfb1e459bbf170298d326bc7;
address constant public ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
enum TradeType {BestOfAll, MaskIn, MaskOut, Split}
enum ProcessWithRate {NotRequired, Required}
// IKyberHintHandler
function buildTokenToEthHint(
address tokenSrc,
TradeType /* tokenToEthType */,
bytes32[] calldata /* tokenToEthReserveIds */,
uint256[] calldata /* tokenToEthSplits */
) external view returns (bytes memory hint)
{
return abi.encode(tokenSrc);
}
function buildEthToTokenHint(
address tokenDest,
TradeType /* ethToTokenType */,
bytes32[] calldata /* ethToTokenReserveIds */,
uint256[] calldata /* ethToTokenSplits */
) external view returns (bytes memory hint)
{
return abi.encode(tokenDest);
}
// IKyberHintHandler
function buildTokenToTokenHint(
address tokenSrc,
TradeType /* tokenToEthType */,
bytes32[] calldata /* tokenToEthReserveIds */,
uint256[] calldata /* tokenToEthSplits */,
address /* tokenDest */,
TradeType /* EthToTokenType */,
bytes32[] calldata /* EthToTokenReserveIds */,
uint256[] calldata /* EthToTokenSplits */
) external view returns (bytes memory hint)
{
return abi.encode(tokenSrc);
}
// IKyberHintHandler
function getTradingReserves(
address tokenSrc,
address tokenDest,
bool isTokenToToken,
bytes calldata hint
)
function kyberNetworkContract()
external
view
returns (
bytes32[] memory reserveIds,
uint256[] memory splitValuesBps,
ProcessWithRate processWithRate
)
returns (address)
{
reserveIds = new bytes32[](1);
reserveIds[0] = bytes32(uint256(1));
splitValuesBps = new uint256[](0);
processWithRate = ProcessWithRate.NotRequired;
return address(this);
}
// Deterministic `IKyberNetworkProxy.getExpectedRateAfterFee()`.
function getExpectedRateAfterFee(
// IKyberNetwork not exposed via IKyberNetworkProxy
function searchBestRate(
address fromToken,
address toToken,
uint256 /* srcQty */,
uint256 /* fee */,
bytes calldata /* hint */
uint256 fromAmount,
bool // usePermissionless
)
external
view
returns
(uint256 expectedRate)
returns (address reserve, uint256 expectedRate)
{
_revertIfShouldFail();
fromToken = fromToken == ETH_ADDRESS ? _getWethAddress() : fromToken;
toToken = toToken == ETH_ADDRESS ? _getWethAddress() : toToken;
expectedRate = LibDeterministicQuotes.getDeterministicRate(
SALT,
fromToken,
toToken
);
(expectedRate, ) = this.getExpectedRate(fromToken, toToken, fromAmount);
return (address(this), expectedRate);
}
// Deterministic `IKyberNetworkProxy.getExpectedRate()`.
@@ -357,24 +294,6 @@ contract TestERC20BridgeSamplerKyberNetwork is
toToken
);
}
function _getKyberNetworkProxyAddress()
override
internal
view
returns (address)
{
return address(this);
}
function _getKyberHintHandlerAddress()
override
internal
view
returns (address)
{
return address(this);
}
}
@@ -390,7 +309,6 @@ contract TestERC20BridgeSamplerEth2Dai is
address payToken,
uint256 payAmount
)
override
external
view
returns (uint256 buyAmount)
@@ -410,7 +328,6 @@ contract TestERC20BridgeSamplerEth2Dai is
address buyToken,
uint256 buyAmount
)
override
external
view
returns (uint256 payAmount)
@@ -444,7 +361,6 @@ contract TestERC20BridgeSamplerUniswapExchangeFactory is
// `IUniswapExchangeFactory.getExchange()`.
function getExchange(address tokenAddress)
override
external
view
returns (address)
@@ -463,9 +379,9 @@ contract TestERC20BridgeSampler is
TestERC20BridgeSamplerEth2Dai public eth2Dai;
TestERC20BridgeSamplerKyberNetwork public kyber;
uint8 private constant MAX_ORDER_STATUS = uint8(IExchange.OrderStatus.CANCELLED) + 1;
uint8 private constant MAX_ORDER_STATUS = uint8(LibOrder.OrderStatus.CANCELLED) + 1;
constructor() public ERC20BridgeSampler() {
constructor() public ERC20BridgeSampler(address(this)) {
uniswap = new TestERC20BridgeSamplerUniswapExchangeFactory();
uniswapV2Router = new TestERC20BridgeSamplerUniswapV2Router01();
eth2Dai = new TestERC20BridgeSamplerEth2Dai();
@@ -479,23 +395,37 @@ contract TestERC20BridgeSampler is
uniswap.createTokenExchanges(tokenAddresses);
}
// Overridden to return deterministic states.
function getOrderFillableTakerAmount(
IExchange.Order memory order,
bytes memory,
IExchange
// `IDevUtils.getOrderRelevantState()`, overridden to return deterministic
// states.
function getOrderRelevantState(
LibOrder.Order memory order,
bytes memory
)
override
public
view
returns (uint256 fillableTakerAmount)
pure
returns (
LibOrder.OrderInfo memory orderInfo,
uint256 fillableTakerAssetAmount,
bool isValidSignature
)
{
return uint256(keccak256(abi.encode(order.salt))) % order.takerAssetAmount;
// The order hash is just the hash of the salt.
bytes32 orderHash = keccak256(abi.encode(order.salt));
// Everything else is derived from the hash.
orderInfo.orderHash = orderHash;
if (uint256(orderHash) % 100 > 90) {
orderInfo.orderStatus = LibOrder.OrderStatus.FULLY_FILLED;
} else {
orderInfo.orderStatus = LibOrder.OrderStatus.FILLABLE;
}
orderInfo.orderTakerAssetFilledAmount = uint256(orderHash) % order.takerAssetAmount;
fillableTakerAssetAmount =
order.takerAssetAmount - orderInfo.orderTakerAssetFilledAmount;
isValidSignature = uint256(orderHash) % 2 == 1;
}
// Overriden to return deterministic decimals.
function _getTokenDecimals(address tokenAddress)
override
internal
view
returns (uint8 decimals)
@@ -505,7 +435,6 @@ contract TestERC20BridgeSampler is
// Overriden to point to a custom contract.
function _getEth2DaiAddress()
override
internal
view
returns (address eth2daiAddress)
@@ -515,7 +444,6 @@ contract TestERC20BridgeSampler is
// Overriden to point to a custom contract.
function _getUniswapExchangeFactoryAddress()
override
internal
view
returns (address uniswapAddress)
@@ -525,7 +453,6 @@ contract TestERC20BridgeSampler is
// Overriden to point to a custom contract.
function _getUniswapV2Router01Address()
override
internal
view
returns (address uniswapV2RouterAddress)
@@ -535,17 +462,6 @@ contract TestERC20BridgeSampler is
// Overriden to point to a custom contract.
function _getKyberNetworkProxyAddress()
override
internal
view
returns (address kyberAddress)
{
return address(kyber);
}
// Overriden to point to a custom contract.
function _getKyberHintHandlerAddress()
override
internal
view
returns (address kyberAddress)

View File

@@ -0,0 +1,92 @@
{
"name": "@0x/contracts-erc20-bridge-sampler",
"version": "1.6.0",
"engines": {
"node": ">=6.12"
},
"description": "Sampler contracts for the 0x asset-swapper",
"main": "lib/src/index.js",
"directories": {
"test": "test"
},
"scripts": {
"build": "yarn pre_build && tsc -b",
"build:ci": "yarn build",
"pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s build test",
"test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov",
"test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html",
"test:trace": "SOLIDITY_REVERT_TRACE=true run-s build run_mocha",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe 'lib/test/**/*.js' --timeout 100000 --bail --exit",
"compile": "sol-compiler",
"watch": "sol-compiler -w",
"clean": "shx rm -rf lib test/generated-artifacts test/generated-wrappers generated-artifacts generated-wrappers",
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers",
"lint": "tslint --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./test/generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
"fix": "tslint --fix --format stylish --project . --exclude ./generated-wrappers/**/* --exclude ./generated-artifacts/**/* --exclude ./test/generated-wrappers/**/* --exclude ./test/generated-artifacts/**/* --exclude **/lib/**/* && yarn lint-contracts",
"coverage:report:text": "istanbul report text",
"coverage:report:html": "istanbul report html && open coverage/index.html",
"profiler:report:html": "istanbul report html && open coverage/index.html",
"coverage:report:lcov": "istanbul report lcov",
"test:circleci": "yarn test",
"contracts:gen": "contracts-gen generate",
"contracts:copy": "contracts-gen copy",
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol",
"compile:truffle": "truffle compile"
},
"config": {
"publicInterfaceContracts": "ERC20BridgeSampler,IERC20BridgeSampler,ILiquidityProvider,ILiquidityProviderRegistry,DummyLiquidityProviderRegistry,DummyLiquidityProvider",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
"abis": "./test/generated-artifacts/@(DummyLiquidityProvider|DummyLiquidityProviderRegistry|ERC20BridgeSampler|ICurve|IDevUtils|IERC20BridgeSampler|IEth2Dai|IKyberNetwork|IKyberNetworkProxy|ILiquidityProvider|ILiquidityProviderRegistry|IMultiBridge|IUniswapExchangeQuotes|IUniswapV2Router01|TestERC20BridgeSampler).json"
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.3.0",
"@0x/contracts-asset-proxy": "^3.3.0",
"@0x/contracts-erc20": "^3.2.0",
"@0x/contracts-exchange": "^3.2.6",
"@0x/contracts-exchange-libs": "^4.3.6",
"@0x/contracts-gen": "^2.0.9",
"@0x/contracts-test-utils": "^5.3.3",
"@0x/contracts-utils": "^4.5.0",
"@0x/dev-utils": "^3.2.2",
"@0x/sol-compiler": "^4.1.0",
"@0x/tslint-config": "^4.0.0",
"@0x/web3-wrapper": "^7.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.2",
"@0x/types": "^3.1.3",
"@0x/typescript-typings": "^5.1.0",
"@0x/utils": "^5.5.0",
"ethereum-types": "^3.1.1",
"lodash": "^4.17.11"
},
"publishConfig": {
"access": "public"
}
}

View File

@@ -0,0 +1,21 @@
/*
* -----------------------------------------------------------------------------
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
import { ContractArtifact } from 'ethereum-types';
import * as DummyLiquidityProvider from '../generated-artifacts/DummyLiquidityProvider.json';
import * as DummyLiquidityProviderRegistry from '../generated-artifacts/DummyLiquidityProviderRegistry.json';
import * as ERC20BridgeSampler from '../generated-artifacts/ERC20BridgeSampler.json';
import * as IERC20BridgeSampler from '../generated-artifacts/IERC20BridgeSampler.json';
import * as ILiquidityProvider from '../generated-artifacts/ILiquidityProvider.json';
import * as ILiquidityProviderRegistry from '../generated-artifacts/ILiquidityProviderRegistry.json';
export const artifacts = {
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
IERC20BridgeSampler: IERC20BridgeSampler as ContractArtifact,
ILiquidityProvider: ILiquidityProvider as ContractArtifact,
ILiquidityProviderRegistry: ILiquidityProviderRegistry as ContractArtifact,
DummyLiquidityProviderRegistry: DummyLiquidityProviderRegistry as ContractArtifact,
DummyLiquidityProvider: DummyLiquidityProvider as ContractArtifact,
};

View File

@@ -0,0 +1,2 @@
export * from './wrappers';
export * from './artifacts';

View File

@@ -0,0 +1,11 @@
/*
* -----------------------------------------------------------------------------
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/dummy_liquidity_provider';
export * from '../generated-wrappers/dummy_liquidity_provider_registry';
export * from '../generated-wrappers/erc20_bridge_sampler';
export * from '../generated-wrappers/i_erc20_bridge_sampler';
export * from '../generated-wrappers/i_liquidity_provider';
export * from '../generated-wrappers/i_liquidity_provider_registry';

View File

@@ -0,0 +1,39 @@
/*
* -----------------------------------------------------------------------------
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
import { ContractArtifact } from 'ethereum-types';
import * as DummyLiquidityProvider from '../test/generated-artifacts/DummyLiquidityProvider.json';
import * as DummyLiquidityProviderRegistry from '../test/generated-artifacts/DummyLiquidityProviderRegistry.json';
import * as ERC20BridgeSampler from '../test/generated-artifacts/ERC20BridgeSampler.json';
import * as ICurve from '../test/generated-artifacts/ICurve.json';
import * as IDevUtils from '../test/generated-artifacts/IDevUtils.json';
import * as IERC20BridgeSampler from '../test/generated-artifacts/IERC20BridgeSampler.json';
import * as IEth2Dai from '../test/generated-artifacts/IEth2Dai.json';
import * as IKyberNetwork from '../test/generated-artifacts/IKyberNetwork.json';
import * as IKyberNetworkProxy from '../test/generated-artifacts/IKyberNetworkProxy.json';
import * as ILiquidityProvider from '../test/generated-artifacts/ILiquidityProvider.json';
import * as ILiquidityProviderRegistry from '../test/generated-artifacts/ILiquidityProviderRegistry.json';
import * as IMultiBridge from '../test/generated-artifacts/IMultiBridge.json';
import * as IUniswapExchangeQuotes from '../test/generated-artifacts/IUniswapExchangeQuotes.json';
import * as IUniswapV2Router01 from '../test/generated-artifacts/IUniswapV2Router01.json';
import * as TestERC20BridgeSampler from '../test/generated-artifacts/TestERC20BridgeSampler.json';
export const artifacts = {
DummyLiquidityProvider: DummyLiquidityProvider as ContractArtifact,
DummyLiquidityProviderRegistry: DummyLiquidityProviderRegistry as ContractArtifact,
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
ICurve: ICurve as ContractArtifact,
IDevUtils: IDevUtils as ContractArtifact,
IERC20BridgeSampler: IERC20BridgeSampler as ContractArtifact,
IEth2Dai: IEth2Dai as ContractArtifact,
IKyberNetwork: IKyberNetwork as ContractArtifact,
IKyberNetworkProxy: IKyberNetworkProxy as ContractArtifact,
ILiquidityProvider: ILiquidityProvider as ContractArtifact,
ILiquidityProviderRegistry: ILiquidityProviderRegistry as ContractArtifact,
IMultiBridge: IMultiBridge as ContractArtifact,
IUniswapExchangeQuotes: IUniswapExchangeQuotes as ContractArtifact,
IUniswapV2Router01: IUniswapV2Router01 as ContractArtifact,
TestERC20BridgeSampler: TestERC20BridgeSampler as ContractArtifact,
};

View File

@@ -10,13 +10,12 @@ import { Order } from '@0x/types';
import { BigNumber, hexUtils } from '@0x/utils';
import * as _ from 'lodash';
import { SamplerCallResult } from '../../src/types';
import { artifacts } from '../artifacts';
import { DummyLiquidityProviderContract, TestERC20BridgeSamplerContract } from '../wrappers';
// tslint:disable: custom-no-magic-numbers
const { NULL_ADDRESS } = constants;
import { artifacts } from './artifacts';
import {
DummyLiquidityProviderContract,
DummyLiquidityProviderRegistryContract,
TestERC20BridgeSamplerContract,
} from './wrappers';
blockchainTests('erc20-bridge-sampler', env => {
let testContract: TestERC20BridgeSamplerContract;
@@ -34,8 +33,10 @@ blockchainTests('erc20-bridge-sampler', env => {
const INVALID_TOKEN_PAIR_ERROR = 'ERC20BridgeSampler/INVALID_TOKEN_PAIR';
const MAKER_TOKEN = randomAddress();
const TAKER_TOKEN = randomAddress();
const INTERMEDIATE_TOKEN = randomAddress();
const KYBER_RESERVE_OFFSET = new BigNumber(0);
const FAKE_BUY_OPTS = {
targetSlippageBps: new BigNumber(5),
maxIterations: new BigNumber(5),
};
before(async () => {
testContract = await TestERC20BridgeSamplerContract.deployFrom0xArtifactAsync(
@@ -209,7 +210,12 @@ blockchainTests('erc20-bridge-sampler', env => {
function getDeterministicFillableTakerAssetAmount(order: Order): BigNumber {
const hash = getPackedHash(hexUtils.leftPad(order.salt));
return new BigNumber(hash).mod(order.takerAssetAmount);
const orderStatus = new BigNumber(hash).mod(100).toNumber() > 90 ? 5 : 3;
const isValidSignature = !!new BigNumber(hash).mod(2).toNumber();
if (orderStatus !== 3 || !isValidSignature) {
return constants.ZERO_AMOUNT;
}
return order.takerAssetAmount.minus(new BigNumber(hash).mod(order.takerAssetAmount));
}
function getDeterministicFillableMakerAssetAmount(order: Order): BigNumber {
@@ -261,48 +267,42 @@ blockchainTests('erc20-bridge-sampler', env => {
await testContract.enableFailTrigger().awaitTransactionSuccessAsync({ value: 1 });
}
function expectQuotesWithinRange(
quotes: BigNumber[],
expectedQuotes: BigNumber[],
maxSlippage: BigNumber | number,
): void {
quotes.forEach((_q, i) => {
// If we're within 1 base unit of a low decimal token
// then that's as good as we're going to get (and slippage is "high")
if (
expectedQuotes[i].isZero() ||
BigNumber.max(expectedQuotes[i], quotes[i])
.minus(BigNumber.min(expectedQuotes[i], quotes[i]))
.eq(1)
) {
return;
}
const slippage = quotes[i]
.dividedBy(expectedQuotes[i])
.minus(1)
.decimalPlaces(4);
expect(slippage, `quote[${i}]: ${slippage} ${quotes[i]} ${expectedQuotes[i]}`).to.be.bignumber.gte(0);
expect(slippage, `quote[${i}] ${slippage} ${quotes[i]} ${expectedQuotes[i]}`).to.be.bignumber.lte(
new BigNumber(maxSlippage),
);
});
}
describe('getOrderFillableTakerAssetAmounts()', () => {
it('returns the expected amount for each order', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN);
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const expected = orders.map(getDeterministicFillableTakerAssetAmount);
const actual = await testContract
.getOrderFillableTakerAssetAmounts(orders, signatures, NULL_ADDRESS)
.callAsync();
const actual = await testContract.getOrderFillableTakerAssetAmounts(orders, signatures).callAsync();
expect(actual).to.deep.eq(expected);
});
it('returns empty for no orders', async () => {
const actual = await testContract.getOrderFillableTakerAssetAmounts([], [], NULL_ADDRESS).callAsync();
const actual = await testContract.getOrderFillableTakerAssetAmounts([], []).callAsync();
expect(actual).to.deep.eq([]);
});
it('returns zero for an order with zero maker asset amount', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
orders[0].makerAssetAmount = constants.ZERO_AMOUNT;
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const actual = await testContract.getOrderFillableTakerAssetAmounts(orders, signatures).callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
it('returns zero for an order with zero taker asset amount', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
orders[0].takerAssetAmount = constants.ZERO_AMOUNT;
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const actual = await testContract.getOrderFillableTakerAssetAmounts(orders, signatures).callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
it('returns zero for an order with an empty signature', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
const signatures: string[] = _.times(orders.length, () => constants.NULL_BYTES);
const actual = await testContract.getOrderFillableTakerAssetAmounts(orders, signatures).callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
});
describe('getOrderFillableMakerAssetAmounts()', () => {
@@ -310,16 +310,37 @@ blockchainTests('erc20-bridge-sampler', env => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN);
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const expected = orders.map(getDeterministicFillableMakerAssetAmount);
const actual = await testContract
.getOrderFillableMakerAssetAmounts(orders, signatures, NULL_ADDRESS)
.callAsync();
const actual = await testContract.getOrderFillableMakerAssetAmounts(orders, signatures).callAsync();
expect(actual).to.deep.eq(expected);
});
it('returns empty for no orders', async () => {
const actual = await testContract.getOrderFillableMakerAssetAmounts([], [], NULL_ADDRESS).callAsync();
const actual = await testContract.getOrderFillableMakerAssetAmounts([], []).callAsync();
expect(actual).to.deep.eq([]);
});
it('returns zero for an order with zero maker asset amount', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
orders[0].makerAssetAmount = constants.ZERO_AMOUNT;
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const actual = await testContract.getOrderFillableMakerAssetAmounts(orders, signatures).callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
it('returns zero for an order with zero taker asset amount', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
orders[0].takerAssetAmount = constants.ZERO_AMOUNT;
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const actual = await testContract.getOrderFillableMakerAssetAmounts(orders, signatures).callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
it('returns zero for an order with an empty signature', async () => {
const orders = createOrders(MAKER_TOKEN, TAKER_TOKEN, 1);
const signatures: string[] = _.times(orders.length, () => constants.NULL_BYTES);
const actual = await testContract.getOrderFillableMakerAssetAmounts(orders, signatures).callAsync();
expect(actual).to.deep.eq([constants.ZERO_AMOUNT]);
});
});
blockchainTests.resets('sampleSellsFromKyberNetwork()', () => {
@@ -328,25 +349,31 @@ blockchainTests('erc20-bridge-sampler', env => {
});
it('throws if tokens are the same', async () => {
const tx = testContract
.sampleSellsFromKyberNetwork(KYBER_RESERVE_OFFSET, MAKER_TOKEN, MAKER_TOKEN, [])
.callAsync();
const tx = testContract.sampleSellsFromKyberNetwork(MAKER_TOKEN, MAKER_TOKEN, []).callAsync();
return expect(tx).to.revertWith(INVALID_TOKEN_PAIR_ERROR);
});
it('can return no quotes', async () => {
const [, , quotes] = await testContract
.sampleSellsFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, MAKER_TOKEN, [])
.callAsync();
const quotes = await testContract.sampleSellsFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, []).callAsync();
expect(quotes).to.deep.eq([]);
});
it('can quote token -> token', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [takerToEthQuotes] = getDeterministicSellQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Kyber'], sampleAmounts);
const [expectedQuotes] = getDeterministicSellQuotes(WETH_ADDRESS, MAKER_TOKEN, ['Kyber'], takerToEthQuotes);
const quotes = await testContract
.sampleSellsFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
it('returns zero if token -> token fails', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const [, , quotes] = await testContract
.sampleSellsFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
const quotes = await testContract
.sampleSellsFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
@@ -354,17 +381,8 @@ blockchainTests('erc20-bridge-sampler', env => {
it('can quote token -> ETH', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [expectedQuotes] = getDeterministicSellQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Kyber'], sampleAmounts);
const [, , quotes] = await testContract
.sampleSellsFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, WETH_ADDRESS, sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
it('can quote token -> token', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [expectedQuotes] = getDeterministicSellQuotes(TAKER_TOKEN, MAKER_TOKEN, ['Kyber'], sampleAmounts);
const [, , quotes] = await testContract
.sampleSellsFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
const quotes = await testContract
.sampleSellsFromKyberNetwork(TAKER_TOKEN, WETH_ADDRESS, sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
@@ -373,8 +391,8 @@ blockchainTests('erc20-bridge-sampler', env => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const [, , quotes] = await testContract
.sampleSellsFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, WETH_ADDRESS, sampleAmounts)
const quotes = await testContract
.sampleSellsFromKyberNetwork(TAKER_TOKEN, WETH_ADDRESS, sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
@@ -382,8 +400,8 @@ blockchainTests('erc20-bridge-sampler', env => {
it('can quote ETH -> token', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [expectedQuotes] = getDeterministicSellQuotes(WETH_ADDRESS, TAKER_TOKEN, ['Kyber'], sampleAmounts);
const [, , quotes] = await testContract
.sampleSellsFromKyberNetwork(KYBER_RESERVE_OFFSET, WETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
const quotes = await testContract
.sampleSellsFromKyberNetwork(WETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
@@ -392,8 +410,8 @@ blockchainTests('erc20-bridge-sampler', env => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const [, , quotes] = await testContract
.sampleSellsFromKyberNetwork(KYBER_RESERVE_OFFSET, WETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
const quotes = await testContract
.sampleSellsFromKyberNetwork(WETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
@@ -406,24 +424,49 @@ blockchainTests('erc20-bridge-sampler', env => {
});
it('throws if tokens are the same', async () => {
const tx = testContract
.sampleBuysFromKyberNetwork(KYBER_RESERVE_OFFSET, MAKER_TOKEN, MAKER_TOKEN, [])
.callAsync();
const tx = testContract.sampleBuysFromKyberNetwork(MAKER_TOKEN, MAKER_TOKEN, [], FAKE_BUY_OPTS).callAsync();
return expect(tx).to.revertWith(INVALID_TOKEN_PAIR_ERROR);
});
it('can return no quotes', async () => {
const [, , quotes] = await testContract
.sampleBuysFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, MAKER_TOKEN, [])
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, [], FAKE_BUY_OPTS)
.callAsync();
expect(quotes).to.deep.eq([]);
});
const expectQuotesWithinRange = (
quotes: BigNumber[],
expectedQuotes: BigNumber[],
maxSlippage: BigNumber | number,
) => {
quotes.forEach((_q, i) => {
// If we're within 1 base unit of a low decimal token
// then that's as good as we're going to get (and slippage is "high")
if (
expectedQuotes[i].isZero() ||
BigNumber.max(expectedQuotes[i], quotes[i])
.minus(BigNumber.min(expectedQuotes[i], quotes[i]))
.eq(1)
) {
return;
}
const slippage = quotes[i]
.dividedBy(expectedQuotes[i])
.minus(1)
.decimalPlaces(4);
expect(slippage, `quote[${i}]: ${slippage} ${quotes[i]} ${expectedQuotes[i]}`).to.be.bignumber.gte(0);
expect(slippage, `quote[${i}] ${slippage} ${quotes[i]} ${expectedQuotes[i]}`).to.be.bignumber.lte(
new BigNumber(maxSlippage),
);
});
};
it('can quote token -> token', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [expectedQuotes] = getDeterministicBuyQuotes(TAKER_TOKEN, MAKER_TOKEN, ['Kyber'], sampleAmounts);
const [, , quotes] = await testContract
.sampleBuysFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
const [ethToMakerQuotes] = getDeterministicBuyQuotes(WETH_ADDRESS, MAKER_TOKEN, ['Kyber'], sampleAmounts);
const [expectedQuotes] = getDeterministicBuyQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Kyber'], ethToMakerQuotes);
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expectQuotesWithinRange(quotes, expectedQuotes, ACCEPTABLE_SLIPPAGE);
});
@@ -432,8 +475,8 @@ blockchainTests('erc20-bridge-sampler', env => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const [, , quotes] = await testContract
.sampleBuysFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, MAKER_TOKEN, sampleAmounts)
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, MAKER_TOKEN, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
@@ -441,8 +484,8 @@ blockchainTests('erc20-bridge-sampler', env => {
it('can quote token -> ETH', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [expectedQuotes] = getDeterministicBuyQuotes(TAKER_TOKEN, WETH_ADDRESS, ['Kyber'], sampleAmounts);
const [, , quotes] = await testContract
.sampleBuysFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, WETH_ADDRESS, sampleAmounts)
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, WETH_ADDRESS, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expectQuotesWithinRange(quotes, expectedQuotes, ACCEPTABLE_SLIPPAGE);
});
@@ -451,8 +494,8 @@ blockchainTests('erc20-bridge-sampler', env => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const [, , quotes] = await testContract
.sampleBuysFromKyberNetwork(KYBER_RESERVE_OFFSET, TAKER_TOKEN, WETH_ADDRESS, sampleAmounts)
const quotes = await testContract
.sampleBuysFromKyberNetwork(TAKER_TOKEN, WETH_ADDRESS, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
@@ -460,8 +503,8 @@ blockchainTests('erc20-bridge-sampler', env => {
it('can quote ETH -> token', async () => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const [expectedQuotes] = getDeterministicBuyQuotes(WETH_ADDRESS, TAKER_TOKEN, ['Kyber'], sampleAmounts);
const [, , quotes] = await testContract
.sampleBuysFromKyberNetwork(KYBER_RESERVE_OFFSET, WETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
const quotes = await testContract
.sampleBuysFromKyberNetwork(WETH_ADDRESS, TAKER_TOKEN, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expectQuotesWithinRange(quotes, expectedQuotes, ACCEPTABLE_SLIPPAGE);
});
@@ -470,8 +513,8 @@ blockchainTests('erc20-bridge-sampler', env => {
const sampleAmounts = getSampleAmounts(TAKER_TOKEN);
const expectedQuotes = _.times(sampleAmounts.length, () => constants.ZERO_AMOUNT);
await enableFailTriggerAsync();
const [, , quotes] = await testContract
.sampleBuysFromKyberNetwork(KYBER_RESERVE_OFFSET, WETH_ADDRESS, TAKER_TOKEN, sampleAmounts)
const quotes = await testContract
.sampleBuysFromKyberNetwork(WETH_ADDRESS, TAKER_TOKEN, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
expect(quotes).to.deep.eq(expectedQuotes);
});
@@ -809,11 +852,12 @@ blockchainTests('erc20-bridge-sampler', env => {
});
});
describe('liquidity provider', () => {
describe('getLiquidityProviderFromRegistry', () => {
const xAsset = randomAddress();
const yAsset = randomAddress();
const sampleAmounts = getSampleAmounts(yAsset);
let liquidityProvider: DummyLiquidityProviderContract;
let registryContract: DummyLiquidityProviderRegistryContract;
before(async () => {
liquidityProvider = await DummyLiquidityProviderContract.deployFrom0xArtifactAsync(
@@ -822,31 +866,78 @@ blockchainTests('erc20-bridge-sampler', env => {
env.txDefaults,
{},
);
registryContract = await DummyLiquidityProviderRegistryContract.deployFrom0xArtifactAsync(
artifacts.DummyLiquidityProviderRegistry,
env.provider,
env.txDefaults,
{},
);
await registryContract
.setLiquidityProviderForMarket(xAsset, yAsset, liquidityProvider.address)
.awaitTransactionSuccessAsync();
});
it('should be able to get the liquidity provider', async () => {
const xyLiquidityProvider = await testContract
.getLiquidityProviderFromRegistry(registryContract.address, xAsset, yAsset)
.callAsync();
const yxLiquidityProvider = await testContract
.getLiquidityProviderFromRegistry(registryContract.address, yAsset, xAsset)
.callAsync();
const unknownLiquidityProvider = await testContract
.getLiquidityProviderFromRegistry(registryContract.address, yAsset, randomAddress())
.callAsync();
expect(xyLiquidityProvider).to.eq(liquidityProvider.address);
expect(yxLiquidityProvider).to.eq(liquidityProvider.address);
expect(unknownLiquidityProvider).to.eq(constants.NULL_ADDRESS);
});
it('should be able to query sells from the liquidity provider', async () => {
const quotes = await testContract
.sampleSellsFromLiquidityProvider(liquidityProvider.address, yAsset, xAsset, sampleAmounts)
const result = await testContract
.sampleSellsFromLiquidityProviderRegistry(registryContract.address, yAsset, xAsset, sampleAmounts)
.callAsync();
quotes.forEach((value, idx) => {
result.forEach((value, idx) => {
expect(value).is.bignumber.eql(sampleAmounts[idx].minus(1));
});
});
it('should be able to query buys from the liquidity provider', async () => {
const quotes = await testContract
.sampleBuysFromLiquidityProvider(liquidityProvider.address, yAsset, xAsset, sampleAmounts)
const result = await testContract
.sampleBuysFromLiquidityProviderRegistry(
registryContract.address,
yAsset,
xAsset,
sampleAmounts,
FAKE_BUY_OPTS,
)
.callAsync();
quotes.forEach((value, idx) => {
result.forEach((value, idx) => {
expect(value).is.bignumber.eql(sampleAmounts[idx].plus(1));
});
});
it('should just return zeros if the liquidity provider does not exist', async () => {
const quotes = await testContract
.sampleBuysFromLiquidityProvider(randomAddress(), yAsset, xAsset, sampleAmounts)
it('should just return zeros if the liquidity provider cannot be found', async () => {
const result = await testContract
.sampleBuysFromLiquidityProviderRegistry(
registryContract.address,
yAsset,
randomAddress(),
sampleAmounts,
FAKE_BUY_OPTS,
)
.callAsync();
quotes.forEach(value => {
result.forEach(value => {
expect(value).is.bignumber.eql(constants.ZERO_AMOUNT);
});
});
it('should just return zeros if the registry does not exist', async () => {
const result = await testContract
.sampleBuysFromLiquidityProviderRegistry(randomAddress(), yAsset, xAsset, sampleAmounts, FAKE_BUY_OPTS)
.callAsync();
result.forEach(value => {
expect(value).is.bignumber.eql(constants.ZERO_AMOUNT);
});
});
@@ -938,16 +1029,11 @@ blockchainTests('erc20-bridge-sampler', env => {
const signatures: string[] = _.times(orders.length, i => hexUtils.random());
const expected = orders.map(getDeterministicFillableTakerAssetAmount);
const calls = [
testContract
.getOrderFillableTakerAssetAmounts(orders, signatures, NULL_ADDRESS)
.getABIEncodedTransactionData(),
testContract.getOrderFillableTakerAssetAmounts(orders, signatures).getABIEncodedTransactionData(),
];
const r = await testContract.batchCall(calls).callAsync();
expect(r).to.be.length(1);
const actual = testContract.getABIDecodedReturnData<BigNumber[]>(
'getOrderFillableTakerAssetAmounts',
r[0].data,
);
const actual = testContract.getABIDecodedReturnData<BigNumber[]>('getOrderFillableTakerAssetAmounts', r[0]);
expect(actual).to.deep.eq(expected);
});
@@ -960,19 +1046,15 @@ blockchainTests('erc20-bridge-sampler', env => {
orders[1].map(getDeterministicFillableMakerAssetAmount),
];
const calls = [
testContract
.getOrderFillableTakerAssetAmounts(orders[0], signatures, NULL_ADDRESS)
.getABIEncodedTransactionData(),
testContract
.getOrderFillableMakerAssetAmounts(orders[1], signatures, NULL_ADDRESS)
.getABIEncodedTransactionData(),
testContract.getOrderFillableTakerAssetAmounts(orders[0], signatures).getABIEncodedTransactionData(),
testContract.getOrderFillableMakerAssetAmounts(orders[1], signatures).getABIEncodedTransactionData(),
];
const r = await testContract.batchCall(calls).callAsync();
expect(r).to.be.length(2);
expect(testContract.getABIDecodedReturnData('getOrderFillableTakerAssetAmounts', r[0].data)).to.deep.eq(
expect(testContract.getABIDecodedReturnData('getOrderFillableTakerAssetAmounts', r[0])).to.deep.eq(
expecteds[0],
);
expect(testContract.getABIDecodedReturnData('getOrderFillableMakerAssetAmounts', r[1].data)).to.deep.eq(
expect(testContract.getABIDecodedReturnData('getOrderFillableMakerAssetAmounts', r[1])).to.deep.eq(
expecteds[1],
);
});
@@ -987,130 +1069,18 @@ blockchainTests('erc20-bridge-sampler', env => {
testContract
.batchCall([
testContract
.getOrderFillableTakerAssetAmounts(orders, signatures, NULL_ADDRESS)
.getOrderFillableTakerAssetAmounts(orders, signatures)
.getABIEncodedTransactionData(),
])
.getABIEncodedTransactionData(),
])
.callAsync();
expect(r).to.be.length(1);
r = testContract.getABIDecodedReturnData<SamplerCallResult[]>('batchCall', r[0].data);
r = testContract.getABIDecodedReturnData<string[]>('batchCall', r[0]);
expect(r).to.be.length(1);
expect(testContract.getABIDecodedReturnData('getOrderFillableTakerAssetAmounts', r[0].data)).to.deep.eq(
expect(testContract.getABIDecodedReturnData('getOrderFillableTakerAssetAmounts', r[0])).to.deep.eq(
expected,
);
});
});
blockchainTests.resets('TwoHopSampler', () => {
before(async () => {
await testContract
.createTokenExchanges([MAKER_TOKEN, TAKER_TOKEN, INTERMEDIATE_TOKEN])
.awaitTransactionSuccessAsync();
});
it('sampleTwoHopSell', async () => {
// tslint:disable-next-line no-unnecessary-type-assertion
const sellAmount = _.last(getSampleAmounts(TAKER_TOKEN))!;
const uniswapV2FirstHopPath = [TAKER_TOKEN, INTERMEDIATE_TOKEN];
const uniswapV2FirstHop = testContract
.sampleSellsFromUniswapV2(uniswapV2FirstHopPath, [constants.ZERO_AMOUNT])
.getABIEncodedTransactionData();
const uniswapV2SecondHopPath = [INTERMEDIATE_TOKEN, randomAddress(), MAKER_TOKEN];
const uniswapV2SecondHop = testContract
.sampleSellsFromUniswapV2(uniswapV2SecondHopPath, [constants.ZERO_AMOUNT])
.getABIEncodedTransactionData();
const eth2DaiFirstHop = testContract
.sampleSellsFromEth2Dai(TAKER_TOKEN, INTERMEDIATE_TOKEN, [constants.ZERO_AMOUNT])
.getABIEncodedTransactionData();
const eth2DaiSecondHop = testContract
.sampleSellsFromEth2Dai(INTERMEDIATE_TOKEN, MAKER_TOKEN, [constants.ZERO_AMOUNT])
.getABIEncodedTransactionData();
const firstHopQuotes = [
getDeterministicSellQuote(ETH2DAI_SALT, TAKER_TOKEN, INTERMEDIATE_TOKEN, sellAmount),
getDeterministicUniswapV2SellQuote(uniswapV2FirstHopPath, sellAmount),
];
const expectedIntermediateAssetAmount = BigNumber.max(...firstHopQuotes);
const secondHopQuotes = [
getDeterministicSellQuote(
ETH2DAI_SALT,
INTERMEDIATE_TOKEN,
MAKER_TOKEN,
expectedIntermediateAssetAmount,
),
getDeterministicUniswapV2SellQuote(uniswapV2SecondHopPath, expectedIntermediateAssetAmount),
];
const expectedBuyAmount = BigNumber.max(...secondHopQuotes);
const [firstHop, secondHop, buyAmount] = await testContract
.sampleTwoHopSell(
[eth2DaiFirstHop, uniswapV2FirstHop],
[eth2DaiSecondHop, uniswapV2SecondHop],
sellAmount,
)
.callAsync();
expect(firstHop.sourceIndex, 'First hop source index').to.bignumber.equal(
firstHopQuotes.findIndex(quote => quote.isEqualTo(expectedIntermediateAssetAmount)),
);
expect(secondHop.sourceIndex, 'Second hop source index').to.bignumber.equal(
secondHopQuotes.findIndex(quote => quote.isEqualTo(expectedBuyAmount)),
);
expect(buyAmount, 'Two hop buy amount').to.bignumber.equal(expectedBuyAmount);
});
it('sampleTwoHopBuy', async () => {
// tslint:disable-next-line no-unnecessary-type-assertion
const buyAmount = _.last(getSampleAmounts(MAKER_TOKEN))!;
const uniswapV2FirstHopPath = [TAKER_TOKEN, INTERMEDIATE_TOKEN];
const uniswapV2FirstHop = testContract
.sampleBuysFromUniswapV2(uniswapV2FirstHopPath, [constants.ZERO_AMOUNT])
.getABIEncodedTransactionData();
const uniswapV2SecondHopPath = [INTERMEDIATE_TOKEN, randomAddress(), MAKER_TOKEN];
const uniswapV2SecondHop = testContract
.sampleBuysFromUniswapV2(uniswapV2SecondHopPath, [constants.ZERO_AMOUNT])
.getABIEncodedTransactionData();
const eth2DaiFirstHop = testContract
.sampleBuysFromEth2Dai(TAKER_TOKEN, INTERMEDIATE_TOKEN, [constants.ZERO_AMOUNT])
.getABIEncodedTransactionData();
const eth2DaiSecondHop = testContract
.sampleBuysFromEth2Dai(INTERMEDIATE_TOKEN, MAKER_TOKEN, [constants.ZERO_AMOUNT])
.getABIEncodedTransactionData();
const secondHopQuotes = [
getDeterministicBuyQuote(ETH2DAI_SALT, INTERMEDIATE_TOKEN, MAKER_TOKEN, buyAmount),
getDeterministicUniswapV2BuyQuote(uniswapV2SecondHopPath, buyAmount),
];
const expectedIntermediateAssetAmount = BigNumber.min(...secondHopQuotes);
const firstHopQuotes = [
getDeterministicBuyQuote(
ETH2DAI_SALT,
TAKER_TOKEN,
INTERMEDIATE_TOKEN,
expectedIntermediateAssetAmount,
),
getDeterministicUniswapV2BuyQuote(uniswapV2FirstHopPath, expectedIntermediateAssetAmount),
];
const expectedSellAmount = BigNumber.min(...firstHopQuotes);
const [firstHop, secondHop, sellAmount] = await testContract
.sampleTwoHopBuy(
[eth2DaiFirstHop, uniswapV2FirstHop],
[eth2DaiSecondHop, uniswapV2SecondHop],
buyAmount,
)
.callAsync();
expect(firstHop.sourceIndex, 'First hop source index').to.bignumber.equal(
firstHopQuotes.findIndex(quote => quote.isEqualTo(expectedSellAmount)),
);
expect(secondHop.sourceIndex, 'Second hop source index').to.bignumber.equal(
secondHopQuotes.findIndex(quote => quote.isEqualTo(expectedIntermediateAssetAmount)),
);
expect(sellAmount, 'Two hop sell amount').to.bignumber.equal(expectedSellAmount);
});
});
});

View File

@@ -0,0 +1,20 @@
/*
* -----------------------------------------------------------------------------
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../test/generated-wrappers/dummy_liquidity_provider';
export * from '../test/generated-wrappers/dummy_liquidity_provider_registry';
export * from '../test/generated-wrappers/erc20_bridge_sampler';
export * from '../test/generated-wrappers/i_curve';
export * from '../test/generated-wrappers/i_dev_utils';
export * from '../test/generated-wrappers/i_erc20_bridge_sampler';
export * from '../test/generated-wrappers/i_eth2_dai';
export * from '../test/generated-wrappers/i_kyber_network';
export * from '../test/generated-wrappers/i_kyber_network_proxy';
export * from '../test/generated-wrappers/i_liquidity_provider';
export * from '../test/generated-wrappers/i_liquidity_provider_registry';
export * from '../test/generated-wrappers/i_multi_bridge';
export * from '../test/generated-wrappers/i_uniswap_exchange_quotes';
export * from '../test/generated-wrappers/i_uniswap_v2_router01';
export * from '../test/generated-wrappers/test_erc20_bridge_sampler';

View File

@@ -0,0 +1,96 @@
/**
* Use this file to configure your truffle project. It's seeded with some
* common settings for different networks and features like migrations,
* compilation and testing. Uncomment the ones you need or modify
* them to suit your project as necessary.
*
* More information about configuration can be found at:
*
* truffleframework.com/docs/advanced/configuration
*
* To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider)
* to sign your transactions before they're sent to a remote public node. Infura accounts
* are available for free at: infura.io/register.
*
* You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
* public/private key pairs. If you're publishing your code to GitHub make sure you load this
* phrase from a file you've .gitignored so it doesn't accidentally become public.
*
*/
// const HDWalletProvider = require('truffle-hdwallet-provider');
// const infuraKey = "fj4jll3k.....";
//
// const fs = require('fs');
// const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
/**
* Networks define how you connect to your ethereum client and let you set the
* defaults web3 uses to send transactions. If you don't specify one truffle
* will spin up a development blockchain for you on port 9545 when you
* run `develop` or `test`. You can ask a truffle command to use a specific
* network from the command line, e.g
*
* $ truffle test --network <network-name>
*/
networks: {
// Useful for testing. The `development` name is special - truffle uses it by default
// if it's defined here and no other network is specified at the command line.
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
// tab if you use this network and you must also set the `host`, `port` and `network_id`
// options below to some value.
//
// development: {
// host: "127.0.0.1", // Localhost (default: none)
// port: 8545, // Standard Ethereum port (default: none)
// network_id: "*", // Any network (default: none)
// },
// Another network with more advanced options...
// advanced: {
// port: 8777, // Custom port
// network_id: 1342, // Custom network
// gas: 8500000, // Gas sent with each transaction (default: ~6700000)
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
// from: <address>, // Account to send txs from (default: accounts[0])
// websockets: true // Enable EventEmitter interface for web3 (default: false)
// },
// Useful for deploying to a public network.
// NB: It's important to wrap the provider as a function.
// ropsten: {
// provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`),
// network_id: 3, // Ropsten's id
// gas: 5500000, // Ropsten has a lower block limit than mainnet
// confirmations: 2, // # of confs to wait between deployments. (default: 0)
// timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
// skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
// },
// Useful for private networks
// private: {
// provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
// network_id: 2111, // This network is yours, in the cloud.
// production: true // Treats this network as if it was a public net. (default: false)
// }
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
version: '0.5.9',
settings: {
evmVersion: 'istanbul',
optimizer: {
enabled: true,
runs: 1000000,
details: { yul: true, deduplicate: true, cse: true, constantOptimizer: true },
},
},
},
},
};

View File

@@ -0,0 +1,29 @@
{
"extends": "../../tsconfig",
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"files": [
"generated-artifacts/DummyLiquidityProvider.json",
"generated-artifacts/DummyLiquidityProviderRegistry.json",
"generated-artifacts/ERC20BridgeSampler.json",
"generated-artifacts/IERC20BridgeSampler.json",
"generated-artifacts/ILiquidityProvider.json",
"generated-artifacts/ILiquidityProviderRegistry.json",
"test/generated-artifacts/DummyLiquidityProvider.json",
"test/generated-artifacts/DummyLiquidityProviderRegistry.json",
"test/generated-artifacts/ERC20BridgeSampler.json",
"test/generated-artifacts/ICurve.json",
"test/generated-artifacts/IDevUtils.json",
"test/generated-artifacts/IERC20BridgeSampler.json",
"test/generated-artifacts/IEth2Dai.json",
"test/generated-artifacts/IKyberNetwork.json",
"test/generated-artifacts/IKyberNetworkProxy.json",
"test/generated-artifacts/ILiquidityProvider.json",
"test/generated-artifacts/ILiquidityProviderRegistry.json",
"test/generated-artifacts/IMultiBridge.json",
"test/generated-artifacts/IUniswapExchangeQuotes.json",
"test/generated-artifacts/IUniswapV2Router01.json",
"test/generated-artifacts/TestERC20BridgeSampler.json"
],
"exclude": ["./deploy/solc/solc_bin"]
}

View File

@@ -0,0 +1,10 @@
{
"extends": ["@0x/tslint-config"],
"rules": {
"custom-no-magic-numbers": false,
"max-file-line-count": false
},
"linterOptions": {
"exclude": ["src/artifacts.ts", "test/artifacts.ts"]
}
}

View File

@@ -1,162 +1,4 @@
[
{
"timestamp": 1611648096,
"version": "3.3.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1610510890,
"version": "3.3.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.3.0",
"changes": [
{
"note": "Add SPDX license identifiers to solidity files",
"pr": 105
},
{
"note": "Allow for excess return data in `LibERC20TokenV06` compat* functions",
"pr": 97
}
],
"timestamp": 1609802516
},
{
"timestamp": 1608692071,
"version": "3.2.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608245516,
"version": "3.2.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "3.2.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "3.2.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "3.2.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605763885,
"version": "3.2.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605302002,
"version": "3.2.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604385937,
"version": "3.2.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604376968,
"version": "3.2.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604355662,
"version": "3.2.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603851023,
"version": "3.2.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603833198,
"version": "3.2.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603265572,
"version": "3.2.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1594788383,
"version": "3.2.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.2.0",
"changes": [

View File

@@ -5,75 +5,6 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.3.2 - _January 26, 2021_
* Dependencies updated
## v3.3.1 - _January 13, 2021_
* Dependencies updated
## v3.3.0 - _January 4, 2021_
* Add SPDX license identifiers to solidity files (#105)
* Allow for excess return data in `LibERC20TokenV06` compat* functions (#97)
## v3.2.14 - _December 23, 2020_
* Dependencies updated
## v3.2.13 - _December 17, 2020_
* Dependencies updated
## v3.2.12 - _December 9, 2020_
* Dependencies updated
## v3.2.11 - _December 7, 2020_
* Dependencies updated
## v3.2.10 - _December 3, 2020_
* Dependencies updated
## v3.2.9 - _November 19, 2020_
* Dependencies updated
## v3.2.8 - _November 13, 2020_
* Dependencies updated
## v3.2.7 - _November 3, 2020_
* Dependencies updated
## v3.2.6 - _November 3, 2020_
* Dependencies updated
## v3.2.5 - _November 2, 2020_
* Dependencies updated
## v3.2.4 - _October 28, 2020_
* Dependencies updated
## v3.2.3 - _October 27, 2020_
* Dependencies updated
## v3.2.2 - _October 21, 2020_
* Dependencies updated
## v3.2.1 - _July 15, 2020_
* Dependencies updated
## v3.2.0 - _June 24, 2020_
* Add `LibERC20Token.approveIfBelow()` (#2512)

View File

@@ -1,4 +1,3 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.

View File

@@ -1,4 +1,3 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.

View File

@@ -1,4 +1,3 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright 2020 ZeroEx Intl.
@@ -119,7 +118,7 @@ library LibERC20TokenV06 {
{
tokenDecimals = 18;
(bool didSucceed, bytes memory resultData) = address(token).staticcall(DECIMALS_CALL_DATA);
if (didSucceed && resultData.length >= 32) {
if (didSucceed && resultData.length == 32) {
tokenDecimals = uint8(LibBytesV06.readUint256(resultData, 0));
}
}
@@ -142,7 +141,7 @@ library LibERC20TokenV06 {
spender
)
);
if (didSucceed && resultData.length >= 32) {
if (didSucceed && resultData.length == 32) {
allowance_ = LibBytesV06.readUint256(resultData, 0);
}
}
@@ -163,7 +162,7 @@ library LibERC20TokenV06 {
owner
)
);
if (didSucceed && resultData.length >= 32) {
if (didSucceed && resultData.length == 32) {
balance = LibBytesV06.readUint256(resultData, 0);
}
}
@@ -181,7 +180,7 @@ library LibERC20TokenV06 {
if (resultData.length == 0) {
return true;
}
if (resultData.length >= 32) {
if (resultData.length == 32) {
uint256 result = LibBytesV06.readUint256(resultData, 0);
if (result == 1) {
return true;

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc20",
"version": "3.3.2",
"version": "3.2.0",
"engines": {
"node": ">=6.12"
},
@@ -43,34 +43,34 @@
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/protocol.git"
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/protocol/issues"
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.4.19",
"@0x/contracts-gen": "^2.0.30",
"@0x/contracts-test-utils": "^5.3.20",
"@0x/contracts-utils": "^4.7.2",
"@0x/dev-utils": "^4.2.1",
"@0x/sol-compiler": "^4.5.2",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.2.0",
"@0x/web3-wrapper": "^7.4.1",
"@0x/abi-gen": "^5.3.0",
"@0x/contracts-gen": "^2.0.9",
"@0x/contracts-test-utils": "^5.3.3",
"@0x/contracts-utils": "^4.5.0",
"@0x/dev-utils": "^3.2.2",
"@0x/sol-compiler": "^4.1.0",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.3",
"@0x/typescript-typings": "^5.1.0",
"@0x/utils": "^5.5.0",
"@0x/web3-wrapper": "^7.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereum-types": "^3.4.0",
"ethereum-types": "^3.1.1",
"lodash": "^4.17.11",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
@@ -78,14 +78,13 @@
"shx": "^0.2.2",
"solhint": "^1.4.1",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.18"
"@0x/base-contract": "^6.2.2"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}
}

View File

@@ -1,157 +1,4 @@
[
{
"timestamp": 1611648096,
"version": "3.1.23",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1610510890,
"version": "3.1.22",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1609802516,
"version": "3.1.21",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608692071,
"version": "3.1.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608245516,
"version": "3.1.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "3.1.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "3.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "3.1.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605763885,
"version": "3.1.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605302002,
"version": "3.1.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604385937,
"version": "3.1.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604376968,
"version": "3.1.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604355662,
"version": "3.1.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603851023,
"version": "3.1.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603833198,
"version": "3.1.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603265572,
"version": "3.1.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1594788383,
"version": "3.1.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "3.1.6",

View File

@@ -5,74 +5,6 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.23 - _January 26, 2021_
* Dependencies updated
## v3.1.22 - _January 13, 2021_
* Dependencies updated
## v3.1.21 - _January 4, 2021_
* Dependencies updated
## v3.1.20 - _December 23, 2020_
* Dependencies updated
## v3.1.19 - _December 17, 2020_
* Dependencies updated
## v3.1.18 - _December 9, 2020_
* Dependencies updated
## v3.1.17 - _December 7, 2020_
* Dependencies updated
## v3.1.16 - _December 3, 2020_
* Dependencies updated
## v3.1.15 - _November 19, 2020_
* Dependencies updated
## v3.1.14 - _November 13, 2020_
* Dependencies updated
## v3.1.13 - _November 3, 2020_
* Dependencies updated
## v3.1.12 - _November 3, 2020_
* Dependencies updated
## v3.1.11 - _November 2, 2020_
* Dependencies updated
## v3.1.10 - _October 28, 2020_
* Dependencies updated
## v3.1.9 - _October 27, 2020_
* Dependencies updated
## v3.1.8 - _October 21, 2020_
* Dependencies updated
## v3.1.7 - _July 15, 2020_
* Dependencies updated
## v3.1.6 - _June 24, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc721",
"version": "3.1.23",
"version": "3.1.6",
"engines": {
"node": ">=6.12"
},
@@ -44,34 +44,34 @@
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/protocol.git"
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/protocol/issues"
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.4.19",
"@0x/contracts-gen": "^2.0.30",
"@0x/contracts-test-utils": "^5.3.20",
"@0x/contracts-utils": "^4.7.2",
"@0x/dev-utils": "^4.2.1",
"@0x/sol-compiler": "^4.5.2",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.2.0",
"@0x/web3-wrapper": "^7.4.1",
"@0x/abi-gen": "^5.3.0",
"@0x/contracts-gen": "^2.0.9",
"@0x/contracts-test-utils": "^5.3.3",
"@0x/contracts-utils": "^4.5.0",
"@0x/dev-utils": "^3.2.2",
"@0x/sol-compiler": "^4.1.0",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.3",
"@0x/typescript-typings": "^5.1.0",
"@0x/utils": "^5.5.0",
"@0x/web3-wrapper": "^7.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
"dirty-chai": "^2.0.1",
"ethereum-types": "^3.4.0",
"ethereum-types": "^3.1.1",
"lodash": "^4.17.11",
"make-promises-safe": "^1.1.0",
"mocha": "^6.2.0",
@@ -80,14 +80,13 @@
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.18"
"@0x/base-contract": "^6.2.2"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}
}

View File

@@ -1,166 +1,4 @@
[
{
"timestamp": 1611648096,
"version": "4.2.24",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1610510890,
"version": "4.2.23",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1609802516,
"version": "4.2.22",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608692071,
"version": "4.2.21",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608245516,
"version": "4.2.20",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1608105788,
"version": "4.2.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "4.2.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "4.2.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "4.2.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605763885,
"version": "4.2.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1605302002,
"version": "4.2.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604385937,
"version": "4.2.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604376968,
"version": "4.2.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1604355662,
"version": "4.2.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603851023,
"version": "4.2.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603833198,
"version": "4.2.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1603265572,
"version": "4.2.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1594788383,
"version": "4.2.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1592969527,
"version": "4.2.6",

View File

@@ -5,78 +5,6 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.2.24 - _January 26, 2021_
* Dependencies updated
## v4.2.23 - _January 13, 2021_
* Dependencies updated
## v4.2.22 - _January 4, 2021_
* Dependencies updated
## v4.2.21 - _December 23, 2020_
* Dependencies updated
## v4.2.20 - _December 17, 2020_
* Dependencies updated
## v4.2.19 - _December 16, 2020_
* Dependencies updated
## v4.2.18 - _December 9, 2020_
* Dependencies updated
## v4.2.17 - _December 7, 2020_
* Dependencies updated
## v4.2.16 - _December 3, 2020_
* Dependencies updated
## v4.2.15 - _November 19, 2020_
* Dependencies updated
## v4.2.14 - _November 13, 2020_
* Dependencies updated
## v4.2.13 - _November 3, 2020_
* Dependencies updated
## v4.2.12 - _November 3, 2020_
* Dependencies updated
## v4.2.11 - _November 2, 2020_
* Dependencies updated
## v4.2.10 - _October 28, 2020_
* Dependencies updated
## v4.2.9 - _October 27, 2020_
* Dependencies updated
## v4.2.8 - _October 21, 2020_
* Dependencies updated
## v4.2.7 - _July 15, 2020_
* Dependencies updated
## v4.2.6 - _June 24, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange-forwarder",
"version": "4.2.24",
"version": "4.2.6",
"engines": {
"node": ">=6.12"
},
@@ -44,36 +44,36 @@
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/protocol.git"
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/protocol/issues"
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^5.4.19",
"@0x/contracts-asset-proxy": "^3.7.5",
"@0x/contracts-dev-utils": "^1.3.22",
"@0x/contracts-erc1155": "^2.1.23",
"@0x/contracts-erc20": "^3.3.2",
"@0x/contracts-erc721": "^3.1.23",
"@0x/contracts-exchange": "^3.2.24",
"@0x/contracts-exchange-libs": "^4.3.23",
"@0x/contracts-gen": "^2.0.30",
"@0x/contracts-test-utils": "^5.3.20",
"@0x/contracts-utils": "^4.7.2",
"@0x/dev-utils": "^4.2.1",
"@0x/order-utils": "^10.4.15",
"@0x/sol-compiler": "^4.5.2",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/utils": "^6.2.0",
"@0x/web3-wrapper": "^7.4.1",
"@0x/abi-gen": "^5.3.0",
"@0x/contracts-asset-proxy": "^3.3.0",
"@0x/contracts-dev-utils": "^1.3.4",
"@0x/contracts-erc1155": "^2.1.6",
"@0x/contracts-erc20": "^3.2.0",
"@0x/contracts-erc721": "^3.1.6",
"@0x/contracts-exchange": "^3.2.6",
"@0x/contracts-exchange-libs": "^4.3.6",
"@0x/contracts-gen": "^2.0.9",
"@0x/contracts-test-utils": "^5.3.3",
"@0x/contracts-utils": "^4.5.0",
"@0x/dev-utils": "^3.2.2",
"@0x/order-utils": "^10.2.5",
"@0x/sol-compiler": "^4.1.0",
"@0x/ts-doc-gen": "^0.0.22",
"@0x/tslint-config": "^4.0.0",
"@0x/types": "^3.1.3",
"@0x/utils": "^5.5.0",
"@0x/web3-wrapper": "^7.1.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
"@types/node": "*",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^3.0.0",
@@ -86,16 +86,15 @@
"solhint": "^1.4.1",
"truffle": "^5.0.32",
"tslint": "5.11.0",
"typedoc": "~0.16.11",
"typedoc": "^0.15.0",
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.18",
"@0x/typescript-typings": "^5.1.6",
"ethereum-types": "^3.4.0"
"@0x/base-contract": "^6.2.2",
"@0x/typescript-typings": "^5.1.0",
"ethereum-types": "^3.1.1"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4f91bfd907996b2f4dd383778b50c479c2602b56"
}
}

Some files were not shown because too many files have changed in this diff Show More