Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions contracts/core/exchange-wrappers/lib/ZeroExOrderDataHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ library ZeroExOrderDataHandler {
return order;
}

/*
* Takes a 0x order, the makerAsset Data Length, and takerAsset Data length
* and constructs the order in memory
* TODO: Re-encode the 0x order so that makerAssetData and takerAssetData are
* more elegantly put together
*
* @param _zeroExOrder The zeroEx order data
* @param _makerAssetDataLength The length of the maker asset data
* @param _takerAssetDataLength The length of the taker asset data
* @return LibOrder.Order The 0x order
*/
function constructZeroExOrder(
bytes _zeroExOrder,
uint _makerAssetDataLength,
Expand Down Expand Up @@ -181,6 +192,12 @@ library ZeroExOrderDataHandler {
return order;
}

/*
* Takes order data and constructs a 0x order
*
* @param _orderData The order data
* @return LibOrder.Order The 0x order
*/
function parseZeroExOrder(bytes _orderData)
internal
pure
Expand All @@ -197,11 +214,24 @@ library ZeroExOrderDataHandler {
return order;
}

/*
* Takes 0x asset data and retrieves the token address
* The asset data must be ERC20
*
* @param _assetData The 0x Asset data passed through in the order
* @return address The token address retrieved from the asset data
*/
function parseERC20TokenAddress(bytes _assetData)
internal
pure
returns(address)
{
// | Asset Data | Location | Length |
// |----------------------------|----------|--------|
// | selector | 0 | 4 |
// | tokenAddress | 32 | 32 |


bytes4 ERC20_SELECTOR = bytes4(keccak256("ERC20Token(address)"));
// Ensure that the asset is ERC20
bytes4 orderProxyId = _assetData.readBytes4(0);
Expand Down