Skip to content

Commit bb461a6

Browse files
committed
better
Signed-off-by: Ihor Farion <ihor@umaproject.org>
1 parent 42cfa34 commit bb461a6

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

contracts/external/libraries/SharedDecimalsLib.sol

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@ abstract contract SharedDecimalsLib {
2525
// @dev To preserve the dust that would otherwise be lost on that conversion,
2626
// we need to unify a denomination that can be represented on ALL chains inside of the OFT mesh
2727
uint256 public immutable decimalConversionRate;
28+
uint8 internal immutable _sharedDecimals;
2829

2930
/**
3031
* @dev Constructor.
3132
* @param _localDecimals The decimals of the token on the local chain (this chain).
32-
* @param _endpoint Unused (kept for parity with OFTCore signature).
33-
* @param _delegate Unused (kept for parity with OFTCore signature).
33+
* @param _sharedDecimalsArg The shared decimals used by the OFT.
3434
*/
35-
constructor(uint8 _localDecimals, address _endpoint, address _delegate) {
36-
_endpoint;
37-
_delegate;
38-
if (_localDecimals < sharedDecimals()) revert InvalidLocalDecimals();
39-
decimalConversionRate = 10 ** (_localDecimals - sharedDecimals());
35+
constructor(uint8 _localDecimals, uint8 _sharedDecimalsArg) {
36+
_sharedDecimals = _sharedDecimalsArg;
37+
if (_localDecimals < _sharedDecimalsArg) revert InvalidLocalDecimals();
38+
decimalConversionRate = 10 ** (_localDecimals - _sharedDecimalsArg);
4039
}
4140

4241
/**
@@ -50,7 +49,7 @@ abstract contract SharedDecimalsLib {
5049
* ie. 4 sharedDecimals would be 1,844,674,407,370,955.1615
5150
*/
5251
function sharedDecimals() public view virtual returns (uint8) {
53-
return 6;
52+
return _sharedDecimals;
5453
}
5554

5655
/**

contracts/periphery/mintburn/sponsored-oft/DstOFTHandler.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ contract DstOFTHandler is BaseModuleHandler, SharedDecimalsLib, ILayerZeroCompos
8787
)
8888
BaseModuleHandler(_donationBox, _baseToken, DEFAULT_ADMIN_ROLE)
8989
ArbitraryEVMFlowExecutor(_multicallHandler)
90-
SharedDecimalsLib(IERC20Metadata(_baseToken).decimals(), address(0), address(0))
90+
SharedDecimalsLib(IERC20Metadata(_baseToken).decimals(), IOFT(_ioft).sharedDecimals())
9191
{
9292
baseToken = _baseToken;
9393

contracts/periphery/mintburn/sponsored-oft/SponsoredOFTSrcPeriphery.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ contract SponsoredOFTSrcPeriphery is Ownable, SharedDecimalsLib {
9595
address _oftMessenger,
9696
uint32 _srcEid,
9797
address _signer
98-
) SharedDecimalsLib(IERC20Metadata(_token).decimals(), address(0), address(0)) {
98+
) SharedDecimalsLib(IERC20Metadata(_token).decimals(), IOFT(_oftMessenger).sharedDecimals()) {
9999
TOKEN = _token;
100100
OFT_MESSENGER = _oftMessenger;
101101
SRC_EID = _srcEid;

0 commit comments

Comments
 (0)