Skip to content

Commit

Permalink
test: Fuzzing prices Dutch Auction
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJurassicPunk committed Apr 20, 2022
1 parent 37ad3a0 commit 0deda9e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions contracts/test/DutchAuction.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ abstract contract TestParameters {
bytes32 internal _R;
bytes32 internal _S;

// Dutch Auction constructor parameters
uint256 internal _PROTOCOL_FEE = 200;
uint256 internal _MIN_AUCTION_LENGTH = 15 minutes;
}
Expand All @@ -31,18 +32,21 @@ contract StrategyDutchAuctionTest is TestHelpers, TestParameters {
strategyDutchAuction = new StrategyDutchAuction(_PROTOCOL_FEE, _MIN_AUCTION_LENGTH);
}

function testTimeOverflow(uint32 auctionLength) public {
uint256 startTime = block.timestamp;
function testTimeAndPriceUnderOverflow(
uint96 auctionLength,
uint256 startPrice,
uint256 endPrice
) public {
cheats.assume(_MIN_AUCTION_LENGTH < uint256(auctionLength));
cheats.assume(startPrice > endPrice);

uint256 startTime = block.timestamp;
uint256 endTime = startTime + uint256(auctionLength);
uint256 startPrice = 2 ether;
uint256 endPrice = 0.5 ether;
bytes memory makerParams = abi.encode(startPrice);

uint256 takerPrice = startPrice -
(((startPrice - endPrice) * (block.timestamp - startTime)) / (endTime - startTime));

bytes memory makerParams = abi.encode(startPrice);

OrderTypes.TakerOrder memory takerBidOrder = OrderTypes.TakerOrder(
false,
_TAKER,
Expand Down

0 comments on commit 0deda9e

Please sign in to comment.