Compare commits
12 Commits
@0x/contra
...
protocol@d
Author | SHA1 | Date | |
---|---|---|---|
|
d9a16ed1f9 | ||
|
57a1120997 | ||
|
0945d4cef2 | ||
|
8f6f7ad453 | ||
|
bb4fad37fa | ||
|
d06daf2957 | ||
|
34314960ef | ||
|
832ba737ec | ||
|
6950fdbebb | ||
|
1849b1bb9a | ||
|
a883139220 | ||
|
bb2c26cb94 |
@@ -1,4 +1,22 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1633374058,
|
||||
"version": "1.4.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1632957537,
|
||||
"version": "1.4.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "1.4.0",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.4.2 - _October 4, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.1 - _September 29, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.4.0 - _September 15, 2021_
|
||||
|
||||
* Support cast vote by signature in Treasury
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-treasury",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.2",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -73,7 +73,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.4.2",
|
||||
"@0x/protocol-utils": "^1.9.0",
|
||||
"@0x/protocol-utils": "^1.9.2",
|
||||
"@0x/subproviders": "^6.6.0",
|
||||
"@0x/types": "^3.3.4",
|
||||
"@0x/typescript-typings": "^5.2.1",
|
||||
|
@@ -1,4 +1,23 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1633374058,
|
||||
"version": "0.29.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.29.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Export TransformERC20FeatureContract",
|
||||
"pr": 282
|
||||
}
|
||||
],
|
||||
"timestamp": 1632957537
|
||||
},
|
||||
{
|
||||
"timestamp": 1631710679,
|
||||
"version": "0.28.5",
|
||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.29.1 - _October 4, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.29.0 - _September 29, 2021_
|
||||
|
||||
* Export TransformERC20FeatureContract (#282)
|
||||
|
||||
## v0.28.5 - _September 15, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -25,7 +25,6 @@ import "./BridgeProtocols.sol";
|
||||
import "./mixins/MixinBalancer.sol";
|
||||
import "./mixins/MixinBalancerV2.sol";
|
||||
import "./mixins/MixinBancor.sol";
|
||||
import "./mixins/MixinClipper.sol";
|
||||
import "./mixins/MixinCoFiX.sol";
|
||||
import "./mixins/MixinCurve.sol";
|
||||
import "./mixins/MixinCurveV2.sol";
|
||||
@@ -51,7 +50,6 @@ contract BridgeAdapter is
|
||||
MixinBalancer,
|
||||
MixinBalancerV2,
|
||||
MixinBancor,
|
||||
MixinClipper,
|
||||
MixinCoFiX,
|
||||
MixinCurve,
|
||||
MixinCurveV2,
|
||||
@@ -77,7 +75,6 @@ contract BridgeAdapter is
|
||||
MixinBalancer()
|
||||
MixinBalancerV2()
|
||||
MixinBancor(weth)
|
||||
MixinClipper(weth)
|
||||
MixinCoFiX()
|
||||
MixinCurve(weth)
|
||||
MixinCurveV2()
|
||||
@@ -248,13 +245,6 @@ contract BridgeAdapter is
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else if (protocolId == BridgeProtocols.CLIPPER) {
|
||||
boughtAmount = _tradeClipper(
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
order.bridgeData
|
||||
);
|
||||
} else {
|
||||
boughtAmount = _tradeZeroExBridge(
|
||||
sellToken,
|
||||
|
@@ -49,5 +49,5 @@ library BridgeProtocols {
|
||||
uint128 internal constant KYBERDMM = 19;
|
||||
uint128 internal constant CURVEV2 = 20;
|
||||
uint128 internal constant LIDO = 21;
|
||||
uint128 internal constant CLIPPER = 22;
|
||||
uint128 internal constant CLIPPER = 22; // Not used: Clipper is now using PLP interface
|
||||
}
|
||||
|
@@ -1,148 +0,0 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/*
|
||||
|
||||
Copyright 2021 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6.5;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
import "../IBridgeAdapter.sol";
|
||||
import "../../../vendor/ILiquidityProvider.sol";
|
||||
|
||||
contract MixinClipper {
|
||||
|
||||
using LibERC20TokenV06 for IERC20TokenV06;
|
||||
|
||||
/// @dev Mainnet address of the WETH contract.
|
||||
IEtherTokenV06 private immutable WETH;
|
||||
|
||||
constructor(IEtherTokenV06 weth)
|
||||
public
|
||||
{
|
||||
WETH = weth;
|
||||
}
|
||||
|
||||
function _tradeClipper(
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory bridgeData
|
||||
)
|
||||
internal
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
// We can only use ETH with Clipper, no WETH available
|
||||
(ILiquidityProvider clipper, bytes memory auxiliaryData) =
|
||||
abi.decode(bridgeData, (ILiquidityProvider, bytes));
|
||||
|
||||
if (sellToken == WETH) {
|
||||
boughtAmount = _executeSellEthForToken(
|
||||
clipper,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
auxiliaryData
|
||||
);
|
||||
} else if (buyToken == WETH) {
|
||||
boughtAmount = _executeSellTokenForEth(
|
||||
clipper,
|
||||
sellToken,
|
||||
sellAmount,
|
||||
auxiliaryData
|
||||
);
|
||||
} else {
|
||||
boughtAmount = _executeSellTokenForToken(
|
||||
clipper,
|
||||
sellToken,
|
||||
buyToken,
|
||||
sellAmount,
|
||||
auxiliaryData
|
||||
);
|
||||
}
|
||||
|
||||
return boughtAmount;
|
||||
}
|
||||
|
||||
function _executeSellEthForToken(
|
||||
ILiquidityProvider clipper,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory auxiliaryData
|
||||
)
|
||||
private
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
// Clipper requires ETH and doesn't support WETH
|
||||
WETH.withdraw(sellAmount);
|
||||
boughtAmount = clipper.sellEthForToken{ value: sellAmount }(
|
||||
buyToken,
|
||||
address(this),
|
||||
1,
|
||||
auxiliaryData
|
||||
);
|
||||
}
|
||||
|
||||
function _executeSellTokenForEth(
|
||||
ILiquidityProvider clipper,
|
||||
IERC20TokenV06 sellToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory auxiliaryData
|
||||
)
|
||||
private
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
// Optimization: We can transfer the tokens into clipper rather than
|
||||
// have an allowance updated
|
||||
sellToken.compatTransfer(address(clipper), sellAmount);
|
||||
|
||||
boughtAmount = clipper.sellTokenForEth(
|
||||
sellToken,
|
||||
payable(address(this)),
|
||||
1,
|
||||
auxiliaryData
|
||||
);
|
||||
|
||||
// we want WETH for possible future trades
|
||||
WETH.deposit{ value: boughtAmount }();
|
||||
}
|
||||
|
||||
function _executeSellTokenForToken(
|
||||
ILiquidityProvider clipper,
|
||||
IERC20TokenV06 sellToken,
|
||||
IERC20TokenV06 buyToken,
|
||||
uint256 sellAmount,
|
||||
bytes memory auxiliaryData
|
||||
)
|
||||
private
|
||||
returns (uint256 boughtAmount)
|
||||
{
|
||||
// Optimization: We can transfer the tokens into clipper rather than
|
||||
// have an allowance updated
|
||||
sellToken.compatTransfer(address(clipper), sellAmount);
|
||||
|
||||
boughtAmount = clipper.sellTokenForToken(
|
||||
sellToken,
|
||||
buyToken,
|
||||
address(this),
|
||||
1,
|
||||
auxiliaryData
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-zero-ex",
|
||||
"version": "0.28.5",
|
||||
"version": "0.29.1",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -43,7 +43,7 @@
|
||||
"config": {
|
||||
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,PositiveSlippageFeeTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,AffiliateFeeTransformer,MetaTransactionsFeature,LogMetadataTransformer,BridgeAdapter,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IFeature|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinBalancer|MixinBalancerV2|MixinBancor|MixinClipper|MixinCoFiX|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestMooniswap|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
|
||||
"abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IFeature|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinBalancer|MixinBalancerV2|MixinBancor|MixinCoFiX|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestMooniswap|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -83,7 +83,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^6.4.2",
|
||||
"@0x/protocol-utils": "^1.9.0",
|
||||
"@0x/protocol-utils": "^1.9.2",
|
||||
"@0x/subproviders": "^6.6.0",
|
||||
"@0x/types": "^3.3.4",
|
||||
"@0x/typescript-typings": "^5.2.1",
|
||||
|
@@ -47,6 +47,7 @@ export {
|
||||
MultiplexFeatureContract,
|
||||
PayTakerTransformerContract,
|
||||
PositiveSlippageFeeTransformerContract,
|
||||
TransformERC20FeatureContract,
|
||||
WethTransformerContract,
|
||||
ZeroExContract,
|
||||
} from './wrappers';
|
||||
|
@@ -84,7 +84,6 @@ import * as MetaTransactionsFeature from '../test/generated-artifacts/MetaTransa
|
||||
import * as MixinBalancer from '../test/generated-artifacts/MixinBalancer.json';
|
||||
import * as MixinBalancerV2 from '../test/generated-artifacts/MixinBalancerV2.json';
|
||||
import * as MixinBancor from '../test/generated-artifacts/MixinBancor.json';
|
||||
import * as MixinClipper from '../test/generated-artifacts/MixinClipper.json';
|
||||
import * as MixinCoFiX from '../test/generated-artifacts/MixinCoFiX.json';
|
||||
import * as MixinCryptoCom from '../test/generated-artifacts/MixinCryptoCom.json';
|
||||
import * as MixinCurve from '../test/generated-artifacts/MixinCurve.json';
|
||||
@@ -276,7 +275,6 @@ export const artifacts = {
|
||||
MixinBalancer: MixinBalancer as ContractArtifact,
|
||||
MixinBalancerV2: MixinBalancerV2 as ContractArtifact,
|
||||
MixinBancor: MixinBancor as ContractArtifact,
|
||||
MixinClipper: MixinClipper as ContractArtifact,
|
||||
MixinCoFiX: MixinCoFiX as ContractArtifact,
|
||||
MixinCryptoCom: MixinCryptoCom as ContractArtifact,
|
||||
MixinCurve: MixinCurve as ContractArtifact,
|
||||
|
@@ -82,7 +82,6 @@ export * from '../test/generated-wrappers/meta_transactions_feature';
|
||||
export * from '../test/generated-wrappers/mixin_balancer';
|
||||
export * from '../test/generated-wrappers/mixin_balancer_v2';
|
||||
export * from '../test/generated-wrappers/mixin_bancor';
|
||||
export * from '../test/generated-wrappers/mixin_clipper';
|
||||
export * from '../test/generated-wrappers/mixin_co_fi_x';
|
||||
export * from '../test/generated-wrappers/mixin_crypto_com';
|
||||
export * from '../test/generated-wrappers/mixin_curve';
|
||||
|
@@ -115,7 +115,6 @@
|
||||
"test/generated-artifacts/MixinBalancer.json",
|
||||
"test/generated-artifacts/MixinBalancerV2.json",
|
||||
"test/generated-artifacts/MixinBancor.json",
|
||||
"test/generated-artifacts/MixinClipper.json",
|
||||
"test/generated-artifacts/MixinCoFiX.json",
|
||||
"test/generated-artifacts/MixinCryptoCom.json",
|
||||
"test/generated-artifacts/MixinCurve.json",
|
||||
|
@@ -3,10 +3,14 @@ Protocol Fees
|
||||
###############################
|
||||
|
||||
An ETH protocol fee is paid by the Taker each time a `Limit Order <./orders.html#limit-orders>`_ is `filled <./functions.html>`_.
|
||||
The fee is proportional to the gas cost of filling an order and scales linearly with gas price. The cost is currently ``70k * tx.gasprice``.
|
||||
The fee is proportional to the gas cost of filling an order and scales linearly with gas price. The cost is currently ``0 * tx.gasprice``.
|
||||
At the end of every Staking Epoch, these fees are aggregated and distributed to the makers as a liquidity reward: the reward is proportional to the maker's collected fees and staked ZRX relative to other makers.
|
||||
To learn more about protocol fees and liquidity incentives, see the `Official Spec <https://github.com/0xProject/0x-protocol-specification/blob/master/staking/staking-specification.md>`_.
|
||||
|
||||
.. note::
|
||||
|
||||
As of September 29, 2021, protocol fees have been removed for all order types in both Exchange V4 and V3 in accordance with `ZEIP-91 <https://0x.org/zrx/vote/zeip-91>`_.
|
||||
|
||||
.. note::
|
||||
|
||||
`RFQ Orders <./orders.html#rfq-orders>`_ are introduced in Exchange V4, and there is currently no protocol fee for filling this type of order.
|
||||
|
@@ -1,2 +1,3 @@
|
||||
six
|
||||
sphinx-markdown-tables
|
||||
sphinx==3.5.4
|
||||
sphinx-markdown-tables
|
||||
|
@@ -1,4 +1,43 @@
|
||||
[
|
||||
{
|
||||
"version": "16.29.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Remove `Clipper` as a custom liquidity source",
|
||||
"pr": 335
|
||||
}
|
||||
],
|
||||
"timestamp": 1633374058
|
||||
},
|
||||
{
|
||||
"version": "16.29.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Initial integration of neon-router (behind feature flag)",
|
||||
"pr": 295
|
||||
}
|
||||
],
|
||||
"timestamp": 1633350101
|
||||
},
|
||||
{
|
||||
"version": "16.28.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update ExchangeProxySwapQuoteConsumer for Multiplex V2 and friends",
|
||||
"pr": 282
|
||||
}
|
||||
],
|
||||
"timestamp": 1632957537
|
||||
},
|
||||
{
|
||||
"version": "16.27.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Remove protocol fees by setting `PROTOCOL_FEE_MULTIPLIER` to 0",
|
||||
"pr": 333
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1631710679,
|
||||
"version": "16.27.4",
|
||||
|
@@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v16.29.1 - _October 4, 2021_
|
||||
|
||||
* Remove `Clipper` as a custom liquidity source (#335)
|
||||
|
||||
## v16.29.0 - _October 4, 2021_
|
||||
|
||||
* Initial integration of neon-router (behind feature flag) (#295)
|
||||
|
||||
## v16.28.0 - _September 29, 2021_
|
||||
|
||||
* Update ExchangeProxySwapQuoteConsumer for Multiplex V2 and friends (#282)
|
||||
|
||||
## v16.27.5 - _Invalid date_
|
||||
|
||||
* Remove protocol fees by setting `PROTOCOL_FEE_MULTIPLIER` to 0 (#333)
|
||||
|
||||
## v16.27.4 - _September 15, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/asset-swapper",
|
||||
"version": "16.27.4",
|
||||
"version": "16.29.1",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -61,12 +61,13 @@
|
||||
"@0x/assert": "^3.0.29",
|
||||
"@0x/base-contract": "^6.4.2",
|
||||
"@0x/contract-addresses": "^6.7.0",
|
||||
"@0x/contract-wrappers": "^13.17.7",
|
||||
"@0x/contract-wrappers": "^13.18.0",
|
||||
"@0x/contracts-erc20": "^3.3.20",
|
||||
"@0x/contracts-zero-ex": "^0.27.1",
|
||||
"@0x/contracts-zero-ex": "^0.29.1",
|
||||
"@0x/dev-utils": "^4.2.9",
|
||||
"@0x/json-schemas": "^6.3.0",
|
||||
"@0x/protocol-utils": "^1.9.0",
|
||||
"@0x/neon-router": "^0.1.3",
|
||||
"@0x/protocol-utils": "^1.9.2",
|
||||
"@0x/quote-server": "^6.0.6",
|
||||
"@0x/types": "^3.3.4",
|
||||
"@0x/typescript-typings": "^5.2.1",
|
||||
@@ -100,7 +101,7 @@
|
||||
"@0x/contracts-test-utils": "^5.4.11",
|
||||
"@0x/contracts-utils": "^4.8.1",
|
||||
"@0x/mesh-rpc-client": "^9.4.2",
|
||||
"@0x/migrations": "^8.1.6",
|
||||
"@0x/migrations": "^8.1.8",
|
||||
"@0x/sol-compiler": "^4.7.5",
|
||||
"@0x/subproviders": "^6.6.0",
|
||||
"@0x/ts-doc-gen": "^0.0.28",
|
||||
|
@@ -38,7 +38,7 @@ const DEFAULT_ORDER_PRUNER_OPTS: OrderPrunerOpts = {
|
||||
|
||||
// 6 seconds polling interval
|
||||
const PROTOCOL_FEE_UTILS_POLLING_INTERVAL_IN_MS = 6000;
|
||||
const PROTOCOL_FEE_MULTIPLIER = new BigNumber(70000);
|
||||
const PROTOCOL_FEE_MULTIPLIER = new BigNumber(0);
|
||||
|
||||
// default 50% buffer for selecting native orders to be aggregated with other sources
|
||||
const MARKET_UTILS_AMOUNT_BUFFER_PERCENTAGE = 0.5;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { ChainId, ContractAddresses } from '@0x/contract-addresses';
|
||||
import { IZeroExContract, WETH9Contract } from '@0x/contract-wrappers';
|
||||
import { MultiplexFeatureContract } from '@0x/contracts-zero-ex';
|
||||
import { IZeroExContract } from '@0x/contract-wrappers';
|
||||
import { TransformERC20FeatureContract } from '@0x/contracts-zero-ex';
|
||||
import {
|
||||
encodeAffiliateFeeTransformerData,
|
||||
encodeCurveLiquidityProviderData,
|
||||
@@ -51,6 +51,7 @@ import {
|
||||
import {
|
||||
multiplexPlpEncoder,
|
||||
multiplexRfqEncoder,
|
||||
MultiplexSubcall,
|
||||
multiplexTransformERC20Encoder,
|
||||
multiplexUniswapEncoder,
|
||||
} from './multiplex_encoders';
|
||||
@@ -82,7 +83,6 @@ const FAKE_PROVIDER: any = {
|
||||
return;
|
||||
},
|
||||
};
|
||||
const DUMMY_WETH_CONTRACT = new WETH9Contract(NULL_ADDRESS, FAKE_PROVIDER);
|
||||
|
||||
export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
public readonly chainId: ChainId;
|
||||
@@ -95,7 +95,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
};
|
||||
|
||||
private readonly _exchangeProxy: IZeroExContract;
|
||||
private readonly _multiplex: MultiplexFeatureContract;
|
||||
private readonly _transformERC20Feature: TransformERC20FeatureContract;
|
||||
|
||||
constructor(public readonly contractAddresses: ContractAddresses, options: Partial<SwapQuoteConsumerOpts> = {}) {
|
||||
const { chainId } = _.merge({}, constants.DEFAULT_SWAP_QUOTER_OPTS, options);
|
||||
@@ -103,7 +103,7 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
this.chainId = chainId;
|
||||
this.contractAddresses = contractAddresses;
|
||||
this._exchangeProxy = new IZeroExContract(contractAddresses.exchangeProxy, FAKE_PROVIDER);
|
||||
this._multiplex = new MultiplexFeatureContract(contractAddresses.exchangeProxy, FAKE_PROVIDER);
|
||||
this._transformERC20Feature = new TransformERC20FeatureContract(contractAddresses.exchangeProxy, FAKE_PROVIDER);
|
||||
this.transformerNonces = {
|
||||
wethTransformer: findTransformerNonce(
|
||||
contractAddresses.transformers.wethTransformer,
|
||||
@@ -338,7 +338,10 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
|
||||
if (this.chainId === ChainId.Mainnet && isMultiplexBatchFillCompatible(quote, optsWithDefaults)) {
|
||||
return {
|
||||
calldataHexString: this._encodeMultiplexBatchFillCalldata({ ...quote, orders: slippedOrders }),
|
||||
calldataHexString: this._encodeMultiplexBatchFillCalldata(
|
||||
{ ...quote, orders: slippedOrders },
|
||||
optsWithDefaults,
|
||||
),
|
||||
ethAmount,
|
||||
toAddress: this._exchangeProxy.address,
|
||||
allowanceTarget: this._exchangeProxy.address,
|
||||
@@ -473,17 +476,27 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
}
|
||||
}
|
||||
|
||||
// Return any unspent sell tokens.
|
||||
const payTakerTokens = [sellToken];
|
||||
// Return any unspent intermediate tokens for two-hop swaps.
|
||||
if (quote.isTwoHop) {
|
||||
payTakerTokens.push(intermediateToken);
|
||||
}
|
||||
// Return any unspent ETH. If ETH is the buy token, it will
|
||||
// be returned in TransformERC20Feature rather than PayTakerTransformer.
|
||||
if (!isToETH) {
|
||||
payTakerTokens.push(ETH_TOKEN_ADDRESS);
|
||||
}
|
||||
// The final transformer will send all funds to the taker.
|
||||
transforms.push({
|
||||
deploymentNonce: this.transformerNonces.payTakerTransformer,
|
||||
data: encodePayTakerTransformerData({
|
||||
tokens: [sellToken, buyToken, ETH_TOKEN_ADDRESS].concat(quote.isTwoHop ? intermediateToken : []),
|
||||
tokens: payTakerTokens,
|
||||
amounts: [],
|
||||
}),
|
||||
});
|
||||
|
||||
const calldataHexString = this._exchangeProxy
|
||||
.transformERC20(
|
||||
const calldataHexString = this._transformERC20Feature
|
||||
.transformERC20Staging(
|
||||
isFromETH ? ETH_TOKEN_ADDRESS : sellToken,
|
||||
isToETH ? ETH_TOKEN_ADDRESS : buyToken,
|
||||
shouldSellEntireBalance ? MAX_UINT256 : sellAmount,
|
||||
@@ -509,8 +522,8 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
throw new Error('Execution not supported for Exchange Proxy quotes');
|
||||
}
|
||||
|
||||
private _encodeMultiplexBatchFillCalldata(quote: SwapQuote): string {
|
||||
const wrappedBatchCalls = [];
|
||||
private _encodeMultiplexBatchFillCalldata(quote: SwapQuote, opts: ExchangeProxyContractOpts): string {
|
||||
const subcalls = [];
|
||||
for_loop: for (const [i, order] of quote.orders.entries()) {
|
||||
switch_statement: switch (order.source) {
|
||||
case ERC20BridgeSource.Native:
|
||||
@@ -519,8 +532,8 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
// before calling this function.
|
||||
throw new Error('Multiplex batch fill only supported for RFQ native orders');
|
||||
}
|
||||
wrappedBatchCalls.push({
|
||||
selector: this._exchangeProxy.getSelector('_fillRfqOrder'),
|
||||
subcalls.push({
|
||||
id: MultiplexSubcall.Rfq,
|
||||
sellAmount: order.takerAmount,
|
||||
data: multiplexRfqEncoder.encode({
|
||||
order: order.fillData.order,
|
||||
@@ -530,8 +543,8 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
break switch_statement;
|
||||
case ERC20BridgeSource.UniswapV2:
|
||||
case ERC20BridgeSource.SushiSwap:
|
||||
wrappedBatchCalls.push({
|
||||
selector: this._multiplex.getSelector('_sellToUniswap'),
|
||||
subcalls.push({
|
||||
id: MultiplexSubcall.UniswapV2,
|
||||
sellAmount: order.takerAmount,
|
||||
data: multiplexUniswapEncoder.encode({
|
||||
tokens: (order.fillData as UniswapV2FillData).tokenAddressPath,
|
||||
@@ -540,8 +553,8 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
});
|
||||
break switch_statement;
|
||||
case ERC20BridgeSource.LiquidityProvider:
|
||||
wrappedBatchCalls.push({
|
||||
selector: this._multiplex.getSelector('_sellToLiquidityProvider'),
|
||||
subcalls.push({
|
||||
id: MultiplexSubcall.LiquidityProvider,
|
||||
sellAmount: order.takerAmount,
|
||||
data: multiplexPlpEncoder.encode({
|
||||
provider: (order.fillData as LiquidityProviderFillData).poolAddress,
|
||||
@@ -551,8 +564,8 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
break switch_statement;
|
||||
case ERC20BridgeSource.UniswapV3:
|
||||
const fillData = (order as OptimizedMarketBridgeOrder<FinalUniswapV3FillData>).fillData;
|
||||
wrappedBatchCalls.push({
|
||||
selector: this._exchangeProxy.getSelector('sellTokenForTokenToUniswapV3'),
|
||||
subcalls.push({
|
||||
id: MultiplexSubcall.UniswapV3,
|
||||
sellAmount: order.takerAmount,
|
||||
data: fillData.uniswapPath,
|
||||
});
|
||||
@@ -571,54 +584,59 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
{
|
||||
deploymentNonce: this.transformerNonces.payTakerTransformer,
|
||||
data: encodePayTakerTransformerData({
|
||||
tokens: [quote.takerToken, quote.makerToken],
|
||||
tokens: [quote.takerToken],
|
||||
amounts: [],
|
||||
}),
|
||||
},
|
||||
];
|
||||
wrappedBatchCalls.push({
|
||||
selector: this._exchangeProxy.getSelector('_transformERC20'),
|
||||
subcalls.push({
|
||||
id: MultiplexSubcall.TransformERC20,
|
||||
sellAmount: BigNumber.sum(...quote.orders.slice(i).map(o => o.takerAmount)),
|
||||
data: multiplexTransformERC20Encoder.encode({
|
||||
transformations,
|
||||
ethValue: constants.ZERO_AMOUNT,
|
||||
}),
|
||||
});
|
||||
break for_loop;
|
||||
}
|
||||
}
|
||||
return this._exchangeProxy
|
||||
.batchFill(
|
||||
{
|
||||
inputToken: quote.takerToken,
|
||||
outputToken: quote.makerToken,
|
||||
sellAmount: quote.worstCaseQuoteInfo.totalTakerAmount,
|
||||
calls: wrappedBatchCalls,
|
||||
},
|
||||
quote.worstCaseQuoteInfo.makerAmount,
|
||||
)
|
||||
.getABIEncodedTransactionData();
|
||||
if (opts.isFromETH) {
|
||||
return this._exchangeProxy
|
||||
.multiplexBatchSellEthForToken(quote.makerToken, subcalls, quote.worstCaseQuoteInfo.makerAmount)
|
||||
.getABIEncodedTransactionData();
|
||||
} else if (opts.isToETH) {
|
||||
return this._exchangeProxy
|
||||
.multiplexBatchSellTokenForEth(
|
||||
quote.takerToken,
|
||||
subcalls,
|
||||
quote.worstCaseQuoteInfo.totalTakerAmount,
|
||||
quote.worstCaseQuoteInfo.makerAmount,
|
||||
)
|
||||
.getABIEncodedTransactionData();
|
||||
} else {
|
||||
return this._exchangeProxy
|
||||
.multiplexBatchSellTokenForToken(
|
||||
quote.takerToken,
|
||||
quote.makerToken,
|
||||
subcalls,
|
||||
quote.worstCaseQuoteInfo.totalTakerAmount,
|
||||
quote.worstCaseQuoteInfo.makerAmount,
|
||||
)
|
||||
.getABIEncodedTransactionData();
|
||||
}
|
||||
}
|
||||
|
||||
private _encodeMultiplexMultiHopFillCalldata(quote: SwapQuote, opts: ExchangeProxyContractOpts): string {
|
||||
const wrappedMultiHopCalls = [];
|
||||
const tokens: string[] = [];
|
||||
if (opts.isFromETH) {
|
||||
wrappedMultiHopCalls.push({
|
||||
selector: DUMMY_WETH_CONTRACT.getSelector('deposit'),
|
||||
data: NULL_BYTES,
|
||||
});
|
||||
tokens.push(ETH_TOKEN_ADDRESS);
|
||||
}
|
||||
const subcalls = [];
|
||||
const [firstHopOrder, secondHopOrder] = quote.orders;
|
||||
const intermediateToken = firstHopOrder.makerToken;
|
||||
tokens.push(quote.takerToken, intermediateToken, quote.makerToken);
|
||||
const tokens = [quote.takerToken, intermediateToken, quote.makerToken];
|
||||
|
||||
for (const order of [firstHopOrder, secondHopOrder]) {
|
||||
switch (order.source) {
|
||||
case ERC20BridgeSource.UniswapV2:
|
||||
case ERC20BridgeSource.SushiSwap:
|
||||
wrappedMultiHopCalls.push({
|
||||
selector: this._multiplex.getSelector('_sellToUniswap'),
|
||||
subcalls.push({
|
||||
id: MultiplexSubcall.UniswapV2,
|
||||
data: multiplexUniswapEncoder.encode({
|
||||
tokens: (order.fillData as UniswapV2FillData).tokenAddressPath,
|
||||
isSushi: order.source === ERC20BridgeSource.SushiSwap,
|
||||
@@ -626,39 +644,49 @@ export class ExchangeProxySwapQuoteConsumer implements SwapQuoteConsumerBase {
|
||||
});
|
||||
break;
|
||||
case ERC20BridgeSource.LiquidityProvider:
|
||||
wrappedMultiHopCalls.push({
|
||||
selector: this._multiplex.getSelector('_sellToLiquidityProvider'),
|
||||
subcalls.push({
|
||||
id: MultiplexSubcall.LiquidityProvider,
|
||||
data: multiplexPlpEncoder.encode({
|
||||
provider: (order.fillData as LiquidityProviderFillData).poolAddress,
|
||||
auxiliaryData: NULL_BYTES,
|
||||
}),
|
||||
});
|
||||
break;
|
||||
case ERC20BridgeSource.UniswapV3:
|
||||
subcalls.push({
|
||||
id: MultiplexSubcall.UniswapV3,
|
||||
data: (order.fillData as FinalUniswapV3FillData).uniswapPath,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
// Note: we'll need to redeploy TransformERC20Feature before we can
|
||||
// use other sources
|
||||
// Should never happen because we check `isMultiplexMultiHopFillCompatible`
|
||||
// before calling this function.
|
||||
throw new Error(`Multiplex multi-hop unsupported source: ${order.source}`);
|
||||
}
|
||||
}
|
||||
if (opts.isToETH) {
|
||||
wrappedMultiHopCalls.push({
|
||||
selector: DUMMY_WETH_CONTRACT.getSelector('withdraw'),
|
||||
data: NULL_BYTES,
|
||||
});
|
||||
tokens.push(ETH_TOKEN_ADDRESS);
|
||||
}
|
||||
return this._exchangeProxy
|
||||
.multiHopFill(
|
||||
{
|
||||
if (opts.isFromETH) {
|
||||
return this._exchangeProxy
|
||||
.multiplexMultiHopSellEthForToken(tokens, subcalls, quote.worstCaseQuoteInfo.makerAmount)
|
||||
.getABIEncodedTransactionData();
|
||||
} else if (opts.isToETH) {
|
||||
return this._exchangeProxy
|
||||
.multiplexMultiHopSellTokenForEth(
|
||||
tokens,
|
||||
sellAmount: quote.worstCaseQuoteInfo.totalTakerAmount,
|
||||
calls: wrappedMultiHopCalls,
|
||||
},
|
||||
quote.worstCaseQuoteInfo.makerAmount,
|
||||
)
|
||||
.getABIEncodedTransactionData();
|
||||
subcalls,
|
||||
quote.worstCaseQuoteInfo.totalTakerAmount,
|
||||
quote.worstCaseQuoteInfo.makerAmount,
|
||||
)
|
||||
.getABIEncodedTransactionData();
|
||||
} else {
|
||||
return this._exchangeProxy
|
||||
.multiplexMultiHopSellTokenForToken(
|
||||
tokens,
|
||||
subcalls,
|
||||
quote.worstCaseQuoteInfo.totalTakerAmount,
|
||||
quote.worstCaseQuoteInfo.makerAmount,
|
||||
)
|
||||
.getABIEncodedTransactionData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,17 @@
|
||||
import { RfqOrder, SIGNATURE_ABI } from '@0x/protocol-utils';
|
||||
import { AbiEncoder } from '@0x/utils';
|
||||
|
||||
export enum MultiplexSubcall {
|
||||
Invalid,
|
||||
Rfq,
|
||||
Otc,
|
||||
UniswapV2,
|
||||
UniswapV3,
|
||||
LiquidityProvider,
|
||||
TransformERC20,
|
||||
BatchSell,
|
||||
MultiHopSell,
|
||||
}
|
||||
export const multiplexTransformERC20Encoder = AbiEncoder.create([
|
||||
{
|
||||
name: 'transformations',
|
||||
@@ -10,7 +21,6 @@ export const multiplexTransformERC20Encoder = AbiEncoder.create([
|
||||
{ name: 'data', type: 'bytes' },
|
||||
],
|
||||
},
|
||||
{ name: 'ethValue', type: 'uint256' },
|
||||
]);
|
||||
export const multiplexRfqEncoder = AbiEncoder.create([
|
||||
{ name: 'order', type: 'tuple', components: RfqOrder.STRUCT_ABI },
|
||||
|
@@ -32,10 +32,6 @@ export function isMultiplexBatchFillCompatible(quote: SwapQuote, opts: ExchangeP
|
||||
if (quote.isTwoHop) {
|
||||
return false;
|
||||
}
|
||||
// batchFill does not support WETH wrapping/unwrapping at the moment
|
||||
if (opts.isFromETH || opts.isToETH) {
|
||||
return false;
|
||||
}
|
||||
if (quote.orders.map(o => o.type).includes(FillQuoteTransformerOrderType.Limit)) {
|
||||
return false;
|
||||
}
|
||||
@@ -49,6 +45,7 @@ const MULTIPLEX_MULTIHOP_FILL_SOURCES = [
|
||||
ERC20BridgeSource.UniswapV2,
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
ERC20BridgeSource.LiquidityProvider,
|
||||
ERC20BridgeSource.UniswapV3,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@@ -363,6 +363,7 @@ export class SwapQuoter {
|
||||
const cloneOpts = _.omit(opts, 'gasPrice') as GetMarketOrdersOpts;
|
||||
const calcOpts: GetMarketOrdersOpts = {
|
||||
...cloneOpts,
|
||||
gasPrice,
|
||||
feeSchedule: _.mapValues(opts.feeSchedule, gasCost => (fillData: FillData) =>
|
||||
gasCost === undefined ? 0 : gasPrice.times(gasCost(fillData)),
|
||||
),
|
||||
|
@@ -256,7 +256,7 @@ export interface RfqRequestOpts {
|
||||
/**
|
||||
* gasPrice: gas price to determine protocolFee amount, default to ethGasStation fast amount
|
||||
*/
|
||||
export interface SwapQuoteRequestOpts extends GetMarketOrdersOpts {
|
||||
export interface SwapQuoteRequestOpts extends Omit<GetMarketOrdersOpts, 'gasPrice'> {
|
||||
gasPrice?: BigNumber;
|
||||
rfqt?: RfqRequestOpts;
|
||||
}
|
||||
|
@@ -99,7 +99,6 @@ export const SELL_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.UniswapV3,
|
||||
ERC20BridgeSource.CurveV2,
|
||||
ERC20BridgeSource.ShibaSwap,
|
||||
ERC20BridgeSource.Clipper,
|
||||
]),
|
||||
[ChainId.Ropsten]: new SourceFilters([
|
||||
ERC20BridgeSource.Kyber,
|
||||
@@ -206,7 +205,6 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
ERC20BridgeSource.UniswapV3,
|
||||
ERC20BridgeSource.CurveV2,
|
||||
ERC20BridgeSource.ShibaSwap,
|
||||
ERC20BridgeSource.Clipper,
|
||||
]),
|
||||
[ChainId.Ropsten]: new SourceFilters([
|
||||
ERC20BridgeSource.Kyber,
|
||||
@@ -278,7 +276,7 @@ export const BUY_SOURCE_FILTER_BY_CHAIN_ID = valueByChainId<SourceFilters>(
|
||||
/**
|
||||
* 0x Protocol Fee Multiplier
|
||||
*/
|
||||
export const PROTOCOL_FEE_MULTIPLIER = new BigNumber(70000);
|
||||
export const PROTOCOL_FEE_MULTIPLIER = new BigNumber(0);
|
||||
|
||||
/**
|
||||
* Sources to poll for ETH fee price estimates.
|
||||
@@ -1482,22 +1480,6 @@ export const LIDO_INFO_BY_CHAIN = valueByChainId<LidoInfo>(
|
||||
},
|
||||
);
|
||||
|
||||
export const CLIPPER_INFO_BY_CHAIN = valueByChainId(
|
||||
{
|
||||
[ChainId.Mainnet]: {
|
||||
poolAddress: '0xe82906b6b1b04f631d126c974af57a3a7b6a99d9',
|
||||
tokens: [
|
||||
MAINNET_TOKENS.WETH, // technically ETH but our sampler and mixin handle this
|
||||
MAINNET_TOKENS.WBTC,
|
||||
MAINNET_TOKENS.USDC,
|
||||
MAINNET_TOKENS.USDT,
|
||||
MAINNET_TOKENS.DAI,
|
||||
],
|
||||
},
|
||||
},
|
||||
{ poolAddress: NULL_ADDRESS, tokens: [] },
|
||||
);
|
||||
|
||||
export const BALANCER_SUBGRAPH_URL = 'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer';
|
||||
export const BALANCER_TOP_POOLS_FETCHED = 250;
|
||||
export const BALANCER_MAX_POOLS_FETCHED = 3;
|
||||
@@ -1637,6 +1619,23 @@ export const TRADER_JOE_ROUTER_BY_CHAIN_ID = valueByChainId<string>(
|
||||
NULL_ADDRESS,
|
||||
);
|
||||
|
||||
export const VIP_ERC20_BRIDGE_SOURCES_BY_CHAIN_ID = valueByChainId<ERC20BridgeSource[]>(
|
||||
{
|
||||
[ChainId.Mainnet]: [ERC20BridgeSource.UniswapV2, ERC20BridgeSource.SushiSwap, ERC20BridgeSource.UniswapV3],
|
||||
[ChainId.BSC]: [
|
||||
ERC20BridgeSource.PancakeSwap,
|
||||
ERC20BridgeSource.PancakeSwapV2,
|
||||
ERC20BridgeSource.BakerySwap,
|
||||
ERC20BridgeSource.SushiSwap,
|
||||
ERC20BridgeSource.ApeSwap,
|
||||
ERC20BridgeSource.CafeSwap,
|
||||
ERC20BridgeSource.CheeseSwap,
|
||||
ERC20BridgeSource.JulSwap,
|
||||
],
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const uniswapV2CloneGasSchedule = (fillData?: FillData) => {
|
||||
// TODO: Different base cost if to/from ETH.
|
||||
let gas = 90e3;
|
||||
@@ -1742,7 +1741,6 @@ export const DEFAULT_GAS_SCHEDULE: Required<FeeSchedule> = {
|
||||
return gas;
|
||||
},
|
||||
[ERC20BridgeSource.Lido]: () => 226e3,
|
||||
[ERC20BridgeSource.Clipper]: () => 170e3,
|
||||
|
||||
//
|
||||
// BSC
|
||||
@@ -1779,7 +1777,7 @@ export const POSITIVE_SLIPPAGE_FEE_TRANSFORMER_GAS = new BigNumber(20000);
|
||||
|
||||
// tslint:enable:custom-no-magic-numbers
|
||||
|
||||
export const DEFAULT_GET_MARKET_ORDERS_OPTS: GetMarketOrdersOpts = {
|
||||
export const DEFAULT_GET_MARKET_ORDERS_OPTS: Omit<GetMarketOrdersOpts, 'gasPrice'> = {
|
||||
// tslint:disable-next-line: custom-no-magic-numbers
|
||||
runLimit: 2 ** 15,
|
||||
excludedSources: [],
|
||||
|
@@ -71,7 +71,25 @@ function hasLiquidity(fills: Fill[]): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
function nativeOrdersToFills(
|
||||
export function ethToOutputAmount({
|
||||
input,
|
||||
output,
|
||||
ethAmount,
|
||||
inputAmountPerEth,
|
||||
outputAmountPerEth,
|
||||
}: {
|
||||
input: BigNumber;
|
||||
output: BigNumber;
|
||||
inputAmountPerEth: BigNumber;
|
||||
outputAmountPerEth: BigNumber;
|
||||
ethAmount: BigNumber | number;
|
||||
}): BigNumber {
|
||||
return !outputAmountPerEth.isZero()
|
||||
? outputAmountPerEth.times(ethAmount)
|
||||
: inputAmountPerEth.times(ethAmount).times(output.dividedToIntegerBy(input));
|
||||
}
|
||||
|
||||
export function nativeOrdersToFills(
|
||||
side: MarketOperation,
|
||||
orders: NativeOrderWithFillableAmounts[],
|
||||
targetInput: BigNumber = POSITIVE_INF,
|
||||
@@ -89,9 +107,13 @@ function nativeOrdersToFills(
|
||||
const input = side === MarketOperation.Sell ? takerAmount : makerAmount;
|
||||
const output = side === MarketOperation.Sell ? makerAmount : takerAmount;
|
||||
const fee = fees[ERC20BridgeSource.Native] === undefined ? 0 : fees[ERC20BridgeSource.Native]!(o);
|
||||
const outputPenalty = !outputAmountPerEth.isZero()
|
||||
? outputAmountPerEth.times(fee)
|
||||
: inputAmountPerEth.times(fee).times(output.dividedToIntegerBy(input));
|
||||
const outputPenalty = ethToOutputAmount({
|
||||
input,
|
||||
output,
|
||||
inputAmountPerEth,
|
||||
outputAmountPerEth,
|
||||
ethAmount: fee,
|
||||
});
|
||||
// targetInput can be less than the order size
|
||||
// whilst the penalty is constant, it affects the adjusted output
|
||||
// only up until the target has been exhausted.
|
||||
@@ -132,7 +154,7 @@ function nativeOrdersToFills(
|
||||
return fills;
|
||||
}
|
||||
|
||||
function dexSamplesToFills(
|
||||
export function dexSamplesToFills(
|
||||
side: MarketOperation,
|
||||
samples: DexSample[],
|
||||
outputAmountPerEth: BigNumber,
|
||||
@@ -156,9 +178,13 @@ function dexSamplesToFills(
|
||||
let penalty = ZERO_AMOUNT;
|
||||
if (i === 0) {
|
||||
// Only the first fill in a DEX path incurs a penalty.
|
||||
penalty = !outputAmountPerEth.isZero()
|
||||
? outputAmountPerEth.times(fee)
|
||||
: inputAmountPerEth.times(fee).times(output.dividedToIntegerBy(input));
|
||||
penalty = ethToOutputAmount({
|
||||
input,
|
||||
output,
|
||||
inputAmountPerEth,
|
||||
outputAmountPerEth,
|
||||
ethAmount: fee,
|
||||
});
|
||||
}
|
||||
const adjustedOutput = side === MarketOperation.Sell ? output.minus(penalty) : output.plus(penalty);
|
||||
|
||||
|
@@ -39,7 +39,7 @@ import { createFills } from './fills';
|
||||
import { getBestTwoHopQuote } from './multihop_utils';
|
||||
import { createOrdersFromTwoHopSample } from './orders';
|
||||
import { Path, PathPenaltyOpts } from './path';
|
||||
import { fillsToSortedPaths, findOptimalPathAsync } from './path_optimizer';
|
||||
import { fillsToSortedPaths, findOptimalPathJSAsync, findOptimalRustPathFromSamples } from './path_optimizer';
|
||||
import { DexOrderSampler, getSampleAmounts } from './sampler';
|
||||
import { SourceFilters } from './source_filters';
|
||||
import {
|
||||
@@ -48,7 +48,6 @@ import {
|
||||
DexSample,
|
||||
ERC20BridgeSource,
|
||||
Fill,
|
||||
FillData,
|
||||
GenerateOptimizedOrdersOpts,
|
||||
GetMarketOrdersOpts,
|
||||
MarketSideLiquidity,
|
||||
@@ -57,6 +56,8 @@ import {
|
||||
OrderDomain,
|
||||
} from './types';
|
||||
|
||||
const SHOULD_USE_RUST_ROUTER = process.env.RUST_ROUTER === 'true';
|
||||
|
||||
// tslint:disable:boolean-naming
|
||||
|
||||
export class MarketOperationUtils {
|
||||
@@ -326,12 +327,12 @@ export class MarketOperationUtils {
|
||||
public async getBatchMarketBuyOrdersAsync(
|
||||
batchNativeOrders: SignedNativeOrder[][],
|
||||
makerAmounts: BigNumber[],
|
||||
opts?: Partial<GetMarketOrdersOpts>,
|
||||
opts: Partial<GetMarketOrdersOpts> & { gasPrice: BigNumber },
|
||||
): Promise<Array<OptimizerResult | undefined>> {
|
||||
if (batchNativeOrders.length === 0) {
|
||||
throw new Error(AggregationError.EmptyOrders);
|
||||
}
|
||||
const _opts = { ...DEFAULT_GET_MARKET_ORDERS_OPTS, ...opts };
|
||||
const _opts: GetMarketOrdersOpts = { ...DEFAULT_GET_MARKET_ORDERS_OPTS, ...opts };
|
||||
|
||||
const requestFilters = new SourceFilters().exclude(_opts.excludedSources).include(_opts.includedSources);
|
||||
const quoteSourceFilters = this._buySources.merge(requestFilters);
|
||||
@@ -409,6 +410,7 @@ export class MarketOperationUtils {
|
||||
excludedSources: _opts.excludedSources,
|
||||
feeSchedule: _opts.feeSchedule,
|
||||
allowFallback: _opts.allowFallback,
|
||||
gasPrice: _opts.gasPrice,
|
||||
},
|
||||
);
|
||||
return optimizerResult;
|
||||
@@ -475,6 +477,7 @@ export class MarketOperationUtils {
|
||||
outputAmountPerEth,
|
||||
inputAmountPerEth,
|
||||
exchangeProxyOverhead: opts.exchangeProxyOverhead || (() => ZERO_AMOUNT),
|
||||
gasPrice: opts.gasPrice,
|
||||
};
|
||||
|
||||
// NOTE: For sell quotes input is the taker asset and for buy quotes input is the maker asset
|
||||
@@ -485,8 +488,22 @@ export class MarketOperationUtils {
|
||||
const _unoptimizedPath = fillsToSortedPaths(fills, side, inputAmount, penaltyOpts)[0];
|
||||
const unoptimizedPath = _unoptimizedPath ? _unoptimizedPath.collapse(orderOpts) : undefined;
|
||||
|
||||
// Find the optimal path
|
||||
const optimalPath = await findOptimalPathAsync(side, fills, inputAmount, opts.runLimit, penaltyOpts);
|
||||
// Find the optimal path using Rust router if enabled, otherwise fallback to JS Router
|
||||
let optimalPath: Path | undefined;
|
||||
if (SHOULD_USE_RUST_ROUTER) {
|
||||
optimalPath = findOptimalRustPathFromSamples(
|
||||
side,
|
||||
dexQuotes,
|
||||
[...nativeOrders, ...augmentedRfqtIndicativeQuotes],
|
||||
inputAmount,
|
||||
penaltyOpts,
|
||||
opts.feeSchedule,
|
||||
this._sampler.chainId,
|
||||
);
|
||||
} else {
|
||||
optimalPath = await findOptimalPathJSAsync(side, fills, inputAmount, opts.runLimit, penaltyOpts);
|
||||
}
|
||||
|
||||
const optimalPathRate = optimalPath ? optimalPath.adjustedRate() : ZERO_AMOUNT;
|
||||
|
||||
const { adjustedRate: bestTwoHopRate, quote: bestTwoHopQuote } = getBestTwoHopQuote(
|
||||
@@ -514,7 +531,7 @@ export class MarketOperationUtils {
|
||||
}
|
||||
|
||||
// Generate a fallback path if required
|
||||
await this._addOptionalFallbackAsync(side, inputAmount, optimalPath, fills, opts, penaltyOpts);
|
||||
await this._addOptionalFallbackAsync(side, inputAmount, optimalPath, dexQuotes, fills, opts, penaltyOpts);
|
||||
const collapsedPath = optimalPath.collapse(orderOpts);
|
||||
|
||||
return {
|
||||
@@ -536,9 +553,9 @@ export class MarketOperationUtils {
|
||||
nativeOrders: SignedNativeOrder[],
|
||||
amount: BigNumber,
|
||||
side: MarketOperation,
|
||||
opts?: Partial<GetMarketOrdersOpts>,
|
||||
opts: Partial<GetMarketOrdersOpts> & { gasPrice: BigNumber },
|
||||
): Promise<OptimizerResultWithReport> {
|
||||
const _opts = { ...DEFAULT_GET_MARKET_ORDERS_OPTS, ...opts };
|
||||
const _opts: GetMarketOrdersOpts = { ...DEFAULT_GET_MARKET_ORDERS_OPTS, ...opts };
|
||||
const optimizerOpts: GenerateOptimizedOrdersOpts = {
|
||||
bridgeSlippage: _opts.bridgeSlippage,
|
||||
maxFallbackSlippage: _opts.maxFallbackSlippage,
|
||||
@@ -546,6 +563,7 @@ export class MarketOperationUtils {
|
||||
feeSchedule: _opts.feeSchedule,
|
||||
allowFallback: _opts.allowFallback,
|
||||
exchangeProxyOverhead: _opts.exchangeProxyOverhead,
|
||||
gasPrice: _opts.gasPrice,
|
||||
};
|
||||
|
||||
if (nativeOrders.length === 0) {
|
||||
@@ -711,7 +729,8 @@ export class MarketOperationUtils {
|
||||
side: MarketOperation,
|
||||
inputAmount: BigNumber,
|
||||
optimalPath: Path,
|
||||
fills: Array<Array<Fill<FillData>>>,
|
||||
dexQuotes: DexSample[][],
|
||||
fills: Fill[][],
|
||||
opts: GenerateOptimizedOrdersOpts,
|
||||
penaltyOpts: PathPenaltyOpts,
|
||||
): Promise<void> {
|
||||
@@ -725,13 +744,37 @@ export class MarketOperationUtils {
|
||||
if (opts.allowFallback && fragileFills.length !== 0) {
|
||||
// We create a fallback path that is exclusive of Native liquidity
|
||||
// This is the optimal on-chain path for the entire input amount
|
||||
const sturdyFills = fills.filter(p => p.length > 0 && !fragileSources.includes(p[0].source));
|
||||
const sturdyOptimalPath = await findOptimalPathAsync(side, sturdyFills, inputAmount, opts.runLimit, {
|
||||
const sturdyPenaltyOpts = {
|
||||
...penaltyOpts,
|
||||
exchangeProxyOverhead: (sourceFlags: bigint) =>
|
||||
// tslint:disable-next-line: no-bitwise
|
||||
penaltyOpts.exchangeProxyOverhead(sourceFlags | optimalPath.sourceFlags),
|
||||
});
|
||||
};
|
||||
|
||||
let sturdyOptimalPath: Path | undefined;
|
||||
if (SHOULD_USE_RUST_ROUTER) {
|
||||
const sturdySamples = dexQuotes.filter(
|
||||
samples => samples.length > 0 && !fragileSources.includes(samples[0].source),
|
||||
);
|
||||
sturdyOptimalPath = findOptimalRustPathFromSamples(
|
||||
side,
|
||||
sturdySamples,
|
||||
[],
|
||||
inputAmount,
|
||||
sturdyPenaltyOpts,
|
||||
opts.feeSchedule,
|
||||
this._sampler.chainId,
|
||||
);
|
||||
} else {
|
||||
const sturdyFills = fills.filter(p => p.length > 0 && !fragileSources.includes(p[0].source));
|
||||
sturdyOptimalPath = await findOptimalPathJSAsync(
|
||||
side,
|
||||
sturdyFills,
|
||||
inputAmount,
|
||||
opts.runLimit,
|
||||
sturdyPenaltyOpts,
|
||||
);
|
||||
}
|
||||
// Calculate the slippage of on-chain sources compared to the most optimal path
|
||||
// if within an acceptable threshold we enable a fallback to prevent reverts
|
||||
if (
|
||||
|
@@ -3,7 +3,7 @@ import { AbiEncoder, BigNumber } from '@0x/utils';
|
||||
|
||||
import { AssetSwapperContractAddresses, MarketOperation } from '../../types';
|
||||
|
||||
import { MAX_UINT256, NULL_BYTES, ZERO_AMOUNT } from './constants';
|
||||
import { MAX_UINT256, ZERO_AMOUNT } from './constants';
|
||||
import {
|
||||
AggregationError,
|
||||
BalancerFillData,
|
||||
@@ -180,8 +180,6 @@ export function getErc20BridgeSourceToBridgeSource(source: ERC20BridgeSource): s
|
||||
return encodeBridgeSourceId(BridgeProtocol.Nerve, 'IronSwap');
|
||||
case ERC20BridgeSource.ACryptos:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Curve, 'ACryptoS');
|
||||
case ERC20BridgeSource.Clipper:
|
||||
return encodeBridgeSourceId(BridgeProtocol.Clipper, 'Clipper');
|
||||
case ERC20BridgeSource.Pangolin:
|
||||
return encodeBridgeSourceId(BridgeProtocol.UniswapV2, 'Pangolin');
|
||||
case ERC20BridgeSource.TraderJoe:
|
||||
@@ -326,10 +324,6 @@ export function createBridgeDataForBridgeOrder(order: OptimizedMarketBridgeOrder
|
||||
const lidoFillData = (order as OptimizedMarketBridgeOrder<LidoFillData>).fillData;
|
||||
bridgeData = encoder.encode([lidoFillData.stEthTokenAddress]);
|
||||
break;
|
||||
case ERC20BridgeSource.Clipper:
|
||||
const clipperFillData = (order as OptimizedMarketBridgeOrder<LiquidityProviderFillData>).fillData;
|
||||
bridgeData = encoder.encode([clipperFillData.poolAddress, NULL_BYTES]);
|
||||
break;
|
||||
default:
|
||||
throw new Error(AggregationError.NoBridgeForSource);
|
||||
}
|
||||
@@ -489,10 +483,6 @@ export const BRIDGE_ENCODERS: {
|
||||
]),
|
||||
[ERC20BridgeSource.KyberDmm]: AbiEncoder.create('(address,address[],address[])'),
|
||||
[ERC20BridgeSource.Lido]: AbiEncoder.create('(address)'),
|
||||
[ERC20BridgeSource.Clipper]: AbiEncoder.create([
|
||||
{ name: 'provider', type: 'address' },
|
||||
{ name: 'data', type: 'bytes' },
|
||||
]),
|
||||
};
|
||||
|
||||
function getFillTokenAmounts(fill: CollapsedFill, side: MarketOperation): [BigNumber, BigNumber] {
|
||||
|
@@ -3,6 +3,7 @@ import { BigNumber } from '@0x/utils';
|
||||
import { MarketOperation } from '../../types';
|
||||
|
||||
import { POSITIVE_INF, ZERO_AMOUNT } from './constants';
|
||||
import { ethToOutputAmount } from './fills';
|
||||
import { createBridgeOrder, createNativeOptimizedOrder, CreateOrderFromPathOpts, getMakerTakerTokens } from './orders';
|
||||
import { getCompleteRate, getRate } from './rate_utils';
|
||||
import {
|
||||
@@ -25,12 +26,14 @@ export interface PathPenaltyOpts {
|
||||
outputAmountPerEth: BigNumber;
|
||||
inputAmountPerEth: BigNumber;
|
||||
exchangeProxyOverhead: ExchangeProxyOverhead;
|
||||
gasPrice: BigNumber;
|
||||
}
|
||||
|
||||
export const DEFAULT_PATH_PENALTY_OPTS: PathPenaltyOpts = {
|
||||
outputAmountPerEth: ZERO_AMOUNT,
|
||||
inputAmountPerEth: ZERO_AMOUNT,
|
||||
exchangeProxyOverhead: () => ZERO_AMOUNT,
|
||||
gasPrice: ZERO_AMOUNT,
|
||||
};
|
||||
|
||||
export class Path {
|
||||
@@ -143,9 +146,13 @@ export class Path {
|
||||
const { input, output } = this._adjustedSize;
|
||||
const { exchangeProxyOverhead, outputAmountPerEth, inputAmountPerEth } = this.pathPenaltyOpts;
|
||||
const gasOverhead = exchangeProxyOverhead(this.sourceFlags);
|
||||
const pathPenalty = !outputAmountPerEth.isZero()
|
||||
? outputAmountPerEth.times(gasOverhead)
|
||||
: inputAmountPerEth.times(gasOverhead).times(output.dividedToIntegerBy(input));
|
||||
const pathPenalty = ethToOutputAmount({
|
||||
input,
|
||||
output,
|
||||
inputAmountPerEth,
|
||||
outputAmountPerEth,
|
||||
ethAmount: gasOverhead,
|
||||
});
|
||||
return {
|
||||
input,
|
||||
output: this.side === MarketOperation.Sell ? output.minus(pathPenalty) : output.plus(pathPenalty),
|
||||
|
@@ -1,20 +1,377 @@
|
||||
import { assert } from '@0x/assert';
|
||||
import { ChainId } from '@0x/contract-addresses';
|
||||
import { OptimizerCapture, route, SerializedPath } from '@0x/neon-router';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
import { performance } from 'perf_hooks';
|
||||
|
||||
import { MarketOperation } from '../../types';
|
||||
import { DEFAULT_INFO_LOGGER } from '../../constants';
|
||||
import { MarketOperation, NativeOrderWithFillableAmounts } from '../../types';
|
||||
import { VIP_ERC20_BRIDGE_SOURCES_BY_CHAIN_ID } from '../market_operation_utils/constants';
|
||||
|
||||
import { dexSamplesToFills, ethToOutputAmount, nativeOrdersToFills } from './fills';
|
||||
import { DEFAULT_PATH_PENALTY_OPTS, Path, PathPenaltyOpts } from './path';
|
||||
import { ERC20BridgeSource, Fill } from './types';
|
||||
import { getRate } from './rate_utils';
|
||||
import { DexSample, ERC20BridgeSource, FeeSchedule, Fill, FillData } from './types';
|
||||
|
||||
// tslint:disable: prefer-for-of custom-no-magic-numbers completed-docs no-bitwise
|
||||
|
||||
const RUN_LIMIT_DECAY_FACTOR = 0.5;
|
||||
const RUST_ROUTER_NUM_SAMPLES = 200;
|
||||
const FILL_QUOTE_TRANSFORMER_GAS_OVERHEAD = new BigNumber(150e3);
|
||||
// NOTE: The Rust router will panic with less than 3 samples
|
||||
const MIN_NUM_SAMPLE_INPUTS = 3;
|
||||
|
||||
const isDexSample = (obj: DexSample | NativeOrderWithFillableAmounts): obj is DexSample => !!(obj as DexSample).source;
|
||||
|
||||
function nativeOrderToNormalizedAmounts(
|
||||
side: MarketOperation,
|
||||
nativeOrder: NativeOrderWithFillableAmounts,
|
||||
): { input: BigNumber; output: BigNumber } {
|
||||
const { fillableTakerAmount, fillableTakerFeeAmount, fillableMakerAmount } = nativeOrder;
|
||||
const makerAmount = fillableMakerAmount;
|
||||
const takerAmount = fillableTakerAmount.plus(fillableTakerFeeAmount);
|
||||
const input = side === MarketOperation.Sell ? takerAmount : makerAmount;
|
||||
const output = side === MarketOperation.Sell ? makerAmount : takerAmount;
|
||||
|
||||
return { input, output };
|
||||
}
|
||||
|
||||
function calculateOuputFee(
|
||||
side: MarketOperation,
|
||||
sampleOrNativeOrder: DexSample | NativeOrderWithFillableAmounts,
|
||||
outputAmountPerEth: BigNumber,
|
||||
inputAmountPerEth: BigNumber,
|
||||
fees: FeeSchedule,
|
||||
): BigNumber {
|
||||
if (isDexSample(sampleOrNativeOrder)) {
|
||||
const { input, output, source, fillData } = sampleOrNativeOrder;
|
||||
const fee = fees[source]?.(fillData) || 0;
|
||||
const outputFee = ethToOutputAmount({
|
||||
input,
|
||||
output,
|
||||
inputAmountPerEth,
|
||||
outputAmountPerEth,
|
||||
ethAmount: fee,
|
||||
});
|
||||
return outputFee;
|
||||
} else {
|
||||
const { input, output } = nativeOrderToNormalizedAmounts(side, sampleOrNativeOrder);
|
||||
const fee = fees[ERC20BridgeSource.Native]?.(sampleOrNativeOrder) || 0;
|
||||
const outputFee = ethToOutputAmount({
|
||||
input,
|
||||
output,
|
||||
inputAmountPerEth,
|
||||
outputAmountPerEth,
|
||||
ethAmount: fee,
|
||||
});
|
||||
return outputFee;
|
||||
}
|
||||
}
|
||||
|
||||
// Use linear interpolation to approximate the output
|
||||
// at a certain input somewhere between the two samples
|
||||
// See https://en.wikipedia.org/wiki/Linear_interpolation
|
||||
const interpolateOutputFromSamples = (
|
||||
left: { input: BigNumber; output: BigNumber },
|
||||
right: { input: BigNumber; output: BigNumber },
|
||||
targetInput: BigNumber,
|
||||
): BigNumber =>
|
||||
left.output.plus(
|
||||
right.output
|
||||
.minus(left.output)
|
||||
.dividedBy(right.input.minus(left.input))
|
||||
.times(targetInput.minus(left.input)),
|
||||
);
|
||||
|
||||
function findRoutesAndCreateOptimalPath(
|
||||
side: MarketOperation,
|
||||
samples: DexSample[][],
|
||||
nativeOrders: NativeOrderWithFillableAmounts[],
|
||||
input: BigNumber,
|
||||
opts: PathPenaltyOpts,
|
||||
fees: FeeSchedule,
|
||||
): Path | undefined {
|
||||
const createFill = (sample: DexSample) =>
|
||||
dexSamplesToFills(side, [sample], opts.outputAmountPerEth, opts.inputAmountPerEth, fees)[0];
|
||||
// Track sample id's to integers (required by rust router)
|
||||
const sampleIdLookup: { [key: string]: number } = {};
|
||||
let sampleIdCounter = 0;
|
||||
const sampleToId = (source: ERC20BridgeSource, index: number): number => {
|
||||
const key = `${source}-${index}`;
|
||||
if (sampleIdLookup[key]) {
|
||||
return sampleIdLookup[key];
|
||||
} else {
|
||||
sampleIdLookup[key] = ++sampleIdCounter;
|
||||
return sampleIdLookup[key];
|
||||
}
|
||||
};
|
||||
|
||||
const samplesAndNativeOrdersWithResults: Array<DexSample[] | NativeOrderWithFillableAmounts[]> = [];
|
||||
const serializedPaths: SerializedPath[] = [];
|
||||
for (const singleSourceSamples of samples) {
|
||||
if (singleSourceSamples.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const singleSourceSamplesWithOutput = [...singleSourceSamples];
|
||||
for (let i = singleSourceSamples.length - 1; i >= 0; i--) {
|
||||
if (singleSourceSamples[i].output.isZero()) {
|
||||
// Remove trailing 0 output samples
|
||||
singleSourceSamplesWithOutput.pop();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (singleSourceSamplesWithOutput.length < MIN_NUM_SAMPLE_INPUTS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO(kimpers): Do we need to handle 0 entries, from eg Kyber?
|
||||
const serializedPath = singleSourceSamplesWithOutput.reduce<SerializedPath>(
|
||||
(memo, sample, sampleIdx) => {
|
||||
memo.ids.push(sampleToId(sample.source, sampleIdx));
|
||||
memo.inputs.push(sample.input.integerValue().toNumber());
|
||||
memo.outputs.push(sample.output.integerValue().toNumber());
|
||||
memo.outputFees.push(
|
||||
calculateOuputFee(side, sample, opts.outputAmountPerEth, opts.inputAmountPerEth, fees)
|
||||
.integerValue()
|
||||
.toNumber(),
|
||||
);
|
||||
|
||||
return memo;
|
||||
},
|
||||
{
|
||||
ids: [],
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
outputFees: [],
|
||||
},
|
||||
);
|
||||
|
||||
samplesAndNativeOrdersWithResults.push(singleSourceSamplesWithOutput);
|
||||
serializedPaths.push(serializedPath);
|
||||
}
|
||||
|
||||
for (const [idx, nativeOrder] of nativeOrders.entries()) {
|
||||
const { input: normalizedOrderInput, output: normalizedOrderOutput } = nativeOrderToNormalizedAmounts(
|
||||
side,
|
||||
nativeOrder,
|
||||
);
|
||||
// NOTE: skip dummy order created in swap_quoter
|
||||
// TODO: remove dummy order and this logic once we don't need the JS router
|
||||
if (normalizedOrderInput.isLessThanOrEqualTo(0) || normalizedOrderOutput.isLessThanOrEqualTo(0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// HACK: the router requires at minimum 3 samples as a basis for interpolation
|
||||
const inputs = [
|
||||
0,
|
||||
normalizedOrderInput
|
||||
.dividedBy(2)
|
||||
.integerValue()
|
||||
.toNumber(),
|
||||
normalizedOrderInput.integerValue().toNumber(),
|
||||
];
|
||||
const outputs = [
|
||||
0,
|
||||
normalizedOrderOutput
|
||||
.dividedBy(2)
|
||||
.integerValue()
|
||||
.toNumber(),
|
||||
normalizedOrderOutput.integerValue().toNumber(),
|
||||
];
|
||||
// NOTE: same fee no matter if full or partial fill
|
||||
const fee = calculateOuputFee(side, nativeOrder, opts.outputAmountPerEth, opts.inputAmountPerEth, fees)
|
||||
.integerValue()
|
||||
.toNumber();
|
||||
const outputFees = [fee, fee, fee];
|
||||
// NOTE: ids can be the same for all fake samples
|
||||
const id = sampleToId(ERC20BridgeSource.Native, idx);
|
||||
const ids = [id, id, id];
|
||||
|
||||
const serializedPath: SerializedPath = {
|
||||
ids,
|
||||
inputs,
|
||||
outputs,
|
||||
outputFees,
|
||||
};
|
||||
|
||||
samplesAndNativeOrdersWithResults.push([nativeOrder]);
|
||||
serializedPaths.push(serializedPath);
|
||||
}
|
||||
|
||||
if (serializedPaths.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const rustArgs: OptimizerCapture = {
|
||||
side,
|
||||
targetInput: input.toNumber(),
|
||||
pathsIn: serializedPaths,
|
||||
};
|
||||
|
||||
const before = performance.now();
|
||||
const allSourcesRustRoute = route(rustArgs, RUST_ROUTER_NUM_SAMPLES);
|
||||
DEFAULT_INFO_LOGGER(
|
||||
{ router: 'neon-router', performanceMs: performance.now() - before, type: 'real' },
|
||||
'Rust router real routing performance',
|
||||
);
|
||||
|
||||
assert.assert(
|
||||
rustArgs.pathsIn.length === allSourcesRustRoute.length,
|
||||
'different number of sources in the Router output than the input',
|
||||
);
|
||||
|
||||
const routesAndSamples = _.zip(allSourcesRustRoute, samplesAndNativeOrdersWithResults);
|
||||
|
||||
const adjustedFills: Fill[] = [];
|
||||
const totalRoutedAmount = BigNumber.sum(...allSourcesRustRoute);
|
||||
|
||||
const scale = input.dividedBy(totalRoutedAmount);
|
||||
for (const [routeInput, routeSamplesAndNativeOrders] of routesAndSamples) {
|
||||
if (!routeInput || !routeSamplesAndNativeOrders) {
|
||||
continue;
|
||||
}
|
||||
// TODO(kimpers): [TKR-241] amounts are sometimes clipped in the router due to precisions loss for number/f64
|
||||
// we can work around it by scaling it and rounding up. However now we end up with a total amount of a couple base units too much
|
||||
const rustInputAdjusted = BigNumber.min(
|
||||
new BigNumber(routeInput).multipliedBy(scale).integerValue(BigNumber.ROUND_CEIL),
|
||||
input,
|
||||
);
|
||||
|
||||
const current = routeSamplesAndNativeOrders[routeSamplesAndNativeOrders.length - 1];
|
||||
if (!isDexSample(current)) {
|
||||
const nativeFill = nativeOrdersToFills(
|
||||
side,
|
||||
[current],
|
||||
rustInputAdjusted,
|
||||
opts.outputAmountPerEth,
|
||||
opts.inputAmountPerEth,
|
||||
fees,
|
||||
)[0];
|
||||
// NOTE: For Limit/RFQ orders we are done here. No need to scale output
|
||||
adjustedFills.push(nativeFill);
|
||||
continue;
|
||||
}
|
||||
|
||||
// NOTE: For DexSamples only
|
||||
let fill = createFill(current);
|
||||
const routeSamples = routeSamplesAndNativeOrders as Array<DexSample<FillData>>;
|
||||
// Descend to approach a closer fill for fillData which may not be consistent
|
||||
// throughout the path (UniswapV3) and for a closer guesstimate at
|
||||
// gas used
|
||||
|
||||
assert.assert(routeSamples.length >= 1, 'Found no sample to use for source');
|
||||
for (let k = routeSamples.length - 1; k >= 0; k--) {
|
||||
if (k === 0) {
|
||||
fill = createFill(routeSamples[0]);
|
||||
}
|
||||
if (rustInputAdjusted.isGreaterThan(routeSamples[k].input)) {
|
||||
// Between here and the previous fill
|
||||
// HACK: Use the midpoint between the two
|
||||
const left = routeSamples[k];
|
||||
const right = routeSamples[k + 1];
|
||||
if (left && right) {
|
||||
// Approximate how much output we get for the input with the surrounding samples
|
||||
const interpolatedOutput = interpolateOutputFromSamples(
|
||||
left,
|
||||
right,
|
||||
rustInputAdjusted,
|
||||
).decimalPlaces(0, side === MarketOperation.Sell ? BigNumber.ROUND_FLOOR : BigNumber.ROUND_CEIL);
|
||||
|
||||
fill = createFill({
|
||||
...right, // default to the greater (for gas used)
|
||||
input: rustInputAdjusted,
|
||||
output: interpolatedOutput,
|
||||
});
|
||||
} else {
|
||||
assert.assert(Boolean(left || right), 'No valid sample to use');
|
||||
fill = createFill(left || right);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const scaleOutput = (output: BigNumber) =>
|
||||
output
|
||||
.dividedBy(fill.input)
|
||||
.times(rustInputAdjusted)
|
||||
.decimalPlaces(0, side === MarketOperation.Sell ? BigNumber.ROUND_FLOOR : BigNumber.ROUND_CEIL);
|
||||
adjustedFills.push({
|
||||
...fill,
|
||||
input: rustInputAdjusted,
|
||||
output: scaleOutput(fill.output),
|
||||
adjustedOutput: scaleOutput(fill.adjustedOutput),
|
||||
index: 0,
|
||||
parent: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
const pathFromRustInputs = Path.create(side, adjustedFills, input);
|
||||
|
||||
return pathFromRustInputs;
|
||||
}
|
||||
|
||||
export function findOptimalRustPathFromSamples(
|
||||
side: MarketOperation,
|
||||
samples: DexSample[][],
|
||||
nativeOrders: NativeOrderWithFillableAmounts[],
|
||||
input: BigNumber,
|
||||
opts: PathPenaltyOpts,
|
||||
fees: FeeSchedule,
|
||||
chainId: ChainId,
|
||||
): Path | undefined {
|
||||
const before = performance.now();
|
||||
const logPerformance = () =>
|
||||
DEFAULT_INFO_LOGGER(
|
||||
{ router: 'neon-router', performanceMs: performance.now() - before, type: 'total' },
|
||||
'Rust router total routing performance',
|
||||
);
|
||||
|
||||
const allSourcesPath = findRoutesAndCreateOptimalPath(side, samples, nativeOrders, input, opts, fees);
|
||||
if (!allSourcesPath) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const vipSources = VIP_ERC20_BRIDGE_SOURCES_BY_CHAIN_ID[chainId];
|
||||
|
||||
// HACK(kimpers): The Rust router currently doesn't account for VIP sources correctly
|
||||
// we need to try to route them in isolation and compare with the results all sources
|
||||
if (vipSources.length > 0) {
|
||||
const vipSourcesSet = new Set(vipSources);
|
||||
const vipSourcesSamples = samples.filter(s => s[0] && vipSourcesSet.has(s[0].source));
|
||||
|
||||
if (vipSourcesSamples.length > 0) {
|
||||
const vipSourcesPath = findRoutesAndCreateOptimalPath(side, vipSourcesSamples, [], input, opts, fees);
|
||||
|
||||
const { input: allSourcesInput, output: allSourcesOutput } = allSourcesPath.adjustedSize();
|
||||
// NOTE: For sell quotes input is the taker asset and for buy quotes input is the maker asset
|
||||
const gasCostInWei = FILL_QUOTE_TRANSFORMER_GAS_OVERHEAD.times(opts.gasPrice);
|
||||
const fqtOverheadInOutputToken = gasCostInWei.times(opts.outputAmountPerEth);
|
||||
const outputWithFqtOverhead =
|
||||
side === MarketOperation.Sell
|
||||
? allSourcesOutput.minus(fqtOverheadInOutputToken)
|
||||
: allSourcesOutput.plus(fqtOverheadInOutputToken);
|
||||
const allSourcesAdjustedRateWithFqtOverhead = getRate(side, allSourcesInput, outputWithFqtOverhead);
|
||||
|
||||
if (vipSourcesPath?.adjustedRate().isGreaterThan(allSourcesAdjustedRateWithFqtOverhead)) {
|
||||
logPerformance();
|
||||
return vipSourcesPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logPerformance();
|
||||
return allSourcesPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the optimal mixture of fills that maximizes (for sells) or minimizes
|
||||
* (for buys) output, while meeting the input requirement.
|
||||
*/
|
||||
export async function findOptimalPathAsync(
|
||||
export async function findOptimalPathJSAsync(
|
||||
side: MarketOperation,
|
||||
fills: Fill[][],
|
||||
targetInput: BigNumber,
|
||||
|
@@ -20,7 +20,6 @@ import {
|
||||
import {
|
||||
BALANCER_V2_VAULT_ADDRESS_BY_CHAIN,
|
||||
BANCOR_REGISTRY_BY_CHAIN_ID,
|
||||
CLIPPER_INFO_BY_CHAIN,
|
||||
DODOV1_CONFIG_BY_CHAIN_ID,
|
||||
DODOV2_FACTORIES_BY_CHAIN_ID,
|
||||
KYBER_CONFIG_BY_CHAIN_ID,
|
||||
@@ -1416,32 +1415,6 @@ export class SamplerOperations {
|
||||
|
||||
return this.getLidoSellQuotes(lidoInfo, makerToken, takerToken, takerFillAmounts);
|
||||
}
|
||||
case ERC20BridgeSource.Clipper:
|
||||
const { poolAddress: clipperPoolAddress, tokens: clipperTokens } = CLIPPER_INFO_BY_CHAIN[
|
||||
this.chainId
|
||||
];
|
||||
if (
|
||||
clipperPoolAddress === NULL_ADDRESS ||
|
||||
!clipperTokens.includes(makerToken) ||
|
||||
!clipperTokens.includes(takerToken)
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
// Clipper requires WETH to be represented as address(0)
|
||||
const adjustedMakerToken =
|
||||
makerToken === NATIVE_FEE_TOKEN_BY_CHAIN_ID[this.chainId] ? NULL_ADDRESS : makerToken;
|
||||
const adjustedTakerToken =
|
||||
takerToken === NATIVE_FEE_TOKEN_BY_CHAIN_ID[this.chainId] ? NULL_ADDRESS : takerToken;
|
||||
// Supports the PLP interface
|
||||
return this.getLiquidityProviderSellQuotes(
|
||||
clipperPoolAddress,
|
||||
adjustedMakerToken,
|
||||
adjustedTakerToken,
|
||||
takerFillAmounts,
|
||||
// tslint:disable-next-line: custom-no-magic-numbers
|
||||
0, // Not used for Clipper
|
||||
ERC20BridgeSource.Clipper,
|
||||
);
|
||||
default:
|
||||
throw new Error(`Unsupported sell sample source: ${source}`);
|
||||
}
|
||||
@@ -1706,32 +1679,6 @@ export class SamplerOperations {
|
||||
|
||||
return this.getLidoBuyQuotes(lidoInfo, makerToken, takerToken, makerFillAmounts);
|
||||
}
|
||||
case ERC20BridgeSource.Clipper:
|
||||
const { poolAddress: clipperPoolAddress, tokens: clipperTokens } = CLIPPER_INFO_BY_CHAIN[
|
||||
this.chainId
|
||||
];
|
||||
if (
|
||||
clipperPoolAddress === NULL_ADDRESS ||
|
||||
!clipperTokens.includes(makerToken) ||
|
||||
!clipperTokens.includes(takerToken)
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
// Clipper requires WETH to be represented as address(0)
|
||||
const adjustedMakerToken =
|
||||
makerToken === NATIVE_FEE_TOKEN_BY_CHAIN_ID[this.chainId] ? NULL_ADDRESS : makerToken;
|
||||
const adjustedTakerToken =
|
||||
takerToken === NATIVE_FEE_TOKEN_BY_CHAIN_ID[this.chainId] ? NULL_ADDRESS : takerToken;
|
||||
// Supports the PLP interface
|
||||
return this.getLiquidityProviderBuyQuotes(
|
||||
clipperPoolAddress,
|
||||
adjustedMakerToken,
|
||||
adjustedTakerToken,
|
||||
makerFillAmounts,
|
||||
// tslint:disable-next-line: custom-no-magic-numbers
|
||||
0, // Not used for Clipper
|
||||
ERC20BridgeSource.Clipper,
|
||||
);
|
||||
default:
|
||||
throw new Error(`Unsupported buy sample source: ${source}`);
|
||||
}
|
||||
|
@@ -69,7 +69,6 @@ export enum ERC20BridgeSource {
|
||||
CurveV2 = 'Curve_V2',
|
||||
Lido = 'Lido',
|
||||
ShibaSwap = 'ShibaSwap',
|
||||
Clipper = 'Clipper',
|
||||
// BSC only
|
||||
PancakeSwap = 'PancakeSwap',
|
||||
PancakeSwapV2 = 'PancakeSwap_V2',
|
||||
@@ -455,6 +454,11 @@ export interface GetMarketOrdersOpts {
|
||||
* hopping to. E.g DAI->USDC via an adjacent token WETH
|
||||
*/
|
||||
tokenAdjacencyGraph: TokenAdjacencyGraph;
|
||||
|
||||
/**
|
||||
* Gas price to use for quote
|
||||
*/
|
||||
gasPrice: BigNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -534,10 +538,11 @@ export interface GenerateOptimizedOrdersOpts {
|
||||
bridgeSlippage?: number;
|
||||
maxFallbackSlippage?: number;
|
||||
excludedSources?: ERC20BridgeSource[];
|
||||
feeSchedule?: FeeSchedule;
|
||||
feeSchedule: FeeSchedule;
|
||||
exchangeProxyOverhead?: ExchangeProxyOverhead;
|
||||
allowFallback?: boolean;
|
||||
shouldBatchBridgeOrders?: boolean;
|
||||
gasPrice: BigNumber;
|
||||
}
|
||||
|
||||
export interface ComparisonPrice {
|
||||
|
@@ -18,7 +18,9 @@ import { DummyLiquidityProviderContract, TestERC20BridgeSamplerContract } from '
|
||||
// tslint:disable: custom-no-magic-numbers
|
||||
|
||||
const { NULL_ADDRESS } = constants;
|
||||
blockchainTests('erc20-bridge-sampler', env => {
|
||||
// HACK(dorothy-zbornak): Disabled because these tests are flakey and all this logic is moving to
|
||||
// the sampler service anyway.
|
||||
blockchainTests.skip('erc20-bridge-sampler', env => {
|
||||
let testContract: TestERC20BridgeSamplerContract;
|
||||
const RATE_DENOMINATOR = constants.ONE_ETHER;
|
||||
const MIN_RATE = new BigNumber('0.01');
|
||||
|
@@ -186,7 +186,7 @@ describe('ExchangeProxySwapQuoteConsumer', () => {
|
||||
);
|
||||
}
|
||||
|
||||
const transformERC20Encoder = AbiEncoder.createMethod('transformERC20', [
|
||||
const transformERC20Encoder = AbiEncoder.createMethod('transformERC20Staging', [
|
||||
{ type: 'address', name: 'inputToken' },
|
||||
{ type: 'address', name: 'outputToken' },
|
||||
{ type: 'uint256', name: 'inputTokenAmount' },
|
||||
@@ -261,7 +261,7 @@ describe('ExchangeProxySwapQuoteConsumer', () => {
|
||||
expect(fillQuoteTransformerData.buyToken).to.eq(MAKER_TOKEN);
|
||||
const payTakerTransformerData = decodePayTakerTransformerData(callArgs.transformations[1].data);
|
||||
expect(payTakerTransformerData.amounts).to.deep.eq([]);
|
||||
expect(payTakerTransformerData.tokens).to.deep.eq([TAKER_TOKEN, MAKER_TOKEN, ETH_TOKEN_ADDRESS]);
|
||||
expect(payTakerTransformerData.tokens).to.deep.eq([TAKER_TOKEN, ETH_TOKEN_ADDRESS]);
|
||||
});
|
||||
|
||||
it('can produce a buy quote', async () => {
|
||||
@@ -292,7 +292,7 @@ describe('ExchangeProxySwapQuoteConsumer', () => {
|
||||
expect(fillQuoteTransformerData.buyToken).to.eq(MAKER_TOKEN);
|
||||
const payTakerTransformerData = decodePayTakerTransformerData(callArgs.transformations[1].data);
|
||||
expect(payTakerTransformerData.amounts).to.deep.eq([]);
|
||||
expect(payTakerTransformerData.tokens).to.deep.eq([TAKER_TOKEN, MAKER_TOKEN, ETH_TOKEN_ADDRESS]);
|
||||
expect(payTakerTransformerData.tokens).to.deep.eq([TAKER_TOKEN, ETH_TOKEN_ADDRESS]);
|
||||
});
|
||||
|
||||
it('ERC20 -> ERC20 does not have a WETH transformer', async () => {
|
||||
@@ -437,12 +437,7 @@ describe('ExchangeProxySwapQuoteConsumer', () => {
|
||||
expect(secondHopFillQuoteTransformerData.buyToken).to.eq(MAKER_TOKEN);
|
||||
const payTakerTransformerData = decodePayTakerTransformerData(callArgs.transformations[2].data);
|
||||
expect(payTakerTransformerData.amounts).to.deep.eq([]);
|
||||
expect(payTakerTransformerData.tokens).to.deep.eq([
|
||||
TAKER_TOKEN,
|
||||
MAKER_TOKEN,
|
||||
ETH_TOKEN_ADDRESS,
|
||||
INTERMEDIATE_TOKEN,
|
||||
]);
|
||||
expect(payTakerTransformerData.tokens).to.deep.eq([TAKER_TOKEN, INTERMEDIATE_TOKEN, ETH_TOKEN_ADDRESS]);
|
||||
});
|
||||
// it.skip('Uses the `LiquidityProviderFeature` if given a single LiquidityProvider order', async () => {
|
||||
// const quote = {
|
||||
@@ -504,7 +499,7 @@ describe('ExchangeProxySwapQuoteConsumer', () => {
|
||||
expect(fillQuoteTransformerData.buyToken).to.eq(MAKER_TOKEN);
|
||||
const payTakerTransformerData = decodePayTakerTransformerData(callArgs.transformations[1].data);
|
||||
expect(payTakerTransformerData.amounts).to.deep.eq([]);
|
||||
expect(payTakerTransformerData.tokens).to.deep.eq([TAKER_TOKEN, MAKER_TOKEN, ETH_TOKEN_ADDRESS]);
|
||||
expect(payTakerTransformerData.tokens).to.deep.eq([TAKER_TOKEN, ETH_TOKEN_ADDRESS]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -79,7 +79,7 @@ async function getMarketSellOrdersAsync(
|
||||
utils: MarketOperationUtils,
|
||||
nativeOrders: SignedNativeOrder[],
|
||||
takerAmount: BigNumber,
|
||||
opts?: Partial<GetMarketOrdersOpts>,
|
||||
opts: Partial<GetMarketOrdersOpts> & { gasPrice: BigNumber },
|
||||
): Promise<OptimizerResultWithReport> {
|
||||
return utils.getOptimizerResultAsync(nativeOrders, takerAmount, MarketOperation.Sell, opts);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ async function getMarketBuyOrdersAsync(
|
||||
utils: MarketOperationUtils,
|
||||
nativeOrders: SignedNativeOrder[],
|
||||
makerAmount: BigNumber,
|
||||
opts?: Partial<GetMarketOrdersOpts>,
|
||||
opts: Partial<GetMarketOrdersOpts> & { gasPrice: BigNumber },
|
||||
): Promise<OptimizerResultWithReport> {
|
||||
return utils.getOptimizerResultAsync(nativeOrders, makerAmount, MarketOperation.Buy, opts);
|
||||
}
|
||||
@@ -459,7 +459,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
FILL_AMOUNT,
|
||||
_.times(NUM_SAMPLES, i => DEFAULT_RATES[ERC20BridgeSource.Native][i]),
|
||||
);
|
||||
const DEFAULT_OPTS: Partial<GetMarketOrdersOpts> = {
|
||||
const DEFAULT_OPTS: Partial<GetMarketOrdersOpts> & { gasPrice: BigNumber } = {
|
||||
numSamples: NUM_SAMPLES,
|
||||
sampleDistributionBase: 1,
|
||||
bridgeSlippage: 0,
|
||||
@@ -468,6 +468,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
allowFallback: false,
|
||||
gasSchedule: {},
|
||||
feeSchedule: {},
|
||||
gasPrice: new BigNumber(30e9),
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -1229,6 +1230,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
excludedSources: [],
|
||||
numSamples: 4,
|
||||
bridgeSlippage: 0,
|
||||
gasPrice: new BigNumber(30e9),
|
||||
},
|
||||
);
|
||||
const result = ordersAndReport.optimizedOrders;
|
||||
@@ -1298,7 +1300,8 @@ describe('MarketOperationUtils tests', () => {
|
||||
FILL_AMOUNT,
|
||||
_.times(NUM_SAMPLES, () => DEFAULT_RATES[ERC20BridgeSource.Native][0]),
|
||||
);
|
||||
const DEFAULT_OPTS: Partial<GetMarketOrdersOpts> = {
|
||||
const GAS_PRICE = new BigNumber(100e9); // 100 gwei
|
||||
const DEFAULT_OPTS: Partial<GetMarketOrdersOpts> & { gasPrice: BigNumber } = {
|
||||
numSamples: NUM_SAMPLES,
|
||||
sampleDistributionBase: 1,
|
||||
bridgeSlippage: 0,
|
||||
@@ -1307,6 +1310,7 @@ describe('MarketOperationUtils tests', () => {
|
||||
allowFallback: false,
|
||||
gasSchedule: {},
|
||||
feeSchedule: {},
|
||||
gasPrice: GAS_PRICE,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -1626,11 +1630,10 @@ describe('MarketOperationUtils tests', () => {
|
||||
getMedianSellRate: createGetMedianSellRate(ETH_TO_TAKER_RATE),
|
||||
});
|
||||
const optimizer = new MarketOperationUtils(MOCK_SAMPLER, contractAddresses, ORDER_DOMAIN);
|
||||
const gasPrice = 100e9; // 100 gwei
|
||||
const exchangeProxyOverhead = (sourceFlags: bigint) =>
|
||||
sourceFlags === SOURCE_FLAGS.LiquidityProvider
|
||||
? constants.ZERO_AMOUNT
|
||||
: new BigNumber(1.3e5).times(gasPrice);
|
||||
: new BigNumber(1.3e5).times(GAS_PRICE);
|
||||
const improvedOrdersResponse = await optimizer.getOptimizerResultAsync(
|
||||
createOrdersFromSellRates(FILL_AMOUNT, rates[ERC20BridgeSource.Native]),
|
||||
FILL_AMOUNT,
|
||||
|
@@ -744,7 +744,7 @@ describe('quote_simulation tests', async () => {
|
||||
side,
|
||||
fillAmount: fillableInput,
|
||||
gasPrice: ONE,
|
||||
opts: { gasSchedule: GAS_SCHEDULE },
|
||||
opts: { gasSchedule: GAS_SCHEDULE, protocolFeeMultiplier: ONE },
|
||||
});
|
||||
if (side === MarketOperation.Sell) {
|
||||
expect(result.totalMakerAssetAmount).to.be.bignumber.eq(fillableOutput);
|
||||
@@ -769,10 +769,10 @@ describe('quote_simulation tests', async () => {
|
||||
side,
|
||||
fillAmount: fillableInput,
|
||||
gasPrice: ONE,
|
||||
opts: { gasSchedule: GAS_SCHEDULE },
|
||||
opts: { gasSchedule: GAS_SCHEDULE, protocolFeeMultiplier: ONE },
|
||||
});
|
||||
expect(result.gas).to.eq(countCollapsedFills(orders));
|
||||
expect(result.protocolFeeAmount).to.bignumber.gt(orders.length);
|
||||
expect(result.protocolFeeAmount).to.bignumber.eq(orders.length);
|
||||
expect(result.takerFeeTakerAssetAmount).to.bignumber.eq(0);
|
||||
expect(result.takerFeeMakerAssetAmount).to.bignumber.eq(0);
|
||||
expect(result.makerAssetAmount).to.bignumber.eq(result.totalMakerAssetAmount);
|
||||
@@ -801,7 +801,7 @@ describe('quote_simulation tests', async () => {
|
||||
side,
|
||||
fillAmount: inputFillAmount,
|
||||
gasPrice: ONE,
|
||||
opts: { gasSchedule: GAS_SCHEDULE },
|
||||
opts: { gasSchedule: GAS_SCHEDULE, protocolFeeMultiplier: ONE },
|
||||
});
|
||||
expect(result.gas).to.gt(0);
|
||||
expect(result.protocolFeeAmount).to.bignumber.gt(0);
|
||||
@@ -835,7 +835,7 @@ describe('quote_simulation tests', async () => {
|
||||
side,
|
||||
fillAmount: totalFillableInput,
|
||||
gasPrice: ONE,
|
||||
opts: { gasSchedule: GAS_SCHEDULE },
|
||||
opts: { gasSchedule: GAS_SCHEDULE, protocolFeeMultiplier: ONE },
|
||||
});
|
||||
|
||||
assertRoughlyEquals(result.takerAssetAmount, fillableInput);
|
||||
@@ -865,7 +865,7 @@ describe('quote_simulation tests', async () => {
|
||||
side,
|
||||
fillAmount: inputFillAmount,
|
||||
gasPrice: ONE,
|
||||
opts: { gasSchedule: GAS_SCHEDULE },
|
||||
opts: { gasSchedule: GAS_SCHEDULE, protocolFeeMultiplier: ONE },
|
||||
});
|
||||
expect(result.gas).to.gt(0);
|
||||
expect(result.protocolFeeAmount).to.bignumber.gt(0);
|
||||
@@ -893,10 +893,10 @@ describe('quote_simulation tests', async () => {
|
||||
side,
|
||||
fillAmount: fillableInput,
|
||||
gasPrice: ONE,
|
||||
opts: { gasSchedule: GAS_SCHEDULE },
|
||||
opts: { gasSchedule: GAS_SCHEDULE, protocolFeeMultiplier: ONE },
|
||||
});
|
||||
expect(result.gas).to.eq(countCollapsedFills(orders));
|
||||
expect(result.protocolFeeAmount).to.bignumber.gt(orders.length);
|
||||
expect(result.protocolFeeAmount).to.bignumber.eq(orders.length);
|
||||
|
||||
assertRoughlyEquals(result.makerAssetAmount, fillableInput);
|
||||
assertRoughlyEquals(result.totalMakerAssetAmount, fillableInput);
|
||||
@@ -923,7 +923,7 @@ describe('quote_simulation tests', async () => {
|
||||
side,
|
||||
fillAmount: inputFillAmount,
|
||||
gasPrice: ONE,
|
||||
opts: { gasSchedule: GAS_SCHEDULE },
|
||||
opts: { gasSchedule: GAS_SCHEDULE, protocolFeeMultiplier: ONE },
|
||||
});
|
||||
expect(result.gas).to.gt(0);
|
||||
expect(result.protocolFeeAmount).to.bignumber.gt(0);
|
||||
@@ -951,7 +951,7 @@ describe('quote_simulation tests', async () => {
|
||||
side,
|
||||
fillAmount: fillableInput,
|
||||
gasPrice: ONE,
|
||||
opts: { gasSchedule: GAS_SCHEDULE, slippage },
|
||||
opts: { gasSchedule: GAS_SCHEDULE, protocolFeeMultiplier: ONE, slippage },
|
||||
});
|
||||
if (side === MarketOperation.Sell) {
|
||||
const slippedOutput = fillableOutput.times(1 - slippage).integerValue();
|
||||
@@ -982,7 +982,7 @@ describe('quote_simulation tests', async () => {
|
||||
side,
|
||||
fillAmount: fillableInput,
|
||||
gasPrice: ONE,
|
||||
opts: { gasSchedule: GAS_SCHEDULE },
|
||||
opts: { gasSchedule: GAS_SCHEDULE, protocolFeeMultiplier: ONE },
|
||||
});
|
||||
const worstCase = simulateWorstCaseFill({
|
||||
orders,
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "3.16.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update IZeroEx and ITransformERC20 artifacts",
|
||||
"pr": 282
|
||||
}
|
||||
],
|
||||
"timestamp": 1632957537
|
||||
},
|
||||
{
|
||||
"timestamp": 1631710679,
|
||||
"version": "3.15.1",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v3.16.0 - _September 29, 2021_
|
||||
|
||||
* Update IZeroEx and ITransformERC20 artifacts (#282)
|
||||
|
||||
## v3.15.1 - _September 15, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schemaVersion": "2.0.0",
|
||||
"contractName": "ITransformERC20",
|
||||
"contractName": "ITransformERC20Feature",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
@@ -43,14 +43,14 @@
|
||||
{ "internalType": "uint32", "name": "deploymentNonce", "type": "uint32" },
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct ITransformERC20.Transformation[]",
|
||||
"internalType": "struct ITransformERC20Feature.Transformation[]",
|
||||
"name": "transformations",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{ "internalType": "bytes32", "name": "callDataHash", "type": "bytes32" },
|
||||
{ "internalType": "bytes", "name": "callDataSignature", "type": "bytes" }
|
||||
{ "internalType": "bool", "name": "useSelfBalance", "type": "bool" },
|
||||
{ "internalType": "address payable", "name": "recipient", "type": "address" }
|
||||
],
|
||||
"internalType": "struct ITransformERC20.TransformERC20Args",
|
||||
"internalType": "struct ITransformERC20Feature.TransformERC20Args",
|
||||
"name": "args",
|
||||
"type": "tuple"
|
||||
}
|
||||
@@ -113,7 +113,7 @@
|
||||
{ "internalType": "uint32", "name": "deploymentNonce", "type": "uint32" },
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct ITransformERC20.Transformation[]",
|
||||
"internalType": "struct ITransformERC20Feature.Transformation[]",
|
||||
"name": "transformations",
|
||||
"type": "tuple[]"
|
||||
}
|
||||
@@ -148,7 +148,7 @@
|
||||
},
|
||||
"kind": "dev",
|
||||
"methods": {
|
||||
"_transformERC20((address,address,address,uint256,uint256,(uint32,bytes)[],bytes32,bytes))": {
|
||||
"_transformERC20((address,address,address,uint256,uint256,(uint32,bytes)[],bool,address))": {
|
||||
"details": "Internal version of `transformERC20()`. Only callable from within.",
|
||||
"params": { "args": "A `TransformERC20Args` struct." },
|
||||
"returns": { "outputTokenAmount": "The amount of `outputToken` received by the taker." }
|
||||
@@ -212,7 +212,8 @@
|
||||
"evm.bytecode.object",
|
||||
"evm.bytecode.sourceMap",
|
||||
"evm.deployedBytecode.object",
|
||||
"evm.deployedBytecode.sourceMap"
|
||||
"evm.deployedBytecode.sourceMap",
|
||||
"evm.methodIdentifiers"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@@ -3,16 +3,6 @@
|
||||
"contractName": "IZeroEx",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{ "indexed": false, "internalType": "bytes32", "name": "orderHash", "type": "bytes32" },
|
||||
{ "indexed": false, "internalType": "address", "name": "maker", "type": "address" },
|
||||
{ "indexed": false, "internalType": "uint64", "name": "expiry", "type": "uint64" }
|
||||
],
|
||||
"name": "ExpiredRfqOrder",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
@@ -49,11 +39,26 @@
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{ "indexed": false, "internalType": "address", "name": "inputToken", "type": "address" },
|
||||
{ "indexed": false, "internalType": "address", "name": "outputToken", "type": "address" },
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "contract IERC20TokenV06",
|
||||
"name": "inputToken",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "contract IERC20TokenV06",
|
||||
"name": "outputToken",
|
||||
"type": "address"
|
||||
},
|
||||
{ "indexed": false, "internalType": "uint256", "name": "inputTokenAmount", "type": "uint256" },
|
||||
{ "indexed": false, "internalType": "uint256", "name": "outputTokenAmount", "type": "uint256" },
|
||||
{ "indexed": false, "internalType": "address", "name": "provider", "type": "address" },
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "contract ILiquidityProvider",
|
||||
"name": "provider",
|
||||
"type": "address"
|
||||
},
|
||||
{ "indexed": false, "internalType": "address", "name": "recipient", "type": "address" }
|
||||
],
|
||||
"name": "LiquidityProviderSwap",
|
||||
@@ -110,10 +115,10 @@
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint128",
|
||||
"name": "takerTokenFilledAmount",
|
||||
"name": "makerTokenFilledAmount",
|
||||
"type": "uint128"
|
||||
},
|
||||
{ "indexed": false, "internalType": "uint128", "name": "makerTokenFilledAmount", "type": "uint128" }
|
||||
{ "indexed": false, "internalType": "uint128", "name": "takerTokenFilledAmount", "type": "uint128" }
|
||||
],
|
||||
"name": "OtcOrderFilled",
|
||||
"type": "event"
|
||||
@@ -268,6 +273,51 @@
|
||||
"stateMutability": "payable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" },
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" },
|
||||
{ "internalType": "uint128", "name": "makerAmount", "type": "uint128" },
|
||||
{ "internalType": "uint128", "name": "takerAmount", "type": "uint128" },
|
||||
{ "internalType": "address", "name": "maker", "type": "address" },
|
||||
{ "internalType": "address", "name": "taker", "type": "address" },
|
||||
{ "internalType": "address", "name": "txOrigin", "type": "address" },
|
||||
{ "internalType": "uint256", "name": "expiryAndNonce", "type": "uint256" }
|
||||
],
|
||||
"internalType": "struct LibNativeOrder.OtcOrder",
|
||||
"name": "order",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum LibSignature.SignatureType",
|
||||
"name": "signatureType",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "uint8", "name": "v", "type": "uint8" },
|
||||
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
|
||||
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
|
||||
],
|
||||
"internalType": "struct LibSignature.Signature",
|
||||
"name": "makerSignature",
|
||||
"type": "tuple"
|
||||
},
|
||||
{ "internalType": "uint128", "name": "takerTokenFillAmount", "type": "uint128" },
|
||||
{ "internalType": "address", "name": "taker", "type": "address" },
|
||||
{ "internalType": "bool", "name": "useSelfBalance", "type": "bool" },
|
||||
{ "internalType": "address", "name": "recipient", "type": "address" }
|
||||
],
|
||||
"name": "_fillOtcOrder",
|
||||
"outputs": [
|
||||
{ "internalType": "uint128", "name": "takerTokenFilledAmount", "type": "uint128" },
|
||||
{ "internalType": "uint128", "name": "makerTokenFilledAmount", "type": "uint128" }
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
@@ -303,7 +353,9 @@
|
||||
"type": "tuple"
|
||||
},
|
||||
{ "internalType": "uint128", "name": "takerTokenFillAmount", "type": "uint128" },
|
||||
{ "internalType": "address", "name": "taker", "type": "address" }
|
||||
{ "internalType": "address", "name": "taker", "type": "address" },
|
||||
{ "internalType": "bool", "name": "useSelfBalance", "type": "bool" },
|
||||
{ "internalType": "address", "name": "recipient", "type": "address" }
|
||||
],
|
||||
"name": "_fillRfqOrder",
|
||||
"outputs": [
|
||||
@@ -313,6 +365,18 @@
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "bytes", "name": "encodedPath", "type": "bytes" },
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{ "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" },
|
||||
{ "internalType": "address", "name": "recipient", "type": "address" }
|
||||
],
|
||||
"name": "_sellHeldTokenForTokenToUniswapV3",
|
||||
"outputs": [{ "internalType": "uint256", "name": "buyAmount", "type": "uint256" }],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
@@ -330,7 +394,9 @@
|
||||
"internalType": "struct ITransformERC20Feature.Transformation[]",
|
||||
"name": "transformations",
|
||||
"type": "tuple[]"
|
||||
}
|
||||
},
|
||||
{ "internalType": "bool", "name": "useSelfBalance", "type": "bool" },
|
||||
{ "internalType": "address payable", "name": "recipient", "type": "address" }
|
||||
],
|
||||
"internalType": "struct ITransformERC20Feature.TransformERC20Args",
|
||||
"name": "args",
|
||||
@@ -480,35 +546,6 @@
|
||||
"stateMutability": "payable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "inputToken", "type": "address" },
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "outputToken", "type": "address" },
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{
|
||||
"components": [
|
||||
{ "internalType": "bytes4", "name": "selector", "type": "bytes4" },
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct IMultiplexFeature.WrappedBatchCall[]",
|
||||
"name": "calls",
|
||||
"type": "tuple[]"
|
||||
}
|
||||
],
|
||||
"internalType": "struct IMultiplexFeature.BatchFillData",
|
||||
"name": "fillData",
|
||||
"type": "tuple"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }
|
||||
],
|
||||
"name": "batchFill",
|
||||
"outputs": [{ "internalType": "uint256", "name": "outputTokenAmount", "type": "uint256" }],
|
||||
"stateMutability": "payable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
@@ -601,6 +638,60 @@
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" },
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" },
|
||||
{ "internalType": "uint128", "name": "makerAmount", "type": "uint128" },
|
||||
{ "internalType": "uint128", "name": "takerAmount", "type": "uint128" },
|
||||
{ "internalType": "address", "name": "maker", "type": "address" },
|
||||
{ "internalType": "address", "name": "taker", "type": "address" },
|
||||
{ "internalType": "address", "name": "txOrigin", "type": "address" },
|
||||
{ "internalType": "uint256", "name": "expiryAndNonce", "type": "uint256" }
|
||||
],
|
||||
"internalType": "struct LibNativeOrder.OtcOrder[]",
|
||||
"name": "orders",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum LibSignature.SignatureType",
|
||||
"name": "signatureType",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "uint8", "name": "v", "type": "uint8" },
|
||||
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
|
||||
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
|
||||
],
|
||||
"internalType": "struct LibSignature.Signature[]",
|
||||
"name": "makerSignatures",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum LibSignature.SignatureType",
|
||||
"name": "signatureType",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "uint8", "name": "v", "type": "uint8" },
|
||||
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
|
||||
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
|
||||
],
|
||||
"internalType": "struct LibSignature.Signature[]",
|
||||
"name": "takerSignatures",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{ "internalType": "bool[]", "name": "unwrapWeth", "type": "bool[]" }
|
||||
],
|
||||
"name": "batchFillTakerSignedOtcOrders",
|
||||
"outputs": [{ "internalType": "bool[]", "name": "successes", "type": "bool[]" }],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
@@ -1026,8 +1117,7 @@
|
||||
"name": "makerSignature",
|
||||
"type": "tuple"
|
||||
},
|
||||
{ "internalType": "uint128", "name": "takerTokenFillAmount", "type": "uint128" },
|
||||
{ "internalType": "bool", "name": "unwrapWeth", "type": "bool" }
|
||||
{ "internalType": "uint128", "name": "takerTokenFillAmount", "type": "uint128" }
|
||||
],
|
||||
"name": "fillOtcOrder",
|
||||
"outputs": [
|
||||
@@ -1037,6 +1127,48 @@
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" },
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" },
|
||||
{ "internalType": "uint128", "name": "makerAmount", "type": "uint128" },
|
||||
{ "internalType": "uint128", "name": "takerAmount", "type": "uint128" },
|
||||
{ "internalType": "address", "name": "maker", "type": "address" },
|
||||
{ "internalType": "address", "name": "taker", "type": "address" },
|
||||
{ "internalType": "address", "name": "txOrigin", "type": "address" },
|
||||
{ "internalType": "uint256", "name": "expiryAndNonce", "type": "uint256" }
|
||||
],
|
||||
"internalType": "struct LibNativeOrder.OtcOrder",
|
||||
"name": "order",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum LibSignature.SignatureType",
|
||||
"name": "signatureType",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "uint8", "name": "v", "type": "uint8" },
|
||||
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
|
||||
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
|
||||
],
|
||||
"internalType": "struct LibSignature.Signature",
|
||||
"name": "makerSignature",
|
||||
"type": "tuple"
|
||||
},
|
||||
{ "internalType": "uint128", "name": "takerTokenFillAmount", "type": "uint128" }
|
||||
],
|
||||
"name": "fillOtcOrderForEth",
|
||||
"outputs": [
|
||||
{ "internalType": "uint128", "name": "takerTokenFilledAmount", "type": "uint128" },
|
||||
{ "internalType": "uint128", "name": "makerTokenFilledAmount", "type": "uint128" }
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
@@ -1168,14 +1300,63 @@
|
||||
"internalType": "struct LibSignature.Signature",
|
||||
"name": "takerSignature",
|
||||
"type": "tuple"
|
||||
},
|
||||
{ "internalType": "bool", "name": "unwrapWeth", "type": "bool" }
|
||||
}
|
||||
],
|
||||
"name": "fillTakerSignedOtcOrder",
|
||||
"outputs": [
|
||||
{ "internalType": "uint128", "name": "takerTokenFilledAmount", "type": "uint128" },
|
||||
{ "internalType": "uint128", "name": "makerTokenFilledAmount", "type": "uint128" }
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "makerToken", "type": "address" },
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "takerToken", "type": "address" },
|
||||
{ "internalType": "uint128", "name": "makerAmount", "type": "uint128" },
|
||||
{ "internalType": "uint128", "name": "takerAmount", "type": "uint128" },
|
||||
{ "internalType": "address", "name": "maker", "type": "address" },
|
||||
{ "internalType": "address", "name": "taker", "type": "address" },
|
||||
{ "internalType": "address", "name": "txOrigin", "type": "address" },
|
||||
{ "internalType": "uint256", "name": "expiryAndNonce", "type": "uint256" }
|
||||
],
|
||||
"internalType": "struct LibNativeOrder.OtcOrder",
|
||||
"name": "order",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum LibSignature.SignatureType",
|
||||
"name": "signatureType",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "uint8", "name": "v", "type": "uint8" },
|
||||
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
|
||||
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
|
||||
],
|
||||
"internalType": "struct LibSignature.Signature",
|
||||
"name": "makerSignature",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum LibSignature.SignatureType",
|
||||
"name": "signatureType",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "uint8", "name": "v", "type": "uint8" },
|
||||
{ "internalType": "bytes32", "name": "r", "type": "bytes32" },
|
||||
{ "internalType": "bytes32", "name": "s", "type": "bytes32" }
|
||||
],
|
||||
"internalType": "struct LibSignature.Signature",
|
||||
"name": "takerSignature",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"name": "fillTakerSignedOtcOrderForEth",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
@@ -1604,31 +1785,150 @@
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "outputToken", "type": "address" },
|
||||
{
|
||||
"components": [
|
||||
{ "internalType": "address[]", "name": "tokens", "type": "address[]" },
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{
|
||||
"components": [
|
||||
{ "internalType": "bytes4", "name": "selector", "type": "bytes4" },
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct IMultiplexFeature.WrappedMultiHopCall[]",
|
||||
"name": "calls",
|
||||
"type": "tuple[]"
|
||||
}
|
||||
"internalType": "enum IMultiplexFeature.MultiplexSubcall",
|
||||
"name": "id",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct IMultiplexFeature.MultiHopFillData",
|
||||
"name": "fillData",
|
||||
"type": "tuple"
|
||||
"internalType": "struct IMultiplexFeature.BatchSellSubcall[]",
|
||||
"name": "calls",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }
|
||||
],
|
||||
"name": "multiHopFill",
|
||||
"outputs": [{ "internalType": "uint256", "name": "outputTokenAmount", "type": "uint256" }],
|
||||
"name": "multiplexBatchSellEthForToken",
|
||||
"outputs": [{ "internalType": "uint256", "name": "boughtAmount", "type": "uint256" }],
|
||||
"stateMutability": "payable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "inputToken", "type": "address" },
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum IMultiplexFeature.MultiplexSubcall",
|
||||
"name": "id",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct IMultiplexFeature.BatchSellSubcall[]",
|
||||
"name": "calls",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{ "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }
|
||||
],
|
||||
"name": "multiplexBatchSellTokenForEth",
|
||||
"outputs": [{ "internalType": "uint256", "name": "boughtAmount", "type": "uint256" }],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "inputToken", "type": "address" },
|
||||
{ "internalType": "contract IERC20TokenV06", "name": "outputToken", "type": "address" },
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum IMultiplexFeature.MultiplexSubcall",
|
||||
"name": "id",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct IMultiplexFeature.BatchSellSubcall[]",
|
||||
"name": "calls",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{ "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }
|
||||
],
|
||||
"name": "multiplexBatchSellTokenForToken",
|
||||
"outputs": [{ "internalType": "uint256", "name": "boughtAmount", "type": "uint256" }],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "address[]", "name": "tokens", "type": "address[]" },
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum IMultiplexFeature.MultiplexSubcall",
|
||||
"name": "id",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct IMultiplexFeature.MultiHopSellSubcall[]",
|
||||
"name": "calls",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }
|
||||
],
|
||||
"name": "multiplexMultiHopSellEthForToken",
|
||||
"outputs": [{ "internalType": "uint256", "name": "boughtAmount", "type": "uint256" }],
|
||||
"stateMutability": "payable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "address[]", "name": "tokens", "type": "address[]" },
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum IMultiplexFeature.MultiplexSubcall",
|
||||
"name": "id",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct IMultiplexFeature.MultiHopSellSubcall[]",
|
||||
"name": "calls",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{ "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }
|
||||
],
|
||||
"name": "multiplexMultiHopSellTokenForEth",
|
||||
"outputs": [{ "internalType": "uint256", "name": "boughtAmount", "type": "uint256" }],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{ "internalType": "address[]", "name": "tokens", "type": "address[]" },
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "enum IMultiplexFeature.MultiplexSubcall",
|
||||
"name": "id",
|
||||
"type": "uint8"
|
||||
},
|
||||
{ "internalType": "bytes", "name": "data", "type": "bytes" }
|
||||
],
|
||||
"internalType": "struct IMultiplexFeature.MultiHopSellSubcall[]",
|
||||
"name": "calls",
|
||||
"type": "tuple[]"
|
||||
},
|
||||
{ "internalType": "uint256", "name": "sellAmount", "type": "uint256" },
|
||||
{ "internalType": "uint256", "name": "minBuyAmount", "type": "uint256" }
|
||||
],
|
||||
"name": "multiplexMultiHopSellTokenForToken",
|
||||
"outputs": [{ "internalType": "uint256", "name": "boughtAmount", "type": "uint256" }],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
@@ -1819,20 +2119,47 @@
|
||||
"takerTokenFilledAmount": "How much maker token was filled."
|
||||
}
|
||||
},
|
||||
"_fillRfqOrder((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128,address)": {
|
||||
"_fillOtcOrder((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),uint128,address,bool,address)": {
|
||||
"details": "Fill an OTC order for up to `takerTokenFillAmount` taker tokens. Internal variant.",
|
||||
"params": {
|
||||
"makerSignature": "The order signature from the maker.",
|
||||
"order": "The OTC order.",
|
||||
"recipient": "The recipient of the bought maker tokens.",
|
||||
"taker": "The address to fill the order in the context of.",
|
||||
"takerTokenFillAmount": "Maximum taker token amount to fill this order with.",
|
||||
"useSelfBalance": "Whether to use the Exchange Proxy's balance of input tokens."
|
||||
},
|
||||
"returns": {
|
||||
"makerTokenFilledAmount": "How much maker token was filled.",
|
||||
"takerTokenFilledAmount": "How much taker token was filled."
|
||||
}
|
||||
},
|
||||
"_fillRfqOrder((address,address,uint128,uint128,address,address,address,bytes32,uint64,uint256),(uint8,uint8,bytes32,bytes32),uint128,address,bool,address)": {
|
||||
"details": "Fill an RFQ order. Internal variant.",
|
||||
"params": {
|
||||
"order": "The RFQ order.",
|
||||
"recipient": "The recipient of the maker tokens.",
|
||||
"signature": "The order signature.",
|
||||
"taker": "The order taker.",
|
||||
"takerTokenFillAmount": "Maximum taker token to fill this order with."
|
||||
"takerTokenFillAmount": "Maximum taker token to fill this order with.",
|
||||
"useSelfBalance": "Whether to use the ExchangeProxy's transient balance of taker tokens to fill the order."
|
||||
},
|
||||
"returns": {
|
||||
"makerTokenFilledAmount": "How much maker token was filled.",
|
||||
"takerTokenFilledAmount": "How much maker token was filled."
|
||||
}
|
||||
},
|
||||
"_transformERC20((address,address,address,uint256,uint256,(uint32,bytes)[]))": {
|
||||
"_sellHeldTokenForTokenToUniswapV3(bytes,uint256,uint256,address)": {
|
||||
"details": "Sell a token for another token directly against uniswap v3. Private variant, uses tokens held by `address(this)`.",
|
||||
"params": {
|
||||
"encodedPath": "Uniswap-encoded path.",
|
||||
"minBuyAmount": "Minimum amount of the last token in the path to buy.",
|
||||
"recipient": "The recipient of the bought tokens. Can be zero for sender.",
|
||||
"sellAmount": "amount of the first token in the path to sell."
|
||||
},
|
||||
"returns": { "buyAmount": "Amount of the last token in the path bought." }
|
||||
},
|
||||
"_transformERC20((address,address,address,uint256,uint256,(uint32,bytes)[],bool,address))": {
|
||||
"details": "Internal version of `transformERC20()`. Only callable from within.",
|
||||
"params": { "args": "A `TransformERC20Args` struct." },
|
||||
"returns": { "outputTokenAmount": "The amount of `outputToken` received by the taker." }
|
||||
@@ -1887,14 +2214,6 @@
|
||||
},
|
||||
"returns": { "returnResults": "The ABI-encoded results of the underlying calls." }
|
||||
},
|
||||
"batchFill((address,address,uint256,(bytes4,uint256,bytes)[]),uint256)": {
|
||||
"details": "Executes a batch of fills selling `fillData.inputToken` for `fillData.outputToken` in sequence. Refer to the internal variant `_batchFill` for the allowed nested operations.",
|
||||
"params": {
|
||||
"fillData": "Encodes the input/output tokens, the sell amount, and the nested operations for this batch fill.",
|
||||
"minBuyAmount": "The minimum amount of `fillData.outputToken` to buy. Reverts if this amount is not met."
|
||||
},
|
||||
"returns": { "outputTokenAmount": "The amount of the output token bought." }
|
||||
},
|
||||
"batchFillLimitOrders((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256)[],(uint8,uint8,bytes32,bytes32)[],uint128[],bool)": {
|
||||
"details": "Fills multiple limit orders.",
|
||||
"params": {
|
||||
@@ -1921,6 +2240,18 @@
|
||||
"takerTokenFilledAmounts": "Array of amounts filled, in taker token."
|
||||
}
|
||||
},
|
||||
"batchFillTakerSignedOtcOrders((address,address,uint128,uint128,address,address,address,uint256)[],(uint8,uint8,bytes32,bytes32)[],(uint8,uint8,bytes32,bytes32)[],bool[])": {
|
||||
"details": "Fills multiple taker-signed OTC orders.",
|
||||
"params": {
|
||||
"makerSignatures": "Array of maker signatures for each order.",
|
||||
"orders": "Array of OTC orders.",
|
||||
"takerSignatures": "Array of taker signatures for each order.",
|
||||
"unwrapWeth": "Array of booleans representing whether or not to unwrap bought WETH into ETH for each order. Should be set to false if the maker token is not WETH."
|
||||
},
|
||||
"returns": {
|
||||
"successes": "Array of booleans representing whether or not each order in `orders` was filled successfully."
|
||||
}
|
||||
},
|
||||
"batchGetLimitOrderRelevantStates((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256)[],(uint8,uint8,bytes32,bytes32)[])": {
|
||||
"details": "Batch version of `getLimitOrderRelevantState()`, without reverting. Orders that would normally cause `getLimitOrderRelevantState()` to revert will have empty results.",
|
||||
"params": { "orders": "The limit orders.", "signatures": "The order signatures." },
|
||||
@@ -2027,13 +2358,24 @@
|
||||
},
|
||||
"returns": { "makerTokenFilledAmount": "How much maker token was filled." }
|
||||
},
|
||||
"fillOtcOrder((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),uint128,bool)": {
|
||||
"fillOtcOrder((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),uint128)": {
|
||||
"details": "Fill an OTC order for up to `takerTokenFillAmount` taker tokens.",
|
||||
"params": {
|
||||
"makerSignature": "The order signature from the maker.",
|
||||
"order": "The OTC order.",
|
||||
"takerTokenFillAmount": "Maximum taker token amount to fill this order with.",
|
||||
"unwrapWeth": "Whether or not to unwrap bought WETH into ETH before transferring it to the taker. Should be set to false"
|
||||
"takerTokenFillAmount": "Maximum taker token amount to fill this order with."
|
||||
},
|
||||
"returns": {
|
||||
"makerTokenFilledAmount": "How much maker token was filled.",
|
||||
"takerTokenFilledAmount": "How much taker token was filled."
|
||||
}
|
||||
},
|
||||
"fillOtcOrderForEth((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),uint128)": {
|
||||
"details": "Fill an OTC order for up to `takerTokenFillAmount` taker tokens. Unwraps bought WETH into ETH before sending it to the taker.",
|
||||
"params": {
|
||||
"makerSignature": "The order signature from the maker.",
|
||||
"order": "The OTC order.",
|
||||
"takerTokenFillAmount": "Maximum taker token amount to fill this order with."
|
||||
},
|
||||
"returns": {
|
||||
"makerTokenFilledAmount": "How much maker token was filled.",
|
||||
@@ -2060,17 +2402,20 @@
|
||||
"takerTokenFilledAmount": "How much maker token was filled."
|
||||
}
|
||||
},
|
||||
"fillTakerSignedOtcOrder((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),(uint8,uint8,bytes32,bytes32),bool)": {
|
||||
"fillTakerSignedOtcOrder((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),(uint8,uint8,bytes32,bytes32))": {
|
||||
"details": "Fully fill an OTC order. \"Meta-transaction\" variant, requires order to be signed by both maker and taker.",
|
||||
"params": {
|
||||
"makerSignature": "The order signature from the maker.",
|
||||
"order": "The OTC order.",
|
||||
"takerSignature": "The order signature from the taker.",
|
||||
"unwrapWeth": "Whether or not to unwrap bought WETH into ETH before transferring it to the taker. Should be set to false if the maker token is not WETH."
|
||||
},
|
||||
"returns": {
|
||||
"makerTokenFilledAmount": "How much maker token was filled.",
|
||||
"takerTokenFilledAmount": "How much taker token was filled."
|
||||
"takerSignature": "The order signature from the taker."
|
||||
}
|
||||
},
|
||||
"fillTakerSignedOtcOrderForEth((address,address,uint128,uint128,address,address,address,uint256),(uint8,uint8,bytes32,bytes32),(uint8,uint8,bytes32,bytes32))": {
|
||||
"details": "Fully fill an OTC order. \"Meta-transaction\" variant, requires order to be signed by both maker and taker. Unwraps bought WETH into ETH before sending it to the taker.",
|
||||
"params": {
|
||||
"makerSignature": "The order signature from the maker.",
|
||||
"order": "The OTC order.",
|
||||
"takerSignature": "The order signature from the taker."
|
||||
}
|
||||
},
|
||||
"getLimitOrderHash((address,address,uint128,uint128,uint128,address,address,address,address,bytes32,uint64,uint256))": {
|
||||
@@ -2184,13 +2529,62 @@
|
||||
"target": "The migrator contract address."
|
||||
}
|
||||
},
|
||||
"multiHopFill((address[],uint256,(bytes4,bytes)[]),uint256)": {
|
||||
"details": "Executes a sequence of fills \"hopping\" through the path of tokens given by `fillData.tokens`. Refer to the internal variant `_multiHopFill` for the allowed nested operations.",
|
||||
"multiplexBatchSellEthForToken(address,(uint8,uint256,bytes)[],uint256)": {
|
||||
"details": "Sells attached ETH for `outputToken` using the provided calls.",
|
||||
"params": {
|
||||
"fillData": "Encodes the path of tokens, the sell amount, and the nested operations for this multi-hop fill.",
|
||||
"minBuyAmount": "The minimum amount of the output token to buy. Reverts if this amount is not met."
|
||||
"calls": "The calls to use to sell the attached ETH.",
|
||||
"minBuyAmount": "The minimum amount of `outputToken` that must be bought for this function to not revert.",
|
||||
"outputToken": "The token to buy."
|
||||
},
|
||||
"returns": { "outputTokenAmount": "The amount of the output token bought." }
|
||||
"returns": { "boughtAmount": "The amount of `outputToken` bought." }
|
||||
},
|
||||
"multiplexBatchSellTokenForEth(address,(uint8,uint256,bytes)[],uint256,uint256)": {
|
||||
"details": "Sells `sellAmount` of the given `inputToken` for ETH using the provided calls.",
|
||||
"params": {
|
||||
"calls": "The calls to use to sell the input tokens.",
|
||||
"inputToken": "The token to sell.",
|
||||
"minBuyAmount": "The minimum amount of ETH that must be bought for this function to not revert.",
|
||||
"sellAmount": "The amount of `inputToken` to sell."
|
||||
},
|
||||
"returns": { "boughtAmount": "The amount of ETH bought." }
|
||||
},
|
||||
"multiplexBatchSellTokenForToken(address,address,(uint8,uint256,bytes)[],uint256,uint256)": {
|
||||
"details": "Sells `sellAmount` of the given `inputToken` for `outputToken` using the provided calls.",
|
||||
"params": {
|
||||
"calls": "The calls to use to sell the input tokens.",
|
||||
"inputToken": "The token to sell.",
|
||||
"minBuyAmount": "The minimum amount of `outputToken` that must be bought for this function to not revert.",
|
||||
"outputToken": "The token to buy.",
|
||||
"sellAmount": "The amount of `inputToken` to sell."
|
||||
},
|
||||
"returns": { "boughtAmount": "The amount of `outputToken` bought." }
|
||||
},
|
||||
"multiplexMultiHopSellEthForToken(address[],(uint8,bytes)[],uint256)": {
|
||||
"details": "Sells attached ETH via the given sequence of tokens and calls. `tokens[0]` must be WETH. The last token in `tokens` is the output token that will ultimately be sent to `msg.sender`",
|
||||
"params": {
|
||||
"calls": "The sequence of calls to use for the sell.",
|
||||
"minBuyAmount": "The minimum amount of output tokens that must be bought for this function to not revert.",
|
||||
"tokens": "The sequence of tokens to use for the sell, i.e. `tokens[i]` will be sold for `tokens[i+1]` via `calls[i]`."
|
||||
},
|
||||
"returns": { "boughtAmount": "The amount of output tokens bought." }
|
||||
},
|
||||
"multiplexMultiHopSellTokenForEth(address[],(uint8,bytes)[],uint256,uint256)": {
|
||||
"details": "Sells `sellAmount` of the input token (`tokens[0]`) for ETH via the given sequence of tokens and calls. The last token in `tokens` must be WETH.",
|
||||
"params": {
|
||||
"calls": "The sequence of calls to use for the sell.",
|
||||
"minBuyAmount": "The minimum amount of ETH that must be bought for this function to not revert.",
|
||||
"tokens": "The sequence of tokens to use for the sell, i.e. `tokens[i]` will be sold for `tokens[i+1]` via `calls[i]`."
|
||||
},
|
||||
"returns": { "boughtAmount": "The amount of ETH bought." }
|
||||
},
|
||||
"multiplexMultiHopSellTokenForToken(address[],(uint8,bytes)[],uint256,uint256)": {
|
||||
"details": "Sells `sellAmount` of the input token (`tokens[0]`) via the given sequence of tokens and calls. The last token in `tokens` is the output token that will ultimately be sent to `msg.sender`",
|
||||
"params": {
|
||||
"calls": "The sequence of calls to use for the sell.",
|
||||
"minBuyAmount": "The minimum amount of output tokens that must be bought for this function to not revert.",
|
||||
"tokens": "The sequence of tokens to use for the sell, i.e. `tokens[i]` will be sold for `tokens[i+1]` via `calls[i]`."
|
||||
},
|
||||
"returns": { "boughtAmount": "The amount of output tokens bought." }
|
||||
},
|
||||
"owner()": {
|
||||
"details": "The owner of this contract.",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contract-artifacts",
|
||||
"version": "3.15.1",
|
||||
"version": "3.16.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "13.18.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update IZeroEx and ITransformERC20 wrappers",
|
||||
"pr": 282
|
||||
}
|
||||
],
|
||||
"timestamp": 1632957537
|
||||
},
|
||||
{
|
||||
"timestamp": 1631710679,
|
||||
"version": "13.17.7",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v13.18.0 - _September 29, 2021_
|
||||
|
||||
* Update IZeroEx and ITransformERC20 wrappers (#282)
|
||||
|
||||
## v13.17.7 - _September 15, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contract-wrappers",
|
||||
"version": "13.17.7",
|
||||
"version": "13.18.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
|
@@ -269,12 +269,12 @@ export class ITransformERC20Contract extends BaseContract {
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'callDataHash',
|
||||
type: 'bytes32',
|
||||
name: 'useSelfBalance',
|
||||
type: 'bool',
|
||||
},
|
||||
{
|
||||
name: 'callDataSignature',
|
||||
type: 'bytes',
|
||||
name: 'recipient',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -497,13 +497,13 @@ export class ITransformERC20Contract extends BaseContract {
|
||||
inputTokenAmount: BigNumber;
|
||||
minOutputTokenAmount: BigNumber;
|
||||
transformations: Array<{ deploymentNonce: number | BigNumber; data: string }>;
|
||||
callDataHash: string;
|
||||
callDataSignature: string;
|
||||
useSelfBalance: boolean;
|
||||
recipient: string;
|
||||
}): ContractTxFunctionObj<BigNumber> {
|
||||
const self = (this as any) as ITransformERC20Contract;
|
||||
|
||||
const functionSignature =
|
||||
'_transformERC20((address,address,address,uint256,uint256,(uint32,bytes)[],bytes32,bytes))';
|
||||
'_transformERC20((address,address,address,uint256,uint256,(uint32,bytes)[],bool,address))';
|
||||
|
||||
return {
|
||||
async sendTransactionAsync(
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -126,7 +126,6 @@ export {
|
||||
IZeroExContract,
|
||||
IZeroExEventArgs,
|
||||
IZeroExEvents,
|
||||
IZeroExExpiredRfqOrderEventArgs,
|
||||
IZeroExLiquidityProviderSwapEventArgs,
|
||||
IZeroExMetaTransactionExecutedEventArgs,
|
||||
IZeroExMigratedEventArgs,
|
||||
|
@@ -1,4 +1,22 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1633374058,
|
||||
"version": "8.1.8",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1632957537,
|
||||
"version": "8.1.7",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1631710679,
|
||||
"version": "8.1.6",
|
||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v8.1.8 - _October 4, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v8.1.7 - _September 29, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v8.1.6 - _September 15, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/migrations",
|
||||
"version": "8.1.6",
|
||||
"version": "8.1.8",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -81,7 +81,7 @@
|
||||
"@0x/contracts-multisig": "^4.1.38",
|
||||
"@0x/contracts-staking": "^2.0.45",
|
||||
"@0x/contracts-utils": "^4.8.1",
|
||||
"@0x/contracts-zero-ex": "^0.28.5",
|
||||
"@0x/contracts-zero-ex": "^0.29.1",
|
||||
"@0x/sol-compiler": "^4.7.5",
|
||||
"@0x/subproviders": "^6.6.0",
|
||||
"@0x/typescript-typings": "^5.2.1",
|
||||
|
@@ -1,4 +1,22 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1633374058,
|
||||
"version": "1.9.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1632957537,
|
||||
"version": "1.9.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "1.9.0",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.9.2 - _October 4, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.9.1 - _September 29, 2021_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.9.0 - _September 15, 2021_
|
||||
|
||||
* Add 'TreasuryVote' class
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/protocol-utils",
|
||||
"version": "1.9.0",
|
||||
"version": "1.9.2",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -64,7 +64,7 @@
|
||||
"dependencies": {
|
||||
"@0x/assert": "^3.0.29",
|
||||
"@0x/contract-addresses": "^6.7.0",
|
||||
"@0x/contract-wrappers": "^13.17.7",
|
||||
"@0x/contract-wrappers": "^13.18.0",
|
||||
"@0x/json-schemas": "^6.3.0",
|
||||
"@0x/subproviders": "^6.6.0",
|
||||
"@0x/utils": "^6.4.4",
|
||||
|
@@ -131,7 +131,7 @@ export enum BridgeProtocol {
|
||||
KyberDmm,
|
||||
CurveV2,
|
||||
Lido,
|
||||
Clipper,
|
||||
Clipper, // Not used: Clipper is now using PLP interface
|
||||
}
|
||||
// tslint:enable: enum-naming
|
||||
|
||||
|
82
yarn.lock
82
yarn.lock
@@ -871,21 +871,6 @@
|
||||
ethereum-types "^3.5.0"
|
||||
ethereumjs-util "^7.0.10"
|
||||
|
||||
"@0x/contracts-zero-ex@^0.27.1":
|
||||
version "0.27.1"
|
||||
resolved "https://registry.yarnpkg.com/@0x/contracts-zero-ex/-/contracts-zero-ex-0.27.1.tgz#968fe9d8134972cb464f7c4a33c4e4089ba9218e"
|
||||
integrity sha512-IDc0pmMtl/92hkhOqlu+dDyIvLtGtwjjE/kdS6x+jwOyNG8sn5sbkwZ3u3PbHk72dND7E0I7BBY9VEXTB1PY/Q==
|
||||
dependencies:
|
||||
"@0x/base-contract" "^6.4.0"
|
||||
"@0x/protocol-utils" "^1.8.1"
|
||||
"@0x/subproviders" "^6.5.3"
|
||||
"@0x/types" "^3.3.3"
|
||||
"@0x/typescript-typings" "^5.2.0"
|
||||
"@0x/utils" "^6.4.3"
|
||||
"@0x/web3-wrapper" "^7.5.3"
|
||||
ethereum-types "^3.5.0"
|
||||
ethereumjs-util "^7.0.10"
|
||||
|
||||
"@0x/dev-utils@^4.2.9":
|
||||
version "4.2.9"
|
||||
resolved "https://registry.yarnpkg.com/@0x/dev-utils/-/dev-utils-4.2.9.tgz#b048b139b0055ef3702682c42ccc2a3788a49f5d"
|
||||
@@ -974,6 +959,13 @@
|
||||
typedoc "~0.16.11"
|
||||
yargs "^10.0.3"
|
||||
|
||||
"@0x/neon-router@^0.1.3":
|
||||
version "0.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@0x/neon-router/-/neon-router-0.1.3.tgz#70da4c17ca4b59dfe8b5e539673e364a70e62ebd"
|
||||
integrity sha512-EfdrG829NalYjAK5/nMTD6YyJQgUzgssL2Hvyphu1ugWxWlZ3QMM9qpZsKt82hUiyZT/64I4JJ3hkerMhTaHeg==
|
||||
dependencies:
|
||||
"@mapbox/node-pre-gyp" "^1.0.5"
|
||||
|
||||
"@0x/order-utils@^10.2.4", "@0x/order-utils@^10.4.28":
|
||||
version "10.4.28"
|
||||
resolved "https://registry.yarnpkg.com/@0x/order-utils/-/order-utils-10.4.28.tgz#c7b2f7d87a7f9834f9aa6186fbac68f32a05a81d"
|
||||
@@ -1115,35 +1107,6 @@
|
||||
solc "^0.5.5"
|
||||
solidity-parser-antlr "^0.4.2"
|
||||
|
||||
"@0x/subproviders@^6.5.3":
|
||||
version "6.5.3"
|
||||
resolved "https://registry.yarnpkg.com/@0x/subproviders/-/subproviders-6.5.3.tgz#aec86903527c8f972beec1bc2fbda5fdba361235"
|
||||
dependencies:
|
||||
"@0x/assert" "^3.0.27"
|
||||
"@0x/types" "^3.3.3"
|
||||
"@0x/typescript-typings" "^5.2.0"
|
||||
"@0x/utils" "^6.4.3"
|
||||
"@0x/web3-wrapper" "^7.5.3"
|
||||
"@ethereumjs/common" "^2.2.0"
|
||||
"@ethereumjs/tx" "^3.1.3"
|
||||
"@ledgerhq/hw-app-eth" "^4.3.0"
|
||||
"@ledgerhq/hw-transport-u2f" "4.24.0"
|
||||
"@types/hdkey" "^0.7.0"
|
||||
"@types/node" "12.12.54"
|
||||
"@types/web3-provider-engine" "^14.0.0"
|
||||
bip39 "^2.5.0"
|
||||
bn.js "^4.11.8"
|
||||
ethereum-types "^3.5.0"
|
||||
ethereumjs-util "^7.0.10"
|
||||
ganache-core "^2.13.2"
|
||||
hdkey "^0.7.1"
|
||||
json-rpc-error "2.0.0"
|
||||
lodash "^4.17.11"
|
||||
semaphore-async-await "^1.5.1"
|
||||
web3-provider-engine "14.0.6"
|
||||
optionalDependencies:
|
||||
"@ledgerhq/hw-transport-node-hid" "^4.3.0"
|
||||
|
||||
"@0x/subproviders@^6.6.0":
|
||||
version "6.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@0x/subproviders/-/subproviders-6.6.0.tgz#1743d44ae5e2be9ec48caddbf0f1a580f1672d32"
|
||||
@@ -1442,13 +1405,6 @@
|
||||
web3 "1.2.1"
|
||||
web3-typescript-typings "^0.10.2"
|
||||
|
||||
"@ethereumjs/common@^2.2.0":
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-2.2.0.tgz#850a3e3e594ee707ad8d44a11e8152fb62450535"
|
||||
dependencies:
|
||||
crc-32 "^1.2.0"
|
||||
ethereumjs-util "^7.0.9"
|
||||
|
||||
"@ethereumjs/common@^2.4.0":
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-2.4.0.tgz#2d67f6e6ba22246c5c89104e6b9a119fb3039766"
|
||||
@@ -1457,13 +1413,6 @@
|
||||
crc-32 "^1.2.0"
|
||||
ethereumjs-util "^7.1.0"
|
||||
|
||||
"@ethereumjs/tx@^3.1.3":
|
||||
version "3.1.4"
|
||||
resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.1.4.tgz#04cf9e9406da5f04a1a26c458744641f4b4b8dd0"
|
||||
dependencies:
|
||||
"@ethereumjs/common" "^2.2.0"
|
||||
ethereumjs-util "^7.0.10"
|
||||
|
||||
"@ethereumjs/tx@^3.3.0":
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.3.0.tgz#14ed1b7fa0f28e1cd61e3ecbdab824205f6a4378"
|
||||
@@ -2531,6 +2480,21 @@
|
||||
semver "^7.3.4"
|
||||
tar "^6.1.0"
|
||||
|
||||
"@mapbox/node-pre-gyp@^1.0.5":
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.5.tgz#2a0b32fcb416fb3f2250fd24cb2a81421a4f5950"
|
||||
integrity sha512-4srsKPXWlIxp5Vbqz5uLfBN+du2fJChBoYn/f2h991WLdk7jUvcSk/McVLSv/X+xQIPI8eGD5GjrnygdyHnhPA==
|
||||
dependencies:
|
||||
detect-libc "^1.0.3"
|
||||
https-proxy-agent "^5.0.0"
|
||||
make-dir "^3.1.0"
|
||||
node-fetch "^2.6.1"
|
||||
nopt "^5.0.0"
|
||||
npmlog "^4.1.2"
|
||||
rimraf "^3.0.2"
|
||||
semver "^7.3.4"
|
||||
tar "^6.1.0"
|
||||
|
||||
"@mrmlnc/readdir-enhanced@^2.2.1":
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
|
||||
@@ -6108,7 +6072,7 @@ ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereum
|
||||
rlp "^2.0.0"
|
||||
safe-buffer "^5.1.1"
|
||||
|
||||
ethereumjs-util@^7.0.10, ethereumjs-util@^7.0.9:
|
||||
ethereumjs-util@^7.0.10:
|
||||
version "7.0.10"
|
||||
resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.0.10.tgz#5fb7b69fa1fda0acc59634cf39d6b0291180fc1f"
|
||||
dependencies:
|
||||
|
Reference in New Issue
Block a user