Skip to content

Instantly share code, notes, and snippets.

@BlinkyStitt
Created February 27, 2019 01:08
Show Gist options
  • Save BlinkyStitt/e3a5eeee8e11983b603dc7e28243c0f2 to your computer and use it in GitHub Desktop.
Save BlinkyStitt/e3a5eeee8e11983b603dc7e28243c0f2 to your computer and use it in GitHub Desktop.
pragma solidity 0.5.4;
// TODO: https://github.com/0xProject/dev-tools-truffle-example/issues/4#issuecomment-467639079
pragma experimental ABIEncoderV2;
/*
https://solidity.readthedocs.io/en/v0.5.0/050-breaking-changes.html#interoperability-with-older-contracts
https://github.com/0xProject/0x-monorepo/blob/development/contracts/exchange/contracts/src/interfaces/IExchange.sol
TODO: i don't think changing types will work. that changes the call signature. i need the original types for this to work!
*/
interface IZrxExchange {
// from "./IExchangeCore.sol";
/// @dev Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch
/// and senderAddress equal to msg.sender (or null address if msg.sender == makerAddress).
/// @param targetOrderEpoch Orders created with a salt less or equal to this value will be cancelled.
function cancelOrdersUpTo(uint256 targetOrderEpoch) external;
/// @dev Fills the input order.
/// @param order Order struct containing order specifications.
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
/// @param signature Proof that order has been created by maker.
/// @return Amounts filled and fees paid by maker and taker.
function fillOrder(
// LibOrder.Order memory order,
bytes calldata order,
uint256 takerAssetFillAmount,
bytes calldata signature
)
external
returns (
// returns (LibFillResults.FillResults memory fillResults);
bytes memory fillResults
);
/// @dev After calling, the order can not be filled anymore.
/// @param order Order struct containing order specifications.
// function cancelOrder(LibOrder.Order memory order)
function cancelOrder(bytes calldata order) external;
/// @dev Gets information about an order: status, hash, and amount filled.
/// @param order Order to gather information on.
/// @return OrderInfo Information about the order and its state.
/// See LibOrder.OrderInfo for a complete description.
// function getOrderInfo(LibOrder.Order memory order)
function getOrderInfo(bytes calldata order)
external
view
returns (
// returns (LibOrder.OrderInfo memory orderInfo);
bytes memory orderInfo
);
// from "./IMatchOrders.sol";
/// @dev Match two complementary orders that have a profitable spread.
/// Each order is filled at their respective price point. However, the calculations are
/// carried out as though the orders are both being filled at the right order's price point.
/// The profit made by the left order goes to the taker (who matched the two orders).
/// @param leftOrder First order to match.
/// @param rightOrder Second order to match.
/// @param leftSignature Proof that order was created by the left maker.
/// @param rightSignature Proof that order was created by the right maker.
/// @return matchedFillResults Amounts filled and fees paid by maker and taker of matched orders.
function matchOrders(
// LibOrder.Order memory leftOrder,
// LibOrder.Order memory rightOrder,
bytes calldata leftOrder,
bytes calldata rightOrder,
bytes calldata leftSignature,
bytes calldata rightSignature
)
external
returns (
// returns (LibFillResults.MatchedFillResults memory matchedFillResults);
bytes memory matchedFillResults
);
// from "./ISignatureValidator.sol";
// from "./ITransactions.sol";
/// @dev Executes an exchange method call in the context of signer.
/// @param salt Arbitrary number to ensure uniqueness of transaction hash.
/// @param signerAddress Address of transaction signer.
/// @param data AbiV2 encoded calldata.
/// @param signature Proof of signer transaction by signer.
function executeTransaction(uint256 salt, address signerAddress, bytes calldata data, bytes calldata signature)
external;
// from "./IAssetProxyDispatcher.sol";
// from "./IWrapperFunctions.sol";
/// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.
/// @param order LibOrder.Order struct containing order specifications.
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
/// @param signature Proof that order has been created by maker.
function fillOrKillOrder(
// LibOrder.Order calldata order,
bytes calldata order,
uint256 takerAssetFillAmount,
bytes calldata signature
)
external
returns (
// returns (LibFillResults.FillResults memory fillResults);
bytes memory fillResults
);
/// @dev Fills an order with specified parameters and ECDSA signature.
/// Returns false if the transaction would otherwise revert.
/// @param order LibOrder.Order struct containing order specifications.
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
/// @param signature Proof that order has been created by maker.
/// @return Amounts filled and fees paid by maker and taker.
function fillOrderNoThrow(
// LibOrder.Order calldata order,
bytes calldata order,
uint256 takerAssetFillAmount,
bytes calldata signature
)
external
returns (
// returns (LibFillResults.FillResults memory fillResults);
bytes memory fillResults
);
/// @dev Synchronously executes multiple calls of fillOrder.
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
function batchFillOrders(
// LibOrder.Order[] calldata orders,
bytes[] calldata orders,
uint256[] calldata takerAssetFillAmounts,
bytes[] calldata signatures
)
external
returns (
// returns (LibFillResults.FillResults memory totalFillResults);
bytes memory totalFillResults
);
/// @dev Synchronously executes multiple calls of fillOrKill.
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
function batchFillOrKillOrders(
// LibOrder.Order[] calldata orders,
bytes[] calldata orders,
uint256[] calldata takerAssetFillAmounts,
bytes[] calldata signatures
)
external
returns (
// returns (LibFillResults.FillResults memory totalFillResults);
bytes memory totalFillResults
);
/// @dev Fills an order with specified parameters and ECDSA signature.
/// Returns false if the transaction would otherwise revert.
/// @param orders Array of order specifications.
/// @param takerAssetFillAmounts Array of desired amounts of takerAsset to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
function batchFillOrdersNoThrow(
// LibOrder.Order[] calldata orders,
bytes[] calldata orders,
uint256[] calldata takerAssetFillAmounts,
bytes[] calldata signatures
)
external
returns (
// returns (LibFillResults.FillResults memory totalFillResults);
bytes memory totalFillResults
);
/// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.
/// @param orders Array of order specifications.
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
function marketSellOrders(bytes[] calldata orders, uint256 takerAssetFillAmount, bytes[] calldata signatures)
external
returns (
// returns (LibFillResults.FillResults memory totalFillResults);
bytes memory totalFillResults
);
/// @dev Synchronously executes multiple calls of fillOrder until total amount of takerAsset is sold by taker.
/// Returns false if the transaction would otherwise revert.
/// @param orders Array of order specifications.
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
/// @param signatures Proofs that orders have been signed by makers.
/// @return Amounts filled and fees paid by makers and taker.
function marketSellOrdersNoThrow(
// LibOrder.Order[] memory orders,
bytes[] calldata orders,
uint256 takerAssetFillAmount,
bytes[] calldata signatures
)
external
returns (
// returns (LibFillResults.FillResults memory totalFillResults);
bytes memory totalFillResults
);
/// @dev Synchronously executes multiple calls of fillOrder until total amount of makerAsset is bought by taker.
/// @param orders Array of order specifications.
/// @param makerAssetFillAmount Desired amount of makerAsset to buy.
/// @param signatures Proofs that orders have been signed by makers.
/// @return Amounts filled and fees paid by makers and taker.
function marketBuyOrders(
// LibOrder.Order[] memory orders,
bytes[] calldata orders,
uint256 makerAssetFillAmount,
bytes[] calldata signatures
)
external
returns (
// returns (LibFillResults.FillResults memory totalFillResults);
bytes memory totalFillResults
);
/// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.
/// Returns false if the transaction would otherwise revert.
/// @param orders Array of order specifications.
/// @param makerAssetFillAmount Desired amount of makerAsset to buy.
/// @param signatures Proofs that orders have been signed by makers.
/// @return Amounts filled and fees paid by makers and taker.
function marketBuyOrdersNoThrow(
// LibOrder.Order[] memory orders,
bytes[] calldata orders,
uint256 makerAssetFillAmount,
bytes[] calldata signatures
)
external
returns (
// returns (LibFillResults.FillResults memory totalFillResults);
bytes memory totalFillResults
);
/// @dev Synchronously cancels multiple orders in a single transaction.
/// @param orders Array of order specifications.
// function batchCancelOrders(LibOrder.Order[] memory orders)
function batchCancelOrders(bytes[] calldata orders) external;
/// @dev Fetches information for all passed in orders
/// @param orders Array of order specifications.
/// @return Array of OrderInfo instances that correspond to each order.
// function getOrdersInfo(LibOrder.Order[] memory orders)
function getOrdersInfo(bytes calldata orders)
external
view
returns (
// returns (LibOrder.OrderInfo[] memory);
bytes[] memory
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment