Compare commits

...

28 Commits

Author SHA1 Message Date
Github Actions
d5ae971f1c Publish
- @0x/contracts-asset-proxy@3.7.12
 - @0x/contracts-broker@1.1.30
 - @0x/contracts-coordinator@3.1.31
 - @0x/contracts-dev-utils@1.3.29
 - @0x/contracts-erc1155@2.1.30
 - @0x/contracts-erc20@3.3.9
 - @0x/contracts-erc721@3.1.30
 - @0x/contracts-exchange-forwarder@4.2.31
 - @0x/contracts-exchange-libs@4.3.30
 - @0x/contracts-exchange@3.2.31
 - @0x/contracts-extensions@6.2.25
 - @0x/contracts-integrations@2.7.45
 - @0x/contracts-multisig@4.1.31
 - @0x/contracts-staking@2.0.38
 - @0x/contracts-test-utils@5.4.1
 - @0x/contracts-treasury@1.1.7
 - @0x/contracts-utils@4.7.9
 - @0x/contracts-zero-ex@0.24.0
 - @0x/asset-swapper@6.15.0
 - @0x/contract-addresses@6.2.0
 - @0x/contract-wrappers-test@12.2.46
 - @0x/contract-wrappers@13.16.2
 - @0x/migrations@8.0.7
 - @0x/order-utils@10.4.22
 - @0x/protocol-utils@1.6.1
2021-05-21 12:37:26 +00:00
Github Actions
5a2f5f9a42 Updated CHANGELOGS & MD docs 2021-05-21 12:37:22 +00:00
Jacob Evans
75a3b70cef chore: Temporarily disable a LiquidityProvider (#248) 2021-05-21 22:08:55 +10:00
Jacob Evans
803cf65ba1 fix: Deploy FQT for KyberDmm/Mstable (#247) 2021-05-19 08:34:26 +10:00
Jacob Evans
5d3947b838 fix prettier 2021-05-18 09:10:29 +10:00
mzhu25
4397a59008 Add Huobi Token to liquidity provider tokens (#246) 2021-05-17 15:21:53 -07:00
Jacob Evans
966d54c935 fix: KyberDmm (#236)
* fix: KyberDmm

* fix: pass buyToken to kyberDmm and require that path ends with buyToken

* Pass BigNumber down to FastABI

* Address Feedback

Co-authored-by: Kim Persson <kimpersson88@gmail.com>
2021-05-18 08:12:28 +10:00
Romain Butteaud
234ddb495d fix: mStable USD Sampler and Mixin fix (#238)
* fix: mStable USD Sampler and Mixin fix

* chore: adding mBTC (mStable) pool

* fix linter
2021-05-16 19:43:06 -07:00
mzhu25
a744acc7bc Add special selectors to selector collision test (#243) 2021-05-14 10:50:58 -07:00
Lawrence Forman
27c624633c fix repo scripts that use PKG= env var (#242)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-05-12 18:53:06 -04:00
Github Actions
7ef75101b4 Publish
- @0x/contracts-integrations@2.7.44
 - @0x/asset-swapper@6.14.0
2021-05-12 09:13:31 +00:00
Github Actions
6f8aace00d Updated CHANGELOGS & MD docs 2021-05-12 09:13:23 +00:00
Kim Persson
6c264b2f18 feat: add DAI and USDC as intermediate tokens on Ropsten [TKR-93] (#231)
* feat: add DAI and USDC as intermediate tokens on Ropsten

* chore: add changelog entry
2021-05-11 19:36:46 +02:00
Daniel Pyrathon
df055e1958 fix: Added fee parameter to Quote Requestor (#235)
* Added changes

* Fixes

* Applied PR feedback

* lint fix
2021-05-11 12:57:51 -04:00
Github Actions
70d2117470 Publish
- @0x/contracts-integrations@2.7.43
 - @0x/asset-swapper@6.13.0
2021-05-11 03:18:25 +00:00
Github Actions
2c173ccaf3 Updated CHANGELOGS & MD docs 2021-05-11 03:18:20 +00:00
mzhu25
d2f4a0c5f3 Updated config.yml 2021-05-10 19:51:12 -07:00
mzhu25
0d6021e5e3 Add LiquidityProvider to BSC sources (#234) 2021-05-10 18:27:52 -07:00
Github Actions
bb04726e7f Publish
- @0x/contracts-integrations@2.7.42
 - @0x/asset-swapper@6.12.0
2021-05-10 01:36:49 +00:00
Github Actions
220ca370c2 Updated CHANGELOGS & MD docs 2021-05-10 01:36:44 +00:00
Jacob Evans
63af4e3e98 fix: TwoHopSampler call (#233) 2021-05-10 11:05:30 +10:00
Github Actions
9754e12d82 Publish
- @0x/contracts-integrations@2.7.41
 - @0x/asset-swapper@6.11.0
2021-05-07 04:35:35 +00:00
Github Actions
d72ebed246 Updated CHANGELOGS & MD docs 2021-05-07 04:35:31 +00:00
Jacob Evans
587fc71058 fix: Sampler contract address overrides (#232)
* fix: Sampler contract address overrides

* Update CHANGELOG
2021-05-07 13:52:51 +10:00
Kim Persson
7d34e09a12 fix: add separate priceComparisonsReport to fix missing quoteReport data [TKR-91] (#219)
* fix: add separate priceComparisonsReport to fix missing quoteReport data

* chore: remove notice about unconfirmed Uniswap V3 addresses

* refactor: move price comparisons computation logic into separate method

* chore: add AS changelog entry
2021-05-06 14:54:54 +02:00
Kim Persson
7d15baad0f feat: Balancer V2 load and cache top pools by num swaps on startup [TKR-96] (#228)
* feat: Balancer V2 load and cache top pools by num swaps on startup

* refactor: Clean up code for Balancer V1 & V2 cache heating

* chore: add AS changelog entry
2021-05-06 14:21:30 +02:00
mzhu25
1e6476ada7 Add ETH pseudo-address when wrapping/unwrapping in Multiplex multihop (#230)
* Add ETH pseudo-address when wrapping/unwrapping in Multiplex multihop

* Update changelog
2021-05-06 15:29:24 +10:00
Lawrence Forman
1d6ca5f6b5 @0x/asset-swapper: Tweak compiler settings for smaller sampler size (#229)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2021-05-05 18:36:38 -04:00
113 changed files with 1505 additions and 363 deletions

View File

@@ -2,11 +2,11 @@ version: 2.1
jobs:
build:
resource_class: large
resource_class: xlarge
docker:
- image: node:12
environment:
NODE_OPTIONS: '--max-old-space-size=6442'
NODE_OPTIONS: '--max-old-space-size=16384'
working_directory: ~/repo
steps:
- checkout

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "3.7.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "3.7.11",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.7.12 - _May 21, 2021_
* Dependencies updated
## v3.7.11 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-asset-proxy",
"version": "3.7.11",
"version": "3.7.12",
"engines": {
"node": ">=6.12"
},
@@ -52,10 +52,10 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/protocol",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contract-wrappers": "^13.16.1",
"@0x/contract-wrappers": "^13.16.2",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/dev-utils": "^4.2.7",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
@@ -80,11 +80,11 @@
},
"dependencies": {
"@0x/base-contract": "^6.4.0",
"@0x/contracts-erc1155": "^2.1.29",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-erc721": "^3.1.29",
"@0x/contracts-exchange-libs": "^4.3.29",
"@0x/order-utils": "^10.4.21",
"@0x/contracts-erc1155": "^2.1.30",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-erc721": "^3.1.30",
"@0x/contracts-exchange-libs": "^4.3.30",
"@0x/order-utils": "^10.4.22",
"@0x/types": "^3.3.3",
"@0x/typescript-typings": "^5.2.0",
"@0x/utils": "^6.4.3",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "1.1.30",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "1.1.29",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.1.30 - _May 21, 2021_
* Dependencies updated
## v1.1.29 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-broker",
"version": "1.1.29",
"version": "1.1.30",
"engines": {
"node": ">=6.12"
},
@@ -52,14 +52,14 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-erc721": "^3.1.29",
"@0x/contracts-exchange": "^3.2.30",
"@0x/contracts-exchange-libs": "^4.3.29",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-erc721": "^3.1.30",
"@0x/contracts-exchange": "^3.2.31",
"@0x/contracts-exchange-libs": "^4.3.30",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
@@ -85,7 +85,7 @@
},
"dependencies": {
"@0x/base-contract": "^6.4.0",
"@0x/order-utils": "^10.4.21",
"@0x/order-utils": "^10.4.22",
"@0x/typescript-typings": "^5.2.0",
"@0x/utils": "^6.4.3",
"ethereum-types": "^3.5.0"

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "3.1.31",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "3.1.30",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.31 - _May 21, 2021_
* Dependencies updated
## v3.1.30 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-coordinator",
"version": "3.1.30",
"version": "3.1.31",
"engines": {
"node": ">=6.12"
},
@@ -53,12 +53,12 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-dev-utils": "^1.3.28",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-dev-utils": "^1.3.29",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-gen": "^2.0.38",
"@0x/dev-utils": "^4.2.7",
"@0x/order-utils": "^10.4.21",
"@0x/order-utils": "^10.4.22",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
@@ -84,10 +84,10 @@
"dependencies": {
"@0x/assert": "^3.0.27",
"@0x/base-contract": "^6.4.0",
"@0x/contract-addresses": "^6.1.0",
"@0x/contracts-exchange": "^3.2.30",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/contract-addresses": "^6.2.0",
"@0x/contracts-exchange": "^3.2.31",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/json-schemas": "^6.1.3",
"@0x/types": "^3.3.3",
"@0x/typescript-typings": "^5.2.0",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "1.3.29",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "1.3.28",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.3.29 - _May 21, 2021_
* Dependencies updated
## v1.3.28 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-dev-utils",
"version": "1.3.28",
"version": "1.3.29",
"engines": {
"node": ">=6.12"
},
@@ -43,10 +43,10 @@
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/assert": "^3.0.27",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "2.1.30",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "2.1.29",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.1.30 - _May 21, 2021_
* Dependencies updated
## v2.1.29 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc1155",
"version": "2.1.29",
"version": "2.1.30",
"engines": {
"node": ">=6.12"
},
@@ -54,7 +54,7 @@
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-utils": "^4.7.9",
"@0x/dev-utils": "^4.2.7",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
@@ -81,7 +81,7 @@
},
"dependencies": {
"@0x/base-contract": "^6.4.0",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/utils": "^6.4.3",
"@0x/web3-wrapper": "^7.5.3",
"lodash": "^4.17.11"

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "3.3.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "3.3.8",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.3.9 - _May 21, 2021_
* Dependencies updated
## v3.3.8 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc20",
"version": "3.3.8",
"version": "3.3.9",
"engines": {
"node": ">=6.12"
},
@@ -53,8 +53,8 @@
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/dev-utils": "^4.2.7",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "3.1.30",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "3.1.29",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.30 - _May 21, 2021_
* Dependencies updated
## v3.1.29 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc721",
"version": "3.1.29",
"version": "3.1.30",
"engines": {
"node": ">=6.12"
},
@@ -54,8 +54,8 @@
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/dev-utils": "^4.2.7",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "4.2.31",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "4.2.30",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.2.31 - _May 21, 2021_
* Dependencies updated
## v4.2.30 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange-forwarder",
"version": "4.2.30",
"version": "4.2.31",
"engines": {
"node": ">=6.12"
},
@@ -53,18 +53,18 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-dev-utils": "^1.3.28",
"@0x/contracts-erc1155": "^2.1.29",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-erc721": "^3.1.29",
"@0x/contracts-exchange": "^3.2.30",
"@0x/contracts-exchange-libs": "^4.3.29",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-dev-utils": "^1.3.29",
"@0x/contracts-erc1155": "^2.1.30",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-erc721": "^3.1.30",
"@0x/contracts-exchange": "^3.2.31",
"@0x/contracts-exchange-libs": "^4.3.30",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/dev-utils": "^4.2.7",
"@0x/order-utils": "^10.4.21",
"@0x/order-utils": "^10.4.22",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "4.3.30",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "4.3.29",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.3.30 - _May 21, 2021_
* Dependencies updated
## v4.3.29 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange-libs",
"version": "4.3.29",
"version": "4.3.30",
"engines": {
"node": ">=6.12"
},
@@ -81,9 +81,9 @@
},
"dependencies": {
"@0x/base-contract": "^6.4.0",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/order-utils": "^10.4.21",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/order-utils": "^10.4.22",
"@0x/types": "^3.3.3",
"@0x/typescript-typings": "^5.2.0",
"@0x/utils": "^6.4.3",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "3.2.31",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "3.2.30",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.2.31 - _May 21, 2021_
* Dependencies updated
## v3.2.30 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange",
"version": "3.2.30",
"version": "3.2.31",
"engines": {
"node": ">=6.12"
},
@@ -53,13 +53,13 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/protocol",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-exchange-libs": "^4.3.29",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-exchange-libs": "^4.3.30",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-multisig": "^4.1.30",
"@0x/contracts-staking": "^2.0.37",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-multisig": "^4.1.31",
"@0x/contracts-staking": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/dev-utils": "^4.2.7",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
@@ -89,11 +89,11 @@
},
"dependencies": {
"@0x/base-contract": "^6.4.0",
"@0x/contracts-dev-utils": "^1.3.28",
"@0x/contracts-erc1155": "^2.1.29",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-erc721": "^3.1.29",
"@0x/order-utils": "^10.4.21",
"@0x/contracts-dev-utils": "^1.3.29",
"@0x/contracts-erc1155": "^2.1.30",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-erc721": "^3.1.30",
"@0x/order-utils": "^10.4.22",
"@0x/utils": "^6.4.3",
"lodash": "^4.17.11"
},

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "6.2.25",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "6.2.24",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v6.2.25 - _May 21, 2021_
* Dependencies updated
## v6.2.24 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-extensions",
"version": "6.2.24",
"version": "6.2.25",
"engines": {
"node": ">=6.12"
},
@@ -53,16 +53,16 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-dev-utils": "^1.3.28",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-erc721": "^3.1.29",
"@0x/contracts-exchange": "^3.2.30",
"@0x/contracts-exchange-libs": "^4.3.29",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-dev-utils": "^1.3.29",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-erc721": "^3.1.30",
"@0x/contracts-exchange": "^3.2.31",
"@0x/contracts-exchange-libs": "^4.3.30",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-utils": "^4.7.9",
"@0x/dev-utils": "^4.2.7",
"@0x/order-utils": "^10.4.21",
"@0x/order-utils": "^10.4.22",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
@@ -91,7 +91,7 @@
},
"dependencies": {
"@0x/base-contract": "^6.4.0",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/typescript-typings": "^5.2.0",
"ethereum-types": "^3.5.0"
},

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-integrations",
"version": "2.7.40",
"version": "2.7.45",
"private": true,
"engines": {
"node": ">=6.12"
@@ -53,21 +53,21 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contract-addresses": "^6.1.0",
"@0x/contract-wrappers": "^13.16.1",
"@0x/contracts-broker": "^1.1.29",
"@0x/contracts-coordinator": "^3.1.30",
"@0x/contracts-dev-utils": "^1.3.28",
"@0x/contracts-exchange-forwarder": "^4.2.30",
"@0x/contracts-exchange-libs": "^4.3.29",
"@0x/contracts-extensions": "^6.2.24",
"@0x/contract-addresses": "^6.2.0",
"@0x/contract-wrappers": "^13.16.2",
"@0x/contracts-broker": "^1.1.30",
"@0x/contracts-coordinator": "^3.1.31",
"@0x/contracts-dev-utils": "^1.3.29",
"@0x/contracts-exchange-forwarder": "^4.2.31",
"@0x/contracts-exchange-libs": "^4.3.30",
"@0x/contracts-extensions": "^6.2.25",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-utils": "^4.7.9",
"@0x/coordinator-server": "^1.0.5",
"@0x/dev-utils": "^4.2.7",
"@0x/migrations": "^8.0.6",
"@0x/order-utils": "^10.4.21",
"@0x/protocol-utils": "^1.6.0",
"@0x/migrations": "^8.0.7",
"@0x/order-utils": "^10.4.22",
"@0x/protocol-utils": "^1.6.1",
"@0x/sol-compiler": "^4.7.3",
"@0x/tslint-config": "^4.1.4",
"@0x/web3-wrapper": "^7.5.3",
@@ -93,17 +93,17 @@
"typescript": "4.2.2"
},
"dependencies": {
"@0x/asset-swapper": "^6.10.0",
"@0x/asset-swapper": "^6.15.0",
"@0x/base-contract": "^6.4.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-erc1155": "^2.1.29",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-erc721": "^3.1.29",
"@0x/contracts-exchange": "^3.2.30",
"@0x/contracts-multisig": "^4.1.30",
"@0x/contracts-staking": "^2.0.37",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-zero-ex": "^0.23.0",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-erc1155": "^2.1.30",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-erc721": "^3.1.30",
"@0x/contracts-exchange": "^3.2.31",
"@0x/contracts-multisig": "^4.1.31",
"@0x/contracts-staking": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-zero-ex": "^0.24.0",
"@0x/subproviders": "^6.5.3",
"@0x/types": "^3.3.3",
"@0x/typescript-typings": "^5.2.0",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "4.1.31",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "4.1.30",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.1.31 - _May 21, 2021_
* Dependencies updated
## v4.1.30 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-multisig",
"version": "4.1.30",
"version": "4.1.31",
"engines": {
"node": ">=6.12"
},
@@ -50,11 +50,11 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/multisig",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/dev-utils": "^4.2.7",
"@0x/sol-compiler": "^4.7.3",
"@0x/tslint-config": "^4.1.4",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "2.0.38",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.0.37",
"changes": [

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.0.38 - _May 21, 2021_
* Dependencies updated
## v2.0.37 - _May 5, 2021_
* Patch epoch finalization issue (#221)

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-staking",
"version": "2.0.37",
"version": "2.0.38",
"engines": {
"node": ">=6.12"
},
@@ -54,14 +54,14 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-dev-utils": "^1.3.28",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-exchange-libs": "^4.3.29",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-dev-utils": "^1.3.29",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-exchange-libs": "^4.3.30",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-utils": "^4.7.9",
"@0x/dev-utils": "^4.2.7",
"@0x/order-utils": "^10.4.21",
"@0x/order-utils": "^10.4.22",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
@@ -88,7 +88,7 @@
},
"dependencies": {
"@0x/base-contract": "^6.4.0",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/typescript-typings": "^5.2.0",
"@0x/utils": "^6.4.3",
"ethereum-types": "^3.5.0",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "5.4.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "5.4.0",
"changes": [

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v5.4.1 - _May 21, 2021_
* Dependencies updated
## v5.4.0 - _May 5, 2021_
* Set default ganache gas limit to 100e6 (#197)

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-test-utils",
"version": "5.4.0",
"version": "5.4.1",
"engines": {
"node": ">=6.12"
},
@@ -44,10 +44,10 @@
"dependencies": {
"@0x/assert": "^3.0.27",
"@0x/base-contract": "^6.4.0",
"@0x/contract-addresses": "^6.1.0",
"@0x/contract-addresses": "^6.2.0",
"@0x/dev-utils": "^4.2.7",
"@0x/json-schemas": "^6.1.3",
"@0x/order-utils": "^10.4.21",
"@0x/order-utils": "^10.4.22",
"@0x/sol-coverage": "^4.0.37",
"@0x/sol-profiler": "^4.1.27",
"@0x/sol-trace": "^3.0.37",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "1.1.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "1.1.6",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.1.7 - _May 21, 2021_
* Dependencies updated
## v1.1.6 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-treasury",
"version": "1.1.6",
"version": "1.1.7",
"engines": {
"node": ">=6.12"
},
@@ -47,12 +47,12 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/treasury",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contract-addresses": "^6.1.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contract-addresses": "^6.2.0",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-staking": "^2.0.37",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-staking": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
@@ -73,7 +73,7 @@
},
"dependencies": {
"@0x/base-contract": "^6.4.0",
"@0x/protocol-utils": "^1.6.0",
"@0x/protocol-utils": "^1.6.1",
"@0x/subproviders": "^6.5.3",
"@0x/types": "^3.3.3",
"@0x/typescript-typings": "^5.2.0",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "4.7.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "4.7.8",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.7.9 - _May 21, 2021_
* Dependencies updated
## v4.7.8 - _May 5, 2021_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-utils",
"version": "4.7.8",
"version": "4.7.9",
"engines": {
"node": ">=6.12"
},
@@ -52,9 +52,9 @@
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/dev-utils": "^4.2.7",
"@0x/order-utils": "^10.4.21",
"@0x/order-utils": "^10.4.22",
"@0x/sol-compiler": "^4.7.3",
"@0x/tslint-config": "^4.1.4",
"@0x/types": "^3.3.3",

View File

@@ -1,4 +1,14 @@
[
{
"version": "0.24.0",
"changes": [
{
"note": "Add special selectors to selector collision test",
"pr": 243
}
],
"timestamp": 1621600614
},
{
"version": "0.23.0",
"changes": [

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.24.0 - _May 21, 2021_
* Add special selectors to selector collision test (#243)
## v0.23.0 - _May 5, 2021_
* Added ETH support to `MixinCurve` (#220)

View File

@@ -31,6 +31,7 @@ import "./mixins/MixinCryptoCom.sol";
import "./mixins/MixinDodo.sol";
import "./mixins/MixinDodoV2.sol";
import "./mixins/MixinKyber.sol";
import "./mixins/MixinKyberDmm.sol";
import "./mixins/MixinMakerPSM.sol";
import "./mixins/MixinMooniswap.sol";
import "./mixins/MixinMStable.sol";
@@ -53,6 +54,7 @@ contract BridgeAdapter is
MixinDodo,
MixinDodoV2,
MixinKyber,
MixinKyberDmm,
MixinMakerPSM,
MixinMooniswap,
MixinMStable,
@@ -217,6 +219,12 @@ contract BridgeAdapter is
sellAmount,
order.bridgeData
);
} else if (protocolId == BridgeProtocols.KYBERDMM) {
boughtAmount = _tradeKyberDmm(
buyToken,
sellAmount,
order.bridgeData
);
} else {
boughtAmount = _tradeZeroExBridge(
sellToken,

View File

@@ -46,4 +46,5 @@ library BridgeProtocols {
uint128 internal constant MAKERPSM = 16;
uint128 internal constant BALANCERV2 = 17;
uint128 internal constant UNISWAPV3 = 18;
uint128 internal constant KYBERDMM = 19;
}

View File

@@ -0,0 +1,94 @@
// 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.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";
/*
KyberDmm Router
*/
interface IKyberDmmRouter {
/// @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 amountIn The amount of input tokens to send.
/// @param amountOutMin The minimum amount of output tokens that must be received for the transaction not to revert.
/// @param pools An array of pool addresses. pools.length must be >= 1.
/// @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 to Recipient of the output tokens.
/// @param deadline Unix timestamp after which the transaction will revert.
/// @return amounts The input token amount and all subsequent output token amounts.
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata pools,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
}
contract MixinKyberDmm {
using LibERC20TokenV06 for IERC20TokenV06;
function _tradeKyberDmm(
IERC20TokenV06 buyToken,
uint256 sellAmount,
bytes memory bridgeData
)
internal
returns (uint256 boughtAmount)
{
address router;
address[] memory pools;
address[] memory path;
(router, pools, path) = abi.decode(bridgeData, (address, address[], address[]));
require(pools.length >= 1, "MixinKyberDmm/POOLS_LENGTH_MUST_BE_AT_LEAST_ONE");
require(path.length == pools.length + 1, "MixinKyberDmm/ARRAY_LENGTH_MISMATCH");
require(
path[path.length - 1] == address(buyToken),
"MixinKyberDmm/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"
);
// Grant the KyberDmm router an allowance to sell the first token.
IERC20TokenV06(path[0]).approveIfBelow(address(router), sellAmount);
uint[] memory amounts = IKyberDmmRouter(router).swapExactTokensForTokens(
// Sell all tokens we hold.
sellAmount,
// Minimum buy amount.
1,
pools,
// Convert to `buyToken` along this path.
path,
// Recipient is `this`.
address(this),
// Expires after this block.
block.timestamp
);
return amounts[amounts.length-1];
}
}

View File

@@ -31,6 +31,7 @@ interface IMStable {
IERC20TokenV06 sellToken,
IERC20TokenV06 buyToken,
uint256 sellAmount,
uint256 minBoughtAmount,
address recipient
)
external
@@ -59,6 +60,8 @@ contract MixinMStable {
sellToken,
buyToken,
sellAmount,
// Minimum buy amount.
1,
address(this)
);
}

View File

@@ -69,7 +69,7 @@ contract MixinUniswapV2 {
assembly { path := _path }
}
require(path.length >= 2, "MixinUniswapV3/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
require(path.length >= 2, "MixinUniswapV2/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
require(
path[path.length - 1] == buyToken,
"MixinUniswapV2/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN"

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-zero-ex",
"version": "0.23.0",
"version": "0.24.0",
"engines": {
"node": ">=6.12"
},
@@ -43,7 +43,7 @@
"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",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IFeature|IFlashWallet|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOwnableFeature|IPancakeSwapFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinBalancer|MixinBalancerV2|MixinBancor|MixinCoFiX|MixinCryptoCom|MixinCurve|MixinDodo|MixinDodoV2|MixinKyber|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestMooniswap|TestNativeOrdersFeature|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|WethTransformer|ZeroEx|ZeroExOptimized).json"
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IFeature|IFlashWallet|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOwnableFeature|IPancakeSwapFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinBalancer|MixinBalancerV2|MixinBancor|MixinCoFiX|MixinCryptoCom|MixinCurve|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestMooniswap|TestNativeOrdersFeature|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|WethTransformer|ZeroEx|ZeroExOptimized).json"
},
"repository": {
"type": "git",
@@ -56,12 +56,12 @@
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/zero-ex",
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contract-addresses": "^6.1.0",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contract-addresses": "^6.2.0",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/dev-utils": "^4.2.7",
"@0x/order-utils": "^10.4.21",
"@0x/order-utils": "^10.4.22",
"@0x/sol-compiler": "^4.7.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",
@@ -83,7 +83,7 @@
},
"dependencies": {
"@0x/base-contract": "^6.4.0",
"@0x/protocol-utils": "^1.6.0",
"@0x/protocol-utils": "^1.6.1",
"@0x/subproviders": "^6.5.3",
"@0x/types": "^3.3.3",
"@0x/typescript-typings": "^5.2.0",

View File

@@ -84,6 +84,7 @@ import * as MixinCurve from '../test/generated-artifacts/MixinCurve.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 MixinKyberDmm from '../test/generated-artifacts/MixinKyberDmm.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';
@@ -245,6 +246,7 @@ export const artifacts = {
MixinDodo: MixinDodo as ContractArtifact,
MixinDodoV2: MixinDodoV2 as ContractArtifact,
MixinKyber: MixinKyber as ContractArtifact,
MixinKyberDmm: MixinKyberDmm as ContractArtifact,
MixinMStable: MixinMStable as ContractArtifact,
MixinMakerPSM: MixinMakerPSM as ContractArtifact,
MixinMooniswap: MixinMooniswap as ContractArtifact,

View File

@@ -3,9 +3,14 @@ import { MethodAbi } from 'ethereum-types';
import * as wrappers from '../../src/wrappers';
// tslint:disable:no-string-literal
blockchainTests('Selector collision test', env => {
it('Function selectors do not collide', () => {
const selectorToSignature: { [selector: string]: string } = {};
selectorToSignature['bca8c7b5'] = 'executeCall(address,bytes)'; // legacy allowance target
selectorToSignature['a9059cbb'] = 'transfer(address,uint256)'; // ERC20Token transfer
selectorToSignature['23b872dd'] = 'transferFrom(address,address,uint256)'; // ERC20Token transferFrom
for (const wrapper of Object.values(wrappers)) {
if (typeof wrapper === 'function') {
const contract = new wrapper(constants.NULL_ADDRESS, env.provider, env.txDefaults);

View File

@@ -82,6 +82,7 @@ export * from '../test/generated-wrappers/mixin_curve';
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_kyber_dmm';
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';

View File

@@ -113,6 +113,7 @@
"test/generated-artifacts/MixinDodo.json",
"test/generated-artifacts/MixinDodoV2.json",
"test/generated-artifacts/MixinKyber.json",
"test/generated-artifacts/MixinKyberDmm.json",
"test/generated-artifacts/MixinMStable.json",
"test/generated-artifacts/MixinMakerPSM.json",
"test/generated-artifacts/MixinMooniswap.json",

View File

@@ -10,7 +10,7 @@
],
"scripts": {
"deps_versions:ci": "node ./node_modules/@0x/monorepo-scripts/lib/deps_versions.js",
"fix": "wsrun --fast-exit --parallel --exclude-missing -c fix $PKG",
"fix": "wsrun --fast-exit --parallel --exclude-missing -p $PKG -c fix",
"ganache": "ganache-cli -p 8545 --gasLimit 10000000 --networkId 50 -m \"${npm_package_config_mnemonic}\"",
"prettier": "prettier --write '**/*.{ts,tsx,json,md}' --config .prettierrc",
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config .prettierrc",
@@ -27,17 +27,17 @@
"install:all": "yarn install",
"wsrun": "wsrun",
"lerna": "lerna",
"build": "lerna link && wsrun -r --stages --fast-exit --exclude-missing -c build $PKG",
"build:ci": "lerna link && wsrun --fast-exit -r --stages --exclude-missing -c build:ci $PKG",
"build": "lerna link && wsrun -r --stages --fast-exit --exclude-missing -p $PKG -c build",
"build:ci": "lerna link && wsrun --fast-exit -r --stages --exclude-missing -p $PKG -c build:ci",
"build:contracts": "lerna link && wsrun -p ${npm_package_config_contractsPackages} --fast-exit -r --stages --exclude-missing -c build",
"build:ts": "tsc -b",
"watch:ts": "tsc -b -w",
"clean": "wsrun --fast-exit -r --parallel --exclude-missing clean -c $PKG",
"contracts:watch": "wsrun --parallel --exclude-missing watch -c $PKG",
"clean": "wsrun --fast-exit -r --parallel --exclude-missing -p $PKG -c clean",
"contracts:watch": "wsrun --parallel --exclude-missing -p $PKG -c watch",
"remove_node_modules": "lerna clean --yes; rm -rf node_modules",
"rebuild": "run-s clean build",
"test": "wsrun --fast-exit --serial --exclude-missing -p $(echo $(echo ${npm_package_config_contractsPackages} ${npm_package_config_nonContractPackages} | tr ' ' '\n' | sort | uniq) ${npm_package_config_ignoreTestsForPackages} | tr ' ' '\n' | sort | uniq -u | tr '\n' ' ') -c test",
"test:all": "wsrun --fast-exit --serial --exclude-missing -c test $PKG",
"test:all": "wsrun --fast-exit --serial --exclude-missing -p $PKG -c test",
"test:contracts": "wsrun --serial -p $(echo ${npm_package_config_contractsPackages} ${npm_package_config_ignoreTestsForPackages} | tr ' ' '\n' | sort | uniq -u | tr '\n' ' ') --fast-exit --exclude-missing -c test",
"test:contracts:all": "wsrun --serial -p ${npm_package_config_contractsPackages} --fast-exit --exclude-missing -c test",
"generate_doc": "node ./node_modules/@0x/monorepo-scripts/lib/doc_generate.js --config ./doc-gen-config.json",
@@ -45,7 +45,7 @@
"diff_md_docs:ci": "wsrun --exclude-missing -c diff_docs",
"test:generate_docs:circleci": "for i in ${npm_package_config_packagesWithDocPages}; do yarn generate_doc --package $i || break -1; done;",
"bundlewatch": "bundlewatch",
"lint": "wsrun --fast-exit --parallel --exclude-missing -c lint $PKG",
"lint": "wsrun --fast-exit --parallel --exclude-missing -p $PKG -c lint",
"upgrade_org_deps": "node node_modules/@0x/monorepo-scripts/lib/upgrade_deps.js -p '@0x|ethereum-types'",
"upgrade_deps": "node node_modules/@0x/monorepo-scripts/lib/upgrade_deps.js",
"verdaccio": "docker run --rm -i -p 4873:4873 0xorg/verdaccio"

View File

@@ -1,4 +1,81 @@
[
{
"version": "6.15.0",
"changes": [
{
"note": "Fix KyberDmm",
"pr": 236
},
{
"note": "Re-enable KyberDmm",
"pr": 247
},
{
"note": "Add Huobi Token to liquidity provider tokens",
"pr": 246
},
{
"note": "Temporarily disable specific LiquidityProvider"
}
],
"timestamp": 1621600614
},
{
"version": "6.14.0",
"changes": [
{
"note": "Add support for additional sources and intermediate tokens on Ropsten",
"pr": 231
}
],
"timestamp": 1620810800
},
{
"version": "6.13.0",
"changes": [
{
"note": "Add LiquidityProvider to BSC sources",
"pr": 234
}
],
"timestamp": 1620703098
},
{
"version": "6.12.0",
"changes": [
{
"note": "`TwoHopSampler` to use `call` over `staticcall` in order to support sources like `Uniswap_V3` and `Balancer_V2`",
"pr": 233
}
],
"timestamp": 1620610602
},
{
"version": "6.11.0",
"changes": [
{
"note": "Add price comparisons data separate from the quote report",
"pr": 219
},
{
"note": "Add caching for top Balancer V2 pools on startup and during regular intervals",
"pr": 228
},
{
"note": "Tweak compiler settings for smaller sampler bytecode",
"pr": 229
},
{
"note": "Fix Multiplex multihop encoding for ETH buys/sells",
"pr": 230
},
{
"note": "Fix Sampler address override for Ganache",
"pr": 232
}
],
"timestamp": 1620362129
},
{
"version": "6.10.0",
"changes": [

View File

@@ -5,6 +5,33 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v6.15.0 - _May 21, 2021_
* Fix KyberDmm (#236)
* Re-enable KyberDmm (#247)
* Add Huobi Token to liquidity provider tokens (#246)
* Temporarily disable specific LiquidityProvider
## v6.14.0 - _May 12, 2021_
* Add support for additional sources and intermediate tokens on Ropsten (#231)
## v6.13.0 - _May 11, 2021_
* Add LiquidityProvider to BSC sources (#234)
## v6.12.0 - _May 10, 2021_
* `TwoHopSampler` to use `call` over `staticcall` in order to support sources like `Uniswap_V3` and `Balancer_V2` (#233)
## v6.11.0 - _May 7, 2021_
* Add price comparisons data separate from the quote report (#219)
* Add caching for top Balancer V2 pools on startup and during regular intervals (#228)
* Tweak compiler settings for smaller sampler bytecode (#229)
* Fix Multiplex multihop encoding for ETH buys/sells (#230)
* Fix Sampler address override for Ganache (#232)
## v6.10.0 - _May 5, 2021_
* Reactivate PancakeSwapV2 and BakerySwap VIP on BSC (#222)

View File

@@ -6,7 +6,7 @@
"shouldSaveStandardInput": true,
"compilerSettings": {
"evmVersion": "istanbul",
"optimizer": { "enabled": false, "runs": 200, "details": { "yul": true } },
"optimizer": { "enabled": true, "runs": 200, "details": { "yul": true, "deduplicate": true } },
"outputSelection": {
"*": {
"*": [

View File

@@ -28,6 +28,7 @@ import "./DODOSampler.sol";
import "./DODOV2Sampler.sol";
import "./Eth2DaiSampler.sol";
import "./KyberSampler.sol";
import "./KyberDmmSampler.sol";
import "./LiquidityProviderSampler.sol";
import "./MakerPSMSampler.sol";
import "./MultiBridgeSampler.sol";
@@ -52,6 +53,7 @@ contract ERC20BridgeSampler is
DODOV2Sampler,
Eth2DaiSampler,
KyberSampler,
KyberDmmSampler,
LiquidityProviderSampler,
MakerPSMSampler,
MStableSampler,

View File

@@ -0,0 +1,159 @@
// 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;
interface IKyberDmmFactory {
function getPoolAtIndex(address token0, address token1, uint256 index)
external
view
returns (address);
}
interface IKyberDmmRouter {
function factory() external view returns (address);
function getAmountsOut(uint256 amountIn, address[] calldata pools, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata pools, address[] calldata path)
external
view
returns (uint256[] memory amounts);
}
contract KyberDmmSampler
{
/// @dev Gas limit for KyberDmm calls.
uint256 constant private KYBER_DMM_CALL_GAS = 150e3; // 150k
/// @dev Sample sell quotes from KyberDmm.
/// @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 pools The pool addresses involved in the multi path trade
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromKyberDmm(
address router,
address[] memory path,
uint256[] memory takerTokenAmounts
)
public
view
returns (address[] memory pools, uint256[] memory makerTokenAmounts)
{
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
pools = _getKyberDmmPools(router, path);
if (pools.length == 0) {
return (pools, makerTokenAmounts);
}
for (uint256 i = 0; i < numSamples; i++) {
try
IKyberDmmRouter(router).getAmountsOut
{gas: KYBER_DMM_CALL_GAS}
(takerTokenAmounts[i], pools, path)
returns (uint256[] memory amounts)
{
makerTokenAmounts[i] = amounts[path.length - 1];
// 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 KyberDmm.
/// @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 pools The pool addresses involved in the multi path trade
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromKyberDmm(
address router,
address[] memory path,
uint256[] memory makerTokenAmounts
)
public
view
returns (address[] memory pools, uint256[] memory takerTokenAmounts)
{
uint256 numSamples = makerTokenAmounts.length;
takerTokenAmounts = new uint256[](numSamples);
pools = _getKyberDmmPools(router, path);
if (pools.length == 0) {
return (pools, takerTokenAmounts);
}
for (uint256 i = 0; i < numSamples; i++) {
try
IKyberDmmRouter(router).getAmountsIn
{gas: KYBER_DMM_CALL_GAS}
(makerTokenAmounts[i], pools, path)
returns (uint256[] memory amounts)
{
takerTokenAmounts[i] = amounts[0];
// Break early if there are 0 amounts
if (takerTokenAmounts[i] == 0) {
break;
}
} catch (bytes memory) {
// Swallow failures, leaving all results as zero.
break;
}
}
}
function _getKyberDmmPools(
address router,
address[] memory path
)
private
view
returns (address[] memory pools)
{
pools = new address[](path.length - 1);
IKyberDmmFactory factory = IKyberDmmFactory(IKyberDmmRouter(router).factory());
for (uint256 i = 0; i < pools.length; i++) {
// Currently only supporting the first pool found at the index
try
factory.getPoolAtIndex
{gas: KYBER_DMM_CALL_GAS}
(path[i], path[i + 1], 0)
returns (address pool)
{
pools[i] = pool;
} catch (bytes memory) {
return new address[](0);
}
}
}
}

View File

@@ -49,6 +49,7 @@ contract MStableSampler is
view
returns (uint256[] memory makerTokenAmounts)
{
_assertValidPair(makerToken, takerToken);
// Initialize array of maker token amounts.
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
@@ -58,7 +59,7 @@ contract MStableSampler is
IMStable(router).getSwapOutput
{gas: DEFAULT_CALL_GAS}
(takerToken, makerToken, takerTokenAmounts[i])
returns (bool, string memory, uint256 amount)
returns (uint256 amount)
{
makerTokenAmounts[i] = amount;
// Break early if there are 0 amounts

View File

@@ -37,7 +37,6 @@ contract TwoHopSampler {
uint256 sellAmount
)
public
view
returns (
HopInfo memory firstHop,
HopInfo memory secondHop,
@@ -47,7 +46,7 @@ contract TwoHopSampler {
uint256 intermediateAssetAmount = 0;
for (uint256 i = 0; i != firstHopCalls.length; ++i) {
firstHopCalls[i].writeUint256(firstHopCalls[i].length - 32, sellAmount);
(bool didSucceed, bytes memory returnData) = address(this).staticcall(firstHopCalls[i]);
(bool didSucceed, bytes memory returnData) = address(this).call(firstHopCalls[i]);
if (didSucceed) {
uint256 amount = returnData.readUint256(returnData.length - 32);
if (amount > intermediateAssetAmount) {
@@ -62,7 +61,7 @@ contract TwoHopSampler {
}
for (uint256 j = 0; j != secondHopCalls.length; ++j) {
secondHopCalls[j].writeUint256(secondHopCalls[j].length - 32, intermediateAssetAmount);
(bool didSucceed, bytes memory returnData) = address(this).staticcall(secondHopCalls[j]);
(bool didSucceed, bytes memory returnData) = address(this).call(secondHopCalls[j]);
if (didSucceed) {
uint256 amount = returnData.readUint256(returnData.length - 32);
if (amount > buyAmount) {
@@ -80,7 +79,6 @@ contract TwoHopSampler {
uint256 buyAmount
)
public
view
returns (
HopInfo memory firstHop,
HopInfo memory secondHop,
@@ -91,7 +89,7 @@ contract TwoHopSampler {
uint256 intermediateAssetAmount = uint256(-1);
for (uint256 j = 0; j != secondHopCalls.length; ++j) {
secondHopCalls[j].writeUint256(secondHopCalls[j].length - 32, buyAmount);
(bool didSucceed, bytes memory returnData) = address(this).staticcall(secondHopCalls[j]);
(bool didSucceed, bytes memory returnData) = address(this).call(secondHopCalls[j]);
if (didSucceed) {
uint256 amount = returnData.readUint256(returnData.length - 32);
if (
@@ -109,7 +107,7 @@ contract TwoHopSampler {
}
for (uint256 i = 0; i != firstHopCalls.length; ++i) {
firstHopCalls[i].writeUint256(firstHopCalls[i].length - 32, intermediateAssetAmount);
(bool didSucceed, bytes memory returnData) = address(this).staticcall(firstHopCalls[i]);
(bool didSucceed, bytes memory returnData) = address(this).call(firstHopCalls[i]);
if (didSucceed) {
uint256 amount = returnData.readUint256(returnData.length - 32);
if (

View File

@@ -57,9 +57,9 @@ contract UniswapV3Sampler
/// @param quoter UniswapV3 Quoter contract.
/// @param path Token route. Should be takerToken -> makerToken
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return uniswapPaths The encoded uniswap path for each sample.
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
/// @return uniswapPaths The encoded uniswap path for each sample.
function sampleSellsFromUniswapV3(
IUniswapV3Quoter quoter,
IERC20TokenV06[] memory path,
@@ -67,8 +67,8 @@ contract UniswapV3Sampler
)
public
returns (
uint256[] memory makerTokenAmounts,
bytes[] memory uniswapPaths
bytes[] memory uniswapPaths,
uint256[] memory makerTokenAmounts
)
{
IUniswapV3Pool[][] memory poolPaths =
@@ -108,9 +108,9 @@ contract UniswapV3Sampler
/// @param quoter UniswapV3 Quoter contract.
/// @param path Token route. Should be takerToken -> makerToken.
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return uniswapPaths The encoded uniswap path for each sample.
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
/// @return uniswapPaths The encoded uniswap path for each sample.
function sampleBuysFromUniswapV3(
IUniswapV3Quoter quoter,
IERC20TokenV06[] memory path,
@@ -118,8 +118,8 @@ contract UniswapV3Sampler
)
public
returns (
uint256[] memory takerTokenAmounts,
bytes[] memory uniswapPaths
bytes[] memory uniswapPaths,
uint256[] memory takerTokenAmounts
)
{
IUniswapV3Pool[][] memory poolPaths =

View File

@@ -29,5 +29,5 @@ interface IMStable {
)
external
view
returns (bool, string memory, uint256 output);
returns (uint256 swapOutput);
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/asset-swapper",
"version": "6.10.0",
"version": "6.15.0",
"engines": {
"node": ">=6.12"
},
@@ -33,12 +33,13 @@
"generate_contract_wrappers": "abi-gen --debug --abis ${npm_package_config_abis} --output test/generated-wrappers --backend ethers",
"contracts:gen": "contracts-gen generate",
"contracts:copy": "contracts-gen copy",
"publish:private": "yarn build && gitpkg publish"
"publish:private": "yarn build && gitpkg publish",
"sampler-size": "jq .compilerOutput.evm.deployedBytecode.object -- test/generated-artifacts/ERC20BridgeSampler.json | echo $(( $(wc -c) / 2 - 1 ))"
},
"config": {
"publicInterfaceContracts": "ERC20BridgeSampler,BalanceChecker,FakeTaker",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
"abis": "./test/generated-artifacts/@(ApproximateBuys|BalanceChecker|BalancerSampler|BalancerV2Sampler|BancorSampler|CurveSampler|DODOSampler|DODOV2Sampler|DummyLiquidityProvider|ERC20BridgeSampler|Eth2DaiSampler|FakeTaker|IBalancer|IBancor|ICurve|IEth2Dai|IKyberNetwork|IMStable|IMooniswap|IMultiBridge|IShell|ISmoothy|IUniswapExchangeQuotes|IUniswapV2Router01|KyberSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|MultiBridgeSampler|NativeOrderSampler|SamplerUtils|ShellSampler|SmoothySampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UniswapV3Sampler|UtilitySampler).json",
"abis": "./test/generated-artifacts/@(ApproximateBuys|BalanceChecker|BalancerSampler|BalancerV2Sampler|BancorSampler|CurveSampler|DODOSampler|DODOV2Sampler|DummyLiquidityProvider|ERC20BridgeSampler|Eth2DaiSampler|FakeTaker|IBalancer|IBancor|ICurve|IEth2Dai|IKyberNetwork|IMStable|IMooniswap|IMultiBridge|IShell|ISmoothy|IUniswapExchangeQuotes|IUniswapV2Router01|KyberDmmSampler|KyberSampler|LiquidityProviderSampler|MStableSampler|MakerPSMSampler|MooniswapSampler|MultiBridgeSampler|NativeOrderSampler|SamplerUtils|ShellSampler|SmoothySampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler|UniswapV3Sampler|UtilitySampler).json",
"postpublish": {
"assets": []
}
@@ -59,14 +60,14 @@
"dependencies": {
"@0x/assert": "^3.0.27",
"@0x/base-contract": "^6.4.0",
"@0x/contract-addresses": "^6.1.0",
"@0x/contract-wrappers": "^13.16.1",
"@0x/contracts-erc20": "^3.3.8",
"@0x/contracts-zero-ex": "^0.23.0",
"@0x/contract-addresses": "^6.2.0",
"@0x/contract-wrappers": "^13.16.2",
"@0x/contracts-erc20": "^3.3.9",
"@0x/contracts-zero-ex": "^0.24.0",
"@0x/dev-utils": "^4.2.7",
"@0x/json-schemas": "^6.1.3",
"@0x/protocol-utils": "^1.6.0",
"@0x/quote-server": "^5.0.0",
"@0x/protocol-utils": "^1.6.1",
"@0x/quote-server": "^6.0.2",
"@0x/types": "^3.3.3",
"@0x/typescript-typings": "^5.2.0",
"@0x/utils": "^6.4.3",
@@ -92,14 +93,14 @@
},
"devDependencies": {
"@0x/abi-gen": "^5.6.0",
"@0x/contracts-asset-proxy": "^3.7.11",
"@0x/contracts-exchange": "^3.2.30",
"@0x/contracts-exchange-libs": "^4.3.29",
"@0x/contracts-asset-proxy": "^3.7.12",
"@0x/contracts-exchange": "^3.2.31",
"@0x/contracts-exchange-libs": "^4.3.30",
"@0x/contracts-gen": "^2.0.38",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contracts-utils": "^4.7.8",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/contracts-utils": "^4.7.9",
"@0x/mesh-rpc-client": "^9.4.2",
"@0x/migrations": "^8.0.6",
"@0x/migrations": "^8.0.7",
"@0x/sol-compiler": "^4.7.3",
"@0x/subproviders": "^6.5.3",
"@0x/ts-doc-gen": "^0.0.28",

View File

@@ -5,7 +5,12 @@ export {
SendTransactionOpts,
} from '@0x/base-contract';
export { ContractAddresses } from '@0x/contract-addresses';
export { V4RFQFirmQuote, V4RFQIndicativeQuote, V4SignedRfqOrder, TakerRequestQueryParams } from '@0x/quote-server';
export {
V4RFQFirmQuote,
V4RFQIndicativeQuote,
V4SignedRfqOrder,
TakerRequestQueryParamsUnnested as TakerRequestQueryParams,
} from '@0x/quote-server';
export { Asset, AssetPairsItem, DecodedLogEvent, EventCallback, IndexedFilterValues } from '@0x/types';
export { BigNumber } from '@0x/utils';
export {
@@ -161,6 +166,7 @@ export {
NativeRfqOrderQuoteReportEntry,
QuoteReport,
QuoteReportEntry,
PriceComparisonsReport,
} from './utils/quote_report_generator';
export { QuoteRequestor } from './utils/quote_requestor';
export { ERC20BridgeSamplerContract, BalanceCheckerContract, FakeTakerContract } from './wrappers';

View File

@@ -565,14 +565,17 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
private _encodeMultiplexMultiHopFillCalldata(quote: SwapQuote, opts: ExchangeProxyContractOpts): string {
const wrappedMultiHopCalls = [];
const tokens: string[] = [];
if (opts.isFromETH) {
wrappedMultiHopCalls.push({
selector: DUMMY_WETH_CONTRACT.getSelector('deposit'),
data: NULL_BYTES,
});
tokens.push(ETH_TOKEN_ADDRESS);
}
const [firstHopOrder, secondHopOrder] = quote.orders;
const intermediateToken = firstHopOrder.makerToken;
tokens.push(quote.takerToken, intermediateToken, quote.makerToken);
for (const order of [firstHopOrder, secondHopOrder]) {
switch (order.source) {
case ERC20BridgeSource.UniswapV2:
@@ -607,11 +610,12 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
selector: DUMMY_WETH_CONTRACT.getSelector('withdraw'),
data: NULL_BYTES,
});
tokens.push(ETH_TOKEN_ADDRESS);
}
return this._exchangeProxy
.multiHopFill(
{
tokens: [quote.takerToken, intermediateToken, quote.makerToken],
tokens,
sellAmount: quote.worstCaseQuoteInfo.totalTakerAmount,
calls: wrappedMultiHopCalls,
},

View File

@@ -114,18 +114,20 @@ export class SwapQuoter {
);
// Allow the sampler bytecode to be overwritten using geths override functionality
const samplerBytecode = _.get(artifacts.ERC20BridgeSampler, 'compilerOutput.evm.deployedBytecode.object');
// Allow address of the Sampler to be overridden, i.e in Ganache where overrides do not work
const samplerAddress = (options.samplerOverrides && options.samplerOverrides.to) || SAMPLER_ADDRESS;
const defaultCodeOverrides = samplerBytecode
? {
[SAMPLER_ADDRESS]: { code: samplerBytecode },
[samplerAddress]: { code: samplerBytecode },
}
: {};
const samplerOverrides = _.assign(
{ block: BlockParamLiteral.Latest, overrides: defaultCodeOverrides },
options.samplerOverrides,
);
const fastAbi = new FastABI(ERC20BridgeSamplerContract.ABI() as MethodAbi[]);
const fastAbi = new FastABI(ERC20BridgeSamplerContract.ABI() as MethodAbi[], { BigNumber });
const samplerContract = new ERC20BridgeSamplerContract(
SAMPLER_ADDRESS,
samplerAddress,
this.provider,
{
gas: samplerGasLimit,
@@ -495,7 +497,14 @@ function createSwapQuote(
gasSchedule: FeeSchedule,
slippage: number,
): SwapQuote {
const { optimizedOrders, quoteReport, sourceFlags, takerAmountPerEth, makerAmountPerEth } = optimizerResult;
const {
optimizedOrders,
quoteReport,
sourceFlags,
takerAmountPerEth,
makerAmountPerEth,
priceComparisonsReport,
} = optimizerResult;
const isTwoHop = sourceFlags === SOURCE_FLAGS[ERC20BridgeSource.MultiHop];
// Calculate quote info
@@ -519,6 +528,7 @@ function createSwapQuote(
makerAmountPerEth,
quoteReport,
isTwoHop,
priceComparisonsReport,
};
if (operation === MarketOperation.Buy) {

View File

@@ -7,7 +7,8 @@ import {
RfqOrderFields,
Signature,
} from '@0x/protocol-utils';
import { TakerRequestQueryParams, V4SignedRfqOrder } from '@0x/quote-server';
import { TakerRequestQueryParamsUnnested, V4SignedRfqOrder } from '@0x/quote-server';
import { Fee } from '@0x/quote-server/lib/src/types';
import { BigNumber } from '@0x/utils';
import { AxiosRequestConfig } from 'axios';
@@ -18,7 +19,7 @@ import {
OptimizedMarketOrder,
TokenAdjacencyGraph,
} from './utils/market_operation_utils/types';
import { QuoteReport } from './utils/quote_report_generator';
import { PriceComparisonsReport, QuoteReport } from './utils/quote_report_generator';
/**
* expiryBufferMs: The number of seconds to add when calculating whether an order is expired or not. Defaults to 300s (5m).
@@ -169,6 +170,7 @@ export interface SwapQuoteBase {
worstCaseQuoteInfo: SwapQuoteInfo;
sourceBreakdown: SwapQuoteOrdersBreakdown;
quoteReport?: QuoteReport;
priceComparisonsReport?: PriceComparisonsReport;
isTwoHop: boolean;
makerTokenDecimals: number;
takerTokenDecimals: number;
@@ -231,6 +233,12 @@ export type SwapQuoteOrdersBreakdown = Partial<
* If set to `true` and `ERC20BridgeSource.Native` is part of the `excludedSources`
* array in `SwapQuoteRequestOpts`, an Error will be raised.
*/
export interface RfqmRequestOptions extends RfqRequestOpts {
isLastLook: true;
fee: Fee;
}
export interface RfqRequestOpts {
takerAddress: string;
txOrigin: string;
@@ -241,6 +249,7 @@ export interface RfqRequestOpts {
nativeExclusivelyRFQ?: boolean;
altRfqAssetOfferings?: AltRfqMakerAssetOfferings;
isLastLook?: boolean;
fee?: Fee;
}
/**
@@ -365,7 +374,7 @@ export enum OrderPrunerPermittedFeeTypes {
export interface MockedRfqQuoteResponse {
endpoint: string;
requestApiKey: string;
requestParams: TakerRequestQueryParams;
requestParams: TakerRequestQueryParamsUnnested;
responseData: any;
responseCode: number;
callback?: (config: any) => Promise<any>;
@@ -385,6 +394,7 @@ export interface AltMockedRfqQuoteResponse {
export interface SamplerOverrides {
overrides: GethCallOverrides;
block: BlockParam;
to?: string;
}
export interface SamplerCallResult {

View File

@@ -1,5 +1,5 @@
import { Web3Wrapper } from '@0x/dev-utils';
import { TakerRequestQueryParams, V4RFQFirmQuote, V4RFQIndicativeQuote } from '@0x/quote-server';
import { TakerRequestQueryParamsUnnested, V4RFQFirmQuote, V4RFQIndicativeQuote } from '@0x/quote-server';
import { BigNumber } from '@0x/utils';
import { AxiosInstance, CancelToken } from 'axios';
@@ -123,7 +123,7 @@ export async function returnQuoteFromAltMMAsync<ResponseT>(
takerToken: string,
maxResponseTimeMs: number,
altRfqAssetOfferings: AltRfqMakerAssetOfferings,
takerRequestQueryParams: TakerRequestQueryParams,
takerRequestQueryParams: TakerRequestQueryParamsUnnested,
axiosInstance: AxiosInstance,
warningLogger: LogFunction,
cancelToken: CancelToken,

View File

@@ -14,9 +14,9 @@ import {
JULSWAP_ROUTER_BY_CHAIN_ID,
KYBER_BANNED_RESERVES,
KYBER_BRIDGED_LIQUIDITY_PREFIX,
KYBER_DMM_ROUTER_BY_CHAIN_ID,
MAX_DODOV2_POOLS_QUERIED,
MAX_KYBER_RESERVES_QUERIED,
MSTABLE_POOLS_BY_CHAIN_ID,
NERVE_BSC_INFOS,
NULL_ADDRESS,
PANCAKESWAP_ROUTER_BY_CHAIN_ID,
@@ -86,6 +86,16 @@ export function getComponentForPair(chainId: ChainId, takerToken: string, makerT
.map(i => i.poolAddress);
}
// tslint:disable completed-docs
export function getMStableForPair(chainId: ChainId, takerToken: string, makerToken: string): string[] {
if (chainId !== ChainId.Mainnet) {
return [];
}
return Object.values(MSTABLE_POOLS_BY_CHAIN_ID[chainId])
.filter(c => [makerToken, takerToken].every(t => c.tokens.includes(t)))
.map(i => i.poolAddress);
}
// tslint:disable completed-docs
export function getCurveInfosForPair(chainId: ChainId, takerToken: string, makerToken: string): CurveInfo[] {
if (chainId !== ChainId.Mainnet) {
@@ -221,13 +231,15 @@ export function getShellLikeInfosForPair(
chainId: ChainId,
takerToken: string,
makerToken: string,
source: ERC20BridgeSource.Shell | ERC20BridgeSource.Component,
source: ERC20BridgeSource.Shell | ERC20BridgeSource.Component | ERC20BridgeSource.MStable,
): string[] {
switch (source) {
case ERC20BridgeSource.Shell:
return getShellsForPair(chainId, takerToken, makerToken);
case ERC20BridgeSource.Component:
return getComponentForPair(chainId, takerToken, makerToken);
case ERC20BridgeSource.MStable:
return getMStableForPair(chainId, takerToken, makerToken);
default:
throw new Error(`Unknown Shell like source ${source}`);
}
@@ -301,7 +313,6 @@ export function uniswapV2LikeRouterAddress(
| ERC20BridgeSource.PancakeSwap
| ERC20BridgeSource.PancakeSwapV2
| ERC20BridgeSource.BakerySwap
| ERC20BridgeSource.KyberDmm
| ERC20BridgeSource.ApeSwap
| ERC20BridgeSource.CafeSwap
| ERC20BridgeSource.CheeseSwap
@@ -320,8 +331,6 @@ export function uniswapV2LikeRouterAddress(
return PANCAKESWAPV2_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.BakerySwap:
return BAKERYSWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.KyberDmm:
return KYBER_DMM_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.ApeSwap:
return APESWAP_ROUTER_BY_CHAIN_ID[chainId];
case ERC20BridgeSource.CafeSwap:

View File

@@ -99,6 +99,8 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.Uniswap,
ERC20BridgeSource.UniswapV2,
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.Curve,
ERC20BridgeSource.Mooniswap,
]),
[ChainId.Rinkeby]: new SourceFilters([ERC20BridgeSource.Native]),
[ChainId.Kovan]: new SourceFilters([ERC20BridgeSource.Native]),
@@ -120,6 +122,7 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.CafeSwap,
ERC20BridgeSource.CheeseSwap,
ERC20BridgeSource.JulSwap,
ERC20BridgeSource.LiquidityProvider,
]),
},
@@ -169,6 +172,8 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.Uniswap,
ERC20BridgeSource.UniswapV2,
ERC20BridgeSource.UniswapV3,
ERC20BridgeSource.Curve,
ERC20BridgeSource.Mooniswap,
]),
[ChainId.Rinkeby]: new SourceFilters([ERC20BridgeSource.Native]),
[ChainId.Kovan]: new SourceFilters([ERC20BridgeSource.Native]),
@@ -190,6 +195,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
ERC20BridgeSource.CafeSwap,
ERC20BridgeSource.CheeseSwap,
ERC20BridgeSource.JulSwap,
ERC20BridgeSource.LiquidityProvider,
]),
},
new SourceFilters([]),
@@ -295,6 +301,7 @@ export const MAINNET_TOKENS = {
crETH: '0xcbc1065255cbc3ab41a6868c22d1f1c573ab89fd',
ankrETH: '0xe95a203b1a91a908f9b9ce46459d101078c2c3cb',
vETH: '0x898bad2774eb97cf6b94605677f43b41871410b1',
HT: '0x6f259637dcD74C767781E37Bc6133cd6A68aa161',
// Mirror Protocol
UST: '0xa47c8bf37f92abed4a126bda807a7b7498661acd',
MIR: '0x09a3ecafa817268f77be1283176b946c4ff2e608',
@@ -414,7 +421,11 @@ export const DEFAULT_INTERMEDIATE_TOKENS_BY_CHAIN_ID = valueByChainId<string[]>(
'0x2170ed0880ac9a755fd29b2688956bd959f933f8', // ETH
'0x55d398326f99059ff775485246999027b3197955', // BUSD-T
],
[ChainId.Ropsten]: [getContractAddressesForChainOrThrow(ChainId.Ropsten).etherToken],
[ChainId.Ropsten]: [
getContractAddressesForChainOrThrow(ChainId.Ropsten).etherToken,
'0xad6d458402f60fd3bd25163575031acdce07538d', // DAI
'0x07865c6e87b9f70255377e024ace6630c1eaa37f', // USDC
],
},
[],
);
@@ -453,7 +464,10 @@ export const NATIVE_FEE_TOKEN_BY_CHAIN_ID = valueByChainId<string>(
NULL_ADDRESS,
);
export const NATIVE_FEE_TOKEN_AMOUNT_BY_CHAIN_ID = valueByChainId({}, ONE_ETHER);
export const NATIVE_FEE_TOKEN_AMOUNT_BY_CHAIN_ID = valueByChainId(
{ [ChainId.Mainnet]: ONE_ETHER.times(0.1) },
ONE_ETHER,
);
// Order dependent
const CURVE_TRI_POOL_MAINNET_TOKENS = [MAINNET_TOKENS.DAI, MAINNET_TOKENS.USDC, MAINNET_TOKENS.USDT];
@@ -837,17 +851,21 @@ export const LIQUIDITY_PROVIDER_REGISTRY_BY_CHAIN_ID = valueByChainId<LiquidityP
[ChainId.Mainnet]: {
['0x1d0d407c5af8c86f0a6494de86e56ae21e46a951']: {
tokens: [
MAINNET_TOKENS.WETH,
MAINNET_TOKENS.USDC,
MAINNET_TOKENS.USDT,
MAINNET_TOKENS.WBTC,
MAINNET_TOKENS.PAX,
MAINNET_TOKENS.LINK,
MAINNET_TOKENS.KNC,
MAINNET_TOKENS.MANA,
MAINNET_TOKENS.DAI,
MAINNET_TOKENS.BUSD,
MAINNET_TOKENS.AAVE,
// Disabled temporarily as the swap function requires
// gas price to be provided. Making it difficult to get
// a gas estimate
// MAINNET_TOKENS.WETH,
// MAINNET_TOKENS.USDC,
// MAINNET_TOKENS.USDT,
// MAINNET_TOKENS.WBTC,
// MAINNET_TOKENS.PAX,
// MAINNET_TOKENS.LINK,
// MAINNET_TOKENS.KNC,
// MAINNET_TOKENS.MANA,
// MAINNET_TOKENS.DAI,
// MAINNET_TOKENS.BUSD,
// MAINNET_TOKENS.AAVE,
// MAINNET_TOKENS.HT,
],
gasCost: (takerToken: string, makerToken: string) =>
[takerToken, makerToken].includes(MAINNET_TOKENS.WETH) ? 160e3 : 280e3,
@@ -894,11 +912,29 @@ export const LINKSWAP_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
NULL_ADDRESS,
);
export const MSTABLE_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
export const MSTABLE_POOLS_BY_CHAIN_ID = valueByChainId(
{
[ChainId.Mainnet]: '0xe2f2a5c287993345a840db3b0845fbc70f5935a5',
[ChainId.Mainnet]: {
mUSD: {
poolAddress: '0xe2f2a5c287993345a840db3b0845fbc70f5935a5',
tokens: [MAINNET_TOKENS.DAI, MAINNET_TOKENS.USDC, MAINNET_TOKENS.USDT],
},
mBTC: {
poolAddress: '0x945facb997494cc2570096c74b5f66a3507330a1',
tokens: [MAINNET_TOKENS.WBTC, MAINNET_TOKENS.RenBTC, MAINNET_TOKENS.sBTC],
},
},
},
{
mUSD: {
poolAddress: NULL_ADDRESS,
tokens: [] as string[],
},
mBTC: {
poolAddress: NULL_ADDRESS,
tokens: [] as string[],
},
},
NULL_ADDRESS,
);
export const OASIS_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
@@ -910,7 +946,7 @@ export const OASIS_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
export const KYBER_DMM_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
{
[ChainId.Mainnet]: '0x12807818B584a3Fa65D38B6C25B13983fE888D6E',
[ChainId.Mainnet]: '0x1c87257f5e8609940bc751a07bb085bb7f8cdbe6',
},
NULL_ADDRESS,
);
@@ -1059,7 +1095,6 @@ export const BALANCER_V2_SUBGRAPH_URL = 'https://api.thegraph.com/subgraphs/name
export const UNISWAPV3_CONFIG_BY_CHAIN_ID = valueByChainId(
{
// Unconfirmed Mainnet contracts, please confirm
[ChainId.Mainnet]: {
quoter: '0xb27308f9f90d607463bb33ea1bebb41c27ce5ab6',
router: '0xe592427a0aece92de3edee1f18e0157c05861564',
@@ -1196,7 +1231,7 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
[ERC20BridgeSource.Balancer]: () => 120e3,
[ERC20BridgeSource.BalancerV2]: () => 100e3,
[ERC20BridgeSource.Cream]: () => 120e3,
[ERC20BridgeSource.MStable]: () => 700e3,
[ERC20BridgeSource.MStable]: () => 200e3,
[ERC20BridgeSource.MakerPsm]: (fillData?: FillData) => {
const psmFillData = fillData as MakerPsmFillData;
return psmFillData.takerToken === psmFillData.gemTokenAddress ? 210e3 : 290e3;
@@ -1335,5 +1370,6 @@ export const DEFAULT_GET_MARKET_ORDERS_OPTS: GetMarketOrdersOpts = {
exchangeProxyOverhead: () => ZERO_AMOUNT,
allowFallback: true,
shouldGenerateQuoteReport: true,
shouldIncludePriceComparisonsReport: false,
tokenAdjacencyGraph: { default: [] },
};

View File

@@ -16,7 +16,14 @@ import {
getNativeAdjustedMakerFillAmount,
} from '../utils';
import { generateQuoteReport, QuoteReport } from './../quote_report_generator';
import {
dexSampleToReportSource,
generateQuoteReport,
multiHopSampleToReportSource,
nativeOrderToReportEntry,
PriceComparisonsReport,
QuoteReport,
} from './../quote_report_generator';
import { getComparisonPrices } from './comparison_price';
import {
BUY_SOURCE_FILTER_BY_CHAIN_ID,
@@ -68,6 +75,27 @@ export class MarketOperationUtils {
return generateQuoteReport(side, quotes.nativeOrders, liquidityDelivered, comparisonPrice, quoteRequestor);
}
private static _computePriceComparisonsReport(
quoteRequestor: QuoteRequestor | undefined,
marketSideLiquidity: MarketSideLiquidity,
comparisonPrice?: BigNumber | undefined,
): PriceComparisonsReport {
const { side, quotes } = marketSideLiquidity;
const dexSources = _.flatten(quotes.dexQuotes).map(quote => dexSampleToReportSource(quote, side));
const multiHopSources = quotes.twoHopQuotes.map(quote => multiHopSampleToReportSource(quote, side));
const nativeSources = quotes.nativeOrders.map(order =>
nativeOrderToReportEntry(
order.type,
order as any,
order.fillableTakerAmount,
comparisonPrice,
quoteRequestor,
),
);
return { dexSources, multiHopSources, nativeSources };
}
constructor(
private readonly _sampler: DexOrderSampler,
private readonly contractAddresses: AssetSwapperContractAddresses,
@@ -677,7 +705,16 @@ export class MarketOperationUtils {
wholeOrderPrice,
);
}
return { ...optimizerResult, quoteReport };
let priceComparisonsReport: PriceComparisonsReport | undefined;
if (_opts.shouldIncludePriceComparisonsReport) {
priceComparisonsReport = MarketOperationUtils._computePriceComparisonsReport(
_opts.rfqt ? _opts.rfqt.quoteRequestor : undefined,
marketSideLiquidity,
wholeOrderPrice,
);
}
return { ...optimizerResult, quoteReport, priceComparisonsReport };
}
private async _refreshPoolCacheIfRequiredAsync(takerToken: string, makerToken: string): Promise<void> {

View File

@@ -16,6 +16,7 @@ import {
ERC20BridgeSource,
FillData,
GenericRouterFillData,
KyberDmmFillData,
KyberFillData,
LiquidityProviderFillData,
MakerPsmFillData,
@@ -99,8 +100,6 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
return encodeBridgeSourceId(BridgeProtocol.Dodo, 'Dodo');
case ERC20BridgeSource.Kyber:
return encodeBridgeSourceId(BridgeProtocol.Kyber, 'Kyber');
case ERC20BridgeSource.KyberDmm:
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'KyberDmm');
case ERC20BridgeSource.LiquidityProvider:
// "LiquidityProvider" is too long to encode (17 characters).
return encodeBridgeSourceId(BridgeProtocol.Unknown, 'LP');
@@ -158,6 +157,8 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'JulSwap');
case ERC20BridgeSource.UniswapV3:
return encodeBridgeSourceId(BridgeProtocol.UniswapV3, 'UniswapV3');
case ERC20BridgeSource.KyberDmm:
return encodeBridgeSourceId(BridgeProtocol.KyberDmm, 'KyberDmm');
default:
throw new Error(AggregationError.NoBridgeForSource);
}
@@ -217,7 +218,6 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
case ERC20BridgeSource.PancakeSwap:
case ERC20BridgeSource.PancakeSwapV2:
case ERC20BridgeSource.BakerySwap:
case ERC20BridgeSource.KyberDmm:
case ERC20BridgeSource.ApeSwap:
case ERC20BridgeSource.CafeSwap:
case ERC20BridgeSource.CheeseSwap:
@@ -274,6 +274,14 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
const uniswapV3FillData = (order as OptimizedMarketBridgeOrder<FinalUniswapV3FillData>).fillData;
bridgeData = encoder.encode([uniswapV3FillData.router, uniswapV3FillData.uniswapPath]);
break;
case ERC20BridgeSource.KyberDmm:
const kyberDmmFillData = (order as OptimizedMarketBridgeOrder<KyberDmmFillData>).fillData;
bridgeData = encoder.encode([
kyberDmmFillData.router,
kyberDmmFillData.poolsPath,
kyberDmmFillData.tokenAddressPath,
]);
break;
default:
throw new Error(AggregationError.NoBridgeForSource);
}
@@ -390,7 +398,6 @@ export const BRIDGE_ENCODERS: {
[ERC20BridgeSource.SushiSwap]: routerAddressPathEncoder,
[ERC20BridgeSource.CryptoCom]: routerAddressPathEncoder,
[ERC20BridgeSource.Linkswap]: routerAddressPathEncoder,
[ERC20BridgeSource.KyberDmm]: routerAddressPathEncoder,
// BSC
[ERC20BridgeSource.PancakeSwap]: routerAddressPathEncoder,
[ERC20BridgeSource.PancakeSwapV2]: routerAddressPathEncoder,
@@ -415,6 +422,7 @@ export const BRIDGE_ENCODERS: {
{ name: 'router', type: 'address' },
{ name: 'path', type: 'bytes' },
]),
[ERC20BridgeSource.KyberDmm]: AbiEncoder.create('(address,address[],address[])'),
};
function getFillTokenAmounts(fill: CollapsedFill, side: MarketOperation): [BigNumber, BigNumber] {

View File

@@ -0,0 +1,149 @@
import { BigNumber } from '@0x/utils';
/**
* This has been copied from https://github.com/balancer-labs/balancer-sor/blob/john/rc2/src/helpers.ts.
* Still awaiting V2 support for @balancer-labs/sor, once full V2 support is shipped we can upgrade sor and delete this file
*/
export const parsePoolData = (
directPools: SubGraphPoolDictionary,
tokenIn: string,
tokenOut: string,
mostLiquidPoolsFirstHop: SubGraphPool[] = [],
mostLiquidPoolsSecondHop: SubGraphPool[] = [],
hopTokens: string[] = [],
): [SubGraphPoolDictionary, Path[]] => {
const pathDataList: Path[] = [];
const pools: SubGraphPoolDictionary = {};
// First add direct pair paths
// tslint:disable-next-line:forin
for (const idKey in directPools) {
const p: SubGraphPool = directPools[idKey];
// Add pool to the set with all pools (only adds if it's still not present in dict)
pools[idKey] = p;
const swap: Swap = {
pool: p.id,
tokenIn,
tokenOut,
tokenInDecimals: 18, // Placeholder for actual decimals
tokenOutDecimals: 18,
};
const path: Path = {
id: p.id,
swaps: [swap],
};
pathDataList.push(path);
}
// Now add multi-hop paths.
// mostLiquidPoolsFirstHop and mostLiquidPoolsSecondHop always has the same
// lengh of hopTokens
for (let i = 0; i < hopTokens.length; i++) {
// Add pools to the set with all pools (only adds if it's still not present in dict)
pools[mostLiquidPoolsFirstHop[i].id] = mostLiquidPoolsFirstHop[i];
pools[mostLiquidPoolsSecondHop[i].id] = mostLiquidPoolsSecondHop[i];
const swap1: Swap = {
pool: mostLiquidPoolsFirstHop[i].id,
tokenIn,
tokenOut: hopTokens[i],
tokenInDecimals: 18, // Placeholder for actual decimals
tokenOutDecimals: 18,
};
const swap2: Swap = {
pool: mostLiquidPoolsSecondHop[i].id,
tokenIn: hopTokens[i],
tokenOut,
tokenInDecimals: 18, // Placeholder for actual decimals
tokenOutDecimals: 18,
};
const path: Path = {
id: mostLiquidPoolsFirstHop[i].id + mostLiquidPoolsSecondHop[i].id, // Path id is the concatenation of the ids of poolFirstHop and poolSecondHop
swaps: [swap1, swap2],
};
pathDataList.push(path);
}
return [pools, pathDataList];
};
interface SubGraphPool {
id: string;
swapFee: string;
totalWeight: string;
totalShares: string;
tokens: SubGraphToken[];
tokensList: string[];
poolType?: string;
// Only for stable pools
amp: string;
// Only for element pools
lpShares?: BigNumber;
time?: BigNumber;
principalToken?: string;
baseToken?: string;
}
interface SubGraphPoolDictionary {
[poolId: string]: SubGraphPool;
}
interface SubGraphToken {
address: string;
balance: string;
decimals: string | number;
// Stable & Element field
weight?: string;
}
interface Path {
id: string; // pool address if direct path, contactenation of pool addresses if multihop
swaps: Swap[];
poolPairData?: PoolPairData[];
limitAmount?: BigNumber;
filterEffectivePrice?: BigNumber; // TODO: This is just used for filtering, maybe there is a better way to filter?
}
interface Swap {
pool: string;
tokenIn: string;
tokenOut: string;
swapAmount?: string;
limitReturnAmount?: string;
maxPrice?: string;
tokenInDecimals: number;
tokenOutDecimals: number;
}
export interface PoolPairData {
id: string;
poolType?: string; // Todo: make this a mandatory field?
pairType?: string; // Todo: make this a mandatory field?
tokenIn: string;
tokenOut: string;
balanceIn?: BigNumber;
balanceOut?: BigNumber;
decimalsIn: number;
decimalsOut: number;
swapFee: BigNumber;
// For weighted & element pools
weightIn?: BigNumber;
weightOut?: BigNumber;
// Only for stable pools
allBalances: BigNumber[];
invariant?: BigNumber;
amp?: BigNumber;
tokenIndexIn?: number;
tokenIndexOut?: number;
// Only for element pools
lpShares?: BigNumber;
time?: BigNumber;
principalToken?: string;
baseToken?: string;
}

View File

@@ -1,5 +1,6 @@
import { getPoolsWithTokens, parsePoolData } from '@balancer-labs/sor';
import { Pool } from '@balancer-labs/sor/dist/types';
import { gql, request } from 'graphql-request';
import { BALANCER_MAX_POOLS_FETCHED, BALANCER_SUBGRAPH_URL, BALANCER_TOP_POOLS_FETCHED } from '../constants';
@@ -49,16 +50,13 @@ export class BalancerPoolsCache extends PoolsCache {
} = {};
const pools = await this._fetchTopPoolsAsync();
pools.forEach(pool => {
for (const pool of pools) {
const { tokensList } = pool;
for (const from of tokensList) {
for (const to of tokensList.filter(t => t.toLowerCase() !== from.toLowerCase())) {
if (!fromToPools[from]) {
fromToPools[from] = {};
}
if (!fromToPools[from][to]) {
fromToPools[from][to] = [];
}
fromToPools[from] = fromToPools[from] || {};
fromToPools[from][to] = fromToPools[from][to] || [];
try {
// The list of pools must be relevant to `from` and `to` for `parsePoolData`
const poolData = parsePoolData([pool], from, to);
@@ -71,45 +69,37 @@ export class BalancerPoolsCache extends PoolsCache {
}
}
}
});
}
}
protected async _fetchTopPoolsAsync(): Promise<BalancerPoolResponse[]> {
const query = `
query {
pools (first: ${
this._topPoolsFetched
}, where: {publicSwap: true, liquidity_gt: 0}, orderBy: swapsCount, orderDirection: desc) {
id
publicSwap
swapFee
totalWeight
tokensList
tokens {
id
address
balance
decimals
symbol
denormWeight
const query = gql`
query fetchTopPools($topPoolsFetched: Int!) {
pools(
first: $topPoolsFetched
where: { publicSwap: true, liquidity_gt: 0 }
orderBy: swapsCount
orderDirection: desc
) {
id
publicSwap
swapFee
totalWeight
tokensList
tokens {
id
address
balance
decimals
symbol
denormWeight
}
}
}
}
}
`;
`;
try {
const response = await fetch(this._subgraphUrl, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
}),
});
const { data } = await response.json();
return data.pools;
const { pools } = await request(this._subgraphUrl, query, { topPoolsFetched: this._topPoolsFetched });
return pools;
} catch (err) {
return [];
}

View File

@@ -1,19 +1,60 @@
// import { getPoolsWithTokens, parsePoolData } from '@balancer-labs/sor'; // TODO - upgrade to v2
import { BigNumber } from '@0x/utils';
// import { parsePoolData } from '@balancer-labs'; // TODO - upgrade to v2
import { Pool } from '@balancer-labs/sor/dist/types';
import { request } from 'graphql-request';
import { gql, request } from 'graphql-request';
import { BALANCER_MAX_POOLS_FETCHED, BALANCER_V2_SUBGRAPH_URL } from '../constants';
import { DEFAULT_WARNING_LOGGER } from '../../../constants';
import { LogFunction } from '../../../types';
import { BALANCER_MAX_POOLS_FETCHED, BALANCER_TOP_POOLS_FETCHED, BALANCER_V2_SUBGRAPH_URL } from '../constants';
import { parsePoolData } from './balancer_sor_v2';
import { CacheValue, PoolsCache } from './pools_cache';
// tslint:disable-next-line:custom-no-magic-numbers
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
interface BalancerPoolResponse {
id: string;
swapFee: string;
tokens: Array<{ address: string; decimals: number; balance: string; weight: string; symbol: string }>;
tokensList: string[];
totalWeight: string;
totalShares: string;
amp: string | null;
}
export class BalancerV2PoolsCache extends PoolsCache {
private static _parseSubgraphPoolData(pool: any, takerToken: string, makerToken: string): Pool {
const tToken = pool.tokens.find((t: any) => t.address === takerToken);
const mToken = pool.tokens.find((t: any) => t.address === makerToken);
const swap = pool.swaps && pool.swaps[0];
const tokenAmountOut = swap ? swap.tokenAmountOut : undefined;
const tokenAmountIn = swap ? swap.tokenAmountIn : undefined;
const spotPrice =
tokenAmountOut && tokenAmountIn ? new BigNumber(tokenAmountOut).div(tokenAmountIn) : undefined; // TODO: xianny check
return {
id: pool.id,
balanceIn: new BigNumber(tToken.balance),
balanceOut: new BigNumber(mToken.balance),
weightIn: new BigNumber(tToken.weight),
weightOut: new BigNumber(mToken.weight),
swapFee: new BigNumber(pool.swapFee),
spotPrice,
};
}
constructor(
private readonly subgraphUrl: string = BALANCER_V2_SUBGRAPH_URL,
private readonly maxPoolsFetched: number = BALANCER_MAX_POOLS_FETCHED,
private readonly _topPoolsFetched: number = BALANCER_TOP_POOLS_FETCHED,
private readonly _warningLogger: LogFunction = DEFAULT_WARNING_LOGGER,
cache: { [key: string]: CacheValue } = {},
) {
super(cache);
void this._loadTopPoolsAsync();
// Reload the top pools every 12 hours
setInterval(async () => void this._loadTopPoolsAsync(), ONE_DAY_MS / 2);
}
// protected async _fetchPoolsForPairAsync(takerToken: string, makerToken: string): Promise<Pool[]> {
@@ -29,8 +70,71 @@ export class BalancerV2PoolsCache extends PoolsCache {
// }
// }
protected async _fetchTopPoolsAsync(): Promise<BalancerPoolResponse[]> {
const query = gql`
query fetchTopPools($topPoolsFetched: Int!) {
pools(
first: $topPoolsFetched
where: { totalLiquidity_gt: 0 }
orderBy: swapsCount
orderDirection: desc
) {
id
swapFee
totalWeight
tokensList
amp
totalShares
tokens {
id
address
balance
decimals
symbol
weight
}
}
}
`;
const { pools } = await request<{ pools: BalancerPoolResponse[] }>(this.subgraphUrl, query, {
topPoolsFetched: this._topPoolsFetched,
});
return pools;
}
protected async _loadTopPoolsAsync(): Promise<void> {
const fromToPools: {
[from: string]: { [to: string]: Pool[] };
} = {};
const pools = await this._fetchTopPoolsAsync();
for (const pool of pools) {
const { tokensList } = pool;
for (const from of tokensList) {
for (const to of tokensList.filter(t => t.toLowerCase() !== from.toLowerCase())) {
fromToPools[from] = fromToPools[from] || {};
fromToPools[from][to] = fromToPools[from][to] || [];
try {
// The list of pools must be relevant to `from` and `to` for `parsePoolData`
const [poolData] = parsePoolData({ [pool.id]: pool as any }, from, to);
fromToPools[from][to].push(
BalancerV2PoolsCache._parseSubgraphPoolData(poolData[pool.id], from, to),
);
// Cache this as we progress through
const expiresAt = Date.now() + this._cacheTimeMs;
this._cachePoolsForPair(from, to, fromToPools[from][to], expiresAt);
} catch (err) {
this._warningLogger(err, `Failed to load Balancer V2 top pools`);
// soldier on
}
}
}
}
}
protected async _fetchPoolsForPairAsync(takerToken: string, makerToken: string): Promise<Pool[]> {
const query = `
const query = gql`
query getPools {
pools(
first: ${this.maxPoolsFetched},
@@ -60,25 +164,7 @@ export class BalancerV2PoolsCache extends PoolsCache {
`;
try {
const { pools } = await request(this.subgraphUrl, query);
return pools.map((pool: any) => {
const tToken = pool.tokens.find((t: any) => t.address === takerToken);
const mToken = pool.tokens.find((t: any) => t.address === makerToken);
const swap = pool.swaps[0];
const tokenAmountOut = swap ? swap.tokenAmountOut : undefined;
const tokenAmountIn = swap ? swap.tokenAmountIn : undefined;
const spotPrice =
tokenAmountOut && tokenAmountIn ? new BigNumber(tokenAmountOut).div(tokenAmountIn) : undefined; // TODO: xianny check
return {
id: pool.id,
balanceIn: new BigNumber(tToken.balance),
balanceOut: new BigNumber(mToken.balance),
weightIn: new BigNumber(tToken.weight),
weightOut: new BigNumber(mToken.weight),
swapFee: new BigNumber(pool.swapFee),
spotPrice,
};
});
return pools.map((pool: any) => BalancerV2PoolsCache._parseSubgraphPoolData(pool, takerToken, makerToken));
} catch (e) {
return [];
}

View File

@@ -1,6 +1,6 @@
import { ChainId } from '@0x/contract-addresses';
import { LimitOrderFields } from '@0x/protocol-utils';
import { BigNumber } from '@0x/utils';
import { BigNumber, logUtils } from '@0x/utils';
import * as _ from 'lodash';
import { SamplerCallResult, SignedNativeOrder } from '../../types';
@@ -23,13 +23,13 @@ import {
DODO_CONFIG_BY_CHAIN_ID,
DODOV2_FACTORIES_BY_CHAIN_ID,
KYBER_CONFIG_BY_CHAIN_ID,
KYBER_DMM_ROUTER_BY_CHAIN_ID,
LINKSWAP_ROUTER_BY_CHAIN_ID,
LIQUIDITY_PROVIDER_REGISTRY_BY_CHAIN_ID,
MAINNET_TOKENS,
MAKER_PSM_INFO_BY_CHAIN_ID,
MAX_UINT256,
MOONISWAP_REGISTRIES_BY_CHAIN_ID,
MSTABLE_ROUTER_BY_CHAIN_ID,
NATIVE_FEE_TOKEN_BY_CHAIN_ID,
NULL_ADDRESS,
NULL_BYTES,
@@ -57,6 +57,7 @@ import {
ERC20BridgeSource,
GenericRouterFillData,
HopInfo,
KyberDmmFillData,
KyberFillData,
KyberSamplerOpts,
LiquidityProviderFillData,
@@ -237,6 +238,52 @@ export class SamplerOperations {
});
}
public getKyberDmmSellQuotes(
router: string,
tokenAddressPath: string[],
takerFillAmounts: BigNumber[],
): SourceQuoteOperation<KyberDmmFillData> {
return new SamplerContractOperation({
source: ERC20BridgeSource.KyberDmm,
contract: this._samplerContract,
function: this._samplerContract.sampleSellsFromKyberDmm,
params: [router, tokenAddressPath, takerFillAmounts],
callback: (callResults: string, fillData: KyberDmmFillData): BigNumber[] => {
const [pools, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
'sampleSellsFromKyberDmm',
callResults,
);
fillData.poolsPath = pools;
fillData.router = router;
fillData.tokenAddressPath = tokenAddressPath;
return samples;
},
});
}
public getKyberDmmBuyQuotes(
router: string,
tokenAddressPath: string[],
makerFillAmounts: BigNumber[],
): SourceQuoteOperation<KyberDmmFillData> {
return new SamplerContractOperation({
source: ERC20BridgeSource.KyberDmm,
contract: this._samplerContract,
function: this._samplerContract.sampleBuysFromKyberDmm,
params: [router, tokenAddressPath, makerFillAmounts],
callback: (callResults: string, fillData: KyberDmmFillData): BigNumber[] => {
const [pools, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
'sampleBuysFromKyberDmm',
callResults,
);
fillData.poolsPath = pools;
fillData.router = router;
fillData.tokenAddressPath = tokenAddressPath;
return samples;
},
});
}
public getUniswapSellQuotes(
router: string,
makerToken: string,
@@ -692,7 +739,7 @@ export class SamplerOperations {
function: this._samplerContract.sampleSellsFromUniswapV3,
params: [quoter, tokenAddressPath, takerFillAmounts],
callback: (callResults: string, fillData: UniswapV3FillData): BigNumber[] => {
const [samples, paths] = this._samplerContract.getABIDecodedReturnData<[BigNumber[], string[]]>(
const [paths, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
'sampleSellsFromUniswapV3',
callResults,
);
@@ -720,7 +767,7 @@ export class SamplerOperations {
function: this._samplerContract.sampleBuysFromUniswapV3,
params: [quoter, tokenAddressPath, makerFillAmounts],
callback: (callResults: string, fillData: UniswapV3FillData): BigNumber[] => {
const [samples, paths] = this._samplerContract.getABIDecodedReturnData<[BigNumber[], string[]]>(
const [paths, samples] = this._samplerContract.getABIDecodedReturnData<[string[], BigNumber[]]>(
'sampleBuysFromUniswapV3',
callResults,
);
@@ -783,7 +830,10 @@ export class SamplerOperations {
};
});
},
() => [],
() => {
logUtils.warn('SamplerContractOperation: Two hop sampler reverted');
return [];
},
);
}
@@ -838,7 +888,10 @@ export class SamplerOperations {
};
});
},
() => [],
() => {
logUtils.warn('SamplerContractOperation: Two hop sampler reverted');
return [];
},
);
}
@@ -1129,7 +1182,6 @@ export class SamplerOperations {
case ERC20BridgeSource.PancakeSwap:
case ERC20BridgeSource.PancakeSwapV2:
case ERC20BridgeSource.BakerySwap:
case ERC20BridgeSource.KyberDmm:
case ERC20BridgeSource.ApeSwap:
case ERC20BridgeSource.CafeSwap:
case ERC20BridgeSource.CheeseSwap:
@@ -1142,6 +1194,16 @@ export class SamplerOperations {
[takerToken, makerToken],
...intermediateTokens.map(t => [takerToken, t, makerToken]),
].map(path => this.getUniswapV2SellQuotes(uniLikeRouter, path, takerFillAmounts, source));
case ERC20BridgeSource.KyberDmm:
const kyberDmmRouter = KYBER_DMM_ROUTER_BY_CHAIN_ID[this.chainId];
if (!isValidAddress(kyberDmmRouter)) {
return [];
}
return this.getKyberDmmSellQuotes(
kyberDmmRouter,
[takerToken, makerToken],
takerFillAmounts,
);
case ERC20BridgeSource.Kyber:
return getKyberOffsets().map(offset =>
this.getKyberSellQuotes(
@@ -1198,14 +1260,9 @@ export class SamplerOperations {
),
);
case ERC20BridgeSource.MStable:
return isValidAddress(MSTABLE_ROUTER_BY_CHAIN_ID[this.chainId])
? this.getMStableSellQuotes(
MSTABLE_ROUTER_BY_CHAIN_ID[this.chainId],
makerToken,
takerToken,
takerFillAmounts,
)
: [];
return getShellLikeInfosForPair(this.chainId, takerToken, makerToken, source).map(pool =>
this.getMStableSellQuotes(pool, makerToken, takerToken, takerFillAmounts),
);
case ERC20BridgeSource.Mooniswap:
return [
...MOONISWAP_REGISTRIES_BY_CHAIN_ID[this.chainId]
@@ -1381,7 +1438,6 @@ export class SamplerOperations {
case ERC20BridgeSource.PancakeSwap:
case ERC20BridgeSource.PancakeSwapV2:
case ERC20BridgeSource.BakerySwap:
case ERC20BridgeSource.KyberDmm:
case ERC20BridgeSource.ApeSwap:
case ERC20BridgeSource.CafeSwap:
case ERC20BridgeSource.CheeseSwap:
@@ -1394,6 +1450,16 @@ export class SamplerOperations {
[takerToken, makerToken],
...intermediateTokens.map(t => [takerToken, t, makerToken]),
].map(path => this.getUniswapV2BuyQuotes(uniLikeRouter, path, makerFillAmounts, source));
case ERC20BridgeSource.KyberDmm:
const kyberDmmRouter = KYBER_DMM_ROUTER_BY_CHAIN_ID[this.chainId];
if (!isValidAddress(kyberDmmRouter)) {
return [];
}
return this.getKyberDmmBuyQuotes(
kyberDmmRouter,
[takerToken, makerToken],
makerFillAmounts,
);
case ERC20BridgeSource.Kyber:
return getKyberOffsets().map(offset =>
this.getKyberBuyQuotes(
@@ -1450,14 +1516,9 @@ export class SamplerOperations {
),
);
case ERC20BridgeSource.MStable:
return isValidAddress(MSTABLE_ROUTER_BY_CHAIN_ID[this.chainId])
? this.getMStableBuyQuotes(
MSTABLE_ROUTER_BY_CHAIN_ID[this.chainId],
makerToken,
takerToken,
makerFillAmounts,
)
: [];
return getShellLikeInfosForPair(this.chainId, takerToken, makerToken, source).map(pool =>
this.getMStableBuyQuotes(pool, makerToken, takerToken, makerFillAmounts),
);
case ERC20BridgeSource.Mooniswap:
return [
...MOONISWAP_REGISTRIES_BY_CHAIN_ID[this.chainId]

View File

@@ -9,7 +9,7 @@ import { BigNumber } from '@0x/utils';
import { NativeOrderWithFillableAmounts, RfqFirmQuoteValidator, RfqRequestOpts } from '../../types';
import { QuoteRequestor } from '../../utils/quote_requestor';
import { QuoteReport } from '../quote_report_generator';
import { PriceComparisonsReport, QuoteReport } from '../quote_report_generator';
import { CollapsedPath } from './path';
import { SourceFilters } from './source_filters';
@@ -224,6 +224,10 @@ export interface UniswapV3FillData extends FillData {
pathAmounts: Array<{ uniswapPath: string; inputAmount: BigNumber }>;
}
export interface KyberDmmFillData extends UniswapV2FillData {
poolsPath: string[];
}
/**
* Represents a node on a fill path.
*/
@@ -401,6 +405,11 @@ export interface GetMarketOrdersOpts {
* Whether to generate a quote report
*/
shouldGenerateQuoteReport: boolean;
/**
* Whether to include price comparison data in the quote
*/
shouldIncludePriceComparisonsReport: boolean;
/**
* Token addresses with a list of adjacent intermediary tokens to consider
* hopping to. E.g DAI->USDC via an adjacent token WETH
@@ -435,6 +444,7 @@ export interface OptimizerResult {
export interface OptimizerResultWithReport extends OptimizerResult {
quoteReport?: QuoteReport;
priceComparisonsReport?: PriceComparisonsReport;
}
export type MarketDepthSide = Array<Array<DexSample<FillData>>>;

View File

@@ -60,6 +60,12 @@ export interface QuoteReport {
sourcesDelivered: QuoteReportEntry[];
}
export interface PriceComparisonsReport {
dexSources: BridgeQuoteReportEntry[];
multiHopSources: MultiHopQuoteReportEntry[];
nativeSources: Array<NativeLimitOrderQuoteReportEntry | NativeRfqOrderQuoteReportEntry>;
}
/**
* Generates a report of sources considered while computing the optimized
* swap quote, and the sources ultimately included in the computed quote.
@@ -72,7 +78,7 @@ export function generateQuoteReport(
quoteRequestor?: QuoteRequestor,
): QuoteReport {
const nativeOrderSourcesConsidered = nativeOrders.map(order =>
_nativeOrderToReportEntry(order.type, order as any, order.fillableTakerAmount, comparisonPrice, quoteRequestor),
nativeOrderToReportEntry(order.type, order as any, order.fillableTakerAmount, comparisonPrice, quoteRequestor),
);
const sourcesConsidered = [...nativeOrderSourcesConsidered.filter(order => order.isRfqt)];
@@ -87,7 +93,7 @@ export function generateQuoteReport(
// map sources delivered
sourcesDelivered = liquidityDelivered.map(collapsedFill => {
if (_isNativeOrderFromCollapsedFill(collapsedFill)) {
return _nativeOrderToReportEntry(
return nativeOrderToReportEntry(
collapsedFill.type,
collapsedFill.fillData,
nativeOrderSignaturesToFillableAmounts[_nativeDataToId(collapsedFill.fillData)],
@@ -95,13 +101,13 @@ export function generateQuoteReport(
quoteRequestor,
);
} else {
return _dexSampleToReportSource(collapsedFill, marketOperation);
return dexSampleToReportSource(collapsedFill, marketOperation);
}
});
} else {
sourcesDelivered = [
// tslint:disable-next-line: no-unnecessary-type-assertion
_multiHopSampleToReportSource(liquidityDelivered as DexSample<MultiHopFillData>, marketOperation),
multiHopSampleToReportSource(liquidityDelivered as DexSample<MultiHopFillData>, marketOperation),
];
}
return {
@@ -115,7 +121,11 @@ function _nativeDataToId(data: { signature: Signature }): string {
return `${v}${r}${s}`;
}
function _dexSampleToReportSource(ds: DexSample, marketOperation: MarketOperation): BridgeQuoteReportEntry {
/**
* Generates a report sample for a DEX source
* NOTE: this is used for the QuoteReport and quote price comparison data
*/
export function dexSampleToReportSource(ds: DexSample, marketOperation: MarketOperation): BridgeQuoteReportEntry {
const liquiditySource = ds.source;
if (liquiditySource === ERC20BridgeSource.Native) {
@@ -143,7 +153,11 @@ function _dexSampleToReportSource(ds: DexSample, marketOperation: MarketOperatio
}
}
function _multiHopSampleToReportSource(
/**
* Generates a report sample for a MultiHop source
* NOTE: this is used for the QuoteReport and quote price comparison data
*/
export function multiHopSampleToReportSource(
ds: DexSample<MultiHopFillData>,
marketOperation: MarketOperation,
): MultiHopQuoteReportEntry {
@@ -176,7 +190,11 @@ function _isNativeOrderFromCollapsedFill(cf: CollapsedFill): cf is NativeCollaps
return type === FillQuoteTransformerOrderType.Limit || type === FillQuoteTransformerOrderType.Rfq;
}
function _nativeOrderToReportEntry(
/**
* Generates a report entry for a native order
* NOTE: this is used for the QuoteReport and quote price comparison data
*/
export function nativeOrderToReportEntry(
type: FillQuoteTransformerOrderType,
fillData: NativeLimitOrderFillData | NativeRfqOrderFillData,
fillableAmount: BigNumber,

View File

@@ -1,6 +1,12 @@
import { schemas, SchemaValidator } from '@0x/json-schemas';
import { FillQuoteTransformerOrderType, Signature } from '@0x/protocol-utils';
import { TakerRequestQueryParams, V4RFQFirmQuote, V4RFQIndicativeQuote, V4SignedRfqOrder } from '@0x/quote-server';
import {
TakerRequestQueryParamsUnnested,
V4RFQFirmQuote,
V4RFQIndicativeQuote,
V4SignedRfqOrder,
} from '@0x/quote-server';
import { Fee } from '@0x/quote-server/lib/src/types';
import { BigNumber, NULL_ADDRESS } from '@0x/utils';
import axios, { AxiosInstance } from 'axios';
@@ -11,6 +17,7 @@ import {
LogFunction,
MarketOperation,
RfqMakerAssetOfferings,
RfqmRequestOptions,
RfqPairType,
RfqRequestOpts,
SignedNativeOrder,
@@ -84,7 +91,8 @@ export class QuoteRequestor {
assetFillAmount: BigNumber,
comparisonPrice?: BigNumber,
isLastLook?: boolean | undefined,
): TakerRequestQueryParams {
fee?: Fee | undefined,
): TakerRequestQueryParamsUnnested {
const { buyAmountBaseUnits, sellAmountBaseUnits } =
marketOperation === MarketOperation.Buy
? {
@@ -97,7 +105,7 @@ export class QuoteRequestor {
};
const requestParamsWithBigNumbers: Pick<
TakerRequestQueryParams,
TakerRequestQueryParamsUnnested,
| 'txOrigin'
| 'takerAddress'
| 'buyTokenAddress'
@@ -105,6 +113,9 @@ export class QuoteRequestor {
| 'comparisonPrice'
| 'isLastLook'
| 'protocolVersion'
| 'feeAmount'
| 'feeToken'
| 'feeType'
> = {
txOrigin,
takerAddress,
@@ -114,7 +125,13 @@ export class QuoteRequestor {
protocolVersion: '4',
};
if (isLastLook) {
if (fee === undefined) {
throw new Error(`isLastLook cannot be passed without a fee parameter`);
}
requestParamsWithBigNumbers.isLastLook = isLastLook.toString();
requestParamsWithBigNumbers.feeAmount = fee.amount.toString();
requestParamsWithBigNumbers.feeToken = fee.token;
requestParamsWithBigNumbers.feeType = fee.type;
}
// convert BigNumbers to strings
@@ -181,12 +198,11 @@ export class QuoteRequestor {
assetFillAmount: BigNumber,
marketOperation: MarketOperation,
comparisonPrice: BigNumber | undefined,
options: RfqRequestOpts,
options: RfqmRequestOptions,
): Promise<SignedNativeOrder[]> {
const _opts: RfqRequestOpts = {
...constants.DEFAULT_RFQT_REQUEST_OPTS,
...options,
isLastLook: true,
};
return this._fetchAndValidateFirmQuotesAsync(
@@ -230,12 +246,11 @@ export class QuoteRequestor {
assetFillAmount: BigNumber,
marketOperation: MarketOperation,
comparisonPrice: BigNumber | undefined,
options: RfqRequestOpts,
options: RfqmRequestOptions,
): Promise<V4RFQIndicativeQuote[]> {
const _opts: RfqRequestOpts = {
...constants.DEFAULT_RFQT_REQUEST_OPTS,
...options,
isLastLook: true,
};
return this._fetchAndValidateIndicativeQuotesAsync(
@@ -344,6 +359,7 @@ export class QuoteRequestor {
assetFillAmount,
comparisonPrice,
options.isLastLook,
options.fee,
);
const quotePath = (() => {

View File

@@ -29,6 +29,7 @@ import * as IShell from '../test/generated-artifacts/IShell.json';
import * as ISmoothy from '../test/generated-artifacts/ISmoothy.json';
import * as IUniswapExchangeQuotes from '../test/generated-artifacts/IUniswapExchangeQuotes.json';
import * as IUniswapV2Router01 from '../test/generated-artifacts/IUniswapV2Router01.json';
import * as KyberDmmSampler from '../test/generated-artifacts/KyberDmmSampler.json';
import * as KyberSampler from '../test/generated-artifacts/KyberSampler.json';
import * as LiquidityProviderSampler from '../test/generated-artifacts/LiquidityProviderSampler.json';
import * as MakerPSMSampler from '../test/generated-artifacts/MakerPSMSampler.json';
@@ -58,6 +59,7 @@ export const artifacts = {
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
Eth2DaiSampler: Eth2DaiSampler as ContractArtifact,
FakeTaker: FakeTaker as ContractArtifact,
KyberDmmSampler: KyberDmmSampler as ContractArtifact,
KyberSampler: KyberSampler as ContractArtifact,
LiquidityProviderSampler: LiquidityProviderSampler as ContractArtifact,
MStableSampler: MStableSampler as ContractArtifact,

View File

@@ -395,7 +395,7 @@ describe('MarketOperationUtils tests', () => {
[ERC20BridgeSource.Uniswap]: { router: randomAddress() },
[ERC20BridgeSource.Eth2Dai]: { router: randomAddress() },
[ERC20BridgeSource.MakerPsm]: {},
[ERC20BridgeSource.KyberDmm]: { tokenAddressPath: [] },
[ERC20BridgeSource.KyberDmm]: { tokenAddressPath: [], router: randomAddress(), poolsPath: [] },
};
const DEFAULT_OPS = {

View File

@@ -1,6 +1,6 @@
import { tokenUtils } from '@0x/dev-utils';
import { FillQuoteTransformerOrderType, SignatureType } from '@0x/protocol-utils';
import { TakerRequestQueryParams, V4RFQIndicativeQuote } from '@0x/quote-server';
import { ETH_TOKEN_ADDRESS, FillQuoteTransformerOrderType, SignatureType } from '@0x/protocol-utils';
import { TakerRequestQueryParamsUnnested, V4RFQIndicativeQuote } from '@0x/quote-server';
import { StatusCodes } from '@0x/types';
import { BigNumber, logUtils } from '@0x/utils';
import Axios from 'axios';
@@ -75,7 +75,7 @@ describe('QuoteRequestor', async () => {
const mockedRequests: MockedRfqQuoteResponse[] = [];
const altMockedRequests: AltMockedRfqQuoteResponse[] = [];
const expectedParams: TakerRequestQueryParams = {
const expectedParams: TakerRequestQueryParamsUnnested = {
sellTokenAddress: takerToken,
buyTokenAddress: makerToken,
sellAmountBaseUnits: '10000',
@@ -84,6 +84,9 @@ describe('QuoteRequestor', async () => {
txOrigin,
isLastLook: 'true', // the major difference between RFQ-T and RFQ-M
protocolVersion: '4',
feeAmount: '1000000000',
feeToken: ETH_TOKEN_ADDRESS,
feeType: 'fixed',
};
const mockedDefaults = {
requestApiKey: apiKey,
@@ -242,6 +245,12 @@ describe('QuoteRequestor', async () => {
txOrigin: takerAddress,
intentOnFilling: true,
altRfqAssetOfferings,
isLastLook: true,
fee: {
amount: new BigNumber('1000000000'),
token: ETH_TOKEN_ADDRESS,
type: 'fixed',
},
},
);
expect(resp).to.deep.eq([
@@ -265,7 +274,7 @@ describe('QuoteRequestor', async () => {
const mockedRequests: MockedRfqQuoteResponse[] = [];
const altMockedRequests: AltMockedRfqQuoteResponse[] = [];
const expectedParams: TakerRequestQueryParams = {
const expectedParams: TakerRequestQueryParamsUnnested = {
sellTokenAddress: takerToken,
buyTokenAddress: makerToken,
sellAmountBaseUnits: '10000',
@@ -451,7 +460,7 @@ describe('QuoteRequestor', async () => {
// Set up RFQ responses
// tslint:disable-next-line:array-type
const mockedRequests: MockedRfqQuoteResponse[] = [];
const expectedParams: TakerRequestQueryParams = {
const expectedParams: TakerRequestQueryParamsUnnested = {
sellTokenAddress: takerToken,
buyTokenAddress: makerToken,
sellAmountBaseUnits: '10000',
@@ -460,6 +469,9 @@ describe('QuoteRequestor', async () => {
txOrigin: takerAddress,
isLastLook: 'true', // the major difference between RFQ-T and RFQ-M
protocolVersion: '4',
feeAmount: '1000000000',
feeToken: ETH_TOKEN_ADDRESS,
feeType: 'fixed',
};
const mockedDefaults = {
requestApiKey: apiKey,
@@ -543,6 +555,12 @@ describe('QuoteRequestor', async () => {
takerAddress,
txOrigin: takerAddress,
intentOnFilling: true,
isLastLook: true,
fee: {
type: 'fixed',
token: ETH_TOKEN_ADDRESS,
amount: new BigNumber('1000000000'),
},
},
);
expect(resp.sort()).to.eql([successfulQuote1, successfulQuote1].sort());
@@ -571,7 +589,7 @@ describe('QuoteRequestor', async () => {
// Set up RFQT responses
// tslint:disable-next-line:array-type
const mockedRequests: MockedRfqQuoteResponse[] = [];
const expectedParams: TakerRequestQueryParams = {
const expectedParams: TakerRequestQueryParamsUnnested = {
sellTokenAddress: takerToken,
buyTokenAddress: makerToken,
sellAmountBaseUnits: '10000',
@@ -678,7 +696,7 @@ describe('QuoteRequestor', async () => {
// Set up RFQT responses
// tslint:disable-next-line:array-type
const mockedRequests: MockedRfqQuoteResponse[] = [];
const expectedParams: TakerRequestQueryParams = {
const expectedParams: TakerRequestQueryParamsUnnested = {
sellTokenAddress: takerToken,
buyTokenAddress: makerToken,
sellAmountBaseUnits: '10000',
@@ -763,7 +781,7 @@ describe('QuoteRequestor', async () => {
// Set up RFQT responses
// tslint:disable-next-line:array-type
const mockedRequests: MockedRfqQuoteResponse[] = [];
const expectedParams: TakerRequestQueryParams = {
const expectedParams: TakerRequestQueryParamsUnnested = {
sellTokenAddress: takerToken,
buyTokenAddress: makerToken,
buyAmountBaseUnits: '10000',

View File

@@ -27,6 +27,7 @@ export * from '../test/generated-wrappers/i_shell';
export * from '../test/generated-wrappers/i_smoothy';
export * from '../test/generated-wrappers/i_uniswap_exchange_quotes';
export * from '../test/generated-wrappers/i_uniswap_v2_router01';
export * from '../test/generated-wrappers/kyber_dmm_sampler';
export * from '../test/generated-wrappers/kyber_sampler';
export * from '../test/generated-wrappers/liquidity_provider_sampler';
export * from '../test/generated-wrappers/m_stable_sampler';

View File

@@ -30,6 +30,7 @@
"test/generated-artifacts/ISmoothy.json",
"test/generated-artifacts/IUniswapExchangeQuotes.json",
"test/generated-artifacts/IUniswapV2Router01.json",
"test/generated-artifacts/KyberDmmSampler.json",
"test/generated-artifacts/KyberSampler.json",
"test/generated-artifacts/LiquidityProviderSampler.json",
"test/generated-artifacts/MStableSampler.json",

View File

@@ -1,4 +1,14 @@
[
{
"version": "6.2.0",
"changes": [
{
"note": "Deployed FQT on mainnet and ropsten for `KyberDMM`",
"pr": 247
}
],
"timestamp": 1621600614
},
{
"version": "6.1.0",
"changes": [

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v6.2.0 - _May 21, 2021_
* Deployed FQT on mainnet and ropsten for `KyberDMM` (#247)
## v6.1.0 - _May 5, 2021_
* Deployed FQT on mainnet and ropsten for `Balancer_V2` (#225)

View File

@@ -36,7 +36,7 @@
"wethTransformer": "0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7",
"payTakerTransformer": "0x4638a7ebe75b911b995d0ec73a81e4f85f41f24e",
"affiliateFeeTransformer": "0xda6d9fc5998f550a094585cf9171f0e8ee3ac59f",
"fillQuoteTransformer": "0x2bbb4abc672bc92821c99c7204afe8f25bdbc9e1",
"fillQuoteTransformer": "0xd12a34076a4d9eac4cb82d87411d958641d0db9b",
"positiveSlippageFeeTransformer": "0xa9416ce1dbde8d331210c07b5c253d94ee4cc3fd"
}
},
@@ -77,7 +77,7 @@
"wethTransformer": "0x05ad19aa3826e0609a19568ffbd1dfe86c6c7184",
"payTakerTransformer": "0x6d0ebf2bcd9cc93ec553b60ad201943dcca4e291",
"affiliateFeeTransformer": "0x6588256778ca4432fa43983ac685c45efb2379e2",
"fillQuoteTransformer": "0xb5c0603014989c4dc4feda01b7bc763953aff02a",
"fillQuoteTransformer": "0xfdabf2a405034fd9034ddc51ba1189cbed6bd651",
"positiveSlippageFeeTransformer": "0x8b332f700fd37e71c5c5b26c4d78b5ca63dd33b2"
}
},

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contract-addresses",
"version": "6.1.0",
"version": "6.2.0",
"engines": {
"node": ">=6.12"
},

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contract-wrappers-test",
"version": "12.2.45",
"version": "12.2.46",
"engines": {
"node": ">=6.12"
},
@@ -31,11 +31,11 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/packages/contract-wrappers-test",
"devDependencies": {
"@0x/contract-wrappers": "^13.16.1",
"@0x/contracts-test-utils": "^5.4.0",
"@0x/contract-wrappers": "^13.16.2",
"@0x/contracts-test-utils": "^5.4.1",
"@0x/dev-utils": "^4.2.7",
"@0x/migrations": "^8.0.6",
"@0x/order-utils": "^10.4.21",
"@0x/migrations": "^8.0.7",
"@0x/order-utils": "^10.4.22",
"@0x/subproviders": "^6.5.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.4",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1621600614,
"version": "13.16.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1620214333,
"version": "13.16.1",

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