Auction Store Items
=====
We want to support any kind of auction in the future (more info https://en.wikipedia.org/wiki/Auction#Winner_selection), so in order to do that we are gonna need to store all the bids.
The first aproach was this one:
```solidity
enum AuctionState {
Initial,
Created,
Active
}
struct AuctionCurrencyItem {
uint256 reservedPrice;
uint256 minBidStep;
uint256 buyNowPrice;
uint256 highestBid;
address highestBidder;
}
struct AuctionItem {
mapping(address => AuctionCurrencyItem) currencyItems;
address assetOwner;
AuctionState state;
uint8 currencyCount;
bytes32 scheduleId;
}
```
But this allows to store only one bid per currency, right?. We need all the bids, because there is a type of auction that is random, another one that allows multiple winners, etc.
Model proposal:
```solidity
enum AuctionState {
Initial,
Created,
Active,
Sold // we might no need this state
}
struct BidItem {
address currency;
uint256 bid;
address bidder;
uint256 timestamp; // remove it for now
}
struct AuctionItem {
mapping(uint256 => BidItem) bidItems;
uint256 bidItemsCount;
// config section
uint256 buyNowPrice;
uint256 reservedPrice;
uint256 minBidStep;
address configCurrency;
//
address assetOwner;
AuctionState state;
bytes32 scheduleId;
}
```
Hightlights:
1. The idea is store in the bidItems all the bids, incrementing the index every time a new bid is arrived, Also, we wanna store the bidItemsCount in order to know how many items do we have.
2. ~~All the data in the config section is ment to be stored in a common token, let’s say USDT, in order to be comparable with the followings bids.~~
- Config section is stored in any currency specified by the seller, we are gonna calculate de highest bid converting to a common currency on the fly.
4. The data stored in the bid items are in the same token that the bidder specifies.
5. For English auction we are gonna take the latest bid as the highest.
6. When the endAuction is triggered the AuctionStatus is changed to Initial if there is no bid items and to Sold if there is a winner.
7. Return previous bid after another place bid with a highest bid (EnglishAuction).