@@ -37,6 +37,7 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
37
37
uint256 public settlementTimeout; // Time in seconds a party can take to accept or propose a settlement before being considered unresponsive.
38
38
Transaction[] public transactions; // List of all created transactions.
39
39
mapping (uint256 => uint256 ) public disputeIDtoTransactionID; // Naps dispute ID to tx ID.
40
+ mapping (IERC20 => uint256 ) public amountCaps; // Caps the amount of the respective token for the Escrow transaction.
40
41
41
42
// ************************************* //
42
43
// * Function Modifiers * //
@@ -47,6 +48,11 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
47
48
_;
48
49
}
49
50
51
+ modifier shouldNotExceedCap (IERC20 _token , uint256 _amount ) {
52
+ if (amountCaps[_token] != 0 && _amount > amountCaps[_token]) revert AmountExceedsCap ();
53
+ _;
54
+ }
55
+
50
56
// ************************************* //
51
57
// * Constructor * //
52
58
// ************************************* //
@@ -117,6 +123,10 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
117
123
emit ParameterUpdated (feeTimeout, _settlementTimeout, arbitratorExtraData);
118
124
}
119
125
126
+ function changeAmountCap (IERC20 _token , uint256 _amountCap ) external onlyByGovernor {
127
+ amountCaps[_token] = _amountCap;
128
+ }
129
+
120
130
// ************************************* //
121
131
// * State Modifiers * //
122
132
// ************************************* //
@@ -126,7 +136,7 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
126
136
uint256 _deadline ,
127
137
string memory _transactionUri ,
128
138
address payable _seller
129
- ) external payable override returns (uint256 transactionID ) {
139
+ ) external payable override shouldNotExceedCap (NATIVE, msg . value ) returns (uint256 transactionID ) {
130
140
Transaction storage transaction = transactions.push ();
131
141
transaction.buyer = payable (msg .sender );
132
142
transaction.seller = _seller;
@@ -153,7 +163,7 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
153
163
uint256 _deadline ,
154
164
string memory _transactionUri ,
155
165
address payable _seller
156
- ) external override returns (uint256 transactionID ) {
166
+ ) external override shouldNotExceedCap (_token, _amount) returns (uint256 transactionID ) {
157
167
// Transfers token from sender wallet to contract.
158
168
if (! _token.safeTransferFrom (msg .sender , address (this ), _amount)) revert TokenTransferFailed ();
159
169
Transaction storage transaction = transactions.push ();
0 commit comments