@@ -71,9 +71,12 @@ contract BatchConversionPayments is BatchNoConversionPayments {
71
71
* - batchEthConversionPayments, paymentNetworkId=4
72
72
* If metaDetails use paymentNetworkId = 4, it must be at the end of the list, or the transaction can be reverted.
73
73
* @param pathsToUSD The list of paths into USD for every token, used to limit the batch fees.
74
- * Without paths, there is not limitation.
75
- * @param feeAddress The address where fees should be paid
76
- * @dev batchPayment only reduces gas consumption when using more than a single payment network.
74
+ * For batchEth, mock an array of array to apply the limit, e.g: [[]]
75
+ * Without paths, there is not limitation, neither for the batchEth functions.
76
+ * @param feeAddress The address where fees should be paid.
77
+ * @dev Use pathsToUSD only if you are pretty sure the batch fees will higher than the
78
+ * USD limit batchFeeAmountUSDLimit, because it increase gas consumption.
79
+ * batchPayment only reduces gas consumption when using more than a single payment network.
77
80
* For single payment network payments, it is more efficient to use the suited batch function.
78
81
*/
79
82
function batchPayment (
@@ -120,6 +123,7 @@ contract BatchConversionPayments is BatchNoConversionPayments {
120
123
}
121
124
batchFeeAmountUSD += batchEthPayments (
122
125
metaDetail.requestDetails,
126
+ pathsToUSD.length > 0 ,
123
127
batchFeeAmountUSD,
124
128
payable (feeAddress)
125
129
);
@@ -129,6 +133,7 @@ contract BatchConversionPayments is BatchNoConversionPayments {
129
133
} else if (metaDetail.paymentNetworkId == 4 ) {
130
134
batchFeeAmountUSD += batchEthConversionPayments (
131
135
metaDetail.requestDetails,
136
+ pathsToUSD.length > 0 ,
132
137
batchFeeAmountUSD,
133
138
payable (feeAddress)
134
139
);
@@ -226,6 +231,7 @@ contract BatchConversionPayments is BatchNoConversionPayments {
226
231
* @notice Send a batch of ETH conversion payments with fees and paymentReferences to multiple accounts.
227
232
* If one payment fails, the whole batch is reverted.
228
233
* @param requestDetails List of ETH requests denominated in fiat to pay.
234
+ * @param applyFeeLimitUSD It set to true to apply the USD fee limit.
229
235
* @param batchFeeAmountUSD The batch fee amount in USD already paid.
230
236
* @param feeAddress The fee recipient.
231
237
* @dev It uses EthereumConversionProxy to pay an invoice and fees.
@@ -236,11 +242,12 @@ contract BatchConversionPayments is BatchNoConversionPayments {
236
242
*/
237
243
function batchEthConversionPayments (
238
244
RequestDetail[] calldata requestDetails ,
245
+ bool applyFeeLimitUSD ,
239
246
uint256 batchFeeAmountUSD ,
240
247
address payable feeAddress
241
248
) public payable returns (uint256 ) {
242
249
// Avoid the possibility to manually put high value to batchFeeAmountUSD
243
- if (batchPaymentOrigin != true ) {
250
+ if (batchPaymentOrigin != true && applyFeeLimitUSD ) {
244
251
batchFeeAmountUSD = 0 ;
245
252
}
246
253
uint256 contractBalance = address (this ).balance;
@@ -264,12 +271,15 @@ contract BatchConversionPayments is BatchNoConversionPayments {
264
271
uint256 batchFeeToPay = (((contractBalance - address (this ).balance)) * batchFee) /
265
272
feeDenominator;
266
273
267
- (batchFeeToPay, batchFeeAmountUSD) = calculateBatchFeeToPay (
268
- batchFeeToPay,
269
- pathsEthToUSD[0 ][0 ],
270
- batchFeeAmountUSD,
271
- pathsEthToUSD
272
- );
274
+ if (applyFeeLimitUSD == true ) {
275
+ (batchFeeToPay, batchFeeAmountUSD) = calculateBatchFeeToPay (
276
+ batchFeeToPay,
277
+ pathsEthToUSD[0 ][0 ],
278
+ batchFeeAmountUSD,
279
+ pathsEthToUSD
280
+ );
281
+ }
282
+
273
283
require (address (this ).balance >= batchFeeToPay, 'Not enough funds for batch conversion fees ' );
274
284
feeAddress.transfer (batchFeeToPay);
275
285
0 commit comments