diff --git a/contracts/modules/capital/MCR.sol b/contracts/modules/capital/MCR.sol index 35c844e20a..8f97f2dc06 100644 --- a/contracts/modules/capital/MCR.sol +++ b/contracts/modules/capital/MCR.sol @@ -102,12 +102,8 @@ contract MCR is IMCR, MasterAware { // the first asset is ETH. skip it, it's already counted for (uint i = 1; i < assets.length; i++) { - - IPool.Asset memory asset = assets[i]; uint activeCoverAmount = cover.totalActiveCoverInAsset(uint24(i)); - - uint assetRate = priceFeed.getAssetToEthRate(assets[i].assetAddress); - uint assetAmountInEth = activeCoverAmount * assetRate / 10 ** asset.decimals; + uint assetAmountInEth = priceFeed.getEthForAsset(assets[i].assetAddress, activeCoverAmount); totalActiveCoverAmountInEth += assetAmountInEth; } diff --git a/contracts/modules/capital/Pool.sol b/contracts/modules/capital/Pool.sol index 06e7fd15da..29a5adcad6 100644 --- a/contracts/modules/capital/Pool.sol +++ b/contracts/modules/capital/Pool.sol @@ -13,6 +13,7 @@ import "../../interfaces/IPool.sol"; import "../../interfaces/IPriceFeedOracle.sol"; import "../../interfaces/ITokenController.sol"; import "../../interfaces/IERC20Detailed.sol"; +import "../../libraries/Math.sol"; import "../../libraries/SafeUintCast.sol"; contract Pool is IPool, MasterAware, ReentrancyGuard { @@ -646,7 +647,7 @@ contract Pool is IPool, MasterAware, ReentrancyGuard { // Step 3. Min [average[Price(0), Price(1)] x ( 1 - Sell Spread), Price(1) ] // Sell Spread = 2.5% uint averagePriceWithSpread = (spotPrice0 + spotPrice1) / 2 * 975 / 1000; - uint finalPrice = averagePriceWithSpread < spotPrice1 ? averagePriceWithSpread : spotPrice1; + uint finalPrice = Math.min(averagePriceWithSpread, spotPrice1); uint ethAmount = finalPrice * nxmAmount / 1e18; require( diff --git a/contracts/modules/cover/Cover.sol b/contracts/modules/cover/Cover.sol index f56073d352..d1bdb3869e 100644 --- a/contracts/modules/cover/Cover.sol +++ b/contracts/modules/cover/Cover.sol @@ -657,10 +657,10 @@ contract Cover is ICover, MasterAwareV2, IStakingPoolBeacon, ReentrancyGuard { ProductType[] calldata newProductTypes, string[] calldata ipfsMetadata ) external override onlyAdvisoryBoard { - uint initialProuctTypesCount = _productTypes.length; + uint initialProductTypesCount = _productTypes.length; for (uint i = 0; i < newProductTypes.length; i++) { _productTypes.push(newProductTypes[i]); - emit ProductTypeSet(initialProuctTypesCount + i, ipfsMetadata[i]); + emit ProductTypeSet(initialProductTypesCount + i, ipfsMetadata[i]); } } diff --git a/contracts/modules/governance/Governance.sol b/contracts/modules/governance/Governance.sol index 925d086f34..4967f67b45 100644 --- a/contracts/modules/governance/Governance.sol +++ b/contracts/modules/governance/Governance.sol @@ -460,7 +460,7 @@ contract Governance is IGovernance, LegacyMasterAware { uint category, uint status, uint finalVerdict, - uint totalRewar + uint totalReward ) { return (