Skip to content

Commit c72dcbd

Browse files
committed
Merge branch 'v1.1_support_isMakerOnly' into 'v1.1'
V1.1 support is maker only See merge request hydro/protocol!21
2 parents fb5fadd + 161971f commit c72dcbd

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

contracts/HybridExchange.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ contract HybridExchange is LibMath, LibOrder, LibRelayer, LibDiscount, LibExchan
127127
OrderAddressSet memory orderAddressSet
128128
) public {
129129
require(canMatchOrdersFrom(orderAddressSet.relayer), INVALID_SENDER);
130+
require(!isMakerOnly(takerOrderParam.data), MAKER_ONLY_ORDER_CANNOT_BE_TAKER);
130131

131132
bool isParticipantRelayer = isParticipant(orderAddressSet.relayer);
132133
uint256 takerFeeRate = getTakerFeeRate(takerOrderParam, isParticipantRelayer);

contracts/helper/TestOrder.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ contract TestOrder is LibOrder {
3232
function getMakerRebateRateFromOrderDataPublic(bytes32 data) public pure returns (uint256) {
3333
return getMakerRebateRateFromOrderData(data);
3434
}
35+
36+
function isMakerOnlyPublic(bytes32 data) public pure returns (bool) {
37+
return isMakerOnly(data);
38+
}
3539
}

contracts/lib/LibExchangeErrors.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ contract LibExchangeErrors {
3333
string constant MAKER_ORDER_OVER_MATCH = "MAKER_ORDER_OVER_MATCH";
3434
string constant TAKER_ORDER_OVER_MATCH = "TAKER_ORDER_OVER_MATCH";
3535
string constant ORDER_VERSION_NOT_SUPPORTED = "ORDER_VERSION_NOT_SUPPORTED";
36+
37+
string constant MAKER_ONLY_ORDER_CANNOT_BE_TAKER = "MAKER_ONLY_ORDER_CANNOT_BE_TAKER";
3638
}

contracts/lib/LibOrder.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ contract LibOrder is EIP712, LibSignature, LibMath {
4949
* ║ asTakerFeeRate │ 2 taker fee rate (base 100,000) ║
5050
* ║ makerRebateRate │ 2 rebate rate for maker (base 100) ║
5151
* ║ salt │ 8 salt ║
52-
* ║ │ 10 reserved ║
52+
* ║ isMakerOnly │ 1 is maker only ║
53+
* ║ │ 9 reserved ║
5354
* ╚════════════════════╧═══════════════════════════════════════════════════════════╝
5455
*/
5556
bytes32 data;
@@ -141,6 +142,10 @@ contract LibOrder is EIP712, LibSignature, LibMath {
141142
return data[2] == 1;
142143
}
143144

145+
function isMakerOnly(bytes32 data) internal pure returns (bool) {
146+
return data[22] == 1;
147+
}
148+
144149
function isMarketBuy(bytes32 data) internal pure returns (bool) {
145150
return !isSell(data) && isMarketOrder(data);
146151
}

sdk/sdk.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ const generateOrderData = (
4444
asMakerFeeRate,
4545
asTakerFeeRate,
4646
makerRebateRate,
47-
salt
47+
salt,
48+
isMakerOnly
4849
) => {
4950
let res = '0x';
5051
res += addLeadingZero(new BigNumber(version).toString(16), 2);
@@ -55,6 +56,7 @@ const generateOrderData = (
5556
res += addLeadingZero(new BigNumber(asTakerFeeRate).toString(16), 2 * 2);
5657
res += addLeadingZero(new BigNumber(makerRebateRate).toString(16), 2 * 2);
5758
res += addLeadingZero(new BigNumber(salt).toString(16), 8 * 2);
59+
res += isMakerOnly ? '01' : '00';
5860

5961
return addTailingZero(res, 66);
6062
};

test/order_test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ contract('Order', accounts => {
3030
makerFeeRate,
3131
takerFeeRate,
3232
makerRebateRate,
33-
salt
33+
salt,
34+
true
3435
);
3536

3637
// version hex 01
@@ -41,7 +42,8 @@ contract('Order', accounts => {
4142
// 50000 hex c3 50
4243
// makerRebateRate hex 00 00
4344
// 488701836 hex 00 00 00 00 1d 20 ff 8c
44-
assert.equal('0x010100005bbf0d4e2710c3500000000000001d20ff8c00000000000000000000', data);
45+
// isMakerOnly hex 01
46+
assert.equal('0x010100005bbf0d4e2710c3500000000000001d20ff8c01000000000000000000', data);
4547
});
4648

4749
it('should parse out expired at from data', async () => {
@@ -120,4 +122,10 @@ contract('Order', accounts => {
120122
res = await contract.methods.getMakerRebateRateFromOrderDataPublic(data).call();
121123
assert.equal(100, res);
122124
});
125+
126+
it('should parse isMakerOnly', async () => {
127+
let data = generateOrderData(0, 0, 0, 0, 0, 0, 0, 0, true);
128+
let res = await contract.methods.isMakerOnlyPublic(data).call();
129+
assert.equal(true, res);
130+
});
123131
});

0 commit comments

Comments
 (0)