@@ -2,13 +2,18 @@ pragma solidity ^0.5.16;
2
2
3
3
import "../ExternStateToken.sol " ;
4
4
import "../interfaces/ISystemStatus.sol " ;
5
+ import "../interfaces/IAddressResolver.sol " ;
6
+ import "../interfaces/IFeePool.sol " ;
5
7
6
8
// Mock synth that also adheres to system status
7
9
8
10
contract MockSynth is ExternStateToken {
9
- ISystemStatus private systemStatus ;
11
+ IAddressResolver private addressResolver ;
10
12
bytes32 public currencyKey;
11
13
14
+ // Where fees are pooled in sUSD
15
+ address public constant FEE_ADDRESS = 0xfeEFEEfeefEeFeefEEFEEfEeFeefEEFeeFEEFEeF ;
16
+
12
17
constructor (
13
18
address payable _proxy ,
14
19
TokenState _tokenState ,
@@ -21,18 +26,49 @@ contract MockSynth is ExternStateToken {
21
26
currencyKey = _currencyKey;
22
27
}
23
28
24
- // Allow SystemStatus to be passed in directly
25
- function setSystemStatus (ISystemStatus _status ) external {
26
- systemStatus = _status;
29
+ function setAddressResolver (IAddressResolver _resolver ) external {
30
+ addressResolver = _resolver;
27
31
}
28
32
29
33
// Used for PurgeableSynth to test removal
30
34
function setTotalSupply (uint256 _totalSupply ) external {
31
35
totalSupply = _totalSupply;
32
36
}
33
37
38
+ /**
39
+ * @notice _transferToFeeAddress function
40
+ * non-sUSD synths are exchanged into sUSD via synthInitiatedExchange
41
+ * notify feePool to record amount as fee paid to feePool */
42
+ function _transferToFeeAddress (address to , uint value ) internal returns (bool ) {
43
+ uint amountInUSD;
44
+
45
+ // sUSD can be transferred to FEE_ADDRESS directly
46
+ if (currencyKey == "sUSD " ) {
47
+ amountInUSD = value;
48
+ _transferByProxy (messageSender, to, value);
49
+ } else {
50
+ // for now, do nothing
51
+ }
52
+
53
+ // Notify feePool to record sUSD to distribute as fees
54
+ IFeePool (addressResolver.getAddress ("FeePool " )).recordFeePaid (amountInUSD);
55
+
56
+ return true ;
57
+ }
58
+
34
59
function transfer (address to , uint value ) external optionalProxy returns (bool ) {
35
- systemStatus.requireSynthActive (currencyKey);
60
+ ISystemStatus (addressResolver.getAddress ("SystemStatus " )).requireSynthActive (currencyKey);
61
+
62
+ // transfers to FEE_ADDRESS will be exchanged into sUSD and recorded as fee
63
+ if (to == FEE_ADDRESS) {
64
+ return _transferToFeeAddress (to, value);
65
+ }
66
+
67
+ // transfers to 0x address will be burned
68
+ if (to == address (0 )) {
69
+ this .burn (messageSender, value);
70
+ return true ;
71
+ }
36
72
37
73
return _transferByProxy (messageSender, to, value);
38
74
}
@@ -42,7 +78,7 @@ contract MockSynth is ExternStateToken {
42
78
address to ,
43
79
uint value
44
80
) external optionalProxy returns (bool ) {
45
- systemStatus .requireSynthActive (currencyKey);
81
+ ISystemStatus (addressResolver. getAddress ( " SystemStatus " )) .requireSynthActive (currencyKey);
46
82
47
83
return _transferFromByProxy (messageSender, from, to, value);
48
84
}
0 commit comments