Compare commits
205 Commits
refactor/n
...
@0x/contra
Author | SHA1 | Date | |
---|---|---|---|
|
6324b08b4d | ||
|
fe73b63aaa | ||
|
192d0b17d9 | ||
|
aa74d04083 | ||
|
d586f5727d | ||
|
98fc79a085 | ||
|
c12a10b96e | ||
|
d3d4a08f91 | ||
|
9ce090c8cd | ||
|
980d60deb8 | ||
|
d6d79e51e7 | ||
|
3ef5de93bb | ||
|
ab7dc33ca4 | ||
|
14dcee5bb6 | ||
|
9856e78609 | ||
|
2801b066b3 | ||
|
5bc8b13fc3 | ||
|
36dba8f5be | ||
|
ee2c069889 | ||
|
6ca14ed7b2 | ||
|
a5babb9a34 | ||
|
661cc4669d | ||
|
553ba5c868 | ||
|
d03d2f254d | ||
|
feb91a04b0 | ||
|
4d63f33aba | ||
|
b72b8b5ffd | ||
|
f7cb7a0f51 | ||
|
9fcb28f5d8 | ||
|
982173471c | ||
|
e77958425f | ||
|
6af4d71573 | ||
|
ee985240fb | ||
|
2aadbda527 | ||
|
297c73abcc | ||
|
4c9e1b21ec | ||
|
41685d1545 | ||
|
b9c25112ed | ||
|
f0738fc122 | ||
|
42baf504b7 | ||
|
56038d122f | ||
|
c4446b6c0e | ||
|
eaed2958c3 | ||
|
a045a3afb8 | ||
|
1cc59ab1ab | ||
|
2c6a714b71 | ||
|
d8c97d6720 | ||
|
d6bc702550 | ||
|
2838cb9420 | ||
|
b10cfc50d3 | ||
|
2e6317b01e | ||
|
50e99e6eac | ||
|
8f2f4554eb | ||
|
67d9678a3a | ||
|
f70341fb48 | ||
|
14cd24ea47 | ||
|
78328056d7 | ||
|
0045a60b0f | ||
|
e4e71c76e1 | ||
|
ca8127545f | ||
|
7b709089ce | ||
|
190f7e45f2 | ||
|
0dcc3a6fc3 | ||
|
c2e8cae293 | ||
|
83da7caab4 | ||
|
fd69a0c273 | ||
|
9b131199ad | ||
|
f5c486050b | ||
|
1f41fe6a20 | ||
|
7f4080e0a2 | ||
|
db76da58d7 | ||
|
cf8fc0ff8e | ||
|
2d16f83e37 | ||
|
4057bdab91 | ||
|
1cd10f0ac9 | ||
|
68f87b2432 | ||
|
69bafc3bcd | ||
|
2c44b06b7b | ||
|
0233f00b4e | ||
|
fedb53187d | ||
|
6774d2f588 | ||
|
cf740b74f5 | ||
|
177c00463a | ||
|
49b0e32129 | ||
|
938fc94756 | ||
|
1561d91c2b | ||
|
9a28e51f51 | ||
|
f55eaa867b | ||
|
6b2856424a | ||
|
da757c4700 | ||
|
75e6654884 | ||
|
87308e7693 | ||
|
d5eef93a76 | ||
|
a7f23a982e | ||
|
9eadc5fc28 | ||
|
92ad1a612e | ||
|
09413c0e12 | ||
|
23788b41d5 | ||
|
ccf999a495 | ||
|
aa1016ee5f | ||
|
423ef57344 | ||
|
c18149e82f | ||
|
d14aebf724 | ||
|
ba719a9631 | ||
|
d36034d958 | ||
|
7750c57620 | ||
|
4d027e11d1 | ||
|
470e9a4697 | ||
|
7c51412e2f | ||
|
b3d1f3cd10 | ||
|
389bb77439 | ||
|
4327885a00 | ||
|
0aef0afbbb | ||
|
fa4c3a4f5f | ||
|
1d7c527c5c | ||
|
cbe3135e4b | ||
|
955ad49711 | ||
|
8d6f6e76e0 | ||
|
9337115650 | ||
|
fa45a44fe4 | ||
|
c9c7ac8559 | ||
|
c881723578 | ||
|
c9c30d3a76 | ||
|
73dfdb5b69 | ||
|
e638268f94 | ||
|
0bfd765481 | ||
|
1f12893735 | ||
|
dd3d9337c4 | ||
|
904214f4a8 | ||
|
64c090c4b4 | ||
|
e24474f152 | ||
|
29fa408256 | ||
|
1b94cc68af | ||
|
f5b4bb3035 | ||
|
afd880f28c | ||
|
cd14cdd168 | ||
|
c8ff53a75f | ||
|
6d08add20b | ||
|
29f9c725e3 | ||
|
a83453f07f | ||
|
ae365ce92c | ||
|
77a592e891 | ||
|
9a1df67d6b | ||
|
4b91411faf | ||
|
622a542d57 | ||
|
cba53a9a50 | ||
|
e186f27f63 | ||
|
4cd767ecb8 | ||
|
f6e85aedf1 | ||
|
b3ee294ba5 | ||
|
1c242def93 | ||
|
f0fe6f2f69 | ||
|
f86d555e49 | ||
|
b0f2c40463 | ||
|
87be6fbb8a | ||
|
9141a9d2c8 | ||
|
7f75de347e | ||
|
329f7761c3 | ||
|
0d8e83cd75 | ||
|
e5d60b8077 | ||
|
ae2fe55efa | ||
|
6073607d3e | ||
|
389ebb5df8 | ||
|
fd9655e9d4 | ||
|
6480aaa189 | ||
|
38969bb0a8 | ||
|
1847ab93af | ||
|
c1177416f5 | ||
|
4fdd203211 | ||
|
4bc11776d7 | ||
|
eb12eac5f3 | ||
|
5f5b951998 | ||
|
8e90547604 | ||
|
fbea74d7ff | ||
|
dcea16bc13 | ||
|
d59a074bd7 | ||
|
39cc4f4dbf | ||
|
85bcf87af8 | ||
|
a0fe1c610f | ||
|
5d21af1a0a | ||
|
f6edbd210c | ||
|
e084807a8f | ||
|
1c7d512829 | ||
|
df0e0866e4 | ||
|
9e6efc3676 | ||
|
3aef29dace | ||
|
9a16e00577 | ||
|
84e4819e6e | ||
|
25dd6bc79a | ||
|
5d2cdb00c2 | ||
|
0f701f42d3 | ||
|
3e3e82d3f7 | ||
|
c57bf86273 | ||
|
f470d282ee | ||
|
b8a2526da5 | ||
|
97575bbde9 | ||
|
e5ed8b2c81 | ||
|
61fbae3ae2 | ||
|
5c2255c841 | ||
|
e036dee6c5 | ||
|
8583aab241 | ||
|
5d05b62821 | ||
|
0063e8178f | ||
|
ec6e5dd517 | ||
|
9d08fefa1c |
@@ -4,7 +4,7 @@ jobs:
|
||||
build:
|
||||
resource_class: xlarge
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
environment:
|
||||
NODE_OPTIONS: '--max-old-space-size=16384'
|
||||
working_directory: ~/repo
|
||||
@@ -19,7 +19,6 @@ jobs:
|
||||
command: yarn --frozen-lockfile --ignore-engines install || yarn --frozen-lockfile --ignore-engines install
|
||||
- setup_remote_docker
|
||||
- run: yarn build:ci || yarn build:ci || yarn build:ci || yarn build:ci || yarn build:ci || yarn build:ci
|
||||
- run: yarn build:ts || yarn build:ts || yarn build:ts || yarn build:ts || yarn build:ts || yarn build:ts
|
||||
- save_cache:
|
||||
key: repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
@@ -31,7 +30,7 @@ jobs:
|
||||
test-exchange-ganache:
|
||||
resource_class: medium+
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
@@ -41,7 +40,7 @@ jobs:
|
||||
test-integrations-ganache:
|
||||
resource_class: medium+
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
@@ -51,7 +50,7 @@ jobs:
|
||||
test-contracts-staking-ganache:
|
||||
resource_class: medium+
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
@@ -61,7 +60,7 @@ jobs:
|
||||
test-contracts-extra-ganache:
|
||||
resource_class: medium+
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
@@ -71,7 +70,7 @@ jobs:
|
||||
test-contracts-rest-ganache:
|
||||
resource_class: medium+
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
@@ -83,7 +82,7 @@ jobs:
|
||||
environment:
|
||||
NODE_OPTIONS: '--max-old-space-size=6442'
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
- image: 0xorg/verdaccio
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
@@ -97,7 +96,7 @@ jobs:
|
||||
path: ~/.npm/_logs
|
||||
test-doc-generation:
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
@@ -108,8 +107,10 @@ jobs:
|
||||
no_output_timeout: 1200
|
||||
test-rest:
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
working_directory: ~/repo
|
||||
environment:
|
||||
RUST_ROUTER: 'true'
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
@@ -117,7 +118,6 @@ jobs:
|
||||
- run: yarn wsrun -p @0x/contracts-test-utils -m --serial -c test:circleci
|
||||
- run: yarn wsrun -p @0x/contract-artifacts -m --serial -c test:circleci
|
||||
- run: yarn wsrun -p @0x/contract-wrappers-test -m --serial -c test:circleci
|
||||
- run: yarn wsrun -p @0x/migrations -m --serial -c test:circleci
|
||||
- run: yarn wsrun -p @0x/order-utils -m --serial -c test:circleci
|
||||
- run: yarn wsrun -p @0x/asset-swapper -m --serial -c test:circleci
|
||||
- save_cache:
|
||||
@@ -136,7 +136,7 @@ jobs:
|
||||
resource_class: large
|
||||
working_directory: ~/repo
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
@@ -147,7 +147,7 @@ jobs:
|
||||
- run: yarn diff_md_docs:ci
|
||||
submit-coverage:
|
||||
docker:
|
||||
- image: node:12
|
||||
- image: node:16
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
|
1
.github/autolabeler.yml
vendored
1
.github/autolabeler.yml
vendored
@@ -1,7 +1,6 @@
|
||||
python: ['python-packages']
|
||||
contracts: ['contracts']
|
||||
@0x/contract-addresses: ['packages/contract-addresses']
|
||||
@0x/migrations: ['packages/migrations']
|
||||
@0x/order-utils: ['packages/order-utils']
|
||||
@0x/contract-artifacts: ['packages/contract-artifacts']
|
||||
@0x/contract-wrappers: ['packages/contract-wrappers']
|
||||
|
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 10
|
||||
node-version: 16
|
||||
- uses: actions/setup-python@v2
|
||||
- name: 'configure git'
|
||||
run: |
|
||||
|
18
CODEOWNERS
18
CODEOWNERS
@@ -1,18 +1,20 @@
|
||||
# See https://help.github.com/articles/about-codeowners/
|
||||
|
||||
# for more info about CODEOWNERS file
|
||||
|
||||
# It uses the same pattern rule for gitignore file
|
||||
|
||||
# https://git-scm.com/docs/gitignore#_pattern_format
|
||||
|
||||
# Website
|
||||
packages/asset-swapper/ @BMillman19 @fragosti @dave4506
|
||||
packages/instant/ @BMillman19 @fragosti @dave4506
|
||||
packages/asset-swapper/ @dekz @dextracker @kyu-c
|
||||
|
||||
# Dev tools & setup
|
||||
.circleci/ @dorothy-zbornak
|
||||
packages/contract-addresses/ @abandeali1
|
||||
packages/contract-artifacts/ @abandeali1
|
||||
packages/order-utils/ @dorothy-zbornak
|
||||
|
||||
.circleci/ @dekz
|
||||
packages/contract-addresses/ @dekz @dextracker @kyu-c
|
||||
packages/contract-artifacts/ @dekz
|
||||
packages/protocol-utils/ @dekz
|
||||
|
||||
# Protocol/smart contracts
|
||||
contracts/ @abandeali1 @hysz @dorothy-zbornak @mzhu25
|
||||
|
||||
contracts/ @dekz @dextracker
|
||||
|
@@ -38,7 +38,6 @@ These packages are all under development. See [/contracts/README.md](/contracts/
|
||||
| [`@0x/protocol-utils`](/packages/protocol-utils) | [](https://www.npmjs.com/package/@0x/protocol-utils) | A set of utilities for generating, parsing, signing and validating 0x orders |
|
||||
| [`@0x/contract-addresses`](/packages/contract-addresses) | [](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) | [](https://www.npmjs.com/package/@0x/contract-wrappers) | JS/TS wrappers for interacting with the 0x smart contracts |
|
||||
| [`@0x/migrations`](/packages/migrations) | [](https://www.npmjs.com/package/@0x/migrations) | Migration tool for deploying 0x smart contracts on private testnets |
|
||||
| [`@0x/contract-artifacts`](/packages/contract-artifacts) | [](https://www.npmjs.com/package/@0x/contract-artifacts) | 0x smart contract compilation artifacts | |
|
||||
|
||||
## Usage
|
||||
|
@@ -1,4 +1,85 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1659750766,
|
||||
"version": "3.3.34",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1658950329,
|
||||
"version": "3.3.33",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1655244958,
|
||||
"version": "3.3.32",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1654284040,
|
||||
"version": "3.3.31",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1652919697,
|
||||
"version": "3.3.30",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1650611093,
|
||||
"version": "3.3.29",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1648739346,
|
||||
"version": "3.3.28",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1646225739,
|
||||
"version": "3.3.27",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1645569128,
|
||||
"version": "3.3.26",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1640364306,
|
||||
"version": "3.3.25",
|
||||
|
@@ -5,6 +5,42 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v3.3.34 - _August 6, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.33 - _July 27, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.32 - _June 14, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.31 - _June 3, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.30 - _May 19, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.29 - _April 22, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.28 - _March 31, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.27 - _March 2, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.26 - _February 22, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.3.25 - _December 24, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-erc20",
|
||||
"version": "3.3.25",
|
||||
"version": "3.3.34",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -51,18 +51,18 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^5.7.2",
|
||||
"@0x/contracts-gen": "^2.0.43",
|
||||
"@0x/contracts-test-utils": "^5.4.16",
|
||||
"@0x/contracts-utils": "^4.8.6",
|
||||
"@0x/dev-utils": "^4.2.11",
|
||||
"@0x/sol-compiler": "^4.7.8",
|
||||
"@0x/abi-gen": "^5.8.0",
|
||||
"@0x/contracts-gen": "^2.0.46",
|
||||
"@0x/contracts-test-utils": "^5.4.25",
|
||||
"@0x/contracts-utils": "^4.8.15",
|
||||
"@0x/dev-utils": "^4.2.14",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
"@0x/ts-doc-gen": "^0.0.28",
|
||||
"@0x/tslint-config": "^4.1.4",
|
||||
"@0x/types": "^3.3.4",
|
||||
"@0x/typescript-typings": "^5.2.1",
|
||||
"@0x/utils": "^6.5.0",
|
||||
"@0x/web3-wrapper": "^7.6.2",
|
||||
"@0x/types": "^3.3.6",
|
||||
"@0x/typescript-typings": "^5.3.1",
|
||||
"@0x/utils": "^6.5.3",
|
||||
"@0x/web3-wrapper": "^7.6.5",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "12.12.54",
|
||||
@@ -70,7 +70,7 @@
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-bignumber": "^3.0.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"ethereum-types": "^3.6.0",
|
||||
"ethereum-types": "^3.7.0",
|
||||
"lodash": "^4.17.11",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^6.2.0",
|
||||
@@ -79,10 +79,10 @@
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "4.2.2"
|
||||
"typescript": "4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.4.5",
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"ethers": "~4.0.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
@@ -1,4 +1,85 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1659750766,
|
||||
"version": "5.4.25",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1658950329,
|
||||
"version": "5.4.24",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1655244958,
|
||||
"version": "5.4.23",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1654284040,
|
||||
"version": "5.4.22",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1652919697,
|
||||
"version": "5.4.21",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1650611093,
|
||||
"version": "5.4.20",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1648739346,
|
||||
"version": "5.4.19",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1646225739,
|
||||
"version": "5.4.18",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1645569128,
|
||||
"version": "5.4.17",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1640364306,
|
||||
"version": "5.4.16",
|
||||
|
@@ -5,6 +5,42 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v5.4.25 - _August 6, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.24 - _July 27, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.23 - _June 14, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.22 - _June 3, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.21 - _May 19, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.20 - _April 22, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.19 - _March 31, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.18 - _March 2, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.17 - _February 22, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v5.4.16 - _December 24, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-test-utils",
|
||||
"version": "5.4.16",
|
||||
"version": "5.4.25",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -34,28 +34,28 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/test-utils",
|
||||
"devDependencies": {
|
||||
"@0x/sol-compiler": "^4.7.8",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
"@0x/tslint-config": "^4.1.4",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "4.2.2"
|
||||
"typescript": "4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/assert": "^3.0.31",
|
||||
"@0x/base-contract": "^6.4.5",
|
||||
"@0x/contract-addresses": "^6.11.0",
|
||||
"@0x/dev-utils": "^4.2.11",
|
||||
"@0x/json-schemas": "^6.4.1",
|
||||
"@0x/assert": "^3.0.34",
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"@0x/contract-addresses": "^6.19.0",
|
||||
"@0x/dev-utils": "^4.2.14",
|
||||
"@0x/json-schemas": "^6.4.4",
|
||||
"@0x/order-utils": "^10.4.28",
|
||||
"@0x/sol-coverage": "^4.0.42",
|
||||
"@0x/sol-profiler": "^4.1.32",
|
||||
"@0x/sol-trace": "^3.0.42",
|
||||
"@0x/subproviders": "^6.6.2",
|
||||
"@0x/types": "^3.3.4",
|
||||
"@0x/typescript-typings": "^5.2.1",
|
||||
"@0x/utils": "^6.5.0",
|
||||
"@0x/web3-wrapper": "^7.6.2",
|
||||
"@0x/sol-coverage": "^4.0.45",
|
||||
"@0x/sol-profiler": "^4.1.35",
|
||||
"@0x/sol-trace": "^3.0.45",
|
||||
"@0x/subproviders": "^6.6.5",
|
||||
"@0x/types": "^3.3.6",
|
||||
"@0x/typescript-typings": "^5.3.1",
|
||||
"@0x/utils": "^6.5.3",
|
||||
"@0x/web3-wrapper": "^7.6.5",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/js-combinatorics": "^0.5.29",
|
||||
"@types/lodash": "4.14.104",
|
||||
@@ -67,7 +67,7 @@
|
||||
"chai-bignumber": "^3.0.0",
|
||||
"decimal.js": "^10.2.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"ethereum-types": "^3.6.0",
|
||||
"ethereum-types": "^3.7.0",
|
||||
"ethereumjs-util": "^7.0.10",
|
||||
"ethers": "~4.0.4",
|
||||
"js-combinatorics": "^0.5.3",
|
||||
|
@@ -1,4 +1,85 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1659750766,
|
||||
"version": "1.4.17",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1658950329,
|
||||
"version": "1.4.16",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1655244958,
|
||||
"version": "1.4.15",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1654284040,
|
||||
"version": "1.4.14",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1652919697,
|
||||
"version": "1.4.13",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1650611093,
|
||||
"version": "1.4.12",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1648739346,
|
||||
"version": "1.4.11",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1646225739,
|
||||
"version": "1.4.10",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1645569128,
|
||||
"version": "1.4.9",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1640364306,
|
||||
"version": "1.4.8",
|
||||
|
@@ -5,6 +5,42 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.4.17 - _August 6, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.16 - _July 27, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.15 - _June 14, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.14 - _June 3, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.13 - _May 19, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.12 - _April 22, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.11 - _March 31, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.10 - _March 2, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.9 - _February 22, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.8 - _December 24, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-treasury",
|
||||
"version": "1.4.8",
|
||||
"version": "1.4.17",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -46,14 +46,14 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/treasury",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^5.7.2",
|
||||
"@0x/contract-addresses": "^6.11.0",
|
||||
"@0x/abi-gen": "^5.8.0",
|
||||
"@0x/contract-addresses": "^6.19.0",
|
||||
"@0x/contracts-asset-proxy": "^3.7.19",
|
||||
"@0x/contracts-erc20": "^3.3.25",
|
||||
"@0x/contracts-gen": "^2.0.43",
|
||||
"@0x/contracts-erc20": "^3.3.34",
|
||||
"@0x/contracts-gen": "^2.0.46",
|
||||
"@0x/contracts-staking": "^2.0.45",
|
||||
"@0x/contracts-test-utils": "^5.4.16",
|
||||
"@0x/sol-compiler": "^4.7.8",
|
||||
"@0x/contracts-test-utils": "^5.4.25",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
"@0x/ts-doc-gen": "^0.0.28",
|
||||
"@0x/tslint-config": "^4.1.4",
|
||||
"@types/isomorphic-fetch": "^0.0.35",
|
||||
@@ -69,17 +69,17 @@
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "4.2.2"
|
||||
"typescript": "4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.4.5",
|
||||
"@0x/protocol-utils": "^1.10.1",
|
||||
"@0x/subproviders": "^6.6.2",
|
||||
"@0x/types": "^3.3.4",
|
||||
"@0x/typescript-typings": "^5.2.1",
|
||||
"@0x/utils": "^6.5.0",
|
||||
"@0x/web3-wrapper": "^7.6.2",
|
||||
"ethereum-types": "^3.6.0",
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"@0x/protocol-utils": "^11.16.1",
|
||||
"@0x/subproviders": "^6.6.5",
|
||||
"@0x/types": "^3.3.6",
|
||||
"@0x/typescript-typings": "^5.3.1",
|
||||
"@0x/utils": "^6.5.3",
|
||||
"@0x/web3-wrapper": "^7.6.5",
|
||||
"ethereum-types": "^3.7.0",
|
||||
"ethereumjs-util": "^7.0.10"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
@@ -1,4 +1,85 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1659750766,
|
||||
"version": "4.8.15",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1658950329,
|
||||
"version": "4.8.14",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1655244958,
|
||||
"version": "4.8.13",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1654284040,
|
||||
"version": "4.8.12",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1652919697,
|
||||
"version": "4.8.11",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1650611093,
|
||||
"version": "4.8.10",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1648739346,
|
||||
"version": "4.8.9",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1646225739,
|
||||
"version": "4.8.8",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1645569128,
|
||||
"version": "4.8.7",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1640364306,
|
||||
"version": "4.8.6",
|
||||
|
@@ -5,6 +5,42 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v4.8.15 - _August 6, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.14 - _July 27, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.13 - _June 14, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.12 - _June 3, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.11 - _May 19, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.10 - _April 22, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.9 - _March 31, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.8 - _March 2, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.7 - _February 22, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v4.8.6 - _December 24, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-utils",
|
||||
"version": "4.8.6",
|
||||
"version": "4.8.15",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -50,15 +50,15 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/utils",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^5.7.2",
|
||||
"@0x/contracts-gen": "^2.0.43",
|
||||
"@0x/contracts-test-utils": "^5.4.16",
|
||||
"@0x/dev-utils": "^4.2.11",
|
||||
"@0x/abi-gen": "^5.8.0",
|
||||
"@0x/contracts-gen": "^2.0.46",
|
||||
"@0x/contracts-test-utils": "^5.4.25",
|
||||
"@0x/dev-utils": "^4.2.14",
|
||||
"@0x/order-utils": "^10.4.28",
|
||||
"@0x/sol-compiler": "^4.7.8",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
"@0x/tslint-config": "^4.1.4",
|
||||
"@0x/types": "^3.3.4",
|
||||
"@0x/web3-wrapper": "^7.6.2",
|
||||
"@0x/types": "^3.3.6",
|
||||
"@0x/web3-wrapper": "^7.6.5",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^5.2.7",
|
||||
@@ -76,14 +76,14 @@
|
||||
"solhint": "^1.4.1",
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "4.2.2"
|
||||
"typescript": "4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.4.5",
|
||||
"@0x/typescript-typings": "^5.2.1",
|
||||
"@0x/utils": "^6.5.0",
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"@0x/typescript-typings": "^5.3.1",
|
||||
"@0x/utils": "^6.5.3",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereum-types": "^3.6.0"
|
||||
"ethereum-types": "^3.7.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@@ -1,4 +1,99 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1659750766,
|
||||
"version": "0.36.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.36.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add Synthetix support in Ethereum and Optimism bridge adapters",
|
||||
"pr": 518
|
||||
}
|
||||
],
|
||||
"timestamp": 1658950329
|
||||
},
|
||||
{
|
||||
"version": "0.35.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Adds support for Velodrome OptimismBridgeAdapter",
|
||||
"pr": 494
|
||||
}
|
||||
],
|
||||
"timestamp": 1655244958
|
||||
},
|
||||
{
|
||||
"version": "0.34.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Splits BridgeAdapter up by chain",
|
||||
"pr": 487
|
||||
},
|
||||
{
|
||||
"note": "Add stETH wrap/unwrap support",
|
||||
"pr": 476
|
||||
},
|
||||
{
|
||||
"note": "Adds support for BancorV3 to EthereumBridgeAdapter",
|
||||
"pr": 492
|
||||
}
|
||||
],
|
||||
"timestamp": 1654284040
|
||||
},
|
||||
{
|
||||
"version": "0.33.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add support for GMX and Platypus to bridge adapter",
|
||||
"pr": 478
|
||||
}
|
||||
],
|
||||
"timestamp": 1652919697
|
||||
},
|
||||
{
|
||||
"version": "0.32.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add support for `BalancerV2Batch` fills in FQT",
|
||||
"pr": 462
|
||||
}
|
||||
],
|
||||
"timestamp": 1650611093
|
||||
},
|
||||
{
|
||||
"timestamp": 1648739346,
|
||||
"version": "0.31.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1646225739,
|
||||
"version": "0.31.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.31.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add ERC721OrdersFeature, ERC1155OrdersFeature, and ERC165Feature",
|
||||
"pr": 429
|
||||
}
|
||||
],
|
||||
"timestamp": 1645569128
|
||||
},
|
||||
{
|
||||
"timestamp": 1640364306,
|
||||
"version": "0.30.1",
|
||||
|
@@ -5,6 +5,44 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.36.1 - _August 6, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.36.0 - _July 27, 2022_
|
||||
|
||||
* Add Synthetix support in Ethereum and Optimism bridge adapters (#518)
|
||||
|
||||
## v0.35.0 - _June 14, 2022_
|
||||
|
||||
* Adds support for Velodrome OptimismBridgeAdapter (#494)
|
||||
|
||||
## v0.34.0 - _June 3, 2022_
|
||||
|
||||
* Splits BridgeAdapter up by chain (#487)
|
||||
* Add stETH wrap/unwrap support (#476)
|
||||
* Adds support for BancorV3 to EthereumBridgeAdapter (#492)
|
||||
|
||||
## v0.33.0 - _May 19, 2022_
|
||||
|
||||
* Add support for GMX and Platypus to bridge adapter (#478)
|
||||
|
||||
## v0.32.0 - _April 22, 2022_
|
||||
|
||||
* Add support for `BalancerV2Batch` fills in FQT (#462)
|
||||
|
||||
## v0.31.2 - _March 31, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.31.1 - _March 2, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.31.0 - _February 22, 2022_
|
||||
|
||||
* Add ERC721OrdersFeature, ERC1155OrdersFeature, and ERC165Feature (#429)
|
||||
|
||||
## v0.30.1 - _December 24, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -26,7 +26,7 @@ library LibNFTOrdersRichErrors {
|
||||
|
||||
function OverspentEthError(
|
||||
uint256 ethSpent,
|
||||
uint256 msgValue
|
||||
uint256 ethAvailable
|
||||
)
|
||||
internal
|
||||
pure
|
||||
@@ -35,7 +35,7 @@ library LibNFTOrdersRichErrors {
|
||||
return abi.encodeWithSelector(
|
||||
bytes4(keccak256("OverspentEthError(uint256,uint256)")),
|
||||
ethSpent,
|
||||
msgValue
|
||||
ethAvailable
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../fixins/FixinCommon.sol";
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
@@ -55,11 +55,11 @@ interface IERC1155OrdersFeature {
|
||||
);
|
||||
|
||||
/// @dev Emitted whenever an `ERC1155Order` is cancelled.
|
||||
/// @param orderHash The hash the order.
|
||||
/// @param maker The maker of the order.
|
||||
/// @param nonce The nonce of the order that was cancelled.
|
||||
event ERC1155OrderCancelled(
|
||||
bytes32 orderHash,
|
||||
address maker
|
||||
address maker,
|
||||
uint256 nonce
|
||||
);
|
||||
|
||||
/// @dev Emitted when an `ERC1155Order` is pre-signed.
|
||||
@@ -125,18 +125,20 @@ interface IERC1155OrdersFeature {
|
||||
external
|
||||
payable;
|
||||
|
||||
/// @dev Cancel a single ERC1155 order. The caller should be the
|
||||
/// maker of the order. Silently succeeds if the order has
|
||||
/// already been filled or cancelled.
|
||||
/// @param order The order to cancel.
|
||||
function cancelERC1155Order(LibNFTOrder.ERC1155Order calldata order)
|
||||
/// @dev Cancel a single ERC1155 order by its nonce. The caller
|
||||
/// should be the maker of the order. Silently succeeds if
|
||||
/// an order with the same nonce has already been filled or
|
||||
/// cancelled.
|
||||
/// @param orderNonce The order nonce.
|
||||
function cancelERC1155Order(uint256 orderNonce)
|
||||
external;
|
||||
|
||||
/// @dev Cancel multiple ERC1155 orders. The caller should be the
|
||||
/// maker of the orders. Silently succeeds if an order has
|
||||
/// already been filled or cancelled.
|
||||
/// @param orders The orders to cancel.
|
||||
function batchCancelERC1155Orders(LibNFTOrder.ERC1155Order[] calldata orders)
|
||||
/// @dev Cancel multiple ERC1155 orders by their nonces. The caller
|
||||
/// should be the maker of the orders. Silently succeeds if
|
||||
/// an order with the same nonce has already been filled or
|
||||
/// cancelled.
|
||||
/// @param orderNonces The order nonces.
|
||||
function batchCancelERC1155Orders(uint256[] calldata orderNonces)
|
||||
external;
|
||||
|
||||
/// @dev Buys multiple ERC1155 assets by filling the
|
||||
@@ -145,6 +147,9 @@ interface IERC1155OrdersFeature {
|
||||
/// @param signatures The order signatures.
|
||||
/// @param erc1155TokenAmounts The amounts of the ERC1155 assets
|
||||
/// to buy for each order.
|
||||
/// @param callbackData The data (if any) to pass to the taker
|
||||
/// callback for each order. Refer to the `callbackData`
|
||||
/// parameter to for `buyERC1155`.
|
||||
/// @param revertIfIncomplete If true, reverts if this
|
||||
/// function fails to fill any individual order.
|
||||
/// @return successes An array of booleans corresponding to whether
|
||||
@@ -153,6 +158,7 @@ interface IERC1155OrdersFeature {
|
||||
LibNFTOrder.ERC1155Order[] calldata sellOrders,
|
||||
LibSignature.Signature[] calldata signatures,
|
||||
uint128[] calldata erc1155TokenAmounts,
|
||||
bytes[] calldata callbackData,
|
||||
bool revertIfIncomplete
|
||||
)
|
||||
external
|
||||
@@ -226,7 +232,7 @@ interface IERC1155OrdersFeature {
|
||||
view
|
||||
returns (LibNFTOrder.OrderInfo memory orderInfo);
|
||||
|
||||
/// @dev Get the canonical hash of an ERC1155 order.
|
||||
/// @dev Get the EIP-712 hash of an ERC1155 order.
|
||||
/// @param order The ERC1155 order.
|
||||
/// @return orderHash The order hash.
|
||||
function getERC1155OrderHash(LibNFTOrder.ERC1155Order calldata order)
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
@@ -138,6 +138,9 @@ interface IERC721OrdersFeature {
|
||||
/// given orders.
|
||||
/// @param sellOrders The ERC721 sell orders.
|
||||
/// @param signatures The order signatures.
|
||||
/// @param callbackData The data (if any) to pass to the taker
|
||||
/// callback for each order. Refer to the `callbackData`
|
||||
/// parameter to for `buyERC721`.
|
||||
/// @param revertIfIncomplete If true, reverts if this
|
||||
/// function fails to fill any individual order.
|
||||
/// @return successes An array of booleans corresponding to whether
|
||||
@@ -145,6 +148,7 @@ interface IERC721OrdersFeature {
|
||||
function batchBuyERC721s(
|
||||
LibNFTOrder.ERC721Order[] calldata sellOrders,
|
||||
LibSignature.Signature[] calldata signatures,
|
||||
bytes[] calldata callbackData,
|
||||
bool revertIfIncomplete
|
||||
)
|
||||
external
|
||||
@@ -258,7 +262,7 @@ interface IERC721OrdersFeature {
|
||||
view
|
||||
returns (LibNFTOrder.OrderStatus status);
|
||||
|
||||
/// @dev Get the canonical hash of an ERC721 order.
|
||||
/// @dev Get the EIP-712 hash of an ERC721 order.
|
||||
/// @param order The ERC721 order.
|
||||
/// @return orderHash The order hash.
|
||||
function getERC721OrderHash(LibNFTOrder.ERC721Order calldata order)
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
@@ -263,93 +263,8 @@ library LibNFTOrder {
|
||||
pure
|
||||
returns (bytes32 structHash)
|
||||
{
|
||||
// We give `order.erc721TokenProperties.length == 0` and
|
||||
// `order.erc721TokenProperties.length == 1` special treatment
|
||||
// because we expect these to be the most common.
|
||||
bytes32 propertiesHash;
|
||||
if (order.erc721TokenProperties.length == 0) {
|
||||
propertiesHash = _EMPTY_ARRAY_KECCAK256;
|
||||
} else if (order.erc721TokenProperties.length == 1) {
|
||||
Property memory property = order
|
||||
.erc721TokenProperties[0];
|
||||
if (
|
||||
address(property.propertyValidator) == address(0) &&
|
||||
property.propertyData.length == 0
|
||||
) {
|
||||
propertiesHash = _NULL_PROPERTY_STRUCT_HASH;
|
||||
} else {
|
||||
// propertiesHash = keccak256(abi.encodePacked(keccak256(abi.encode(
|
||||
// _PROPERTY_TYPEHASH,
|
||||
// order.erc721TokenProperties[0].propertyValidator,
|
||||
// keccak256(order.erc721TokenProperties[0].propertyData)
|
||||
// ))));
|
||||
bytes32 dataHash = keccak256(property.propertyData);
|
||||
assembly {
|
||||
// Load free memory pointer
|
||||
let mem := mload(64)
|
||||
mstore(mem, _PROPERTY_TYPEHASH)
|
||||
// property.propertyValidator
|
||||
mstore(add(mem, 32), and(ADDRESS_MASK, mload(property)))
|
||||
// keccak256(property.propertyData)
|
||||
mstore(add(mem, 64), dataHash)
|
||||
mstore(mem, keccak256(mem, 96))
|
||||
propertiesHash := keccak256(mem, 32)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bytes32[] memory propertyStructHashArray = new bytes32[](
|
||||
order.erc721TokenProperties.length
|
||||
);
|
||||
for (uint256 i = 0; i < order.erc721TokenProperties.length; i++) {
|
||||
propertyStructHashArray[i] = keccak256(abi.encode(
|
||||
_PROPERTY_TYPEHASH,
|
||||
order.erc721TokenProperties[i].propertyValidator,
|
||||
keccak256(order.erc721TokenProperties[i].propertyData)
|
||||
));
|
||||
}
|
||||
propertiesHash = keccak256(abi.encodePacked(propertyStructHashArray));
|
||||
}
|
||||
|
||||
// We give `order.fees.length == 0` and
|
||||
// `order.fees.length == 1` special treatment
|
||||
// because we expect these to be the most common.
|
||||
bytes32 feesHash;
|
||||
if (order.fees.length == 0) {
|
||||
feesHash = _EMPTY_ARRAY_KECCAK256;
|
||||
} else if (order.fees.length == 1) {
|
||||
// feesHash = keccak256(abi.encodePacked(keccak256(abi.encode(
|
||||
// _FEE_TYPEHASH,
|
||||
// order.fees[0].recipient,
|
||||
// order.fees[0].amount,
|
||||
// keccak256(order.fees[0].feeData)
|
||||
// ))));
|
||||
Fee memory fee = order.fees[0];
|
||||
bytes32 dataHash = keccak256(fee.feeData);
|
||||
assembly {
|
||||
// Load free memory pointer
|
||||
let mem := mload(64)
|
||||
mstore(mem, _FEE_TYPEHASH)
|
||||
// fee.recipient
|
||||
mstore(add(mem, 32), and(ADDRESS_MASK, mload(fee)))
|
||||
// fee.amount
|
||||
mstore(add(mem, 64), mload(add(fee, 32)))
|
||||
// keccak256(fee.feeData)
|
||||
mstore(add(mem, 96), dataHash)
|
||||
mstore(mem, keccak256(mem, 128))
|
||||
feesHash := keccak256(mem, 32)
|
||||
}
|
||||
} else {
|
||||
bytes32[] memory feeStructHashArray = new bytes32[](order.fees.length);
|
||||
for (uint256 i = 0; i < order.fees.length; i++) {
|
||||
feeStructHashArray[i] = keccak256(abi.encode(
|
||||
_FEE_TYPEHASH,
|
||||
order.fees[i].recipient,
|
||||
order.fees[i].amount,
|
||||
keccak256(order.fees[i].feeData)
|
||||
));
|
||||
}
|
||||
feesHash = keccak256(abi.encodePacked(feeStructHashArray));
|
||||
}
|
||||
bytes32 propertiesHash = _propertiesHash(order.erc721TokenProperties);
|
||||
bytes32 feesHash = _feesHash(order.fees);
|
||||
|
||||
// Hash in place, equivalent to:
|
||||
// return keccak256(abi.encode(
|
||||
@@ -373,18 +288,18 @@ library LibNFTOrder {
|
||||
let feesHashPos := add(order, 224) // order + (32 * 7)
|
||||
let propertiesHashPos := add(order, 320) // order + (32 * 10)
|
||||
|
||||
let temp1 := mload(typeHashPos)
|
||||
let temp2 := mload(feesHashPos)
|
||||
let temp3 := mload(propertiesHashPos)
|
||||
let typeHashMemBefore := mload(typeHashPos)
|
||||
let feeHashMemBefore := mload(feesHashPos)
|
||||
let propertiesHashMemBefore := mload(propertiesHashPos)
|
||||
|
||||
mstore(typeHashPos, _ERC_721_ORDER_TYPEHASH)
|
||||
mstore(feesHashPos, feesHash)
|
||||
mstore(propertiesHashPos, propertiesHash)
|
||||
structHash := keccak256(typeHashPos, 384 /* 32 * 12 */ )
|
||||
|
||||
mstore(typeHashPos, temp1)
|
||||
mstore(feesHashPos, temp2)
|
||||
mstore(propertiesHashPos, temp3)
|
||||
mstore(typeHashPos, typeHashMemBefore)
|
||||
mstore(feesHashPos, feeHashMemBefore)
|
||||
mstore(propertiesHashPos, propertiesHashMemBefore)
|
||||
}
|
||||
return structHash;
|
||||
}
|
||||
@@ -397,93 +312,8 @@ library LibNFTOrder {
|
||||
pure
|
||||
returns (bytes32 structHash)
|
||||
{
|
||||
// We give `order.erc1155TokenProperties.length == 0` and
|
||||
// `order.erc1155TokenProperties.length == 1` special treatment
|
||||
// because we expect these to be the most common.
|
||||
bytes32 propertiesHash;
|
||||
if (order.erc1155TokenProperties.length == 0) {
|
||||
propertiesHash = _EMPTY_ARRAY_KECCAK256;
|
||||
} else if (order.erc1155TokenProperties.length == 1) {
|
||||
Property memory property = order
|
||||
.erc1155TokenProperties[0];
|
||||
if (
|
||||
address(property.propertyValidator) == address(0) &&
|
||||
property.propertyData.length == 0
|
||||
) {
|
||||
propertiesHash = _NULL_PROPERTY_STRUCT_HASH;
|
||||
} else {
|
||||
// propertiesHash = keccak256(abi.encodePacked(keccak256(abi.encode(
|
||||
// _PROPERTY_TYPEHASH,
|
||||
// order.erc1155TokenProperties[0].propertyValidator,
|
||||
// keccak256(order.erc1155TokenProperties[0].propertyData)
|
||||
// ))));
|
||||
bytes32 dataHash = keccak256(property.propertyData);
|
||||
assembly {
|
||||
// Load free memory pointer
|
||||
let mem := mload(64)
|
||||
mstore(mem, _PROPERTY_TYPEHASH)
|
||||
// property.propertyValidator
|
||||
mstore(add(mem, 32), and(ADDRESS_MASK, mload(property)))
|
||||
// keccak256(property.propertyData)
|
||||
mstore(add(mem, 64), dataHash)
|
||||
mstore(mem, keccak256(mem, 96))
|
||||
propertiesHash := keccak256(mem, 32)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bytes32[] memory propertyStructHashArray = new bytes32[](
|
||||
order.erc1155TokenProperties.length
|
||||
);
|
||||
for (uint256 i = 0; i < order.erc1155TokenProperties.length; i++) {
|
||||
propertyStructHashArray[i] = keccak256(abi.encode(
|
||||
_PROPERTY_TYPEHASH,
|
||||
order.erc1155TokenProperties[i].propertyValidator,
|
||||
keccak256(order.erc1155TokenProperties[i].propertyData)
|
||||
));
|
||||
}
|
||||
propertiesHash = keccak256(abi.encodePacked(propertyStructHashArray));
|
||||
}
|
||||
|
||||
// We give `order.fees.length == 0` and
|
||||
// `order.fees.length == 1` special treatment
|
||||
// because we expect these to be the most common.
|
||||
bytes32 feesHash;
|
||||
if (order.fees.length == 0) {
|
||||
feesHash = _EMPTY_ARRAY_KECCAK256;
|
||||
} else if (order.fees.length == 1) {
|
||||
// feesHash = keccak256(abi.encodePacked(keccak256(abi.encode(
|
||||
// _FEE_TYPEHASH,
|
||||
// order.fees[0].recipient,
|
||||
// order.fees[0].amount,
|
||||
// keccak256(order.fees[0].feeData)
|
||||
// ))));
|
||||
Fee memory fee = order.fees[0];
|
||||
bytes32 dataHash = keccak256(fee.feeData);
|
||||
assembly {
|
||||
// Load free memory pointer
|
||||
let mem := mload(64)
|
||||
mstore(mem, _FEE_TYPEHASH)
|
||||
// fee.recipient
|
||||
mstore(add(mem, 32), and(ADDRESS_MASK, mload(fee)))
|
||||
// fee.amount
|
||||
mstore(add(mem, 64), mload(add(fee, 32)))
|
||||
// keccak256(fee.feeData)
|
||||
mstore(add(mem, 96), dataHash)
|
||||
mstore(mem, keccak256(mem, 128))
|
||||
feesHash := keccak256(mem, 32)
|
||||
}
|
||||
} else {
|
||||
bytes32[] memory feeStructHashArray = new bytes32[](order.fees.length);
|
||||
for (uint256 i = 0; i < order.fees.length; i++) {
|
||||
feeStructHashArray[i] = keccak256(abi.encode(
|
||||
_FEE_TYPEHASH,
|
||||
order.fees[i].recipient,
|
||||
order.fees[i].amount,
|
||||
keccak256(order.fees[i].feeData)
|
||||
));
|
||||
}
|
||||
feesHash = keccak256(abi.encodePacked(feeStructHashArray));
|
||||
}
|
||||
bytes32 propertiesHash = _propertiesHash(order.erc1155TokenProperties);
|
||||
bytes32 feesHash = _feesHash(order.fees);
|
||||
|
||||
// Hash in place, equivalent to:
|
||||
// return keccak256(abi.encode(
|
||||
@@ -508,19 +338,122 @@ library LibNFTOrder {
|
||||
let feesHashPos := add(order, 224) // order + (32 * 7)
|
||||
let propertiesHashPos := add(order, 320) // order + (32 * 10)
|
||||
|
||||
let temp1 := mload(typeHashPos)
|
||||
let temp2 := mload(feesHashPos)
|
||||
let temp3 := mload(propertiesHashPos)
|
||||
let typeHashMemBefore := mload(typeHashPos)
|
||||
let feesHashMemBefore := mload(feesHashPos)
|
||||
let propertiesHashMemBefore := mload(propertiesHashPos)
|
||||
|
||||
mstore(typeHashPos, _ERC_1155_ORDER_TYPEHASH)
|
||||
mstore(feesHashPos, feesHash)
|
||||
mstore(propertiesHashPos, propertiesHash)
|
||||
structHash := keccak256(typeHashPos, 416 /* 32 * 12 */ )
|
||||
|
||||
mstore(typeHashPos, temp1)
|
||||
mstore(feesHashPos, temp2)
|
||||
mstore(propertiesHashPos, temp3)
|
||||
mstore(typeHashPos, typeHashMemBefore)
|
||||
mstore(feesHashPos, feesHashMemBefore)
|
||||
mstore(propertiesHashPos, propertiesHashMemBefore)
|
||||
}
|
||||
return structHash;
|
||||
}
|
||||
|
||||
// Hashes the `properties` array as part of computing the
|
||||
// EIP-712 hash of an `ERC721Order` or `ERC1155Order`.
|
||||
function _propertiesHash(Property[] memory properties)
|
||||
private
|
||||
pure
|
||||
returns (bytes32 propertiesHash)
|
||||
{
|
||||
uint256 numProperties = properties.length;
|
||||
// We give `properties.length == 0` and `properties.length == 1`
|
||||
// special treatment because we expect these to be the most common.
|
||||
if (numProperties == 0) {
|
||||
propertiesHash = _EMPTY_ARRAY_KECCAK256;
|
||||
} else if (numProperties == 1) {
|
||||
Property memory property = properties[0];
|
||||
if (
|
||||
address(property.propertyValidator) == address(0) &&
|
||||
property.propertyData.length == 0
|
||||
) {
|
||||
propertiesHash = _NULL_PROPERTY_STRUCT_HASH;
|
||||
} else {
|
||||
// propertiesHash = keccak256(abi.encodePacked(keccak256(abi.encode(
|
||||
// _PROPERTY_TYPEHASH,
|
||||
// properties[0].propertyValidator,
|
||||
// keccak256(properties[0].propertyData)
|
||||
// ))));
|
||||
bytes32 dataHash = keccak256(property.propertyData);
|
||||
assembly {
|
||||
// Load free memory pointer
|
||||
let mem := mload(64)
|
||||
mstore(mem, _PROPERTY_TYPEHASH)
|
||||
// property.propertyValidator
|
||||
mstore(add(mem, 32), and(ADDRESS_MASK, mload(property)))
|
||||
// keccak256(property.propertyData)
|
||||
mstore(add(mem, 64), dataHash)
|
||||
mstore(mem, keccak256(mem, 96))
|
||||
propertiesHash := keccak256(mem, 32)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bytes32[] memory propertyStructHashArray = new bytes32[](numProperties);
|
||||
for (uint256 i = 0; i < numProperties; i++) {
|
||||
propertyStructHashArray[i] = keccak256(abi.encode(
|
||||
_PROPERTY_TYPEHASH,
|
||||
properties[i].propertyValidator,
|
||||
keccak256(properties[i].propertyData)
|
||||
));
|
||||
}
|
||||
assembly {
|
||||
propertiesHash := keccak256(add(propertyStructHashArray, 32), mul(numProperties, 32))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hashes the `fees` array as part of computing the
|
||||
// EIP-712 hash of an `ERC721Order` or `ERC1155Order`.
|
||||
function _feesHash(Fee[] memory fees)
|
||||
private
|
||||
pure
|
||||
returns (bytes32 feesHash)
|
||||
{
|
||||
uint256 numFees = fees.length;
|
||||
// We give `fees.length == 0` and `fees.length == 1`
|
||||
// special treatment because we expect these to be the most common.
|
||||
if (numFees == 0) {
|
||||
feesHash = _EMPTY_ARRAY_KECCAK256;
|
||||
} else if (numFees == 1) {
|
||||
// feesHash = keccak256(abi.encodePacked(keccak256(abi.encode(
|
||||
// _FEE_TYPEHASH,
|
||||
// fees[0].recipient,
|
||||
// fees[0].amount,
|
||||
// keccak256(fees[0].feeData)
|
||||
// ))));
|
||||
Fee memory fee = fees[0];
|
||||
bytes32 dataHash = keccak256(fee.feeData);
|
||||
assembly {
|
||||
// Load free memory pointer
|
||||
let mem := mload(64)
|
||||
mstore(mem, _FEE_TYPEHASH)
|
||||
// fee.recipient
|
||||
mstore(add(mem, 32), and(ADDRESS_MASK, mload(fee)))
|
||||
// fee.amount
|
||||
mstore(add(mem, 64), mload(add(fee, 32)))
|
||||
// keccak256(fee.feeData)
|
||||
mstore(add(mem, 96), dataHash)
|
||||
mstore(mem, keccak256(mem, 128))
|
||||
feesHash := keccak256(mem, 32)
|
||||
}
|
||||
} else {
|
||||
bytes32[] memory feeStructHashArray = new bytes32[](numFees);
|
||||
for (uint256 i = 0; i < numFees; i++) {
|
||||
feeStructHashArray[i] = keccak256(abi.encode(
|
||||
_FEE_TYPEHASH,
|
||||
fees[i].recipient,
|
||||
fees[i].amount,
|
||||
keccak256(fees[i].feeData)
|
||||
));
|
||||
}
|
||||
assembly {
|
||||
feesHash := keccak256(add(feeStructHashArray, 32), mul(numFees, 32))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
@@ -51,10 +51,6 @@ contract ERC1155OrdersFeature is
|
||||
|
||||
/// @dev The magic return value indicating the success of a `onERC1155Received`.
|
||||
bytes4 private constant ERC1155_RECEIVED_MAGIC_BYTES = this.onERC1155Received.selector;
|
||||
/// @dev Highest bit of a uint256, used to flag cancelled orders.
|
||||
uint256 private constant CANCEL_BIT = 1 << 255;
|
||||
/// @dev Second-highest bit of a uint256, used to flag pre-signed orders.
|
||||
uint256 private constant PRESIGN_BIT = 1 << 254;
|
||||
|
||||
|
||||
constructor(address zeroExAddress, IEtherTokenV06 weth)
|
||||
@@ -156,7 +152,7 @@ contract ERC1155OrdersFeature is
|
||||
)
|
||||
);
|
||||
uint256 ethBalanceAfter = address(this).balance;
|
||||
// Cannot spent more than `msg.value`
|
||||
// Cannot use pre-existing ETH balance
|
||||
if (ethBalanceAfter < ethBalanceBefore) {
|
||||
LibNFTOrdersRichErrors.OverspentEthError(
|
||||
ethBalanceBefore - ethBalanceAfter + msg.value,
|
||||
@@ -167,39 +163,36 @@ contract ERC1155OrdersFeature is
|
||||
_transferEth(msg.sender, ethBalanceAfter - ethBalanceBefore);
|
||||
}
|
||||
|
||||
/// @dev Cancel a single ERC1155 order. The caller should be the
|
||||
/// maker of the order. Silently succeeds if the order has
|
||||
/// already been filled or cancelled.
|
||||
/// @param order The order to cancel.
|
||||
function cancelERC1155Order(LibNFTOrder.ERC1155Order memory order)
|
||||
/// @dev Cancel a single ERC1155 order by its nonce. The caller
|
||||
/// should be the maker of the order. Silently succeeds if
|
||||
/// an order with the same nonce has already been filled or
|
||||
/// cancelled.
|
||||
/// @param orderNonce The order nonce.
|
||||
function cancelERC1155Order(uint256 orderNonce)
|
||||
public
|
||||
override
|
||||
{
|
||||
require(
|
||||
order.maker == msg.sender,
|
||||
"ERC1155OrdersFeature::cancelERC1155Order/ONLY_MAKER"
|
||||
);
|
||||
// The bitvector is indexed by the lower 8 bits of the nonce.
|
||||
uint256 flag = 1 << (orderNonce & 255);
|
||||
// Update order cancellation bit vector to indicate that the order
|
||||
// has been cancelled/filled by setting the designated bit to 1.
|
||||
LibERC1155OrdersStorage.getStorage().orderCancellationByMaker
|
||||
[msg.sender][uint248(orderNonce >> 8)] |= flag;
|
||||
|
||||
bytes32 orderHash = getERC1155OrderHash(order);
|
||||
// Set the high bit on the order state variable to indicate
|
||||
// a cancel. It's OK to cancel twice.
|
||||
LibERC1155OrdersStorage.Storage storage stor =
|
||||
LibERC1155OrdersStorage.getStorage();
|
||||
stor.orderState[orderHash] |= CANCEL_BIT;
|
||||
|
||||
emit ERC1155OrderCancelled(orderHash, msg.sender);
|
||||
emit ERC1155OrderCancelled(msg.sender, orderNonce);
|
||||
}
|
||||
|
||||
/// @dev Cancel multiple ERC1155 orders. The caller should be the
|
||||
/// maker of the orders. Silently succeeds if an order has
|
||||
/// already been filled or cancelled.
|
||||
/// @param orders The orders to cancel.
|
||||
function batchCancelERC1155Orders(LibNFTOrder.ERC1155Order[] memory orders)
|
||||
public
|
||||
/// @dev Cancel multiple ERC1155 orders by their nonces. The caller
|
||||
/// should be the maker of the orders. Silently succeeds if
|
||||
/// an order with the same nonce has already been filled or
|
||||
/// cancelled.
|
||||
/// @param orderNonces The order nonces.
|
||||
function batchCancelERC1155Orders(uint256[] calldata orderNonces)
|
||||
external
|
||||
override
|
||||
{
|
||||
for (uint256 i = 0; i < orders.length; i++) {
|
||||
cancelERC1155Order(orders[i]);
|
||||
for (uint256 i = 0; i < orderNonces.length; i++) {
|
||||
cancelERC1155Order(orderNonces[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,6 +202,9 @@ contract ERC1155OrdersFeature is
|
||||
/// @param signatures The order signatures.
|
||||
/// @param erc1155FillAmounts The amounts of the ERC1155 assets
|
||||
/// to buy for each order.
|
||||
/// @param callbackData The data (if any) to pass to the taker
|
||||
/// callback for each order. Refer to the `callbackData`
|
||||
/// parameter to for `buyERC1155`.
|
||||
/// @param revertIfIncomplete If true, reverts if this
|
||||
/// function fails to fill any individual order.
|
||||
/// @return successes An array of booleans corresponding to whether
|
||||
@@ -217,6 +213,7 @@ contract ERC1155OrdersFeature is
|
||||
LibNFTOrder.ERC1155Order[] memory sellOrders,
|
||||
LibSignature.Signature[] memory signatures,
|
||||
uint128[] calldata erc1155FillAmounts,
|
||||
bytes[] memory callbackData,
|
||||
bool revertIfIncomplete
|
||||
)
|
||||
public
|
||||
@@ -226,50 +223,60 @@ contract ERC1155OrdersFeature is
|
||||
{
|
||||
require(
|
||||
sellOrders.length == signatures.length &&
|
||||
sellOrders.length == erc1155FillAmounts.length,
|
||||
sellOrders.length == erc1155FillAmounts.length &&
|
||||
sellOrders.length == callbackData.length,
|
||||
"ERC1155OrdersFeature::batchBuyERC1155s/ARRAY_LENGTH_MISMATCH"
|
||||
);
|
||||
successes = new bool[](sellOrders.length);
|
||||
|
||||
uint256 ethSpent = 0;
|
||||
for (uint256 i = 0; i < sellOrders.length; i++) {
|
||||
bytes memory returnData;
|
||||
// Delegatecall `_buyERC1155` to track ETH consumption while
|
||||
// preserving execution context.
|
||||
// Note that `_buyERC1155` is a public function but should _not_
|
||||
// be registered in the Exchange Proxy.
|
||||
(successes[i], returnData) = _implementation.delegatecall(
|
||||
abi.encodeWithSelector(
|
||||
this._buyERC1155.selector,
|
||||
uint256 ethBalanceBefore = address(this).balance
|
||||
.safeSub(msg.value);
|
||||
if (revertIfIncomplete) {
|
||||
for (uint256 i = 0; i < sellOrders.length; i++) {
|
||||
// Will revert if _buyERC1155 reverts.
|
||||
_buyERC1155(
|
||||
sellOrders[i],
|
||||
signatures[i],
|
||||
BuyParams(
|
||||
erc1155FillAmounts[i],
|
||||
msg.value - ethSpent, // Remaining ETH available
|
||||
new bytes(0) // No taker callback; allowing a
|
||||
// callback would potentially mess
|
||||
// up the ETH accounting here.
|
||||
address(this).balance.safeSub(ethBalanceBefore), // Remaining ETH available
|
||||
callbackData[i]
|
||||
)
|
||||
)
|
||||
);
|
||||
if (successes[i]) {
|
||||
(uint256 _ethSpent) = abi.decode(returnData, (uint256));
|
||||
ethSpent = ethSpent.safeAdd(_ethSpent);
|
||||
} else if (revertIfIncomplete) {
|
||||
// Bubble up revert
|
||||
returnData.rrevert();
|
||||
);
|
||||
successes[i] = true;
|
||||
}
|
||||
} else {
|
||||
for (uint256 i = 0; i < sellOrders.length; i++) {
|
||||
// Delegatecall `_buyERC1155` to catch swallow reverts while
|
||||
// preserving execution context.
|
||||
// Note that `_buyERC1155` is a public function but should _not_
|
||||
// be registered in the Exchange Proxy.
|
||||
(successes[i], ) = _implementation.delegatecall(
|
||||
abi.encodeWithSelector(
|
||||
this._buyERC1155.selector,
|
||||
sellOrders[i],
|
||||
signatures[i],
|
||||
BuyParams(
|
||||
erc1155FillAmounts[i],
|
||||
address(this).balance.safeSub(ethBalanceBefore), // Remaining ETH available
|
||||
callbackData[i]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (ethSpent > msg.value) {
|
||||
// Cannot use pre-existing ETH balance
|
||||
uint256 ethBalanceAfter = address(this).balance;
|
||||
if (ethBalanceAfter < ethBalanceBefore) {
|
||||
LibNFTOrdersRichErrors.OverspentEthError(
|
||||
ethSpent,
|
||||
msg.value + (ethBalanceBefore - ethBalanceAfter),
|
||||
msg.value
|
||||
).rrevert();
|
||||
}
|
||||
|
||||
// Refund
|
||||
_transferEth(msg.sender, msg.value - ethSpent);
|
||||
_transferEth(msg.sender, ethBalanceAfter - ethBalanceBefore);
|
||||
}
|
||||
|
||||
/// @dev Callback for the ERC1155 `safeTransferFrom` function.
|
||||
@@ -350,9 +357,9 @@ contract ERC1155OrdersFeature is
|
||||
|
||||
LibERC1155OrdersStorage.Storage storage stor =
|
||||
LibERC1155OrdersStorage.getStorage();
|
||||
// Set the second-highest bit on the order state variable
|
||||
// Set `preSigned` to true on the order state variable
|
||||
// to indicate that the order has been pre-signed.
|
||||
stor.orderState[orderHash] |= PRESIGN_BIT;
|
||||
stor.orderState[orderHash].preSigned = true;
|
||||
|
||||
emit ERC1155OrderPreSigned(
|
||||
order.direction,
|
||||
@@ -408,10 +415,8 @@ contract ERC1155OrdersFeature is
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (uint256 ethSpent)
|
||||
{
|
||||
uint256 erc20FillAmount;
|
||||
(erc20FillAmount, ethSpent) = _buyNFT(
|
||||
uint256 erc20FillAmount = _buyNFT(
|
||||
sellOrder.asNFTOrder(),
|
||||
signature,
|
||||
params
|
||||
@@ -464,9 +469,8 @@ contract ERC1155OrdersFeature is
|
||||
{
|
||||
if (signature.signatureType == LibSignature.SignatureType.PRESIGNED) {
|
||||
// Check if order hash has been pre-signed by the maker.
|
||||
uint256 orderState = LibERC1155OrdersStorage.getStorage()
|
||||
.orderState[orderHash];
|
||||
bool isPreSigned = orderState & PRESIGN_BIT != 0;
|
||||
bool isPreSigned = LibERC1155OrdersStorage.getStorage()
|
||||
.orderState[orderHash].preSigned;
|
||||
if (!isPreSigned) {
|
||||
LibNFTOrdersRichErrors.InvalidSignerError(maker, address(0)).rrevert();
|
||||
}
|
||||
@@ -512,10 +516,10 @@ contract ERC1155OrdersFeature is
|
||||
override
|
||||
{
|
||||
LibERC1155OrdersStorage.Storage storage stor = LibERC1155OrdersStorage.getStorage();
|
||||
uint128 currentFilledAmount = uint128(stor.orderState[orderHash]);
|
||||
uint128 filledAmount = stor.orderState[orderHash].filledAmount;
|
||||
// Filled amount should never overflow 128 bits
|
||||
assert(currentFilledAmount + fillAmount > currentFilledAmount);
|
||||
stor.orderState[orderHash] += fillAmount;
|
||||
assert(filledAmount + fillAmount > filledAmount);
|
||||
stor.orderState[orderHash].filledAmount = filledAmount + fillAmount;
|
||||
}
|
||||
|
||||
/// @dev If the given order is buying an ERC1155 asset, checks
|
||||
@@ -553,23 +557,6 @@ contract ERC1155OrdersFeature is
|
||||
orderInfo.orderAmount = order.erc1155TokenAmount;
|
||||
orderInfo.orderHash = getERC1155OrderHash(order);
|
||||
|
||||
{
|
||||
LibERC1155OrdersStorage.Storage storage stor =
|
||||
LibERC1155OrdersStorage.getStorage();
|
||||
uint256 orderState = stor.orderState[orderInfo.orderHash];
|
||||
orderInfo.remainingAmount = order.erc1155TokenAmount
|
||||
.safeSub128(uint128(orderState));
|
||||
|
||||
if (orderInfo.remainingAmount == 0) {
|
||||
orderInfo.status = LibNFTOrder.OrderStatus.UNFILLABLE;
|
||||
return orderInfo;
|
||||
}
|
||||
if (orderState & CANCEL_BIT != 0) {
|
||||
orderInfo.status = LibNFTOrder.OrderStatus.UNFILLABLE;
|
||||
return orderInfo;
|
||||
}
|
||||
}
|
||||
|
||||
// Only buy orders with `erc1155TokenId` == 0 can be property
|
||||
// orders.
|
||||
if (order.erc1155TokenProperties.length > 0 &&
|
||||
@@ -595,6 +582,29 @@ contract ERC1155OrdersFeature is
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
{
|
||||
LibERC1155OrdersStorage.Storage storage stor =
|
||||
LibERC1155OrdersStorage.getStorage();
|
||||
|
||||
LibERC1155OrdersStorage.OrderState storage orderState =
|
||||
stor.orderState[orderInfo.orderHash];
|
||||
orderInfo.remainingAmount = order.erc1155TokenAmount
|
||||
.safeSub128(orderState.filledAmount);
|
||||
|
||||
// `orderCancellationByMaker` is indexed by maker and nonce.
|
||||
uint256 orderCancellationBitVector =
|
||||
stor.orderCancellationByMaker[order.maker][uint248(order.nonce >> 8)];
|
||||
// The bitvector is indexed by the lower 8 bits of the nonce.
|
||||
uint256 flag = 1 << (order.nonce & 255);
|
||||
|
||||
if (orderInfo.remainingAmount == 0 ||
|
||||
orderCancellationBitVector & flag != 0)
|
||||
{
|
||||
orderInfo.status = LibNFTOrder.OrderStatus.UNFILLABLE;
|
||||
return orderInfo;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, the order is fillable.
|
||||
orderInfo.status = LibNFTOrder.OrderStatus.FILLABLE;
|
||||
}
|
||||
@@ -611,7 +621,7 @@ contract ERC1155OrdersFeature is
|
||||
return getERC1155OrderInfo(order.asERC1155Order());
|
||||
}
|
||||
|
||||
/// @dev Get the canonical hash of an ERC1155 order.
|
||||
/// @dev Get the EIP-712 hash of an ERC1155 order.
|
||||
/// @param order The ERC1155 order.
|
||||
/// @return orderHash The order hash.
|
||||
function getERC1155OrderHash(LibNFTOrder.ERC1155Order memory order)
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
@@ -142,10 +142,10 @@ contract ERC721OrdersFeature is
|
||||
callbackData
|
||||
);
|
||||
uint256 ethBalanceAfter = address(this).balance;
|
||||
// Cannot spent more than `msg.value`
|
||||
// Cannot use pre-existing ETH balance
|
||||
if (ethBalanceAfter < ethBalanceBefore) {
|
||||
LibNFTOrdersRichErrors.OverspentEthError(
|
||||
ethBalanceBefore - ethBalanceAfter + msg.value,
|
||||
msg.value + (ethBalanceBefore - ethBalanceAfter),
|
||||
msg.value
|
||||
).rrevert();
|
||||
}
|
||||
@@ -164,11 +164,7 @@ contract ERC721OrdersFeature is
|
||||
{
|
||||
// Mark order as cancelled
|
||||
_setOrderStatusBit(msg.sender, orderNonce);
|
||||
|
||||
emit ERC721OrderCancelled(
|
||||
msg.sender,
|
||||
orderNonce
|
||||
);
|
||||
emit ERC721OrderCancelled(msg.sender, orderNonce);
|
||||
}
|
||||
|
||||
/// @dev Cancel multiple ERC721 orders by their nonces. The caller
|
||||
@@ -191,11 +187,15 @@ contract ERC721OrdersFeature is
|
||||
/// @param signatures The order signatures.
|
||||
/// @param revertIfIncomplete If true, reverts if this
|
||||
/// function fails to fill any individual order.
|
||||
/// @param callbackData The data (if any) to pass to the taker
|
||||
/// callback for each order. Refer to the `callbackData`
|
||||
/// parameter to for `buyERC721`.
|
||||
/// @return successes An array of booleans corresponding to whether
|
||||
/// each order in `orders` was successfully filled.
|
||||
function batchBuyERC721s(
|
||||
LibNFTOrder.ERC721Order[] memory sellOrders,
|
||||
LibSignature.Signature[] memory signatures,
|
||||
bytes[] memory callbackData,
|
||||
bool revertIfIncomplete
|
||||
)
|
||||
public
|
||||
@@ -204,47 +204,54 @@ contract ERC721OrdersFeature is
|
||||
returns (bool[] memory successes)
|
||||
{
|
||||
require(
|
||||
sellOrders.length == signatures.length,
|
||||
sellOrders.length == signatures.length &&
|
||||
sellOrders.length == callbackData.length,
|
||||
"ERC721OrdersFeature::batchBuyERC721s/ARRAY_LENGTH_MISMATCH"
|
||||
);
|
||||
successes = new bool[](sellOrders.length);
|
||||
|
||||
uint256 ethSpent = 0;
|
||||
for (uint256 i = 0; i < sellOrders.length; i++) {
|
||||
bytes memory returnData;
|
||||
// Delegatecall `_buyERC721` to track ETH consumption while
|
||||
// preserving execution context.
|
||||
// Note that `_buyERC721` is a public function but should _not_
|
||||
// be registered in the Exchange Proxy.
|
||||
(successes[i], returnData) = _implementation.delegatecall(
|
||||
abi.encodeWithSelector(
|
||||
this._buyERC721.selector,
|
||||
uint256 ethBalanceBefore = address(this).balance
|
||||
.safeSub(msg.value);
|
||||
if (revertIfIncomplete) {
|
||||
for (uint256 i = 0; i < sellOrders.length; i++) {
|
||||
// Will revert if _buyERC721 reverts.
|
||||
_buyERC721(
|
||||
sellOrders[i],
|
||||
signatures[i],
|
||||
msg.value - ethSpent, // Remaining ETH available
|
||||
new bytes(0) // No taker callback; allowing a
|
||||
// callback would potentially mess
|
||||
// up the ETH accounting here.
|
||||
)
|
||||
);
|
||||
if (successes[i]) {
|
||||
(uint256 _ethSpent) = abi.decode(returnData, (uint256));
|
||||
ethSpent = ethSpent.safeAdd(_ethSpent);
|
||||
} else if (revertIfIncomplete) {
|
||||
// Bubble up revert
|
||||
returnData.rrevert();
|
||||
address(this).balance.safeSub(ethBalanceBefore),
|
||||
callbackData[i]
|
||||
);
|
||||
successes[i] = true;
|
||||
}
|
||||
} else {
|
||||
for (uint256 i = 0; i < sellOrders.length; i++) {
|
||||
// Delegatecall `_buyERC721` to swallow reverts while
|
||||
// preserving execution context.
|
||||
// Note that `_buyERC721` is a public function but should _not_
|
||||
// be registered in the Exchange Proxy.
|
||||
(successes[i], ) = _implementation.delegatecall(
|
||||
abi.encodeWithSelector(
|
||||
this._buyERC721.selector,
|
||||
sellOrders[i],
|
||||
signatures[i],
|
||||
address(this).balance.safeSub(ethBalanceBefore), // Remaining ETH available
|
||||
callbackData[i]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (ethSpent > msg.value) {
|
||||
// Cannot use pre-existing ETH balance
|
||||
uint256 ethBalanceAfter = address(this).balance;
|
||||
if (ethBalanceAfter < ethBalanceBefore) {
|
||||
LibNFTOrdersRichErrors.OverspentEthError(
|
||||
ethSpent,
|
||||
msg.value + (ethBalanceBefore - ethBalanceAfter),
|
||||
msg.value
|
||||
).rrevert();
|
||||
}
|
||||
|
||||
// Refund
|
||||
_transferEth(msg.sender, msg.value - ethSpent);
|
||||
_transferEth(msg.sender, ethBalanceAfter - ethBalanceBefore);
|
||||
}
|
||||
|
||||
/// @dev Matches a pair of complementary orders that have
|
||||
@@ -268,6 +275,14 @@ contract ERC721OrdersFeature is
|
||||
override
|
||||
returns (uint256 profit)
|
||||
{
|
||||
// The ERC721 tokens must match
|
||||
if (sellOrder.erc721Token != buyOrder.erc721Token) {
|
||||
LibNFTOrdersRichErrors.ERC721TokenMismatchError(
|
||||
address(sellOrder.erc721Token),
|
||||
address(buyOrder.erc721Token)
|
||||
).rrevert();
|
||||
}
|
||||
|
||||
LibNFTOrder.NFTOrder memory sellNFTOrder = sellOrder.asNFTOrder();
|
||||
LibNFTOrder.NFTOrder memory buyNFTOrder = buyOrder.asNFTOrder();
|
||||
|
||||
@@ -294,28 +309,6 @@ contract ERC721OrdersFeature is
|
||||
_updateOrderState(buyNFTOrder, buyOrderInfo.orderHash, 1);
|
||||
}
|
||||
|
||||
// The ERC721 tokens must match
|
||||
if (sellOrder.erc721Token != buyOrder.erc721Token) {
|
||||
LibNFTOrdersRichErrors.ERC721TokenMismatchError(
|
||||
address(sellOrder.erc721Token),
|
||||
address(buyOrder.erc721Token)
|
||||
).rrevert();
|
||||
}
|
||||
|
||||
{
|
||||
// The ERC20 tokens must match. Okay if the sell order specifies ETH
|
||||
// and the buy order specifies WETH; we will unwrap the WETH before
|
||||
// sending it to `sellOrder.maker`.
|
||||
bool isWethBuyEthSell =
|
||||
address(sellOrder.erc20Token) == NATIVE_TOKEN_ADDRESS &&
|
||||
buyOrder.erc20Token == WETH;
|
||||
if (sellOrder.erc20Token != buyOrder.erc20Token && !isWethBuyEthSell) {
|
||||
LibNFTOrdersRichErrors.ERC20TokenMismatchError(
|
||||
address(sellOrder.erc20Token),
|
||||
address(buyOrder.erc20Token)
|
||||
).rrevert();
|
||||
}
|
||||
}
|
||||
// The buyer must be willing to pay at least the amount that the
|
||||
// seller is asking.
|
||||
if (buyOrder.erc20TokenAmount < sellOrder.erc20TokenAmount) {
|
||||
@@ -375,10 +368,10 @@ contract ERC721OrdersFeature is
|
||||
// the `erc20Token`, which in this case is WETH.
|
||||
_payFees(
|
||||
buyNFTOrder,
|
||||
buyOrder.maker,
|
||||
1,
|
||||
1,
|
||||
false
|
||||
buyOrder.maker, // payer
|
||||
1, // fillAmount
|
||||
1, // orderAmount
|
||||
false // useNativeToken
|
||||
);
|
||||
|
||||
// Step 5: Pay fees for the sell order. The `erc20Token` of the
|
||||
@@ -388,10 +381,10 @@ contract ERC721OrdersFeature is
|
||||
// sell order fees.
|
||||
uint256 sellOrderFees = _payFees(
|
||||
sellNFTOrder,
|
||||
address(this),
|
||||
1,
|
||||
1,
|
||||
true
|
||||
address(this), // payer
|
||||
1, // fillAmount
|
||||
1, // orderAmount
|
||||
true // useNativeToken
|
||||
);
|
||||
|
||||
// Step 6: The spread must be enough to cover the sell order fees.
|
||||
@@ -412,6 +405,14 @@ contract ERC721OrdersFeature is
|
||||
_transferEth(msg.sender, profit);
|
||||
}
|
||||
} else {
|
||||
// ERC20 tokens must match
|
||||
if (sellOrder.erc20Token != buyOrder.erc20Token) {
|
||||
LibNFTOrdersRichErrors.ERC20TokenMismatchError(
|
||||
address(sellOrder.erc20Token),
|
||||
address(buyOrder.erc20Token)
|
||||
).rrevert();
|
||||
}
|
||||
|
||||
// Step 1: Transfer the ERC20 token from the buyer to the seller.
|
||||
// Note that we transfer `sellOrder.erc20TokenAmount`, which
|
||||
// is at most `buyOrder.erc20TokenAmount`.
|
||||
@@ -428,10 +429,10 @@ contract ERC721OrdersFeature is
|
||||
// `buyOrder.erc20TokenAmount` _plus_ `buyOrder.fees`.
|
||||
_payFees(
|
||||
buyNFTOrder,
|
||||
buyOrder.maker,
|
||||
1,
|
||||
1,
|
||||
false
|
||||
buyOrder.maker, // payer
|
||||
1, // fillAmount
|
||||
1, // orderAmount
|
||||
false // useNativeToken
|
||||
);
|
||||
|
||||
// Step 3: Pay fees for the sell order. These are paid by the buyer
|
||||
@@ -440,10 +441,10 @@ contract ERC721OrdersFeature is
|
||||
// so, we revert in the following step.
|
||||
uint256 sellOrderFees = _payFees(
|
||||
sellNFTOrder,
|
||||
buyOrder.maker,
|
||||
1,
|
||||
1,
|
||||
false
|
||||
buyOrder.maker, // payer
|
||||
1, // fillAmount
|
||||
1, // orderAmount
|
||||
false // useNativeToken
|
||||
);
|
||||
|
||||
// Step 4: The spread must be enough to cover the sell order fees.
|
||||
@@ -457,7 +458,7 @@ contract ERC721OrdersFeature is
|
||||
).rrevert();
|
||||
}
|
||||
|
||||
// Step 7: We calculate the profit as:
|
||||
// Step 5: We calculate the profit as:
|
||||
// profit = buyOrder.erc20TokenAmount - sellOrder.erc20TokenAmount - sellOrderFees
|
||||
// = spread - sellOrderFees
|
||||
// I.e. the buyer would've been willing to pay up to `profit`
|
||||
@@ -688,9 +689,8 @@ contract ERC721OrdersFeature is
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (uint256 ethSpent)
|
||||
{
|
||||
(, ethSpent) = _buyNFT(
|
||||
_buyNFT(
|
||||
sellOrder.asNFTOrder(),
|
||||
signature,
|
||||
BuyParams(
|
||||
@@ -801,7 +801,7 @@ contract ERC721OrdersFeature is
|
||||
private
|
||||
{
|
||||
// The bitvector is indexed by the lower 8 bits of the nonce.
|
||||
uint256 flag = 1 << (nonce % 256);
|
||||
uint256 flag = 1 << (nonce & 255);
|
||||
// Update order status bit vector to indicate that the given order
|
||||
// has been cancelled/filled by setting the designated bit to 1.
|
||||
LibERC721OrdersStorage.getStorage().orderStatusByMaker
|
||||
@@ -870,7 +870,7 @@ contract ERC721OrdersFeature is
|
||||
uint256 orderStatusBitVector =
|
||||
stor.orderStatusByMaker[order.maker][uint248(order.nonce >> 8)];
|
||||
// The bitvector is indexed by the lower 8 bits of the nonce.
|
||||
uint256 flag = 1 << (order.nonce % 256);
|
||||
uint256 flag = 1 << (order.nonce & 255);
|
||||
// If the designated bit is set, the order has been cancelled or
|
||||
// previously filled, so it is now unfillable.
|
||||
if (orderStatusBitVector & flag != 0) {
|
||||
@@ -897,7 +897,7 @@ contract ERC721OrdersFeature is
|
||||
orderInfo.remainingAmount = orderInfo.status == LibNFTOrder.OrderStatus.FILLABLE ? 1 : 0;
|
||||
}
|
||||
|
||||
/// @dev Get the canonical hash of an ERC721 order.
|
||||
/// @dev Get the EIP-712 hash of an ERC721 order.
|
||||
/// @param order The ERC721 order.
|
||||
/// @return orderHash The order hash.
|
||||
function getERC721OrderHash(LibNFTOrder.ERC721Order memory order)
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
@@ -191,7 +191,7 @@ abstract contract NFTOrders is
|
||||
BuyParams memory params
|
||||
)
|
||||
internal
|
||||
returns (uint256 erc20FillAmount, uint256 ethSpent)
|
||||
returns (uint256 erc20FillAmount)
|
||||
{
|
||||
LibNFTOrder.OrderInfo memory orderInfo = _getOrderInfo(sellOrder);
|
||||
// Check that the order can be filled.
|
||||
@@ -231,6 +231,7 @@ abstract contract NFTOrders is
|
||||
params.buyAmount
|
||||
);
|
||||
|
||||
uint256 ethAvailable = params.ethAvailable;
|
||||
if (params.takerCallbackData.length > 0) {
|
||||
require(
|
||||
msg.sender != address(this),
|
||||
@@ -240,7 +241,9 @@ abstract contract NFTOrders is
|
||||
// Invoke the callback
|
||||
bytes4 callbackResult = ITakerCallback(msg.sender)
|
||||
.zeroExTakerCallback(orderInfo.orderHash, params.takerCallbackData);
|
||||
params.ethAvailable = params.ethAvailable.safeAdd(
|
||||
// Update `ethAvailable` with amount acquired during
|
||||
// the callback
|
||||
ethAvailable = ethAvailable.safeAdd(
|
||||
address(this).balance.safeSub(ethBalanceBeforeCallback)
|
||||
);
|
||||
// Check for the magic success bytes
|
||||
@@ -251,30 +254,21 @@ abstract contract NFTOrders is
|
||||
}
|
||||
|
||||
if (address(sellOrder.erc20Token) == NATIVE_TOKEN_ADDRESS) {
|
||||
// Check that we have enough ETH.
|
||||
if (params.ethAvailable < erc20FillAmount) {
|
||||
LibNFTOrdersRichErrors.InsufficientEthError(
|
||||
params.ethAvailable,
|
||||
erc20FillAmount
|
||||
).rrevert();
|
||||
}
|
||||
// Transfer ETH to the seller.
|
||||
_transferEth(payable(sellOrder.maker), erc20FillAmount);
|
||||
// Fees are paid from the EP's current balance of ETH.
|
||||
uint256 ethFees = _payFees(
|
||||
_payEthFees(
|
||||
sellOrder,
|
||||
address(this),
|
||||
params.buyAmount,
|
||||
orderInfo.orderAmount,
|
||||
true
|
||||
erc20FillAmount,
|
||||
ethAvailable
|
||||
);
|
||||
// Sum the amount of ETH spent.
|
||||
ethSpent = erc20FillAmount.safeAdd(ethFees);
|
||||
} else if (sellOrder.erc20Token == WETH) {
|
||||
// If there is enough ETH available, fill the WETH order
|
||||
// (including fees) using that ETH.
|
||||
// Otherwise, transfer WETH from the taker.
|
||||
if (params.ethAvailable >= erc20FillAmount) {
|
||||
if (ethAvailable >= erc20FillAmount) {
|
||||
// Wrap ETH.
|
||||
WETH.deposit{value: erc20FillAmount}();
|
||||
// TODO: Probably safe to just use WETH.transfer for some
|
||||
@@ -285,16 +279,14 @@ abstract contract NFTOrders is
|
||||
sellOrder.maker,
|
||||
erc20FillAmount
|
||||
);
|
||||
// Pay fees using ETH.
|
||||
uint256 ethFees = _payFees(
|
||||
// Fees are paid from the EP's current balance of ETH.
|
||||
_payEthFees(
|
||||
sellOrder,
|
||||
address(this),
|
||||
params.buyAmount,
|
||||
orderInfo.orderAmount,
|
||||
true
|
||||
erc20FillAmount,
|
||||
ethAvailable
|
||||
);
|
||||
// Sum the amount of ETH spent.
|
||||
ethSpent = erc20FillAmount.safeAdd(ethFees);
|
||||
} else {
|
||||
// Transfer WETH from the buyer to the seller.
|
||||
_transferERC20TokensFrom(
|
||||
@@ -403,6 +395,33 @@ abstract contract NFTOrders is
|
||||
_validateOrderSignature(orderInfo.orderHash, signature, buyOrder.maker);
|
||||
}
|
||||
|
||||
function _payEthFees(
|
||||
LibNFTOrder.NFTOrder memory order,
|
||||
uint128 fillAmount,
|
||||
uint128 orderAmount,
|
||||
uint256 ethSpent,
|
||||
uint256 ethAvailable
|
||||
)
|
||||
private
|
||||
{
|
||||
// Pay fees using ETH.
|
||||
uint256 ethFees = _payFees(
|
||||
order,
|
||||
address(this),
|
||||
fillAmount,
|
||||
orderAmount,
|
||||
true
|
||||
);
|
||||
// Update amount of ETH spent.
|
||||
ethSpent = ethSpent.safeAdd(ethFees);
|
||||
if (ethSpent > ethAvailable) {
|
||||
LibNFTOrdersRichErrors.OverspentEthError(
|
||||
ethSpent,
|
||||
ethAvailable
|
||||
).rrevert();
|
||||
}
|
||||
}
|
||||
|
||||
function _payFees(
|
||||
LibNFTOrder.NFTOrder memory order,
|
||||
address payer,
|
||||
@@ -413,6 +432,15 @@ abstract contract NFTOrders is
|
||||
internal
|
||||
returns (uint256 totalFeesPaid)
|
||||
{
|
||||
// Make assertions about ETH case
|
||||
if (useNativeToken) {
|
||||
assert(payer == address(this));
|
||||
assert(
|
||||
order.erc20Token == WETH ||
|
||||
address(order.erc20Token) == NATIVE_TOKEN_ADDRESS
|
||||
);
|
||||
}
|
||||
|
||||
for (uint256 i = 0; i < order.fees.length; i++) {
|
||||
LibNFTOrder.Fee memory fee = order.fees[i];
|
||||
|
||||
@@ -425,7 +453,7 @@ abstract contract NFTOrders is
|
||||
if (fillAmount == orderAmount) {
|
||||
feeFillAmount = fee.amount;
|
||||
} else {
|
||||
// Round in favor of the taker or maker
|
||||
// Round against the fee recipient
|
||||
feeFillAmount = LibMathV06.getPartialAmountFloor(
|
||||
fillAmount,
|
||||
orderAmount,
|
||||
@@ -437,11 +465,6 @@ abstract contract NFTOrders is
|
||||
}
|
||||
|
||||
if (useNativeToken) {
|
||||
assert(payer == address(this));
|
||||
assert(
|
||||
order.erc20Token == WETH ||
|
||||
address(order.erc20Token) == NATIVE_TOKEN_ADDRESS
|
||||
);
|
||||
// Transfer ETH to the fee recipient.
|
||||
_transferEth(payable(fee.recipient), feeFillAmount);
|
||||
} else {
|
||||
@@ -506,31 +529,31 @@ abstract contract NFTOrders is
|
||||
order.nftId
|
||||
).rrevert();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Validate each property
|
||||
for (uint256 i = 0; i < order.nftProperties.length; i++) {
|
||||
LibNFTOrder.Property memory property = order.nftProperties[i];
|
||||
// `address(0)` is interpreted as a no-op. Any token ID
|
||||
// will satisfy a property with `propertyValidator == address(0)`.
|
||||
if (address(property.propertyValidator) == address(0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Validate each property
|
||||
for (uint256 i = 0; i < order.nftProperties.length; i++) {
|
||||
LibNFTOrder.Property memory property = order.nftProperties[i];
|
||||
// `address(0)` is interpreted as a no-op. Any token ID
|
||||
// will satisfy a property with `propertyValidator == address(0)`.
|
||||
if (address(property.propertyValidator) == address(0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Call the property validator and throw a descriptive error
|
||||
// if the call reverts.
|
||||
try property.propertyValidator.validateProperty(
|
||||
order.nft,
|
||||
tokenId,
|
||||
property.propertyData
|
||||
) {} catch (bytes memory errorData) {
|
||||
LibNFTOrdersRichErrors.PropertyValidationFailedError(
|
||||
address(property.propertyValidator),
|
||||
// Call the property validator and throw a descriptive error
|
||||
// if the call reverts.
|
||||
try property.propertyValidator.validateProperty(
|
||||
order.nft,
|
||||
tokenId,
|
||||
property.propertyData,
|
||||
errorData
|
||||
).rrevert();
|
||||
property.propertyData
|
||||
) {} catch (bytes memory errorData) {
|
||||
LibNFTOrdersRichErrors.PropertyValidationFailedError(
|
||||
address(property.propertyValidator),
|
||||
order.nft,
|
||||
tokenId,
|
||||
property.propertyData,
|
||||
errorData
|
||||
).rrevert();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./LibStorage.sol";
|
||||
@@ -26,12 +26,20 @@ import "./LibStorage.sol";
|
||||
/// @dev Storage helpers for `ERC1155OrdersFeature`.
|
||||
library LibERC1155OrdersStorage {
|
||||
|
||||
struct OrderState {
|
||||
// The amount (denominated in the ERC1155 asset)
|
||||
// that the order has been filled by.
|
||||
uint128 filledAmount;
|
||||
// Whether the order has been pre-signed.
|
||||
bool preSigned;
|
||||
}
|
||||
|
||||
/// @dev Storage bucket for this feature.
|
||||
struct Storage {
|
||||
// The lower `uint128` is the taker token fill amount.
|
||||
// The highest bit will be `1` if the order was cancelled.
|
||||
// The second-highest bit will be `1` if the order was pre-signed.
|
||||
mapping(bytes32 => uint256) orderState;
|
||||
// Mapping from order hash to order state:
|
||||
mapping(bytes32 => OrderState) orderState;
|
||||
// maker => nonce range => order cancellation bit vector
|
||||
mapping(address => mapping(uint248 => uint256)) orderCancellationByMaker;
|
||||
}
|
||||
|
||||
/// @dev Get the storage bucket for this contract.
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./LibStorage.sol";
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
|
@@ -313,7 +313,7 @@ contract FillQuoteTransformer is
|
||||
if (success) {
|
||||
results.makerTokenBoughtAmount = abi.decode(resultData, (uint256));
|
||||
results.takerTokenSoldAmount = takerTokenFillAmount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fill a single limit order.
|
||||
|
@@ -0,0 +1,88 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./IBridgeAdapter.sol";
|
||||
|
||||
abstract contract AbstractBridgeAdapter is IBridgeAdapter {
|
||||
|
||||
constructor(
|
||||
uint256 expectedChainId,
|
||||
string memory expectedChainName
|
||||
)
|
||||
public
|
||||
{
|
||||
uint256 chainId;
|
||||
assembly { chainId := chainid() }
|
||||
// Allow testing on Ganache
|
||||
if (chainId != expectedChainId && chainId != 1337) {
|
||||
revert(string(abi.encodePacked(expectedChainName, "BridgeAdapter.constructor: wrong chain ID")));
|
||||
}
|
||||
}
|
||||
|
||||
function isSupportedSource(bytes32 source)
|
||||
external
|
||||
override
|
||||
returns (bool isSupported)
|
||||
{
|
||||
BridgeOrder memory placeholderOrder;
|
||||
placeholderOrder.source = source;
|
||||
IERC20TokenV06 placeholderToken = IERC20TokenV06(address(0));
|
||||
|
||||
(, isSupported) = _trade(
|
||||
placeholderOrder,
|
||||
placeholderToken,
|
||||
placeholderToken,
|
||||
0,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
function trade(
|
||||
BridgeOrder memory order,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount
|
||||
)
|
||||
public
|
||||
override
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
(boughtAmount, ) = _trade(
|
||||
order,
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
function _trade(
|
||||
BridgeOrder memory order,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bool dryRun
|
||||
)
|
||||
internal
|
||||
virtual
|
||||
returns (uint256 boughtAmount, bool supportedSource);
|
||||
}
|
@@ -0,0 +1,151 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./AbstractBridgeAdapter.sol";
|
||||
import "./BridgeProtocols.sol";
|
||||
import "./mixins/MixinCurve.sol";
|
||||
import "./mixins/MixinCurveV2.sol";
|
||||
import "./mixins/MixinGMX.sol";
|
||||
import "./mixins/MixinKyberDmm.sol";
|
||||
import "./mixins/MixinAaveV2.sol";
|
||||
import "./mixins/MixinNerve.sol";
|
||||
import "./mixins/MixinPlatypus.sol";
|
||||
import "./mixins/MixinUniswapV2.sol";
|
||||
import "./mixins/MixinWOOFi.sol";
|
||||
import "./mixins/MixinZeroExBridge.sol";
|
||||
|
||||
contract AvalancheBridgeAdapter is
|
||||
AbstractBridgeAdapter(43114, "Avalanche"),
|
||||
MixinCurve,
|
||||
MixinCurveV2,
|
||||
MixinGMX,
|
||||
MixinKyberDmm,
|
||||
MixinAaveV2,
|
||||
MixinNerve,
|
||||
MixinPlatypus,
|
||||
MixinUniswapV2,
|
||||
MixinWOOFi,
|
||||
MixinZeroExBridge
|
||||
{
|
||||
constructor(IEtherTokenV06 weth)
|
||||
public
|
||||
MixinCurve(weth)
|
||||
{}
|
||||
|
||||
function _trade(
|
||||
BridgeOrder memory order,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bool dryRun
|
||||
)
|
||||
internal
|
||||
override
|
||||
returns (uint256 boughtAmount, bool supportedSource)
|
||||
{
|
||||
uint128 protocolId = uint128(uint256(order.source) >> 128);
|
||||
if (protocolId == BridgeProtocols.CURVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurve(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.CURVEV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurveV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswapV2(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.NERVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeNerve(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.KYBERDMM) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeKyberDmm(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.AAVEV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeAaveV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.GMX) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeGMX(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.PLATYPUS) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradePlatypus(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.WOOFI) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeWOOFi(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
}
|
||||
|
||||
emit BridgeFill(
|
||||
order.source,
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
boughtAmount
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,142 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./AbstractBridgeAdapter.sol";
|
||||
import "./BridgeProtocols.sol";
|
||||
import "./mixins/MixinCurve.sol";
|
||||
import "./mixins/MixinDodo.sol";
|
||||
import "./mixins/MixinDodoV2.sol";
|
||||
import "./mixins/MixinKyberDmm.sol";
|
||||
import "./mixins/MixinMooniswap.sol";
|
||||
import "./mixins/MixinNerve.sol";
|
||||
import "./mixins/MixinUniswapV2.sol";
|
||||
import "./mixins/MixinWOOFi.sol";
|
||||
import "./mixins/MixinZeroExBridge.sol";
|
||||
|
||||
contract BSCBridgeAdapter is
|
||||
AbstractBridgeAdapter(56, "BSC"),
|
||||
MixinCurve,
|
||||
MixinDodo,
|
||||
MixinDodoV2,
|
||||
MixinKyberDmm,
|
||||
MixinMooniswap,
|
||||
MixinNerve,
|
||||
MixinUniswapV2,
|
||||
MixinWOOFi,
|
||||
MixinZeroExBridge
|
||||
{
|
||||
constructor(IEtherTokenV06 weth)
|
||||
public
|
||||
MixinCurve(weth)
|
||||
MixinMooniswap(weth)
|
||||
{}
|
||||
|
||||
function _trade(
|
||||
BridgeOrder memory order,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bool dryRun
|
||||
)
|
||||
internal
|
||||
override
|
||||
returns (uint256 boughtAmount, bool supportedSource)
|
||||
{
|
||||
uint128 protocolId = uint128(uint256(order.source) >> 128);
|
||||
if (protocolId == BridgeProtocols.CURVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurve(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswapV2(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.MOONISWAP) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeMooniswap(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.DODO) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeDodo(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.DODOV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeDodoV2(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.NERVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeNerve(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.KYBERDMM) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeKyberDmm(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.WOOFI) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeWOOFi(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
}
|
||||
|
||||
emit BridgeFill(
|
||||
order.source,
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
boughtAmount
|
||||
);
|
||||
}
|
||||
}
|
@@ -27,29 +27,36 @@ library BridgeProtocols {
|
||||
// A incrementally increasing, append-only list of protocol IDs.
|
||||
// We don't use an enum so solidity doesn't throw when we pass in a
|
||||
// new protocol ID that hasn't been rolled up yet.
|
||||
uint128 internal constant UNKNOWN = 0;
|
||||
uint128 internal constant CURVE = 1;
|
||||
uint128 internal constant UNISWAPV2 = 2;
|
||||
uint128 internal constant UNISWAP = 3;
|
||||
uint128 internal constant BALANCER = 4;
|
||||
uint128 internal constant KYBER = 5;
|
||||
uint128 internal constant MOONISWAP = 6;
|
||||
uint128 internal constant MSTABLE = 7;
|
||||
uint128 internal constant OASIS = 8;
|
||||
uint128 internal constant SHELL = 9;
|
||||
uint128 internal constant DODO = 10;
|
||||
uint128 internal constant DODOV2 = 11;
|
||||
uint128 internal constant CRYPTOCOM = 12;
|
||||
uint128 internal constant BANCOR = 13;
|
||||
uint128 internal constant COFIX = 14;
|
||||
uint128 internal constant NERVE = 15;
|
||||
uint128 internal constant MAKERPSM = 16;
|
||||
uint128 internal constant BALANCERV2 = 17;
|
||||
uint128 internal constant UNISWAPV3 = 18;
|
||||
uint128 internal constant KYBERDMM = 19;
|
||||
uint128 internal constant CURVEV2 = 20;
|
||||
uint128 internal constant LIDO = 21;
|
||||
uint128 internal constant CLIPPER = 22; // Not used: Clipper is now using PLP interface
|
||||
uint128 internal constant AAVEV2 = 23;
|
||||
uint128 internal constant COMPOUND = 24;
|
||||
uint128 internal constant UNKNOWN = 0;
|
||||
uint128 internal constant CURVE = 1;
|
||||
uint128 internal constant UNISWAPV2 = 2;
|
||||
uint128 internal constant UNISWAP = 3;
|
||||
uint128 internal constant BALANCER = 4;
|
||||
uint128 internal constant KYBER = 5; // Not used: deprecated.
|
||||
uint128 internal constant MOONISWAP = 6;
|
||||
uint128 internal constant MSTABLE = 7;
|
||||
uint128 internal constant OASIS = 8; // Not used: deprecated.
|
||||
uint128 internal constant SHELL = 9;
|
||||
uint128 internal constant DODO = 10;
|
||||
uint128 internal constant DODOV2 = 11;
|
||||
uint128 internal constant CRYPTOCOM = 12;
|
||||
uint128 internal constant BANCOR = 13;
|
||||
uint128 internal constant COFIX = 14; // Not used: deprecated.
|
||||
uint128 internal constant NERVE = 15;
|
||||
uint128 internal constant MAKERPSM = 16;
|
||||
uint128 internal constant BALANCERV2 = 17;
|
||||
uint128 internal constant UNISWAPV3 = 18;
|
||||
uint128 internal constant KYBERDMM = 19;
|
||||
uint128 internal constant CURVEV2 = 20;
|
||||
uint128 internal constant LIDO = 21;
|
||||
uint128 internal constant CLIPPER = 22; // Not used: Clipper is now using PLP interface
|
||||
uint128 internal constant AAVEV2 = 23;
|
||||
uint128 internal constant COMPOUND = 24;
|
||||
uint128 internal constant BALANCERV2BATCH = 25;
|
||||
uint128 internal constant GMX = 26;
|
||||
uint128 internal constant PLATYPUS = 27;
|
||||
uint128 internal constant BANCORV3 = 28;
|
||||
uint128 internal constant VELODROME = 29;
|
||||
uint128 internal constant SYNTHETIX = 30;
|
||||
uint128 internal constant WOOFI = 31;
|
||||
}
|
||||
|
@@ -0,0 +1,84 @@
|
||||
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./AbstractBridgeAdapter.sol";
|
||||
import "./BridgeProtocols.sol";
|
||||
import "./mixins/MixinNerve.sol";
|
||||
import "./mixins/MixinUniswapV2.sol";
|
||||
import "./mixins/MixinZeroExBridge.sol";
|
||||
|
||||
contract CeloBridgeAdapter is
|
||||
AbstractBridgeAdapter(42220, "Celo"),
|
||||
MixinNerve,
|
||||
MixinUniswapV2,
|
||||
MixinZeroExBridge
|
||||
{
|
||||
constructor(address _weth)
|
||||
public
|
||||
{}
|
||||
|
||||
function _trade(
|
||||
BridgeOrder memory order,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bool dryRun
|
||||
)
|
||||
internal
|
||||
override
|
||||
returns (uint256 boughtAmount, bool supportedSource)
|
||||
{
|
||||
uint128 protocolId = uint128(uint256(order.source) >> 128);
|
||||
if (protocolId == BridgeProtocols.UNISWAPV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswapV2(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.NERVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeNerve(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
}
|
||||
|
||||
emit BridgeFill(
|
||||
order.source,
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
boughtAmount
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2021 ZeroEx Intl.
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -20,55 +20,53 @@
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./IBridgeAdapter.sol";
|
||||
import "./AbstractBridgeAdapter.sol";
|
||||
import "./BridgeProtocols.sol";
|
||||
import "./mixins/MixinAaveV2.sol";
|
||||
import "./mixins/MixinBalancer.sol";
|
||||
import "./mixins/MixinBalancerV2.sol";
|
||||
import "./mixins/MixinBalancerV2Batch.sol";
|
||||
import "./mixins/MixinBancor.sol";
|
||||
import "./mixins/MixinCoFiX.sol";
|
||||
import "./mixins/MixinBancorV3.sol";
|
||||
import "./mixins/MixinCompound.sol";
|
||||
import "./mixins/MixinCurve.sol";
|
||||
import "./mixins/MixinCurveV2.sol";
|
||||
import "./mixins/MixinCryptoCom.sol";
|
||||
import "./mixins/MixinDodo.sol";
|
||||
import "./mixins/MixinDodoV2.sol";
|
||||
import "./mixins/MixinKyber.sol";
|
||||
import "./mixins/MixinKyberDmm.sol";
|
||||
import "./mixins/MixinLido.sol";
|
||||
import "./mixins/MixinMakerPSM.sol";
|
||||
import "./mixins/MixinMooniswap.sol";
|
||||
import "./mixins/MixinMStable.sol";
|
||||
import "./mixins/MixinNerve.sol";
|
||||
import "./mixins/MixinOasis.sol";
|
||||
import "./mixins/MixinShell.sol";
|
||||
import "./mixins/MixinSynthetix.sol";
|
||||
import "./mixins/MixinUniswap.sol";
|
||||
import "./mixins/MixinUniswapV2.sol";
|
||||
import "./mixins/MixinUniswapV3.sol";
|
||||
import "./mixins/MixinZeroExBridge.sol";
|
||||
|
||||
contract BridgeAdapter is
|
||||
IBridgeAdapter,
|
||||
contract EthereumBridgeAdapter is
|
||||
AbstractBridgeAdapter(1, "Ethereum"),
|
||||
MixinAaveV2,
|
||||
MixinBalancer,
|
||||
MixinBalancerV2,
|
||||
MixinBalancerV2Batch,
|
||||
MixinBancor,
|
||||
MixinCoFiX,
|
||||
MixinBancorV3,
|
||||
MixinCompound,
|
||||
MixinCurve,
|
||||
MixinCurveV2,
|
||||
MixinCryptoCom,
|
||||
MixinDodo,
|
||||
MixinDodoV2,
|
||||
MixinKyber,
|
||||
MixinKyberDmm,
|
||||
MixinLido,
|
||||
MixinMakerPSM,
|
||||
MixinMooniswap,
|
||||
MixinMStable,
|
||||
MixinNerve,
|
||||
MixinOasis,
|
||||
MixinShell,
|
||||
MixinSynthetix,
|
||||
MixinUniswap,
|
||||
MixinUniswapV2,
|
||||
MixinUniswapV3,
|
||||
@@ -76,43 +74,28 @@ contract BridgeAdapter is
|
||||
{
|
||||
constructor(IEtherTokenV06 weth)
|
||||
public
|
||||
MixinAaveV2()
|
||||
MixinBalancer()
|
||||
MixinBalancerV2()
|
||||
MixinBancor(weth)
|
||||
MixinCoFiX()
|
||||
MixinBancorV3(weth)
|
||||
MixinCompound(weth)
|
||||
MixinCurve(weth)
|
||||
MixinCurveV2()
|
||||
MixinCryptoCom()
|
||||
MixinDodo()
|
||||
MixinDodoV2()
|
||||
MixinKyber(weth)
|
||||
MixinLido(weth)
|
||||
MixinMakerPSM()
|
||||
MixinMooniswap(weth)
|
||||
MixinMStable()
|
||||
MixinNerve()
|
||||
MixinOasis()
|
||||
MixinShell()
|
||||
MixinUniswap(weth)
|
||||
MixinUniswapV2()
|
||||
MixinUniswapV3()
|
||||
MixinZeroExBridge()
|
||||
{}
|
||||
|
||||
function trade(
|
||||
function _trade(
|
||||
BridgeOrder memory order,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount
|
||||
uint256 sellAmount,
|
||||
bool dryRun
|
||||
)
|
||||
public
|
||||
internal
|
||||
override
|
||||
returns (uint256 boughtAmount)
|
||||
returns (uint256 boughtAmount, bool supportedSource)
|
||||
{
|
||||
uint128 protocolId = uint128(uint256(order.source) >> 128);
|
||||
if (protocolId == BridgeProtocols.CURVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurve(
|
||||
sellToken,
|
||||
buyToken,
|
||||
@@ -120,6 +103,7 @@ contract BridgeAdapter is
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.CURVEV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurveV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
@@ -127,18 +111,21 @@ contract BridgeAdapter is
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNISWAPV3) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswapV3(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswapV2(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNISWAP) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswap(
|
||||
sellToken,
|
||||
buyToken,
|
||||
@@ -146,6 +133,7 @@ contract BridgeAdapter is
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.BALANCER) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeBalancer(
|
||||
sellToken,
|
||||
buyToken,
|
||||
@@ -153,48 +141,37 @@ contract BridgeAdapter is
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.BALANCERV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeBalancerV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.KYBER) {
|
||||
boughtAmount = _tradeKyber(
|
||||
sellToken,
|
||||
buyToken,
|
||||
} else if (protocolId == BridgeProtocols.BALANCERV2BATCH) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeBalancerV2Batch(
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.MAKERPSM) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeMakerPsm(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.MOONISWAP) {
|
||||
boughtAmount = _tradeMooniswap(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.MSTABLE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeMStable(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.OASIS) {
|
||||
boughtAmount = _tradeOasis(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.SHELL) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeShell(
|
||||
sellToken,
|
||||
buyToken,
|
||||
@@ -202,49 +179,49 @@ contract BridgeAdapter is
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.DODO) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeDodo(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.DODOV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeDodoV2(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.CRYPTOCOM) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCryptoCom(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.BANCOR) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeBancor(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.COFIX) {
|
||||
boughtAmount = _tradeCoFiX(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.NERVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeNerve(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.KYBERDMM) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeKyberDmm(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.LIDO) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeLido(
|
||||
sellToken,
|
||||
buyToken,
|
||||
@@ -252,6 +229,7 @@ contract BridgeAdapter is
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.AAVEV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeAaveV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
@@ -259,13 +237,28 @@ contract BridgeAdapter is
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.COMPOUND) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCompound(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else {
|
||||
} else if (protocolId == BridgeProtocols.BANCORV3) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeBancorV3(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.SYNTHETIX) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeSynthetix(
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
buyToken,
|
@@ -0,0 +1,134 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./AbstractBridgeAdapter.sol";
|
||||
import "./BridgeProtocols.sol";
|
||||
import "./mixins/MixinAaveV2.sol";
|
||||
import "./mixins/MixinBalancerV2.sol";
|
||||
import "./mixins/MixinCurve.sol";
|
||||
import "./mixins/MixinCurveV2.sol";
|
||||
import "./mixins/MixinNerve.sol";
|
||||
import "./mixins/MixinUniswapV2.sol";
|
||||
import "./mixins/MixinWOOFi.sol";
|
||||
import "./mixins/MixinZeroExBridge.sol";
|
||||
|
||||
contract FantomBridgeAdapter is
|
||||
AbstractBridgeAdapter(250, "Fantom"),
|
||||
MixinAaveV2,
|
||||
MixinBalancerV2,
|
||||
MixinCurve,
|
||||
MixinCurveV2,
|
||||
MixinNerve,
|
||||
MixinUniswapV2,
|
||||
MixinWOOFi,
|
||||
MixinZeroExBridge
|
||||
{
|
||||
constructor(IEtherTokenV06 weth)
|
||||
public
|
||||
MixinCurve(weth)
|
||||
{}
|
||||
|
||||
function _trade(
|
||||
BridgeOrder memory order,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bool dryRun
|
||||
)
|
||||
internal
|
||||
override
|
||||
returns (uint256 boughtAmount, bool supportedSource)
|
||||
{
|
||||
uint128 protocolId = uint128(uint256(order.source) >> 128);
|
||||
if (protocolId == BridgeProtocols.CURVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurve(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.CURVEV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurveV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswapV2(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.BALANCERV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeBalancerV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.NERVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeNerve(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.AAVEV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeAaveV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.WOOFI) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeWOOFi(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
}
|
||||
|
||||
emit BridgeFill(
|
||||
order.source,
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
boughtAmount
|
||||
);
|
||||
}
|
||||
}
|
@@ -50,6 +50,10 @@ interface IBridgeAdapter {
|
||||
uint256 outputTokenAmount
|
||||
);
|
||||
|
||||
function isSupportedSource(bytes32 source)
|
||||
external
|
||||
returns (bool isSupported);
|
||||
|
||||
function trade(
|
||||
BridgeOrder calldata order,
|
||||
IERC20TokenV06 sellToken,
|
||||
|
@@ -0,0 +1,122 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./AbstractBridgeAdapter.sol";
|
||||
import "./BridgeProtocols.sol";
|
||||
import "./mixins/MixinCurve.sol";
|
||||
import "./mixins/MixinCurveV2.sol";
|
||||
import "./mixins/MixinNerve.sol";
|
||||
import "./mixins/MixinSynthetix.sol";
|
||||
import "./mixins/MixinUniswapV3.sol";
|
||||
import "./mixins/MixinVelodrome.sol";
|
||||
import "./mixins/MixinZeroExBridge.sol";
|
||||
|
||||
contract OptimismBridgeAdapter is
|
||||
AbstractBridgeAdapter(10, "Optimism"),
|
||||
MixinCurve,
|
||||
MixinCurveV2,
|
||||
MixinNerve,
|
||||
MixinSynthetix,
|
||||
MixinUniswapV3,
|
||||
MixinVelodrome,
|
||||
MixinZeroExBridge
|
||||
{
|
||||
constructor(IEtherTokenV06 weth)
|
||||
public
|
||||
MixinCurve(weth)
|
||||
{}
|
||||
|
||||
function _trade(
|
||||
BridgeOrder memory order,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bool dryRun
|
||||
)
|
||||
internal
|
||||
override
|
||||
returns (uint256 boughtAmount, bool supportedSource)
|
||||
{
|
||||
uint128 protocolId = uint128(uint256(order.source) >> 128);
|
||||
if (protocolId == BridgeProtocols.CURVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurve(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.CURVEV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurveV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNISWAPV3) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswapV3(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.NERVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeNerve(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.VELODROME) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeVelodrome(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.SYNTHETIX) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeSynthetix(
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
}
|
||||
|
||||
emit BridgeFill(
|
||||
order.source,
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
boughtAmount
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,188 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./AbstractBridgeAdapter.sol";
|
||||
import "./BridgeProtocols.sol";
|
||||
import "./mixins/MixinAaveV2.sol";
|
||||
import "./mixins/MixinBalancerV2.sol";
|
||||
import "./mixins/MixinBalancerV2Batch.sol";
|
||||
import "./mixins/MixinCurve.sol";
|
||||
import "./mixins/MixinCurveV2.sol";
|
||||
import "./mixins/MixinDodo.sol";
|
||||
import "./mixins/MixinDodoV2.sol";
|
||||
import "./mixins/MixinKyberDmm.sol";
|
||||
import "./mixins/MixinMStable.sol";
|
||||
import "./mixins/MixinNerve.sol";
|
||||
import "./mixins/MixinUniswapV2.sol";
|
||||
import "./mixins/MixinUniswapV3.sol";
|
||||
import "./mixins/MixinWOOFi.sol";
|
||||
import "./mixins/MixinZeroExBridge.sol";
|
||||
|
||||
contract PolygonBridgeAdapter is
|
||||
AbstractBridgeAdapter(137, "Polygon"),
|
||||
MixinAaveV2,
|
||||
MixinBalancerV2,
|
||||
MixinBalancerV2Batch,
|
||||
MixinCurve,
|
||||
MixinCurveV2,
|
||||
MixinDodo,
|
||||
MixinDodoV2,
|
||||
MixinKyberDmm,
|
||||
MixinMStable,
|
||||
MixinNerve,
|
||||
MixinUniswapV2,
|
||||
MixinUniswapV3,
|
||||
MixinWOOFi,
|
||||
MixinZeroExBridge
|
||||
{
|
||||
constructor(IEtherTokenV06 weth)
|
||||
public
|
||||
MixinCurve(weth)
|
||||
{}
|
||||
|
||||
function _trade(
|
||||
BridgeOrder memory order,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bool dryRun
|
||||
)
|
||||
internal
|
||||
override
|
||||
returns (uint256 boughtAmount, bool supportedSource)
|
||||
{
|
||||
uint128 protocolId = uint128(uint256(order.source) >> 128);
|
||||
if (protocolId == BridgeProtocols.CURVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurve(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.CURVEV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeCurveV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNISWAPV3) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswapV3(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNISWAPV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeUniswapV2(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.BALANCERV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeBalancerV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.BALANCERV2BATCH) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeBalancerV2Batch(
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.MSTABLE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeMStable(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.DODO) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeDodo(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.DODOV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeDodoV2(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.NERVE) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeNerve(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.KYBERDMM) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeKyberDmm(
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.AAVEV2) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeAaveV2(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.WOOFI) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeWOOFi(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.UNKNOWN) {
|
||||
if (dryRun) { return (0, true); }
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
}
|
||||
|
||||
emit BridgeFill(
|
||||
order.source,
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
boughtAmount
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,107 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
|
||||
|
||||
interface IBalancerV2BatchSwapVault {
|
||||
|
||||
enum SwapKind { GIVEN_IN, GIVEN_OUT }
|
||||
|
||||
struct BatchSwapStep {
|
||||
bytes32 poolId;
|
||||
uint256 assetInIndex;
|
||||
uint256 assetOutIndex;
|
||||
uint256 amount;
|
||||
bytes userData;
|
||||
}
|
||||
|
||||
struct FundManagement {
|
||||
address sender;
|
||||
bool fromInternalBalance;
|
||||
address payable recipient;
|
||||
bool toInternalBalance;
|
||||
}
|
||||
|
||||
function batchSwap(
|
||||
SwapKind kind,
|
||||
BatchSwapStep[] calldata swaps,
|
||||
IERC20TokenV06[] calldata assets,
|
||||
FundManagement calldata funds,
|
||||
int256[] calldata limits,
|
||||
uint256 deadline
|
||||
) external returns (int256[] memory amounts);
|
||||
}
|
||||
|
||||
contract MixinBalancerV2Batch {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
|
||||
struct BalancerV2BatchBridgeData {
|
||||
IBalancerV2BatchSwapVault vault;
|
||||
IBalancerV2BatchSwapVault.BatchSwapStep[] swapSteps;
|
||||
IERC20TokenV06[] assets;
|
||||
}
|
||||
|
||||
function _tradeBalancerV2Batch(
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
internal
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
// Decode the bridge data.
|
||||
(
|
||||
IBalancerV2BatchSwapVault vault,
|
||||
IBalancerV2BatchSwapVault.BatchSwapStep[] memory swapSteps,
|
||||
address[] memory assets_
|
||||
) = abi.decode(bridgeData, (IBalancerV2BatchSwapVault, IBalancerV2BatchSwapVault.BatchSwapStep[], address[]));
|
||||
IERC20TokenV06[] memory assets;
|
||||
assembly { assets := assets_ }
|
||||
|
||||
// Grant an allowance to the exchange to spend `fromTokenAddress` token.
|
||||
assets[0].approveIfBelow(address(vault), sellAmount);
|
||||
|
||||
swapSteps[0].amount = sellAmount;
|
||||
int256[] memory limits = new int256[](assets.length);
|
||||
for (uint256 i = 0; i < limits.length; ++i) {
|
||||
limits[i] = type(int256).max;
|
||||
}
|
||||
|
||||
int256[] memory amounts = vault.batchSwap(
|
||||
IBalancerV2BatchSwapVault.SwapKind.GIVEN_IN,
|
||||
swapSteps,
|
||||
assets,
|
||||
IBalancerV2BatchSwapVault.FundManagement({
|
||||
sender: address(this),
|
||||
fromInternalBalance: false,
|
||||
recipient: payable(address(this)),
|
||||
toInternalBalance: false
|
||||
}),
|
||||
limits,
|
||||
block.timestamp + 1
|
||||
);
|
||||
require(amounts[amounts.length - 1] <= 0, 'Unexpected BalancerV2Batch output');
|
||||
return uint256(amounts[amounts.length - 1] * -1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,128 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
|
||||
|
||||
/*
|
||||
BancorV3
|
||||
*/
|
||||
interface IBancorV3 {
|
||||
/**
|
||||
* @dev performs a trade by providing the source amount and returns the target amount and the associated fee
|
||||
*
|
||||
* requirements:
|
||||
*
|
||||
* - the caller must be the network contract
|
||||
*/
|
||||
function tradeBySourceAmount(
|
||||
address sourceToken,
|
||||
address targetToken,
|
||||
uint256 sourceAmount,
|
||||
uint256 minReturnAmount,
|
||||
uint256 deadline,
|
||||
address beneficiary
|
||||
) external payable returns (uint256 amount);
|
||||
}
|
||||
|
||||
contract MixinBancorV3 {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
|
||||
IERC20TokenV06 constant public BANCORV3_ETH_ADDRESS =
|
||||
IERC20TokenV06(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
|
||||
IEtherTokenV06 private immutable WETH;
|
||||
|
||||
constructor(IEtherTokenV06 weth)
|
||||
public
|
||||
{
|
||||
WETH = weth;
|
||||
}
|
||||
|
||||
function _tradeBancorV3(
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
internal
|
||||
returns (uint256 amountOut)
|
||||
|
||||
{
|
||||
IBancorV3 router;
|
||||
IERC20TokenV06[] memory path;
|
||||
address[] memory _path;
|
||||
uint256 payableAmount = 0;
|
||||
|
||||
{
|
||||
(router, _path) = abi.decode(bridgeData, (IBancorV3, address[]));
|
||||
// To get around `abi.decode()` not supporting interface array types.
|
||||
assembly { path := _path }
|
||||
}
|
||||
|
||||
require(path.length >= 2, "MixinBancorV3/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
|
||||
require(
|
||||
path[path.length - 1] == buyToken,
|
||||
"MixinBancorV3/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
|
||||
);
|
||||
|
||||
//swap WETH->ETH as Bancor only deals in ETH
|
||||
if(_path[0] == address(WETH)) {
|
||||
//withdraw the sell amount of WETH for ETH
|
||||
WETH.withdraw(sellAmount);
|
||||
payableAmount = sellAmount;
|
||||
// set _path[0] to the ETH address if WETH is our buy token
|
||||
_path[0] = address(BANCORV3_ETH_ADDRESS);
|
||||
} else {
|
||||
// Grant the BancorV3 router an allowance to sell the first token.
|
||||
path[0].approveIfBelow(address(router), sellAmount);
|
||||
}
|
||||
|
||||
// if we are buying WETH we need to swap to ETH and deposit into WETH after the swap
|
||||
if(_path[1] == address(WETH)){
|
||||
_path[1] = address(BANCORV3_ETH_ADDRESS);
|
||||
}
|
||||
|
||||
|
||||
uint256 amountOut = router.tradeBySourceAmount{value: payableAmount}(
|
||||
_path[0],
|
||||
_path[1],
|
||||
// Sell all tokens we hold.
|
||||
sellAmount,
|
||||
// Minimum buy amount.
|
||||
1,
|
||||
//deadline
|
||||
block.timestamp + 1,
|
||||
// address of the mixin
|
||||
address(this)
|
||||
);
|
||||
|
||||
// if we want to return WETH deposit the ETH amount we sold
|
||||
if(buyToken == WETH){
|
||||
WETH.deposit{value: amountOut}();
|
||||
}
|
||||
|
||||
return amountOut;
|
||||
}
|
||||
}
|
@@ -1,92 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
|
||||
|
||||
interface ICoFiXRouter {
|
||||
// msg.value = fee
|
||||
function swapExactTokensForETH(
|
||||
address token,
|
||||
uint amountIn,
|
||||
uint amountOutMin,
|
||||
address to,
|
||||
address rewardTo,
|
||||
uint deadline
|
||||
) external payable returns (uint _amountIn, uint _amountOut);
|
||||
|
||||
// msg.value = amountIn + fee
|
||||
function swapExactETHForTokens(
|
||||
address token,
|
||||
uint amountIn,
|
||||
uint amountOutMin,
|
||||
address to,
|
||||
address rewardTo,
|
||||
uint deadline
|
||||
) external payable returns (uint _amountIn, uint _amountOut);
|
||||
}
|
||||
|
||||
interface ICoFiXPair {
|
||||
|
||||
function swapWithExact(address outToken, address to)
|
||||
external
|
||||
payable
|
||||
returns (
|
||||
uint amountIn,
|
||||
uint amountOut,
|
||||
uint oracleFeeChange,
|
||||
uint256[4] memory tradeInfo
|
||||
);
|
||||
}
|
||||
|
||||
contract MixinCoFiX {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
|
||||
function _tradeCoFiX(
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
internal
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
(uint256 fee, ICoFiXPair pool) = abi.decode(bridgeData, (uint256, ICoFiXPair));
|
||||
// Transfer tokens into the pool
|
||||
LibERC20TokenV06.compatTransfer(
|
||||
sellToken,
|
||||
address(pool),
|
||||
sellAmount
|
||||
);
|
||||
// Call the swap exact with the tokens now in the pool
|
||||
// pay the NEST Oracle fee with ETH
|
||||
(/* In */, boughtAmount, , ) = pool.swapWithExact{value: fee}(
|
||||
address(buyToken),
|
||||
address(this)
|
||||
);
|
||||
|
||||
return boughtAmount;
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
|
||||
import "../IBridgeAdapter.sol";
|
||||
|
||||
/*
|
||||
UniswapV2
|
||||
*/
|
||||
interface IGmxRouter {
|
||||
|
||||
// /// @dev Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path.
|
||||
// /// The first element of path is the input token, the last is the output token, and any intermediate elements represent
|
||||
// /// intermediate pairs to trade through (if, for example, a direct pair does not exist).
|
||||
// /// @param _path An array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
|
||||
// /// @param _amountIn The amount of input tokens to send.
|
||||
// /// @param _minOut The minimum amount of output tokens that must be received for the transaction not to revert.
|
||||
// /// @param _reciever Recipient of the output tokens.
|
||||
function swap(
|
||||
address[] calldata _path, uint256 _amountIn, uint256 _minOut, address _receiver
|
||||
) external;
|
||||
}
|
||||
|
||||
contract MixinGMX {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
using LibSafeMathV06 for uint256;
|
||||
|
||||
function _tradeGMX(
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
public
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
address _router;
|
||||
address reader;
|
||||
address vault;
|
||||
address[] memory _path;
|
||||
IGmxRouter router;
|
||||
IERC20TokenV06[] memory path;
|
||||
|
||||
{
|
||||
//decode the bridge data
|
||||
(_router, reader, vault, _path) = abi.decode(bridgeData, (address, address, address, address[]));
|
||||
// To get around `abi.decode()` not supporting interface array types.
|
||||
assembly { path := _path }
|
||||
}
|
||||
|
||||
require(path.length >= 2, "MixinGMX/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
|
||||
require(
|
||||
path[path.length - 1] == buyToken,
|
||||
"MixinGMX/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
|
||||
);
|
||||
|
||||
//connect to the GMX router
|
||||
router = IGmxRouter(_router);
|
||||
|
||||
// Grant the GMX router an allowance to sell the first token.
|
||||
path[0].approveIfBelow(address(router), sellAmount);
|
||||
|
||||
//track the balance to know how much we bought
|
||||
uint256 beforeBalance = buyToken.balanceOf(address(this));
|
||||
router.swap(
|
||||
// Convert to `buyToken` along this path.
|
||||
_path,
|
||||
// Sell all tokens we hold.
|
||||
sellAmount,
|
||||
// Minimum buy amount.
|
||||
0,
|
||||
// Recipient is `this`.
|
||||
address(this)
|
||||
);
|
||||
|
||||
//calculate the difference in balance from preswap->postswap to find how many tokens out
|
||||
boughtAmount = buyToken.balanceOf(address(this)).safeSub(beforeBalance);
|
||||
|
||||
return boughtAmount;
|
||||
}
|
||||
}
|
@@ -1,124 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
import "../IBridgeAdapter.sol";
|
||||
|
||||
interface IKyberNetworkProxy {
|
||||
|
||||
/// @dev Sells `sellTokenAddress` tokens for `buyTokenAddress` tokens
|
||||
/// using a hint for the reserve.
|
||||
/// @param sellToken Token to sell.
|
||||
/// @param sellAmount Amount of tokens to sell.
|
||||
/// @param buyToken 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(
|
||||
IERC20TokenV06 sellToken,
|
||||
uint256 sellAmount,
|
||||
IERC20TokenV06 buyToken,
|
||||
address payable recipientAddress,
|
||||
uint256 maxBuyTokenAmount,
|
||||
uint256 minConversionRate,
|
||||
address payable walletId,
|
||||
bytes calldata hint
|
||||
)
|
||||
external
|
||||
payable
|
||||
returns (uint256 boughtAmount);
|
||||
}
|
||||
|
||||
contract MixinKyber {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
|
||||
/// @dev Address indicating the trade is using ETH
|
||||
IERC20TokenV06 private immutable KYBER_ETH_ADDRESS =
|
||||
IERC20TokenV06(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
|
||||
/// @dev Mainnet address of the WETH contract.
|
||||
IEtherTokenV06 private immutable WETH;
|
||||
|
||||
constructor(IEtherTokenV06 weth)
|
||||
public
|
||||
{
|
||||
WETH = weth;
|
||||
}
|
||||
|
||||
function _tradeKyber(
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
internal
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
(IKyberNetworkProxy kyber, bytes memory hint) =
|
||||
abi.decode(bridgeData, (IKyberNetworkProxy, bytes));
|
||||
|
||||
uint256 payableAmount = 0;
|
||||
if (sellToken != WETH) {
|
||||
// If the input token is not WETH, grant an allowance to the exchange
|
||||
// to spend them.
|
||||
sellToken.approveIfBelow(
|
||||
address(kyber),
|
||||
sellAmount
|
||||
);
|
||||
} else {
|
||||
// If the input token is WETH, unwrap it and attach it to the call.
|
||||
payableAmount = sellAmount;
|
||||
WETH.withdraw(payableAmount);
|
||||
}
|
||||
|
||||
// Try to sell all of this contract's input token balance through
|
||||
// `KyberNetworkProxy.trade()`.
|
||||
boughtAmount = kyber.tradeWithHint{ value: payableAmount }(
|
||||
// Input token.
|
||||
sellToken == WETH ? KYBER_ETH_ADDRESS : sellToken,
|
||||
// Sell amount.
|
||||
sellAmount,
|
||||
// Output token.
|
||||
buyToken == WETH ? KYBER_ETH_ADDRESS : buyToken,
|
||||
// Transfer to this contract
|
||||
address(uint160(address(this))),
|
||||
// Buy as much as possible.
|
||||
uint256(-1),
|
||||
// Lowest minimum conversion rate
|
||||
1,
|
||||
// No affiliate address.
|
||||
address(0),
|
||||
hint
|
||||
);
|
||||
// If receving ETH, wrap it to WETH.
|
||||
if (buyToken == WETH) {
|
||||
WETH.deposit{ value: boughtAmount }();
|
||||
}
|
||||
return boughtAmount;
|
||||
}
|
||||
}
|
@@ -26,7 +26,7 @@ import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
|
||||
|
||||
/// @dev Minimal interface for minting StETH
|
||||
interface ILido {
|
||||
interface IStETH {
|
||||
/// @dev Adds eth to the pool
|
||||
/// @param _referral optional address for referrals
|
||||
/// @return StETH Amount of shares generated
|
||||
@@ -37,6 +37,33 @@ interface ILido {
|
||||
function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);
|
||||
}
|
||||
|
||||
/// @dev Minimal interface for wrapping/unwrapping stETH.
|
||||
interface IWstETH {
|
||||
|
||||
/**
|
||||
* @notice Exchanges stETH to wstETH
|
||||
* @param _stETHAmount amount of stETH to wrap in exchange for wstETH
|
||||
* @dev Requirements:
|
||||
* - `_stETHAmount` must be non-zero
|
||||
* - msg.sender must approve at least `_stETHAmount` stETH to this
|
||||
* contract.
|
||||
* - msg.sender must have at least `_stETHAmount` of stETH.
|
||||
* User should first approve _stETHAmount to the WstETH contract
|
||||
* @return Amount of wstETH user receives after wrap
|
||||
*/
|
||||
function wrap(uint256 _stETHAmount) external returns (uint256);
|
||||
|
||||
/**
|
||||
* @notice Exchanges wstETH to stETH
|
||||
* @param _wstETHAmount amount of wstETH to uwrap in exchange for stETH
|
||||
* @dev Requirements:
|
||||
* - `_wstETHAmount` must be non-zero
|
||||
* - msg.sender must have at least `_wstETHAmount` wstETH.
|
||||
* @return Amount of stETH user receives after unwrap
|
||||
*/
|
||||
function unwrap(uint256 _wstETHAmount) external returns (uint256);
|
||||
}
|
||||
|
||||
|
||||
contract MixinLido {
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
@@ -59,12 +86,43 @@ contract MixinLido {
|
||||
internal
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
(ILido lido) = abi.decode(bridgeData, (ILido));
|
||||
if (address(sellToken) == address(WETH) && address(buyToken) == address(lido)) {
|
||||
if (address(sellToken) == address(WETH)) {
|
||||
return _tradeStETH(buyToken, sellAmount, bridgeData);
|
||||
}
|
||||
|
||||
return _tradeWstETH(sellToken, buyToken, sellAmount, bridgeData);
|
||||
}
|
||||
|
||||
function _tradeStETH(
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
) private returns (uint256 boughtAmount) {
|
||||
(IStETH stETH) = abi.decode(bridgeData, (IStETH));
|
||||
if (address(buyToken) == address(stETH)) {
|
||||
WETH.withdraw(sellAmount);
|
||||
boughtAmount = lido.getPooledEthByShares(lido.submit{ value: sellAmount}(address(0)));
|
||||
} else {
|
||||
revert("MixinLido/UNSUPPORTED_TOKEN_PAIR");
|
||||
return stETH.getPooledEthByShares(stETH.submit{ value: sellAmount}(address(0)));
|
||||
}
|
||||
|
||||
revert("MixinLido/UNSUPPORTED_TOKEN_PAIR");
|
||||
}
|
||||
|
||||
function _tradeWstETH(
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
|
||||
) private returns(uint256 boughtAmount){
|
||||
(IEtherTokenV06 stETH, IWstETH wstETH) = abi.decode(bridgeData, (IEtherTokenV06, IWstETH));
|
||||
if (address(sellToken) == address(stETH) && address(buyToken) == address(wstETH) ) {
|
||||
sellToken.approveIfBelow(address(wstETH), sellAmount);
|
||||
return wstETH.wrap(sellAmount);
|
||||
}
|
||||
if (address(sellToken) == address(wstETH) && address(buyToken) == address(stETH) ) {
|
||||
return wstETH.unwrap(sellAmount);
|
||||
}
|
||||
|
||||
revert("MixinLido/UNSUPPORTED_TOKEN_PAIR");
|
||||
}
|
||||
}
|
||||
|
@@ -1,76 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "../IBridgeAdapter.sol";
|
||||
|
||||
interface IOasis {
|
||||
|
||||
/// @dev Sell `sellAmount` of `sellToken` token and receive `buyToken` token.
|
||||
/// @param sellToken The token being sold.
|
||||
/// @param sellAmount The amount of `sellToken` token being sold.
|
||||
/// @param buyToken The token being bought.
|
||||
/// @param minBoughtAmount Minimum amount of `buyToken` token to buy.
|
||||
/// @return boughtAmount Amount of `buyToken` bought.
|
||||
function sellAllAmount(
|
||||
IERC20TokenV06 sellToken,
|
||||
uint256 sellAmount,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 minBoughtAmount
|
||||
)
|
||||
external
|
||||
returns (uint256 boughtAmount);
|
||||
}
|
||||
|
||||
contract MixinOasis {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
|
||||
function _tradeOasis(
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
internal
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
|
||||
(IOasis oasis) = abi.decode(bridgeData, (IOasis));
|
||||
|
||||
// Grant an allowance to the exchange to spend `sellToken` token.
|
||||
sellToken.approveIfBelow(
|
||||
address(oasis),
|
||||
sellAmount
|
||||
);
|
||||
// Try to sell all of this contract's `sellToken` token balance.
|
||||
boughtAmount = oasis.sellAllAmount(
|
||||
sellToken,
|
||||
sellAmount,
|
||||
buyToken,
|
||||
// min fill amount
|
||||
1
|
||||
);
|
||||
return boughtAmount;
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
|
||||
|
||||
|
||||
interface IPlatypusRouter {
|
||||
|
||||
function swapTokensForTokens(
|
||||
address[] calldata tokenPath,
|
||||
address[] calldata poolPath,
|
||||
uint256 fromAmount,
|
||||
uint256 minimumToAmount,
|
||||
address to,
|
||||
uint256 deadline
|
||||
) external returns (uint256 amountOut, uint256 haircut);
|
||||
}
|
||||
|
||||
contract MixinPlatypus {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
using LibSafeMathV06 for uint256;
|
||||
|
||||
function _tradePlatypus(
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
public
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
IPlatypusRouter router;
|
||||
address _router;
|
||||
address[] memory _pool;
|
||||
IERC20TokenV06[] memory path;
|
||||
address[] memory _path;
|
||||
|
||||
{
|
||||
(_router, _pool, _path) = abi.decode(bridgeData, (address, address[], address[]));
|
||||
|
||||
// To get around `abi.decode()` not supporting interface array types.
|
||||
assembly { path := _path }
|
||||
}
|
||||
|
||||
//connect to the ptp router
|
||||
router = IPlatypusRouter(_router);
|
||||
|
||||
require(path.length >= 2, "MixinPlatypus/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
|
||||
require(
|
||||
path[path.length - 1] == buyToken,
|
||||
"MixinPlatypus/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
|
||||
);
|
||||
// Grant the Platypus router an allowance to sell the first token.
|
||||
path[0].approveIfBelow(address(router), sellAmount);
|
||||
|
||||
//keep track of the previous balance to confirm amount out
|
||||
uint256 beforeBalance = buyToken.balanceOf(address(this));
|
||||
|
||||
router.swapTokensForTokens(
|
||||
// Convert to `buyToken` along this path.
|
||||
_path,
|
||||
// pool to swap on
|
||||
_pool,
|
||||
// Sell all tokens we hold.
|
||||
sellAmount,
|
||||
// Minimum buy amount.
|
||||
0,
|
||||
// Recipient is `this`.
|
||||
address(this),
|
||||
|
||||
block.timestamp + 1
|
||||
);
|
||||
//calculate the buy amount from the tokens we recieved
|
||||
boughtAmount = buyToken.balanceOf(address(this)).safeSub(beforeBalance);
|
||||
return boughtAmount;
|
||||
}
|
||||
}
|
@@ -0,0 +1,99 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
interface ISynthetix {
|
||||
// Ethereum Mainnet
|
||||
function exchangeAtomically(
|
||||
bytes32 sourceCurrencyKey,
|
||||
uint256 sourceAmount,
|
||||
bytes32 destinationCurrencyKey,
|
||||
bytes32 trackingCode,
|
||||
uint256 minAmount
|
||||
) external returns (uint256 amountReceived);
|
||||
|
||||
// Optimism
|
||||
function exchangeWithTracking(
|
||||
bytes32 sourceCurrencyKey,
|
||||
uint256 sourceAmount,
|
||||
bytes32 destinationCurrencyKey,
|
||||
address rewardAddress,
|
||||
bytes32 trackingCode
|
||||
) external returns (uint256 amountReceived);
|
||||
}
|
||||
|
||||
contract MixinSynthetix {
|
||||
address private constant rewardAddress =
|
||||
0x5C80239D97E1eB216b5c3D8fBa5DE5Be5d38e4C9;
|
||||
bytes32 constant trackingCode =
|
||||
0x3058000000000000000000000000000000000000000000000000000000000000;
|
||||
|
||||
function _tradeSynthetix(uint256 sellAmount, bytes memory bridgeData)
|
||||
public
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
(
|
||||
ISynthetix synthetix,
|
||||
bytes32 sourceCurrencyKey,
|
||||
bytes32 destinationCurrencyKey
|
||||
) = abi.decode(
|
||||
bridgeData,
|
||||
(ISynthetix, bytes32, bytes32)
|
||||
);
|
||||
|
||||
boughtAmount = exchange(
|
||||
synthetix,
|
||||
sourceCurrencyKey,
|
||||
destinationCurrencyKey,
|
||||
sellAmount
|
||||
);
|
||||
}
|
||||
|
||||
function exchange(
|
||||
ISynthetix synthetix,
|
||||
bytes32 sourceCurrencyKey,
|
||||
bytes32 destinationCurrencyKey,
|
||||
uint256 sellAmount
|
||||
) internal returns (uint256 boughtAmount) {
|
||||
uint256 chainId;
|
||||
assembly {
|
||||
chainId := chainid()
|
||||
}
|
||||
|
||||
if (chainId == 1) {
|
||||
boughtAmount = synthetix.exchangeAtomically(
|
||||
sourceCurrencyKey,
|
||||
sellAmount,
|
||||
destinationCurrencyKey,
|
||||
trackingCode,
|
||||
0
|
||||
);
|
||||
} else {
|
||||
boughtAmount = synthetix.exchangeWithTracking(
|
||||
sourceCurrencyKey,
|
||||
sellAmount,
|
||||
destinationCurrencyKey,
|
||||
rewardAddress,
|
||||
trackingCode
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
|
||||
interface IVelodromeRouter {
|
||||
function swapExactTokensForTokensSimple(
|
||||
uint256 amountIn,
|
||||
uint256 amountOutMin,
|
||||
address tokenFrom,
|
||||
address tokenTo,
|
||||
bool stable,
|
||||
address to,
|
||||
uint256 deadline
|
||||
) external returns (uint256[] memory amounts);
|
||||
}
|
||||
|
||||
contract MixinVelodrome {
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
|
||||
function _tradeVelodrome(
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
internal
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
|
||||
(IVelodromeRouter router, bool stable) = abi.decode(bridgeData, (IVelodromeRouter, bool));
|
||||
sellToken.approveIfBelow(address(router), sellAmount);
|
||||
|
||||
boughtAmount = router.swapExactTokensForTokensSimple(
|
||||
sellAmount,
|
||||
0,
|
||||
address(sellToken),
|
||||
address(buyToken),
|
||||
stable,
|
||||
address(this),
|
||||
block.timestamp + 1
|
||||
)[1];
|
||||
}
|
||||
}
|
@@ -0,0 +1,136 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
import "../IBridgeAdapter.sol";
|
||||
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
|
||||
|
||||
/// @dev WooFI pool interface.
|
||||
interface IWooPP {
|
||||
function quoteToken() external view returns (address);
|
||||
|
||||
function sellBase(
|
||||
address baseToken,
|
||||
uint256 baseAmount,
|
||||
uint256 minQuoteAmount,
|
||||
address to,
|
||||
address rebateTo
|
||||
) external returns (uint256 quoteAmount);
|
||||
|
||||
function sellQuote(
|
||||
address baseToken,
|
||||
uint256 quoteAmount,
|
||||
uint256 minBaseAmount,
|
||||
address to,
|
||||
address rebateTo
|
||||
) external returns (uint256 baseAmount);
|
||||
|
||||
/// @dev Query the amount for selling the base token amount.
|
||||
/// @param baseToken the base token to sell
|
||||
/// @param baseAmount the amount to sell
|
||||
/// @return quoteAmount the swapped quote amount
|
||||
function querySellBase(
|
||||
address baseToken,
|
||||
uint256 baseAmount
|
||||
) external view returns (uint256 quoteAmount);
|
||||
|
||||
}
|
||||
|
||||
contract MixinWOOFi{
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
using LibERC20TokenV06 for IEtherTokenV06;
|
||||
using LibSafeMathV06 for uint256;
|
||||
|
||||
address constant rebateAddress = 0xBfdcBB4C05843163F491C24f9c0019c510786304;
|
||||
|
||||
// /// @dev Swaps an exact amount of input tokens for as many output tokens as possible.
|
||||
// /// @param _amountIn Amount of input tokens to send
|
||||
// /// @param _minAmountOut The minimum amount of output tokens that must be received for the transaction not to revert.
|
||||
// /// @param _tokenIn Input token
|
||||
// /// @param _tokenOut Output token
|
||||
// /// @param _to recipient of tokens
|
||||
// /// @param pool WOOFi pool where the swap will happen
|
||||
function _tradeWOOFi(
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
public
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
(IWooPP _pool) = abi.decode(bridgeData, (IWooPP));
|
||||
uint256 beforeBalance = buyToken.balanceOf(address(this));
|
||||
|
||||
sellToken.approveIfBelow(address(_pool), sellAmount);
|
||||
|
||||
_swap(
|
||||
sellAmount,
|
||||
address(sellToken),
|
||||
address(buyToken),
|
||||
_pool
|
||||
);
|
||||
boughtAmount = buyToken.balanceOf(address(this)).safeSub(beforeBalance);
|
||||
}
|
||||
|
||||
function _swap(
|
||||
uint _amountIn,
|
||||
address _tokenIn,
|
||||
address _tokenOut,
|
||||
IWooPP pool
|
||||
) internal {
|
||||
address quoteToken = pool.quoteToken();
|
||||
if (_tokenIn == quoteToken) {
|
||||
pool.sellQuote(
|
||||
_tokenOut,
|
||||
_amountIn,
|
||||
1,
|
||||
address(this),
|
||||
rebateAddress
|
||||
);
|
||||
} else if (_tokenOut == quoteToken) {
|
||||
pool.sellBase(
|
||||
_tokenIn,
|
||||
_amountIn,
|
||||
1,
|
||||
address(this),
|
||||
rebateAddress
|
||||
);
|
||||
} else {
|
||||
uint256 quoteAmount = pool.sellBase(
|
||||
_tokenIn,
|
||||
_amountIn,
|
||||
0,
|
||||
address(this),
|
||||
rebateAddress
|
||||
);
|
||||
IERC20TokenV06(pool.quoteToken()).approveIfBelow(address(pool), quoteAmount);
|
||||
pool.sellQuote(
|
||||
_tokenOut,
|
||||
quoteAmount,
|
||||
1,
|
||||
address(this),
|
||||
rebateAddress
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
|
||||
|
||||
interface IERC721Token {
|
||||
@@ -143,11 +143,11 @@ interface IERC721Token {
|
||||
/// @dev Throws if `_tokenId` is not a valid NFT.
|
||||
/// @param _tokenId The NFT to find the approved address for
|
||||
/// @return The approved address for this NFT, or the zero address if there is none
|
||||
function getApproved(uint256 _tokenId)
|
||||
function getApproved(uint256 _tokenId)
|
||||
external
|
||||
view
|
||||
returns (address);
|
||||
|
||||
|
||||
/// @notice Query if an address is an authorized operator for another address
|
||||
/// @param _owner The address that owns the NFTs
|
||||
/// @param _operator The address that acts on behalf of the owner
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
|
@@ -85,9 +85,9 @@ contract TestNFTOrderPresigner {
|
||||
zeroEx.cancelERC721Order(orderNonce);
|
||||
}
|
||||
|
||||
function cancelERC1155Order(LibNFTOrder.ERC1155Order calldata order)
|
||||
function cancelERC1155Order(uint256 orderNonce)
|
||||
external
|
||||
{
|
||||
zeroEx.cancelERC1155Order(order);
|
||||
zeroEx.cancelERC1155Order(orderNonce);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-zero-ex",
|
||||
"version": "0.30.1",
|
||||
"version": "0.36.1",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -41,9 +41,9 @@
|
||||
"rollback": "node ./lib/scripts/rollback.js"
|
||||
},
|
||||
"config": {
|
||||
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,PositiveSlippageFeeTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,AffiliateFeeTransformer,MetaTransactionsFeature,LogMetadataTransformer,BridgeAdapter,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature",
|
||||
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,PositiveSlippageFeeTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,AffiliateFeeTransformer,MetaTransactionsFeature,LogMetadataTransformer,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature,AvalancheBridgeAdapter,BSCBridgeAdapter,CeloBridgeAdapter,EthereumBridgeAdapter,FantomBridgeAdapter,OptimismBridgeAdapter,PolygonBridgeAdapter",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|ERC1155OrdersFeature|ERC165Feature|ERC721OrdersFeature|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinERC1155Spender|FixinERC721Spender|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC1155OrdersFeature|IERC1155Token|IERC165Feature|IERC20Bridge|IERC20Transformer|IERC721OrdersFeature|IERC721Token|IFeature|IFeeRecipient|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|IPropertyValidator|ISimpleFunctionRegistryFeature|IStaking|ITakerCallback|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC1155OrdersStorage|LibERC20Transformer|LibERC721OrdersStorage|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNFTOrder|LibNFTOrdersRichErrors|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinAaveV2|MixinBalancer|MixinBalancerV2|MixinBancor|MixinCoFiX|MixinCompound|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NFTOrders|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFeeRecipient|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC1155Token|TestMintableERC20Token|TestMintableERC721Token|TestMooniswap|TestNFTOrderPresigner|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestPropertyValidator|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
|
||||
"abis": "./test/generated-artifacts/@(AbstractBridgeAdapter|AffiliateFeeTransformer|AvalancheBridgeAdapter|BSCBridgeAdapter|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeProtocols|CeloBridgeAdapter|CurveLiquidityProvider|ERC1155OrdersFeature|ERC165Feature|ERC721OrdersFeature|EthereumBridgeAdapter|FantomBridgeAdapter|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinERC1155Spender|FixinERC721Spender|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC1155OrdersFeature|IERC1155Token|IERC165Feature|IERC20Bridge|IERC20Transformer|IERC721OrdersFeature|IERC721Token|IFeature|IFeeRecipient|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|IPropertyValidator|ISimpleFunctionRegistryFeature|IStaking|ITakerCallback|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC1155OrdersStorage|LibERC20Transformer|LibERC721OrdersStorage|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNFTOrder|LibNFTOrdersRichErrors|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinAaveV2|MixinBalancer|MixinBalancerV2|MixinBalancerV2Batch|MixinBancor|MixinBancorV3|MixinCompound|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinGMX|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinPlatypus|MixinShell|MixinSynthetix|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinVelodrome|MixinWOOFi|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NFTOrders|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OptimismBridgeAdapter|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PolygonBridgeAdapter|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFeeRecipient|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC1155Token|TestMintableERC20Token|TestMintableERC721Token|TestMooniswap|TestNFTOrderPresigner|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestPropertyValidator|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -55,14 +55,14 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/zero-ex",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^5.7.2",
|
||||
"@0x/contract-addresses": "^6.11.0",
|
||||
"@0x/contracts-erc20": "^3.3.25",
|
||||
"@0x/contracts-gen": "^2.0.43",
|
||||
"@0x/contracts-test-utils": "^5.4.16",
|
||||
"@0x/dev-utils": "^4.2.11",
|
||||
"@0x/abi-gen": "^5.8.0",
|
||||
"@0x/contract-addresses": "^6.19.0",
|
||||
"@0x/contracts-erc20": "^3.3.34",
|
||||
"@0x/contracts-gen": "^2.0.46",
|
||||
"@0x/contracts-test-utils": "^5.4.25",
|
||||
"@0x/dev-utils": "^4.2.14",
|
||||
"@0x/order-utils": "^10.4.28",
|
||||
"@0x/sol-compiler": "^4.7.8",
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
"@0x/ts-doc-gen": "^0.0.28",
|
||||
"@0x/tslint-config": "^4.1.4",
|
||||
"@types/isomorphic-fetch": "^0.0.35",
|
||||
@@ -79,17 +79,17 @@
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "4.2.2"
|
||||
"typescript": "4.6.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.4.5",
|
||||
"@0x/protocol-utils": "^1.10.1",
|
||||
"@0x/subproviders": "^6.6.2",
|
||||
"@0x/types": "^3.3.4",
|
||||
"@0x/typescript-typings": "^5.2.1",
|
||||
"@0x/utils": "^6.5.0",
|
||||
"@0x/web3-wrapper": "^7.6.2",
|
||||
"ethereum-types": "^3.6.0",
|
||||
"@0x/base-contract": "^6.5.0",
|
||||
"@0x/protocol-utils": "^11.16.1",
|
||||
"@0x/subproviders": "^6.6.5",
|
||||
"@0x/types": "^3.3.6",
|
||||
"@0x/typescript-typings": "^5.3.1",
|
||||
"@0x/utils": "^6.5.3",
|
||||
"@0x/web3-wrapper": "^7.6.5",
|
||||
"ethereum-types": "^3.7.0",
|
||||
"ethereumjs-util": "^7.0.10",
|
||||
"ethers": "~4.0.4"
|
||||
},
|
||||
|
@@ -6,9 +6,13 @@
|
||||
import { ContractArtifact } from 'ethereum-types';
|
||||
|
||||
import * as AffiliateFeeTransformer from '../generated-artifacts/AffiliateFeeTransformer.json';
|
||||
import * as AvalancheBridgeAdapter from '../generated-artifacts/AvalancheBridgeAdapter.json';
|
||||
import * as BatchFillNativeOrdersFeature from '../generated-artifacts/BatchFillNativeOrdersFeature.json';
|
||||
import * as BridgeAdapter from '../generated-artifacts/BridgeAdapter.json';
|
||||
import * as BSCBridgeAdapter from '../generated-artifacts/BSCBridgeAdapter.json';
|
||||
import * as CeloBridgeAdapter from '../generated-artifacts/CeloBridgeAdapter.json';
|
||||
import * as CurveLiquidityProvider from '../generated-artifacts/CurveLiquidityProvider.json';
|
||||
import * as EthereumBridgeAdapter from '../generated-artifacts/EthereumBridgeAdapter.json';
|
||||
import * as FantomBridgeAdapter from '../generated-artifacts/FantomBridgeAdapter.json';
|
||||
import * as FeeCollector from '../generated-artifacts/FeeCollector.json';
|
||||
import * as FeeCollectorController from '../generated-artifacts/FeeCollectorController.json';
|
||||
import * as FillQuoteTransformer from '../generated-artifacts/FillQuoteTransformer.json';
|
||||
@@ -30,9 +34,11 @@ import * as LogMetadataTransformer from '../generated-artifacts/LogMetadataTrans
|
||||
import * as MetaTransactionsFeature from '../generated-artifacts/MetaTransactionsFeature.json';
|
||||
import * as MultiplexFeature from '../generated-artifacts/MultiplexFeature.json';
|
||||
import * as NativeOrdersFeature from '../generated-artifacts/NativeOrdersFeature.json';
|
||||
import * as OptimismBridgeAdapter from '../generated-artifacts/OptimismBridgeAdapter.json';
|
||||
import * as OtcOrdersFeature from '../generated-artifacts/OtcOrdersFeature.json';
|
||||
import * as OwnableFeature from '../generated-artifacts/OwnableFeature.json';
|
||||
import * as PayTakerTransformer from '../generated-artifacts/PayTakerTransformer.json';
|
||||
import * as PolygonBridgeAdapter from '../generated-artifacts/PolygonBridgeAdapter.json';
|
||||
import * as PositiveSlippageFeeTransformer from '../generated-artifacts/PositiveSlippageFeeTransformer.json';
|
||||
import * as SimpleFunctionRegistryFeature from '../generated-artifacts/SimpleFunctionRegistryFeature.json';
|
||||
import * as TransformERC20Feature from '../generated-artifacts/TransformERC20Feature.json';
|
||||
@@ -58,7 +64,6 @@ export const artifacts = {
|
||||
AffiliateFeeTransformer: AffiliateFeeTransformer as ContractArtifact,
|
||||
MetaTransactionsFeature: MetaTransactionsFeature as ContractArtifact,
|
||||
LogMetadataTransformer: LogMetadataTransformer as ContractArtifact,
|
||||
BridgeAdapter: BridgeAdapter as ContractArtifact,
|
||||
LiquidityProviderFeature: LiquidityProviderFeature as ContractArtifact,
|
||||
ILiquidityProviderFeature: ILiquidityProviderFeature as ContractArtifact,
|
||||
NativeOrdersFeature: NativeOrdersFeature as ContractArtifact,
|
||||
@@ -72,4 +77,11 @@ export const artifacts = {
|
||||
IMultiplexFeature: IMultiplexFeature as ContractArtifact,
|
||||
OtcOrdersFeature: OtcOrdersFeature as ContractArtifact,
|
||||
IOtcOrdersFeature: IOtcOrdersFeature as ContractArtifact,
|
||||
AvalancheBridgeAdapter: AvalancheBridgeAdapter as ContractArtifact,
|
||||
BSCBridgeAdapter: BSCBridgeAdapter as ContractArtifact,
|
||||
CeloBridgeAdapter: CeloBridgeAdapter as ContractArtifact,
|
||||
EthereumBridgeAdapter: EthereumBridgeAdapter as ContractArtifact,
|
||||
FantomBridgeAdapter: FantomBridgeAdapter as ContractArtifact,
|
||||
OptimismBridgeAdapter: OptimismBridgeAdapter as ContractArtifact,
|
||||
PolygonBridgeAdapter: PolygonBridgeAdapter as ContractArtifact,
|
||||
};
|
||||
|
@@ -35,7 +35,11 @@ export * from './bloom_filter_utils';
|
||||
export { GREEDY_TOKENS } from './constants';
|
||||
export {
|
||||
AffiliateFeeTransformerContract,
|
||||
BridgeAdapterContract,
|
||||
AvalancheBridgeAdapterContract,
|
||||
BSCBridgeAdapterContract,
|
||||
CeloBridgeAdapterContract,
|
||||
EthereumBridgeAdapterContract,
|
||||
FantomBridgeAdapterContract,
|
||||
FillQuoteTransformerContract,
|
||||
IOwnableFeatureContract,
|
||||
IOwnableFeatureEvents,
|
||||
@@ -45,7 +49,9 @@ export {
|
||||
IZeroExContract,
|
||||
LogMetadataTransformerContract,
|
||||
MultiplexFeatureContract,
|
||||
OptimismBridgeAdapterContract,
|
||||
PayTakerTransformerContract,
|
||||
PolygonBridgeAdapterContract,
|
||||
PositiveSlippageFeeTransformerContract,
|
||||
TransformERC20FeatureContract,
|
||||
WethTransformerContract,
|
||||
|
@@ -4,9 +4,13 @@
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
export * from '../generated-wrappers/affiliate_fee_transformer';
|
||||
export * from '../generated-wrappers/avalanche_bridge_adapter';
|
||||
export * from '../generated-wrappers/b_s_c_bridge_adapter';
|
||||
export * from '../generated-wrappers/batch_fill_native_orders_feature';
|
||||
export * from '../generated-wrappers/bridge_adapter';
|
||||
export * from '../generated-wrappers/celo_bridge_adapter';
|
||||
export * from '../generated-wrappers/curve_liquidity_provider';
|
||||
export * from '../generated-wrappers/ethereum_bridge_adapter';
|
||||
export * from '../generated-wrappers/fantom_bridge_adapter';
|
||||
export * from '../generated-wrappers/fee_collector';
|
||||
export * from '../generated-wrappers/fee_collector_controller';
|
||||
export * from '../generated-wrappers/fill_quote_transformer';
|
||||
@@ -28,9 +32,11 @@ export * from '../generated-wrappers/log_metadata_transformer';
|
||||
export * from '../generated-wrappers/meta_transactions_feature';
|
||||
export * from '../generated-wrappers/multiplex_feature';
|
||||
export * from '../generated-wrappers/native_orders_feature';
|
||||
export * from '../generated-wrappers/optimism_bridge_adapter';
|
||||
export * from '../generated-wrappers/otc_orders_feature';
|
||||
export * from '../generated-wrappers/ownable_feature';
|
||||
export * from '../generated-wrappers/pay_taker_transformer';
|
||||
export * from '../generated-wrappers/polygon_bridge_adapter';
|
||||
export * from '../generated-wrappers/positive_slippage_fee_transformer';
|
||||
export * from '../generated-wrappers/simple_function_registry_feature';
|
||||
export * from '../generated-wrappers/transform_erc20_feature';
|
||||
|
@@ -5,15 +5,20 @@
|
||||
*/
|
||||
import { ContractArtifact } from 'ethereum-types';
|
||||
|
||||
import * as AbstractBridgeAdapter from '../test/generated-artifacts/AbstractBridgeAdapter.json';
|
||||
import * as AffiliateFeeTransformer from '../test/generated-artifacts/AffiliateFeeTransformer.json';
|
||||
import * as AvalancheBridgeAdapter from '../test/generated-artifacts/AvalancheBridgeAdapter.json';
|
||||
import * as BatchFillNativeOrdersFeature from '../test/generated-artifacts/BatchFillNativeOrdersFeature.json';
|
||||
import * as BootstrapFeature from '../test/generated-artifacts/BootstrapFeature.json';
|
||||
import * as BridgeAdapter from '../test/generated-artifacts/BridgeAdapter.json';
|
||||
import * as BridgeProtocols from '../test/generated-artifacts/BridgeProtocols.json';
|
||||
import * as BSCBridgeAdapter from '../test/generated-artifacts/BSCBridgeAdapter.json';
|
||||
import * as CeloBridgeAdapter from '../test/generated-artifacts/CeloBridgeAdapter.json';
|
||||
import * as CurveLiquidityProvider from '../test/generated-artifacts/CurveLiquidityProvider.json';
|
||||
import * as ERC1155OrdersFeature from '../test/generated-artifacts/ERC1155OrdersFeature.json';
|
||||
import * as ERC165Feature from '../test/generated-artifacts/ERC165Feature.json';
|
||||
import * as ERC721OrdersFeature from '../test/generated-artifacts/ERC721OrdersFeature.json';
|
||||
import * as EthereumBridgeAdapter from '../test/generated-artifacts/EthereumBridgeAdapter.json';
|
||||
import * as FantomBridgeAdapter from '../test/generated-artifacts/FantomBridgeAdapter.json';
|
||||
import * as FeeCollector from '../test/generated-artifacts/FeeCollector.json';
|
||||
import * as FeeCollectorController from '../test/generated-artifacts/FeeCollectorController.json';
|
||||
import * as FillQuoteTransformer from '../test/generated-artifacts/FillQuoteTransformer.json';
|
||||
@@ -101,26 +106,30 @@ import * as MetaTransactionsFeature from '../test/generated-artifacts/MetaTransa
|
||||
import * as MixinAaveV2 from '../test/generated-artifacts/MixinAaveV2.json';
|
||||
import * as MixinBalancer from '../test/generated-artifacts/MixinBalancer.json';
|
||||
import * as MixinBalancerV2 from '../test/generated-artifacts/MixinBalancerV2.json';
|
||||
import * as MixinBalancerV2Batch from '../test/generated-artifacts/MixinBalancerV2Batch.json';
|
||||
import * as MixinBancor from '../test/generated-artifacts/MixinBancor.json';
|
||||
import * as MixinCoFiX from '../test/generated-artifacts/MixinCoFiX.json';
|
||||
import * as MixinBancorV3 from '../test/generated-artifacts/MixinBancorV3.json';
|
||||
import * as MixinCompound from '../test/generated-artifacts/MixinCompound.json';
|
||||
import * as MixinCryptoCom from '../test/generated-artifacts/MixinCryptoCom.json';
|
||||
import * as MixinCurve from '../test/generated-artifacts/MixinCurve.json';
|
||||
import * as MixinCurveV2 from '../test/generated-artifacts/MixinCurveV2.json';
|
||||
import * as MixinDodo from '../test/generated-artifacts/MixinDodo.json';
|
||||
import * as MixinDodoV2 from '../test/generated-artifacts/MixinDodoV2.json';
|
||||
import * as MixinKyber from '../test/generated-artifacts/MixinKyber.json';
|
||||
import * as MixinGMX from '../test/generated-artifacts/MixinGMX.json';
|
||||
import * as MixinKyberDmm from '../test/generated-artifacts/MixinKyberDmm.json';
|
||||
import * as MixinLido from '../test/generated-artifacts/MixinLido.json';
|
||||
import * as MixinMakerPSM from '../test/generated-artifacts/MixinMakerPSM.json';
|
||||
import * as MixinMooniswap from '../test/generated-artifacts/MixinMooniswap.json';
|
||||
import * as MixinMStable from '../test/generated-artifacts/MixinMStable.json';
|
||||
import * as MixinNerve from '../test/generated-artifacts/MixinNerve.json';
|
||||
import * as MixinOasis from '../test/generated-artifacts/MixinOasis.json';
|
||||
import * as MixinPlatypus from '../test/generated-artifacts/MixinPlatypus.json';
|
||||
import * as MixinShell from '../test/generated-artifacts/MixinShell.json';
|
||||
import * as MixinSynthetix from '../test/generated-artifacts/MixinSynthetix.json';
|
||||
import * as MixinUniswap from '../test/generated-artifacts/MixinUniswap.json';
|
||||
import * as MixinUniswapV2 from '../test/generated-artifacts/MixinUniswapV2.json';
|
||||
import * as MixinUniswapV3 from '../test/generated-artifacts/MixinUniswapV3.json';
|
||||
import * as MixinVelodrome from '../test/generated-artifacts/MixinVelodrome.json';
|
||||
import * as MixinWOOFi from '../test/generated-artifacts/MixinWOOFi.json';
|
||||
import * as MixinZeroExBridge from '../test/generated-artifacts/MixinZeroExBridge.json';
|
||||
import * as MooniswapLiquidityProvider from '../test/generated-artifacts/MooniswapLiquidityProvider.json';
|
||||
import * as MultiplexFeature from '../test/generated-artifacts/MultiplexFeature.json';
|
||||
@@ -136,11 +145,13 @@ import * as NativeOrdersInfo from '../test/generated-artifacts/NativeOrdersInfo.
|
||||
import * as NativeOrdersProtocolFees from '../test/generated-artifacts/NativeOrdersProtocolFees.json';
|
||||
import * as NativeOrdersSettlement from '../test/generated-artifacts/NativeOrdersSettlement.json';
|
||||
import * as NFTOrders from '../test/generated-artifacts/NFTOrders.json';
|
||||
import * as OptimismBridgeAdapter from '../test/generated-artifacts/OptimismBridgeAdapter.json';
|
||||
import * as OtcOrdersFeature from '../test/generated-artifacts/OtcOrdersFeature.json';
|
||||
import * as OwnableFeature from '../test/generated-artifacts/OwnableFeature.json';
|
||||
import * as PancakeSwapFeature from '../test/generated-artifacts/PancakeSwapFeature.json';
|
||||
import * as PayTakerTransformer from '../test/generated-artifacts/PayTakerTransformer.json';
|
||||
import * as PermissionlessTransformerDeployer from '../test/generated-artifacts/PermissionlessTransformerDeployer.json';
|
||||
import * as PolygonBridgeAdapter from '../test/generated-artifacts/PolygonBridgeAdapter.json';
|
||||
import * as PositiveSlippageFeeTransformer from '../test/generated-artifacts/PositiveSlippageFeeTransformer.json';
|
||||
import * as SimpleFunctionRegistryFeature from '../test/generated-artifacts/SimpleFunctionRegistryFeature.json';
|
||||
import * as TestBridge from '../test/generated-artifacts/TestBridge.json';
|
||||
@@ -307,32 +318,43 @@ export const artifacts = {
|
||||
PositiveSlippageFeeTransformer: PositiveSlippageFeeTransformer as ContractArtifact,
|
||||
Transformer: Transformer as ContractArtifact,
|
||||
WethTransformer: WethTransformer as ContractArtifact,
|
||||
BridgeAdapter: BridgeAdapter as ContractArtifact,
|
||||
AbstractBridgeAdapter: AbstractBridgeAdapter as ContractArtifact,
|
||||
AvalancheBridgeAdapter: AvalancheBridgeAdapter as ContractArtifact,
|
||||
BSCBridgeAdapter: BSCBridgeAdapter as ContractArtifact,
|
||||
BridgeProtocols: BridgeProtocols as ContractArtifact,
|
||||
CeloBridgeAdapter: CeloBridgeAdapter as ContractArtifact,
|
||||
EthereumBridgeAdapter: EthereumBridgeAdapter as ContractArtifact,
|
||||
FantomBridgeAdapter: FantomBridgeAdapter as ContractArtifact,
|
||||
IBridgeAdapter: IBridgeAdapter as ContractArtifact,
|
||||
OptimismBridgeAdapter: OptimismBridgeAdapter as ContractArtifact,
|
||||
PolygonBridgeAdapter: PolygonBridgeAdapter as ContractArtifact,
|
||||
MixinAaveV2: MixinAaveV2 as ContractArtifact,
|
||||
MixinBalancer: MixinBalancer as ContractArtifact,
|
||||
MixinBalancerV2: MixinBalancerV2 as ContractArtifact,
|
||||
MixinBalancerV2Batch: MixinBalancerV2Batch as ContractArtifact,
|
||||
MixinBancor: MixinBancor as ContractArtifact,
|
||||
MixinCoFiX: MixinCoFiX as ContractArtifact,
|
||||
MixinBancorV3: MixinBancorV3 as ContractArtifact,
|
||||
MixinCompound: MixinCompound as ContractArtifact,
|
||||
MixinCryptoCom: MixinCryptoCom as ContractArtifact,
|
||||
MixinCurve: MixinCurve as ContractArtifact,
|
||||
MixinCurveV2: MixinCurveV2 as ContractArtifact,
|
||||
MixinDodo: MixinDodo as ContractArtifact,
|
||||
MixinDodoV2: MixinDodoV2 as ContractArtifact,
|
||||
MixinKyber: MixinKyber as ContractArtifact,
|
||||
MixinGMX: MixinGMX as ContractArtifact,
|
||||
MixinKyberDmm: MixinKyberDmm as ContractArtifact,
|
||||
MixinLido: MixinLido as ContractArtifact,
|
||||
MixinMStable: MixinMStable as ContractArtifact,
|
||||
MixinMakerPSM: MixinMakerPSM as ContractArtifact,
|
||||
MixinMooniswap: MixinMooniswap as ContractArtifact,
|
||||
MixinNerve: MixinNerve as ContractArtifact,
|
||||
MixinOasis: MixinOasis as ContractArtifact,
|
||||
MixinPlatypus: MixinPlatypus as ContractArtifact,
|
||||
MixinShell: MixinShell as ContractArtifact,
|
||||
MixinSynthetix: MixinSynthetix as ContractArtifact,
|
||||
MixinUniswap: MixinUniswap as ContractArtifact,
|
||||
MixinUniswapV2: MixinUniswapV2 as ContractArtifact,
|
||||
MixinUniswapV3: MixinUniswapV3 as ContractArtifact,
|
||||
MixinVelodrome: MixinVelodrome as ContractArtifact,
|
||||
MixinWOOFi: MixinWOOFi as ContractArtifact,
|
||||
MixinZeroExBridge: MixinZeroExBridge as ContractArtifact,
|
||||
IERC1155Token: IERC1155Token as ContractArtifact,
|
||||
IERC721Token: IERC721Token as ContractArtifact,
|
||||
|
@@ -32,7 +32,7 @@ import {
|
||||
TestWethContract,
|
||||
} from '../wrappers';
|
||||
|
||||
blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
blockchainTests.resets('ERC1155OrdersFeature', env => {
|
||||
const { NULL_ADDRESS, MAX_UINT256, ZERO_AMOUNT: ZERO } = constants;
|
||||
const ETH_TOKEN_ADDRESS = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
|
||||
|
||||
@@ -347,22 +347,22 @@ blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
describe('cancelERC1155Order', () => {
|
||||
it('can cancel an order', async () => {
|
||||
const order = getTestERC1155Order();
|
||||
const tx = await zeroEx.cancelERC1155Order(order).awaitTransactionSuccessAsync({
|
||||
const tx = await zeroEx.cancelERC1155Order(order.nonce).awaitTransactionSuccessAsync({
|
||||
from: maker,
|
||||
});
|
||||
verifyEventsFromLogs(tx.logs, [{ orderHash: order.getHash(), maker }], IZeroExEvents.ERC1155OrderCancelled);
|
||||
verifyEventsFromLogs(tx.logs, [{ maker, nonce: order.nonce }], IZeroExEvents.ERC1155OrderCancelled);
|
||||
const orderInfo = await zeroEx.getERC1155OrderInfo(order).callAsync();
|
||||
expect(orderInfo.status).to.equal(NFTOrder.OrderStatus.Unfillable);
|
||||
});
|
||||
it('cancelling an order twice silently succeeds', async () => {
|
||||
const order = getTestERC1155Order();
|
||||
await zeroEx.cancelERC1155Order(order).awaitTransactionSuccessAsync({
|
||||
await zeroEx.cancelERC1155Order(order.nonce).awaitTransactionSuccessAsync({
|
||||
from: maker,
|
||||
});
|
||||
const tx = await zeroEx.cancelERC1155Order(order).awaitTransactionSuccessAsync({
|
||||
const tx = await zeroEx.cancelERC1155Order(order.nonce).awaitTransactionSuccessAsync({
|
||||
from: maker,
|
||||
});
|
||||
verifyEventsFromLogs(tx.logs, [{ orderHash: order.getHash(), maker }], IZeroExEvents.ERC1155OrderCancelled);
|
||||
verifyEventsFromLogs(tx.logs, [{ maker, nonce: order.nonce }], IZeroExEvents.ERC1155OrderCancelled);
|
||||
const orderInfo = await zeroEx.getERC1155OrderInfo(order).callAsync();
|
||||
expect(orderInfo.status).to.equal(NFTOrder.OrderStatus.Unfillable);
|
||||
});
|
||||
@@ -427,7 +427,7 @@ blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
});
|
||||
const signature = await order.getSignatureWithProviderAsync(env.provider);
|
||||
await mintAssetsAsync(order);
|
||||
await zeroEx.cancelERC1155Order(order).awaitTransactionSuccessAsync({
|
||||
await zeroEx.cancelERC1155Order(order.nonce).awaitTransactionSuccessAsync({
|
||||
from: maker,
|
||||
});
|
||||
const tx = zeroEx
|
||||
@@ -990,7 +990,7 @@ blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
});
|
||||
const signature = await order.getSignatureWithProviderAsync(env.provider);
|
||||
await mintAssetsAsync(order);
|
||||
await zeroEx.cancelERC1155Order(order).awaitTransactionSuccessAsync({
|
||||
await zeroEx.cancelERC1155Order(order.nonce).awaitTransactionSuccessAsync({
|
||||
from: maker,
|
||||
});
|
||||
const tx = zeroEx
|
||||
@@ -1352,6 +1352,7 @@ blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
[order],
|
||||
[signature, signature],
|
||||
[order.erc1155TokenAmount, order.erc1155TokenAmount],
|
||||
[NULL_BYTES, NULL_BYTES],
|
||||
false,
|
||||
)
|
||||
.awaitTransactionSuccessAsync({
|
||||
@@ -1382,6 +1383,7 @@ blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
[order1, order2],
|
||||
[signature1, signature2],
|
||||
[order1.erc1155TokenAmount, order2.erc1155TokenAmount],
|
||||
[NULL_BYTES, NULL_BYTES],
|
||||
false,
|
||||
)
|
||||
.awaitTransactionSuccessAsync({
|
||||
@@ -1417,6 +1419,7 @@ blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
[order1, order2],
|
||||
[signature1, signature2],
|
||||
[order1.erc1155TokenAmount, order2.erc1155TokenAmount],
|
||||
[NULL_BYTES, NULL_BYTES],
|
||||
false,
|
||||
);
|
||||
const successes = await tx.callAsync({
|
||||
@@ -1460,6 +1463,7 @@ blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
[order1, order2],
|
||||
[signature1, signature2],
|
||||
[order1.erc1155TokenAmount, order2.erc1155TokenAmount],
|
||||
[NULL_BYTES, NULL_BYTES],
|
||||
true,
|
||||
)
|
||||
.awaitTransactionSuccessAsync({
|
||||
@@ -1488,6 +1492,7 @@ blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
[order1, order2],
|
||||
[signature1, signature2],
|
||||
[order1.erc1155TokenAmount, order2.erc1155TokenAmount],
|
||||
[NULL_BYTES, NULL_BYTES],
|
||||
true,
|
||||
)
|
||||
.awaitTransactionSuccessAsync({
|
||||
@@ -1573,7 +1578,7 @@ blockchainTests.resets.only('ERC1155OrdersFeature', env => {
|
||||
});
|
||||
await mintAssetsAsync(order);
|
||||
await contractMaker.preSignERC1155Order(order).awaitTransactionSuccessAsync();
|
||||
await contractMaker.cancelERC1155Order(order).awaitTransactionSuccessAsync();
|
||||
await contractMaker.cancelERC1155Order(order.nonce).awaitTransactionSuccessAsync();
|
||||
const tx = zeroEx
|
||||
.sellERC1155(
|
||||
order,
|
||||
|
@@ -1228,7 +1228,7 @@ blockchainTests.resets('ERC721OrdersFeature', env => {
|
||||
});
|
||||
const signature = await order.getSignatureWithProviderAsync(env.provider);
|
||||
await mintAssetsAsync(order);
|
||||
const tx = zeroEx.batchBuyERC721s([order], [signature, signature], false).awaitTransactionSuccessAsync({
|
||||
const tx = zeroEx.batchBuyERC721s([order], [signature, signature], [], false).awaitTransactionSuccessAsync({
|
||||
from: taker,
|
||||
});
|
||||
return expect(tx).to.revertWith('ERC721OrdersFeature::batchBuyERC721s/ARRAY_LENGTH_MISMATCH');
|
||||
@@ -1250,7 +1250,7 @@ blockchainTests.resets('ERC721OrdersFeature', env => {
|
||||
value: order2.erc20TokenAmount,
|
||||
});
|
||||
await zeroEx
|
||||
.batchBuyERC721s([order1, order2], [signature1, signature2], false)
|
||||
.batchBuyERC721s([order1, order2], [signature1, signature2], [NULL_BYTES, NULL_BYTES], false)
|
||||
.awaitTransactionSuccessAsync({
|
||||
from: taker,
|
||||
});
|
||||
@@ -1278,7 +1278,12 @@ blockchainTests.resets('ERC721OrdersFeature', env => {
|
||||
from: taker,
|
||||
value: order2.erc20TokenAmount,
|
||||
});
|
||||
const tx = zeroEx.batchBuyERC721s([order1, order2], [signature1, signature2], false);
|
||||
const tx = zeroEx.batchBuyERC721s(
|
||||
[order1, order2],
|
||||
[signature1, signature2],
|
||||
[NULL_BYTES, NULL_BYTES],
|
||||
false,
|
||||
);
|
||||
const successes = await tx.callAsync({
|
||||
from: taker,
|
||||
});
|
||||
@@ -1314,7 +1319,7 @@ blockchainTests.resets('ERC721OrdersFeature', env => {
|
||||
value: order2.erc20TokenAmount,
|
||||
});
|
||||
const tx = zeroEx
|
||||
.batchBuyERC721s([order1, order2], [signature1, signature2], true)
|
||||
.batchBuyERC721s([order1, order2], [signature1, signature2], [NULL_BYTES, NULL_BYTES], true)
|
||||
.awaitTransactionSuccessAsync({
|
||||
from: taker,
|
||||
});
|
||||
@@ -1335,7 +1340,7 @@ blockchainTests.resets('ERC721OrdersFeature', env => {
|
||||
await erc721Token.mint(maker, order2.erc721TokenId).awaitTransactionSuccessAsync();
|
||||
const takerEthBalanceBefore = await env.web3Wrapper.getBalanceInWeiAsync(taker);
|
||||
await zeroEx
|
||||
.batchBuyERC721s([order1, order2], [signature1, signature2], true)
|
||||
.batchBuyERC721s([order1, order2], [signature1, signature2], [NULL_BYTES, NULL_BYTES], true)
|
||||
.awaitTransactionSuccessAsync({
|
||||
from: taker,
|
||||
value: order1.erc20TokenAmount.plus(order2.erc20TokenAmount).plus(1),
|
||||
@@ -1495,9 +1500,11 @@ blockchainTests.resets('ERC721OrdersFeature', env => {
|
||||
const buyOrder = getTestERC721Order({
|
||||
direction: NFTOrder.TradeDirection.BuyNFT,
|
||||
erc20Token: weth.address,
|
||||
erc20TokenAmount: sellOrder.erc20TokenAmount,
|
||||
erc721TokenId: sellOrder.erc721TokenId,
|
||||
});
|
||||
const buySignature = await buyOrder.getSignatureWithProviderAsync(env.provider);
|
||||
await mintAssetsAsync(buyOrder, sellOrder.erc721TokenId, sellOrder.maker);
|
||||
const tx = zeroEx
|
||||
.matchERC721Orders(sellOrder, buyOrder, sellSignature, buySignature)
|
||||
.awaitTransactionSuccessAsync({
|
||||
|
@@ -28,7 +28,7 @@ import { artifacts } from '../artifacts';
|
||||
import { TestFillQuoteTransformerBridgeContract } from '../generated-wrappers/test_fill_quote_transformer_bridge';
|
||||
import { getRandomLimitOrder, getRandomRfqOrder } from '../utils/orders';
|
||||
import {
|
||||
BridgeAdapterContract,
|
||||
EthereumBridgeAdapterContract,
|
||||
FillQuoteTransformerContract,
|
||||
TestFillQuoteTransformerExchangeContract,
|
||||
TestFillQuoteTransformerHostContract,
|
||||
@@ -52,7 +52,8 @@ blockchainTests.resets('FillQuoteTransformer', env => {
|
||||
let singleProtocolFee: BigNumber;
|
||||
|
||||
const GAS_PRICE = 1337;
|
||||
const TEST_BRIDGE_SOURCE = hexUtils.random(32);
|
||||
// Left half is 0, corresponding to BridgeProtocol.Unknown
|
||||
const TEST_BRIDGE_SOURCE = hexUtils.leftPad(hexUtils.random(16), 32);
|
||||
const HIGH_BIT = new BigNumber(2).pow(255);
|
||||
const REVERT_AMOUNT = new BigNumber('0xdeadbeef');
|
||||
|
||||
@@ -64,8 +65,8 @@ blockchainTests.resets('FillQuoteTransformer', env => {
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
const bridgeAdapter = await BridgeAdapterContract.deployFrom0xArtifactAsync(
|
||||
artifacts.BridgeAdapter,
|
||||
const bridgeAdapter = await EthereumBridgeAdapterContract.deployFrom0xArtifactAsync(
|
||||
artifacts.EthereumBridgeAdapter,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
|
@@ -3,15 +3,20 @@
|
||||
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
export * from '../test/generated-wrappers/abstract_bridge_adapter';
|
||||
export * from '../test/generated-wrappers/affiliate_fee_transformer';
|
||||
export * from '../test/generated-wrappers/avalanche_bridge_adapter';
|
||||
export * from '../test/generated-wrappers/b_s_c_bridge_adapter';
|
||||
export * from '../test/generated-wrappers/batch_fill_native_orders_feature';
|
||||
export * from '../test/generated-wrappers/bootstrap_feature';
|
||||
export * from '../test/generated-wrappers/bridge_adapter';
|
||||
export * from '../test/generated-wrappers/bridge_protocols';
|
||||
export * from '../test/generated-wrappers/celo_bridge_adapter';
|
||||
export * from '../test/generated-wrappers/curve_liquidity_provider';
|
||||
export * from '../test/generated-wrappers/erc1155_orders_feature';
|
||||
export * from '../test/generated-wrappers/erc165_feature';
|
||||
export * from '../test/generated-wrappers/erc721_orders_feature';
|
||||
export * from '../test/generated-wrappers/ethereum_bridge_adapter';
|
||||
export * from '../test/generated-wrappers/fantom_bridge_adapter';
|
||||
export * from '../test/generated-wrappers/fee_collector';
|
||||
export * from '../test/generated-wrappers/fee_collector_controller';
|
||||
export * from '../test/generated-wrappers/fill_quote_transformer';
|
||||
@@ -99,26 +104,30 @@ export * from '../test/generated-wrappers/meta_transactions_feature';
|
||||
export * from '../test/generated-wrappers/mixin_aave_v2';
|
||||
export * from '../test/generated-wrappers/mixin_balancer';
|
||||
export * from '../test/generated-wrappers/mixin_balancer_v2';
|
||||
export * from '../test/generated-wrappers/mixin_balancer_v2_batch';
|
||||
export * from '../test/generated-wrappers/mixin_bancor';
|
||||
export * from '../test/generated-wrappers/mixin_co_fi_x';
|
||||
export * from '../test/generated-wrappers/mixin_bancor_v3';
|
||||
export * from '../test/generated-wrappers/mixin_compound';
|
||||
export * from '../test/generated-wrappers/mixin_crypto_com';
|
||||
export * from '../test/generated-wrappers/mixin_curve';
|
||||
export * from '../test/generated-wrappers/mixin_curve_v2';
|
||||
export * from '../test/generated-wrappers/mixin_dodo';
|
||||
export * from '../test/generated-wrappers/mixin_dodo_v2';
|
||||
export * from '../test/generated-wrappers/mixin_kyber';
|
||||
export * from '../test/generated-wrappers/mixin_g_m_x';
|
||||
export * from '../test/generated-wrappers/mixin_kyber_dmm';
|
||||
export * from '../test/generated-wrappers/mixin_lido';
|
||||
export * from '../test/generated-wrappers/mixin_m_stable';
|
||||
export * from '../test/generated-wrappers/mixin_maker_p_s_m';
|
||||
export * from '../test/generated-wrappers/mixin_mooniswap';
|
||||
export * from '../test/generated-wrappers/mixin_nerve';
|
||||
export * from '../test/generated-wrappers/mixin_oasis';
|
||||
export * from '../test/generated-wrappers/mixin_platypus';
|
||||
export * from '../test/generated-wrappers/mixin_shell';
|
||||
export * from '../test/generated-wrappers/mixin_synthetix';
|
||||
export * from '../test/generated-wrappers/mixin_uniswap';
|
||||
export * from '../test/generated-wrappers/mixin_uniswap_v2';
|
||||
export * from '../test/generated-wrappers/mixin_uniswap_v3';
|
||||
export * from '../test/generated-wrappers/mixin_velodrome';
|
||||
export * from '../test/generated-wrappers/mixin_w_o_o_fi';
|
||||
export * from '../test/generated-wrappers/mixin_zero_ex_bridge';
|
||||
export * from '../test/generated-wrappers/mooniswap_liquidity_provider';
|
||||
export * from '../test/generated-wrappers/multiplex_feature';
|
||||
@@ -134,11 +143,13 @@ export * from '../test/generated-wrappers/native_orders_feature';
|
||||
export * from '../test/generated-wrappers/native_orders_info';
|
||||
export * from '../test/generated-wrappers/native_orders_protocol_fees';
|
||||
export * from '../test/generated-wrappers/native_orders_settlement';
|
||||
export * from '../test/generated-wrappers/optimism_bridge_adapter';
|
||||
export * from '../test/generated-wrappers/otc_orders_feature';
|
||||
export * from '../test/generated-wrappers/ownable_feature';
|
||||
export * from '../test/generated-wrappers/pancake_swap_feature';
|
||||
export * from '../test/generated-wrappers/pay_taker_transformer';
|
||||
export * from '../test/generated-wrappers/permissionless_transformer_deployer';
|
||||
export * from '../test/generated-wrappers/polygon_bridge_adapter';
|
||||
export * from '../test/generated-wrappers/positive_slippage_fee_transformer';
|
||||
export * from '../test/generated-wrappers/simple_function_registry_feature';
|
||||
export * from '../test/generated-wrappers/test_bridge';
|
||||
|
@@ -4,9 +4,13 @@
|
||||
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*", "./scripts/**/*"],
|
||||
"files": [
|
||||
"generated-artifacts/AffiliateFeeTransformer.json",
|
||||
"generated-artifacts/AvalancheBridgeAdapter.json",
|
||||
"generated-artifacts/BSCBridgeAdapter.json",
|
||||
"generated-artifacts/BatchFillNativeOrdersFeature.json",
|
||||
"generated-artifacts/BridgeAdapter.json",
|
||||
"generated-artifacts/CeloBridgeAdapter.json",
|
||||
"generated-artifacts/CurveLiquidityProvider.json",
|
||||
"generated-artifacts/EthereumBridgeAdapter.json",
|
||||
"generated-artifacts/FantomBridgeAdapter.json",
|
||||
"generated-artifacts/FeeCollector.json",
|
||||
"generated-artifacts/FeeCollectorController.json",
|
||||
"generated-artifacts/FillQuoteTransformer.json",
|
||||
@@ -28,23 +32,30 @@
|
||||
"generated-artifacts/MetaTransactionsFeature.json",
|
||||
"generated-artifacts/MultiplexFeature.json",
|
||||
"generated-artifacts/NativeOrdersFeature.json",
|
||||
"generated-artifacts/OptimismBridgeAdapter.json",
|
||||
"generated-artifacts/OtcOrdersFeature.json",
|
||||
"generated-artifacts/OwnableFeature.json",
|
||||
"generated-artifacts/PayTakerTransformer.json",
|
||||
"generated-artifacts/PolygonBridgeAdapter.json",
|
||||
"generated-artifacts/PositiveSlippageFeeTransformer.json",
|
||||
"generated-artifacts/SimpleFunctionRegistryFeature.json",
|
||||
"generated-artifacts/TransformERC20Feature.json",
|
||||
"generated-artifacts/WethTransformer.json",
|
||||
"generated-artifacts/ZeroEx.json",
|
||||
"test/generated-artifacts/AbstractBridgeAdapter.json",
|
||||
"test/generated-artifacts/AffiliateFeeTransformer.json",
|
||||
"test/generated-artifacts/AvalancheBridgeAdapter.json",
|
||||
"test/generated-artifacts/BSCBridgeAdapter.json",
|
||||
"test/generated-artifacts/BatchFillNativeOrdersFeature.json",
|
||||
"test/generated-artifacts/BootstrapFeature.json",
|
||||
"test/generated-artifacts/BridgeAdapter.json",
|
||||
"test/generated-artifacts/BridgeProtocols.json",
|
||||
"test/generated-artifacts/CeloBridgeAdapter.json",
|
||||
"test/generated-artifacts/CurveLiquidityProvider.json",
|
||||
"test/generated-artifacts/ERC1155OrdersFeature.json",
|
||||
"test/generated-artifacts/ERC165Feature.json",
|
||||
"test/generated-artifacts/ERC721OrdersFeature.json",
|
||||
"test/generated-artifacts/EthereumBridgeAdapter.json",
|
||||
"test/generated-artifacts/FantomBridgeAdapter.json",
|
||||
"test/generated-artifacts/FeeCollector.json",
|
||||
"test/generated-artifacts/FeeCollectorController.json",
|
||||
"test/generated-artifacts/FillQuoteTransformer.json",
|
||||
@@ -132,26 +143,30 @@
|
||||
"test/generated-artifacts/MixinAaveV2.json",
|
||||
"test/generated-artifacts/MixinBalancer.json",
|
||||
"test/generated-artifacts/MixinBalancerV2.json",
|
||||
"test/generated-artifacts/MixinBalancerV2Batch.json",
|
||||
"test/generated-artifacts/MixinBancor.json",
|
||||
"test/generated-artifacts/MixinCoFiX.json",
|
||||
"test/generated-artifacts/MixinBancorV3.json",
|
||||
"test/generated-artifacts/MixinCompound.json",
|
||||
"test/generated-artifacts/MixinCryptoCom.json",
|
||||
"test/generated-artifacts/MixinCurve.json",
|
||||
"test/generated-artifacts/MixinCurveV2.json",
|
||||
"test/generated-artifacts/MixinDodo.json",
|
||||
"test/generated-artifacts/MixinDodoV2.json",
|
||||
"test/generated-artifacts/MixinKyber.json",
|
||||
"test/generated-artifacts/MixinGMX.json",
|
||||
"test/generated-artifacts/MixinKyberDmm.json",
|
||||
"test/generated-artifacts/MixinLido.json",
|
||||
"test/generated-artifacts/MixinMStable.json",
|
||||
"test/generated-artifacts/MixinMakerPSM.json",
|
||||
"test/generated-artifacts/MixinMooniswap.json",
|
||||
"test/generated-artifacts/MixinNerve.json",
|
||||
"test/generated-artifacts/MixinOasis.json",
|
||||
"test/generated-artifacts/MixinPlatypus.json",
|
||||
"test/generated-artifacts/MixinShell.json",
|
||||
"test/generated-artifacts/MixinSynthetix.json",
|
||||
"test/generated-artifacts/MixinUniswap.json",
|
||||
"test/generated-artifacts/MixinUniswapV2.json",
|
||||
"test/generated-artifacts/MixinUniswapV3.json",
|
||||
"test/generated-artifacts/MixinVelodrome.json",
|
||||
"test/generated-artifacts/MixinWOOFi.json",
|
||||
"test/generated-artifacts/MixinZeroExBridge.json",
|
||||
"test/generated-artifacts/MooniswapLiquidityProvider.json",
|
||||
"test/generated-artifacts/MultiplexFeature.json",
|
||||
@@ -167,11 +182,13 @@
|
||||
"test/generated-artifacts/NativeOrdersInfo.json",
|
||||
"test/generated-artifacts/NativeOrdersProtocolFees.json",
|
||||
"test/generated-artifacts/NativeOrdersSettlement.json",
|
||||
"test/generated-artifacts/OptimismBridgeAdapter.json",
|
||||
"test/generated-artifacts/OtcOrdersFeature.json",
|
||||
"test/generated-artifacts/OwnableFeature.json",
|
||||
"test/generated-artifacts/PancakeSwapFeature.json",
|
||||
"test/generated-artifacts/PayTakerTransformer.json",
|
||||
"test/generated-artifacts/PermissionlessTransformerDeployer.json",
|
||||
"test/generated-artifacts/PolygonBridgeAdapter.json",
|
||||
"test/generated-artifacts/PositiveSlippageFeeTransformer.json",
|
||||
"test/generated-artifacts/SimpleFunctionRegistryFeature.json",
|
||||
"test/generated-artifacts/TestBridge.json",
|
||||
|
@@ -4,23 +4,28 @@ Audits
|
||||
|
||||
Below are links to our third-party audit reports.
|
||||
|
||||
+------------------+---------------------------------------------------------------------------------------------------------------+
|
||||
| **Release** | **Reports** |
|
||||
+------------------+---------------------------------------------------------------------------------------------------------------+
|
||||
| Exchange V4 | * `Consensys Diligence (December 2020) <https://consensys.net/diligence/audits/2020/12/0x-exchange-v4/>`__ |
|
||||
+------------------+---------------------------------------------------------------------------------------------------------------+
|
||||
| Exchange V3 | * `Trail of Bits <http://zeips.0x.org.s3-website.us-east-2.amazonaws.com/audits/56/trail-of-bits/audit.pdf>`_ |
|
||||
| | * `Consensys Diligence (Exchange) <https://diligence.consensys.net/audits/2019/09/0x-v3-exchange/>`__ |
|
||||
| | * `Consensys Diligence (Staking) <https://diligence.consensys.net/audits/2019/10/0x-v3-staking/>`__ |
|
||||
+------------------+---------------------------------------------------------------------------------------------------------------+
|
||||
| Exchange V2.1 | * `First <https://docs.google.com/document/d/1jYv6V21MfCSwCS5fxD6ZyaLWGzkpRSUO0lZpST94XsA/edit>`_ |
|
||||
| | * `Consensys Diligence <https://github.com/ConsenSys/0x_audit_report_2018-07-23>`_ |
|
||||
+------------------+---------------------------------------------------------------------------------------------------------------+
|
||||
| MultiAssetProxy | * `Consensys Diligence <https://github.com/ConsenSys/0x-audit-report-2018-12>`__ |
|
||||
+------------------+---------------------------------------------------------------------------------------------------------------+
|
||||
| ERC1155Proxy | * `Consensys Diligence <https://github.com/ConsenSys/0x-audit-report-2019-05>`__ |
|
||||
+------------------+---------------------------------------------------------------------------------------------------------------+
|
||||
| StaticCallProxy | * No third-party audit. |
|
||||
+------------------+---------------------------------------------------------------------------------------------------------------+
|
||||
| ERC20BridgeProxy | * No third-party audit. |
|
||||
+------------------+---------------------------------------------------------------------------------------------------------------+
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
| **Release** | **Reports** |
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
| ERC721OrdersFeature | * `ABDK Consulting <https://s3.us-east-2.amazonaws.com/zeips.0x.org/audits/abdk-consulting/ABDK_0x_Solidity_v_1_0.pdf>`__ |
|
||||
| | |
|
||||
| | |
|
||||
| ERC1155OrdersFeature | |
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
| Exchange V4 | * `Consensys Diligence (December 2020) <https://consensys.net/diligence/audits/2020/12/0x-exchange-v4/>`__ |
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
| Exchange V3 | * `Trail of Bits <http://zeips.0x.org.s3-website.us-east-2.amazonaws.com/audits/56/trail-of-bits/audit.pdf>`__ |
|
||||
| | * `Consensys Diligence (Exchange) <https://diligence.consensys.net/audits/2019/09/0x-v3-exchange/>`__ |
|
||||
| | * `Consensys Diligence (Staking) <https://diligence.consensys.net/audits/2019/10/0x-v3-staking/>`__ |
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
| Exchange V2.1 | * `First <https://docs.google.com/document/d/1jYv6V21MfCSwCS5fxD6ZyaLWGzkpRSUO0lZpST94XsA/edit>`_ |
|
||||
| | * `Consensys Diligence <https://github.com/ConsenSys/0x_audit_report_2018-07-23>`_ |
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
| MultiAssetProxy | * `Consensys Diligence <https://github.com/ConsenSys/0x-audit-report-2018-12>`__ |
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
| ERC1155Proxy | * `Consensys Diligence <https://github.com/ConsenSys/0x-audit-report-2019-05>`__ |
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
| StaticCallProxy | * No third-party audit. |
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
| ERC20BridgeProxy | * No third-party audit. |
|
||||
+----------------------+---------------------------------------------------------------------------------------------------------------------------+
|
||||
|
@@ -2,47 +2,15 @@
|
||||
Bounties
|
||||
###############################
|
||||
|
||||
We run an ongoing bug bounty for the 0x Protocol smart contracts! The program is open to anyone and
|
||||
rewards up to **$100,000 for critical exploits**. The scope and disclosure instructions are below.
|
||||
|
||||
Rewards
|
||||
-------
|
||||
The severity of reported vulnerabilities will be graded according to the `CVSS <https://www.first.org/cvss/>`_ (Common Vulnerability Scoring Standard).
|
||||
The following table will serve as a guideline for reward decisions:
|
||||
The bug bounties on this page apply only to the *0x smart contracts* on Ethereum mainnet, Binance Smart Chain, Polygon, Avalanche, Fantom, Celo, Optimism and future deployments in other EVM-compatible networks announced through our official communication channels.
|
||||
|
||||
+----------------------------+---------------------+
|
||||
| **Exploit Score** | **Reward** |
|
||||
+----------------------------+---------------------+
|
||||
| Critical (CVSS 9.0 - 10.0) | $10,000 - $100,000 |
|
||||
+----------------------------+---------------------+
|
||||
| High (CVSS 7.0 - 8.9) | $2,500 - $10,000 |
|
||||
+----------------------------+---------------------+
|
||||
| Medium (CVSS 4.0 - 6.9) | $1,000 - $2,500 |
|
||||
+----------------------------+---------------------+
|
||||
| Low (CVSS 0.0 - 3.9) | $0 - $1,000 |
|
||||
+----------------------------+---------------------+
|
||||
Bug reports pertaining to 0x API and 0x web interfaces (e.g. Matcha, 0x.org), both in terms of UI/UX or servers/infrastructure, are not eligible. Only the first reporter of a given contract vulnerability will be rewarded, and findings already discovered as part of a formal audit are ineligible.
|
||||
|
||||
Please note that any rewards will ultimately be awarded at the discretion of ZeroEx Intl. All rewards will be paid out in ZRX.
|
||||
Overview
|
||||
--------
|
||||
|
||||
Areas of Interest
|
||||
-----------------
|
||||
|
||||
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| **Area** | **Examples** |
|
||||
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Loss of funds | * A user loses funds in a way that they did not explicitly authorize (e.g an account is able to gain access to an ``AssetProxy`` and drain user funds). |
|
||||
| | * A user authorized a transaction or trade but spends more assets than normally expected (e.g an order is allowed to be over-filled). |
|
||||
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Unintended contract state | * A user is able to update the state of a contract such that it is no longer useable (e.g permanently lock a mutex). |
|
||||
| | * Any assets get unexpectedly "stuck" in a contract with regular use of the contract's public methods. |
|
||||
| | * An action taken in the staking contracts is applied to an incorrect epoch. |
|
||||
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Bypassing time locks | * The ``ZeroExGovernor`` is allowed to bypass the timelock for transactions where it is not explicitly allowed to do so. |
|
||||
| | * A user is allowed to bypass the ``ZeroExGovernor``. |
|
||||
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Incorrect math | * Overflows or underflow result in unexpected behavior. |
|
||||
| | * The staking reward payouts are incorrect. |
|
||||
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
0x has completed smart contract audits with Consensys Diligence, Trail of Bits and ABDK. We run a continuous bug bounty program for the V4 release of the 0x core contracts.
|
||||
|
||||
Scope
|
||||
-----
|
||||
@@ -51,14 +19,14 @@ The following contracts are in scope of the bug bounty. Please note that any bug
|
||||
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| **Release** | **Contracts** | **Commit Hash** |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Exchange V4 | * Documentation at `https://0xprotocol.readthedocs.io/en/latest/ <https://0xprotocol.readthedocs.io/en/latest/>`__ | `72a74e7c66 <https://github.com/0xProject/protocol/tree/72a74e7c66e27da02dd9f4ce604ad057c740c304/contracts/zero-ex/contracts/src>`__ |
|
||||
| | * `ZeroEx.sol <https://github.com/0xProject/protocol/blob/72a74e7c66e27da02dd9f4ce604ad057c740c304/contracts/zero-ex/contracts/src/ZeroEx.sol>`__ | |
|
||||
| | * `ZeroExOptimized.sol <https://github.com/0xProject/protocol/blob/72a74e7c66e27da02dd9f4ce604ad057c740c304/contracts/zero-ex/contracts/src/ZeroExOptimized.sol>`__ | |
|
||||
| | * `external/*.sol <https://github.com/0xProject/protocol/tree/72a74e7c66e27da02dd9f4ce604ad057c740c304/contracts/zero-ex/contracts/src/external>`__ | |
|
||||
| | * `features/**.sol <https://github.com/0xProject/protocol/tree/72a74e7c66e27da02dd9f4ce604ad057c740c304/contracts/zero-ex/contracts/src/features>`__ | |
|
||||
| | * `fixins/*.sol <https://github.com/0xProject/protocol/tree/72a74e7c66e27da02dd9f4ce604ad057c740c304/contracts/zero-ex/contracts/src/fixins>`__ | |
|
||||
| | * `migrations/*.sol <https://github.com/0xProject/protocol/tree/72a74e7c66e27da02dd9f4ce604ad057c740c304/contracts/zero-ex/contracts/src/migrations>`__ | |
|
||||
| | * `storage/*.sol <https://github.com/0xProject/protocol/tree/72a74e7c66e27da02dd9f4ce604ad057c740c304/contracts/zero-ex/contracts/src/storage>`__ | |
|
||||
| Exchange V4 | * Documentation at `https://protocol.0x.org/en/latest/ <https://protocol.0x.org/en/latest/>`__ | `2cbeb9c <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src>`__ |
|
||||
| | * `ZeroEx.sol <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src/ZeroEx.sol>`__ | |
|
||||
| | * `ZeroExOptimized.sol <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src/ZeroExOptimized.sol>`__ | |
|
||||
| | * `external/*.sol <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src/external>`__ | |
|
||||
| | * `features/**.sol <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src/features>`__ | |
|
||||
| | * `fixins/*.sol <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src/fixins>`__ | |
|
||||
| | * `migrations/*.sol <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src/migrations>`__ | |
|
||||
| | * `storage/*.sol <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src/storage>`__ | |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Exchange V3 | * `ERC20BridgeProxy.sol <https://github.com/0xProject/0x-monorepo/blob/fb8360edfd4f42f2d2b127b95c156eb1b0daa02b/contracts/asset-proxy/contracts/src/ERC20BridgeProxy.sol>`_ (`spec <https://github.com/0xProject/0x-protocol-specification/blob/master/asset-proxy/erc20-bridge-proxy.md>`__) | `fb8360edfd <https://github.com/0xProject/0x-monorepo/tree/fb8360edfd4f42f2d2b127b95c156eb1b0daa02b/contracts>`__ |
|
||||
| | * `Exchange.sol <https://github.com/0xProject/0x-monorepo/blob/fb8360edfd4f42f2d2b127b95c156eb1b0daa02b/contracts/exchange/contracts/src/Exchange.sol>`__ (`spec <https://github.com/0xProject/0x-protocol-specification/blob/master/v3/v3-specification.md>`__) | |
|
||||
@@ -67,7 +35,7 @@ The following contracts are in scope of the bug bounty. Please note that any bug
|
||||
| | * `StakingProxy.sol <https://github.com/0xProject/0x-monorepo/blob/fb8360edfd4f42f2d2b127b95c156eb1b0daa02b/contracts/staking/contracts/src/StakingProxy.sol>`_ (`spec <https://github.com/0xProject/0x-protocol-specification/blob/master/staking/staking-specification.md>`__) | |
|
||||
| | * `ZrxVault.sol <https://github.com/0xProject/0x-monorepo/blob/fb8360edfd4f42f2d2b127b95c156eb1b0daa02b/contracts/staking/contracts/src/ZrxVault.sol>`_ (`spec <https://github.com/0xProject/0x-protocol-specification/blob/master/staking/staking-specification.md>`__) | |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| Exchange V2.1 | * `src/2.0.0/protocol <https://github.com/0xProject/0x-monorepo/tree/ff70c5ecfe28eff14e1a372c5e493b8f5363e1d0/packages/contracts/src/2.0.0/protocol>`_ | `ff70c5ecfe <https://github.com/0xProject/0x-monorepo/tree/ff70c5ecfe28eff14e1a372c5e493b8f5363e1d0/contracts>`_ |
|
||||
| Exchange V2.1 | * `src/2.0.0/protocol <https://github.com/0xProject/0x-monorepo/tree/ff70c5ecfe28eff14e1a372c5e493b8f5363e1d0/packages/contracts/src/2.0.0/protocol>`_ | `ff70c5ecfe <https://github.com/0xProject/0x-monorepo/tree/ff70c5ecfe28eff14e1a372c5e493b8f5363e1d0/packages/contracts/src/2.0.0>`_ |
|
||||
| | * `src/2.0.0/utils <https://github.com/0xProject/0x-monorepo/tree/ff70c5ecfe28eff14e1a372c5e493b8f5363e1d0/packages/contracts/src/2.0.0/utils>`_ | |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| MultiAssetProxy | * `MultiAssetProxy.sol <https://github.com/0xProject/0x-monorepo/blob/c4d9ef9f83508154fe9db35796b6b86aeb0f2240/contracts/asset-proxy/contracts/src/MultiAssetProxy.sol>`_ | `c4d9ef9f83 <https://github.com/0xProject/0x-monorepo/tree/c4d9ef9f83508154fe9db35796b6b86aeb0f2240/contracts>`_ |
|
||||
@@ -78,9 +46,37 @@ The following contracts are in scope of the bug bounty. Please note that any bug
|
||||
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| ERC20BridgeProxy | * `ERC20BridgeProxy.sol <https://github.com/0xProject/0x-monorepo/blob/281658ba349a2c5088b40b503998bea5020284a6/contracts/asset-proxy/contracts/src/ERC20BridgeProxy.sol>`__ | `281658ba34 <https://github.com/0xProject/0x-monorepo/tree/281658ba349a2c5088b40b503998bea5020284a6/contracts>`_ |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| ExchangeProxy | * `contracts/src <https://github.com/0xProject/0x-monorepo/tree/7967a8416c76e34ff5a0a4eb80e7b33ff8c0e297/contracts/zero-ex>`__ | `7967a8416c <https://github.com/0xProject/0x-monorepo/tree/7967a8416c76e34ff5a0a4eb80e7b33ff8c0e297/contracts>`_ |
|
||||
| ExchangeProxy | * `contracts/src <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src>`__ | `2cbeb9c <https://github.com/0xProject/protocol/tree/audit/nft-orders-address-findings/contracts/zero-ex/contracts/src>`_ |
|
||||
+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
Bounties
|
||||
--------
|
||||
The bounty program will pay out rewards according to the severity of a vulnerability. The severity of reported vulnerabilities will be graded according to the `CVSS <https://www.first.org/cvss/>`__ (Common Vulnerability Scoring Standard).
|
||||
|
||||
The final reward amount is at the sole discretion of 0x Labs and will be paid in the specified sum in either USD or ETH.
|
||||
|
||||
+----------------------------+---------------------+
|
||||
| **Exploit Score** | **Reward** |
|
||||
+----------------------------+---------------------+
|
||||
| Critical (CVSS 9.0 - 10.0) | up to $1,000,000 |
|
||||
+----------------------------+---------------------+
|
||||
| High (CVSS 7.0 - 8.9) | up to $350,000 |
|
||||
+----------------------------+---------------------+
|
||||
| Medium (CVSS 4.0 - 6.9) | up to $35,000 |
|
||||
+----------------------------+---------------------+
|
||||
| Low (CVSS 0.0 - 3.9) | up to $5,000 |
|
||||
+----------------------------+---------------------+
|
||||
|
||||
Recent Inclusions
|
||||
-----------------
|
||||
|
||||
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| **Change** | **** |
|
||||
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| NFT feature | * Trade ERC721 and ERC1155 assets. See `ZEIP-93 <https://github.com/0xProject/ZEIPs/issues/93>`__ for more details |
|
||||
+---------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
|
||||
Disclosures
|
||||
-----------
|
||||
Please e-mail all submissions to security@0x.org with the subject "BUG BOUNTY". Your submission
|
||||
|
@@ -17,3 +17,10 @@ Known tokens:
|
||||
- LINK
|
||||
- sUSD
|
||||
- USDT
|
||||
|
||||
Tokens with Fees on Transfer
|
||||
----------------------------
|
||||
These tokens do not follow the ERC20 specification. As such the protocol expects the transfer to transfer
|
||||
the specified amount, or revert. Since tokens with transfer fees do not meet this criteria, the behaviour
|
||||
of the protocol with these tokens is unspecified. In most cases it will result in an overall transaction failure
|
||||
due to various slippage protections.
|
@@ -17,10 +17,12 @@ This page outlines upcoming releases and expected changes.
|
||||
+---------------------------------------------+---------------------------------------------------------------+----------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| **Name** | **Overview** | **Est Release Date** | **Status** | **Additional** |
|
||||
+---------------------------------------------+---------------------------------------------------------------+----------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| `Amaretto`_ | Protocol 4.1: Efficiency + Batch Fills | 03/15/21 | Development | |
|
||||
| `Nifty`_ | ERC721 and ERC1155 support | 02/14/22 | Vote | |
|
||||
+---------------------------------------------+---------------------------------------------------------------+----------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| *The following releases have been deployed* | | | | |
|
||||
+---------------------------------------------+---------------------------------------------------------------+----------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| `Amaretto`_ | Protocol 4.1: Efficiency + Batch Fills | 03/15/21 | Deployed | |
|
||||
+---------------------------------------------+---------------------------------------------------------------+----------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| `Babooshka`_ | Connect Exchange Proxy to Staking | 02/08/21 | Deployed | `Release Notes <https://github.com/0xProject/0x-migrations/blob/main/src/exchange-proxy/migrations/log/9_babooshka.md>`__ |
|
||||
+---------------------------------------------+---------------------------------------------------------------+----------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| `Squire`_ | Aggregation for `V4 Orders <../basics/orders.html>`_ | 02/04/21 | Deployed | N/A |
|
||||
@@ -45,6 +47,19 @@ This page outlines upcoming releases and expected changes.
|
||||
Upcoming
|
||||
========
|
||||
|
||||
Nifty
|
||||
--------
|
||||
|
||||
- ERC721 and ERC1155 order types
|
||||
- Batch fills for NFT orders
|
||||
- Property based orders
|
||||
- Ability to receive ETH in NFT orders
|
||||
|
||||
|
||||
|
||||
Past
|
||||
=====
|
||||
|
||||
Amaretto
|
||||
--------
|
||||
|
||||
@@ -53,10 +68,6 @@ Amaretto
|
||||
- Mooniswap VIP
|
||||
- Curve / Swerve VIP (via PLP Sandbox)
|
||||
|
||||
|
||||
Past
|
||||
=====
|
||||
|
||||
Babooshka
|
||||
----------
|
||||
|
||||
|
@@ -57,18 +57,22 @@ Liquidity Aggregation
|
||||
|
||||
Liquidity can be pulled from other Decentralized Exchanges (DEX) to supplement native liquidity (0x orders). This is currently used by 0x API to provide the aggregate the best prices across the entire DEX Ecosystem. Check out `https://matcha.xyz <https://matcha.xyz>`_ to see this in action!
|
||||
|
||||
Supported DEX's:
|
||||
Below are just a few of the Supported DEX's on Ethereum:
|
||||
|
||||
* Balancer
|
||||
* Balancer v1/v2
|
||||
* Bancor v1/v2
|
||||
* Curve
|
||||
* DoDo
|
||||
* Dodo v1/v2
|
||||
* Kyber
|
||||
* MakerPSM
|
||||
* MStable
|
||||
* Mooniswap
|
||||
* Oasis
|
||||
* Shell
|
||||
* Sushiswap
|
||||
* Uniswap v1/v2
|
||||
* Shibaswap
|
||||
* Smoothy
|
||||
* Uniswap v1/v2/v3
|
||||
|
||||
This transformation is implemented by the `FillQuoteTransformer <../architecture/transformers.html>`_. Abi-Encode the following struct to get the ``data``:
|
||||
|
||||
|
@@ -6,16 +6,17 @@ Addresses
|
||||
.. note::
|
||||
This page is auto-generated. See the `contract-addresses <https://github.com/0xProject/protocol/blob/development/packages/contract-addresses/addresses.json>`_ package for an exhaustive list of contracts across all networks.
|
||||
|
||||
The Exchange Proxy may have different addresses on various networks, see the `Exchange Proxy Addresses <./addresses.html#exchange-proxy-addresses>`__ table for an exhaustive list.
|
||||
|
||||
Exchange V4
|
||||
===================
|
||||
.. csv-table::
|
||||
|
||||
exchangeProxy, `0xdef1c0ded9bec7f1a1670819833240f027b25eff <https://etherscan.io/address//0xdef1c0ded9bec7f1a1670819833240f027b25eff>`_
|
||||
exchangeProxyAllowanceTarget, `0xf740b67da229f2f10bcbd38a7979992fcc71b8eb <https://etherscan.io/address//0xf740b67da229f2f10bcbd38a7979992fcc71b8eb>`_
|
||||
exchangeProxyFlashWallet, `0x22f9dcf4647084d6c31b2765f6910cd85c178c18 <https://etherscan.io/address//0x22f9dcf4647084d6c31b2765f6910cd85c178c18>`_
|
||||
exchangeProxyGovernor, `0x618f9c67ce7bf1a50afa1e7e0238422601b0ff6e <https://etherscan.io/address//0x618f9c67ce7bf1a50afa1e7e0238422601b0ff6e>`_
|
||||
exchangeProxyLiquidityProviderSandbox, `0x407b4128e9ecad8769b2332312a9f655cb9f5f3a <https://etherscan.io/address//0x407b4128e9ecad8769b2332312a9f655cb9f5f3a>`_
|
||||
exchangeProxyTransformerDeployer, `0x39dce47a67ad34344eab877eae3ef1fa2a1d50bb <https://etherscan.io/address//0x39dce47a67ad34344eab877eae3ef1fa2a1d50bb>`_
|
||||
exchangeProxy, `0xdef1c0ded9bec7f1a1670819833240f027b25eff <https://etherscan.io/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff>`__
|
||||
exchangeProxyFlashWallet, `0x22f9dcf4647084d6c31b2765f6910cd85c178c18 <https://etherscan.io/address/0x22f9dcf4647084d6c31b2765f6910cd85c178c18>`__
|
||||
exchangeProxyGovernor, `0x618f9c67ce7bf1a50afa1e7e0238422601b0ff6e <https://etherscan.io/address/0x618f9c67ce7bf1a50afa1e7e0238422601b0ff6e>`__
|
||||
exchangeProxyLiquidityProviderSandbox, `0x407b4128e9ecad8769b2332312a9f655cb9f5f3a <https://etherscan.io/address/0x407b4128e9ecad8769b2332312a9f655cb9f5f3a>`__
|
||||
exchangeProxyTransformerDeployer, `0x39dce47a67ad34344eab877eae3ef1fa2a1d50bb <https://etherscan.io/address/0x39dce47a67ad34344eab877eae3ef1fa2a1d50bb>`__
|
||||
|
||||
|
||||
|
||||
@@ -23,10 +24,11 @@ Transformers
|
||||
===================
|
||||
.. csv-table::
|
||||
|
||||
wethTransformer, `0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7 <https://etherscan.io/address//0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7>`_
|
||||
payTakerTransformer, `0x4638a7ebe75b911b995d0ec73a81e4f85f41f24e <https://etherscan.io/address//0x4638a7ebe75b911b995d0ec73a81e4f85f41f24e>`_
|
||||
fillQuoteTransformer, `0x5ce5174d7442061135ea849970ffc7763920e0fd <https://etherscan.io/address//0x5ce5174d7442061135ea849970ffc7763920e0fd>`_
|
||||
affiliateFeeTransformer, `0xda6d9fc5998f550a094585cf9171f0e8ee3ac59f <https://etherscan.io/address//0xda6d9fc5998f550a094585cf9171f0e8ee3ac59f>`_
|
||||
wethTransformer, `0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7 <https://etherscan.io/address/0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7>`__
|
||||
payTakerTransformer, `0x4638a7ebe75b911b995d0ec73a81e4f85f41f24e <https://etherscan.io/address/0x4638a7ebe75b911b995d0ec73a81e4f85f41f24e>`__
|
||||
affiliateFeeTransformer, `0xda6d9fc5998f550a094585cf9171f0e8ee3ac59f <https://etherscan.io/address/0xda6d9fc5998f550a094585cf9171f0e8ee3ac59f>`__
|
||||
fillQuoteTransformer, `0xb4fa284689c9784a60d840eb136bb16c5246191f <https://etherscan.io/address/0xb4fa284689c9784a60d840eb136bb16c5246191f>`__
|
||||
positiveSlippageFeeTransformer, `0xa9416ce1dbde8d331210c07b5c253d94ee4cc3fd <https://etherscan.io/address/0xa9416ce1dbde8d331210c07b5c253d94ee4cc3fd>`__
|
||||
|
||||
|
||||
|
||||
@@ -34,10 +36,10 @@ ZRX / Staking
|
||||
===================
|
||||
.. csv-table::
|
||||
|
||||
staking, `0x2a17c35ff147b32f13f19f2e311446eeb02503f3 <https://etherscan.io/address//0x2a17c35ff147b32f13f19f2e311446eeb02503f3>`_
|
||||
stakingProxy, `0xa26e80e7dea86279c6d778d702cc413e6cffa777 <https://etherscan.io/address//0xa26e80e7dea86279c6d778d702cc413e6cffa777>`_
|
||||
zrxToken, `0xe41d2489571d322189246dafa5ebde1f4699f498 <https://etherscan.io/address//0xe41d2489571d322189246dafa5ebde1f4699f498>`_
|
||||
zrxVault, `0xba7f8b5fb1b19c1211c5d49550fcd149177a5eaf <https://etherscan.io/address//0xba7f8b5fb1b19c1211c5d49550fcd149177a5eaf>`_
|
||||
staking, `0x2a17c35ff147b32f13f19f2e311446eeb02503f3 <https://etherscan.io/address/0x2a17c35ff147b32f13f19f2e311446eeb02503f3>`__
|
||||
stakingProxy, `0xa26e80e7dea86279c6d778d702cc413e6cffa777 <https://etherscan.io/address/0xa26e80e7dea86279c6d778d702cc413e6cffa777>`__
|
||||
zrxToken, `0xe41d2489571d322189246dafa5ebde1f4699f498 <https://etherscan.io/address/0xe41d2489571d322189246dafa5ebde1f4699f498>`__
|
||||
zrxVault, `0xba7f8b5fb1b19c1211c5d49550fcd149177a5eaf <https://etherscan.io/address/0xba7f8b5fb1b19c1211c5d49550fcd149177a5eaf>`__
|
||||
|
||||
|
||||
|
||||
@@ -45,9 +47,22 @@ Miscellaneous
|
||||
===================
|
||||
.. csv-table::
|
||||
|
||||
devUtils, `0x74134cf88b21383713e096a5ecf59e297dc7f547 <https://etherscan.io/address//0x74134cf88b21383713e096a5ecf59e297dc7f547>`_
|
||||
etherToken, `0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 <https://etherscan.io/address//0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2>`_
|
||||
erc20BridgeSampler, `0xd8c38704c9937ea3312de29f824b4ad3450a5e61 <https://etherscan.io/address//0xd8c38704c9937ea3312de29f824b4ad3450a5e61>`_
|
||||
devUtils, `0x74134cf88b21383713e096a5ecf59e297dc7f547 <https://etherscan.io/address/0x74134cf88b21383713e096a5ecf59e297dc7f547>`__
|
||||
etherToken, `0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 <https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2>`__
|
||||
erc20BridgeSampler, `0xd8c38704c9937ea3312de29f824b4ad3450a5e61 <https://etherscan.io/address/0xd8c38704c9937ea3312de29f824b4ad3450a5e61>`__
|
||||
|
||||
|
||||
|
||||
Exchange Proxy Addresses
|
||||
=========================
|
||||
Note: Some addresses have changed across various networks
|
||||
|
||||
.. csv-table::
|
||||
|
||||
Ethereum, `0xdef1c0ded9bec7f1a1670819833240f027b25eff <https://etherscan.io/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff>`__
|
||||
Optimism, `0xdef1abe32c034e558cdd535791643c58a13acc10 <https://optimistic.etherscan.io/address/0xdef1abe32c034e558cdd535791643c58a13acc10>`__
|
||||
Binance Smart Chain, `0xdef1c0ded9bec7f1a1670819833240f027b25eff <https://bscscan.com/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff>`__
|
||||
Polygon, `0xdef1c0ded9bec7f1a1670819833240f027b25eff <https://polygonscan.com/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff>`__
|
||||
Avalanche, `0xdef1c0ded9bec7f1a1670819833240f027b25eff <https://snowtrace.io/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff>`__
|
||||
Fantom, `0xdef189deaef76e379df891899eb5a00a94cbc250 <https://ftmscan.com/address/0xdef189deaef76e379df891899eb5a00a94cbc250>`__
|
||||
Celo, `0xdef1c0ded9bec7f1a1670819833240f027b25eff <https://explorer.celo.org/address/0xdef1c0ded9bec7f1a1670819833240f027b25eff>`__
|
||||
|
@@ -2,6 +2,4 @@
|
||||
Allowances
|
||||
###############################
|
||||
|
||||
Both maker and taker allowance should be be set directly on the `Exchange Proxy contract <./addresses.html#exchange-v4>`_.
|
||||
|
||||
For takers, legacy allowances set on the `Allowance Target <./addresses.html#exchange-v4>`_ will continue to work during this transition period but will suffer a gas penalty. It's highly encouraged to migrate allowances over to the Exchange Proxy as soon as possible to avoid interruption.
|
||||
Both maker and taker allowance should be be set directly on the `Exchange Proxy contract <./addresses.html#exchange-proxy-addresses>`_.
|
||||
|
@@ -61,6 +61,18 @@ illustrates how events are emitted when trading through the Exchange Proxy.
|
||||
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
|
||||
| `TransformerMetadata`_ | A general, customizable event emitted that can be emitted by transformers as-needed. | FlashWallet |
|
||||
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
|
||||
| `ERC1155OrderFilled`_ | Emitted when a `V4 ERC1155 Order <./orders.html#erc1155-orders>`_ is filled. | ExchangeProxy |
|
||||
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
|
||||
| `ERC721OrderFilled`_ | Emitted when a `V4 ERC721 Order <./orders.html#erc721-orders>`_ is filled. | ExchangeProxy |
|
||||
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
|
||||
| `ERC1155OrderCancelled`_ | Emitted when a `V4 ERC1155 Order <./orders.html#erc1155-orders>`_ is cancelled. | ExchangeProxy |
|
||||
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
|
||||
| `ERC721OrderCancelled`_ | Emitted when a `V4 ERC721 Order <./orders.html#erc721-orders>`_ is cancelled. | ExchangeProxy |
|
||||
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
|
||||
| `ERC1155OrderPreSigned`_ | Emitted when a `V4 ERC1155 Order <./orders.html#erc1155-orders>`_ is signed on-chain. | ExchangeProxy |
|
||||
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
|
||||
| `ERC721OrderPreSigned`_ | Emitted when a `V4 ERC721 Order <./orders.html#erc721-orders>`_ is signed on-chain. | ExchangeProxy |
|
||||
+-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+
|
||||
|
||||
|
||||
Deployed
|
||||
@@ -374,6 +386,143 @@ TransformerMetadata
|
||||
);
|
||||
|
||||
|
||||
ERC721OrderFilled
|
||||
-------------------
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Emitted whenever an `ERC721Order` is filled.
|
||||
/// @param direction Whether the order is selling or
|
||||
/// buying the ERC721 token.
|
||||
/// @param maker The maker of the order.
|
||||
/// @param taker The taker of the order.
|
||||
/// @param nonce The unique maker nonce in the order.
|
||||
/// @param erc20Token The address of the ERC20 token.
|
||||
/// @param erc20TokenAmount The amount of ERC20 token
|
||||
/// to sell or buy.
|
||||
/// @param erc721Token The address of the ERC721 token.
|
||||
/// @param erc721TokenId The ID of the ERC721 asset.
|
||||
/// @param matcher If this order was matched with another using `matchERC721Orders()`,
|
||||
/// this will be the address of the caller. If not, this will be `address(0)`.
|
||||
event ERC721OrderFilled(
|
||||
LibNFTOrder.TradeDirection direction,
|
||||
address maker,
|
||||
address taker,
|
||||
uint256 nonce,
|
||||
IERC20TokenV06 erc20Token,
|
||||
uint256 erc20TokenAmount,
|
||||
IERC721Token erc721Token,
|
||||
uint256 erc721TokenId,
|
||||
address matcher
|
||||
);
|
||||
|
||||
ERC721OrderCancelled
|
||||
---------------------
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Emitted whenever an `ERC721Order` is cancelled.
|
||||
/// @param maker The maker of the order.
|
||||
/// @param nonce The nonce of the order that was cancelled.
|
||||
event ERC721OrderCancelled(
|
||||
address maker,
|
||||
uint256 nonce
|
||||
);
|
||||
|
||||
ERC721OrderPreSigned
|
||||
---------------------
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
|
||||
/// @dev Emitted when an `ERC721Order` is pre-signed.
|
||||
/// Contains all the fields of the order.
|
||||
event ERC721OrderPreSigned(
|
||||
LibNFTOrder.TradeDirection direction,
|
||||
address maker,
|
||||
address taker,
|
||||
uint256 expiry,
|
||||
uint256 nonce,
|
||||
IERC20TokenV06 erc20Token,
|
||||
uint256 erc20TokenAmount,
|
||||
LibNFTOrder.Fee[] fees,
|
||||
IERC721Token erc721Token,
|
||||
uint256 erc721TokenId,
|
||||
LibNFTOrder.Property[] erc721TokenProperties
|
||||
);
|
||||
|
||||
ERC1155OrderFilled
|
||||
-------------------
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Emitted whenever an `ERC1155Order` is filled.
|
||||
/// @param direction Whether the order is selling or
|
||||
/// buying the ERC1155 token.
|
||||
/// @param maker The maker of the order.
|
||||
/// @param taker The taker of the order.
|
||||
/// @param nonce The unique maker nonce in the order.
|
||||
/// @param erc20Token The address of the ERC20 token.
|
||||
/// @param erc20FillAmount The amount of ERC20 token filled.
|
||||
/// @param erc1155Token The address of the ERC1155 token.
|
||||
/// @param erc1155TokenId The ID of the ERC1155 asset.
|
||||
/// @param erc1155FillAmount The amount of ERC1155 asset filled.
|
||||
/// @param matcher Currently unused.
|
||||
event ERC1155OrderFilled(
|
||||
LibNFTOrder.TradeDirection direction,
|
||||
address maker,
|
||||
address taker,
|
||||
uint256 nonce,
|
||||
IERC20TokenV06 erc20Token,
|
||||
uint256 erc20FillAmount,
|
||||
IERC1155Token erc1155Token,
|
||||
uint256 erc1155TokenId,
|
||||
uint128 erc1155FillAmount,
|
||||
address matcher
|
||||
);
|
||||
|
||||
ERC1155OrderCancelled
|
||||
---------------------
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Emitted whenever an `ERC1155Order` is cancelled.
|
||||
/// @param orderHash The hash the order.
|
||||
/// @param maker The maker of the order.
|
||||
event ERC1155OrderCancelled(
|
||||
bytes32 orderHash,
|
||||
address maker
|
||||
);
|
||||
|
||||
ERC1155OrderPreSigned
|
||||
---------------------
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Emitted when an `ERC1155Order` is pre-signed.
|
||||
/// Contains all the fields of the order.
|
||||
event ERC1155OrderPreSigned(
|
||||
LibNFTOrder.TradeDirection direction,
|
||||
address maker,
|
||||
address taker,
|
||||
uint256 expiry,
|
||||
uint256 nonce,
|
||||
IERC20TokenV06 erc20Token,
|
||||
uint256 erc20TokenAmount,
|
||||
LibNFTOrder.Fee[] fees,
|
||||
IERC1155Token erc1155Token,
|
||||
uint256 erc1155TokenId,
|
||||
LibNFTOrder.Property[] erc1155TokenProperties,
|
||||
uint128 erc1155TokenAmount
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -67,6 +67,46 @@ Below is a catalog of basic Exchange functionality. For more advanced usage, lik
|
||||
| `transferProtocolFeesForPools`_ | Transfers protocol fees from escrow to the 0x Staking System. |
|
||||
| | This should be called near the end of each epoch. |
|
||||
+-----------------------------------------+--------------------------------------------------------------------------+
|
||||
| **NFT Orders** | **Overview** |
|
||||
+-----------------------------------------+--------------------------------------------------------------------------+
|
||||
| `sellERC721`_ | These are specialised orders for NFT trading |
|
||||
+-----------------------------------------+ |
|
||||
| `buyERC721`_ | |
|
||||
+-----------------------------------------+ |
|
||||
| `batchBuyERC721s`_ | |
|
||||
+-----------------------------------------+ |
|
||||
| `matchERC721Orders`_ | |
|
||||
+-----------------------------------------+ |
|
||||
| `batchMatchERC721Orders`_ | |
|
||||
+-----------------------------------------+ |
|
||||
| `preSignERC721Order`_ | |
|
||||
+-----------------------------------------+ |
|
||||
| `validateERC721OrderSignature`_ | |
|
||||
+-----------------------------------------+ |
|
||||
| `validateERC721OrderProperties`_ | |
|
||||
+-----------------------------------------+ |
|
||||
| `getERC721OrderStatus`_ | |
|
||||
+-----------------------------------------+ |
|
||||
| `getERC721OrderHash`_ | |
|
||||
+-----------------------------------------+ +
|
||||
| `sellERC1155`_ | |
|
||||
+-----------------------------------------+ +
|
||||
| `buyERC1155`_ | |
|
||||
+-----------------------------------------+ +
|
||||
| `batchCancelERC1155Orders`_ | |
|
||||
+-----------------------------------------+ +
|
||||
| `batchBuyERC1155s`_ | |
|
||||
+-----------------------------------------+ +
|
||||
| `preSignERC1155Order`_ | |
|
||||
+-----------------------------------------+ +
|
||||
| `validateERC1155OrderSignature`_ | |
|
||||
+-----------------------------------------+ +
|
||||
| `validateERC1155OrderProperties`_ | |
|
||||
+-----------------------------------------+ +
|
||||
| `getERC1155OrderInfo`_ | |
|
||||
+-----------------------------------------+ +
|
||||
| `getERC1155OrderHash`_ | |
|
||||
+-----------------------------------------+--------------------------------------------------------------------------+
|
||||
|
||||
|
||||
Limit Orders
|
||||
@@ -733,3 +773,490 @@ This function transfers protocol fees from `Fee Collectors <../architecture/fee_
|
||||
/// @param poolIds Staking pool IDs
|
||||
function transferProtocolFeesForPools(bytes32[] calldata poolIds)
|
||||
external;
|
||||
|
||||
|
||||
|
||||
NFT Orders
|
||||
==========
|
||||
|
||||
|
||||
sellERC721
|
||||
----------------------------
|
||||
|
||||
This function sells an ERC721 token given a buy order.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Sells an ERC721 asset to fill the given order.
|
||||
/// @param buyOrder The ERC721 buy order.
|
||||
/// @param signature The order signature from the maker.
|
||||
/// @param erc721TokenId The ID of the ERC721 asset being
|
||||
/// sold. If the given order specifies properties,
|
||||
/// the asset must satisfy those properties. Otherwise,
|
||||
/// it must equal the tokenId in the order.
|
||||
/// @param unwrapNativeToken If this parameter is true and the
|
||||
/// ERC20 token of the order is e.g. WETH, unwraps the
|
||||
/// token before transferring it to the taker.
|
||||
/// @param callbackData If this parameter is non-zero, invokes
|
||||
/// `zeroExERC721OrderCallback` on `msg.sender` after
|
||||
/// the ERC20 tokens have been transferred to `msg.sender`
|
||||
/// but before transferring the ERC721 asset to the buyer.
|
||||
function sellERC721(
|
||||
LibNFTOrder.ERC721Order _calldata_ buyOrder,
|
||||
LibSignature.Signature _calldata_ signature,
|
||||
uint256 erc721TokenId,
|
||||
bool unwrapNativeToken,
|
||||
bytes _calldata_ callbackData
|
||||
)
|
||||
_external_;
|
||||
|
||||
|
||||
buyERC721
|
||||
----------------------------
|
||||
|
||||
This function buys an ERC721 token given a sell order.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
|
||||
/// @dev Buys an ERC721 asset by filling the given order.
|
||||
/// @param sellOrder The ERC721 sell order.
|
||||
/// @param signature The order signature.
|
||||
/// @param callbackData If this parameter is non-zero, invokes
|
||||
/// `zeroExERC721OrderCallback` on `msg.sender` after
|
||||
/// the ERC721 asset has been transferred to `msg.sender`
|
||||
/// but before transferring the ERC20 tokens to the seller.
|
||||
/// Native tokens acquired during the callback can be used
|
||||
/// to fill the order.
|
||||
function buyERC721(
|
||||
LibNFTOrder.ERC721Order _calldata_ sellOrder,
|
||||
LibSignature.Signature _calldata_ signature,
|
||||
bytes _calldata_ callbackData
|
||||
)
|
||||
_external_
|
||||
_payable_;
|
||||
|
||||
|
||||
cancelERC721Order
|
||||
----------------------------
|
||||
|
||||
This function cancels an ERC721 order using the order `nonce` field.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Cancel a single ERC721 order by its nonce. The caller
|
||||
/// should be the maker of the order. Silently succeeds if
|
||||
/// an order with the same nonce has already been filled or
|
||||
/// cancelled.
|
||||
/// @param orderNonce The order nonce.
|
||||
function cancelERC721Order(uint256 orderNonce)
|
||||
_external_;
|
||||
|
||||
|
||||
batchCancelERC721Orders
|
||||
----------------------------
|
||||
|
||||
This function cancels an number of ERC721 order using the order `nonce` field.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Cancel multiple ERC721 orders by their nonces. The caller
|
||||
/// should be the maker of the orders. Silently succeeds if
|
||||
/// an order with the same nonce has already been filled or
|
||||
/// cancelled.
|
||||
/// @param orderNonces The order nonces.
|
||||
function batchCancelERC721Orders(uint256[] _calldata_ orderNonces)
|
||||
_external_;
|
||||
|
||||
batchBuyERC721s
|
||||
----------------------------
|
||||
|
||||
This function buys a number of ERC721's. If you wish the transaction to revert unless ALL NFT's are purchased, set `revertIfIncomplete` to true.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Buys multiple ERC721 assets by filling the
|
||||
/// given orders.
|
||||
/// @param sellOrders The ERC721 sell orders.
|
||||
/// @param signatures The order signatures.
|
||||
/// @param revertIfIncomplete If true, reverts if this
|
||||
/// function fails to fill any individual order.
|
||||
/// @return successes An array of booleans corresponding to whether
|
||||
/// each order in `orders` was successfully filled.
|
||||
function batchBuyERC721s(
|
||||
LibNFTOrder.ERC721Order[] _calldata_ sellOrders,
|
||||
LibSignature.Signature[] _calldata_ signatures,
|
||||
bool revertIfIncomplete
|
||||
)
|
||||
_external_
|
||||
_payable_
|
||||
returns (bool[] _memory_ successes);
|
||||
|
||||
matchERC721Orders
|
||||
----------------------------
|
||||
|
||||
This function matches a buy order and a sell order together. The matcher receives any spread in price.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Matches a pair of complementary orders that have
|
||||
/// a non-negative spread. Each order is filled at
|
||||
/// their respective price, and the matcher receives
|
||||
/// a profit denominated in the ERC20 token.
|
||||
/// @param sellOrder Order selling an ERC721 asset.
|
||||
/// @param buyOrder Order buying an ERC721 asset.
|
||||
/// @param sellOrderSignature Signature for the sell order.
|
||||
/// @param buyOrderSignature Signature for the buy order.
|
||||
/// @return profit The amount of profit earned by the caller
|
||||
/// of this function (denominated in the ERC20 token
|
||||
/// of the matched orders).
|
||||
function matchERC721Orders(
|
||||
LibNFTOrder.ERC721Order _calldata_ sellOrder,
|
||||
LibNFTOrder.ERC721Order _calldata_ buyOrder,
|
||||
LibSignature.Signature _calldata_ sellOrderSignature,
|
||||
LibSignature.Signature _calldata_ buyOrderSignature
|
||||
)
|
||||
_external_
|
||||
returns (uint256 profit);
|
||||
|
||||
|
||||
batchMatchERC721Orders
|
||||
----------------------------
|
||||
|
||||
This function matches a buy orders and a sell orders together. The matcher receives any spread in price.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Matches pairs of complementary orders that have
|
||||
/// non-negative spreads. Each order is filled at
|
||||
/// their respective price, and the matcher receives
|
||||
/// a profit denominated in the ERC20 token.
|
||||
/// @param sellOrders Orders selling ERC721 assets.
|
||||
/// @param buyOrders Orders buying ERC721 assets.
|
||||
/// @param sellOrderSignatures Signatures for the sell orders.
|
||||
/// @param buyOrderSignatures Signatures for the buy orders.
|
||||
/// @return profits The amount of profit earned by the caller
|
||||
/// of this function for each pair of matched orders
|
||||
/// (denominated in the ERC20 token of the order pair).
|
||||
/// @return successes An array of booleans corresponding to
|
||||
/// whether each pair of orders was successfully matched.
|
||||
function batchMatchERC721Orders(
|
||||
LibNFTOrder.ERC721Order[] _calldata_ sellOrders,
|
||||
LibNFTOrder.ERC721Order[] _calldata_ buyOrders,
|
||||
LibSignature.Signature[] _calldata_ sellOrderSignatures,
|
||||
LibSignature.Signature[] _calldata_ buyOrderSignatures
|
||||
)
|
||||
_external_
|
||||
returns (uint256[] _memory_ profits, bool[] _memory_ successes);
|
||||
|
||||
|
||||
preSignERC721Order
|
||||
----------------------------
|
||||
|
||||
This function pre-signs an order. Useful for contracts that wish to buy or sell an NFT.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Approves an ERC721 order on-chain. After pre-signing
|
||||
/// the order, the `PRESIGNED` signature type will become
|
||||
/// valid for that order and signer.
|
||||
/// @param order An ERC721 order.
|
||||
function preSignERC721Order(LibNFTOrder.ERC721Order _calldata_ order)
|
||||
_external_;
|
||||
|
||||
validateERC721OrderSignature
|
||||
----------------------------
|
||||
|
||||
A read function to validate an ERC721 order signature.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Checks whether the given signature is valid for the
|
||||
/// the given ERC721 order. Reverts if not.
|
||||
/// @param order The ERC721 order.
|
||||
/// @param signature The signature to validate.
|
||||
function validateERC721OrderSignature(
|
||||
LibNFTOrder.ERC721Order _calldata_ order,
|
||||
LibSignature.Signature _calldata_ signature
|
||||
)
|
||||
_external_
|
||||
_view_;
|
||||
|
||||
|
||||
validateERC721OrderProperties
|
||||
---------------------------------
|
||||
|
||||
A read function to validate a property based order with a particular token id.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev If the given order is buying an ERC721 asset, checks
|
||||
/// whether or not the given token ID satisfies the required
|
||||
/// properties specified in the order. If the order does not
|
||||
/// specify any properties, this function instead checks
|
||||
/// whether the given token ID matches the ID in the order.
|
||||
/// Reverts if any checks fail, or if the order is selling
|
||||
/// an ERC721 asset.
|
||||
/// @param order The ERC721 order.
|
||||
/// @param erc721TokenId The ID of the ERC721 asset.
|
||||
function validateERC721OrderProperties(
|
||||
LibNFTOrder.ERC721Order _calldata_ order,
|
||||
uint256 erc721TokenId
|
||||
)
|
||||
_external_
|
||||
_view_;
|
||||
|
||||
|
||||
getERC721OrderStatus
|
||||
----------------------------
|
||||
|
||||
A read function to return the order status. E.g whether it is filled, cancelled or expired.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Get the current status of an ERC721 order.
|
||||
/// @param order The ERC721 order.
|
||||
/// @return status The status of the order.
|
||||
function getERC721OrderStatus(LibNFTOrder.ERC721Order _calldata_ order)
|
||||
_external_
|
||||
_view_
|
||||
returns (LibNFTOrder.OrderStatus status);
|
||||
|
||||
|
||||
getERC721OrderHash
|
||||
----------------------------
|
||||
|
||||
A read function to return the uniquie order hash.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Get the canonical hash of an ERC721 order.
|
||||
/// @param order The ERC721 order.
|
||||
/// @return orderHash The order hash.
|
||||
function getERC721OrderHash(LibNFTOrder.ERC721Order _calldata_ order)
|
||||
_external_
|
||||
_view_
|
||||
returns (bytes32 orderHash);
|
||||
|
||||
getERC721OrderStatusBitVector
|
||||
---------------------------------
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Get the order status bit vector for the given
|
||||
/// maker address and nonce range.
|
||||
/// @param maker The maker of the order.
|
||||
/// @param nonceRange Order status bit vectors are indexed
|
||||
/// by maker address and the upper 248 bits of the
|
||||
/// order nonce. We define `nonceRange` to be these
|
||||
/// 248 bits.
|
||||
/// @return bitVector The order status bit vector for the
|
||||
/// given maker and nonce range.
|
||||
function getERC721OrderStatusBitVector(address maker, uint248 nonceRange)
|
||||
_external_
|
||||
_view_
|
||||
returns (uint256 bitVector);
|
||||
|
||||
sellERC1155
|
||||
----------------------------
|
||||
|
||||
Sells an ERC115 token given a buy order.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Sells an ERC1155 asset to fill the given order.
|
||||
/// @param buyOrder The ERC1155 buy order.
|
||||
/// @param signature The order signature from the maker.
|
||||
/// @param erc1155TokenId The ID of the ERC1155 asset being
|
||||
/// sold. If the given order specifies properties,
|
||||
/// the asset must satisfy those properties. Otherwise,
|
||||
/// it must equal the tokenId in the order.
|
||||
/// @param erc1155SellAmount The amount of the ERC1155 asset
|
||||
/// to sell.
|
||||
/// @param unwrapNativeToken If this parameter is true and the
|
||||
/// ERC20 token of the order is e.g. WETH, unwraps the
|
||||
/// token before transferring it to the taker.
|
||||
/// @param callbackData If this parameter is non-zero, invokes
|
||||
/// `zeroExERC1155OrderCallback` on `msg.sender` after
|
||||
/// the ERC20 tokens have been transferred to `msg.sender`
|
||||
/// but before transferring the ERC1155 asset to the buyer.
|
||||
function sellERC1155(
|
||||
LibNFTOrder.ERC1155Order _calldata_ buyOrder,
|
||||
LibSignature.Signature _calldata_ signature,
|
||||
uint256 erc1155TokenId,
|
||||
uint128 erc1155SellAmount,
|
||||
bool unwrapNativeToken,
|
||||
bytes _calldata_ callbackData
|
||||
)
|
||||
_external_;
|
||||
|
||||
|
||||
buyERC1155
|
||||
----------------------------
|
||||
|
||||
Buys an ERC115 token given a sell order.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Buys an ERC1155 asset by filling the given order.
|
||||
/// @param sellOrder The ERC1155 sell order.
|
||||
/// @param signature The order signature.
|
||||
/// @param erc1155BuyAmount The amount of the ERC1155 asset
|
||||
/// to buy.
|
||||
/// @param callbackData If this parameter is non-zero, invokes
|
||||
/// `zeroExERC1155OrderCallback` on `msg.sender` after
|
||||
/// the ERC1155 asset has been transferred to `msg.sender`
|
||||
/// but before transferring the ERC20 tokens to the seller.
|
||||
/// Native tokens acquired during the callback can be used
|
||||
/// to fill the order.
|
||||
function buyERC1155(
|
||||
LibNFTOrder.ERC1155Order _calldata_ sellOrder,
|
||||
LibSignature.Signature _calldata_ signature,
|
||||
uint128 erc1155BuyAmount,
|
||||
bytes _calldata_ callbackData
|
||||
)
|
||||
_external_
|
||||
_payable_;
|
||||
|
||||
|
||||
cancelERC1155Order
|
||||
----------------------------
|
||||
|
||||
Cancels an ERC115 order given the order struct.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Cancel a single ERC1155 order. The caller should be the
|
||||
/// maker of the order. Silently succeeds if the order has
|
||||
/// already been filled or cancelled.
|
||||
/// @param order The order to cancel.
|
||||
function cancelERC1155Order(LibNFTOrder.ERC1155Order _calldata_ order)
|
||||
_external_;
|
||||
|
||||
batchCancelERC1155Orders
|
||||
----------------------------
|
||||
|
||||
Cancels a number of ERC115 orders.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Cancel multiple ERC1155 orders. The caller should be the
|
||||
/// maker of the orders. Silently succeeds if an order has
|
||||
/// already been filled or cancelled.
|
||||
/// @param orders The orders to cancel.
|
||||
function batchCancelERC1155Orders(LibNFTOrder.ERC1155Order[] _calldata_ orders)
|
||||
_external_;
|
||||
|
||||
batchBuyERC1155s
|
||||
----------------------------
|
||||
|
||||
Buys multiple ERC1155 assets given the sell orders.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Buys multiple ERC1155 assets by filling the
|
||||
/// given orders.
|
||||
/// @param sellOrders The ERC1155 sell orders.
|
||||
/// @param signatures The order signatures.
|
||||
/// @param erc1155TokenAmounts The amounts of the ERC1155 assets
|
||||
/// to buy for each order.
|
||||
/// @param revertIfIncomplete If true, reverts if this
|
||||
/// function fails to fill any individual order.
|
||||
/// @return successes An array of booleans corresponding to whether
|
||||
/// each order in `orders` was successfully filled.
|
||||
function batchBuyERC1155s(
|
||||
LibNFTOrder.ERC1155Order[] _calldata_ sellOrders,
|
||||
LibSignature.Signature[] _calldata_ signatures,
|
||||
uint128[] _calldata_ erc1155TokenAmounts,
|
||||
bool revertIfIncomplete
|
||||
)
|
||||
_external_
|
||||
_payable_
|
||||
returns (bool[] _memory_ successes);
|
||||
|
||||
preSignERC1155Order
|
||||
----------------------------
|
||||
|
||||
Pre-signs the order on-chain. This is useful for smart contracts.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Approves an ERC1155 order on-chain. After pre-signing
|
||||
/// the order, the `PRESIGNED` signature type will become
|
||||
/// valid for that order and signer.
|
||||
/// @param order An ERC1155 order.
|
||||
function preSignERC1155Order(LibNFTOrder.ERC1155Order _calldata_ order)
|
||||
_external_;
|
||||
|
||||
|
||||
validateERC1155OrderSignature
|
||||
---------------------------------
|
||||
|
||||
A read function to validate the ERC1155 order signatures.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Checks whether the given signature is valid for the
|
||||
/// the given ERC1155 order. Reverts if not.
|
||||
/// @param order The ERC1155 order.
|
||||
/// @param signature The signature to validate.
|
||||
function validateERC1155OrderSignature(
|
||||
LibNFTOrder.ERC1155Order calldata order,
|
||||
LibSignature.Signature calldata signature
|
||||
)
|
||||
external
|
||||
view;
|
||||
|
||||
|
||||
validateERC1155OrderProperties
|
||||
---------------------------------
|
||||
|
||||
A read function to validate the specific ERC1155 asset against a property based order.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev If the given order is buying an ERC1155 asset, checks
|
||||
/// whether or not the given token ID satisfies the required
|
||||
/// properties specified in the order. If the order does not
|
||||
/// specify any properties, this function instead checks
|
||||
/// whether the given token ID matches the ID in the order.
|
||||
/// Reverts if any checks fail, or if the order is selling
|
||||
/// an ERC1155 asset.
|
||||
/// @param order The ERC1155 order.
|
||||
/// @param erc1155TokenId The ID of the ERC1155 asset.
|
||||
function validateERC1155OrderProperties(
|
||||
LibNFTOrder.ERC1155Order calldata order,
|
||||
uint256 erc1155TokenId
|
||||
)
|
||||
external
|
||||
view;
|
||||
|
||||
getERC1155OrderInfo
|
||||
----------------------------
|
||||
|
||||
A read function to get the ERC1155 order info. Such as whether it has been cancelled, expired or filled.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Get the order info for an ERC1155 order.
|
||||
/// @param order The ERC1155 order.
|
||||
/// @return orderInfo Infor about the order.
|
||||
function getERC1155OrderInfo(LibNFTOrder.ERC1155Order calldata order)
|
||||
external
|
||||
view
|
||||
returns (LibNFTOrder.OrderInfo memory orderInfo);
|
||||
|
||||
getERC1155OrderHash
|
||||
----------------------------
|
||||
|
||||
A read function to calculate the unique order hash.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Get the canonical hash of an ERC1155 order.
|
||||
/// @param order The ERC1155 order.
|
||||
/// @return orderHash The order hash.
|
||||
function getERC1155OrderHash(LibNFTOrder.ERC1155Order calldata order)
|
||||
external
|
||||
view
|
||||
returns (bytes32 orderHash);
|
@@ -89,10 +89,160 @@ The ``RFQOrder`` struct has the following fields:
|
||||
+-----------------+-------------+----------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
|
||||
NFT Orders
|
||||
===========
|
||||
|
||||
NFT orders in 0x V4 are optimized for this specific use case. They are up to 54% cheaper than alternatives currently on Ethereum.
|
||||
Unlike 0x Limit orders, there is a `direction` of the trade, either buy or sell. ERC20's can be exchanged for either ERC721 or ERC1155.
|
||||
|
||||
Property based orders can also be created by specifying the properties field in the respective order.
|
||||
|
||||
A number of fees can be embedded in the order.
|
||||
|
||||
`NFT Swap SDK <https://docs.swapsdk.xyz/0x-v4>`__ is a friendly library that will help you easily create and consume NFT orders in 0x V4. You can find their `documentation here <https://docs.swapsdk.xyz/0x-v4>`__.
|
||||
|
||||
|
||||
ERC721 Orders
|
||||
*************
|
||||
|
||||
The ``ERC721Order`` struct has the following fields:
|
||||
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| Field | Type | Description |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``direction`` | ``enum`` | The trade direction, either sell the NFT or buy the NFT |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``maker`` | ``address`` | The address of the maker, and signer, of this order. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``taker`` | ``address`` | Allowed taker address. Set to zero to allow any taker. [optional; default 0] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``expiry`` | ``uint256`` | The Unix timestamp in seconds when this order expires. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``nonce`` | ``uint256`` | Number used to uniquiely represent this order. Used for cancellations. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc20Token`` | ``address`` | The ERC20 token used to pay for the ERC721 token. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc20TokenAmount`` | ``uint256`` | The amount of erc20Token being sold. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``fees`` | ``Fees[]`` | An array of structs containing the fee data [optional] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc721Token`` | ``address`` | The ERC721 token. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc721TokenId`` | ``uint256`` | The ERC721 token id. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc721TokenProperties`` | ``Property[]`` | Properties to validate for a property based order. [optional] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
|
||||
ERC1155 Orders
|
||||
***************
|
||||
|
||||
The ``ERC1155Order`` struct has the following fields:
|
||||
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| Field | Type | Description |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``direction`` | ``enum`` | The trade direction, either sell the NFT or buy the NFT |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``maker`` | ``address`` | The address of the maker, and signer, of this order. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``taker`` | ``address`` | Allowed taker address. Set to zero to allow any taker. [optional; default 0] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``expiry`` | ``uint256`` | The Unix timestamp in seconds when this order expires. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``nonce`` | ``uint256`` | Number used to uniquiely represent this order. Used for cancellations. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc20Token`` | ``address`` | The ERC20 token used to pay for the ERC721 token. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc20TokenAmount`` | ``uint256`` | The amount of erc20Token being sold. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``fees`` | ``Fees[]`` | An array of structs containing the fee data [optional] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc1155Token`` | ``address`` | The ERC1155 token. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc1155TokenId`` | ``uint256`` | The ERC1155 token id. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc1155TokenProperties`` | ``Property[]`` | Properties to validate for a property based order. [optional] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``erc1155TokenAmount`` | ``uin128`` | The ERC1155 amount. [required] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
|
||||
NFT Order Property
|
||||
******************
|
||||
|
||||
For Property based NFT orders, the properties have the following fields:
|
||||
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| Field | Type | Description |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``propertyValidator`` | ``address`` | The address of the contract which implements `IPropertyValidator`. |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``propertyData`` | ``bytes`` | The address of the maker, and signer, of this order. |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
|
||||
The property validator contract must implement the following interface when Property based orders are used.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
/// @dev Checks that the given ERC721/ERC1155 asset satisfies the properties encoded in `propertyData`.
|
||||
/// Should revert if the asset does not satisfy the specified properties.
|
||||
/// @param tokenAddress The ERC721/ERC1155 token contract address.
|
||||
/// @param tokenId The ERC721/ERC1155 tokenId of the asset to check.
|
||||
/// @param propertyData Encoded properties or auxiliary data needed to perform the check.
|
||||
function validateProperty(
|
||||
address tokenAddress,
|
||||
uint256 tokenId,
|
||||
bytes calldata propertyData
|
||||
)
|
||||
external
|
||||
view;
|
||||
|
||||
NFT Order Fee
|
||||
**************
|
||||
|
||||
For NFT orders with fees, the fees have the following fields:
|
||||
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| Field | Type | Description |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``receipient`` | ``address`` | The receipient of the fees. |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``amount`` | ``uint256`` | The amount of fee to be paid to recipient. |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
| ``feeData`` | ``bytes`` | If provided the recipient (contract) will be called with this feeData [optional] |
|
||||
+----------------------------+-----------------+------------------------------------------------------------------------------------------+
|
||||
|
||||
The contract must implement the following interface when the `feeData` is present.
|
||||
|
||||
.. code-block:: solidity
|
||||
|
||||
interface IFeeRecipient {
|
||||
|
||||
/// @dev A callback function invoked in the ERC721Feature for each ERC721
|
||||
/// order fee that get paid. Integrators can make use of this callback
|
||||
/// to implement arbitrary fee-handling logic, e.g. splitting the fee
|
||||
/// between multiple parties.
|
||||
/// @param tokenAddress The address of the token in which the received fee is
|
||||
/// denominated. `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` indicates
|
||||
/// that the fee was paid in the native token (e.g. ETH).
|
||||
/// @param amount The amount of the given token received.
|
||||
/// @param feeData Arbitrary data encoded in the `Fee` used by this callback.
|
||||
/// @return success The selector of this function (0x0190805e),
|
||||
/// indicating that the callback succeeded.
|
||||
function receiveFeeCallback(
|
||||
address tokenAddress,
|
||||
uint256 amount,
|
||||
bytes calldata feeData
|
||||
)
|
||||
external
|
||||
returns (bytes4 success);
|
||||
}
|
||||
|
||||
|
||||
|
||||
How To Sign
|
||||
==============
|
||||
|
||||
Both Limit & RFQ orders must be signed by the `maker` or a registered order signer (`registerAllowedOrderSigner <./functions.html#registerallowedrfqorigins>`_). This signature is needed to fill an order, see `Basic Functionality <./functions.html>`_.
|
||||
Orders must be signed by the `maker` or a registered order signer (`registerAllowedOrderSigner <./functions.html#registerallowedrfqorigins>`_). This signature is needed to fill an order, see `Basic Functionality <./functions.html>`_.
|
||||
|
||||
The protocol accepts signatures defined by the following struct:
|
||||
|
||||
|
@@ -60,9 +60,9 @@ copyright = u'2016, ZeroEx Inc'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '4.0'
|
||||
version = '4.1'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '4.0'
|
||||
release = '4.1'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
@@ -12,7 +12,6 @@ sections = [
|
||||
"name": "Exchange V4",
|
||||
"contracts": [
|
||||
'exchangeProxy',
|
||||
'exchangeProxyAllowanceTarget',
|
||||
'exchangeProxyFlashWallet',
|
||||
'exchangeProxyGovernor',
|
||||
'exchangeProxyLiquidityProviderSandbox',
|
||||
@@ -50,18 +49,43 @@ sections = [
|
||||
}
|
||||
]
|
||||
|
||||
def printRow(contract, address):
|
||||
etherscanLink = "%s/%s"%("https://etherscan.io/address/", address)
|
||||
print(" %s, `%s <%s>`_"%(contract, address, etherscanLink))
|
||||
networks = {
|
||||
'1': 'Ethereum',
|
||||
'10': 'Optimism',
|
||||
'56': 'Binance Smart Chain',
|
||||
'137': 'Polygon',
|
||||
'43114': 'Avalanche',
|
||||
'250': 'Fantom',
|
||||
'42220': 'Celo',
|
||||
}
|
||||
|
||||
def printTable(contracts, addresses):
|
||||
etherscanByNetwork = {
|
||||
'1': 'https://etherscan.io/address',
|
||||
'10': 'https://optimistic.etherscan.io/address',
|
||||
'56': 'https://bscscan.com/address',
|
||||
'137': 'https://polygonscan.com/address',
|
||||
'43114': 'https://snowtrace.io/address',
|
||||
'250': 'https://ftmscan.com/address',
|
||||
'42220': 'https://explorer.celo.org/address',
|
||||
}
|
||||
|
||||
|
||||
def getLinkableAddress(address, network):
|
||||
etherscanLink = "%s/%s"%(etherscanByNetwork[network], address)
|
||||
return "`%s <%s>`__"%(address, etherscanLink)
|
||||
|
||||
def printRow(contract, address, network):
|
||||
etherscanLink = "%s/%s"%(etherscanByNetwork[network], address)
|
||||
print(" %s, %s"%(contract, getLinkableAddress(address, network)))
|
||||
|
||||
def printTable(contracts, addresses, network):
|
||||
print(".. csv-table::\n")
|
||||
for contract in contracts:
|
||||
if isinstance(addresses[contract], unicode):
|
||||
printRow(contract, addresses[contract])
|
||||
if isinstance(addresses[contract], str):
|
||||
printRow(contract, addresses[contract], network)
|
||||
else:
|
||||
for contract,address in addresses[contract].items():
|
||||
printRow(contract, address)
|
||||
printRow(contract, address, network)
|
||||
|
||||
|
||||
print(
|
||||
@@ -72,6 +96,8 @@ Addresses
|
||||
|
||||
.. note::
|
||||
This page is auto-generated. See the `contract-addresses <https://github.com/0xProject/protocol/blob/development/packages/contract-addresses/addresses.json>`_ package for an exhaustive list of contracts across all networks.
|
||||
|
||||
The Exchange Proxy may have different addresses on various networks, see the `Exchange Proxy Addresses <./addresses.html#exchange-proxy-addresses>`__ table for an exhaustive list.
|
||||
'''
|
||||
)
|
||||
|
||||
@@ -79,6 +105,13 @@ with open('../packages/contract-addresses/addresses.json') as f:
|
||||
addresses = json.load(f)
|
||||
for section in sections:
|
||||
print("%s\n==================="%(section["name"]))
|
||||
printTable(section["contracts"], addresses["1"])
|
||||
printTable(section["contracts"], addresses["1"], "1")
|
||||
print("\n\n")
|
||||
print("Exchange Proxy Addresses \n=========================")
|
||||
print("Note: Some addresses have changed across various networks\n")
|
||||
print(".. csv-table::\n")
|
||||
for network in networks:
|
||||
# etherscanLink = "%s/%s"%("https://etherscan.io/address/", address)
|
||||
# print(" %s, `%s <%s>`_"%(contract, address, etherscanLink))
|
||||
print(" %s, %s"%(networks[network], getLinkableAddress(addresses[network]["exchangeProxy"], network)))
|
||||
|
||||
|
13
package.json
13
package.json
@@ -52,29 +52,30 @@
|
||||
},
|
||||
"config": {
|
||||
"contractsPackages": "@0x/contracts-erc20 @0x/contracts-test-utils @0x/contracts-utils @0x/contracts-zero-ex @0x/contracts-treasury",
|
||||
"nonContractPackages": "@0x/migrations @0x/contract-wrappers @0x/contract-addresses @0x/contract-artifacts @0x/contract-wrappers-test @0x/asset-swapper",
|
||||
"nonContractPackages": "@0x/contract-wrappers @0x/contract-addresses @0x/contract-artifacts @0x/contract-wrappers-test @0x/asset-swapper",
|
||||
"ignoreTestsForPackages": "",
|
||||
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic",
|
||||
"packagesWithDocPages": "@0x/contract-wrappers @0x/migrations",
|
||||
"packagesWithDocPages": "@0x/contract-wrappers",
|
||||
"ignoreDependencyVersions": "@types/styled-components @types/node",
|
||||
"ignoreDependencyVersionsForPackage": "contract-wrappers"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0x/monorepo-scripts": "^3.2.1",
|
||||
"@0x-lerna-fork/lerna": "3.16.10",
|
||||
"@0x/monorepo-scripts": "^3.2.4",
|
||||
"@0xproject/npm-cli-login": "^0.0.11",
|
||||
"async-child-process": "^1.1.1",
|
||||
"coveralls": "^3.0.0",
|
||||
"ganache-cli": "6.8.0-istanbul.0",
|
||||
"ganache-cli": "6.12.2",
|
||||
"lcov-result-merger": "^3.0.0",
|
||||
"lerna": "^3.0.0-beta.25",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"prettier": "1.19.1",
|
||||
"source-map-support": "^0.5.6",
|
||||
"typescript": "4.2.2",
|
||||
"typescript": "4.6.3",
|
||||
"wsrun": "^5.2.4"
|
||||
},
|
||||
"resolutions": {
|
||||
"merkle-patricia-tree": "^2.3.2"
|
||||
"merkle-patricia-tree": "3.0.0",
|
||||
"**/bignumber.js": "^9.0.2"
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,493 @@
|
||||
[
|
||||
{
|
||||
"version": "16.66.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add WOOFi support",
|
||||
"pr": 513
|
||||
}
|
||||
],
|
||||
"timestamp": 1659750766
|
||||
},
|
||||
{
|
||||
"version": "16.65.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Use 0x gas api instead of eth gas station api",
|
||||
"pr": 532
|
||||
}
|
||||
],
|
||||
"timestamp": 1659391840
|
||||
},
|
||||
{
|
||||
"version": "16.64.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Refactor `TokenAdjacency` and `TokenAdjacencyBuilder`",
|
||||
"pr": 517
|
||||
},
|
||||
{
|
||||
"note": "Add Synthetix support`",
|
||||
"pr": 518
|
||||
},
|
||||
{
|
||||
"note": "Replace Beethoven X subgraph URL",
|
||||
"pr": 519
|
||||
},
|
||||
{
|
||||
"note": "Remove Mooniswap on Ethereum mainnet",
|
||||
"pr": 529
|
||||
}
|
||||
],
|
||||
"timestamp": 1658950329
|
||||
},
|
||||
{
|
||||
"version": "16.63.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Better error handling for balancer cache",
|
||||
"pr": 515
|
||||
}
|
||||
],
|
||||
"timestamp": 1657661207
|
||||
},
|
||||
{
|
||||
"version": "16.63.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Remove JS router",
|
||||
"pr": 480
|
||||
},
|
||||
{
|
||||
"note": "Removed Median price in favour of best gas adjusted price",
|
||||
"pr": 480
|
||||
}
|
||||
],
|
||||
"timestamp": 1656491792
|
||||
},
|
||||
{
|
||||
"version": "16.62.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Offboard Smoothy and ComethSwap",
|
||||
"pr": 509
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "16.62.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Remove nUSD from intermediate liquidity to save on sampler gas",
|
||||
"pr": 505
|
||||
}
|
||||
],
|
||||
"timestamp": 1655253622
|
||||
},
|
||||
{
|
||||
"version": "16.62.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add MDEX on BSC",
|
||||
"pr": 496
|
||||
},
|
||||
{
|
||||
"note": "Add KnightSwap on BSC",
|
||||
"pr": 498
|
||||
},
|
||||
{
|
||||
"note": "Add Velodrome support on Optimism",
|
||||
"pr": 494
|
||||
},
|
||||
{
|
||||
"note": "Do not send empty entries on Quote Report",
|
||||
"pr": 501
|
||||
},
|
||||
{
|
||||
"note": "KnightSwap/Mdex cosmetic change",
|
||||
"pr": 502
|
||||
},
|
||||
{
|
||||
"note": "Offboard JetSwap, CafeSwap, JulSwap, and PolyDex",
|
||||
"pr": 503
|
||||
}
|
||||
],
|
||||
"timestamp": 1655244958
|
||||
},
|
||||
{
|
||||
"version": "16.61.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add stETH wrap/unwrap support",
|
||||
"pr": 476
|
||||
},
|
||||
{
|
||||
"note": "Offboard/clean up Oasis, CoFix, and legacy Kyber",
|
||||
"pr": 482
|
||||
},
|
||||
{
|
||||
"note": "Add MeshSwap on Polygon",
|
||||
"pr": 491
|
||||
}
|
||||
],
|
||||
"timestamp": 1654284040
|
||||
},
|
||||
{
|
||||
"version": "16.60.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Alias Balancer sor to the old version",
|
||||
"pr": 481
|
||||
}
|
||||
],
|
||||
"timestamp": 1652931596
|
||||
},
|
||||
{
|
||||
"version": "16.60.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add BiSwap on BSC",
|
||||
"pr": 467
|
||||
},
|
||||
{
|
||||
"note": "Add GMX and Platypus on Avalanche and Enable KyberDMM on bsc",
|
||||
"pr": 478
|
||||
},
|
||||
{
|
||||
"note": "Add Yoshi Exchange support in Fantom",
|
||||
"pr": 473
|
||||
},
|
||||
{
|
||||
"note": "Fix KyberDMM gas underestimation",
|
||||
"pr": 479
|
||||
}
|
||||
],
|
||||
"timestamp": 1652919697
|
||||
},
|
||||
{
|
||||
"version": "16.59.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Remove SnowSwap on mainnet",
|
||||
"pr": 468
|
||||
},
|
||||
{
|
||||
"note": "Offboard Swerve Finance and LinkSwap",
|
||||
"pr": 469
|
||||
},
|
||||
{
|
||||
"note": "Offboard Eth2Dai",
|
||||
"pr": 470
|
||||
},
|
||||
{
|
||||
"note": "Add an optional IRfqClient for SwapQuoter#getSwapQuoteAsync",
|
||||
"pr": 467
|
||||
}
|
||||
],
|
||||
"timestamp": 1652400434
|
||||
},
|
||||
{
|
||||
"version": "16.58.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update Saddle pools on Mainnet",
|
||||
"pr": 450
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "16.57.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix a runtime error related to BalancerV2SwapInfoCache",
|
||||
"pr": 472
|
||||
}
|
||||
],
|
||||
"timestamp": 1652146864
|
||||
},
|
||||
{
|
||||
"version": "16.57.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix missing AMM quotes on indicative Quote Reports",
|
||||
"pr": 466
|
||||
}
|
||||
],
|
||||
"timestamp": 1651526551
|
||||
},
|
||||
{
|
||||
"version": "16.57.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added QUICK/ANY pair on Polygon",
|
||||
"pr": 464
|
||||
},
|
||||
{
|
||||
"note": "Added cvxFXS/FXS curve pool on mainnet",
|
||||
"pr": 465
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "16.57.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add BalancerV2 batch swap support",
|
||||
"pr": 462
|
||||
}
|
||||
],
|
||||
"timestamp": 1650611093
|
||||
},
|
||||
{
|
||||
"version": "16.56.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add estimatedGas to ExtendedQuoteReport",
|
||||
"pr": 463
|
||||
}
|
||||
],
|
||||
"timestamp": 1650575781
|
||||
},
|
||||
{
|
||||
"version": "16.55.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix fillRfqOrder VIP being used for swaps that need transformERC20",
|
||||
"pr": 461
|
||||
}
|
||||
],
|
||||
"timestamp": 1649347667
|
||||
},
|
||||
{
|
||||
"version": "16.54.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add true VIP support for eligible RFQt swaps",
|
||||
"pr": 458
|
||||
}
|
||||
],
|
||||
"timestamp": 1649215576
|
||||
},
|
||||
{
|
||||
"version": "16.53.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Adds support for STG/USDC pool on Curve Mainnet",
|
||||
"pr": 451
|
||||
},
|
||||
{
|
||||
"note": "Use neon-router in asset-swapper tests",
|
||||
"pr": 453
|
||||
},
|
||||
{
|
||||
"note": "Add sampler blocknumber to quote report data",
|
||||
"pr": 448
|
||||
}
|
||||
],
|
||||
"timestamp": 1648739346
|
||||
},
|
||||
{
|
||||
"version": "16.52.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Adds support for mobius money on celo",
|
||||
"pr": 423
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "16.51.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added `Curve` `YFI-ETH` pool",
|
||||
"pr": 444
|
||||
}
|
||||
],
|
||||
"timestamp": 1646888282
|
||||
},
|
||||
{
|
||||
"version": "16.50.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Routing glue optimization",
|
||||
"pr": 439
|
||||
},
|
||||
{
|
||||
"note": "Move VIP source routing into neon-router & disable fallback orders for native/plp",
|
||||
"pr": 440
|
||||
}
|
||||
],
|
||||
"timestamp": 1646837959
|
||||
},
|
||||
{
|
||||
"version": "16.50.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update `Uniswap_V3` address on `Ropsten`",
|
||||
"pr": 441
|
||||
}
|
||||
],
|
||||
"timestamp": 1646617024
|
||||
},
|
||||
{
|
||||
"version": "16.50.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add BTRFLY/WETH Curve pool on mainnet",
|
||||
"pr": 437
|
||||
},
|
||||
{
|
||||
"note": "Lower Uniswap V3 Sampler gas allowance",
|
||||
"pr": 438
|
||||
}
|
||||
],
|
||||
"timestamp": 1646312638
|
||||
},
|
||||
{
|
||||
"version": "16.50.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Adding support for Geist on `Fantom`",
|
||||
"pr": 398
|
||||
},
|
||||
{
|
||||
"note": "Improve Uniswap V3 gas schedule",
|
||||
"pr": 424
|
||||
}
|
||||
],
|
||||
"timestamp": 1646225739
|
||||
},
|
||||
{
|
||||
"version": "16.49.9",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix native order scaling & filter out 1 wei quotes",
|
||||
"pr": "430"
|
||||
}
|
||||
],
|
||||
"timestamp": 1645696356
|
||||
},
|
||||
{
|
||||
"timestamp": 1645569128,
|
||||
"version": "16.49.8",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "16.49.7",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix native order handling for very small quotes and bump `neon-router` dependency",
|
||||
"pr": 425
|
||||
}
|
||||
],
|
||||
"timestamp": 1645534245
|
||||
},
|
||||
{
|
||||
"version": "16.49.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fixed btrfly routing to include the ohmV2/dai, ohmV2/btfly, and ohmV2/weth pools",
|
||||
"pr": 427
|
||||
}
|
||||
],
|
||||
"timestamp": 1645113751
|
||||
},
|
||||
{
|
||||
"version": "16.49.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix scaling 1 base unit to 0, round output to base units",
|
||||
"pr": 422
|
||||
}
|
||||
],
|
||||
"timestamp": 1644844353
|
||||
},
|
||||
{
|
||||
"version": "16.49.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Reverts 'Improve Uniswap V3 gas schedule' due to issue with buys",
|
||||
"pr": 419
|
||||
}
|
||||
],
|
||||
"timestamp": 1644507275
|
||||
},
|
||||
{
|
||||
"version": "16.49.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix `slippage` inconsistency when recalculated in exchange proxy quote consumer",
|
||||
"pr": 412
|
||||
},
|
||||
{
|
||||
"note": "Fix incorrect output scaling when input is less than desired amount, update fast-abi",
|
||||
"pr": 401
|
||||
},
|
||||
{
|
||||
"note": "Improve Uniswap V3 gas schedule",
|
||||
"pr": 397
|
||||
},
|
||||
{
|
||||
"note": "Fix add Native as VIP and use Path to compare all sources vs vip only",
|
||||
"pr": 413
|
||||
}
|
||||
],
|
||||
"timestamp": 1644495123
|
||||
},
|
||||
{
|
||||
"version": "16.49.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix ABI encoding error with two hop buys due to applying slippage to uint(-1) values",
|
||||
"pr": 410
|
||||
}
|
||||
],
|
||||
"timestamp": 1643653482
|
||||
},
|
||||
{
|
||||
"version": "16.49.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix WorstCaseQuoteInfo encoding bug",
|
||||
"pr": 402
|
||||
}
|
||||
],
|
||||
"timestamp": 1643613597
|
||||
},
|
||||
{
|
||||
"version": "16.49.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add more curve pools",
|
||||
"pr": 409
|
||||
}
|
||||
],
|
||||
"timestamp": 1643407900
|
||||
},
|
||||
{
|
||||
"version": "16.48.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Use `MIM` as an intermediate asset on `Fantom`",
|
||||
"pr": 405
|
||||
}
|
||||
],
|
||||
"timestamp": 1643148019
|
||||
},
|
||||
{
|
||||
"version": "16.47.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Adding support for Synapse on all networks",
|
||||
"pr": 400
|
||||
}
|
||||
],
|
||||
"timestamp": 1643136662
|
||||
},
|
||||
{
|
||||
"version": "16.46.0",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,188 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v16.66.0 - _August 6, 2022_
|
||||
|
||||
* Add WOOFi support (#513)
|
||||
|
||||
## v16.65.0 - _August 1, 2022_
|
||||
|
||||
* Use 0x gas api instead of eth gas station api (#532)
|
||||
|
||||
## v16.64.0 - _July 27, 2022_
|
||||
|
||||
* Refactor `TokenAdjacency` and `TokenAdjacencyBuilder` (#517)
|
||||
* Add Synthetix support` (#518)
|
||||
* Replace Beethoven X subgraph URL (#519)
|
||||
* Remove Mooniswap on Ethereum mainnet (#529)
|
||||
|
||||
## v16.63.1 - _July 12, 2022_
|
||||
|
||||
* Better error handling for balancer cache (#515)
|
||||
|
||||
## v16.63.0 - _June 29, 2022_
|
||||
|
||||
* Remove JS router (#480)
|
||||
* Removed Median price in favour of best gas adjusted price (#480)
|
||||
|
||||
## v16.62.2 - _Invalid date_
|
||||
|
||||
* Offboard Smoothy and ComethSwap (#509)
|
||||
|
||||
## v16.62.1 - _June 15, 2022_
|
||||
|
||||
* Remove nUSD from intermediate liquidity to save on sampler gas (#505)
|
||||
|
||||
## v16.62.0 - _June 14, 2022_
|
||||
|
||||
* Add MDEX on BSC (#496)
|
||||
* Add KnightSwap on BSC (#498)
|
||||
* Add Velodrome support on Optimism (#494)
|
||||
* Do not send empty entries on Quote Report (#501)
|
||||
* KnightSwap/Mdex cosmetic change (#502)
|
||||
* Offboard JetSwap, CafeSwap, JulSwap, and PolyDex (#503)
|
||||
|
||||
## v16.61.0 - _June 3, 2022_
|
||||
|
||||
* Add stETH wrap/unwrap support (#476)
|
||||
* Offboard/clean up Oasis, CoFix, and legacy Kyber (#482)
|
||||
* Add MeshSwap on Polygon (#491)
|
||||
|
||||
## v16.60.1 - _May 19, 2022_
|
||||
|
||||
* Alias Balancer sor to the old version (#481)
|
||||
|
||||
## v16.60.0 - _May 19, 2022_
|
||||
|
||||
* Add BiSwap on BSC (#467)
|
||||
* Add GMX and Platypus on Avalanche and Enable KyberDMM on bsc (#478)
|
||||
* Add Yoshi Exchange support in Fantom (#473)
|
||||
* Fix KyberDMM gas underestimation (#479)
|
||||
|
||||
## v16.59.0 - _May 13, 2022_
|
||||
|
||||
* Remove SnowSwap on mainnet (#468)
|
||||
* Offboard Swerve Finance and LinkSwap (#469)
|
||||
* Offboard Eth2Dai (#470)
|
||||
* Add an optional IRfqClient for SwapQuoter#getSwapQuoteAsync (#467)
|
||||
|
||||
## v16.58.0 - _Invalid date_
|
||||
|
||||
* Update Saddle pools on Mainnet (#450)
|
||||
|
||||
## v16.57.3 - _May 10, 2022_
|
||||
|
||||
* Fix a runtime error related to BalancerV2SwapInfoCache (#472)
|
||||
|
||||
## v16.57.2 - _May 2, 2022_
|
||||
|
||||
* Fix missing AMM quotes on indicative Quote Reports (#466)
|
||||
|
||||
## v16.57.1 - _Invalid date_
|
||||
|
||||
* Added QUICK/ANY pair on Polygon (#464)
|
||||
* Added cvxFXS/FXS curve pool on mainnet (#465)
|
||||
|
||||
## v16.57.0 - _April 22, 2022_
|
||||
|
||||
* Add BalancerV2 batch swap support (#462)
|
||||
|
||||
## v16.56.0 - _April 21, 2022_
|
||||
|
||||
* Add estimatedGas to ExtendedQuoteReport (#463)
|
||||
|
||||
## v16.55.0 - _April 7, 2022_
|
||||
|
||||
* Fix fillRfqOrder VIP being used for swaps that need transformERC20 (#461)
|
||||
|
||||
## v16.54.0 - _April 6, 2022_
|
||||
|
||||
* Add true VIP support for eligible RFQt swaps (#458)
|
||||
|
||||
## v16.53.0 - _March 31, 2022_
|
||||
|
||||
* Adds support for STG/USDC pool on Curve Mainnet (#451)
|
||||
* Use neon-router in asset-swapper tests (#453)
|
||||
* Add sampler blocknumber to quote report data (#448)
|
||||
|
||||
## v16.52.0 - _Invalid date_
|
||||
|
||||
* Adds support for mobius money on celo (#423)
|
||||
|
||||
## v16.51.0 - _March 10, 2022_
|
||||
|
||||
* Added `Curve` `YFI-ETH` pool (#444)
|
||||
|
||||
## v16.50.3 - _March 9, 2022_
|
||||
|
||||
* Routing glue optimization (#439)
|
||||
* Move VIP source routing into neon-router & disable fallback orders for native/plp (#440)
|
||||
|
||||
## v16.50.2 - _March 7, 2022_
|
||||
|
||||
* Update `Uniswap_V3` address on `Ropsten` (#441)
|
||||
|
||||
## v16.50.1 - _March 3, 2022_
|
||||
|
||||
* Add BTRFLY/WETH Curve pool on mainnet (#437)
|
||||
* Lower Uniswap V3 Sampler gas allowance (#438)
|
||||
|
||||
## v16.50.0 - _March 2, 2022_
|
||||
|
||||
* Adding support for Geist on `Fantom` (#398)
|
||||
* Improve Uniswap V3 gas schedule (#424)
|
||||
|
||||
## v16.49.9 - _February 24, 2022_
|
||||
|
||||
* Fix native order scaling & filter out 1 wei quotes (#430)
|
||||
|
||||
## v16.49.8 - _February 22, 2022_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v16.49.7 - _February 22, 2022_
|
||||
|
||||
* Fix native order handling for very small quotes and bump `neon-router` dependency (#425)
|
||||
|
||||
## v16.49.6 - _February 17, 2022_
|
||||
|
||||
* Fixed btrfly routing to include the ohmV2/dai, ohmV2/btfly, and ohmV2/weth pools (#427)
|
||||
|
||||
## v16.49.5 - _February 14, 2022_
|
||||
|
||||
* Fix scaling 1 base unit to 0, round output to base units (#422)
|
||||
|
||||
## v16.49.4 - _February 10, 2022_
|
||||
|
||||
* Reverts 'Improve Uniswap V3 gas schedule' due to issue with buys (#419)
|
||||
|
||||
## v16.49.3 - _February 10, 2022_
|
||||
|
||||
* Fix `slippage` inconsistency when recalculated in exchange proxy quote consumer (#412)
|
||||
* Fix incorrect output scaling when input is less than desired amount, update fast-abi (#401)
|
||||
* Improve Uniswap V3 gas schedule (#397)
|
||||
* Fix add Native as VIP and use Path to compare all sources vs vip only (#413)
|
||||
|
||||
## v16.49.2 - _January 31, 2022_
|
||||
|
||||
* Fix ABI encoding error with two hop buys due to applying slippage to uint(-1) values (#410)
|
||||
|
||||
## v16.49.1 - _January 31, 2022_
|
||||
|
||||
* Fix WorstCaseQuoteInfo encoding bug (#402)
|
||||
|
||||
## v16.49.0 - _January 28, 2022_
|
||||
|
||||
* Add more curve pools (#409)
|
||||
|
||||
## v16.48.0 - _January 25, 2022_
|
||||
|
||||
* Use `MIM` as an intermediate asset on `Fantom` (#405)
|
||||
|
||||
## v16.47.0 - _January 25, 2022_
|
||||
|
||||
* Adding support for Synapse on all networks (#400)
|
||||
|
||||
## v16.46.0 - _January 11, 2022_
|
||||
|
||||
* Enable `Curve` ETH/CVX pool (#394)
|
||||
|
@@ -6,7 +6,7 @@
|
||||
"shouldSaveStandardInput": true,
|
||||
"compilerSettings": {
|
||||
"evmVersion": "istanbul",
|
||||
"optimizer": { "enabled": true, "runs": 200, "details": { "yul": true, "deduplicate": true } },
|
||||
"optimizer": { "enabled": true, "runs": 200, "details": { "yul": false, "deduplicate": true } },
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
|
105
packages/asset-swapper/contracts/src/BalancerV2BatchSampler.sol
Normal file
105
packages/asset-swapper/contracts/src/BalancerV2BatchSampler.sol
Normal file
@@ -0,0 +1,105 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2021 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IBalancerV2Vault.sol";
|
||||
import "./BalancerV2Common.sol";
|
||||
|
||||
contract BalancerV2BatchSampler is BalancerV2Common {
|
||||
|
||||
// Replaces amount for first step with each takerTokenAmount and calls queryBatchSwap using supplied steps
|
||||
/// @dev Sample sell quotes from Balancer V2 supporting multihops.
|
||||
/// @param swapSteps Array of swap steps (can be >= 1).
|
||||
/// @param swapAssets Array of token address for swaps.
|
||||
/// @param takerTokenAmounts Taker token sell amount for each sample.
|
||||
function sampleMultihopSellsFromBalancerV2(
|
||||
IBalancerV2Vault vault,
|
||||
IBalancerV2Vault.BatchSwapStep[] memory swapSteps,
|
||||
address[] memory swapAssets,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
returns (uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
IBalancerV2Vault.FundManagement memory swapFunds =
|
||||
_createSwapFunds();
|
||||
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
swapSteps[0].amount = takerTokenAmounts[i];
|
||||
try
|
||||
// For sells we specify the takerToken which is what the vault will receive from the trade
|
||||
vault.queryBatchSwap(IBalancerV2Vault.SwapKind.GIVEN_IN, swapSteps, swapAssets, swapFunds)
|
||||
// amounts represent pool balance deltas from the swap (incoming balance, outgoing balance)
|
||||
returns (int256[] memory amounts) {
|
||||
// Outgoing balance is negative so we need to flip the sign
|
||||
// Note - queryBatchSwap will return a delta for each token in the assets array and last asset should be tokenOut
|
||||
int256 amountOutFromPool = amounts[amounts.length - 1] * -1;
|
||||
if (amountOutFromPool <= 0) {
|
||||
break;
|
||||
}
|
||||
makerTokenAmounts[i] = uint256(amountOutFromPool);
|
||||
} catch {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replaces amount for first step with each makerTokenAmount and calls queryBatchSwap using supplied steps
|
||||
/// @dev Sample buy quotes from Balancer V2 supporting multihops.
|
||||
/// @param swapSteps Array of swap steps (can be >= 1).
|
||||
/// @param swapAssets Array of token address for swaps.
|
||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||
function sampleMultihopBuysFromBalancerV2(
|
||||
IBalancerV2Vault vault,
|
||||
IBalancerV2Vault.BatchSwapStep[] memory swapSteps,
|
||||
address[] memory swapAssets,
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
returns (uint256[] memory takerTokenAmounts)
|
||||
{
|
||||
uint256 numSamples = makerTokenAmounts.length;
|
||||
takerTokenAmounts = new uint256[](numSamples);
|
||||
IBalancerV2Vault.FundManagement memory swapFunds =
|
||||
_createSwapFunds();
|
||||
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
swapSteps[0].amount = makerTokenAmounts[i];
|
||||
try
|
||||
// Uses GIVEN_OUT type for Buy
|
||||
vault.queryBatchSwap(IBalancerV2Vault.SwapKind.GIVEN_OUT, swapSteps, swapAssets, swapFunds)
|
||||
// amounts represent pool balance deltas from the swap (incoming balance, outgoing balance)
|
||||
returns (int256[] memory amounts) {
|
||||
int256 amountIntoPool = amounts[0];
|
||||
if (amountIntoPool <= 0) {
|
||||
break;
|
||||
}
|
||||
takerTokenAmounts[i] = uint256(amountIntoPool);
|
||||
} catch {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,28 +18,24 @@
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IBalancerV2Vault.sol";
|
||||
|
||||
|
||||
interface ISmoothy {
|
||||
contract BalancerV2Common {
|
||||
|
||||
function getBalance (
|
||||
uint256 tid
|
||||
)
|
||||
external
|
||||
function _createSwapFunds()
|
||||
internal
|
||||
view
|
||||
returns (uint256 balance);
|
||||
|
||||
function _yBalances (
|
||||
uint256 tid
|
||||
)
|
||||
external
|
||||
view
|
||||
returns (uint256 balance);
|
||||
|
||||
function getTokenStats (
|
||||
uint256 tid
|
||||
)
|
||||
external
|
||||
view
|
||||
returns (uint256 softWeight, uint256 hardWeight, uint256 balance, uint256 decimals);
|
||||
returns (IBalancerV2Vault.FundManagement memory)
|
||||
{
|
||||
return
|
||||
IBalancerV2Vault.FundManagement({
|
||||
sender: address(this),
|
||||
fromInternalBalance: false,
|
||||
recipient: payable(address(this)),
|
||||
toInternalBalance: false
|
||||
});
|
||||
}
|
||||
}
|
@@ -21,44 +21,11 @@ pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./SamplerUtils.sol";
|
||||
import "./interfaces/IBalancerV2Vault.sol";
|
||||
import "./BalancerV2Common.sol";
|
||||
|
||||
/// @dev Minimal Balancer V2 Vault interface
|
||||
/// for documentation refer to https://github.com/balancer-labs/balancer-core-v2/blob/master/contracts/vault/interfaces/IVault.sol
|
||||
interface IBalancerV2Vault {
|
||||
enum SwapKind { GIVEN_IN, GIVEN_OUT }
|
||||
|
||||
struct BatchSwapStep {
|
||||
bytes32 poolId;
|
||||
uint256 assetInIndex;
|
||||
uint256 assetOutIndex;
|
||||
uint256 amount;
|
||||
bytes userData;
|
||||
}
|
||||
|
||||
struct FundManagement {
|
||||
address sender;
|
||||
bool fromInternalBalance;
|
||||
address payable recipient;
|
||||
bool toInternalBalance;
|
||||
}
|
||||
|
||||
function queryBatchSwap(
|
||||
SwapKind kind,
|
||||
BatchSwapStep[] calldata swaps,
|
||||
IAsset[] calldata assets,
|
||||
FundManagement calldata funds
|
||||
) external returns (int256[] memory assetDeltas);
|
||||
}
|
||||
interface IAsset {
|
||||
// solhint-disable-previous-line no-empty-blocks
|
||||
}
|
||||
|
||||
contract BalancerV2Sampler is SamplerUtils {
|
||||
|
||||
struct BalancerV2PoolInfo {
|
||||
bytes32 poolId;
|
||||
address vault;
|
||||
}
|
||||
contract BalancerV2Sampler is SamplerUtils, BalancerV2Common {
|
||||
|
||||
/// @dev Sample sell quotes from Balancer V2.
|
||||
/// @param poolInfo Struct with pool related data
|
||||
@@ -68,7 +35,7 @@ contract BalancerV2Sampler is SamplerUtils {
|
||||
/// @return makerTokenAmounts Maker amounts bought at each taker token
|
||||
/// amount.
|
||||
function sampleSellsFromBalancerV2(
|
||||
BalancerV2PoolInfo memory poolInfo,
|
||||
IBalancerV2Vault.BalancerV2PoolInfo memory poolInfo,
|
||||
address takerToken,
|
||||
address makerToken,
|
||||
uint256[] memory takerTokenAmounts
|
||||
@@ -78,9 +45,9 @@ contract BalancerV2Sampler is SamplerUtils {
|
||||
{
|
||||
_assertValidPair(makerToken, takerToken);
|
||||
IBalancerV2Vault vault = IBalancerV2Vault(poolInfo.vault);
|
||||
IAsset[] memory swapAssets = new IAsset[](2);
|
||||
swapAssets[0] = IAsset(takerToken);
|
||||
swapAssets[1] = IAsset(makerToken);
|
||||
address[] memory swapAssets = new address[](2);
|
||||
swapAssets[0] = takerToken;
|
||||
swapAssets[1] = makerToken;
|
||||
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
@@ -97,7 +64,7 @@ contract BalancerV2Sampler is SamplerUtils {
|
||||
// amounts represent pool balance deltas from the swap (incoming balance, outgoing balance)
|
||||
returns (int256[] memory amounts) {
|
||||
// Outgoing balance is negative so we need to flip the sign
|
||||
int256 amountOutFromPool = amounts[1] * -1;
|
||||
int256 amountOutFromPool = amounts[amounts.length - 1] * -1;
|
||||
if (amountOutFromPool <= 0) {
|
||||
break;
|
||||
}
|
||||
@@ -117,7 +84,7 @@ contract BalancerV2Sampler is SamplerUtils {
|
||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||
/// amount.
|
||||
function sampleBuysFromBalancerV2(
|
||||
BalancerV2PoolInfo memory poolInfo,
|
||||
IBalancerV2Vault.BalancerV2PoolInfo memory poolInfo,
|
||||
address takerToken,
|
||||
address makerToken,
|
||||
uint256[] memory makerTokenAmounts
|
||||
@@ -127,9 +94,9 @@ contract BalancerV2Sampler is SamplerUtils {
|
||||
{
|
||||
_assertValidPair(makerToken, takerToken);
|
||||
IBalancerV2Vault vault = IBalancerV2Vault(poolInfo.vault);
|
||||
IAsset[] memory swapAssets = new IAsset[](2);
|
||||
swapAssets[0] = IAsset(takerToken);
|
||||
swapAssets[1] = IAsset(makerToken);
|
||||
address[] memory swapAssets = new address[](2);
|
||||
swapAssets[0] = takerToken;
|
||||
swapAssets[1] = makerToken;
|
||||
|
||||
uint256 numSamples = makerTokenAmounts.length;
|
||||
takerTokenAmounts = new uint256[](numSamples);
|
||||
@@ -157,7 +124,7 @@ contract BalancerV2Sampler is SamplerUtils {
|
||||
}
|
||||
|
||||
function _createSwapSteps(
|
||||
BalancerV2PoolInfo memory poolInfo,
|
||||
IBalancerV2Vault.BalancerV2PoolInfo memory poolInfo,
|
||||
uint256 amount
|
||||
) private pure returns (IBalancerV2Vault.BatchSwapStep[] memory) {
|
||||
IBalancerV2Vault.BatchSwapStep[] memory swapSteps =
|
||||
@@ -172,18 +139,4 @@ contract BalancerV2Sampler is SamplerUtils {
|
||||
|
||||
return swapSteps;
|
||||
}
|
||||
|
||||
function _createSwapFunds()
|
||||
private
|
||||
view
|
||||
returns (IBalancerV2Vault.FundManagement memory)
|
||||
{
|
||||
return
|
||||
IBalancerV2Vault.FundManagement({
|
||||
sender: address(this),
|
||||
fromInternalBalance: false,
|
||||
recipient: payable(address(this)),
|
||||
toInternalBalance: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -22,9 +22,8 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IBancor.sol";
|
||||
|
||||
contract CompilerHack {}
|
||||
|
||||
contract BancorSampler is CompilerHack {
|
||||
contract BancorSampler {
|
||||
|
||||
/// @dev Base gas limit for Bancor calls.
|
||||
uint256 constant private BANCOR_CALL_GAS = 300e3; // 300k
|
||||
|
120
packages/asset-swapper/contracts/src/BancorV3Sampler.sol
Normal file
120
packages/asset-swapper/contracts/src/BancorV3Sampler.sol
Normal file
@@ -0,0 +1,120 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IBancorV3.sol";
|
||||
|
||||
|
||||
contract BancorV3Sampler
|
||||
{
|
||||
/// @dev Gas limit for BancorV3 calls.
|
||||
uint256 constant private BancorV3_CALL_GAS = 150e3; // 150k
|
||||
|
||||
address constant public ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||
|
||||
/// @dev Sample sell quotes from BancorV3.
|
||||
/// @param weth The WETH contract address
|
||||
/// @param router Router to look up tokens and amounts
|
||||
/// @param path Token route. Should be takerToken -> makerToken
|
||||
/// @param takerTokenAmounts Taker token sell amount for each sample.
|
||||
/// @return makerTokenAmounts Maker amounts bought at each taker token
|
||||
/// amount.
|
||||
function sampleSellsFromBancorV3(
|
||||
address weth,
|
||||
address router,
|
||||
address[] memory path,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
|
||||
if(path[0] == weth){
|
||||
path[0] = ETH;
|
||||
}
|
||||
if(path[1] == weth){
|
||||
path[1] = ETH;
|
||||
}
|
||||
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
try
|
||||
IBancorV3(router).tradeOutputBySourceAmount(path[0], path[1], takerTokenAmounts[i])
|
||||
returns (uint256 amount)
|
||||
{
|
||||
makerTokenAmounts[i] = amount;
|
||||
// Break early if there are 0 amounts
|
||||
if (makerTokenAmounts[i] == 0) {
|
||||
break;
|
||||
}
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Sample buy quotes from BancorV3.
|
||||
/// @param weth The WETH contract address
|
||||
/// @param router Router to look up tokens and amounts
|
||||
/// @param path Token route. Should be takerToken -> makerToken.
|
||||
/// @param makerTokenAmounts Maker token buy amount for each sample.
|
||||
/// @return takerTokenAmounts Taker amounts sold at each maker token
|
||||
/// amount.
|
||||
function sampleBuysFromBancorV3(
|
||||
address weth,
|
||||
address router,
|
||||
address[] memory path,
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory takerTokenAmounts)
|
||||
{
|
||||
uint256 numSamples = makerTokenAmounts.length;
|
||||
takerTokenAmounts = new uint256[](numSamples);
|
||||
|
||||
if(path[0] == weth){
|
||||
path[0] = ETH;
|
||||
}
|
||||
if(path[1] == weth){
|
||||
path[1] = ETH;
|
||||
}
|
||||
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
try
|
||||
IBancorV3(router).tradeInputByTargetAmount(path[0], path[1], makerTokenAmounts[i])
|
||||
returns (uint256 amount)
|
||||
{
|
||||
takerTokenAmounts[i] = amount;
|
||||
// Break early if there are 0 amounts
|
||||
if (takerTokenAmounts[i] == 0) {
|
||||
break;
|
||||
}
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -22,52 +22,60 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./BalancerSampler.sol";
|
||||
import "./BalancerV2Sampler.sol";
|
||||
import "./BalancerV2BatchSampler.sol";
|
||||
import "./BancorSampler.sol";
|
||||
import "./BancorV3Sampler.sol";
|
||||
import "./CompoundSampler.sol";
|
||||
import "./CurveSampler.sol";
|
||||
import "./DODOSampler.sol";
|
||||
import "./DODOV2Sampler.sol";
|
||||
import "./KyberSampler.sol";
|
||||
import "./GMXSampler.sol";
|
||||
import "./KyberDmmSampler.sol";
|
||||
import "./LidoSampler.sol";
|
||||
import "./LiquidityProviderSampler.sol";
|
||||
import "./MakerPSMSampler.sol";
|
||||
import "./MultiBridgeSampler.sol";
|
||||
import "./MStableSampler.sol";
|
||||
import "./MooniswapSampler.sol";
|
||||
import "./NativeOrderSampler.sol";
|
||||
import "./PlatypusSampler.sol";
|
||||
import "./ShellSampler.sol";
|
||||
import "./SmoothySampler.sol";
|
||||
import "./SynthetixSampler.sol";
|
||||
import "./TwoHopSampler.sol";
|
||||
import "./UniswapSampler.sol";
|
||||
import "./UniswapV2Sampler.sol";
|
||||
import "./UniswapV3Sampler.sol";
|
||||
import "./VelodromeSampler.sol";
|
||||
import "./WooPPSampler.sol";
|
||||
import "./UtilitySampler.sol";
|
||||
|
||||
|
||||
contract ERC20BridgeSampler is
|
||||
BalancerSampler,
|
||||
BalancerV2Sampler,
|
||||
BalancerV2BatchSampler,
|
||||
BancorSampler,
|
||||
BancorV3Sampler,
|
||||
CompoundSampler,
|
||||
CurveSampler,
|
||||
DODOSampler,
|
||||
DODOV2Sampler,
|
||||
KyberSampler,
|
||||
GMXSampler,
|
||||
KyberDmmSampler,
|
||||
LidoSampler,
|
||||
LiquidityProviderSampler,
|
||||
MakerPSMSampler,
|
||||
MStableSampler,
|
||||
MooniswapSampler,
|
||||
MultiBridgeSampler,
|
||||
NativeOrderSampler,
|
||||
PlatypusSampler,
|
||||
ShellSampler,
|
||||
SmoothySampler,
|
||||
SynthetixSampler,
|
||||
TwoHopSampler,
|
||||
UniswapSampler,
|
||||
UniswapV2Sampler,
|
||||
UniswapV3Sampler,
|
||||
VelodromeSampler,
|
||||
WooPPSampler,
|
||||
UtilitySampler
|
||||
{
|
||||
|
||||
@@ -92,4 +100,6 @@ contract ERC20BridgeSampler is
|
||||
(callResults[i].success, callResults[i].data) = address(this).call(callDatas[i]);
|
||||
}
|
||||
}
|
||||
|
||||
receive() external payable {}
|
||||
}
|
||||
|
96
packages/asset-swapper/contracts/src/GMXSampler.sol
Normal file
96
packages/asset-swapper/contracts/src/GMXSampler.sol
Normal file
@@ -0,0 +1,96 @@
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IGMX.sol";
|
||||
import "./ApproximateBuys.sol";
|
||||
import "./SamplerUtils.sol";
|
||||
|
||||
contract GMXSampler is
|
||||
SamplerUtils,
|
||||
ApproximateBuys
|
||||
{
|
||||
struct GMXInfo {
|
||||
address reader;
|
||||
address vault;
|
||||
address[] path;
|
||||
}
|
||||
|
||||
function sampleSellsFromGMX(
|
||||
address reader,
|
||||
address vault,
|
||||
address[] memory path,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
try
|
||||
IGMX(reader).getAmountOut(IVault(vault), path[0], path[1], takerTokenAmounts[i])
|
||||
returns (uint256 amountAfterFees, uint256 feeAmount)
|
||||
{
|
||||
makerTokenAmounts[i] = amountAfterFees;
|
||||
// Break early if there are 0 amounts
|
||||
if (makerTokenAmounts[i] == 0) {
|
||||
break;
|
||||
}
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sampleBuysFromGMX(
|
||||
address reader,
|
||||
address vault,
|
||||
address[] memory path,
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory takerTokenAmounts)
|
||||
{
|
||||
address[] memory invertBuyPath = new address[](2);
|
||||
invertBuyPath[0] = path[1];
|
||||
invertBuyPath[1] = path[0];
|
||||
return _sampleApproximateBuys(
|
||||
ApproximateBuyQuoteOpts({
|
||||
makerTokenData: abi.encode(reader, vault, invertBuyPath),
|
||||
takerTokenData: abi.encode(reader, vault, path),
|
||||
getSellQuoteCallback: _sampleSellForApproximateBuyFromGMX
|
||||
}),
|
||||
makerTokenAmounts
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function _sampleSellForApproximateBuyFromGMX(
|
||||
bytes memory takerTokenData,
|
||||
bytes memory makerTokenData,
|
||||
uint256 sellAmount
|
||||
)
|
||||
private
|
||||
view
|
||||
returns (uint256 buyAmount)
|
||||
{
|
||||
(address _reader, address _vault, address[] memory _path ) = abi.decode(takerTokenData, (address, address, address[]));
|
||||
|
||||
(bool success, bytes memory resultData) = address(this).staticcall(abi.encodeWithSelector(
|
||||
this.sampleSellsFromGMX.selector,
|
||||
_reader,
|
||||
_vault,
|
||||
_path,
|
||||
_toSingleValueArray(sellAmount)
|
||||
));
|
||||
if(!success) {
|
||||
return 0;
|
||||
}
|
||||
// solhint-disable-next-line indent
|
||||
return abi.decode(resultData, (uint256[]))[0];
|
||||
}
|
||||
|
||||
}
|
@@ -1,301 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IKyberNetwork.sol";
|
||||
import "./ApproximateBuys.sol";
|
||||
import "./SamplerUtils.sol";
|
||||
|
||||
|
||||
contract KyberSampler is
|
||||
SamplerUtils,
|
||||
ApproximateBuys
|
||||
{
|
||||
/// @dev Gas limit for Kyber calls.
|
||||
uint256 constant private KYBER_CALL_GAS = 500e3; // 500k
|
||||
/// @dev Kyber ETH pseudo-address.
|
||||
address constant internal KYBER_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
|
||||
|
||||
struct KyberSamplerOpts {
|
||||
uint256 reserveOffset;
|
||||
address hintHandler;
|
||||
address networkProxy;
|
||||
address weth;
|
||||
bytes hint;
|
||||
}
|
||||
|
||||
/// @dev Sample sell quotes from Kyber.
|
||||
/// @param opts KyberSamplerOpts The nth reserve
|
||||
/// @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 reserveId The id of the reserve found at reserveOffset
|
||||
/// @return hint The hint for the selected reserve
|
||||
/// @return makerTokenAmounts Maker amounts bought at each taker token amount.
|
||||
function sampleSellsFromKyberNetwork(
|
||||
KyberSamplerOpts memory opts,
|
||||
address takerToken,
|
||||
address makerToken,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (bytes32 reserveId, bytes memory hint, uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
_assertValidPair(makerToken, takerToken);
|
||||
reserveId = _getNextReserveId(opts, takerToken, makerToken);
|
||||
if (reserveId == 0x0) {
|
||||
return (reserveId, hint, makerTokenAmounts);
|
||||
}
|
||||
opts.hint = this.encodeKyberHint(opts, reserveId, takerToken, makerToken);
|
||||
hint = opts.hint;
|
||||
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
uint256 value = this.sampleSellFromKyberNetwork(
|
||||
opts,
|
||||
takerToken,
|
||||
makerToken,
|
||||
takerTokenAmounts[i]
|
||||
);
|
||||
makerTokenAmounts[i] = value;
|
||||
// Break early if there are 0 amounts
|
||||
if (makerTokenAmounts[i] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Sample buy quotes from Kyber.
|
||||
/// @param opts KyberSamplerOpts The nth reserve
|
||||
/// @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 reserveId The id of the reserve found at reserveOffset
|
||||
/// @return hint The hint for the selected reserve
|
||||
/// @return takerTokenAmounts Taker amounts sold at each maker token amount.
|
||||
function sampleBuysFromKyberNetwork(
|
||||
KyberSamplerOpts memory opts,
|
||||
address takerToken,
|
||||
address makerToken,
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (bytes32 reserveId, bytes memory hint, uint256[] memory takerTokenAmounts)
|
||||
{
|
||||
_assertValidPair(makerToken, takerToken);
|
||||
|
||||
reserveId = _getNextReserveId(opts, takerToken, makerToken);
|
||||
if (reserveId == 0x0) {
|
||||
return (reserveId, hint, takerTokenAmounts);
|
||||
}
|
||||
opts.hint = this.encodeKyberHint(opts, reserveId, takerToken, makerToken);
|
||||
hint = opts.hint;
|
||||
|
||||
takerTokenAmounts = _sampleApproximateBuys(
|
||||
ApproximateBuyQuoteOpts({
|
||||
makerTokenData: abi.encode(makerToken, opts),
|
||||
takerTokenData: abi.encode(takerToken, opts),
|
||||
getSellQuoteCallback: _sampleSellForApproximateBuyFromKyber
|
||||
}),
|
||||
makerTokenAmounts
|
||||
);
|
||||
return (reserveId, hint, takerTokenAmounts);
|
||||
}
|
||||
|
||||
function encodeKyberHint(
|
||||
KyberSamplerOpts memory opts,
|
||||
bytes32 reserveId,
|
||||
address takerToken,
|
||||
address makerToken
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (bytes memory hint)
|
||||
{
|
||||
// Build a hint selecting the single reserve
|
||||
IKyberHintHandler kyberHint = IKyberHintHandler(opts.hintHandler);
|
||||
|
||||
// All other reserves should be ignored with this hint
|
||||
bytes32[] memory selectedReserves = new bytes32[](1);
|
||||
selectedReserves[0] = reserveId;
|
||||
uint256[] memory emptySplits = new uint256[](0);
|
||||
|
||||
if (takerToken == opts.weth) {
|
||||
// ETH to Token
|
||||
try
|
||||
kyberHint.buildEthToTokenHint
|
||||
{gas: KYBER_CALL_GAS}
|
||||
(
|
||||
makerToken,
|
||||
IKyberHintHandler.TradeType.MaskIn,
|
||||
selectedReserves,
|
||||
emptySplits
|
||||
)
|
||||
returns (bytes memory result)
|
||||
{
|
||||
return result;
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
}
|
||||
} else if (makerToken == opts.weth) {
|
||||
// Token to ETH
|
||||
try
|
||||
kyberHint.buildTokenToEthHint
|
||||
{gas: KYBER_CALL_GAS}
|
||||
(
|
||||
takerToken,
|
||||
IKyberHintHandler.TradeType.MaskIn,
|
||||
selectedReserves,
|
||||
emptySplits
|
||||
)
|
||||
returns (bytes memory result)
|
||||
{
|
||||
return result;
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
}
|
||||
|
||||
} else {
|
||||
// Token to Token
|
||||
// We use the same reserve both ways
|
||||
try
|
||||
kyberHint.buildTokenToTokenHint
|
||||
{gas: KYBER_CALL_GAS}
|
||||
(
|
||||
takerToken,
|
||||
IKyberHintHandler.TradeType.MaskIn,
|
||||
selectedReserves,
|
||||
emptySplits,
|
||||
makerToken,
|
||||
IKyberHintHandler.TradeType.MaskIn,
|
||||
selectedReserves,
|
||||
emptySplits
|
||||
)
|
||||
returns (bytes memory result)
|
||||
{
|
||||
return result;
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _sampleSellForApproximateBuyFromKyber(
|
||||
bytes memory takerTokenData,
|
||||
bytes memory makerTokenData,
|
||||
uint256 sellAmount
|
||||
)
|
||||
private
|
||||
view
|
||||
returns (uint256)
|
||||
{
|
||||
(address makerToken, KyberSamplerOpts memory opts) =
|
||||
abi.decode(makerTokenData, (address, KyberSamplerOpts));
|
||||
(address takerToken, ) =
|
||||
abi.decode(takerTokenData, (address, KyberSamplerOpts));
|
||||
try
|
||||
this.sampleSellFromKyberNetwork
|
||||
(opts, takerToken, makerToken, sellAmount)
|
||||
returns (uint256 amount)
|
||||
{
|
||||
return amount;
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function sampleSellFromKyberNetwork(
|
||||
KyberSamplerOpts memory opts,
|
||||
address takerToken,
|
||||
address makerToken,
|
||||
uint256 takerTokenAmount
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256 makerTokenAmount)
|
||||
{
|
||||
// If there is no hint do not continue
|
||||
if (opts.hint.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
try
|
||||
IKyberNetworkProxy(opts.networkProxy).getExpectedRateAfterFee
|
||||
{gas: KYBER_CALL_GAS}
|
||||
(
|
||||
takerToken == opts.weth ? KYBER_ETH_ADDRESS : takerToken,
|
||||
makerToken == opts.weth ? KYBER_ETH_ADDRESS : makerToken,
|
||||
takerTokenAmount,
|
||||
0, // fee
|
||||
opts.hint
|
||||
)
|
||||
returns (uint256 rate)
|
||||
{
|
||||
uint256 makerTokenDecimals = _getTokenDecimals(makerToken);
|
||||
uint256 takerTokenDecimals = _getTokenDecimals(takerToken);
|
||||
makerTokenAmount =
|
||||
rate *
|
||||
takerTokenAmount *
|
||||
10 ** makerTokenDecimals /
|
||||
10 ** takerTokenDecimals /
|
||||
10 ** 18;
|
||||
return makerTokenAmount;
|
||||
} catch (bytes memory) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function _getNextReserveId(
|
||||
KyberSamplerOpts memory opts,
|
||||
address takerToken,
|
||||
address makerToken
|
||||
)
|
||||
internal
|
||||
view
|
||||
returns (bytes32 reserveId)
|
||||
{
|
||||
// Fetch the registered reserves for this pair
|
||||
IKyberHintHandler kyberHint = IKyberHintHandler(opts.hintHandler);
|
||||
(bytes32[] memory reserveIds, ,) = kyberHint.getTradingReserves(
|
||||
takerToken == opts.weth ? KYBER_ETH_ADDRESS : takerToken,
|
||||
makerToken == opts.weth ? KYBER_ETH_ADDRESS : makerToken,
|
||||
true,
|
||||
new bytes(0) // empty hint
|
||||
);
|
||||
|
||||
if (opts.reserveOffset >= reserveIds.length) {
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
reserveId = reserveIds[opts.reserveOffset];
|
||||
// Ignore Kyber Bridged Reserves (0xbb)
|
||||
if (uint256(reserveId >> 248) == 0xbb) {
|
||||
return 0x0;
|
||||
}
|
||||
|
||||
return reserveId;
|
||||
}
|
||||
}
|
@@ -22,10 +22,18 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./SamplerUtils.sol";
|
||||
|
||||
|
||||
interface IWstETH {
|
||||
function getWstETHByStETH(uint256 _stETHAmount) external view returns (uint256);
|
||||
function getStETHByWstETH(uint256 _wstETHAmount) external view returns (uint256);
|
||||
}
|
||||
|
||||
|
||||
contract LidoSampler is SamplerUtils {
|
||||
struct LidoInfo {
|
||||
address stEthToken;
|
||||
address wethToken;
|
||||
address wstEthToken;
|
||||
}
|
||||
|
||||
/// @dev Sample sell quotes from Lido
|
||||
@@ -42,20 +50,17 @@ contract LidoSampler is SamplerUtils {
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
pure
|
||||
view
|
||||
returns (uint256[] memory)
|
||||
{
|
||||
_assertValidPair(makerToken, takerToken);
|
||||
|
||||
if (takerToken != lidoInfo.wethToken || makerToken != address(lidoInfo.stEthToken)) {
|
||||
// Return 0 values if not selling WETH for stETH
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
uint256[] memory makerTokenAmounts = new uint256[](numSamples);
|
||||
return makerTokenAmounts;
|
||||
if (takerToken == lidoInfo.wethToken && makerToken == address(lidoInfo.stEthToken)) {
|
||||
// Minting stETH is always 1:1 therefore we can just return the same amounts back.
|
||||
return takerTokenAmounts;
|
||||
}
|
||||
|
||||
// Minting stETH is always 1:1 therefore we can just return the same amounts back
|
||||
return takerTokenAmounts;
|
||||
return _sampleSellsForWrapped(lidoInfo, takerToken, makerToken, takerTokenAmounts);
|
||||
}
|
||||
|
||||
/// @dev Sample buy quotes from Lido.
|
||||
@@ -72,20 +77,43 @@ contract LidoSampler is SamplerUtils {
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
pure
|
||||
view
|
||||
returns (uint256[] memory)
|
||||
{
|
||||
_assertValidPair(makerToken, takerToken);
|
||||
|
||||
if (takerToken != lidoInfo.wethToken || makerToken != address(lidoInfo.stEthToken)) {
|
||||
// Return 0 values if not buying stETH for WETH
|
||||
uint256 numSamples = makerTokenAmounts.length;
|
||||
uint256[] memory takerTokenAmounts = new uint256[](numSamples);
|
||||
return takerTokenAmounts;
|
||||
if (takerToken == lidoInfo.wethToken && makerToken == address(lidoInfo.stEthToken)) {
|
||||
// Minting stETH is always 1:1 therefore we can just return the same amounts back.
|
||||
return makerTokenAmounts;
|
||||
}
|
||||
|
||||
// Minting stETH is always 1:1 therefore we can just return the same amounts back
|
||||
return makerTokenAmounts;
|
||||
// Swap out `makerToken` and `takerToken` and re-use `_sampleSellsForWrapped`.
|
||||
return _sampleSellsForWrapped(lidoInfo, makerToken, takerToken, makerTokenAmounts);
|
||||
}
|
||||
|
||||
function _sampleSellsForWrapped(
|
||||
LidoInfo memory lidoInfo,
|
||||
address takerToken,
|
||||
address makerToken,
|
||||
uint256[] memory takerTokenAmounts
|
||||
) private view returns (uint256[] memory) {
|
||||
IWstETH wstETH = IWstETH(lidoInfo.wstEthToken);
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
uint256[] memory makerTokenAmounts = new uint256[](numSamples);
|
||||
|
||||
if (takerToken == lidoInfo.stEthToken && makerToken == lidoInfo.wstEthToken) {
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
makerTokenAmounts[i] = wstETH.getWstETHByStETH(takerTokenAmounts[i]);
|
||||
}
|
||||
return makerTokenAmounts;
|
||||
}
|
||||
|
||||
if (takerToken == lidoInfo.wstEthToken && makerToken == lidoInfo.stEthToken) {
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
makerTokenAmounts[i] = wstETH.getStETHByWstETH(takerTokenAmounts[i]);
|
||||
}
|
||||
return makerTokenAmounts;
|
||||
}
|
||||
|
||||
// Returns 0 values.
|
||||
return makerTokenAmounts;
|
||||
}
|
||||
}
|
||||
|
@@ -1,82 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IMultiBridge.sol";
|
||||
|
||||
|
||||
contract MultiBridgeSampler {
|
||||
|
||||
/// @dev Default gas limit for multibridge calls.
|
||||
uint256 constant private DEFAULT_CALL_GAS = 400e3; // 400k
|
||||
|
||||
/// @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[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
// Initialize array of maker token amounts.
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
|
||||
// If no address provided, return all zeros.
|
||||
if (multibridge == address(0)) {
|
||||
return makerTokenAmounts;
|
||||
}
|
||||
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
(bool didSucceed, bytes memory resultData) =
|
||||
multibridge.staticcall.gas(DEFAULT_CALL_GAS)(
|
||||
abi.encodeWithSelector(
|
||||
IMultiBridge(0).getSellQuote.selector,
|
||||
takerToken,
|
||||
intermediateToken,
|
||||
makerToken,
|
||||
takerTokenAmounts[i]
|
||||
));
|
||||
uint256 buyAmount = 0;
|
||||
if (didSucceed) {
|
||||
buyAmount = abi.decode(resultData, (uint256));
|
||||
}
|
||||
// Exit early if the amount is too high for the source to serve
|
||||
if (buyAmount == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
makerTokenAmounts[i] = buyAmount;
|
||||
}
|
||||
}
|
||||
}
|
89
packages/asset-swapper/contracts/src/PlatypusSampler.sol
Normal file
89
packages/asset-swapper/contracts/src/PlatypusSampler.sol
Normal file
@@ -0,0 +1,89 @@
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./interfaces/IPlatypus.sol";
|
||||
import "./ApproximateBuys.sol";
|
||||
import "./SamplerUtils.sol";
|
||||
|
||||
|
||||
contract PlatypusSampler is
|
||||
SamplerUtils,
|
||||
ApproximateBuys
|
||||
{
|
||||
|
||||
function sampleSellsFromPlatypus(
|
||||
address pool,
|
||||
address[] memory path,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
try
|
||||
IPlatypus(pool).quotePotentialSwap(path[0], path[1], takerTokenAmounts[i])
|
||||
returns (uint256 amountAfterFees, uint256 feeAmount)
|
||||
{
|
||||
makerTokenAmounts[i] = amountAfterFees;
|
||||
// Break early if there are 0 amounts
|
||||
if (makerTokenAmounts[i] == 0) {
|
||||
break;
|
||||
}
|
||||
} catch (bytes memory result) {
|
||||
// Swallow failures, leaving all results as zero.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sampleBuysFromPlatypus(
|
||||
address pool,
|
||||
address[] memory path,
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory takerTokenAmounts)
|
||||
{
|
||||
address[] memory invertBuyPath = new address[](2);
|
||||
invertBuyPath[0] = path[1];
|
||||
invertBuyPath[1] = path[0];
|
||||
return _sampleApproximateBuys(
|
||||
ApproximateBuyQuoteOpts({
|
||||
makerTokenData: abi.encode(pool, invertBuyPath),
|
||||
takerTokenData: abi.encode(pool, path),
|
||||
getSellQuoteCallback: _sampleSellForApproximateBuyFromPlatypus
|
||||
}),
|
||||
makerTokenAmounts
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function _sampleSellForApproximateBuyFromPlatypus(
|
||||
bytes memory makerTokenData,
|
||||
bytes memory takerTokenData,
|
||||
uint256 sellAmount
|
||||
)
|
||||
private
|
||||
view
|
||||
returns (uint256 buyAmount)
|
||||
{
|
||||
(address _pool, address[] memory _path ) = abi.decode(makerTokenData, (address, address[]));
|
||||
|
||||
(bool success, bytes memory resultData) = address(this).staticcall(abi.encodeWithSelector(
|
||||
this.sampleSellsFromPlatypus.selector,
|
||||
_pool,
|
||||
_path,
|
||||
_toSingleValueArray(sellAmount)
|
||||
));
|
||||
if(!success) {
|
||||
return 0;
|
||||
}
|
||||
// solhint-disable-next-line indent
|
||||
return abi.decode(resultData, (uint256[]))[0];
|
||||
}
|
||||
}
|
@@ -1,156 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.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.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
// import "./interfaces/ISmoothy.sol";
|
||||
import "./ApproximateBuys.sol";
|
||||
import "./SamplerUtils.sol";
|
||||
import "./interfaces/ISmoothy.sol";
|
||||
|
||||
contract SmoothySampler is
|
||||
SamplerUtils,
|
||||
ApproximateBuys
|
||||
{
|
||||
/// @dev Information for sampling from smoothy sources.
|
||||
struct SmoothyInfo {
|
||||
address poolAddress;
|
||||
bytes4 sellQuoteFunctionSelector;
|
||||
bytes4 buyQuoteFunctionSelector;
|
||||
}
|
||||
|
||||
/// @dev Base gas limit for Smoothy calls.
|
||||
uint256 constant private SMOOTHY_CALL_GAS = 600e3;
|
||||
|
||||
/// @dev Sample sell quotes from Smoothy.
|
||||
/// @param smoothyInfo Smoothy information specific to this token pair.
|
||||
/// @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 sampleSellsFromSmoothy(
|
||||
SmoothyInfo memory smoothyInfo,
|
||||
int128 fromTokenIdx,
|
||||
int128 toTokenIdx,
|
||||
uint256[] memory takerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory makerTokenAmounts)
|
||||
{
|
||||
// Basically a Curve fork
|
||||
|
||||
// Smoothy only keep a percentage of its tokens available in reserve
|
||||
uint256 poolReserveMakerAmount = ISmoothy(smoothyInfo.poolAddress).getBalance(uint256(toTokenIdx)) -
|
||||
ISmoothy(smoothyInfo.poolAddress)._yBalances(uint256(toTokenIdx));
|
||||
(, , , uint256 decimals) = ISmoothy(smoothyInfo.poolAddress).getTokenStats(uint256(toTokenIdx));
|
||||
poolReserveMakerAmount = poolReserveMakerAmount/(10**(18-decimals));
|
||||
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
(bool didSucceed, bytes memory resultData) =
|
||||
smoothyInfo.poolAddress.staticcall.gas(SMOOTHY_CALL_GAS)(
|
||||
abi.encodeWithSelector(
|
||||
smoothyInfo.sellQuoteFunctionSelector,
|
||||
fromTokenIdx,
|
||||
toTokenIdx,
|
||||
takerTokenAmounts[i]
|
||||
));
|
||||
uint256 buyAmount = 0;
|
||||
if (didSucceed) {
|
||||
buyAmount = abi.decode(resultData, (uint256));
|
||||
}
|
||||
|
||||
// Make sure the quoted buyAmount is available in the pool reserve
|
||||
if (buyAmount >= poolReserveMakerAmount) {
|
||||
// Assign pool reserve amount for all higher samples to break early
|
||||
for (uint256 j = i; j < numSamples; j++) {
|
||||
makerTokenAmounts[j] = poolReserveMakerAmount;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
makerTokenAmounts[i] = buyAmount;
|
||||
}
|
||||
|
||||
// Break early if there are 0 amounts
|
||||
if (makerTokenAmounts[i] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Sample buy quotes from Smoothy.
|
||||
/// @param smoothyInfo Smoothy information specific to this token pair.
|
||||
/// @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 sampleBuysFromSmoothy(
|
||||
SmoothyInfo memory smoothyInfo,
|
||||
int128 fromTokenIdx,
|
||||
int128 toTokenIdx,
|
||||
uint256[] memory makerTokenAmounts
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint256[] memory takerTokenAmounts)
|
||||
{
|
||||
// Buys not supported so approximate it.
|
||||
return _sampleApproximateBuys(
|
||||
ApproximateBuyQuoteOpts({
|
||||
makerTokenData: abi.encode(toTokenIdx, smoothyInfo),
|
||||
takerTokenData: abi.encode(fromTokenIdx, smoothyInfo),
|
||||
getSellQuoteCallback: _sampleSellForApproximateBuyFromSmoothy
|
||||
}),
|
||||
makerTokenAmounts
|
||||
);
|
||||
}
|
||||
|
||||
function _sampleSellForApproximateBuyFromSmoothy(
|
||||
bytes memory takerTokenData,
|
||||
bytes memory makerTokenData,
|
||||
uint256 sellAmount
|
||||
)
|
||||
private
|
||||
view
|
||||
returns (uint256 buyAmount)
|
||||
{
|
||||
(int128 takerTokenIdx, SmoothyInfo memory smoothyInfo) =
|
||||
abi.decode(takerTokenData, (int128, SmoothyInfo));
|
||||
(int128 makerTokenIdx) =
|
||||
abi.decode(makerTokenData, (int128));
|
||||
(bool success, bytes memory resultData) =
|
||||
address(this).staticcall(abi.encodeWithSelector(
|
||||
this.sampleSellsFromSmoothy.selector,
|
||||
smoothyInfo,
|
||||
takerTokenIdx,
|
||||
makerTokenIdx,
|
||||
_toSingleValueArray(sellAmount)
|
||||
));
|
||||
if (!success) {
|
||||
return 0;
|
||||
}
|
||||
// solhint-disable-next-line indent
|
||||
return abi.decode(resultData, (uint256[]))[0];
|
||||
}
|
||||
}
|
173
packages/asset-swapper/contracts/src/SynthetixSampler.sol
Normal file
173
packages/asset-swapper/contracts/src/SynthetixSampler.sol
Normal file
@@ -0,0 +1,173 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
interface IReadProxyAddressResolver {
|
||||
function target() external view returns (address);
|
||||
}
|
||||
|
||||
interface IAddressResolver {
|
||||
function getAddress(bytes32 name) external view returns (address);
|
||||
}
|
||||
|
||||
interface IExchanger {
|
||||
// Ethereum Mainnet
|
||||
function getAmountsForAtomicExchange(
|
||||
uint256 sourceAmount,
|
||||
bytes32 sourceCurrencyKey,
|
||||
bytes32 destinationCurrencyKey
|
||||
)
|
||||
external
|
||||
view
|
||||
returns (
|
||||
uint256 amountReceived,
|
||||
uint256 fee,
|
||||
uint256 exchangeFeeRate
|
||||
);
|
||||
|
||||
// Optimism
|
||||
function getAmountsForExchange(
|
||||
uint256 sourceAmount,
|
||||
bytes32 sourceCurrencyKey,
|
||||
bytes32 destinationCurrencyKey
|
||||
)
|
||||
external
|
||||
view
|
||||
returns (
|
||||
uint256 amountReceived,
|
||||
uint256 fee,
|
||||
uint256 exchangeFeeRate
|
||||
);
|
||||
}
|
||||
|
||||
contract SynthetixSampler {
|
||||
|
||||
/// @dev Sample sell quotes from Synthetix Atomic Swap.
|
||||
/// @param takerTokenSymbol Symbol (currency key) of the taker token (what to sell).
|
||||
/// @param makerTokenSymbol Symbol (currency key) of the maker token (what to buy).
|
||||
/// @param takerTokenAmounts Taker token sell amount for each sample (sorted in ascending order).
|
||||
/// @return synthetix Synthetix address.
|
||||
/// @return makerTokenAmounts Maker amounts bought at each taker token amount.
|
||||
function sampleSellsFromSynthetix(
|
||||
IReadProxyAddressResolver readProxy,
|
||||
bytes32 takerTokenSymbol,
|
||||
bytes32 makerTokenSymbol,
|
||||
uint256[] memory takerTokenAmounts
|
||||
) public view returns (address synthetix, uint256[] memory makerTokenAmounts) {
|
||||
synthetix = getSynthetixAddress(readProxy);
|
||||
uint256 numSamples = takerTokenAmounts.length;
|
||||
makerTokenAmounts = new uint256[](numSamples);
|
||||
if (numSamples == 0) {
|
||||
return (synthetix, makerTokenAmounts);
|
||||
}
|
||||
|
||||
makerTokenAmounts[0] = exchange(
|
||||
readProxy,
|
||||
takerTokenAmounts[0],
|
||||
takerTokenSymbol,
|
||||
makerTokenSymbol
|
||||
);
|
||||
|
||||
// Synthetix atomic swap has a fixed rate. Calculate the rest based on the first value (and save gas).
|
||||
for (uint256 i = 1; i < numSamples; i++) {
|
||||
makerTokenAmounts[i] =
|
||||
(makerTokenAmounts[0] * takerTokenAmounts[i]) /
|
||||
takerTokenAmounts[0];
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Sample buy quotes from Synthetix Atomic Swap.
|
||||
/// @param takerTokenSymbol Symbol (currency key) of the taker token (what to sell).
|
||||
/// @param makerTokenSymbol Symbol (currency key) of the maker token (what to buy).
|
||||
/// @param makerTokenAmounts Maker token buy amount for each sample (sorted in ascending order).
|
||||
/// @return synthetix Synthetix address.
|
||||
/// @return takerTokenAmounts Taker amounts sold at each maker token amount.
|
||||
function sampleBuysFromSynthetix(
|
||||
IReadProxyAddressResolver readProxy,
|
||||
bytes32 takerTokenSymbol,
|
||||
bytes32 makerTokenSymbol,
|
||||
uint256[] memory makerTokenAmounts
|
||||
) public view returns (address synthetix, uint256[] memory takerTokenAmounts) {
|
||||
synthetix = getSynthetixAddress(readProxy);
|
||||
// Since Synthetix atomic have a fixed rate, we can pick any reasonablely size takerTokenAmount (fixed to 1 ether here) and calculate the rest.
|
||||
uint256 amountReceivedForEther = exchange(
|
||||
readProxy,
|
||||
1 ether,
|
||||
takerTokenSymbol,
|
||||
makerTokenSymbol
|
||||
);
|
||||
|
||||
uint256 numSamples = makerTokenAmounts.length;
|
||||
takerTokenAmounts = new uint256[](numSamples);
|
||||
|
||||
for (uint256 i = 0; i < numSamples; i++) {
|
||||
takerTokenAmounts[i] =
|
||||
(1 ether * makerTokenAmounts[i]) /
|
||||
amountReceivedForEther;
|
||||
}
|
||||
}
|
||||
|
||||
function exchange(
|
||||
IReadProxyAddressResolver readProxy,
|
||||
uint256 sourceAmount,
|
||||
bytes32 sourceCurrencyKey,
|
||||
bytes32 destinationCurrencyKey
|
||||
) private view returns (uint256 amountReceived) {
|
||||
IExchanger exchanger = getExchanger(readProxy);
|
||||
uint256 chainId;
|
||||
assembly {
|
||||
chainId := chainid()
|
||||
}
|
||||
|
||||
if (chainId == 1) {
|
||||
(amountReceived, , ) = exchanger.getAmountsForAtomicExchange(
|
||||
sourceAmount,
|
||||
sourceCurrencyKey,
|
||||
destinationCurrencyKey
|
||||
);
|
||||
} else {
|
||||
(amountReceived, , ) = exchanger.getAmountsForExchange(
|
||||
sourceAmount,
|
||||
sourceCurrencyKey,
|
||||
destinationCurrencyKey
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function getSynthetixAddress(IReadProxyAddressResolver readProxy)
|
||||
private
|
||||
view
|
||||
returns (address)
|
||||
{
|
||||
return IAddressResolver(readProxy.target()).getAddress("Synthetix");
|
||||
}
|
||||
|
||||
function getExchanger(IReadProxyAddressResolver readProxy)
|
||||
private
|
||||
view
|
||||
returns (IExchanger)
|
||||
{
|
||||
return
|
||||
IExchanger(
|
||||
IAddressResolver(readProxy.target()).getAddress("Exchanger")
|
||||
);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user