UniswapFeature (#2703)

* Minimal Uniswap accessor.

* Add comments

* Safe math

* mainnet gas benchmark

* Assembler Uniswap

* Selectors and addresses

* Fix bugs in ABI encoders

* Typo

* AsmUniswap test

* Fix wantAmount computation

* Golfing

* Bypass AllowanceTarget

* Generalized asm uniswapper

* Implement ordering

* Fix pair computation

* #6 Golfing Iron

* Remove 'to' argument (saves 377 gas)

* New contract api

* `@0x/contracts-zero-ex`: Add `UniswapFeature`

* `@0x/contract-artifacts`: Regenerate artifacts

* `@0x/contract-wrappers`: Regenerate wrappers

* `@0x/asset-swapper`: Add Uniswap VIP support.
`@0x/asset-swapper`: Add `includeSources` support.

* `@0x/contracts-zero-ex`: Fix misleading comments in `UniswapFeature`.
`@0x/asset-swapper`: Fix linter errors.

* `@0x/asset-swapper`: Fix source filter bugs.

* `@0x/contracts-zero-ex`: `UniswapFeature`: Reduce calldata size for AllowanceTarget call
`@0x/asset-swapper`: Fix failing test.

* `@0x/contracts-zero-ex`: Fix ETH buy tokens not being normalized to WETH.

* `@0x/asset-swapper`: Fix multi-hop weirdness with source filters.

* `@0x/asset-swapper`: Fix failing test.

* `@0x/asset-swapper`: Really fix that broken AS test.

* `@0x/asset-swapper`: use filter objects instead of source array for valid buy and sell sources/

* `@0x/asset-swapper`: Move some source filtering logic into the sampler operations.

* `@0x/contracts-zero-ex`: Address PR feedback

* `@0x/contracts-zero-ex`: Fix feature version bug.

* `@0x/asset-swapper`: Did I actually fix AS tests this time? Who knows.

Co-authored-by: Remco Bloemen <remco@0x.org>
Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com>
Co-authored-by: Lawrence Forman <me@merklejerk.com>
This commit is contained in:
Lawrence Forman
2020-09-23 02:27:48 -04:00
committed by GitHub
parent 32d11d1ba5
commit f84b375cde
27 changed files with 1044 additions and 179 deletions

View File

@@ -13,6 +13,10 @@
{
"note": "Remove `ERC20BridgeSampler` artifact",
"pr": 2647
},
{
"note": "Regenerate artifacts",
"pr": 2703
}
]
},

View File

@@ -85,7 +85,7 @@
{ "internalType": "contract IERC20TokenV06", "name": "feeToken", "type": "address" },
{ "internalType": "uint256", "name": "feeAmount", "type": "uint256" }
],
"internalType": "struct IMetaTransactions.MetaTransactionData",
"internalType": "struct IMetaTransactionsFeature.MetaTransactionData",
"name": "mtx",
"type": "tuple"
},
@@ -122,14 +122,14 @@
{ "internalType": "uint32", "name": "deploymentNonce", "type": "uint32" },
{ "internalType": "bytes", "name": "data", "type": "bytes" }
],
"internalType": "struct ITransformERC20.Transformation[]",
"internalType": "struct ITransformERC20Feature.Transformation[]",
"name": "transformations",
"type": "tuple[]"
},
{ "internalType": "bytes32", "name": "callDataHash", "type": "bytes32" },
{ "internalType": "bytes", "name": "callDataSignature", "type": "bytes" }
],
"internalType": "struct ITransformERC20.TransformERC20Args",
"internalType": "struct ITransformERC20Feature.TransformERC20Args",
"name": "args",
"type": "tuple"
}
@@ -154,7 +154,7 @@
{ "internalType": "contract IERC20TokenV06", "name": "feeToken", "type": "address" },
{ "internalType": "uint256", "name": "feeAmount", "type": "uint256" }
],
"internalType": "struct IMetaTransactions.MetaTransactionData[]",
"internalType": "struct IMetaTransactionsFeature.MetaTransactionData[]",
"name": "mtxs",
"type": "tuple[]"
},
@@ -187,7 +187,7 @@
{ "internalType": "contract IERC20TokenV06", "name": "feeToken", "type": "address" },
{ "internalType": "uint256", "name": "feeAmount", "type": "uint256" }
],
"internalType": "struct IMetaTransactions.MetaTransactionData",
"internalType": "struct IMetaTransactionsFeature.MetaTransactionData",
"name": "mtx",
"type": "tuple"
},
@@ -237,7 +237,7 @@
{ "internalType": "contract IERC20TokenV06", "name": "feeToken", "type": "address" },
{ "internalType": "uint256", "name": "feeAmount", "type": "uint256" }
],
"internalType": "struct IMetaTransactions.MetaTransactionData",
"internalType": "struct IMetaTransactionsFeature.MetaTransactionData",
"name": "mtx",
"type": "tuple"
}
@@ -262,7 +262,7 @@
{ "internalType": "contract IERC20TokenV06", "name": "feeToken", "type": "address" },
{ "internalType": "uint256", "name": "feeAmount", "type": "uint256" }
],
"internalType": "struct IMetaTransactions.MetaTransactionData",
"internalType": "struct IMetaTransactionsFeature.MetaTransactionData",
"name": "mtx",
"type": "tuple"
}
@@ -366,6 +366,18 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "contract IERC20TokenV06[]", "name": "tokens", "type": "address[]" },
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
{ "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" },
{ "internalType": "bool", "name": "isSushi", "type": "bool" }
],
"name": "sellToUniswap",
"outputs": [{ "internalType": "uint256", "name": "buyAmount", "type": "uint256" }],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [{ "internalType": "address", "name": "quoteSigner", "type": "address" }],
"name": "setQuoteSigner",
@@ -398,7 +410,7 @@
{ "internalType": "uint32", "name": "deploymentNonce", "type": "uint32" },
{ "internalType": "bytes", "name": "data", "type": "bytes" }
],
"internalType": "struct ITransformERC20.Transformation[]",
"internalType": "struct ITransformERC20Feature.Transformation[]",
"name": "transformations",
"type": "tuple[]"
}
@@ -552,6 +564,16 @@
"targetImpl": "The address of an older implementation of the function."
}
},
"sellToUniswap(address[],uint256,uint256,bool)": {
"details": "Efficiently sell directly to uniswap/sushiswap.",
"params": {
"isSushi": "Use sushiswap if true.",
"minBuyAmount": "Minimum amount of `tokens[-1]` to buy.",
"sellAmount": "of `tokens[0]` Amount to sell.",
"tokens": "Sell path."
},
"returns": { "buyAmount": "Amount of `tokens[-1]` bought." }
},
"setQuoteSigner(address)": {
"details": "Replace the optional signer for `transformERC20()` calldata. Only callable by the owner.",
"params": { "quoteSigner": "The address of the new calldata signer." }