Skip to content

Commit

Permalink
👷 auctionReady
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Oct 25, 2024
1 parent 94bc947 commit c11885c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/KSXVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,21 @@ contract KSXVault is ERC4626, Ownable, Initializable {

/// @notice Checks if the auction is ready to start
function auctionReady() public view returns (bool) {
if (_startOfWeek(block.timestamp) > lastAuctionStartTime) {
bool isOneWeek = auctionCooldown == MAX_AUCTION_COOLDOWN;
bool divisibleByWeek = MAX_AUCTION_COOLDOWN / auctionCooldown > 2;
if (isOneWeek && _startOfWeek(block.timestamp) > lastAuctionStartTime) {
/// @dev if the auctions are started weekly then check if the current time is after the start of the week
return true;
} else if (!divisibleByWeek && _startOfWeek(block.timestamp) + auctionCooldown > lastAuctionStartTime) {
/// @dev if the cooldown is not a multiple of a week then check if the cooldown has passed
/// the start of the week + the cooldown period
return true;
} else if (divisibleByWeek) {
/// @dev this needs to check multiple times the auction cooldown because
/// the cooldown is a multiple of a week
//todo recrursively? go through n number of auctionCooldown periods to see if
// the last auction time is less than the start of the week + n * auctionCooldown?
// maybe do decrementing loop?
return true;
} else {
return false;
Expand Down

0 comments on commit c11885c

Please sign in to comment.