Skip to content

Commit 778d276

Browse files
committed
feat: allow address(0) for ETH deployment in ListaRevenueDistributor
- Remove require != address(0) checks in initialize() for autoBuyback/revenueWallet/listaDistributeTo - Add address(0) guards in _distributeToken() and _distributeTokenWithCost() to skip transfers - Remove require != address(0) from setter methods to allow resetting to address(0) This enables deploying ListaRevenueDistributor on ETH where revenue stays in the contract for manual cross-chain bridging instead of auto-distributing.
1 parent a7d762a commit 778d276

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

contracts/dao/ListaRevenueDistributor.sol

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ contract ListaRevenueDistributor is Initializable, AccessControlUpgradeable {
8383
require(_admin != address(0), "admin is the zero address");
8484
require(_manager != address(0), "manager is the zero address");
8585
require(_listaTokenAddress != address(0), "listaTokenAddress is the zero address");
86-
require(_autoBuybackAddress != address(0), "autoBuybackAddress is the zero address");
87-
require(_revenueWalletAddress != address(0), "revenueWalletAddress is the zero address");
88-
require(_listaDistributeToAddress != address(0), "listaDistributeToAddress is the zero address");
8986
require(_distributeRate <= 1e18, "too big rate number");
9087

9188
__AccessControl_init();
@@ -122,12 +119,16 @@ contract ListaRevenueDistributor is Initializable, AccessControlUpgradeable {
122119
if (amount0 > 0) {
123120
if (token == listaTokenAddress) {
124121
// lista should skip autoBuyback process
125-
IERC20(token).safeTransfer(listaDistributeToAddress, amount0);
122+
if (listaDistributeToAddress != address(0)) {
123+
IERC20(token).safeTransfer(listaDistributeToAddress, amount0);
124+
}
126125
} else {
127-
IERC20(token).safeTransfer(autoBuybackAddress, amount0);
126+
if (autoBuybackAddress != address(0)) {
127+
IERC20(token).safeTransfer(autoBuybackAddress, amount0);
128+
}
128129
}
129130
}
130-
if (amount1 > 0) {
131+
if (amount1 > 0 && revenueWalletAddress != address(0)) {
131132
IERC20(token).safeTransfer(revenueWalletAddress, amount1);
132133
}
133134

@@ -208,13 +209,17 @@ contract ListaRevenueDistributor is Initializable, AccessControlUpgradeable {
208209
if (amount0 > 0) {
209210
if (token == listaTokenAddress) {
210211
// lista should skip autoBuyback process
211-
IERC20(token).safeTransfer(listaDistributeToAddress, amount0);
212+
if (listaDistributeToAddress != address(0)) {
213+
IERC20(token).safeTransfer(listaDistributeToAddress, amount0);
214+
}
212215
} else {
213-
IERC20(token).safeTransfer(autoBuybackAddress, amount0);
216+
if (autoBuybackAddress != address(0)) {
217+
IERC20(token).safeTransfer(autoBuybackAddress, amount0);
218+
}
214219
}
215220

216221
}
217-
if (amount1 > 0) {
222+
if (amount1 > 0 && revenueWalletAddress != address(0)) {
218223
IERC20(token).safeTransfer(revenueWalletAddress, amount1);
219224
}
220225
if (cost > 0) {
@@ -226,23 +231,20 @@ contract ListaRevenueDistributor is Initializable, AccessControlUpgradeable {
226231
}
227232

228233
function changeAutoBuybackAddress(address _autoBuybackAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
229-
require(_autoBuybackAddress != address(0), "autoBuybackAddress is the zero address");
230234
require(_autoBuybackAddress != autoBuybackAddress, "autoBuybackAddress is the same");
231235
autoBuybackAddress = _autoBuybackAddress;
232236

233237
emit AddressChanged(1, autoBuybackAddress);
234238
}
235239

236240
function changeRevenueWalletAddress(address _revenueWalletAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
237-
require(_revenueWalletAddress != address(0), "revenueWalletAddress is the zero address");
238241
require(_revenueWalletAddress != revenueWalletAddress, "revenueWalletAddress is the same");
239242
revenueWalletAddress = _revenueWalletAddress;
240243

241244
emit AddressChanged(2, revenueWalletAddress);
242245
}
243246

244247
function changeListaDistributeToAddress(address _listaDistributeToAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
245-
require(_listaDistributeToAddress != address(0), "listaDistributeToAddress is the zero address");
246248
require(_listaDistributeToAddress != listaDistributeToAddress, "listaDistributeToAddress is the same");
247249
listaDistributeToAddress = _listaDistributeToAddress;
248250

0 commit comments

Comments
 (0)