Skip to content

Commit b824218

Browse files
authored
Avoid div by 0 in compute DR (#271)
1 parent 5708d68 commit b824218

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

spot-contracts/contracts/FeePolicy.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ contract FeePolicy is IFeePolicy, OwnableUpgradeable {
314314
/// @inheritdoc IFeePolicy
315315
function computeDeviationRatio(SystemTVL memory s) public view override returns (uint256) {
316316
// NOTE: We assume that perp's TVL and vault's TVL values have the same base denomination.
317-
return s.vaultTVL.mulDiv(ONE, s.perpTVL).mulDiv(ONE, targetSystemRatio);
317+
uint256 perpTVL = (s.perpTVL > 0) ? s.perpTVL : 0x1;
318+
return s.vaultTVL.mulDiv(ONE, perpTVL).mulDiv(ONE, targetSystemRatio);
318319
}
319320
}

0 commit comments

Comments
 (0)