From 8d7f6b01c10125b60b9f1d2d09bfa3b3e023f91e Mon Sep 17 00:00:00 2001 From: miguelmtzinf Date: Thu, 15 Dec 2022 13:15:17 +0100 Subject: [PATCH] fix: Change order of GhoToken for CEI pattern --- src/contracts/gho/GhoToken.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/contracts/gho/GhoToken.sol b/src/contracts/gho/GhoToken.sol index 146b71ff..cb39ea3e 100644 --- a/src/contracts/gho/GhoToken.sol +++ b/src/contracts/gho/GhoToken.sol @@ -38,8 +38,9 @@ contract GhoToken is ERC20, Ownable, IGhoToken { require(bucketCapacity >= newBucketLevel, 'FACILITATOR_BUCKET_CAPACITY_EXCEEDED'); _facilitators[msg.sender].bucketLevel = uint128(newBucketLevel); - emit BucketLevelChanged(msg.sender, currentBucketLevel, newBucketLevel); _mint(account, amount); + + emit BucketLevelChanged(msg.sender, currentBucketLevel, newBucketLevel); } /** @@ -50,11 +51,14 @@ contract GhoToken is ERC20, Ownable, IGhoToken { */ function burn(uint256 amount) external override { require(amount != 0, 'INVALID_BURN_AMOUNT'); + uint256 currentBucketLevel = _facilitators[msg.sender].bucketLevel; uint256 newBucketLevel = currentBucketLevel - amount; _facilitators[msg.sender].bucketLevel = uint128(newBucketLevel); - emit BucketLevelChanged(msg.sender, currentBucketLevel, newBucketLevel); + _burn(msg.sender, amount); + + emit BucketLevelChanged(msg.sender, currentBucketLevel, newBucketLevel); } /// @inheritdoc IGhoToken