* v4 FillQuoteTransformer (#104) * Update FQT to support v4 orders * `@0x/contracts-zero-ex`: Tweak FQT `@0x/contracts-zero-ex`: Drop `ERC20BridgeTransfer` event and add `PartialQuoteFill` event. * `@0x/contracts-utils`: Add `LibSafeMathV06.downcastToUint128()` * `@0x/protocol-utils`: Update transformer utils for V4 FQT * `@0x/contracts-zero-ex`: Fixing FQT tests... * `@0x/contracts-zero-ex`: rename FQT bridge event * `@0x/contracts-zero-ex`: Un-`only` tests * `@0x/migrations`: Update `BridgeAdapter` deployment * `@0x/contracts-integrations`: Delete `mtx_tests` * `@0x/protocol-utils`: Address review comments * `@0x/contracts-zero-ex`: Address review comments * `@0x/migrations`: Update migrations Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com> Co-authored-by: Lawrence Forman <me@merklejerk.com> * v4: Asset-swapper (main branch) (#113) * refactor quote_requestor * WIP v4/asset-swapper: Clean up SwapQuoter and remove @0x/orderbook * Start replacing SignedOrder everywhere * wip: new order type * wip * remove order-utils from most places * hack: Play around with VerboseX types (#119) * hack: Play around with VerboseX types * More hacks * Fix up the bridgeData encodings * Rework Orderbook return type * feat: Don't charge a protocol fee for RFQ orders WIP (#121) * fix simple build errors * simplify types a little * remove SwapQuoteCalculator: unnecessary abstraction * Fix all ./src build errors; make types consistent * export more types for use in 0x API; modify Orderbook interface * stop overriding APIOrder * feat: RFQ v4 + consolidated bridge encoders (#125) * feat: check if taker address is contract * Rework bridge data * Worst case adjustments * RFQT v4 * Future/v4 validate orders (#126) * RFQT v4 * v4 validate native orders * use default invalid signature * refactor rfqt validations in swap quoter * fix types * fix RFQT unlisted api key * remove priceAwareRFQFlag * adjust maker/taker amounts * update JSON schemas * filter zero fillable orders Co-authored-by: xianny <xianny@gmail.com> * fix type export Co-authored-by: xianny <xianny@gmail.com> * remove order-utils as much as possible * work on tests compile * Comment out quote reporter test * updated tests * restore order-utils accidental changes * some lints * Remove old fill_test * ts lint disable for now * update quote report * Re-enable quote report tests * make fill data required field * fix lint * type guards * force fillData as required * fix lint * fix naming * exports * adjust MultiBridge by slippage * cleanups (checkpoint 1) * cleanup types (checkpoint #2) * remove unused deps * `@0x/contract-addresses`: Deploy new FQT (#129) Co-authored-by: Lawrence Forman <me@merklejerk.com> * commit bump to republish * DRY up the rfqt mocker * fix: Balancer load top pools (#131) * fix: Balancer load top 250 pools * refetch top pools on an interval Co-authored-by: Jacob Evans <jacob@dekz.net> Co-authored-by: Kim Persson <kimpers@users.noreply.github.com> Co-authored-by: Lawrence Forman <lawrence@0xproject.com> Co-authored-by: Lawrence Forman <me@merklejerk.com> * Update post rebase * prettier * Remove test helpers exported in asset-swapper * Clean up from review comments * prettier * lint * recreate rfqt mocker * change merge and INVALID_SIGNATURE Co-authored-by: Lawrence Forman <lawrence@0xproject.com> Co-authored-by: Michael Zhu <mchl.zhu.96@gmail.com> Co-authored-by: Lawrence Forman <me@merklejerk.com> Co-authored-by: Xianny <8582774+xianny@users.noreply.github.com> Co-authored-by: Kim Persson <kimpers@users.noreply.github.com>
134 lines
4.0 KiB
Solidity
134 lines
4.0 KiB
Solidity
// SPDX-License-Identifier: Apache-2.0
|
|
/*
|
|
|
|
Copyright 2020 ZeroEx Intl.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
pragma solidity ^0.6.5;
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
|
|
|
|
|
|
contract TestLiquidityProvider {
|
|
event SellTokenForToken(
|
|
address inputToken,
|
|
address outputToken,
|
|
address recipient,
|
|
uint256 minBuyAmount,
|
|
uint256 inputTokenBalance
|
|
);
|
|
|
|
event SellEthForToken(
|
|
address outputToken,
|
|
address recipient,
|
|
uint256 minBuyAmount,
|
|
uint256 ethBalance
|
|
);
|
|
|
|
event SellTokenForEth(
|
|
address inputToken,
|
|
address recipient,
|
|
uint256 minBuyAmount,
|
|
uint256 inputTokenBalance
|
|
);
|
|
|
|
IERC20TokenV06 public immutable xAsset;
|
|
IERC20TokenV06 public immutable yAsset;
|
|
|
|
constructor(IERC20TokenV06 xAsset_, IERC20TokenV06 yAsset_)
|
|
public
|
|
{
|
|
xAsset = xAsset_;
|
|
yAsset = yAsset_;
|
|
}
|
|
|
|
receive() external payable {}
|
|
|
|
/// @dev Trades `inputToken` for `outputToken`. The amount of `inputToken`
|
|
/// to sell must be transferred to the contract prior to calling this
|
|
/// function to trigger the trade.
|
|
/// @param inputToken The token being sold.
|
|
/// @param outputToken The token being bought.
|
|
/// @param recipient The recipient of the bought tokens.
|
|
/// @param minBuyAmount The minimum acceptable amount of `outputToken` to buy.
|
|
/// @return boughtAmount The amount of `outputToken` bought.
|
|
function sellTokenForToken(
|
|
address inputToken,
|
|
address outputToken,
|
|
address recipient,
|
|
uint256 minBuyAmount,
|
|
bytes calldata // auxiliaryData
|
|
)
|
|
external
|
|
returns (uint256 boughtAmount)
|
|
{
|
|
emit SellTokenForToken(
|
|
inputToken,
|
|
outputToken,
|
|
recipient,
|
|
minBuyAmount,
|
|
IERC20TokenV06(inputToken).balanceOf(address(this))
|
|
);
|
|
}
|
|
|
|
/// @dev Trades ETH for token. ETH must be sent to the contract prior to
|
|
/// calling this function to trigger the trade.
|
|
/// @param outputToken The token being bought.
|
|
/// @param recipient The recipient of the bought tokens.
|
|
/// @param minBuyAmount The minimum acceptable amount of `outputToken` to buy.
|
|
/// @return boughtAmount The amount of `outputToken` bought.
|
|
function sellEthForToken(
|
|
address outputToken,
|
|
address recipient,
|
|
uint256 minBuyAmount,
|
|
bytes calldata // auxiliaryData
|
|
)
|
|
external
|
|
returns (uint256 boughtAmount)
|
|
{
|
|
emit SellEthForToken(
|
|
outputToken,
|
|
recipient,
|
|
minBuyAmount,
|
|
address(this).balance
|
|
);
|
|
}
|
|
|
|
/// @dev Trades token for ETH. The token must be sent to the contract prior
|
|
/// to calling this function to trigger the trade.
|
|
/// @param inputToken The token being sold.
|
|
/// @param recipient The recipient of the bought tokens.
|
|
/// @param minBuyAmount The minimum acceptable amount of ETH to buy.
|
|
/// @return boughtAmount The amount of ETH bought.
|
|
function sellTokenForEth(
|
|
address inputToken,
|
|
address payable recipient,
|
|
uint256 minBuyAmount,
|
|
bytes calldata // auxiliaryData
|
|
)
|
|
external
|
|
returns (uint256 boughtAmount)
|
|
{
|
|
emit SellTokenForEth(
|
|
inputToken,
|
|
recipient,
|
|
minBuyAmount,
|
|
IERC20TokenV06(inputToken).balanceOf(address(this))
|
|
);
|
|
}
|
|
}
|