Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Enforced invariant to make sure auction duration can never exceed epoc… #326

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/AstariaRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ contract AstariaRouter is
bytes memory data = incoming.data;
if (what == FileType.AuctionWindow) {
uint256 window = abi.decode(data, (uint256));
if (window >= s.minEpochLength) revert InvalidFileData();
s.auctionWindow = window.safeCastTo32();
} else if (what == FileType.LiquidationFee) {
(uint256 numerator, uint256 denominator) = abi.decode(
Expand All @@ -292,6 +293,8 @@ contract AstariaRouter is
s.protocolFeeNumerator = numerator.safeCastTo32();
s.protocolFeeDenominator = denominator.safeCastTo32();
} else if (what == FileType.MinEpochLength) {
uint256 minLength = abi.decode(data, (uint256));
if (minLength <= s.auctionWindow) revert InvalidFileData();
s.minEpochLength = abi.decode(data, (uint256)).safeCastTo32();
Comment on lines +296 to 298

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to decode data twice.

} else if (what == FileType.MaxEpochLength) {
s.maxEpochLength = abi.decode(data, (uint256)).safeCastTo32();
Expand Down Expand Up @@ -538,10 +541,15 @@ contract AstariaRouter is
IPublicVault.InvalidStates.EPOCH_TOO_HIGH
);
}

if (vaultFee > s.maxStrategistFee) {
revert IAstariaRouter.InvalidVaultFee();
}
if (epochLength <= s.auctionWindow) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is implied from above where we check:

  • s.minEpochLength <= epochLength
  • and when filing s.auctionWindow < s.minEpochLength (need to check this in the constructor as well)

revert IPublicVault.InvalidState(
IPublicVault.InvalidStates.EPOCH_TOO_LOW
);
}

return
_newVault(
s,
Expand Down