0

This is quite possibly not a question within the scope of stackexchange but please help out.

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.

7
  • 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?
    – Mehsil sem
    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?
    – Mehsil sem
    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

1 Answer 1

0

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);
    }
}
5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.