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

Commit

Permalink
invalid check for filing denominator and numerator, added unit test, s…
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Redden authored and androolloyd committed Dec 28, 2022
1 parent c1670e3 commit 7ac15bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/AstariaRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ contract AstariaRouter is Auth, ERC4626Router, Pausable, IAstariaRouter {
data,
(uint256, uint256)
);
if (denominator > numerator) revert InvalidFileData();
if (denominator < numerator) revert InvalidFileData();
s.liquidationFeeNumerator = numerator.safeCastTo32();
s.liquidationFeeDenominator = denominator.safeCastTo32();
} else if (what == FileType.StrategistFee) {
Expand All @@ -302,15 +302,15 @@ contract AstariaRouter is Auth, ERC4626Router, Pausable, IAstariaRouter {
data,
(uint256, uint256)
);
if (denominator > numerator) revert InvalidFileData();
if (denominator < numerator) revert InvalidFileData();
s.protocolFeeNumerator = numerator.safeCastTo32();
s.protocolFeeDenominator = denominator.safeCastTo32();
} else if (what == FileType.BuyoutFee) {
(uint256 numerator, uint256 denominator) = abi.decode(
data,
(uint256, uint256)
);
if (denominator > numerator) revert InvalidFileData();
if (denominator < numerator) revert InvalidFileData();
s.buyoutFeeNumerator = numerator.safeCastTo32();
s.buyoutFeeDenominator = denominator.safeCastTo32();
} else if (what == FileType.MinInterestBPS) {
Expand Down
12 changes: 12 additions & 0 deletions src/test/RevertTesting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ contract RevertTesting is TestHelpers {
);
}

function testInvalidFileData() public {
vm.expectRevert(
abi.encodeWithSelector(IAstariaRouter.InvalidFileData.selector)
);
ASTARIA_ROUTER.file(
IAstariaRouter.File({
what: IAstariaRouter.FileType.ProtocolFee,
data: abi.encode(uint256(11), uint256(10))
})
);
}

function testFailInvalidSignature() public {
TestNFT nft = new TestNFT(3);
address tokenContract = address(nft);
Expand Down

0 comments on commit 7ac15bd

Please sign in to comment.