Compare commits

..

24 Commits

Author SHA1 Message Date
Github Actions
0eff2548d5 Publish
- @0x/contracts-asset-proxy@3.7.0
 - @0x/contracts-broker@1.1.18
 - @0x/contracts-coordinator@3.1.19
 - @0x/contracts-dev-utils@1.3.17
 - @0x/contracts-exchange-forwarder@4.2.19
 - @0x/contracts-exchange@3.2.19
 - @0x/contracts-extensions@6.2.13
 - @0x/contracts-integrations@2.7.16
 - @0x/contracts-multisig@4.1.19
 - @0x/contracts-staking@2.0.26
 - @0x/contracts-zero-ex@0.13.0
 - @0x/asset-swapper@5.5.0
 - @0x/contract-wrappers-test@12.2.29
 - @0x/migrations@6.5.5
2020-12-16 08:03:31 +00:00
Github Actions
93ee681204 Updated CHANGELOGS & MD docs 2020-12-16 08:03:25 +00:00
Jacob Evans
d7bea98075 fix: [asset-swapper] Rework Bancor to only use paths and sample best path (#88)
* Rework Bancor to only use paths and sample best path

* Deployed address

* Clean up and pin bancor sdk

* CHANGELOGs
2020-12-16 17:34:47 +10:00
Lawrence Forman
437a3b048d EP: Address audit feedback (#82)
* `@0x/contracts-zero-ex`: Address audit feedback (1/2)

* `@0x/contracts-zero-ex`: Cap the ETH transfer amount to a liquidity provider to `msg.value`

* `@0x/contracts-zero-ex`: Bump feature contract versions

* `@0x/contracts-zero-ex`: Always transfer msg.value to the liqudity provider in LiquiidityProviderFeature

* Remove PLP backwards-compatibility (#85)

* Remove backwards-compatibility from MixinZeroExBridge and LiquidityProviderSandbox

* `@0x/contracts-zero-ex`: Update CHANGELOG

Co-authored-by: Lawrence Forman <me@merklejerk.com>

Co-authored-by: Lawrence Forman <me@merklejerk.com>
Co-authored-by: mzhu25 <mchl.zhu.96@gmail.com>
2020-12-16 01:37:39 -05:00
Daniel Pyrathon
f55a9454b5 fix: Fix quote report (#87)
* updates market side liquidity with the appropriate firm and indicative quotes for reporting

* linting and fixing

* linting and fixing
2020-12-15 16:57:54 -08:00
Daniel Pyrathon
3b03ad0db4 fix: added SRA schema for V4 orders (#86)
* added SRA schema for V4 orders

* address comments
2020-12-14 17:39:42 -08:00
mzhu25
27d679e1f1 Rollback CLI tools (#79)
* Rollback CLI tools

* Refactor

* Address PR feedback

* Sort deployment history

* Rollback specific deployment

* Split calldata
2020-12-10 19:42:00 -08:00
Github Actions
1e16d59c23 Publish
- @0x/contracts-asset-proxy@3.6.9
 - @0x/contracts-broker@1.1.17
 - @0x/contracts-coordinator@3.1.18
 - @0x/contracts-dev-utils@1.3.16
 - @0x/contracts-erc1155@2.1.18
 - @0x/contracts-erc20@3.2.12
 - @0x/contracts-erc721@3.1.18
 - @0x/contracts-exchange-forwarder@4.2.18
 - @0x/contracts-exchange-libs@4.3.18
 - @0x/contracts-exchange@3.2.18
 - @0x/contracts-extensions@6.2.12
 - @0x/contracts-integrations@2.7.15
 - @0x/contracts-multisig@4.1.18
 - @0x/contracts-staking@2.0.25
 - @0x/contracts-test-utils@5.3.15
 - @0x/contracts-utils@4.6.3
 - @0x/contracts-zero-ex@0.12.0
 - @0x/asset-swapper@5.4.2
 - @0x/contract-artifacts@3.10.0
 - @0x/contract-wrappers-test@12.2.28
 - @0x/contract-wrappers@13.11.0
 - @0x/migrations@6.5.4
 - @0x/order-utils@10.4.10
 - @0x/protocol-utils@1.0.1
2020-12-09 03:40:56 +00:00
Github Actions
1e7c9bbb1f Updated CHANGELOGS & MD docs 2020-12-09 03:40:51 +00:00
Lawrence Forman
edda1edc50 @0x/protocol-utils (#76)
* add new packages

* `@0x/protocol-utils`: Update with latest code from `@0x/contracs-zero-ex` + misc stuff

* @0x/contracts-zero-ex`: Switch to using `@0x/protocol-utils` in most places

* @0x/protocol-types`: Delete this package.

* regen yarn lock

* `@0x/contracts-zero-ex`: Unpin `@0x/protocol-utils` dep.

* `@0x/contracts-integrations`: Fix borken test

* update changelogs

* `@0x/protocol-utils`: Update deps

* `@0x/protocol-utils`: add tests

* `@0x/protocol-utils`: More tests

* `@0x/protocol-utils`: Update readme.

* update deps

* run prettier

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

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

* `@0x/protocol-utils`: Update changelog

* `@0x/contract-wrappers`: Export stuff for doc gen

* `@0x/protocol-utils`: Use `Web3Wrapper.signTypedDataV4Async()` for MM compatibility.

* upgrade org deps

Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-08 22:08:52 -05:00
Greg Hysz
d1eb6279b4 Updated addresses and transformer nonces after hot-pants (#78) 2020-12-08 11:33:36 -08:00
Greg Hysz
4ace79d947 Updated Releases + Fix Links (#77)
* Updated releases

* fixed some typos and links in docs
2020-12-08 10:44:59 -08:00
mzhu25
e5eee96487 Add naive selector collision test (#74) 2020-12-07 19:49:37 -08:00
Github Actions
907adf9145 Publish
- @0x/contracts-asset-proxy@3.6.8
 - @0x/contracts-broker@1.1.16
 - @0x/contracts-coordinator@3.1.17
 - @0x/contracts-dev-utils@1.3.15
 - @0x/contracts-erc1155@2.1.17
 - @0x/contracts-erc20@3.2.11
 - @0x/contracts-erc721@3.1.17
 - @0x/contracts-exchange-forwarder@4.2.17
 - @0x/contracts-exchange-libs@4.3.17
 - @0x/contracts-exchange@3.2.17
 - @0x/contracts-extensions@6.2.11
 - @0x/contracts-integrations@2.7.14
 - @0x/contracts-multisig@4.1.17
 - @0x/contracts-staking@2.0.24
 - @0x/contracts-test-utils@5.3.14
 - @0x/contracts-utils@4.6.2
 - @0x/contracts-zero-ex@0.11.1
 - @0x/asset-swapper@5.4.1
 - @0x/contract-addresses@5.6.0
 - @0x/contract-wrappers-test@12.2.27
 - @0x/contract-wrappers@13.10.3
 - @0x/migrations@6.5.3
 - @0x/order-utils@10.4.9
2020-12-07 22:56:33 +00:00
Github Actions
c046fe6220 Updated CHANGELOGS & MD docs 2020-12-07 22:56:27 +00:00
Lawrence Forman
84bf20de41 Update CHANGELOG.json (#75)
* Update CHANGELOG.json

* Update CHANGELOG.json
2020-12-07 17:17:43 -05:00
Lawrence Forman
f5a6f74d9a Update mainnet and ropsten transformer addresses for hot-pants release (#70)
Co-authored-by: Lawrence Forman <me@merklejerk.com>
2020-12-07 16:41:56 -05:00
Github Actions
7c7fc51ccf Publish
- @0x/contracts-integrations@2.7.13
 - @0x/asset-swapper@5.4.0
2020-12-07 20:42:41 +00:00
Github Actions
fa22f6de0d Updated CHANGELOGS & MD docs 2020-12-07 20:42:34 +00:00
Kim Persson
4f41214af2 feat: add takerAssetToEthRate and makerAssetToEthRate to quote response (#49)
* ADDS expose ethToTakerAssetRate and ethToTakerAssetRate

* REFACTORS rename to more correct takerAssetToEth/makerAssetToEth naming

* ADDS asset-swapper change log entry
2020-12-07 20:40:56 +01:00
Github Actions
607b7169bc Publish
- @0x/contracts-integrations@2.7.12
 - @0x/asset-swapper@5.3.1
2020-12-03 23:05:32 +00:00
Github Actions
1253490a38 Updated CHANGELOGS & MD docs 2020-12-03 23:05:26 +00:00
Alex Kroeger
0a37a588e8 Added BalanceChecker contract (#60)
* Added BalanceChecker contract

* Upgraded to solidity 0.6, simplified contract, added tests

* uint -> uint256

* export BalanceChecker contract wrapper

* prettier

* removed superfluous test code

* prettier
2020-12-03 14:31:45 -08:00
Greg Hysz
23ee108089 updated release names (#72) 2020-12-03 11:00:44 -08:00
176 changed files with 6971 additions and 1045 deletions

View File

@@ -1,4 +1,32 @@
[
{
"version": "3.7.0",
"changes": [
{
"note": "Fix Bancor support of ETH",
"pr": 88
}
],
"timestamp": 1608105788
},
{
"timestamp": 1607485227,
"version": "3.6.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "3.6.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "3.6.7",

View File

@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.7.0 - _December 16, 2020_
* Fix Bancor support of ETH (#88)
## v3.6.9 - _December 9, 2020_
* Dependencies updated
## v3.6.8 - _December 7, 2020_
* Dependencies updated
## v3.6.7 - _December 3, 2020_
* Dependencies updated

View File

@@ -21,6 +21,7 @@ pragma solidity ^0.5.9;
pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
import "@0x/contracts-erc20/contracts/src/interfaces/IEtherToken.sol";
import "@0x/contracts-erc20/contracts/src/LibERC20Token.sol";
import "@0x/contracts-exchange-libs/contracts/src/IWallet.sol";
import "@0x/contracts-utils/contracts/src/DeploymentConstants.sol";
@@ -36,6 +37,20 @@ contract BancorBridge is
struct TransferState {
address bancorNetworkAddress;
address[] path;
IEtherToken weth;
}
/// @dev Bancor ETH pseudo-address.
address constant public BANCOR_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// solhint-disable no-empty-blocks
/// @dev Payable fallback to receive ETH from Bancor/WETH.
function ()
external
payable
{
// Poor man's receive in 0.5.9
require(msg.data.length == 0);
}
/// @dev Callback for `IERC20Bridge`. Tries to buy `amount` of
@@ -60,7 +75,6 @@ contract BancorBridge is
{
// hold variables to get around stack depth limitations
TransferState memory state;
// Decode the bridge data.
(
state.path,
@@ -68,34 +82,42 @@ contract BancorBridge is
// solhint-disable indent
) = abi.decode(bridgeData, (address[], address));
// solhint-enable indent
state.weth = IEtherToken(_getWethAddress());
require(state.path.length > 0, "BancorBridge/PATH_MUST_EXIST");
// Just transfer the tokens if they're the same.
if (state.path[0] == toTokenAddress) {
LibERC20Token.transfer(state.path[0], to, amount);
return BRIDGE_SUCCESS;
require(state.path.length >= 2, "BancorBridge/PATH_LENGTH_MUST_BE_GREATER_THAN_TWO");
// Grant an allowance to the Bancor Network to spend `fromTokenAddress` token.
uint256 fromTokenBalance;
uint256 payableAmount = 0;
// If it's ETH in the path then withdraw from WETH
// The Bancor path will have ETH as the 0xeee address
// Bancor expects to be paid in ETH not WETH
if (state.path[0] == BANCOR_ETH_ADDRESS) {
fromTokenBalance = state.weth.balanceOf(address(this));
state.weth.withdraw(fromTokenBalance);
payableAmount = fromTokenBalance;
} else {
fromTokenBalance = IERC20Token(state.path[0]).balanceOf(address(this));
LibERC20Token.approveIfBelow(state.path[0], state.bancorNetworkAddress, fromTokenBalance);
}
// Otherwise use Bancor to convert
require(state.path.length > 2, "BancorBridge/PATH_LENGTH_MUST_BE_GREATER_THAN_TWO");
require(state.path[state.path.length - 1] == toTokenAddress, "BancorBridge/LAST_ELEMENT_OF_PATH_MUST_MATCH_OUTPUT_TOKEN");
// // Grant an allowance to the Bancor Network to spend `fromTokenAddress` token.
uint256 fromTokenBalance = IERC20Token(state.path[0]).balanceOf(address(this));
LibERC20Token.approveIfBelow(state.path[0], state.bancorNetworkAddress, fromTokenBalance);
// Convert the tokens
uint256 boughtAmount = IBancorNetwork(state.bancorNetworkAddress).convertByPath(
uint256 boughtAmount = IBancorNetwork(state.bancorNetworkAddress).convertByPath.value(payableAmount)(
state.path, // path originating with source token and terminating in destination token
fromTokenBalance, // amount of source token to trade
amount, // minimum amount of destination token expected to receive
to, // beneficiary
state.path[state.path.length-1] == BANCOR_ETH_ADDRESS ? address(this) : to, // beneficiary
address(0), // affiliateAccount; no fee paid
0 // affiliateFee; no fee paid
);
if (state.path[state.path.length-1] == BANCOR_ETH_ADDRESS) {
state.weth.deposit.value(boughtAmount)();
state.weth.transfer(to, boughtAmount);
}
emit ERC20BridgeTransfer(
state.path[0], // fromTokenAddress
state.path[0] == BANCOR_ETH_ADDRESS ? address(state.weth) : state.path[0],
toTokenAddress,
fromTokenBalance,
boughtAmount,
@@ -118,5 +140,5 @@ contract BancorBridge is
{
return LEGACY_WALLET_MAGIC_VALUE;
}
}

View File

@@ -56,11 +56,14 @@ contract KyberBridge is
uint256 constant private KYBER_RATE_BASE = 10 ** 18;
// solhint-disable no-empty-blocks
/// @dev Payable fallback to receive ETH from Kyber.
/// @dev Payable fallback to receive ETH from Kyber/WETH.
function ()
external
payable
{}
{
// Poor man's receive in 0.5.9
require(msg.data.length == 0);
}
/// @dev Callback for `IKyberBridge`. Tries to buy `amount` of
/// `toTokenAddress` tokens by selling the entirety of the opposing asset

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-asset-proxy",
"version": "3.6.7",
"version": "3.7.0",
"engines": {
"node": ">=6.12"
},
@@ -51,13 +51,13 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/protocol",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contract-wrappers": "^13.10.2",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/dev-utils": "^4.1.2",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contract-wrappers": "^13.11.0",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/dev-utils": "^4.1.3",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@types/lodash": "4.14.104",
@@ -79,16 +79,16 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/contracts-erc1155": "^2.1.16",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-erc721": "^3.1.16",
"@0x/contracts-exchange-libs": "^4.3.16",
"@0x/order-utils": "^10.4.8",
"@0x/base-contract": "^6.2.14",
"@0x/contracts-erc1155": "^2.1.18",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-erc721": "^3.1.18",
"@0x/contracts-exchange-libs": "^4.3.18",
"@0x/order-utils": "^10.4.10",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"ethereum-types": "^3.4.0",
"lodash": "^4.17.11"
},

View File

@@ -12,13 +12,11 @@ import { DecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { artifacts } from './artifacts';
import { TestBancorBridgeContract } from './generated-wrappers/test_bancor_bridge';
import {
TestBancorBridgeConvertByPathInputEventArgs as ConvertByPathArgs,
TestBancorBridgeEvents as ContractEvents,
TestBancorBridgeTokenApproveEventArgs as TokenApproveArgs,
TestBancorBridgeTokenTransferEventArgs as TokenTransferArgs,
} from './wrappers';
blockchainTests.resets('Bancor unit tests', env => {
@@ -128,24 +126,6 @@ blockchainTests.resets('Bancor unit tests', env => {
expect(result).to.eq(AssetProxyId.ERC20Bridge);
});
it('performs transfer when both tokens are the same', async () => {
const createTokenFn = testContract.createToken(constants.NULL_ADDRESS);
const tokenAddress = await createTokenFn.callAsync();
await createTokenFn.awaitTransactionSuccessAsync();
const { opts, result, logs } = await transferFromAsync({
tokenAddressesPath: [tokenAddress, tokenAddress],
});
expect(result).to.eq(AssetProxyId.ERC20Bridge, 'asset proxy id');
const transfers = filterLogsToArguments<TokenTransferArgs>(logs, ContractEvents.TokenTransfer);
expect(transfers.length).to.eq(1);
expect(transfers[0].token).to.eq(tokenAddress, 'input token address');
expect(transfers[0].from).to.eq(testContract.address);
expect(transfers[0].to).to.eq(opts.toAddress, 'recipient address');
expect(transfers[0].amount).to.bignumber.eq(opts.amount, 'amount');
});
describe('token -> token', async () => {
it('calls BancorNetwork.convertByPath()', async () => {
const { opts, result, logs } = await transferFromAsync();

View File

@@ -1,4 +1,31 @@
[
{
"timestamp": 1608105788,
"version": "1.1.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "1.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "1.1.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "1.1.15",

View File

@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.1.18 - _December 16, 2020_
* Dependencies updated
## v1.1.17 - _December 9, 2020_
* Dependencies updated
## v1.1.16 - _December 7, 2020_
* Dependencies updated
## v1.1.15 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-broker",
"version": "1.1.15",
"version": "1.1.18",
"engines": {
"node": ">=6.12"
},
@@ -51,20 +51,20 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-erc721": "^3.1.16",
"@0x/contracts-exchange": "^3.2.16",
"@0x/contracts-exchange-libs": "^4.3.16",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-erc721": "^3.1.18",
"@0x/contracts-exchange": "^3.2.19",
"@0x/contracts-exchange-libs": "^4.3.18",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -84,8 +84,8 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/order-utils": "^10.4.8",
"@0x/base-contract": "^6.2.14",
"@0x/order-utils": "^10.4.10",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",
"ethereum-types": "^3.4.0"

View File

@@ -1,4 +1,31 @@
[
{
"timestamp": 1608105788,
"version": "3.1.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "3.1.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "3.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "3.1.16",

View File

@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.19 - _December 16, 2020_
* Dependencies updated
## v3.1.18 - _December 9, 2020_
* Dependencies updated
## v3.1.17 - _December 7, 2020_
* Dependencies updated
## v3.1.16 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-coordinator",
"version": "3.1.16",
"version": "3.1.19",
"engines": {
"node": ">=6.12"
},
@@ -52,17 +52,17 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-dev-utils": "^1.3.14",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-gen": "^2.0.23",
"@0x/dev-utils": "^4.1.2",
"@0x/order-utils": "^10.4.8",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-dev-utils": "^1.3.17",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-gen": "^2.0.24",
"@0x/dev-utils": "^4.1.3",
"@0x/order-utils": "^10.4.10",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -83,11 +83,11 @@
},
"dependencies": {
"@0x/assert": "^3.0.19",
"@0x/base-contract": "^6.2.13",
"@0x/contract-addresses": "^5.5.0",
"@0x/contracts-exchange": "^3.2.16",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/base-contract": "^6.2.14",
"@0x/contract-addresses": "^5.6.0",
"@0x/contracts-exchange": "^3.2.19",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/json-schemas": "^5.3.4",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",

View File

@@ -1,4 +1,31 @@
[
{
"timestamp": 1608105788,
"version": "1.3.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "1.3.16",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "1.3.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "1.3.14",

View File

@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.3.17 - _December 16, 2020_
* Dependencies updated
## v1.3.16 - _December 9, 2020_
* Dependencies updated
## v1.3.15 - _December 7, 2020_
* Dependencies updated
## v1.3.14 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-dev-utils",
"version": "1.3.14",
"version": "1.3.17",
"engines": {
"node": ">=6.12"
},
@@ -41,13 +41,13 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/dev-utils",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/abi-gen": "^5.4.13",
"@0x/assert": "^3.0.19",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/sol-compiler": "^4.4.0",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
@@ -63,7 +63,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/base-contract": "^6.2.14",
"@types/node": "12.12.54"
},
"publishConfig": {

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1607485227,
"version": "2.1.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "2.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "2.1.16",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.1.18 - _December 9, 2020_
* Dependencies updated
## v2.1.17 - _December 7, 2020_
* Dependencies updated
## v2.1.16 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc1155",
"version": "2.1.16",
"version": "2.1.18",
"engines": {
"node": ">=6.12"
},
@@ -52,11 +52,11 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-utils": "^4.6.1",
"@0x/dev-utils": "^4.1.2",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-utils": "^4.6.3",
"@0x/dev-utils": "^4.1.3",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
@@ -80,10 +80,10 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/base-contract": "^6.2.14",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"lodash": "^4.17.11"
},
"publishConfig": {

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1607485227,
"version": "3.2.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "3.2.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "3.2.10",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.2.12 - _December 9, 2020_
* Dependencies updated
## v3.2.11 - _December 7, 2020_
* Dependencies updated
## v3.2.10 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc20",
"version": "3.2.10",
"version": "3.2.12",
"engines": {
"node": ">=6.12"
},
@@ -51,18 +51,18 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/dev-utils": "^4.1.2",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/dev-utils": "^4.1.3",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -82,7 +82,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13"
"@0x/base-contract": "^6.2.14"
},
"publishConfig": {
"access": "public"

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1607485227,
"version": "3.1.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "3.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "3.1.16",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.18 - _December 9, 2020_
* Dependencies updated
## v3.1.17 - _December 7, 2020_
* Dependencies updated
## v3.1.16 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc721",
"version": "3.1.16",
"version": "3.1.18",
"engines": {
"node": ">=6.12"
},
@@ -52,18 +52,18 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/dev-utils": "^4.1.2",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/dev-utils": "^4.1.3",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -84,7 +84,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13"
"@0x/base-contract": "^6.2.14"
},
"publishConfig": {
"access": "public"

View File

@@ -1,4 +1,31 @@
[
{
"timestamp": 1608105788,
"version": "4.2.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "4.2.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "4.2.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "4.2.16",

View File

@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.2.19 - _December 16, 2020_
* Dependencies updated
## v4.2.18 - _December 9, 2020_
* Dependencies updated
## v4.2.17 - _December 7, 2020_
* Dependencies updated
## v4.2.16 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange-forwarder",
"version": "4.2.16",
"version": "4.2.19",
"engines": {
"node": ">=6.12"
},
@@ -52,25 +52,25 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-dev-utils": "^1.3.14",
"@0x/contracts-erc1155": "^2.1.16",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-erc721": "^3.1.16",
"@0x/contracts-exchange": "^3.2.16",
"@0x/contracts-exchange-libs": "^4.3.16",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/dev-utils": "^4.1.2",
"@0x/order-utils": "^10.4.8",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-dev-utils": "^1.3.17",
"@0x/contracts-erc1155": "^2.1.18",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-erc721": "^3.1.18",
"@0x/contracts-exchange": "^3.2.19",
"@0x/contracts-exchange-libs": "^4.3.18",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/dev-utils": "^4.1.3",
"@0x/order-utils": "^10.4.10",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -90,7 +90,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/base-contract": "^6.2.14",
"@0x/typescript-typings": "^5.1.6",
"ethereum-types": "^3.4.0"
},

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1607485227,
"version": "4.3.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "4.3.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "4.3.16",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.3.18 - _December 9, 2020_
* Dependencies updated
## v4.3.17 - _December 7, 2020_
* Dependencies updated
## v4.3.16 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange-libs",
"version": "4.3.16",
"version": "4.3.18",
"engines": {
"node": ">=6.12"
},
@@ -52,14 +52,14 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/libs",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-gen": "^2.0.23",
"@0x/dev-utils": "^4.1.2",
"@0x/sol-compiler": "^4.4.0",
"@0x/subproviders": "^6.2.2",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-gen": "^2.0.24",
"@0x/dev-utils": "^4.1.3",
"@0x/sol-compiler": "^4.4.1",
"@0x/subproviders": "^6.2.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -80,10 +80,10 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/order-utils": "^10.4.8",
"@0x/base-contract": "^6.2.14",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/order-utils": "^10.4.10",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",

View File

@@ -1,4 +1,31 @@
[
{
"timestamp": 1608105788,
"version": "3.2.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "3.2.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "3.2.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "3.2.16",

View File

@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.2.19 - _December 16, 2020_
* Dependencies updated
## v3.2.18 - _December 9, 2020_
* Dependencies updated
## v3.2.17 - _December 7, 2020_
* Dependencies updated
## v3.2.16 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange",
"version": "3.2.16",
"version": "3.2.19",
"engines": {
"node": ">=6.12"
},
@@ -52,21 +52,21 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/protocol",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-exchange-libs": "^4.3.16",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-multisig": "^4.1.16",
"@0x/contracts-staking": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/dev-utils": "^4.1.2",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-exchange-libs": "^4.3.18",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-multisig": "^4.1.19",
"@0x/contracts-staking": "^2.0.26",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/dev-utils": "^4.1.3",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -88,12 +88,12 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/contracts-dev-utils": "^1.3.14",
"@0x/contracts-erc1155": "^2.1.16",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-erc721": "^3.1.16",
"@0x/order-utils": "^10.4.8",
"@0x/base-contract": "^6.2.14",
"@0x/contracts-dev-utils": "^1.3.17",
"@0x/contracts-erc1155": "^2.1.18",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-erc721": "^3.1.18",
"@0x/order-utils": "^10.4.10",
"@0x/utils": "^6.1.1",
"lodash": "^4.17.11"
},

View File

@@ -1,4 +1,31 @@
[
{
"timestamp": 1608105788,
"version": "6.2.13",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "6.2.12",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "6.2.11",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "6.2.10",

View File

@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v6.2.13 - _December 16, 2020_
* Dependencies updated
## v6.2.12 - _December 9, 2020_
* Dependencies updated
## v6.2.11 - _December 7, 2020_
* Dependencies updated
## v6.2.10 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-extensions",
"version": "6.2.10",
"version": "6.2.13",
"engines": {
"node": ">=6.12"
},
@@ -52,23 +52,23 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-dev-utils": "^1.3.14",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-erc721": "^3.1.16",
"@0x/contracts-exchange": "^3.2.16",
"@0x/contracts-exchange-libs": "^4.3.16",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-utils": "^4.6.1",
"@0x/dev-utils": "^4.1.2",
"@0x/order-utils": "^10.4.8",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-dev-utils": "^1.3.17",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-erc721": "^3.1.18",
"@0x/contracts-exchange": "^3.2.19",
"@0x/contracts-exchange-libs": "^4.3.18",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-utils": "^4.6.3",
"@0x/dev-utils": "^4.1.3",
"@0x/order-utils": "^10.4.10",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -90,8 +90,8 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/base-contract": "^6.2.14",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/typescript-typings": "^5.1.6",
"ethereum-types": "^3.4.0"
},

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-integrations",
"version": "2.7.11",
"version": "2.7.16",
"private": true,
"engines": {
"node": ">=6.12"
@@ -52,24 +52,25 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/extensions",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contract-addresses": "^5.5.0",
"@0x/contract-wrappers": "^13.10.2",
"@0x/contracts-broker": "^1.1.15",
"@0x/contracts-coordinator": "^3.1.16",
"@0x/contracts-dev-utils": "^1.3.14",
"@0x/contracts-exchange-forwarder": "^4.2.16",
"@0x/contracts-exchange-libs": "^4.3.16",
"@0x/contracts-extensions": "^6.2.10",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-utils": "^4.6.1",
"@0x/abi-gen": "^5.4.13",
"@0x/contract-addresses": "^5.6.0",
"@0x/contract-wrappers": "^13.11.0",
"@0x/contracts-broker": "^1.1.18",
"@0x/contracts-coordinator": "^3.1.19",
"@0x/contracts-dev-utils": "^1.3.17",
"@0x/contracts-exchange-forwarder": "^4.2.19",
"@0x/contracts-exchange-libs": "^4.3.18",
"@0x/contracts-extensions": "^6.2.13",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-utils": "^4.6.3",
"@0x/coordinator-server": "^1.0.5",
"@0x/dev-utils": "^4.1.2",
"@0x/migrations": "^6.5.2",
"@0x/order-utils": "^10.4.8",
"@0x/sol-compiler": "^4.4.0",
"@0x/dev-utils": "^4.1.3",
"@0x/migrations": "^6.5.5",
"@0x/order-utils": "^10.4.10",
"@0x/protocol-utils": "^1.0.1",
"@0x/sol-compiler": "^4.4.1",
"@0x/tslint-config": "^4.1.3",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@azure/core-asynciterator-polyfill": "^1.0.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
@@ -92,18 +93,18 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/asset-swapper": "^5.3.0",
"@0x/base-contract": "^6.2.13",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-erc1155": "^2.1.16",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-erc721": "^3.1.16",
"@0x/contracts-exchange": "^3.2.16",
"@0x/contracts-multisig": "^4.1.16",
"@0x/contracts-staking": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-zero-ex": "^0.11.0",
"@0x/subproviders": "^6.2.2",
"@0x/asset-swapper": "^5.5.0",
"@0x/base-contract": "^6.2.14",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-erc1155": "^2.1.18",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-erc721": "^3.1.18",
"@0x/contracts-exchange": "^3.2.19",
"@0x/contracts-multisig": "^4.1.19",
"@0x/contracts-staking": "^2.0.26",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-zero-ex": "^0.13.0",
"@0x/subproviders": "^6.2.3",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",

View File

@@ -6,19 +6,17 @@ import {
artifacts as exchangeProxyArtifacts,
IZeroExContract,
LogMetadataTransformerContract,
Signature,
} from '@0x/contracts-zero-ex';
import { migrateOnceAsync } from '@0x/migrations';
import { assetDataUtils, signatureUtils, SignedExchangeProxyMetaTransaction } from '@0x/order-utils';
import {
assetDataUtils,
encodeFillQuoteTransformerData,
encodePayTakerTransformerData,
ETH_TOKEN_ADDRESS,
FillQuoteTransformerSide,
findTransformerNonce,
signatureUtils,
SignedExchangeProxyMetaTransaction,
} from '@0x/order-utils';
Signature,
} from '@0x/protocol-utils';
import { AssetProxyId, Order, SignedOrder } from '@0x/types';
import { BigNumber, hexUtils } from '@0x/utils';
import * as ethjs from 'ethereumjs-util';

View File

@@ -1,4 +1,31 @@
[
{
"timestamp": 1608105788,
"version": "4.1.19",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "4.1.18",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "4.1.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "4.1.16",

View File

@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.1.19 - _December 16, 2020_
* Dependencies updated
## v4.1.18 - _December 9, 2020_
* Dependencies updated
## v4.1.17 - _December 7, 2020_
* Dependencies updated
## v4.1.16 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-multisig",
"version": "4.1.16",
"version": "4.1.19",
"engines": {
"node": ">=6.12"
},
@@ -49,18 +49,18 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/multisig",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/dev-utils": "^4.1.2",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/dev-utils": "^4.1.3",
"@0x/sol-compiler": "^4.4.1",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/node": "12.12.54",
@@ -78,7 +78,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/base-contract": "^6.2.14",
"@0x/typescript-typings": "^5.1.6",
"ethereum-types": "^3.4.0"
},

View File

@@ -1,4 +1,31 @@
[
{
"timestamp": 1608105788,
"version": "2.0.26",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607485227,
"version": "2.0.25",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "2.0.24",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "2.0.23",

View File

@@ -5,6 +5,18 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.0.26 - _December 16, 2020_
* Dependencies updated
## v2.0.25 - _December 9, 2020_
* Dependencies updated
## v2.0.24 - _December 7, 2020_
* Dependencies updated
## v2.0.23 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-staking",
"version": "2.0.23",
"version": "2.0.26",
"engines": {
"node": ">=6.12"
},
@@ -53,20 +53,20 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/tokens",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-dev-utils": "^1.3.14",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-exchange-libs": "^4.3.16",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-utils": "^4.6.1",
"@0x/dev-utils": "^4.1.2",
"@0x/order-utils": "^10.4.8",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-dev-utils": "^1.3.17",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-exchange-libs": "^4.3.18",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-utils": "^4.6.3",
"@0x/dev-utils": "^4.1.3",
"@0x/order-utils": "^10.4.10",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/lodash": "4.14.104",
"@types/node": "12.12.54",
"chai": "^4.0.1",
@@ -87,8 +87,8 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/base-contract": "^6.2.14",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",
"ethereum-types": "^3.4.0",

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1607485227,
"version": "5.3.15",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "5.3.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "5.3.13",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v5.3.15 - _December 9, 2020_
* Dependencies updated
## v5.3.14 - _December 7, 2020_
* Dependencies updated
## v5.3.13 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-test-utils",
"version": "5.3.13",
"version": "5.3.15",
"engines": {
"node": ">=6.12"
},
@@ -34,7 +34,7 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/test-utils",
"devDependencies": {
"@0x/sol-compiler": "^4.4.0",
"@0x/sol-compiler": "^4.4.1",
"@0x/tslint-config": "^4.1.3",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
@@ -43,19 +43,19 @@
},
"dependencies": {
"@0x/assert": "^3.0.19",
"@0x/base-contract": "^6.2.13",
"@0x/contract-addresses": "^5.5.0",
"@0x/dev-utils": "^4.1.2",
"@0x/base-contract": "^6.2.14",
"@0x/contract-addresses": "^5.6.0",
"@0x/dev-utils": "^4.1.3",
"@0x/json-schemas": "^5.3.4",
"@0x/order-utils": "^10.4.8",
"@0x/sol-coverage": "^4.0.23",
"@0x/sol-profiler": "^4.1.13",
"@0x/sol-trace": "^3.0.23",
"@0x/subproviders": "^6.2.2",
"@0x/order-utils": "^10.4.10",
"@0x/sol-coverage": "^4.0.24",
"@0x/sol-profiler": "^4.1.14",
"@0x/sol-trace": "^3.0.24",
"@0x/subproviders": "^6.2.3",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/bn.js": "^4.11.0",
"@types/js-combinatorics": "^0.5.29",
"@types/lodash": "4.14.104",

View File

@@ -1,4 +1,22 @@
[
{
"timestamp": 1607485227,
"version": "4.6.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "4.6.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1606961263,
"version": "4.6.1",

View File

@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.6.3 - _December 9, 2020_
* Dependencies updated
## v4.6.2 - _December 7, 2020_
* Dependencies updated
## v4.6.1 - _December 3, 2020_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-utils",
"version": "4.6.1",
"version": "4.6.3",
"engines": {
"node": ">=6.12"
},
@@ -50,15 +50,15 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/utils",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/dev-utils": "^4.1.2",
"@0x/order-utils": "^10.4.8",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/dev-utils": "^4.1.3",
"@0x/order-utils": "^10.4.10",
"@0x/sol-compiler": "^4.4.1",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
@@ -79,7 +79,7 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/base-contract": "^6.2.14",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",
"bn.js": "^4.11.8",

View File

@@ -8,3 +8,4 @@
# Blacklist tests in lib
/lib/test/*
# Package specific ignore
/lib/scripts/*

View File

@@ -1,4 +1,45 @@
[
{
"version": "0.13.0",
"changes": [
{
"note": "Address audit feedback in UniswapFeature",
"pr": 82
},
{
"note": "Always transfer `msg.value` to the liquidity provider contract in LiquidityProviderFeature to",
"pr": 82
},
{
"note": "Remove backwards compatibility with old PLP/bridge interface in `LiquidityProviderFeature` and `MixinZeroExBridge`",
"pr": 85
}
],
"timestamp": 1608105788
},
{
"version": "0.12.0",
"changes": [
{
"note": "Add test for selector collisions on the proxy",
"pr": 74
},
{
"note": "Move tooling out into `@0x/protocol-utils`.",
"pr": 76
}
],
"timestamp": 1607485227
},
{
"timestamp": 1607381756,
"version": "0.11.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "0.11.0",
"changes": [

View File

@@ -5,6 +5,21 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.13.0 - _December 16, 2020_
* Address audit feedback in UniswapFeature (#82)
* Always transfer `msg.value` to the liquidity provider contract in LiquidityProviderFeature to (#82)
* Remove backwards compatibility with old PLP/bridge interface in `LiquidityProviderFeature` and `MixinZeroExBridge` (#85)
## v0.12.0 - _December 9, 2020_
* Add test for selector collisions on the proxy (#74)
* Move tooling out into `@0x/protocol-utils`. (#76)
## v0.11.1 - _December 7, 2020_
* Dependencies updated
## v0.11.0 - _December 3, 2020_
* Turn `LibTokenSpender` into `FixinTokenSpender` (#38)

View File

@@ -57,7 +57,6 @@ contract FeeCollector is AuthorizableV06 {
external
onlyAuthorized
{
// Leave 1 wei behind to avoid expensive zero-->non-zero state change.
if (address(this).balance > 0) {
weth.deposit{value: address(this).balance}();
}

View File

@@ -68,21 +68,13 @@ contract LiquidityProviderSandbox is
onlyOwner
override
{
try ILiquidityProvider(provider).sellTokenForToken(
ILiquidityProvider(provider).sellTokenForToken(
inputToken,
outputToken,
recipient,
minBuyAmount,
auxiliaryData
) {} catch {
IERC20Bridge(provider).bridgeTransferFrom(
outputToken,
provider,
recipient,
minBuyAmount,
auxiliaryData
);
}
);
}
/// @dev Calls `sellEthForToken` on the given `provider` contract to

View File

@@ -44,7 +44,7 @@ contract LiquidityProviderFeature is
/// @dev Name of this feature.
string public constant override FEATURE_NAME = "LiquidityProviderFeature";
/// @dev Version of this feature.
uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 0, 1);
uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 0, 2);
/// @dev ETH pseudo-token address.
address constant internal ETH_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
@@ -111,9 +111,13 @@ contract LiquidityProviderFeature is
recipient = msg.sender;
}
if (inputToken == ETH_TOKEN_ADDRESS) {
provider.transfer(sellAmount);
} else {
// Forward all attached ETH to the provider.
if (msg.value > 0) {
provider.transfer(msg.value);
}
if (inputToken != ETH_TOKEN_ADDRESS) {
// Transfer input ERC20 tokens to the provider.
_transferERC20Tokens(
IERC20TokenV06(inputToken),
msg.sender,

View File

@@ -37,7 +37,7 @@ contract UniswapFeature is
/// @dev Name of this feature.
string public constant override FEATURE_NAME = "UniswapFeature";
/// @dev Version of this feature.
uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 1, 0);
uint256 public immutable override FEATURE_VERSION = _encodeVersion(1, 1, 1);
/// @dev A bloom filter for tokens that consume all gas when `transferFrom()` fails.
bytes32 public immutable GREEDY_TOKENS_BLOOM_FILTER;
/// @dev WETH contract.
@@ -167,8 +167,13 @@ contract UniswapFeature is
}
if iszero(i) {
// This is the first token in the path.
switch eq(sellToken, ETH_TOKEN_ADDRESS_32)
case 0 { // Not selling ETH. Selling an ERC20 instead.
// Make sure ETH was not attached to the call.
if gt(callvalue(), 0) {
revert(0, 0)
}
// For the first pair we need to transfer sellTokens into the
// pair contract.
moveTakerTokensTo(sellToken, pair, sellAmount)
@@ -203,6 +208,10 @@ contract UniswapFeature is
if iszero(staticcall(gas(), pair, 0xB00, 0x4, 0xC00, 0x40)) {
bubbleRevert()
}
// Revert if the pair contract does not return two words.
if iszero(eq(returndatasize(), 0x40)) {
revert(0,0)
}
// Sell amount for this hop is the previous buy amount.
let pairSellAmount := buyAmount
@@ -374,11 +383,15 @@ contract UniswapFeature is
mstore(0xB00, ALLOWANCE_CALL_SELECTOR_32)
mstore(0xB04, caller())
mstore(0xB24, address())
let success := call(gas(), token, 0, 0xB00, 0x44, 0xC00, 0x20)
let success := staticcall(gas(), token, 0xB00, 0x44, 0xC00, 0x20)
if iszero(success) {
// Call to allowance() failed.
bubbleRevert()
}
// Make sure the allowance call returned a single word.
if iszero(eq(returndatasize(), 0x20)) {
revert(0, 0)
}
// Call succeeded.
// Result is stored in 0xC00-0xC20.
if lt(mload(0xC00), amount) {
@@ -397,8 +410,6 @@ contract UniswapFeature is
mstore(0xB44, amount)
let success := call(
// Cap the gas limit to prvent all gas being consumed
// if the token reverts.
gas(),
token,
0,

View File

@@ -22,7 +22,6 @@ import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
import "../../../vendor/ILiquidityProvider.sol";
import "../../../vendor/v3/IERC20Bridge.sol";
contract MixinZeroExBridge {
@@ -61,32 +60,20 @@ contract MixinZeroExBridge {
bridgeAddress,
sellAmount
);
try ILiquidityProvider(bridgeAddress).sellTokenForToken(
address(sellToken),
address(buyToken),
address(this), // recipient
1, // minBuyAmount
bridgeData
) returns (uint256 _boughtAmount) {
boughtAmount = _boughtAmount;
emit ERC20BridgeTransfer(
sellToken,
buyToken,
sellAmount,
boughtAmount,
bridgeAddress,
address(this)
);
} catch {
uint256 balanceBefore = buyToken.balanceOf(address(this));
IERC20Bridge(bridgeAddress).bridgeTransferFrom(
address(buyToken),
bridgeAddress,
address(this), // recipient
1, // minBuyAmount
bridgeData
);
boughtAmount = buyToken.balanceOf(address(this)).safeSub(balanceBefore);
}
boughtAmount = ILiquidityProvider(bridgeAddress).sellTokenForToken(
address(sellToken),
address(buyToken),
address(this), // recipient
1, // minBuyAmount
bridgeData
);
emit ERC20BridgeTransfer(
sellToken,
buyToken,
sellAmount,
boughtAmount,
bridgeAddress,
address(this)
);
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/contracts-zero-ex",
"version": "0.11.0",
"version": "0.13.0",
"engines": {
"node": ">=6.12"
},
@@ -37,7 +37,8 @@
"compile:truffle": "truffle compile",
"docs:md": "ts-doc-gen --sourceDir='$PROJECT_FILES' --output=$MD_FILE_DIR --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json",
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES",
"publish:private": "yarn build && gitpkg publish"
"publish:private": "yarn build && gitpkg publish",
"rollback": "node ./lib/scripts/rollback.js"
},
"config": {
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IAllowanceTarget,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITokenSpenderFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,TokenSpenderFeature,AffiliateFeeTransformer,SignatureValidatorFeature,MetaTransactionsFeature,LogMetadataTransformer,BridgeAdapter,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector",
@@ -54,19 +55,24 @@
},
"homepage": "https://github.com/0xProject/protocol/tree/main/contracts/zero-ex",
"devDependencies": {
"@0x/abi-gen": "^5.4.12",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/dev-utils": "^4.1.2",
"@0x/sol-compiler": "^4.4.0",
"@0x/abi-gen": "^5.4.13",
"@0x/contract-addresses": "^5.6.0",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/dev-utils": "^4.1.3",
"@0x/sol-compiler": "^4.4.1",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@types/isomorphic-fetch": "^0.0.35",
"@types/lodash": "4.14.104",
"@types/mocha": "^5.2.7",
"@types/prompts": "^2.0.9",
"isomorphic-fetch": "^3.0.0",
"lodash": "^4.17.11",
"mocha": "^6.2.0",
"npm-run-all": "^4.1.2",
"prompts": "^2.4.0",
"shx": "^0.2.2",
"solhint": "^1.4.1",
"truffle": "^5.0.32",
@@ -75,13 +81,14 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/order-utils": "^10.4.8",
"@0x/subproviders": "^6.2.2",
"@0x/base-contract": "^6.2.14",
"@0x/order-utils": "^10.4.10",
"@0x/protocol-utils": "^1.0.1",
"@0x/subproviders": "^6.2.3",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"ethereum-types": "^3.4.0",
"ethereumjs-util": "^5.1.1"
},

View File

@@ -0,0 +1,420 @@
import { getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
import { constants } from '@0x/contracts-test-utils';
import { RPCSubprovider, SupportedProvider, Web3ProviderEngine } from '@0x/subproviders';
import { AbiEncoder, BigNumber, logUtils, providerUtils } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { MethodAbi } from 'ethereum-types';
import * as fetch from 'isomorphic-fetch';
import * as _ from 'lodash';
import * as prompts from 'prompts';
import * as wrappers from '../src/wrappers';
const SUBGRAPH_URL = 'https://api.thegraph.com/subgraphs/name/mzhu25/zeroex-migrations';
const ownableFeature = new wrappers.OwnableFeatureContract(constants.NULL_ADDRESS, new Web3ProviderEngine());
const simpleFunctionRegistryFeature = new wrappers.SimpleFunctionRegistryFeatureContract(
constants.NULL_ADDRESS,
new Web3ProviderEngine(),
);
const DO_NOT_ROLLBACK = [
ownableFeature.getSelector('migrate'),
ownableFeature.getSelector('transferOwnership'),
simpleFunctionRegistryFeature.getSelector('rollback'),
simpleFunctionRegistryFeature.getSelector('extend'),
];
const governorEncoder = AbiEncoder.create('(bytes[], address[], uint256[])');
const selectorToSignature: { [selector: string]: string } = {};
for (const wrapper of Object.values(wrappers)) {
if (typeof wrapper === 'function') {
const contract = new wrapper(constants.NULL_ADDRESS, new Web3ProviderEngine());
contract.abi
.filter(abiDef => abiDef.type === 'function')
.map(method => {
const methodName = (method as MethodAbi).name;
const selector = contract.getSelector(methodName);
const signature = contract.getFunctionSignature(methodName);
selectorToSignature[selector] = signature;
});
}
}
interface ProxyFunctionEntity {
id: string;
currentImpl: string;
fullHistory: Array<{ impl: string; timestamp: string }>;
}
interface Deployment {
time: string;
updates: Array<{ selector: string; signature?: string; previousImpl: string; newImpl: string }>;
}
async function querySubgraphAsync(): Promise<ProxyFunctionEntity[]> {
const query = `
{
proxyFunctions {
id
currentImpl
fullHistory {
impl
timestamp
}
}
}
`;
const response = await fetch(SUBGRAPH_URL, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
}),
});
const {
data: { proxyFunctions },
} = await response.json();
// Sort the history in chronological order
proxyFunctions.map((fn: ProxyFunctionEntity) =>
fn.fullHistory.sort((a, b) => Number.parseInt(a.timestamp, 10) - Number.parseInt(b.timestamp, 10)),
);
return proxyFunctions;
}
function reconstructDeployments(proxyFunctions: ProxyFunctionEntity[]): Deployment[] {
const deploymentsByTimestamp: { [timestamp: string]: Deployment } = {};
proxyFunctions.map(fn => {
fn.fullHistory.map((update, i) => {
const { updates } = (deploymentsByTimestamp[update.timestamp] = deploymentsByTimestamp[
update.timestamp
] || { time: timestampToUTC(update.timestamp), updates: [] });
updates.push({
selector: fn.id,
signature: selectorToSignature[fn.id],
previousImpl: i > 0 ? fn.fullHistory[i - 1].impl : constants.NULL_ADDRESS,
newImpl: update.impl,
});
});
});
return Object.keys(deploymentsByTimestamp)
.sort()
.map(timestamp => deploymentsByTimestamp[timestamp]);
}
function timestampToUTC(timestamp: string): string {
return new Date(Number.parseInt(timestamp, 10) * 1000).toUTCString();
}
enum CommandLineActions {
History = 'History',
Function = 'Function',
Current = 'Current',
Rollback = 'Rollback',
Emergency = 'Emergency',
Exit = 'Exit',
}
async function confirmRollbackAsync(
rollbackTargets: { [selector: string]: string },
proxyFunctions: ProxyFunctionEntity[],
): Promise<boolean> {
const { confirmed } = await prompts({
type: 'confirm',
name: 'confirmed',
message: `Are these the correct rollbacks?\n${Object.entries(rollbackTargets)
.map(
([selector, target]) =>
`[${selector}] ${selectorToSignature[selector] || '(function signature not found)'} \n ${
proxyFunctions.find(fn => fn.id === selector)!.currentImpl
} => ${target}`,
)
.join('\n')}`,
});
return confirmed;
}
async function printRollbackCalldataAsync(
rollbackTargets: { [selector: string]: string },
zeroEx: wrappers.IZeroExContract,
): Promise<void> {
const numRollbacks = Object.keys(rollbackTargets).length;
const { numTxns } = await prompts({
type: 'number',
name: 'numTxns',
message:
'To avoid limitations on calldata size, the full rollback can be split into multiple transactions. How many transactions would you like to split it into?',
initial: 1,
style: 'default',
min: 1,
max: numRollbacks,
});
for (let i = 0; i < numTxns; i++) {
const startIndex = i * Math.trunc(numRollbacks / numTxns);
const endIndex = startIndex + Math.trunc(numRollbacks / numTxns) + (i < numRollbacks % numTxns ? 1 : 0);
const rollbacks = Object.entries(rollbackTargets).slice(startIndex, endIndex);
const rollbackCallData = governorEncoder.encode([
rollbacks.map(([selector, target]) => zeroEx.rollback(selector, target).getABIEncodedTransactionData()),
new Array(rollbacks.length).fill(zeroEx.address),
new Array(rollbacks.length).fill(constants.ZERO_AMOUNT),
]);
if (numTxns > 1) {
logUtils.log(`======================== Governor Calldata #${i + 1} ========================`);
}
logUtils.log(rollbackCallData);
}
}
async function deploymentHistoryAsync(deployments: Deployment[], proxyFunctions: ProxyFunctionEntity[]): Promise<void> {
const { index } = await prompts({
type: 'select',
name: 'index',
message: 'Choose a deployment:',
choices: deployments.map((deployment, i) => ({
title: deployment.time,
value: i,
})),
});
const { action } = await prompts({
type: 'select',
name: 'action',
message: 'What would you like to do?',
choices: [
{ title: 'Deployment info', value: 'info' },
{ title: 'Rollback this deployment', value: 'rollback' },
],
});
if (action === 'info') {
logUtils.log(
deployments[index].updates.map(update => ({
selector: update.selector,
signature: update.signature || '(function signature not found)',
update: `${update.previousImpl} => ${update.newImpl}`,
})),
);
} else {
const zeroEx = await getMainnetContractAsync();
const rollbackTargets: { [selector: string]: string } = {};
for (const update of deployments[index].updates) {
rollbackTargets[update.selector] = update.previousImpl;
const rollbackLength = (await zeroEx.getRollbackLength(update.selector).callAsync()).toNumber();
for (let i = rollbackLength - 1; i >= 0; i--) {
const entry = await zeroEx.getRollbackEntryAtIndex(update.selector, new BigNumber(i)).callAsync();
if (entry === update.previousImpl) {
break;
} else if (i === 0) {
logUtils.log(
'Cannot rollback this deployment. The following update from this deployment cannot be rolled back:',
);
logUtils.log(`\t[${update.selector}] ${update.signature || '(function signature not found)'}`);
logUtils.log(`\t${update.previousImpl} => ${update.newImpl}`);
logUtils.log(
`Cannot find ${
update.previousImpl
} in the selector's rollback history. It itself may have been previously rolled back.`,
);
return;
}
}
}
const isConfirmed = await confirmRollbackAsync(rollbackTargets, proxyFunctions);
if (isConfirmed) {
await printRollbackCalldataAsync(rollbackTargets, zeroEx);
}
}
}
async function functionHistoryAsync(proxyFunctions: ProxyFunctionEntity[]): Promise<void> {
const { fnSelector } = await prompts({
type: 'autocomplete',
name: 'fnSelector',
message: 'Enter the selector or name of the function:',
choices: [
..._.flatMap(Object.entries(selectorToSignature), ([selector, signature]) => [
{ title: selector, value: selector, description: signature },
{ title: signature, value: selector, description: selector },
]),
...proxyFunctions
.filter(fn => !Object.keys(selectorToSignature).includes(fn.id))
.map(fn => ({ title: fn.id, value: fn.id, description: '(function signature not found)' })),
],
});
const functionEntity = proxyFunctions.find(fn => fn.id === fnSelector);
if (functionEntity === undefined) {
logUtils.log(`Couldn't find deployment history for selector ${fnSelector}`);
} else {
logUtils.log(
functionEntity.fullHistory.map(update => ({
date: timestampToUTC(update.timestamp),
impl: update.impl,
})),
);
}
}
async function currentFunctionsAsync(proxyFunctions: ProxyFunctionEntity[]): Promise<void> {
const currentFunctions: {
[selector: string]: { signature: string; impl: string; lastUpdated: string };
} = {};
proxyFunctions
.filter(fn => fn.currentImpl !== constants.NULL_ADDRESS)
.map(fn => {
currentFunctions[fn.id] = {
signature: selectorToSignature[fn.id] || '(function signature not found)',
impl: fn.currentImpl,
lastUpdated: timestampToUTC(fn.fullHistory.slice(-1)[0].timestamp),
};
});
logUtils.log(currentFunctions);
}
async function generateRollbackAsync(proxyFunctions: ProxyFunctionEntity[]): Promise<void> {
const zeroEx = await getMainnetContractAsync();
const { selected } = await prompts({
type: 'autocompleteMultiselect',
name: 'selected',
message: 'Select the functions to rollback:',
choices: _.flatMap(proxyFunctions.filter(fn => fn.currentImpl !== constants.NULL_ADDRESS), fn => [
{
title: [
`[${fn.id}]`,
`Implemented @ ${fn.currentImpl}`,
selectorToSignature[fn.id] || '(function signature not found)',
].join('\n\t\t\t\t'),
value: fn.id,
},
]),
});
const rollbackTargets: { [selector: string]: string } = {};
for (const selector of selected) {
const rollbackLength = (await zeroEx.getRollbackLength(selector).callAsync()).toNumber();
const rollbackHistory = await Promise.all(
_.range(rollbackLength).map(async i =>
zeroEx.getRollbackEntryAtIndex(selector, new BigNumber(i)).callAsync(),
),
);
const fullHistory = proxyFunctions.find(fn => fn.id === selector)!.fullHistory;
const previousImpl = rollbackHistory[rollbackLength - 1];
const { target } = await prompts({
type: 'select',
name: 'target',
message: 'Select the implementation to rollback to',
hint: `[${selector}] ${selectorToSignature[selector] || '(function signature not found)'}`,
choices: [
{
title: 'DISABLE',
value: constants.NULL_ADDRESS,
description: 'Rolls back to address(0)',
},
{
title: 'PREVIOUS',
value: previousImpl,
description: `${previousImpl} (${timestampToUTC(
_.findLast(fullHistory, update => update.impl === previousImpl)!.timestamp,
)})`,
},
...[...new Set(rollbackHistory)]
.filter(impl => impl !== constants.NULL_ADDRESS)
.map(impl => ({
title: impl,
value: impl,
description: timestampToUTC(_.findLast(fullHistory, update => update.impl === impl)!.timestamp),
})),
],
});
rollbackTargets[selector] = target;
}
const isConfirmed = await confirmRollbackAsync(rollbackTargets, proxyFunctions);
if (isConfirmed) {
await printRollbackCalldataAsync(rollbackTargets, zeroEx);
}
}
async function generateEmergencyRollbackAsync(proxyFunctions: ProxyFunctionEntity[]): Promise<void> {
const zeroEx = new wrappers.IZeroExContract(
getContractAddressesForChainOrThrow(1).exchangeProxy,
new Web3ProviderEngine(),
);
const allSelectors = proxyFunctions
.filter(fn => fn.currentImpl !== constants.NULL_ADDRESS && !DO_NOT_ROLLBACK.includes(fn.id))
.map(fn => fn.id);
await printRollbackCalldataAsync(
_.zipObject(allSelectors, new Array(allSelectors.length).fill(constants.NULL_ADDRESS)),
zeroEx,
);
}
let provider: SupportedProvider | undefined = process.env.RPC_URL ? createWeb3Provider(process.env.RPC_URL) : undefined;
function createWeb3Provider(rpcUrl: string): SupportedProvider {
const providerEngine = new Web3ProviderEngine();
providerEngine.addProvider(new RPCSubprovider(rpcUrl));
providerUtils.startProviderEngine(providerEngine);
return providerEngine;
}
async function getMainnetContractAsync(): Promise<wrappers.IZeroExContract> {
if (provider === undefined) {
const { rpcUrl } = await prompts({
type: 'text',
name: 'rpcUrl',
message: 'Enter an RPC endpoint:',
});
provider = createWeb3Provider(rpcUrl);
}
const chainId = await new Web3Wrapper(provider).getChainIdAsync();
const { exchangeProxy } = getContractAddressesForChainOrThrow(chainId);
return new wrappers.IZeroExContract(exchangeProxy, provider);
}
(async () => {
const proxyFunctions = await querySubgraphAsync();
const deployments = reconstructDeployments(proxyFunctions);
while (true) {
const { action } = await prompts({
type: 'select',
name: 'action',
message: 'What would you like to do?',
choices: [
{ title: '🚢 Deployment history', value: CommandLineActions.History },
{ title: '📜 Function history', value: CommandLineActions.Function },
{ title: '🗺️ Currently registered functions', value: CommandLineActions.Current },
{ title: '🔙 Generate rollback calldata', value: CommandLineActions.Rollback },
{ title: '🚨 Emergency shutdown calldata', value: CommandLineActions.Emergency },
{ title: '👋 Exit', value: CommandLineActions.Exit },
],
});
switch (action) {
case CommandLineActions.History:
await deploymentHistoryAsync(deployments, proxyFunctions);
break;
case CommandLineActions.Function:
await functionHistoryAsync(proxyFunctions);
break;
case CommandLineActions.Current:
await currentFunctionsAsync(proxyFunctions);
break;
case CommandLineActions.Rollback:
await generateRollbackAsync(proxyFunctions);
break;
case CommandLineActions.Emergency:
await generateEmergencyRollbackAsync(proxyFunctions);
break;
case CommandLineActions.Exit:
default:
process.exit(0);
}
}
})().catch(err => {
logUtils.log(err);
process.exit(1);
});

View File

@@ -31,10 +31,6 @@ export {
export { artifacts } from './artifacts';
export * from './migration';
export * from './nonce_utils';
export * from './signature_utils';
export * from './orders';
export * from './eip712_utils';
export * from './revert_errors';
export * from './bloom_filter_utils';
export { GREEDY_TOKENS } from './constants';
export {

View File

@@ -9,8 +9,6 @@ import { abis } from '../utils/abis';
import { fullMigrateAsync } from '../utils/migration';
import {
LiquidityProviderSandboxContract,
TestBridgeContract,
TestBridgeEvents,
TestLiquidityProviderContract,
TestLiquidityProviderEvents,
TestWethContract,
@@ -148,41 +146,6 @@ blockchainTests('LiquidityProvider feature', env => {
TestLiquidityProviderEvents.SellTokenForToken,
);
});
it('Successfully executes an ERC20-ERC20 swap (backwards-compatibility)', async () => {
const bridge = await TestBridgeContract.deployFrom0xArtifactAsync(
artifacts.TestBridge,
env.provider,
env.txDefaults,
artifacts,
weth.address,
token.address,
);
const tx = await feature
.sellToLiquidityProvider(
token.address,
weth.address,
bridge.address,
constants.NULL_ADDRESS,
constants.ONE_ETHER,
constants.ZERO_AMOUNT,
constants.NULL_BYTES,
)
.awaitTransactionSuccessAsync({ from: taker });
verifyEventsFromLogs(
tx.logs,
[
{
inputToken: token.address,
outputToken: weth.address,
inputTokenAmount: constants.ONE_ETHER,
outputTokenAmount: constants.ZERO_AMOUNT,
from: bridge.address,
to: taker,
},
],
TestBridgeEvents.ERC20BridgeTransfer,
);
});
it('Reverts if cannot fulfill the minimum buy amount', async () => {
const minBuyAmount = new BigNumber(1);
const tx = feature

View File

@@ -7,11 +7,11 @@ import {
verifyEventsFromLogs,
} from '@0x/contracts-test-utils';
import { getExchangeProxyMetaTransactionHash, signatureUtils } from '@0x/order-utils';
import { Signature } from '@0x/protocol-utils';
import { ExchangeProxyMetaTransaction } from '@0x/types';
import { BigNumber, hexUtils, StringRevertError, ZeroExRevertErrors } from '@0x/utils';
import * as _ from 'lodash';
import { Signature } from '../../src/signature_utils';
import { IZeroExContract, MetaTransactionsFeatureContract } from '../../src/wrappers';
import { artifacts } from '../artifacts';
import { abis } from '../utils/abis';

View File

@@ -1,9 +1,16 @@
import { blockchainTests, constants, describe, expect, verifyEventsFromLogs } from '@0x/contracts-test-utils';
import {
LimitOrder,
LimitOrderFields,
OrderInfo,
OrderStatus,
RevertErrors,
RfqOrder,
RfqOrderFields,
} from '@0x/protocol-utils';
import { AnyRevertError, BigNumber } from '@0x/utils';
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import { LimitOrder, LimitOrderFields, OrderInfo, OrderStatus, RfqOrder, RfqOrderFields } from '../../src/orders';
import * as RevertErrors from '../../src/revert_errors';
import { IZeroExContract, IZeroExEvents } from '../../src/wrappers';
import { artifacts } from '../artifacts';
import { fullMigrateAsync } from '../utils/migration';
@@ -446,7 +453,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestLimitOrder();
const tx = zeroEx.cancelLimitOrder(order).awaitTransactionSuccessAsync({ from: notMaker });
return expect(tx).to.revertWith(
new RevertErrors.OnlyOrderMakerAllowed(order.getHash(), notMaker, order.maker),
new RevertErrors.NativeOrders.OnlyOrderMakerAllowed(order.getHash(), notMaker, order.maker),
);
});
});
@@ -520,7 +527,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestRfqOrder();
const tx = zeroEx.cancelRfqOrder(order).awaitTransactionSuccessAsync({ from: notMaker });
return expect(tx).to.revertWith(
new RevertErrors.OnlyOrderMakerAllowed(order.getHash(), notMaker, order.maker),
new RevertErrors.NativeOrders.OnlyOrderMakerAllowed(order.getHash(), notMaker, order.maker),
);
});
});
@@ -542,7 +549,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const orders = [...new Array(3)].map(() => getTestLimitOrder());
const tx = zeroEx.batchCancelLimitOrders(orders).awaitTransactionSuccessAsync({ from: notMaker });
return expect(tx).to.revertWith(
new RevertErrors.OnlyOrderMakerAllowed(orders[0].getHash(), notMaker, orders[0].maker),
new RevertErrors.NativeOrders.OnlyOrderMakerAllowed(orders[0].getHash(), notMaker, orders[0].maker),
);
});
});
@@ -564,7 +571,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const orders = [...new Array(3)].map(() => getTestRfqOrder());
const tx = zeroEx.batchCancelRfqOrders(orders).awaitTransactionSuccessAsync({ from: notMaker });
return expect(tx).to.revertWith(
new RevertErrors.OnlyOrderMakerAllowed(orders[0].getHash(), notMaker, orders[0].maker),
new RevertErrors.NativeOrders.OnlyOrderMakerAllowed(orders[0].getHash(), notMaker, orders[0].maker),
);
});
});
@@ -925,7 +932,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestLimitOrder({ expiry: createExpiry(-60) });
const tx = fillLimitOrderAsync(order);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableError(order.getHash(), OrderStatus.Expired),
new RevertErrors.NativeOrders.OrderNotFillableError(order.getHash(), OrderStatus.Expired),
);
});
@@ -934,7 +941,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
await zeroEx.cancelLimitOrder(order).awaitTransactionSuccessAsync({ from: maker });
const tx = fillLimitOrderAsync(order);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableError(order.getHash(), OrderStatus.Cancelled),
new RevertErrors.NativeOrders.OrderNotFillableError(order.getHash(), OrderStatus.Cancelled),
);
});
@@ -945,7 +952,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
.awaitTransactionSuccessAsync({ from: maker });
const tx = fillLimitOrderAsync(order);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableError(order.getHash(), OrderStatus.Cancelled),
new RevertErrors.NativeOrders.OrderNotFillableError(order.getHash(), OrderStatus.Cancelled),
);
});
@@ -953,7 +960,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestLimitOrder({ taker });
const tx = fillLimitOrderAsync(order, { fillAmount: order.takerAmount, taker: notTaker });
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableByTakerError(order.getHash(), notTaker, order.taker),
new RevertErrors.NativeOrders.OrderNotFillableByTakerError(order.getHash(), notTaker, order.taker),
);
});
@@ -961,7 +968,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestLimitOrder({ sender: taker });
const tx = fillLimitOrderAsync(order, { fillAmount: order.takerAmount, taker: notTaker });
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableBySenderError(order.getHash(), notTaker, order.sender),
new RevertErrors.NativeOrders.OrderNotFillableBySenderError(order.getHash(), notTaker, order.sender),
);
});
@@ -971,7 +978,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
// signature.
const tx = fillLimitOrderAsync(order.clone({ chainId: 1234 }));
return expect(tx).to.revertWith(
new RevertErrors.OrderNotSignedByMakerError(order.getHash(), undefined, order.maker),
new RevertErrors.NativeOrders.OrderNotSignedByMakerError(order.getHash(), undefined, order.maker),
);
});
@@ -1173,7 +1180,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestRfqOrder();
const tx = fillRfqOrderAsync(order, order.takerAmount, notTaker);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableByOriginError(order.getHash(), notTaker, taker),
new RevertErrors.NativeOrders.OrderNotFillableByOriginError(order.getHash(), notTaker, taker),
);
});
@@ -1218,7 +1225,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const tx = fillRfqOrderAsync(order, order.takerAmount, notTaker);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableByOriginError(order.getHash(), notTaker, taker),
new RevertErrors.NativeOrders.OrderNotFillableByOriginError(order.getHash(), notTaker, taker),
);
});
@@ -1226,7 +1233,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestRfqOrder({ txOrigin: NULL_ADDRESS });
const tx = fillRfqOrderAsync(order, order.takerAmount, notTaker);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableError(order.getHash(), OrderStatus.Invalid),
new RevertErrors.NativeOrders.OrderNotFillableError(order.getHash(), OrderStatus.Invalid),
);
});
@@ -1234,7 +1241,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestRfqOrder({ taker, txOrigin: notTaker });
const tx = fillRfqOrderAsync(order, order.takerAmount, notTaker);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableByTakerError(order.getHash(), notTaker, order.taker),
new RevertErrors.NativeOrders.OrderNotFillableByTakerError(order.getHash(), notTaker, order.taker),
);
});
@@ -1242,7 +1249,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
const order = getTestRfqOrder({ expiry: createExpiry(-60) });
const tx = fillRfqOrderAsync(order);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableError(order.getHash(), OrderStatus.Expired),
new RevertErrors.NativeOrders.OrderNotFillableError(order.getHash(), OrderStatus.Expired),
);
});
@@ -1251,7 +1258,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
await zeroEx.cancelRfqOrder(order).awaitTransactionSuccessAsync({ from: maker });
const tx = fillRfqOrderAsync(order);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableError(order.getHash(), OrderStatus.Cancelled),
new RevertErrors.NativeOrders.OrderNotFillableError(order.getHash(), OrderStatus.Cancelled),
);
});
@@ -1262,7 +1269,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
.awaitTransactionSuccessAsync({ from: maker });
const tx = fillRfqOrderAsync(order);
return expect(tx).to.revertWith(
new RevertErrors.OrderNotFillableError(order.getHash(), OrderStatus.Cancelled),
new RevertErrors.NativeOrders.OrderNotFillableError(order.getHash(), OrderStatus.Cancelled),
);
});
@@ -1272,7 +1279,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
// signature.
const tx = fillRfqOrderAsync(order.clone({ chainId: 1234 }));
return expect(tx).to.revertWith(
new RevertErrors.OrderNotSignedByMakerError(order.getHash(), undefined, order.maker),
new RevertErrors.NativeOrders.OrderNotSignedByMakerError(order.getHash(), undefined, order.maker),
);
});
@@ -1309,7 +1316,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
.fillOrKillLimitOrder(order, await order.getSignatureWithProviderAsync(env.provider), fillAmount)
.awaitTransactionSuccessAsync({ from: taker, value: SINGLE_PROTOCOL_FEE });
return expect(tx).to.revertWith(
new RevertErrors.FillOrKillFailedError(order.getHash(), order.takerAmount, fillAmount),
new RevertErrors.NativeOrders.FillOrKillFailedError(order.getHash(), order.takerAmount, fillAmount),
);
});
@@ -1344,7 +1351,7 @@ blockchainTests.resets('NativeOrdersFeature', env => {
.fillOrKillRfqOrder(order, await order.getSignatureWithProviderAsync(env.provider), fillAmount)
.awaitTransactionSuccessAsync({ from: taker });
return expect(tx).to.revertWith(
new RevertErrors.FillOrKillFailedError(order.getHash(), order.takerAmount, fillAmount),
new RevertErrors.NativeOrders.FillOrKillFailedError(order.getHash(), order.takerAmount, fillAmount),
);
});

View File

@@ -0,0 +1,29 @@
import { blockchainTests, constants, expect } from '@0x/contracts-test-utils';
import { MethodAbi } from 'ethereum-types';
import * as wrappers from '../../src/wrappers';
blockchainTests('Selector collision test', env => {
it('Function selectors do not collide', () => {
const selectorToSignature: { [selector: string]: string } = {};
for (const wrapper of Object.values(wrappers)) {
if (typeof wrapper === 'function') {
const contract = new wrapper(constants.NULL_ADDRESS, env.provider, env.txDefaults);
contract.abi
.filter(abiDef => abiDef.type === 'function')
.map(method => {
const methodName = (method as MethodAbi).name;
const selector = contract.getSelector(methodName);
const signature = contract.getFunctionSignature(methodName);
if (selectorToSignature[selector]) {
expect(
signature,
`Selectors collide: ${signature}, ${selectorToSignature[selector]}`,
).to.equal(selectorToSignature[selector]);
}
selectorToSignature[selector] = signature;
});
}
}
});
});

View File

@@ -8,7 +8,7 @@ import {
randomAddress,
verifyEventsFromLogs,
} from '@0x/contracts-test-utils';
import { ETH_TOKEN_ADDRESS } from '@0x/order-utils';
import { ETH_TOKEN_ADDRESS } from '@0x/protocol-utils';
import { AbiEncoder, hexUtils, OwnableRevertErrors, ZeroExRevertErrors } from '@0x/utils';
import * as ethjs from 'ethereumjs-util';

View File

@@ -2,8 +2,7 @@ import { blockchainTests, expect } from '@0x/contracts-test-utils';
import { hexUtils } from '@0x/utils';
import * as ethjs from 'ethereumjs-util';
import { SignatureValidationError, SignatureValidationErrorCodes } from '../src/revert_errors';
import { eip712SignHashWithKey, ethSignHashWithKey, SignatureType } from '../src/signature_utils';
import { eip712SignHashWithKey, ethSignHashWithKey, RevertErrors, SignatureType } from '@0x/protocol-utils';
import { artifacts } from './artifacts';
import { TestLibSignatureContract } from './wrappers';
@@ -58,7 +57,10 @@ blockchainTests.resets('LibSignature library', env => {
v: 1,
};
return expect(testLib.getSignerOfHash(hash, sig).callAsync()).to.revertWith(
new SignatureValidationError(SignatureValidationErrorCodes.BadSignatureData, hash),
new RevertErrors.Signatures.SignatureValidationError(
RevertErrors.Signatures.SignatureValidationErrorCodes.BadSignatureData,
hash,
),
);
});
@@ -69,7 +71,10 @@ blockchainTests.resets('LibSignature library', env => {
r: '0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141',
};
return expect(testLib.getSignerOfHash(hash, sig).callAsync()).to.revertWith(
new SignatureValidationError(SignatureValidationErrorCodes.BadSignatureData, hash),
new RevertErrors.Signatures.SignatureValidationError(
RevertErrors.Signatures.SignatureValidationErrorCodes.BadSignatureData,
hash,
),
);
});
@@ -80,7 +85,10 @@ blockchainTests.resets('LibSignature library', env => {
signatureType: SignatureType.Illegal,
};
return expect(testLib.getSignerOfHash(hash, sig).callAsync()).to.revertWith(
new SignatureValidationError(SignatureValidationErrorCodes.Illegal, hash),
new RevertErrors.Signatures.SignatureValidationError(
RevertErrors.Signatures.SignatureValidationErrorCodes.Illegal,
hash,
),
);
});
@@ -91,7 +99,10 @@ blockchainTests.resets('LibSignature library', env => {
signatureType: SignatureType.Invalid,
};
return expect(testLib.getSignerOfHash(hash, sig).callAsync()).to.revertWith(
new SignatureValidationError(SignatureValidationErrorCodes.AlwaysInvalid, hash),
new RevertErrors.Signatures.SignatureValidationError(
RevertErrors.Signatures.SignatureValidationErrorCodes.AlwaysInvalid,
hash,
),
);
});
});

View File

@@ -1,5 +1,5 @@
import { blockchainTests, constants, expect, getRandomInteger, randomAddress } from '@0x/contracts-test-utils';
import { encodeAffiliateFeeTransformerData, ETH_TOKEN_ADDRESS } from '@0x/order-utils';
import { encodeAffiliateFeeTransformerData, ETH_TOKEN_ADDRESS } from '@0x/protocol-utils';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';

View File

@@ -7,12 +7,8 @@ import {
Numberish,
randomAddress,
} from '@0x/contracts-test-utils';
import {
assetDataUtils,
encodeFillQuoteTransformerData,
FillQuoteTransformerData,
FillQuoteTransformerSide,
} from '@0x/order-utils';
import { assetDataUtils } from '@0x/order-utils';
import { encodeFillQuoteTransformerData, FillQuoteTransformerData, FillQuoteTransformerSide } from '@0x/protocol-utils';
import { Order } from '@0x/types';
import { BigNumber, hexUtils, ZeroExRevertErrors } from '@0x/utils';
import * as _ from 'lodash';

View File

@@ -1,5 +1,5 @@
import { blockchainTests, constants, expect, getRandomInteger, randomAddress } from '@0x/contracts-test-utils';
import { encodePayTakerTransformerData, ETH_TOKEN_ADDRESS } from '@0x/order-utils';
import { encodePayTakerTransformerData, ETH_TOKEN_ADDRESS } from '@0x/protocol-utils';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';

View File

@@ -1,5 +1,5 @@
import { blockchainTests, constants, expect, getRandomInteger, randomAddress } from '@0x/contracts-test-utils';
import { encodeWethTransformerData, ETH_TOKEN_ADDRESS } from '@0x/order-utils';
import { encodeWethTransformerData, ETH_TOKEN_ADDRESS } from '@0x/protocol-utils';
import { BigNumber, ZeroExRevertErrors } from '@0x/utils';
import * as _ from 'lodash';

View File

@@ -1,8 +1,7 @@
import { getRandomInteger, randomAddress } from '@0x/contracts-test-utils';
import { LimitOrder, LimitOrderFields, RfqOrder, RfqOrderFields } from '@0x/protocol-utils';
import { BigNumber, hexUtils } from '@0x/utils';
import { LimitOrder, LimitOrderFields, RfqOrder, RfqOrderFields } from '../../src/orders';
/**
* Generate a random limit order.
*/

View File

@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig",
"compilerOptions": { "outDir": "lib", "rootDir": ".", "resolveJsonModule": true },
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*"],
"include": ["./src/**/*", "./test/**/*", "./generated-wrappers/**/*", "./scripts/**/*"],
"files": [
"generated-artifacts/AffiliateFeeTransformer.json",
"generated-artifacts/BridgeAdapter.json",

View File

@@ -7,29 +7,22 @@ Releases
This page outlines upcoming releases and expected changes.
+-------------+---------------------------------------------------------------+----------------------+------------+
| **Release** | **Overview** | **Est Release Date** | **Status** |
+-------------+---------------------------------------------------------------+----------------------+------------+
| `VIP`_ | PLP VIP | 12/01/20 | Timelocked |
+-------------+---------------------------------------------------------------+----------------------+------------+
| `Hancock`_ | Remove calldata signing / DeFi Saver Fix / Allowance on Proxy | 12/07/20 | Testing |
+-------------+---------------------------------------------------------------+----------------------+------------+
| `Tinker`_ | V4 Orders | Early January 2021 | In Audits |
+-------------+---------------------------------------------------------------+----------------------+------------+
.. table::
:widths: 20 50 10 10 10
VIP
----
- Deploy the `LiquidityProviderFeature <../architecture/features.html>`_, which enables optimized trades directly with `PLP <../advanced/plp.html>`_
+--------------+---------------------------------------------------------------+----------------------+------------+---------------------------------------------------------------------------------------------------------------+
| **Release** | **Overview** | **Est Release Date** | **Status** | **Additional** |
+--------------+---------------------------------------------------------------+----------------------+------------+---------------------------------------------------------------------------------------------------------------+
| `Tinker`_ | `V4 Orders <../basics/orders.html>`_ | 01/05/21 | In Audits | |
+--------------+---------------------------------------------------------------+----------------------+------------+---------------------------------------------------------------------------------------------------------------+
| `Hot-Pants`_ | Remove calldata signing / DeFi Saver Fix / Allowance on Proxy | 12/07/20 | Deployed | `Release Notes <https://github.com/0xProject/0x-migrations/blob/main/src/exchange-proxy/migrations/LOG.md>`__ |
+--------------+---------------------------------------------------------------+----------------------+------------+---------------------------------------------------------------------------------------------------------------+
| `Plop`_ | PLP VIP | 12/01/20 | Deployed | |
+--------------+---------------------------------------------------------------+----------------------+------------+---------------------------------------------------------------------------------------------------------------+
Hancock
-------
- Removes calldata signing from ``TransformERC20`` Feature.
- Redeploying all `Transformers <../architecture/transformers.html>`_ (new interface w/o ``calldataHash``)
- Allowances can now be set on the `Proxy <../architecture/features/proxy.html>`_. See more on the `Allowances Page <../basics/allowances.html>`_. This involves redeploying the following `Features <../architecture/features.html>`_: ``MetaTransactionsFeature``, ``TransformERC20Feature``, ``UniswapFeature``.
Upcoming
========
Tinker
------
@@ -38,4 +31,21 @@ Tinker
- Deploy updated `FillQuoteTransformer <../architecture/transformers.html>`_, which can fill `V4 Orders <../basics/orders.html>`_. This transformer will no longer call Exchange V3.
- Introduce `new events <../basics/events.html>`_.
- Decommission `SignatureValidationFeature <../architecture/features.html>`_.
- Decommission `TokenSpenderFeature <../architecture/features.html>`_.
- Decommission `TokenSpenderFeature <../architecture/features.html>`_.
Past
=====
Hot-Pants
----------
- Removes calldata signing from ``TransformERC20`` Feature.
- Redeploying all `Transformers <../architecture/transformers.html>`_ (new interface w/o ``calldataHash``)
- Allowances can now be set on the `Proxy <../architecture/features/proxy.html>`_. See more on the `Allowances Page <../basics/allowances.html>`_. This involves redeploying the following `Features <../architecture/features.html>`_: ``MetaTransactionsFeature``, ``TransformERC20Feature``, ``UniswapFeature``.
Plop
----
- Deploy the `LiquidityProviderFeature <../architecture/features.html>`_, which enables optimized trades directly with `PLP <../advanced/plp.html>`_

View File

@@ -70,7 +70,7 @@ Supported DEX's:
* Sushiswap
* Uniswap v1/v2
This transformation is implemented by the `FillQuoteTransformer <../architecture/transformers.html>`_ and has the ``deploymentNonce`` of ``5``. Abi-Encode the following struct to get the ``data``:
This transformation is implemented by the `FillQuoteTransformer <../architecture/transformers.html>`_. Abi-Encode the following struct to get the ``data``:
.. warning::
An upgrade is pending to this transformation. This currently uses Exchange V3 Orders, but will soon be updated to use `V4 Orders <../basics/orders.html>`_. - 11/26/2020
@@ -117,7 +117,7 @@ This transformation currently executes a Market Sell or Market Buy on a series o
WETH Wrapping
-------------
This transformation is implemented by the `WethTransformer <../architecture/transformers.html>`_ and has the ``deploymentNonce`` of ``1``. Abi-Encode the following struct to get the ``data``:
This transformation is implemented by the `WethTransformer <../architecture/transformers.html>`_. Abi-Encode the following struct to get the ``data``:
.. code-block:: solidity
@@ -135,7 +135,7 @@ If the supplied token address is `WETH (etherToken) <../basics/addresses.html>`_
Affiliate Fees
--------------
This transformation is implemented by the `AffiliateFeeTransformer <../architecture/transformers.html>`_ and has the ``deploymentNonce`` of ``3``. Abi-Encode the following struct to get the ``data``:
This transformation is implemented by the `AffiliateFeeTransformer <../architecture/transformers.html>`_. Abi-Encode the following struct to get the ``data``:
.. code-block:: solidity
@@ -156,7 +156,7 @@ This pays the ``recipient`` in the ``amount`` of ``token`` specified. This can b
Pay Taker
---------
This transformation is implemented by the `PayTakerTransformer <../architecture/transformers.html>`_ and has the ``deploymentNonce`` of ``2``. Abi-Encode the following struct to get the ``data``:
This transformation is implemented by the `PayTakerTransformer <../architecture/transformers.html>`_. Abi-Encode the following struct to get the ``data``:
.. code-block:: solidity

View File

@@ -7,19 +7,20 @@ Transformers extend the core protocol. They are trustless and permissioned by th
Below is a catalog of Transformers.
.. table::
:widths: 20 60 20
:widths: 20 60 10 10
+--------------------------+------------------------------------------------------------------------------------------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| **Transformer** | **Description** | **Nonce** | **Resources** |
+--------------------------+------------------------------------------------------------------------------------------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| FillQuoteTransformer | Aggregates Liquidity across DEXs and Native 0x Orders. | 9 | `Code <https://github.com/0xProject/protocol/blob/development/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol>`__; `Usage <../advanced/erc20_transformations.html#liquidity-aggregation>`__ |
+--------------------------+------------------------------------------------------------------------------------------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| AffiliateFeesTransformer | Allows integrators to charge an affiliate fee when an order is filled by their platform. | 8 | `Code <https://github.com/0xProject/protocol/blob/development/contracts/zero-ex/contracts/src/transformers/AffiliateFeeTransformer.sol>`__; `Usage <../advanced/erc20_transformations.html#affiliate-fees>`__ |
+--------------------------+------------------------------------------------------------------------------------------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| PayTakerTransformer | Forwards funds in the Flash Wallet to the Taker. | 7 | `Code <https://github.com/0xProject/protocol/blob/development/contracts/zero-ex/contracts/src/transformers/PayTakerTransformer.sol>`__; `Usage <../advanced/erc20_transformations.html#pay-taker>`__ |
+--------------------------+------------------------------------------------------------------------------------------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| WethTransformer | Wraps ETH into WETH (and unwraps) | 6 | `Code <https://github.com/0xProject/protocol/blob/development/contracts/zero-ex/contracts/src/transformers/WethTransformer.sol>`__; `Usage <../advanced/erc20_transformations.html#weth-wrapping>`__ |
+--------------------------+------------------------------------------------------------------------------------------+-----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+--------------------------+------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| **Transformer** | **Description** | **Resources** |
+--------------------------+------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| FillQuoteTransformer | Aggregates Liquidity across DEXs and Native 0x Orders. | `Code <https://github.com/0xProject/protocol/blob/development/contracts/zero-ex/contracts/src/transformers/FillQuoteTransformer.sol>`__; `Usage <../advanced/erc20_transformations.html#liquidity-aggregation>`__ |
+--------------------------+------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| WethTransformer | Wraps ETH into WETH (and unwraps) | `Code <https://github.com/0xProject/protocol/blob/development/contracts/zero-ex/contracts/src/transformers/WethTransformer.sol>`__; `Usage <../advanced/erc20_transformations.html#weth-wrapping>`__ |
+--------------------------+------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| AffiliateFeesTransformer | Allows integrators to charge an affiliate fee when an order is filled by their platform. | `Code <https://github.com/0xProject/protocol/blob/development/contracts/zero-ex/contracts/src/transformers/AffiliateFeeTransformer.sol>`__; `Usage <../advanced/erc20_transformations.html#affiliate-fees>`__ |
+--------------------------+------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| PayTakerTransformer | Forwards funds in the Flash Wallet to the Taker. | `Code <https://github.com/0xProject/protocol/blob/development/contracts/zero-ex/contracts/src/transformers/PayTakerTransformer.sol>`__; `Usage <../advanced/erc20_transformations.html#pay-taker>`__ |
+--------------------------+------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Implementing a Transformer

View File

@@ -23,10 +23,10 @@ Transformers
===================
.. csv-table::
wethTransformer, `0x68c0bb685099dc7cb5c5ce2b26185945b357383e <https://etherscan.io/address//0x68c0bb685099dc7cb5c5ce2b26185945b357383e>`_
payTakerTransformer, `0x49b9df2c58491764cf40cb052dd4243df63622c7 <https://etherscan.io/address//0x49b9df2c58491764cf40cb052dd4243df63622c7>`_
fillQuoteTransformer, `0xfbfb26935f15db6a319a43db5085245a6df1e408 <https://etherscan.io/address//0xfbfb26935f15db6a319a43db5085245a6df1e408>`_
affiliateFeeTransformer, `0x4581b59a05ba373b9f67676f66bdb5fcd67e7567 <https://etherscan.io/address//0x4581b59a05ba373b9f67676f66bdb5fcd67e7567>`_
wethTransformer, `0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7 <https://etherscan.io/address//0xb2bc06a4efb20fc6553a69dbfa49b7be938034a7>`_
payTakerTransformer, `0x4638a7ebe75b911b995d0ec73a81e4f85f41f24e <https://etherscan.io/address//0x4638a7ebe75b911b995d0ec73a81e4f85f41f24e>`_
fillQuoteTransformer, `0x74c35f17a19d4ee0ddd65cc21c671806913f9176 <https://etherscan.io/address//0x74c35f17a19d4ee0ddd65cc21c671806913f9176>`_
affiliateFeeTransformer, `0xda6d9fc5998f550a094585cf9171f0e8ee3ac59f <https://etherscan.io/address//0xda6d9fc5998f550a094585cf9171f0e8ee3ac59f>`_

View File

@@ -18,7 +18,7 @@ Below is a catalog of basic Exchange functionality. For more advanced usage, lik
| `cancelPairLimitOrders`_ | Cancels Limit orders in a specific market pair. |
| | Ex: Cancel all Limit Orders selling WETH for USDC. |
+---------------------------------+--------------------------------------------------------------------------+
| `batchCancelLimitPairOrders`_ | A batch call to `cancelLimitPairOrders`. |
| `batchCancelPairLimitOrders`_ | A batch call to `cancelPairLimitOrders`. |
+---------------------------------+--------------------------------------------------------------------------+
| `getLimitOrderInfo`_ | Returns the state of a given order. |
+---------------------------------+--------------------------------------------------------------------------+
@@ -155,7 +155,7 @@ This function cancels all limit orders created by the caller with with a maker a
.. code-block:: solidity
function cancelPairRfqOrders(
function cancelPairLimitOrders(
address makerToken,
address takerToken,
uint256 salt;
@@ -167,14 +167,14 @@ This function emits a `PairCancelledLimitOrders <../basics/events.html#paircance
- ``msg.sender != order.maker``
- The ``salt`` parameter is ≤ to a previous ``salt``.
batchCancelLimitPairOrders
batchCancelPairLimitOrders
--------------------------
This function performs multiple ``cancelLimitPairOrders()`` at once. Each respective index across arrays is equivalent to a single call.
This function performs multiple ``cancelPairLimitOrders()`` at once. Each respective index across arrays is equivalent to a single call.
.. code-block:: solidity
function batchCancelLimitPairOrders(
function batchCancelPairLimitOrders(
address[] makerTokens,
address[] takerTokens,
uint256[] salts;
@@ -329,7 +329,7 @@ If the trade is successful a `RfqOrderFilled <../basics/events.html#rfqorderfill
- The market pair (Ex, ``WETH/USDT``) was cancelled (``order.salt`` is less than the value passed to ``cancelPairLimitOrders``.
- Either the maker or taker has an insufficient allowance/balance.
- The order's ``taker`` field is non-zero and does not match the actual taker. This is ``msg.sender``, unless used with `meta-transactions <../advanced/mtx.rst>`_ in which case it is the signer.
- The order's ``origin`` field is non-zero and does not match ``tx.origin`` or a valid origin (see `registerAllowedRfqOrigins <../basics/functions.html#id11>`_).
- The order's ``origin`` field is non-zero and does not match ``tx.origin`` or a valid origin (see `registerAllowedRfqOrigins`_).
- The maker's signature is invalid.
fillOrKillRfqOrder
@@ -526,9 +526,10 @@ The hash can be manually generated using the following code:
order.salt
))
));
registerAllowedRfqOrigins
-------------------------
--------------------------
The RFQ order includes a ``txOrigin`` field, which a maker can use to restrict which EOA's can submit the Ethereum transaction that fills their order. There are two ways a maker can use this field.

View File

@@ -92,7 +92,7 @@ The ``RFQOrder`` struct has the following fields:
How To Sign
==============
Both Limit & RFQ orders must be signed by the `maker`. This signature is needed to fill an order, see `Basic Functionality <./functions.rst>`_.
Both Limit & RFQ orders must be signed by the `maker`. This signature is needed to fill an order, see `Basic Functionality <./functions.html>`_.
The protocol accepts signatures defined by the following struct:
@@ -137,4 +137,34 @@ In both cases, the ``@0x/protocol-utils`` package simplifies generating these si
The Orderbook
=======================
Orders are shared through a decentralized and permissionless network, called `0x Mesh <https://0x.org/mesh>`_. The simplest way to post and discover orders is through `0x API <https://0x.org/api>`_. See `this guide <https://0x.org/docs/guides/market-making-on-0x>`_ tailored for Market Makers.
Orders are shared through a decentralized and permissionless network, called `0x Mesh <https://0x.org/mesh>`_. The simplest way to post and discover orders is through `0x API <https://0x.org/api>`_. See `this guide <https://0x.org/docs/guides/market-making-on-0x>`_ tailored for Market Makers.
Orders are usually represented as a JSON object off-chain. Below is a table represention and example of how orders should be formatted off-chain.
JSON representation of RFQ Orders
*********************************
A ``RFQOrder`` should be serialized to JSON as following:
.. code-block:: typescript
interface RfqOrderJson {
"maker": string,
"taker": string,
"makerToken": string,
"takerToken": string,
"makerAmount": string,
"takerAmount": string,
"txOrigin": string,
"pool": string,
"expiry": number,
"salt": string,
"chainId": number, // Ethereum Chain Id where the transaction is submitted.
"verifyingContract": string, // Address of the contract where the transaction should be sent.
"signature": {
"signatureType": number,
"v": number,
"s": string,
"r": string,
}
}

View File

@@ -1,4 +1,51 @@
[
{
"version": "5.5.0",
"changes": [
{
"note": "Bancor now supported in all pairs",
"pr": 88
}
],
"timestamp": 1608105788
},
{
"timestamp": 1607485227,
"version": "5.4.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1607381756,
"version": "5.4.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "5.4.0",
"changes": [
{
"note": "Add `takerAssetToEthRate` and `makerAssetToEthRate` to swap quote response",
"pr": 49
}
],
"timestamp": 1607373752
},
{
"timestamp": 1607036724,
"version": "5.3.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "5.3.0",
"changes": [

View File

@@ -5,6 +5,26 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v5.5.0 - _December 16, 2020_
* Bancor now supported in all pairs (#88)
## v5.4.2 - _December 9, 2020_
* Dependencies updated
## v5.4.1 - _December 7, 2020_
* Dependencies updated
## v5.4.0 - _December 7, 2020_
* Add `takerAssetToEthRate` and `makerAssetToEthRate` to swap quote response (#49)
## v5.3.1 - _December 3, 2020_
* Dependencies updated
## v5.3.0 - _December 3, 2020_
* Added Crypto.com (#43)

View File

@@ -0,0 +1,89 @@
/*
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;
// ERC20 contract interface
abstract contract IToken {
/// @dev Query the balance of owner
/// @param _owner The address from which the balance will be retrieved
/// @return Balance of owner
function balanceOf(address _owner) public virtual view returns (uint256);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public virtual view returns (uint256);
}
contract BalanceChecker {
/*
Check the token balances of wallet-token pairs.
Pass 0xeee... as a "token" address to get ETH balance.
Possible error throws:
- extremely large arrays for user and or tokens (gas cost too high)
Returns a one-dimensional that's user.length long.
*/
function balances(address[] calldata users, address[] calldata tokens) external view returns (uint256[] memory) {
// make sure the users array and tokens array are of equal length
require(users.length == tokens.length, "users array is a different length than the tokens array");
uint256[] memory addrBalances = new uint256[](users.length);
for(uint i = 0; i < users.length; i++) {
if (tokens[i] != address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)) {
addrBalances[i] = IToken(tokens[i]).balanceOf(users[i]);
} else {
addrBalances[i] = users[i].balance; // ETH balance
}
}
return addrBalances;
}
/*
Check the allowances of an array of owner-spender-tokens
Returns 0 for 0xeee... (ETH)
Possible error throws:
- extremely large arrays for user and or tokens (gas cost too high)
Returns a one-dimensional array that's owners.length long.
*/
function allowances(address[] calldata owners, address[] calldata spenders, address[] calldata tokens) external view returns (uint256[] memory) {
// make sure the arrays are all of equal length
require(owners.length == spenders.length, "all arrays must be of equal length");
require(owners.length == tokens.length, "all arrays must be of equal length");
uint256[] memory addrAllowances = new uint256[](owners.length);
for(uint i = 0; i < owners.length; i++) {
if (tokens[i] != address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)) {
addrAllowances[i] = IToken(tokens[i]).allowance(owners[i], spenders[i]);
} else {
// ETH
addrAllowances[i] = 0;
}
}
return addrAllowances;
}
}

View File

@@ -0,0 +1,131 @@
/*
Copyright 2020 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./DeploymentConstants.sol";
import "./interfaces/IBancor.sol";
contract BancorSampler is
DeploymentConstants
{
/// @dev Base gas limit for Bancor calls.
uint256 constant private BANCOR_CALL_GAS = 300e3; // 300k
address constant private BANCOR_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @dev Sample sell quotes from Bancor.
/// @param paths The paths to check for Bancor. Only the best is used
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param takerTokenAmounts Taker token sell amount for each sample.
/// @return bancorNetwork the Bancor Network address
/// @return path the selected conversion path from bancor
/// @return makerTokenAmounts Maker amounts bought at each taker token
/// amount.
function sampleSellsFromBancor(
address[][] memory paths,
address takerToken,
address makerToken,
uint256[] memory takerTokenAmounts
)
public
view
returns (address bancorNetwork, address[] memory path, uint256[] memory makerTokenAmounts)
{
bancorNetwork = _getBancorNetwork();
if (paths.length == 0) {
return (bancorNetwork, path, makerTokenAmounts);
}
uint256 maxBoughtAmount = 0;
// Find the best path by selling the largest taker amount
for (uint256 i = 0; i < paths.length; i++) {
if (paths[i].length < 2) {
continue;
}
try
IBancorNetwork(bancorNetwork)
.rateByPath
{gas: BANCOR_CALL_GAS}
(paths[i], takerTokenAmounts[takerTokenAmounts.length-1])
returns (uint256 amount)
{
if (amount > maxBoughtAmount) {
maxBoughtAmount = amount;
path = paths[i];
}
} catch {
// Swallow failures, leaving all results as zero.
continue;
}
}
uint256 numSamples = takerTokenAmounts.length;
makerTokenAmounts = new uint256[](numSamples);
for (uint256 i = 0; i < numSamples; i++) {
try
IBancorNetwork(bancorNetwork)
.rateByPath
{gas: BANCOR_CALL_GAS}
(path, takerTokenAmounts[i])
returns (uint256 amount)
{
makerTokenAmounts[i] = amount;
} catch {
// Swallow failures, leaving all results as zero.
break;
}
}
return (bancorNetwork, path, makerTokenAmounts);
}
/// @dev Sample buy quotes from Bancor. Unimplemented
/// @param paths The paths to check for Bancor. Only the best is used
/// @param takerToken Address of the taker token (what to sell).
/// @param makerToken Address of the maker token (what to buy).
/// @param makerTokenAmounts Maker token buy amount for each sample.
/// @return bancorNetwork the Bancor Network address
/// @return path the selected conversion path from bancor
/// @return takerTokenAmounts Taker amounts sold at each maker token
/// amount.
function sampleBuysFromBancor(
address[][] memory paths,
address takerToken,
address makerToken,
uint256[] memory makerTokenAmounts
)
public
view
returns (address bancorNetwork, address[] memory path, uint256[] memory takerTokenAmounts)
{
}
function _getBancorNetwork()
private
view
returns (address)
{
IBancorRegistry registry = IBancorRegistry(_getBancorRegistryAddress());
return registry.getAddress(registry.BANCOR_NETWORK());
}
}

View File

@@ -62,6 +62,8 @@ contract DeploymentConstants {
address constant private DODO_REGISTRY = 0x3A97247DF274a17C59A3bd12735ea3FcDFb49950;
/// @dev Mainnet address of the DODO Helper contract
address constant private DODO_HELPER = 0x533dA777aeDCE766CEAe696bf90f8541A4bA80Eb;
/// @dev Mainnet address of the Bancor Registry contract
address constant private BANCOR_REGISTRY = 0x52Ae12ABe5D8BD778BD5397F99cA900624CfADD4;
// // Ropsten addresses ///////////////////////////////////////////////////////
// /// @dev Mainnet address of the WETH contract.
@@ -337,4 +339,14 @@ contract DeploymentConstants {
{
return DODO_HELPER;
}
/// @dev An overridable way to retrieve the Bancor Registry contract address.
/// @return registry The Bancor registry contract address.
function _getBancorRegistryAddress()
internal
view
returns (address registry)
{
return BANCOR_REGISTRY;
}
}

View File

@@ -20,6 +20,7 @@ pragma solidity ^0.6;
pragma experimental ABIEncoderV2;
import "./BalancerSampler.sol";
import "./BancorSampler.sol";
import "./CurveSampler.sol";
import "./DODOSampler.sol";
import "./Eth2DaiSampler.sol";
@@ -38,6 +39,7 @@ import "./UniswapV2Sampler.sol";
contract ERC20BridgeSampler is
BalancerSampler,
BancorSampler,
CurveSampler,
DODOSampler,
Eth2DaiSampler,

View File

@@ -0,0 +1,32 @@
/*
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;
interface IBancor {}
interface IBancorNetwork {
function conversionPath(address _sourceToken, address _targetToken) external view returns (address[] memory);
function rateByPath(address[] memory _path, uint256 _amount) external view returns (uint256);
}
interface IBancorRegistry {
function getAddress(bytes32 _contractName) external view returns (address);
function BANCOR_NETWORK() external view returns (bytes32);
}

View File

@@ -1,6 +1,6 @@
{
"name": "@0x/asset-swapper",
"version": "5.3.0",
"version": "5.5.0",
"engines": {
"node": ">=6.12"
},
@@ -36,9 +36,9 @@
"publish:private": "yarn build && gitpkg publish"
},
"config": {
"publicInterfaceContracts": "ERC20BridgeSampler",
"publicInterfaceContracts": "ERC20BridgeSampler,BalanceChecker",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
"abis": "./test/generated-artifacts/@(ApproximateBuys|BalancerSampler|CurveSampler|DODOSampler|DeploymentConstants|DummyLiquidityProvider|ERC20BridgeSampler|Eth2DaiSampler|IBalancer|ICurve|IEth2Dai|IKyberNetwork|IMStable|IMooniswap|IMultiBridge|IShell|IUniswapExchangeQuotes|IUniswapV2Router01|KyberSampler|LiquidityProviderSampler|MStableSampler|MooniswapSampler|MultiBridgeSampler|NativeOrderSampler|SamplerUtils|ShellSampler|SushiSwapSampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler).json",
"abis": "./test/generated-artifacts/@(ApproximateBuys|BalanceChecker|BalancerSampler|BancorSampler|CurveSampler|DODOSampler|DeploymentConstants|DummyLiquidityProvider|ERC20BridgeSampler|Eth2DaiSampler|IBalancer|IBancor|ICurve|IEth2Dai|IKyberNetwork|IMStable|IMooniswap|IMultiBridge|IShell|IUniswapExchangeQuotes|IUniswapV2Router01|KyberSampler|LiquidityProviderSampler|MStableSampler|MooniswapSampler|MultiBridgeSampler|NativeOrderSampler|SamplerUtils|ShellSampler|SushiSwapSampler|TestERC20BridgeSampler|TestNativeOrderSampler|TwoHopSampler|UniswapSampler|UniswapV2Sampler).json",
"postpublish": {
"assets": []
}
@@ -58,20 +58,20 @@
},
"dependencies": {
"@0x/assert": "^3.0.19",
"@0x/base-contract": "^6.2.13",
"@0x/contract-addresses": "^5.5.0",
"@0x/contract-wrappers": "^13.10.2",
"@0x/dev-utils": "^4.1.2",
"@0x/base-contract": "^6.2.14",
"@0x/contract-addresses": "^5.6.0",
"@0x/contract-wrappers": "^13.11.0",
"@0x/dev-utils": "^4.1.3",
"@0x/json-schemas": "^5.3.4",
"@0x/order-utils": "^10.4.8",
"@0x/order-utils": "^10.4.10",
"@0x/orderbook": "0xProject/gitpkg-registry#0x-orderbook-v2.2.7-e10a81023",
"@0x/quote-server": "^3.1.0",
"@0x/types": "^3.3.1",
"@0x/typescript-typings": "^5.1.6",
"@0x/utils": "^6.1.1",
"@0x/web3-wrapper": "^7.2.10",
"@0x/web3-wrapper": "^7.3.0",
"@balancer-labs/sor": "0.3.2",
"@bancor/sdk": "^0.2.9",
"@bancor/sdk": "0.2.9",
"@ethersproject/abi": "^5.0.1",
"@ethersproject/address": "^5.0.1",
"@ethersproject/contracts": "^5.0.1",
@@ -86,19 +86,19 @@
"lodash": "^4.17.11"
},
"devDependencies": {
"@0x/base-contract": "^6.2.13",
"@0x/contracts-asset-proxy": "^3.6.7",
"@0x/contracts-erc20": "^3.2.10",
"@0x/contracts-exchange": "^3.2.16",
"@0x/contracts-exchange-libs": "^4.3.16",
"@0x/contracts-gen": "^2.0.23",
"@0x/contracts-test-utils": "^5.3.13",
"@0x/contracts-utils": "^4.6.1",
"@0x/contracts-zero-ex": "^0.11.0",
"@0x/base-contract": "^6.2.14",
"@0x/contracts-asset-proxy": "^3.7.0",
"@0x/contracts-erc20": "^3.2.12",
"@0x/contracts-exchange": "^3.2.19",
"@0x/contracts-exchange-libs": "^4.3.18",
"@0x/contracts-gen": "^2.0.24",
"@0x/contracts-test-utils": "^5.3.15",
"@0x/contracts-utils": "^4.6.3",
"@0x/contracts-zero-ex": "^0.13.0",
"@0x/mesh-rpc-client": "^9.4.2",
"@0x/migrations": "^6.5.2",
"@0x/sol-compiler": "^4.4.0",
"@0x/subproviders": "^6.2.2",
"@0x/migrations": "^6.5.5",
"@0x/sol-compiler": "^4.4.1",
"@0x/subproviders": "^6.2.3",
"@0x/ts-doc-gen": "^0.0.28",
"@0x/tslint-config": "^4.1.3",
"@0x/types": "^3.3.1",

View File

@@ -5,5 +5,9 @@
*/
import { ContractArtifact } from 'ethereum-types';
import * as BalanceChecker from '../generated-artifacts/BalanceChecker.json';
import * as ERC20BridgeSampler from '../generated-artifacts/ERC20BridgeSampler.json';
export const artifacts = { ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact };
export const artifacts = {
ERC20BridgeSampler: ERC20BridgeSampler as ContractArtifact,
BalanceChecker: BalanceChecker as ContractArtifact,
};

View File

@@ -177,7 +177,7 @@ export {
} from './utils/quote_report_generator';
export { QuoteRequestor } from './utils/quote_requestor';
export { rfqtMocker } from './utils/rfqt_mocker';
export { ERC20BridgeSamplerContract } from './wrappers';
export { ERC20BridgeSamplerContract, BalanceCheckerContract } from './wrappers';
import { ERC20BridgeSource } from './utils/market_operation_utils/types';
export type Native = ERC20BridgeSource.Native;
export type MultiHop = ERC20BridgeSource.MultiHop;

View File

@@ -213,9 +213,8 @@ export class SwapQuoter {
samplerContract,
samplerOverrides,
provider,
undefined,
undefined,
undefined,
undefined, // balancer pool cache
undefined, // cream pool cache
tokenAdjacencyGraph,
liquidityProviderRegistry,
),

View File

@@ -198,6 +198,8 @@ export interface SwapQuoteBase {
isTwoHop: boolean;
makerTokenDecimals: number;
takerTokenDecimals: number;
takerAssetToEthRate: BigNumber;
makerAssetToEthRate: BigNumber;
}
/**

View File

@@ -1,26 +1,17 @@
import { SupportedProvider } from '@0x/dev-utils';
import { BigNumber } from '@0x/utils';
import { SDK } from '@bancor/sdk';
import { Ethereum, getDecimals } from '@bancor/sdk/dist/blockchains/ethereum';
import { fromWei, toWei } from '@bancor/sdk/dist/helpers';
import { BlockchainType, Token } from '@bancor/sdk/dist/types';
import { Ethereum } from '@bancor/sdk/dist/blockchains/ethereum';
import { BlockchainType } from '@bancor/sdk/dist/types';
import { BancorFillData, Quote } from './types';
import { TOKENS } from './constants';
/**
* Converts an address to a Bancor Token type
*/
export function token(address: string, blockchainType: BlockchainType = BlockchainType.Ethereum): Token {
return {
blockchainType,
blockchainId: address,
};
}
const findToken = (tokenAddress: string, graph: object): string =>
// If we're looking for WETH it is stored by Bancor as the 0xeee address
tokenAddress.toLowerCase() === TOKENS.WETH.toLowerCase()
? '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
: Object.keys(graph).filter(k => k.toLowerCase() === tokenAddress.toLowerCase())[0];
export class BancorService {
// Bancor recommends setting this value to 2% under the expected return amount
public minReturnAmountBufferPercentage = 0.99;
public static async createAsync(provider: SupportedProvider): Promise<BancorService> {
const sdk = await SDK.create({ ethereumNodeEndpoint: provider });
const service = new BancorService(sdk);
@@ -28,38 +19,16 @@ export class BancorService {
}
constructor(public sdk: SDK) {}
public async getQuotesAsync(
fromToken: string,
toToken: string,
amounts: BigNumber[],
): Promise<Array<Quote<BancorFillData>>> {
const sdk = this.sdk;
const blockchain = sdk._core.blockchains[BlockchainType.Ethereum] as Ethereum;
const sourceDecimals = await getDecimals(blockchain, fromToken);
const quotes = await sdk.pricing.getPathAndRates(
token(fromToken),
token(toToken),
amounts.map(amt => fromWei(amt.toString(), sourceDecimals)),
);
const targetDecimals = await getDecimals(blockchain, toToken);
const networkAddress = this.getBancorNetworkAddress();
return quotes.map(quote => {
const { path, rate } = quote;
const output = toWei(rate, targetDecimals);
return {
amount: new BigNumber(output).multipliedBy(this.minReturnAmountBufferPercentage).dp(0),
fillData: {
path: path.map(p => p.blockchainId),
networkAddress,
},
};
});
}
public getBancorNetworkAddress(): string {
const blockchain = this.sdk._core.blockchains[BlockchainType.Ethereum] as Ethereum;
return blockchain.bancorNetwork._address;
public getPaths(_fromToken: string, _toToken: string): string[][] {
// HACK: We reach into the blockchain object and pull in it's cache of tokens
// and we use it's internal non-async getPathsFunc
try {
const blockchain = this.sdk._core.blockchains[BlockchainType.Ethereum] as Ethereum;
const fromToken = findToken(_fromToken, blockchain.graph);
const toToken = findToken(_toToken, blockchain.graph);
return blockchain.getPathsFunc.bind(blockchain)(fromToken, toToken);
} catch (e) {
return [];
}
}
}

View File

@@ -5,6 +5,7 @@ import { BridgeContractAddresses } from '../../types';
import { SourceFilters } from './source_filters';
import {
BancorFillData,
CurveFillData,
CurveFunctionSelectors,
CurveInfo,
@@ -34,8 +35,7 @@ export const SELL_SOURCE_FILTER = new SourceFilters([
ERC20BridgeSource.Kyber,
ERC20BridgeSource.Curve,
ERC20BridgeSource.Balancer,
// Bancor is sampled off-chain, but this list should only include on-chain sources (used in ERC20BridgeSampler)
// ERC20BridgeSource.Bancor,
ERC20BridgeSource.Bancor,
ERC20BridgeSource.MStable,
ERC20BridgeSource.Mooniswap,
ERC20BridgeSource.Swerve,
@@ -60,7 +60,7 @@ export const BUY_SOURCE_FILTER = new SourceFilters([
ERC20BridgeSource.Kyber,
ERC20BridgeSource.Curve,
ERC20BridgeSource.Balancer,
// ERC20BridgeSource.Bancor, // FIXME: Disabled until Bancor SDK supports buy quotes
// ERC20BridgeSource.Bancor, // FIXME: Bancor Buys not implemented in Sampler
ERC20BridgeSource.MStable,
ERC20BridgeSource.Mooniswap,
ERC20BridgeSource.Shell,
@@ -410,7 +410,7 @@ export const BRIDGE_ADDRESSES_BY_CHAIN: { [chainId in ChainId]: BridgeContractAd
curveBridge: '0x1796cd592d19e3bcd744fbb025bb61a6d8cb2c09',
multiBridge: '0xc03117a8c9bde203f70aa911cb64a7a0df5ba1e1',
balancerBridge: '0xfe01821ca163844203220cd08e4f2b2fb43ae4e4',
bancorBridge: '0x259897d9699553edbdf8538599242354e957fb94',
bancorBridge: '0xc880c252db7c51f74161633338a3bdafa8e65276',
mStableBridge: '0x2bf04fcea05f0989a14d9afa37aa376baca6b2b3',
mooniswapBridge: '0x02b7eca484ad960fca3f7709e0b2ac81eec3069c',
sushiswapBridge: '0x47ed0262a0b688dcb836d254c6a2e96b6c48a9f5',
@@ -539,7 +539,14 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
throw new Error('Unrecognized SnowSwap address');
}
},
[ERC20BridgeSource.Bancor]: () => 300e3,
[ERC20BridgeSource.Bancor]: (fillData?: FillData) => {
let gas = 200e3;
const path = (fillData as BancorFillData).path;
if (path.length > 2) {
gas += (path.length - 2) * 60e3; // +60k for each hop.
}
return gas;
},
};
export const DEFAULT_FEE_SCHEDULE: Required<FeeSchedule> = Object.assign(

View File

@@ -81,13 +81,12 @@ export class MarketOperationUtils {
private readonly _feeSources = new SourceFilters(FEE_QUOTE_SOURCES);
private static _computeQuoteReport(
nativeOrders: SignedOrder[],
quoteRequestor: QuoteRequestor | undefined,
marketSideLiquidity: MarketSideLiquidity,
optimizerResult: OptimizerResult,
comparisonPrice?: BigNumber | undefined,
): QuoteReport {
const { side, dexQuotes, twoHopQuotes, orderFillableAmounts } = marketSideLiquidity;
const { side, dexQuotes, twoHopQuotes, orderFillableAmounts, nativeOrders } = marketSideLiquidity;
const { liquidityDelivered } = optimizerResult;
return generateQuoteReport(
side,
@@ -204,23 +203,12 @@ export class MarketOperationUtils {
? this._sampler.getCreamSellQuotesOffChainAsync(makerToken, takerToken, sampleAmounts)
: Promise.resolve([]);
const offChainBancorPromise = quoteSourceFilters.isAllowed(ERC20BridgeSource.Bancor)
? this._sampler.getBancorSellQuotesOffChainAsync(makerToken, takerToken, [takerAmount])
: Promise.resolve([]);
const [
[tokenDecimals, orderFillableAmounts, ethToMakerAssetRate, ethToTakerAssetRate, dexQuotes, twoHopQuotes],
rfqtIndicativeQuotes,
offChainBalancerQuotes,
offChainCreamQuotes,
offChainBancorQuotes,
] = await Promise.all([
samplerPromise,
rfqtPromise,
offChainBalancerPromise,
offChainCreamPromise,
offChainBancorPromise,
]);
] = await Promise.all([samplerPromise, rfqtPromise, offChainBalancerPromise, offChainCreamPromise]);
const [makerTokenDecimals, takerTokenDecimals] = tokenDecimals;
return {
@@ -228,7 +216,7 @@ export class MarketOperationUtils {
inputAmount: takerAmount,
inputToken: takerToken,
outputToken: makerToken,
dexQuotes: dexQuotes.concat([...offChainBalancerQuotes, ...offChainCreamQuotes, offChainBancorQuotes]),
dexQuotes: dexQuotes.concat([...offChainBalancerQuotes, ...offChainCreamQuotes]),
nativeOrders,
orderFillableAmounts,
ethToOutputRate: ethToMakerAssetRate,
@@ -543,6 +531,10 @@ export class MarketOperationUtils {
exchangeProxyOverhead: opts.exchangeProxyOverhead || (() => ZERO_AMOUNT),
};
// NOTE: For sell quotes input is the taker asset and for buy quotes input is the maker asset
const takerAssetToEthRate = side === MarketOperation.Sell ? ethToInputRate : ethToOutputRate;
const makerAssetToEthRate = side === MarketOperation.Sell ? ethToOutputRate : ethToInputRate;
// Find the unoptimized best rate to calculate savings from optimizer
const _unoptimizedPath = fillsToSortedPaths(fills, side, inputAmount, optimizerOpts)[0];
const unoptimizedPath = _unoptimizedPath ? _unoptimizedPath.collapse(orderOpts) : undefined;
@@ -565,6 +557,8 @@ export class MarketOperationUtils {
marketSideLiquidity,
adjustedRate: bestTwoHopRate,
unoptimizedPath,
takerAssetToEthRate,
makerAssetToEthRate,
};
}
@@ -598,6 +592,8 @@ export class MarketOperationUtils {
marketSideLiquidity,
adjustedRate: optimalPathRate,
unoptimizedPath,
takerAssetToEthRate,
makerAssetToEthRate,
};
}
@@ -622,7 +618,7 @@ export class MarketOperationUtils {
side === MarketOperation.Sell
? this.getMarketSellLiquidityAsync.bind(this)
: this.getMarketBuyLiquidityAsync.bind(this);
const marketSideLiquidity: MarketSideLiquidity = await marketLiquidityFnAsync(nativeOrders, amount, _opts);
let marketSideLiquidity: MarketSideLiquidity = await marketLiquidityFnAsync(nativeOrders, amount, _opts);
let optimizerResult: OptimizerResult | undefined;
try {
optimizerResult = await this._generateOptimizedOrdersAsync(marketSideLiquidity, optimizerOpts);
@@ -665,13 +661,11 @@ export class MarketOperationUtils {
);
// Re-run optimizer with the new indicative quote
if (indicativeQuotes.length > 0) {
optimizerResult = await this._generateOptimizedOrdersAsync(
{
...marketSideLiquidity,
rfqtIndicativeQuotes: indicativeQuotes,
},
optimizerOpts,
);
marketSideLiquidity = {
...marketSideLiquidity,
rfqtIndicativeQuotes: indicativeQuotes,
};
optimizerResult = await this._generateOptimizedOrdersAsync(marketSideLiquidity, optimizerOpts);
}
} else if (!rfqt.isIndicative && isFirmPriceAwareEnabled) {
// A firm quote is being requested, and firm quotes price-aware enabled. Ensure that `intentOnFilling` is enabled.
@@ -699,19 +693,18 @@ export class MarketOperationUtils {
? firmQuoteSignedOrders.map(signedOrder => signedOrder.takerAssetAmount)
: await rfqt.firmQuoteValidator.getRfqtTakerFillableAmountsAsync(firmQuoteSignedOrders);
marketSideLiquidity = {
...marketSideLiquidity,
nativeOrders: marketSideLiquidity.nativeOrders.concat(firmQuoteSignedOrders),
orderFillableAmounts: marketSideLiquidity.orderFillableAmounts.concat(
rfqOrderFillableAmounts,
),
};
// Re-run optimizer with the new firm quote. This is the second and last time
// we run the optimized in a block of code. In this case, we don't catch a potential `NoOptimalPath` exception
// and we let it bubble up if it happens.
optimizerResult = await this._generateOptimizedOrdersAsync(
{
...marketSideLiquidity,
nativeOrders: marketSideLiquidity.nativeOrders.concat(firmQuoteSignedOrders),
orderFillableAmounts: marketSideLiquidity.orderFillableAmounts.concat(
rfqOrderFillableAmounts,
),
},
optimizerOpts,
);
optimizerResult = await this._generateOptimizedOrdersAsync(marketSideLiquidity, optimizerOpts);
}
}
}
@@ -727,7 +720,6 @@ export class MarketOperationUtils {
let quoteReport: QuoteReport | undefined;
if (_opts.shouldGenerateQuoteReport) {
quoteReport = MarketOperationUtils._computeQuoteReport(
nativeOrders,
_opts.rfqt ? _opts.rfqt.quoteRequestor : undefined,
marketSideLiquidity,
optimizerResult,

View File

@@ -5,7 +5,6 @@ import { SamplerOverrides } from '../../types';
import { ERC20BridgeSamplerContract } from '../../wrappers';
import { BalancerPoolsCache } from './balancer_utils';
import { BancorService } from './bancor_service';
import { CreamPoolsCache } from './cream_utils';
import { SamplerOperations } from './sampler_operations';
import { BatchedOperation, LiquidityProviderRegistry, TokenAdjacencyGraph } from './types';
@@ -39,7 +38,6 @@ export class DexOrderSampler extends SamplerOperations {
provider?: SupportedProvider,
balancerPoolsCache?: BalancerPoolsCache,
creamPoolsCache?: CreamPoolsCache,
getBancorServiceFn?: () => BancorService,
tokenAdjacencyGraph?: TokenAdjacencyGraph,
liquidityProviderRegistry?: LiquidityProviderRegistry,
) {
@@ -48,7 +46,6 @@ export class DexOrderSampler extends SamplerOperations {
provider,
balancerPoolsCache,
creamPoolsCache,
getBancorServiceFn,
tokenAdjacencyGraph,
liquidityProviderRegistry,
);

View File

@@ -84,22 +84,20 @@ export class SamplerOperations {
public readonly provider?: SupportedProvider,
public readonly balancerPoolsCache: BalancerPoolsCache = new BalancerPoolsCache(),
public readonly creamPoolsCache: CreamPoolsCache = new CreamPoolsCache(),
protected readonly getBancorServiceFn?: () => BancorService, // for dependency injection in tests
protected readonly tokenAdjacencyGraph: TokenAdjacencyGraph = { default: [] },
public readonly liquidityProviderRegistry: LiquidityProviderRegistry = LIQUIDITY_PROVIDER_REGISTRY,
) {}
) {
// Initialize the Bancor service, fetching paths in the background
this.initBancorServiceAsync().catch(/* do nothing */);
}
public async getBancorServiceAsync(): Promise<BancorService> {
if (this.getBancorServiceFn !== undefined) {
return this.getBancorServiceFn();
}
public async initBancorServiceAsync(): Promise<void> {
if (this.provider === undefined) {
throw new Error('Cannot sample liquidity from Bancor; no provider supplied.');
return;
}
if (this._bancorService === undefined) {
this._bancorService = await BancorService.createAsync(this.provider);
}
return this._bancorService;
}
public getTokenDecimals(makerTokenAddress: string, takerTokenAddress: string): BatchedOperation<BigNumber[]> {
@@ -588,28 +586,48 @@ export class SamplerOperations {
});
}
public async getBancorSellQuotesOffChainAsync(
public getBancorSellQuotes(
makerToken: string,
takerToken: string,
takerFillAmounts: BigNumber[],
): Promise<Array<DexSample<BancorFillData>>> {
const bancorService = await this.getBancorServiceAsync();
try {
const quotes = await bancorService.getQuotesAsync(takerToken, makerToken, takerFillAmounts);
return quotes.map((quote, i) => ({
source: ERC20BridgeSource.Bancor,
output: quote.amount,
input: takerFillAmounts[i],
fillData: quote.fillData,
}));
} catch (e) {
return takerFillAmounts.map(input => ({
source: ERC20BridgeSource.Bancor,
output: ZERO_AMOUNT,
input,
fillData: { path: [], networkAddress: '' },
}));
}
): SourceQuoteOperation<BancorFillData> {
const paths = this._bancorService ? this._bancorService.getPaths(takerToken, makerToken) : [];
return new SamplerContractOperation({
source: ERC20BridgeSource.Bancor,
contract: this._samplerContract,
function: this._samplerContract.sampleSellsFromBancor,
params: [paths, takerToken, makerToken, takerFillAmounts],
callback: (callResults: string, fillData: BancorFillData): BigNumber[] => {
const [networkAddress, path, samples] = this._samplerContract.getABIDecodedReturnData<
[string, string[], BigNumber[]]
>('sampleSellsFromBancor', callResults);
fillData.networkAddress = networkAddress;
fillData.path = path;
return samples;
},
});
}
// Unimplemented
public getBancorBuyQuotes(
makerToken: string,
takerToken: string,
makerFillAmounts: BigNumber[],
): SourceQuoteOperation<BancorFillData> {
return new SamplerContractOperation({
source: ERC20BridgeSource.Bancor,
contract: this._samplerContract,
function: this._samplerContract.sampleBuysFromBancor,
params: [[], takerToken, makerToken, makerFillAmounts],
callback: (callResults: string, fillData: BancorFillData): BigNumber[] => {
const [networkAddress, path, samples] = this._samplerContract.getABIDecodedReturnData<
[string, string[], BigNumber[]]
>('sampleSellsFromBancor', callResults);
fillData.networkAddress = networkAddress;
fillData.path = path;
return samples;
},
});
}
public getMooniswapSellQuotes(
@@ -1114,6 +1132,8 @@ export class SamplerOperations {
);
case ERC20BridgeSource.Dodo:
return this.getDODOSellQuotes(makerToken, takerToken, takerFillAmounts);
case ERC20BridgeSource.Bancor:
return this.getBancorSellQuotes(makerToken, takerToken, takerFillAmounts);
default:
throw new Error(`Unsupported sell sample source: ${source}`);
}
@@ -1237,6 +1257,8 @@ export class SamplerOperations {
);
case ERC20BridgeSource.Dodo:
return this.getDODOBuyQuotes(makerToken, takerToken, makerFillAmounts);
case ERC20BridgeSource.Bancor:
return this.getBancorBuyQuotes(makerToken, takerToken, makerFillAmounts);
default:
throw new Error(`Unsupported buy sample source: ${source}`);
}

View File

@@ -346,6 +346,8 @@ export interface OptimizerResult {
marketSideLiquidity: MarketSideLiquidity;
adjustedRate: BigNumber;
unoptimizedPath?: CollapsedPath;
takerAssetToEthRate: BigNumber;
makerAssetToEthRate: BigNumber;
}
export interface OptimizerResultWithReport extends OptimizerResult {

View File

@@ -170,7 +170,14 @@ function createSwapQuote(
gasPrice: BigNumber,
gasSchedule: FeeSchedule,
): SwapQuote {
const { optimizedOrders, quoteReport, sourceFlags, unoptimizedPath } = optimizerResult;
const {
optimizedOrders,
quoteReport,
sourceFlags,
unoptimizedPath,
takerAssetToEthRate,
makerAssetToEthRate,
} = optimizerResult;
const isTwoHop = sourceFlags === SOURCE_FLAGS[ERC20BridgeSource.MultiHop];
// Calculate quote info
@@ -203,6 +210,8 @@ function createSwapQuote(
sourceBreakdown,
makerTokenDecimals,
takerTokenDecimals,
takerAssetToEthRate,
makerAssetToEthRate,
quoteReport,
isTwoHop,
};

View File

@@ -3,4 +3,5 @@
* Warning: This file is auto-generated by contracts-gen. Don't edit manually.
* -----------------------------------------------------------------------------
*/
export * from '../generated-wrappers/balance_checker';
export * from '../generated-wrappers/erc20_bridge_sampler';

View File

@@ -6,7 +6,9 @@
import { ContractArtifact } from 'ethereum-types';
import * as ApproximateBuys from '../test/generated-artifacts/ApproximateBuys.json';
import * as BalanceChecker from '../test/generated-artifacts/BalanceChecker.json';
import * as BalancerSampler from '../test/generated-artifacts/BalancerSampler.json';
import * as BancorSampler from '../test/generated-artifacts/BancorSampler.json';
import * as CurveSampler from '../test/generated-artifacts/CurveSampler.json';
import * as DeploymentConstants from '../test/generated-artifacts/DeploymentConstants.json';
import * as DODOSampler from '../test/generated-artifacts/DODOSampler.json';
@@ -14,6 +16,7 @@ import * as DummyLiquidityProvider from '../test/generated-artifacts/DummyLiquid
import * as ERC20BridgeSampler from '../test/generated-artifacts/ERC20BridgeSampler.json';
import * as Eth2DaiSampler from '../test/generated-artifacts/Eth2DaiSampler.json';
import * as IBalancer from '../test/generated-artifacts/IBalancer.json';
import * as IBancor from '../test/generated-artifacts/IBancor.json';
import * as ICurve from '../test/generated-artifacts/ICurve.json';
import * as IEth2Dai from '../test/generated-artifacts/IEth2Dai.json';
import * as IKyberNetwork from '../test/generated-artifacts/IKyberNetwork.json';
@@ -39,7 +42,9 @@ import * as UniswapSampler from '../test/generated-artifacts/UniswapSampler.json
import * as UniswapV2Sampler from '../test/generated-artifacts/UniswapV2Sampler.json';
export const artifacts = {
ApproximateBuys: ApproximateBuys as ContractArtifact,
BalanceChecker: BalanceChecker as ContractArtifact,
BalancerSampler: BalancerSampler as ContractArtifact,
BancorSampler: BancorSampler as ContractArtifact,
CurveSampler: CurveSampler as ContractArtifact,
DODOSampler: DODOSampler as ContractArtifact,
DeploymentConstants: DeploymentConstants as ContractArtifact,
@@ -58,6 +63,7 @@ export const artifacts = {
UniswapSampler: UniswapSampler as ContractArtifact,
UniswapV2Sampler: UniswapV2Sampler as ContractArtifact,
IBalancer: IBalancer as ContractArtifact,
IBancor: IBancor as ContractArtifact,
ICurve: ICurve as ContractArtifact,
IEth2Dai: IEth2Dai as ContractArtifact,
IKyberNetwork: IKyberNetwork as ContractArtifact,

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