@@ -259,27 +259,20 @@ contract NttManager is INttManager, NttManagerState {
259
259
260
260
{
261
261
// Lock/burn tokens before checking rate limits
262
- if (mode == Mode.LOCKING) {
263
- {
264
- // use transferFrom to pull tokens from the user and lock them
265
- // query own token balance before transfer
266
- uint256 balanceBefore = _getTokenBalanceOf (token, address (this ));
262
+ // use transferFrom to pull tokens from the user and lock them
263
+ // query own token balance before transfer
264
+ uint256 balanceBefore = _getTokenBalanceOf (token, address (this ));
267
265
268
- // transfer tokens
269
- IERC20 (token).safeTransferFrom (msg .sender , address (this ), amount);
266
+ // transfer tokens
267
+ IERC20 (token).safeTransferFrom (msg .sender , address (this ), amount);
270
268
271
- // query own token balance after transfer
272
- uint256 balanceAfter = _getTokenBalanceOf (token, address (this ));
269
+ // query own token balance after transfer
270
+ uint256 balanceAfter = _getTokenBalanceOf (token, address (this ));
273
271
274
- // correct amount for potential transfer fees
275
- amount = balanceAfter - balanceBefore;
276
- }
277
- } else if (mode == Mode.BURNING) {
272
+ // correct amount for potential transfer fees
273
+ amount = balanceAfter - balanceBefore;
274
+ if (mode == Mode.BURNING) {
278
275
{
279
- // query sender's token balance before burn
280
- uint256 balanceBefore = _getTokenBalanceOf (token, msg .sender );
281
-
282
- // call the token's burn function to burn the sender's token
283
276
// NOTE: We don't account for burn fees in this code path.
284
277
// We verify that the user's change in balance is equal to the amount that's burned.
285
278
// Accounting for burn fees can be non-trivial, since there
@@ -291,18 +284,14 @@ contract NttManager is INttManager, NttManagerState {
291
284
// Since there is no standard way to query for burn fee amounts with burnable tokens,
292
285
// and NTT would be used on a per-token basis, implementing this functionality
293
286
// is left to integrating projects who may need to account for burn fees on their tokens.
294
- ERC20Burnable (token).burnFrom (msg .sender , amount);
295
-
296
- // query sender's token balance after transfer
297
- uint256 balanceAfter = _getTokenBalanceOf (token, msg .sender );
287
+ ERC20Burnable (token).burn (amount);
298
288
299
- uint256 balanceDiff = balanceBefore - balanceAfter;
300
- if (balanceDiff != amount) {
301
- revert BurnAmountDifferentThanBalanceDiff (amount, balanceDiff);
289
+ // tokens held by the contract after the operation should be the same as before
290
+ uint256 balanceAfterBurn = _getTokenBalanceOf (token, address (this ));
291
+ if (balanceBefore != balanceAfterBurn) {
292
+ revert BurnAmountDifferentThanBalanceDiff (balanceBefore, balanceAfterBurn);
302
293
}
303
294
}
304
- } else {
305
- revert InvalidMode (uint8 (mode));
306
295
}
307
296
}
308
297
0 commit comments