# What is expected in setting up the following dutch auction?

I am trying to do an solidity project in which a dutch auction is to be implemented and the auction logic is as follows:

``````The auction is initiated with a start date, end date and a start price.

The price is always known at any time as the linear line connecting the points:
``````

a) start date, start price. (startPrice = a · startDate + b)

b) end date, 0. (0 = a · end date + b)

I don't understand the logic behind setting up the start date and end date. What exactly is the formula they are expecting to be used here? I would highly appreciate it if someone could explain what 'linear line' means here as well.

• It looks like an error. I would interpret it as "..as the line connecting...". Without more point it is just a line.
– Ismael
May 11, 2022 at 5:23
• @Ismael Yes it does seem to be an error. Do you think you could expand on what a and b means here or about the logic on how to implement it? May 16, 2022 at 2:50
• `a` and `b` are numeric values. The price at time `x` will be `a . x + b`. In order to determine the values the equations: `0 = a . end_date b` and `start_price = a . start_date + b` must be resolved.
– Ismael
May 16, 2022 at 6:53
• @Ismael, so what are the values that we supply here? Should we give all the values a, b and startprice? May 19, 2022 at 15:23
• The values for `start_price`, `start_date` and `end_date` should be defined when the contract will launch. Then you have a system of two linear equations with two unknowns `a` and `b`, solving the system you'll obtain the values for `a` and `b`.
– Ismael
May 19, 2022 at 20:09

At deploy time configure the parameters `startDate`, `endDate` and `startingPrice`.

Then at time `date` the current price will be returned by `getCurrentPrice(date)`.

``````// SPDX-License-Identifier: ISC

pragma solidity 0.8.14;

contract A {
uint256 public startDate;
uint256 public endDate;
uint256 public startingPrice;

constructor(uint256 _startDate, uint256 _endDate, uint256 _startingPrice) {
require(_startDate < _endDate, "Invalid date range");
startDate = _startDate;
endDate = _endDate;
startingPrice = _startingPrice;
}

function getCurrentPrice(uint256 date) public view returns (uint256) {
require((date >= startDate) && (date < endDate), "Invalid date");
return (endDate - date) * startingPrice / (endDate - startDate);
}
}
``````
• Hey is 'date' available inbuilt in solidity? Or is it to be declared separately? Jun 8, 2022 at 14:41
• @Mehsilsem If you want to get the "current" date (and time) use `block.timestamp`.
– Ismael
Jun 8, 2022 at 15:41
• I tried changing it as required but it doesn't seem to be working. Can you please take a look at it here : gist.github.com/anandasaia/6bea1bb45dca1ffdcef91bdd2b8b432b Jun 8, 2022 at 18:20