Skip to content

Commit 05cd466

Browse files
committed
rename ETH functions into Native functions
1 parent d2f0cfe commit 05cd466

File tree

9 files changed

+123
-119
lines changed

9 files changed

+123
-119
lines changed

packages/smart-contracts/scripts/test-deploy-batch-conversion-deployment.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { deployOne } from './deploy-one';
44

55
import {
66
batchConversionPaymentsArtifact,
7+
chainlinkConversionPath,
78
erc20ConversionProxy,
89
erc20FeeProxyArtifact,
910
ethConversionArtifact,
@@ -27,8 +28,8 @@ export async function deployBatchConversionPayment(
2728
const _ERC20FeeProxyAddress = erc20FeeProxyArtifact.getAddress('private');
2829
const _EthereumFeeProxyAddress = ethereumFeeProxyArtifact.getAddress('private');
2930
const _paymentErc20ConversionFeeProxy = erc20ConversionProxy.getAddress('private');
30-
const _paymentEthConversionFeeProxy = ethConversionArtifact.getAddress('private');
31-
const _chainlinkConversionPath = '0x4e71920b7330515faf5EA0c690f1aD06a85fB60c';
31+
const _paymentNativeConversionFeeProxy = ethConversionArtifact.getAddress('private');
32+
const _chainlinkConversionPath = chainlinkConversionPath.getAddress('private');
3233

3334
// Deploy BatchConversionPayments contract
3435
const { address: BatchConversionPaymentsAddress } = await deployOne(
@@ -40,7 +41,7 @@ export async function deployBatchConversionPayment(
4041
_ERC20FeeProxyAddress,
4142
_EthereumFeeProxyAddress,
4243
_paymentErc20ConversionFeeProxy,
43-
_paymentEthConversionFeeProxy,
44+
_paymentNativeConversionFeeProxy,
4445
_chainlinkConversionPath,
4546
await (await hre.ethers.getSigners())[0].getAddress(),
4647
],
@@ -78,11 +79,11 @@ export async function deployBatchConversionPayment(
7879
await batchConversion.connect(owner).setBatchFee(30);
7980
await batchConversion
8081
.connect(owner)
81-
.setETHAndUSDAddress(
82+
.setNativeAndUSDAddress(
8283
currencyManager.fromSymbol('ETH')!.hash,
8384
currencyManager.fromSymbol('USD')!.hash,
8485
);
85-
await batchConversion.connect(owner).setBatchFeeAmountUSDLimit(300); // * 1_000_000_000_000_000_000);
86+
await batchConversion.connect(owner).setBatchFeeAmountUSDLimit(150 * 1e8); // 150$
8687

8788
// ----------------------------------
8889
console.log('Contracts deployed');

packages/smart-contracts/src/contracts/BatchConversionPayments.sol

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ contract BatchConversionPayments is BatchNoConversionPayments {
2222
using SafeERC20 for IERC20;
2323

2424
IERC20ConversionProxy public paymentErc20ConversionProxy;
25-
IEthConversionProxy public paymentEthConversionProxy;
25+
IEthConversionProxy public paymentNativeConversionProxy;
2626

2727
/**
2828
* @dev Used by the batchPayment to handle information for heterogeneous batches, grouped by payment network:
@@ -36,29 +36,29 @@ contract BatchConversionPayments is BatchNoConversionPayments {
3636

3737
/**
3838
* @param _paymentErc20Proxy The ERC20 payment proxy address to use.
39-
* @param _paymentEthProxy The ETH payment proxy address to use.
39+
* @param _paymentNativeProxy The native payment proxy address to use.
4040
* @param _paymentErc20ConversionProxy The ERC20 Conversion payment proxy address to use.
41-
* @param _paymentEthConversionFeeProxy The ETH Conversion payment proxy address to use.
41+
* @param _paymentNativeConversionFeeProxy The native Conversion payment proxy address to use.
4242
* @param _chainlinkConversionPathAddress The address of the conversion path contract.
4343
* @param _owner Owner of the contract.
4444
*/
4545
constructor(
4646
address _paymentErc20Proxy,
47-
address _paymentEthProxy,
47+
address _paymentNativeProxy,
4848
address _paymentErc20ConversionProxy,
49-
address _paymentEthConversionFeeProxy,
49+
address _paymentNativeConversionFeeProxy,
5050
address _chainlinkConversionPathAddress,
5151
address _owner
5252
)
5353
BatchNoConversionPayments(
5454
_paymentErc20Proxy,
55-
_paymentEthProxy,
55+
_paymentNativeProxy,
5656
_chainlinkConversionPathAddress,
5757
_owner
5858
)
5959
{
6060
paymentErc20ConversionProxy = IERC20ConversionProxy(_paymentErc20ConversionProxy);
61-
paymentEthConversionProxy = IEthConversionProxy(_paymentEthConversionFeeProxy);
61+
paymentNativeConversionProxy = IEthConversionProxy(_paymentNativeConversionFeeProxy);
6262
}
6363

6464
/**
@@ -67,12 +67,12 @@ contract BatchConversionPayments is BatchNoConversionPayments {
6767
* - batchMultiERC20ConversionPayments, paymentNetworkId=0
6868
* - batchERC20Payments, paymentNetworkId=1
6969
* - batchMultiERC20Payments, paymentNetworkId=2
70-
* - batchEthPayments, paymentNetworkId=3
71-
* - batchEthConversionPayments, paymentNetworkId=4
70+
* - batchNativePayments, paymentNetworkId=3
71+
* - batchNativeConversionPayments, paymentNetworkId=4
7272
* If metaDetails use paymentNetworkId = 4, it must be at the end of the list, or the transaction can be reverted.
7373
* @param pathsToUSD The list of paths into USD for every token, used to limit the batch fees.
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.
74+
* For batch native, mock an array of array to apply the limit, e.g: [[]]
75+
* Without paths, there is not limitation, neither for the batch native functions.
7676
* @param feeAddress The address where fees should be paid.
7777
* @dev Use pathsToUSD only if you are pretty sure the batch fees will higher than the
7878
* USD limit batchFeeAmountUSDLimit, because it increase gas consumption.
@@ -112,20 +112,20 @@ contract BatchConversionPayments is BatchNoConversionPayments {
112112
);
113113
} else if (metaDetail.paymentNetworkId == 3) {
114114
if (metaDetails[metaDetails.length - 1].paymentNetworkId == 4) {
115-
// Set to false only if batchEthConversionPayments is called after this function
116-
transferBackRemainingEth = false;
115+
// Set to false only if batchNativeConversionPayments is called after this function
116+
transferBackRemainingNativeTokens = false;
117117
}
118-
batchFeeAmountUSD += _batchEthPayments(
118+
batchFeeAmountUSD += _batchNativePayments(
119119
metaDetail.requestDetails,
120120
pathsToUSD.length == 0,
121121
batchFeeAmountUSD,
122122
payable(feeAddress)
123123
);
124124
if (metaDetails[metaDetails.length - 1].paymentNetworkId == 4) {
125-
transferBackRemainingEth = true;
125+
transferBackRemainingNativeTokens = true;
126126
}
127127
} else if (metaDetail.paymentNetworkId == 4) {
128-
batchFeeAmountUSD += _batchEthConversionPayments(
128+
batchFeeAmountUSD += _batchNativeConversionPayments(
129129
metaDetail.requestDetails,
130130
pathsToUSD.length == 0,
131131
batchFeeAmountUSD,
@@ -154,23 +154,22 @@ contract BatchConversionPayments is BatchNoConversionPayments {
154154
}
155155

156156
/**
157-
* @notice Send a batch of ETH conversion payments with fees and paymentReferences to multiple accounts.
157+
* @notice Send a batch of Native conversion payments with fees and paymentReferences to multiple accounts.
158158
* If one payment fails, the whole batch is reverted.
159-
* @param requestDetails List of ETH requests denominated in fiat to pay.
159+
* @param requestDetails List of native requests denominated in fiat to pay.
160160
* @param skipFeeUSDLimit Setting the value to true skips the USD fee limit, and reduce gas consumption.
161161
* @param feeAddress The fee recipient.
162-
* @dev It uses EthereumConversionProxy to pay an invoice and fees.
162+
* @dev It uses NativeConversionProxy (EthereumConversionProxy) to pay an invoice and fees.
163163
* Please:
164-
* Note that if there is not enough ether attached to the function call,
164+
* Note that if there is not enough Native token attached to the function call,
165165
* the following error is thrown: "revert paymentProxy transferExactEthWithReferenceAndFee failed"
166-
* This choice reduces the gas significantly, by delegating the whole conversion to the payment proxy.
167166
*/
168-
function batchEthConversionPayments(
167+
function batchNativeConversionPayments(
169168
RequestDetail[] calldata requestDetails,
170169
bool skipFeeUSDLimit,
171170
address payable feeAddress
172171
) public payable returns (uint256) {
173-
return _batchEthConversionPayments(requestDetails, skipFeeUSDLimit, 0, feeAddress);
172+
return _batchNativeConversionPayments(requestDetails, skipFeeUSDLimit, 0, feeAddress);
174173
}
175174

176175
/**
@@ -250,19 +249,18 @@ contract BatchConversionPayments is BatchNoConversionPayments {
250249
}
251250

252251
/**
253-
* @notice Send a batch of ETH conversion payments with fees and paymentReferences to multiple accounts.
252+
* @notice Send a batch of Native conversion payments with fees and paymentReferences to multiple accounts.
254253
* If one payment fails, the whole batch is reverted.
255-
* @param requestDetails List of ETH requests denominated in fiat to pay.
254+
* @param requestDetails List of native requests denominated in fiat to pay.
256255
* @param skipFeeUSDLimit Setting the value to true skips the USD fee limit, and reduce gas consumption.
257256
* @param batchFeeAmountUSD The batch fee amount in USD already paid.
258257
* @param feeAddress The fee recipient.
259-
* @dev It uses EthereumConversionProxy to pay an invoice and fees.
258+
* @dev It uses NativeConversionProxy (EthereumConversionProxy) to pay an invoice and fees.
260259
* Please:
261-
* Note that if there is not enough ether attached to the function call,
260+
* Note that if there is not enough Native token attached to the function call,
262261
* the following error is thrown: "revert paymentProxy transferExactEthWithReferenceAndFee failed"
263-
* This choice reduces the gas significantly, by delegating the whole conversion to the payment proxy.
264262
*/
265-
function _batchEthConversionPayments(
263+
function _batchNativeConversionPayments(
266264
RequestDetail[] calldata requestDetails,
267265
bool skipFeeUSDLimit,
268266
uint256 batchFeeAmountUSD,
@@ -271,10 +269,10 @@ contract BatchConversionPayments is BatchNoConversionPayments {
271269
uint256 contractBalance = address(this).balance;
272270
payerAuthorized = true;
273271

274-
// Batch contract pays the requests through EthConversionProxy
272+
// Batch contract pays the requests through nativeConversionProxy
275273
for (uint256 i = 0; i < requestDetails.length; i++) {
276274
RequestDetail memory rD = requestDetails[i];
277-
paymentEthConversionProxy.transferWithReferenceAndFee{value: address(this).balance}(
275+
paymentNativeConversionProxy.transferWithReferenceAndFee{value: address(this).balance}(
278276
payable(rD.recipient),
279277
rD.requestAmount,
280278
rD.path,
@@ -292,16 +290,16 @@ contract BatchConversionPayments is BatchNoConversionPayments {
292290
if (skipFeeUSDLimit == false) {
293291
(batchFeeToPay, batchFeeAmountUSD) = calculateBatchFeeToPay(
294292
batchFeeToPay,
295-
pathsEthToUSD[0][0],
293+
pathsNativeToUSD[0][0],
296294
batchFeeAmountUSD,
297-
pathsEthToUSD
295+
pathsNativeToUSD
298296
);
299297
}
300298

301299
require(address(this).balance >= batchFeeToPay, 'Not enough funds for batch conversion fees');
302300
feeAddress.transfer(batchFeeToPay);
303301

304-
// Batch contract transfers the remaining ethers to the payer
302+
// Batch contract transfers the remaining native tokens to the payer
305303
(bool sendBackSuccess, ) = payable(msg.sender).call{value: address(this).balance}('');
306304
require(sendBackSuccess, 'Could not send remaining funds to the payer');
307305
payerAuthorized = false;
@@ -322,10 +320,13 @@ contract BatchConversionPayments is BatchNoConversionPayments {
322320
}
323321

324322
/**
325-
* @param _paymentEthConversionProxy The address of the Ethereum Conversion payment proxy to use.
323+
* @param _paymentNativeConversionProxy The address of the native Conversion payment proxy to use.
326324
* Update cautiously, the proxy has to match the invoice proxy.
327325
*/
328-
function setPaymentEthConversionProxy(address _paymentEthConversionProxy) external onlyOwner {
329-
paymentEthConversionProxy = IEthConversionProxy(_paymentEthConversionProxy);
326+
function setPaymentNativeConversionProxy(address _paymentNativeConversionProxy)
327+
external
328+
onlyOwner
329+
{
330+
paymentNativeConversionProxy = IEthConversionProxy(_paymentNativeConversionProxy);
330331
}
331332
}

0 commit comments

Comments
 (0)