Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CuttingBoardDutchAuctionV1_2

Git Source

Inherits: CuttingBoardDutchAuctionV1_1

Title: CuttingBoardDutchAuctionV1_2

Patch upgrade fixing one bug in CuttingBoardDutchAuctionV1_1: Bug — setMinimumPrice during a live auction can corrupt lastClosingPrice. Root cause: setMinimumPrice (V1) raises lastClosingPrice when the new minimum exceeds it. If called while an auction is live, lastClosingPrice is lifted above the auction's decay range. When _processClaim later sets lastClosingPrice = currentPrice (≤ startingPrice), it drops below the raised minimum. The next startCuttingBoardAuction then derives a starting price from this depressed lastClosingPrice while base is clamped to the higher minimumPrice, causing an InvalidPriceRange revert. Fix: reject setMinimumPrice while a live (unclaimed, unexpired) auction exists. Keepers must wait until the auction ends (claimed or expired) before adjusting the price floor. Enhancement — cap multiplier/divisor values to prevent extreme pricing. Root cause: unbounded startingPriceMultiplier or basePriceDivisor values can produce auction price ranges so extreme that they are effectively unusable (e.g., overflow-adjacent starting prices or near-zero base prices). A malicious or misconfigured keeper could set these to values orders of magnitude beyond any reasonable range. Fix: both setStartingPriceMultiplier and setBasePriceDivisor enforce an upper bound of MAX_MULTIPLIER (100e18, i.e. 100x). This still allows wide pricing flexibility while preventing degenerate cases.

State Variables

MAX_MULTIPLIER

Upper bound for startingPriceMultiplier and basePriceDivisor. 100e18 (100x) prevents extreme price ranges while allowing wide keeper flexibility. Values beyond this would produce degenerate auction parameters (overflow-adjacent starts or near-zero floors).

uint256 internal constant MAX_MULTIPLIER = 100e18

Functions

setMinimumPrice

Update the minimum price floor

Overrides V1 to reject calls while a live auction exists, preventing lastClosingPrice corruption that leads to InvalidPriceRange on the next startCuttingBoardAuction.

function setMinimumPrice(uint256 _minimumPrice)
    external
    virtual
    override
    onlyKeeper;

Parameters

NameTypeDescription
_minimumPriceuint256New minimum price in payment token decimals

setBasePriceDivisor

Update the base price divisor (controls price floor)

Overrides V1 to enforce upper bound of MAX_MULTIPLIER (100e18). Must be > 1e18 and <= MAX_MULTIPLIER.

function setBasePriceDivisor(uint256 _basePriceDivisor)
    external
    virtual
    override
    onlyKeeper;

Parameters

NameTypeDescription
_basePriceDivisoruint256New divisor (e.g., 2e18 = 0.5x previous price)

setStartingPriceMultiplier

Update the starting price multiplier (controls auction start price)

Overrides V1 to enforce upper bound of MAX_MULTIPLIER (100e18). Must be > 1e18 and <= MAX_MULTIPLIER.

function setStartingPriceMultiplier(uint256 _startingPriceMultiplier)
    external
    virtual
    override
    onlyKeeper;

Parameters

NameTypeDescription
_startingPriceMultiplieruint256New multiplier (e.g., 2e18 = 2x previous price)

setAllocationDuration

Update the allocation duration (control period length)

Overrides V1 to remove the auctions-already-started guard, allowing governance to adjust the duration after the first auction. Safe because the value is snapshot into each Auction struct at creation time, so only future auctions are affected.

function setAllocationDuration(uint256 _allocationDuration)
    external
    virtual
    override
    onlyGovernor;

Parameters

NameTypeDescription
_allocationDurationuint256New allocation duration in seconds

setAuctionDuration

Update the auction duration (price decay period)

Overrides V1 to remove the auctions-already-started guard, allowing governance to adjust the duration after the first auction. Rejects calls while a live auction exists because auctionDuration is read from storage (not snapshotted into the Auction struct), so changing it mid-flight would alter the price decay curve, expiry check, and the setMinimumPrice active-auction guard.

function setAuctionDuration(uint256 _auctionDuration)
    external
    virtual
    override
    onlyGovernor;

Parameters

NameTypeDescription
_auctionDurationuint256New auction duration in seconds

Errors

AuctionStillActive

Reverts when setMinimumPrice is called during a live auction.

error AuctionStillActive();