Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [unreleased]

### Added
- ```tradeFor``` function to allow forwarder contracts.

### Changed
- Using new [Signature Validator](https://github.com/DexyProject/SignatureValidator) package.

Expand Down
33 changes: 33 additions & 0 deletions contracts/Exchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ contract Exchange is Ownable, ExchangeInterface {
using OrderLibrary for OrderLibrary.Order;
using ExchangeLibrary for ExchangeLibrary.Exchange;

bytes32 constant public TAKER_HASH_SCHEME = keccak256(
"uint Maximum Fill Amount",
"uint Nonce"
);

address constant public ETH = 0x0;

uint256 constant public MAX_FEE = 5000000000000000; // 0.5% ((0.5 / 100) * 10**18)
Expand Down Expand Up @@ -59,6 +64,34 @@ contract Exchange is Ownable, ExchangeInterface {
exchange.trade(OrderLibrary.createOrder(addresses, values), msg.sender, signature, maxFillAmount);
}

// @todo new name
/// @dev Takes order on behalf of a user.
/// @param addresses Array of trade's maker, makerToken and takerToken.
/// @param values Array of trade's makerTokenAmount, takerTokenAmount, expires and nonce.
/// @param signature Signed order along with signature mode.
/// @param maxFillAmount Maximum amount of the order to be filled.
/// @param nonce Random taker nonce.
/// @param takerSig Taker signature.
function tradeFor(
address[3] addresses,
uint[4] values,
bytes signature,
uint maxFillAmount,
uint nonce,
bytes takerSig
)
external
{
bytes32 hash = keccak256(TAKER_HASH_SCHEME, keccak256(maxFillAmount, nonce));

exchange.trade(
OrderLibrary.createOrder(addresses, values),
SignatureValidator.recover(hash, takerSig),
signature,
maxFillAmount
);
}

/// @dev Cancels an order.
/// @param addresses Array of trade's maker, makerToken and takerToken.
/// @param values Array of trade's makerTokenAmount, takerTokenAmount, expires and nonce.
Expand Down
26 changes: 26 additions & 0 deletions contracts/Forwarders/ForwarderInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pragma solidity ^0.4.18;

interface ForwarderInterface {

/// @dev Takes order on behalf of a user.
/// @param addresses Array of trade's maker, makerToken and takerToken.
/// @param values Array of trade's makerTokenAmount, takerTokenAmount, expires and nonce.
/// @param sig Signed order along with signature mode.
/// @param maxFillAmount Maximum amount of the order to be filled.
/// @param nonce Random taker nonce.
/// @param takerSig Taker signature, taker address MUST be derived from this signature.
function trade(
address[3] addresses,
uint[4] values,
bytes sig,
uint maxFillAmount,
uint nonce,
bytes takerSig
) external;

/// @dev Returns if a user is permitted to take orders.
/// @param user Address of the user
/// @return Bool whether user can trade.
function isPermitted(address user) public view returns (bool);

}
Loading