@@ -34,6 +34,9 @@ abstract contract TrueCurrencyWithPoR is TrueCurrency, IPoRToken {
34
34
super ._mint (account, amount);
35
35
return ;
36
36
}
37
+ // Get required info about decimals.
38
+ // Decimals of the Proof of Reserve feed must be the same as the token's.
39
+ require (decimals () == AggregatorV3Interface (chainReserveFeed).decimals (), "Unexpected decimals of PoR feed " );
37
40
38
41
// Get latest proof-of-reserves from the feed
39
42
(, int256 signedReserves , , uint256 updatedAt , ) = AggregatorV3Interface (chainReserveFeed).latestRoundData ();
@@ -46,20 +49,10 @@ abstract contract TrueCurrencyWithPoR is TrueCurrency, IPoRToken {
46
49
// Check the answer is fresh enough (i.e., within the specified heartbeat)
47
50
require (block .timestamp .sub (updatedAt) <= chainReserveHeartbeat, "TrueCurrency: PoR answer too old " );
48
51
49
- // Get required info about total supply & decimals
50
- uint8 trueDecimals = decimals ();
51
- uint8 reserveDecimals = AggregatorV3Interface (chainReserveFeed).decimals ();
52
- uint256 currentSupply = totalSupply ();
53
- // Normalise TrueCurrency & reserve decimals
54
- if (trueDecimals < reserveDecimals) {
55
- currentSupply = currentSupply.mul (10 ** uint256 (reserveDecimals - trueDecimals));
56
- } else if (trueDecimals > reserveDecimals) {
57
- reserves = reserves.mul (10 ** uint256 (trueDecimals - reserveDecimals));
58
- }
59
-
52
+ // Get required info about total supply.
60
53
// Check that after minting more tokens, the total supply would NOT exceed the reserves
61
54
// reported by the latest valid proof-of-reserves feed.
62
- require (currentSupply + amount <= reserves, "TrueCurrency: total supply would exceed reserves after mint " );
55
+ require (totalSupply () + amount <= reserves, "TrueCurrency: total supply would exceed reserves after mint " );
63
56
super ._mint (account, amount);
64
57
}
65
58
0 commit comments