@@ -36,8 +36,6 @@ contract BatchNoConversionPayments is Ownable {
36
36
batchFeeAmountUSDLimit = 150 * 1e8 represents $150 */
37
37
uint64 public batchFeeAmountUSDLimit;
38
38
39
- /** payerAuthorized is set to true only when needed for batch native conversion */
40
- bool internal payerAuthorized = false ;
41
39
/** transferBackRemainingNativeTokens is set to false only if the payer use batchPayment
42
40
and call both batchNativePayments and batchNativeConversionPayments */
43
41
bool internal transferBackRemainingNativeTokens = true ;
@@ -97,11 +95,10 @@ contract BatchNoConversionPayments is Ownable {
97
95
98
96
/**
99
97
* This contract is non-payable.
100
- * Making a Native payment with conversion requires the contract to accept incoming Native tokens.
101
- * @dev See the end of `paymentNativeConversionProxy.transferWithReferenceAndFee` where the leftover is given back.
98
+ * @dev See the end of `paymentNativeProxy.transferWithReferenceAndFee` where the leftover is given back.
102
99
*/
103
- receive () external payable {
104
- require (payerAuthorized || msg .value == 0 , 'Non-payable ' );
100
+ receive () external payable virtual {
101
+ require (msg .value == 0 , 'Non-payable ' );
105
102
}
106
103
107
104
/**
@@ -178,7 +175,7 @@ contract BatchNoConversionPayments is Ownable {
178
175
179
176
// Batch contract pays the requests thourgh NativeFeeProxy (EthFeeProxy)
180
177
for (uint256 i = 0 ; i < requestDetails.length ; i++ ) {
181
- RequestDetail memory rD = requestDetails[i];
178
+ RequestDetail calldata rD = requestDetails[i];
182
179
require (address (this ).balance >= rD.requestAmount + rD.feeAmount, 'Not enough funds ' );
183
180
amount += rD.requestAmount;
184
181
@@ -248,12 +245,7 @@ contract BatchNoConversionPayments is Ownable {
248
245
249
246
IERC20 requestedToken = IERC20 (requestDetails[0 ].path[0 ]);
250
247
251
- contractAllowanceApprovalTransfer (
252
- requestedToken,
253
- amountAndFee,
254
- batchFeeAmount,
255
- address (paymentErc20Proxy)
256
- );
248
+ transferToContract (requestedToken, amountAndFee, batchFeeAmount, address (paymentErc20Proxy));
257
249
258
250
// Payer pays batch fee amount
259
251
require (
@@ -263,7 +255,7 @@ contract BatchNoConversionPayments is Ownable {
263
255
264
256
// Batch contract pays the requests using Erc20FeeProxy
265
257
for (uint256 i = 0 ; i < requestDetails.length ; i++ ) {
266
- RequestDetail memory rD = requestDetails[i];
258
+ RequestDetail calldata rD = requestDetails[i];
267
259
paymentErc20Proxy.transferFromWithReferenceAndFee (
268
260
rD.path[0 ],
269
261
rD.recipient,
@@ -300,7 +292,7 @@ contract BatchNoConversionPayments is Ownable {
300
292
for (uint256 i = 0 ; i < uTokens.length && uTokens[i].amountAndFee > 0 ; i++ ) {
301
293
uTokens[i].batchFeeAmount = (uTokens[i].batchFeeAmount * batchFee) / feeDenominator;
302
294
IERC20 requestedToken = IERC20 (uTokens[i].tokenAddress);
303
- contractAllowanceApprovalTransfer (
295
+ transferToContract (
304
296
requestedToken,
305
297
uTokens[i].amountAndFee,
306
298
uTokens[i].batchFeeAmount,
@@ -326,7 +318,7 @@ contract BatchNoConversionPayments is Ownable {
326
318
327
319
// Batch contract pays the requests using Erc20FeeProxy
328
320
for (uint256 i = 0 ; i < requestDetails.length ; i++ ) {
329
- RequestDetail memory rD = requestDetails[i];
321
+ RequestDetail calldata rD = requestDetails[i];
330
322
paymentErc20Proxy.transferFromWithReferenceAndFee (
331
323
rD.path[0 ],
332
324
rD.recipient,
@@ -344,17 +336,19 @@ contract BatchNoConversionPayments is Ownable {
344
336
*/
345
337
346
338
/**
347
- * It:
339
+ * Top up the contract with enough `requestedToken` to pay `amountAndFee`.
340
+ *
341
+ * It also performs a few checks:
348
342
* - checks that the batch contract has enough allowance from the payer
349
- * - checks that the payer has enough fund, including batch fees
350
- * - does the transfer of token from the payer to the batch contract
343
+ * - checks that the payer has enough funds, including batch fees
351
344
* - increases the allowance of the contract to use the payment proxy if needed
345
+ *
352
346
* @param requestedToken The token to pay
353
347
* @param amountAndFee The amount and the fee for a token to pay
354
348
* @param batchFeeAmount The batch fee amount for a token to pay
355
349
* @param paymentProxyAddress The payment proxy address used to pay
356
350
*/
357
- function contractAllowanceApprovalTransfer (
351
+ function transferToContract (
358
352
IERC20 requestedToken ,
359
353
uint256 amountAndFee ,
360
354
uint256 batchFeeAmount ,
@@ -400,7 +394,7 @@ contract BatchNoConversionPayments is Ownable {
400
394
uTokens = new Token [](requestDetails.length );
401
395
for (uint256 i = 0 ; i < requestDetails.length ; i++ ) {
402
396
for (uint256 k = 0 ; k < requestDetails.length ; k++ ) {
403
- RequestDetail memory rD = requestDetails[i];
397
+ RequestDetail calldata rD = requestDetails[i];
404
398
// If the token is already in the existing uTokens list
405
399
if (uTokens[k].tokenAddress == rD.path[rD.path.length - 1 ]) {
406
400
if (rD.path.length > 1 ) {
0 commit comments