Skip to content

Instantly share code, notes, and snippets.

@tempofeng
Last active July 20, 2018 07:10
Show Gist options
  • Save tempofeng/1b982846876aff2ea92341a7308dd55b to your computer and use it in GitHub Desktop.
Save tempofeng/1b982846876aff2ea92341a7308dd55b to your computer and use it in GitHub Desktop.
contract Exchange is Owned {
function depositToken(address token, address target, uint256 amount) public returns (bool) {
if (target == 0x0) target = msg.sender;
require(acceptDeposit(token, target, amount));
require(Token(token).transferFrom(msg.sender, this, amount));
return true;
}
function deposit(address target) public payable returns (bool) {
if (target == 0x0) target = msg.sender;
require(acceptDeposit(0x0, target, msg.value));
return true;
}
function trade(uint256[8] tradeValues, address[4] tradeAddresses, uint8[2] v, bytes32[4] rs) public onlyAdmin returns (bool) {
/* amount is in amountBuy terms */
/* tradeValues
[0] amountBuy
[1] amountSell
[2] expires
[3] nonce
[4] amount
[5] tradeNonce
[6] feeMake
[7] feeTake
tradeAddressses
[0] tokenBuy
[1] tokenSell
[2] maker
[3] taker
*/
...
bytes32 orderHash = keccak256(this, tradeAddresses[0], tradeValues[0], tradeAddresses[1], tradeValues[1], tradeValues[2], tradeValues[3], tradeAddresses[2]);
bytes32 tradeHash = keccak256(orderHash, tradeValues[4], tradeAddresses[3], tradeValues[5]);
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment