Skip to content

Commit 6388e15

Browse files
committed
fix: buyback params style
1 parent eb6542c commit 6388e15

2 files changed

Lines changed: 41 additions & 41 deletions

File tree

contracts/buyback/Buyback.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,45 +155,45 @@ contract Buyback is
155155
}
156156

157157
/// @dev buy back tokens using router
158-
/// @param router The address of the router.
158+
/// @param _router The address of the router.
159159
/// @param _tokenIn The address of the input token.
160160
/// @param _tokenOut The address of the output token.
161-
/// @param amountIn The amount to sell.
162-
/// @param amountOutMin The minimum amount to receive.
163-
/// @param swapData The swap data.
161+
/// @param _amountIn The amount to sell.
162+
/// @param _amountOutMin The minimum amount to receive.
163+
/// @param _swapData The swap data.
164164
function buyback(
165-
address router,
165+
address _router,
166166
address _tokenIn,
167167
address _tokenOut,
168-
uint256 amountIn,
169-
uint256 amountOutMin,
170-
bytes calldata swapData
168+
uint256 _amountIn,
169+
uint256 _amountOutMin,
170+
bytes calldata _swapData
171171
) external onlyRole(BOT) nonReentrant whenNotPaused {
172172
require(tokenInWhitelist[_tokenIn], "token not whitelisted");
173173
require(tokenOut == _tokenOut, "token not whitelisted");
174-
require(routerWhitelist[router], "router not whitelisted");
174+
require(routerWhitelist[_router], "router not whitelisted");
175175

176176
uint256 beforeTokenIn = _getTokenBalance(_tokenIn, address(this));
177177
uint256 beforeTokenOut = _getTokenBalance(_tokenOut, receiver);
178178

179179
bool isNativeTokenIn = (_tokenIn == SWAP_NATIVE_TOKEN_ADDRESS);
180180
if (!isNativeTokenIn) {
181-
IERC20(_tokenIn).safeApprove(router, amountIn);
181+
IERC20(_tokenIn).safeApprove(_router, _amountIn);
182182
}
183-
(bool success, ) = router.call{ value: isNativeTokenIn ? amountIn : 0 }(swapData);
183+
(bool success, ) = _router.call{ value: isNativeTokenIn ? _amountIn : 0 }(_swapData);
184184
require(success, "swap failed");
185185

186186
if (!isNativeTokenIn) {
187-
IERC20(_tokenIn).safeApprove(router, 0);
187+
IERC20(_tokenIn).safeApprove(_router, 0);
188188
}
189189

190190
uint256 actualAmountIn = beforeTokenIn - _getTokenBalance(_tokenIn, address(this));
191191
uint256 actualAmountOut = _getTokenBalance(_tokenOut, receiver) - beforeTokenOut;
192192

193-
require(actualAmountIn <= amountIn, "exceed amount in");
194-
require(actualAmountOut >= amountOutMin, "not enough profit");
193+
require(actualAmountIn <= _amountIn, "exceed amount in");
194+
require(actualAmountOut >= _amountOutMin, "not enough profit");
195195

196-
emit BoughtBack(router, _tokenIn, _tokenOut, actualAmountIn, actualAmountOut);
196+
emit BoughtBack(_router, _tokenIn, _tokenOut, actualAmountIn, actualAmountOut);
197197
}
198198

199199
/**

contracts/dao/ListaAutoBuyback.sol

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,44 +131,44 @@ contract ListaAutoBuyback is Initializable, AccessControlUpgradeable {
131131
}
132132

133133
/// @dev buy back tokens using router
134-
/// @param router The address of the router.
135-
/// @param tokenIn The address of the input token.
136-
/// @param tokenOut The address of the output token.
137-
/// @param amountIn The amount to sell.
138-
/// @param amountOutMin The minimum amount to receive.
139-
/// @param swapData The swap data.
134+
/// @param _router The address of the router.
135+
/// @param _tokenIn The address of the input token.
136+
/// @param _tokenOut The address of the output token.
137+
/// @param _amountIn The amount to sell.
138+
/// @param _amountOutMin The minimum amount to receive.
139+
/// @param _swapData The swap data.
140140
function buyback(
141-
address router,
142-
address tokenIn,
143-
address tokenOut,
144-
uint256 amountIn,
145-
uint256 amountOutMin,
146-
bytes calldata swapData
141+
address _router,
142+
address _tokenIn,
143+
address _tokenOut,
144+
uint256 _amountIn,
145+
uint256 _amountOutMin,
146+
bytes calldata _swapData
147147
) external onlyRole(BOT) {
148-
require(tokenWhitelist[tokenIn], "token not whitelisted");
149-
require(tokenWhitelist[tokenOut], "token not whitelisted");
150-
require(routerWhitelist[router], "router not whitelisted");
148+
require(tokenWhitelist[_tokenIn], "token not whitelisted");
149+
require(tokenWhitelist[_tokenOut], "token not whitelisted");
150+
require(routerWhitelist[_router], "router not whitelisted");
151151

152-
uint256 beforeTokenIn = _getTokenBalance(tokenIn, address(this));
153-
uint256 beforeTokenOut = _getTokenBalance(tokenOut, defaultReceiver);
152+
uint256 beforeTokenIn = _getTokenBalance(_tokenIn, address(this));
153+
uint256 beforeTokenOut = _getTokenBalance(_tokenOut, defaultReceiver);
154154

155-
bool isNativeTokenIn = (tokenIn == SWAP_NATIVE_TOKEN_ADDRESS);
155+
bool isNativeTokenIn = (_tokenIn == SWAP_NATIVE_TOKEN_ADDRESS);
156156
if (!isNativeTokenIn) {
157-
IERC20(tokenIn).safeApprove(router, amountIn);
157+
IERC20(_tokenIn).safeApprove(_router, _amountIn);
158158
}
159-
(bool success, ) = router.call{value: isNativeTokenIn ? amountIn : 0}(swapData);
159+
(bool success, ) = _router.call{value: isNativeTokenIn ? _amountIn : 0}(_swapData);
160160
require(success, "swap failed");
161161
if (!isNativeTokenIn) {
162-
IERC20(tokenIn).safeApprove(router, 0);
162+
IERC20(_tokenIn).safeApprove(_router, 0);
163163
}
164164

165-
uint256 actualAmountIn = beforeTokenIn - _getTokenBalance(tokenIn, address(this));
166-
uint256 actualAmountOut = _getTokenBalance(tokenOut, defaultReceiver) - beforeTokenOut;
165+
uint256 actualAmountIn = beforeTokenIn - _getTokenBalance(_tokenIn, address(this));
166+
uint256 actualAmountOut = _getTokenBalance(_tokenOut, defaultReceiver) - beforeTokenOut;
167167

168-
require(actualAmountIn <= amountIn, "exceed amount in");
169-
require(actualAmountOut >= amountOutMin, "not enough profit");
168+
require(actualAmountIn <= _amountIn, "exceed amount in");
169+
require(actualAmountOut >= _amountOutMin, "not enough profit");
170170

171-
emit BoughtBack(router, tokenIn, tokenOut, actualAmountIn, actualAmountOut);
171+
emit BoughtBack(_router, _tokenIn, _tokenOut, actualAmountIn, actualAmountOut);
172172
}
173173

174174
function adminTransfer(address _token, uint256 _amount) external onlyRole(DEFAULT_ADMIN_ROLE) {

0 commit comments

Comments
 (0)