File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
program-analysis/echidna/example Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ pragma solidity ^ 0.8.0 ;
2+
3+ contract TestDutchAuctionOptimization {
4+ int256 maxPriceDifference;
5+
6+ function setMaxPriceDifference (
7+ uint256 startPrice ,
8+ uint256 endPrice ,
9+ uint256 startTime ,
10+ uint256 endTime
11+ ) public {
12+ if (endTime < (startTime + 900 )) {
13+ revert ();
14+ }
15+ if (startPrice <= endPrice) {
16+ revert ();
17+ }
18+ uint256 numerator = (startPrice - endPrice) *
19+ (block .timestamp - startTime);
20+ uint256 denominator = endTime - startTime;
21+ uint256 stepDecrease = numerator / denominator;
22+ uint256 currentAuctionPrice = startPrice - stepDecrease;
23+ if (currentAuctionPrice < endPrice) {
24+ maxPriceDifference = int256 (endPrice - currentAuctionPrice);
25+ }
26+ if (currentAuctionPrice > startPrice) {
27+ maxPriceDifference = int256 (currentAuctionPrice - startPrice);
28+ }
29+ }
30+
31+ function echidna_opt_price_difference () public view returns (int256 ) {
32+ return maxPriceDifference;
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments