Skip to content

Commit

Permalink
fix: casting in current index calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
0xIryna committed Nov 20, 2024
1 parent cf573e7 commit e3c810f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/HubPortal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pragma solidity 0.8.26;

import { IERC20 } from "../lib/common/src/interfaces/IERC20.sol";
import { UIntMath } from "../lib/common/src/libs/UIntMath.sol";
import { IndexingMath } from "../lib/common/src/libs/IndexingMath.sol";
import { TransceiverStructs } from "../lib/example-native-token-transfers/evm/src/libraries/TransceiverStructs.sol";

Expand Down Expand Up @@ -174,11 +175,12 @@ contract HubPortal is IHubPortal, Portal {
function _currentIndex() internal view override returns (uint128) {
return
_isEarningEnabled()
? uint128(uint256(_disablePortalIndex) * _currentMTokenIndex()) / _enableMTokenIndex
? UIntMath.bound128((uint256(_disablePortalIndex) * _currentMTokenIndex()) / _enableMTokenIndex)
: _disablePortalIndex;
}

function _currentMTokenIndex() private view returns (uint128 index_) {
/// @dev Returns the current M Token index
function _currentMTokenIndex() private view returns (uint128) {
return IMTokenLike(mToken()).currentIndex();
}

Expand Down

0 comments on commit e3c810f

Please sign in to comment.