Skip to content

Commit a8a2825

Browse files
[Protocol3] add ProtocolFeesUpdated event (#258)
* [Protocol3] add event: ProtocolFeeChanged * update
1 parent e489257 commit a8a2825

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

packages/loopring_v3/contracts/iface/IExchange.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ contract IExchange
114114
uint96 amount
115115
);
116116

117+
event ProtocolFeesUpdated(
118+
uint8 takerFeeBips,
119+
uint8 makerFeeBips,
120+
uint8 previousTakerFeeBips,
121+
uint8 previousMakerFeeBips
122+
);
123+
117124
// -- Settings --
118125
function getGlobalSettings()
119126
public

packages/loopring_v3/contracts/impl/libexchange/ExchangeAccounts.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import "./ExchangeData.sol";
2727
/// @author Brecht Devos - <[email protected]>
2828
library ExchangeAccounts
2929
{
30-
using AddressUtil for address payable;
3130
using MathUint for uint;
3231
using ExchangeBalances for ExchangeData.State;
3332

packages/loopring_v3/contracts/impl/libexchange/ExchangeBlocks.sol

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ library ExchangeBlocks
5252
uint indexed blockIdx
5353
);
5454

55+
event ProtocolFeesUpdated(
56+
uint8 takerFeeBips,
57+
uint8 makerFeeBips,
58+
uint8 previousTakerFeeBips,
59+
uint8 previousMakerFeeBips
60+
);
61+
5562
function commitBlock(
5663
ExchangeData.State storage S,
5764
uint8 blockType,
@@ -260,7 +267,7 @@ library ExchangeBlocks
260267
"INVALID_TIMESTAMP"
261268
);
262269
require(
263-
validateProtocolFeeValues(S, protocolTakerFeeBips, protocolMakerFeeBips),
270+
validateAndUpdateProtocolFeeValues(S, protocolTakerFeeBips, protocolMakerFeeBips),
264271
"INVALID_PROTOCOL_FEES"
265272
);
266273
} else if (blockType == ExchangeData.BlockType.DEPOSIT) {
@@ -388,7 +395,7 @@ library ExchangeBlocks
388395
emit BlockCommitted(S.blocks.length - 1, publicDataHash);
389396
}
390397

391-
function validateProtocolFeeValues(
398+
function validateAndUpdateProtocolFeeValues(
392399
ExchangeData.State storage S,
393400
uint8 takerFeeBips,
394401
uint8 makerFeeBips
@@ -407,6 +414,18 @@ library ExchangeBlocks
407414
S.onchainDataAvailability
408415
);
409416
data.timestamp = uint32(now);
417+
418+
bool feeUpdated = (data.takerFeeBips != data.previousTakerFeeBips) ||
419+
(data.makerFeeBips != data.previousMakerFeeBips);
420+
421+
if (feeUpdated) {
422+
emit ProtocolFeesUpdated(
423+
data.takerFeeBips,
424+
data.makerFeeBips,
425+
data.previousTakerFeeBips,
426+
data.previousMakerFeeBips
427+
);
428+
}
410429
}
411430
// The given fee values are valid if they are the current or previous protocol fee values
412431
return (takerFeeBips == data.takerFeeBips && makerFeeBips == data.makerFeeBips) ||

0 commit comments

Comments
 (0)