Skip to content

Commit

Permalink
update(Ticket): cast amounts to uint208 when calling TwabLib
Browse files Browse the repository at this point in the history
  • Loading branch information
kamescg committed Oct 6, 2021
1 parent 472eefa commit 0f645fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions contracts/Ticket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import "./ControlledToken.sol";
*/
contract Ticket is ControlledToken, ITicket {
using SafeERC20 for IERC20;
using SafeCast for uint256;
using ExtendedSafeCastLib for uint256;

/// @notice Record of token holders TWABs for each account.
Expand Down Expand Up @@ -375,7 +374,7 @@ contract Ticket is ControlledToken, ITicket {
bool tsIsNew
) = TwabLib.decreaseBalance(
totalSupplyTwab,
_amount,
_amount.toUint208(),
"Ticket/burn-amount-exceeds-total-supply-twab",
uint32(block.timestamp)
);
Expand Down Expand Up @@ -456,7 +455,7 @@ contract Ticket is ControlledToken, ITicket {
bool isNew
) = TwabLib.decreaseBalance(
_account,
_amount,
_amount.toUint208(),
"ERC20: burn amount exceeds balance",
uint32(block.timestamp)
);
Expand Down
4 changes: 2 additions & 2 deletions contracts/libraries/TwabLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ library TwabLib {
*/
function decreaseBalance(
Account storage _account,
uint256 _amount,
uint208 _amount,
string memory _revertMessage,
uint32 _currentTime
)
Expand All @@ -115,7 +115,7 @@ library TwabLib {
require(_accountDetails.balance >= _amount, _revertMessage);

(accountDetails, twab, isNew) = _nextTwab(_account.twabs, _accountDetails, _currentTime);
accountDetails.balance = (_accountDetails.balance - _amount).toUint208();
accountDetails.balance = _accountDetails.balance - _amount;
}

/** @notice Calculates the average balance held by a user for a given time frame.
Expand Down

0 comments on commit 0f645fb

Please sign in to comment.