Skip to content

Commit d845940

Browse files
committed
audit fixes
1 parent 90718b8 commit d845940

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ src = 'src'
33
out = 'out'
44

55
optimizer = true
6-
optimizer_runs = 800
6+
optimizer_runs = 100
77
fs_permissions = [{ access = "read-write", path = "./"}]
88

99
solc_version = "0.8.27"

src/risk-managers/BaseManager.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ abstract contract BaseManager is IBaseManager, Ownable2StepUpgradeable {
8383

8484
mapping(address => bool) public trustedRiskAssessor;
8585

86+
bytes[49] private __gap;
87+
8688
constructor(
8789
ISubAccounts _subAccounts,
8890
ICashAsset _cashAsset,

src/risk-managers/PMRMLib_2.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ contract PMRMLib_2 is IPMRMLib_2, Ownable2Step {
105105
}
106106

107107
function setCollateralParameters(address asset, CollateralParameters memory params) external onlyOwner {
108-
// once enabled cannot be disabled, must have haircuts set to 100% instead. Otherwise subaccoutns may be frozen
108+
// once enabled cannot be disabled, must have haircuts set to 100% instead. Otherwise subaccounts may be frozen
109109
require(
110-
params.isEnabled && params.MMHaircut <= 1e18 && params.MMHaircut <= 1e18, PMRML2_InvalidCollateralParameters()
110+
params.isEnabled && (params.IMHaircut + params.MMHaircut) <= 1e18 && params.MMHaircut <= 1e18,
111+
PMRML2_InvalidCollateralParameters()
111112
);
112113
// Note: asset must be added to pmrm to be used as collateral. If
113114
collaterals[asset] = params;
@@ -137,9 +138,9 @@ contract PMRMLib_2 is IPMRMLib_2, Ownable2Step {
137138
IPMRM_2.Scenario memory scenario = scenarios[i];
138139

139140
// SPAN value with discounting applied, and only the *difference from MtM*
140-
int scenarioMTM = getScenarioPnL(portfolio, scenario);
141-
if (scenarioMTM < minSPAN) {
142-
minSPAN = scenarioMTM;
141+
int scenarioPnL = getScenarioPnL(portfolio, scenario);
142+
if (scenarioPnL < minSPAN) {
143+
minSPAN = scenarioPnL;
143144
worstScenario = i;
144145
}
145146
}

src/risk-managers/PMRM_2.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ contract PMRM_2 is IPMRM_2, ILiquidatableManager, BaseManagerUpgradeable, Reentr
288288
portfolio.expiries = new ExpiryHoldings[](seenExpiries);
289289
portfolio.collaterals = new CollateralHoldings[](collateralCount);
290290
(portfolio.spotPrice, portfolio.minConfidence) = spotFeed.getSpot();
291-
(uint stablePrice,) = stableFeed.getSpot();
292-
portfolio.stablePrice = stablePrice;
291+
(portfolio.stablePrice,) = stableFeed.getSpot();
293292

294293
_initialiseExpiries(portfolio, expiryCount);
295294
_arrangeAssets(accountId, portfolio, assets, collateralCount, expiryCount);
@@ -356,7 +355,7 @@ contract PMRM_2 is IPMRM_2, ILiquidatableManager, BaseManagerUpgradeable, Reentr
356355
// We assume the rate is always positive.
357356
rate = SignedMath.max(rate, 0);
358357

359-
// We dont compare this to the portfolio.minConfidence yet - we do that in preComputes
358+
// We don't compare this to the portfolio.minConfidence yet - we do that in preComputes
360359
uint minConfidence = Math.min(fwdConfidence, rateConfidence);
361360

362361
// if an option expired, also set secToExpiry to 0
@@ -479,7 +478,7 @@ contract PMRM_2 is IPMRM_2, ILiquidatableManager, BaseManagerUpgradeable, Reentr
479478
}
480479

481480
/**
482-
* @notice Can be called by anyone to settle a perp asset in an account
481+
* @notice Can be called by anyone to settle an option asset in an account
483482
*/
484483
function settleOptions(IOptionAsset _option, uint accountId) external {
485484
require(_option == option, PMRM_2_UnsupportedAsset());

0 commit comments

Comments
 (0)