Skip to content

[codex] Require graduation for LBP params#342

Merged
zhongeric merged 1 commit into
devfrom
codex-lbp-params-revert-non-graduated
May 21, 2026
Merged

[codex] Require graduation for LBP params#342
zhongeric merged 1 commit into
devfrom
codex-lbp-params-revert-non-graduated

Conversation

@zhongeric

Copy link
Copy Markdown
Contributor

Description

Updates ContinuousClearingAuction.lbpInitializationParams() to revert with NotGraduated after finalization if the auction did not graduate. This keeps the ILBPInitializer response aligned with the interface expectation that returned initialization values are correct at call time, since failed auctions do not have settled currencyRaised and tokensSold values for LBP migration.

The PR also adds BTT coverage for the finalized-but-not-graduated case and adjusts existing initializer-param fixtures that are intended to exercise successful graduated auctions.

How Has This Been Tested?

  • forge test --offline --match-path test/btt/auction/lbpInitializationParams.t.sol
  • forge test --offline --match-path 'test/btt/auction/*.t.sol'
  • forge test --offline --match-path test/btt/auctionFactory/initializeDistribution.t.sol
  • forge fmt --check

Note: I started a full forge test --offline run, but it was intentionally stopped because it was taking too long. Completed output before termination showed passing suites only, with pre-existing compiler/deprecation warnings.

@zhongeric zhongeric marked this pull request as ready for review May 21, 2026 21:50
@zhongeric zhongeric requested a review from a team as a code owner May 21, 2026 21:50
@zhongeric zhongeric merged commit ceaf535 into dev May 21, 2026
5 checks passed
zhongeric added a commit that referenced this pull request Jun 16, 2026
* chore: cleanup step storage (#321)

* feat: add CCALens and TickDataLens (#325)

* feat: add CCALens and TickDataLens

* chore: update deploy script for CCALens

* feat: build buffer in memory instead of preallocating

* chore: natspec

* refactor: optimize TickDataLens memory handling

---------

Co-authored-by: mgretzke <m.gretzke@vimage.de>
Co-authored-by: Mark Gretzke <65617397+mgretzke@users.noreply.github.com>

* feat: only recipient can sweep (#329)

* feat: only receiver can sweep

* fix: added missing error in interface

* test: fixed and added new

* test: moved tests

* chore: fix flaky test for low values

* feat: add supply rollover (#327)

* save

* save

* initial implementation

* save

* fix: div by MPS

* save

* save

* save state

* save

* pass most

* save state

* fix: case where remaining supply can be zero

* rollover passes all invariant tests + added comments

* fix requiredDemand* functions and added comments

* chore: add getters to IContinuousClearingAuction

* chore: fix gas by removing console.log statements

* chore: cleanup nits

* nit: naming

* nit: improve comments

* fix: test showing rounding difference when currencyRaised is calculated

* chore: fix wei limit

* fix: required demand at price test

* chore: renaming functions in lib and fixing tests

* chore: gas

* feat: add toPriceCeiling function to DemandLib

* chore: add btt tests for toPriceCeiling function

* chore: fix canClearSupplyAtPrice test

* chore: natspec

* feat: add currencyRaisedAtPrice to DemandLib

* chore: rm using keyword for math

* chore: update canClearSupplyAtPrice test

* comments and fix gas test

* chore: comments

* fix: fuzz tests for canClearSupplyAtPrice

* feat: add currencyRaisedAtPrice test coverage

* fix: stack too deep

* chore: update gas snap

* feat: custody tokens (#330)

* feat: custody tokens

* refactor: remove unused NotAuthorized error

* fix: added custody tokens to previous tests and scripts

* test: added new tests

* fuzzed custodyTokens

* fuzzed custodyTokens in Constructor tests

* test: tests asserting that the custody tokens are swept

* Added Fuzz tests to Auction.custodyTokens.t.sol

* fix: updated comment

* chore: reworked natspec comments

---------

Co-authored-by: Eric Zhong <eric.zhong@uniswap.org>

* fix: test sweepUnsoldTokens caller address

* fix: flaky test bound

* chore: remove dos test (#333)

* chore: refactor auction storage (#332)

* chore: refactor auction storage

* chore: fix

* chore: forge fmt

* fix: remove flaky TickDataLens gas snapshot

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: remainingSupply is zero edge case (#331)

* save

* save

* initial implementation

* save

* fix: div by MPS

* save

* save

* save state

* save

* pass most

* save state

* fix: case where remaining supply can be zero

* rollover passes all invariant tests + added comments

* fix requiredDemand* functions and added comments

* chore: add getters to IContinuousClearingAuction

* chore: fix gas by removing console.log statements

* chore: cleanup nits

* nit: naming

* nit: improve comments

* fix: test showing rounding difference when currencyRaised is calculated

* chore: fix wei limit

* fix: required demand at price test

* chore: renaming functions in lib and fixing tests

* chore: gas

* feat: add toPriceCeiling function to DemandLib

* chore: add btt tests for toPriceCeiling function

* chore: fix canClearSupplyAtPrice test

* chore: natspec

* feat: add currencyRaisedAtPrice to DemandLib

* chore: rm using keyword for math

* chore: update canClearSupplyAtPrice test

* comments and fix gas test

* chore: comments

* fix: fuzz tests for canClearSupplyAtPrice

* feat: add currencyRaisedAtPrice test coverage

* save: local

* fix: remainingSupplyZero edge case

* fix: stack too deep

* feat: add test coverage for remainingSupplyZero edge case

* rm plan

* fix: merge conflicts

* fix: check remaining supply is not zero on bid submission

* add: test for remaining supply being zero

* fix: clamp total cleared to total supply

* chore: comments

* fix test

* fix: remove saturating sub and use sub directly and fix tests

* revert: remove custody tokens from CCA (#335)

Remove the custody token configuration and behavior so CCA returns to total-supply-only token deposits and unsold token sweeps while preserving the newer storage and test refactors.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: tighten min floor price inverse boundary (#336)

Ensure the documented Q96 reciprocal of MIN_FLOOR_PRICE fits in uint160 for downstream LBP/v4 initialization math.

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor: call checkpoint accounting library directly (#338)

Remove thin CheckpointStorage accounting wrappers so bid exits use the underlying library helpers directly, and keep tests/docs aligned with the reduced storage surface.

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat: add protocol fee controller (#340)

* add liquidity launcher submodule

* update dep

* move up to dev

* fix: imports

* chore: inheritdoc

* feat: add protocol fees to CCA, factory, and storage

* feat: add owner-controlled protocol fee controller

Co-authored-by: Cursor <cursoragent@cursor.com>

* update docs

* fix: address protocol fee review comments

Cache raised currency reads, avoid protocol fee transfer before sweep state is written, and expose the factory fee controller with clearer naming.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: simplify protocol fee controller wiring

Make factory protocol fee controllers immutable, document runtime fee lookups, and add sweep currency gas snapshots.

Co-authored-by: Cursor <cursoragent@cursor.com>

* nit comment

* fix

---------

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: support rollover math in TickDataLens (#334)

* fix: support rollover math in TickDataLens

Use the auction's rollover-aware required demand helper so tick data reflects remaining supply over the remaining issuance schedule.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: cache rollover demand inputs in TickDataLens

Avoid calling requiredDemandQ96 for each initialized tick by caching remaining supply and schedule values once per lens read.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: compute TickDataLens rollover values in Solidity

Keep assembly scoped to tick array construction while using Solady math helpers for rollover demand calculations.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: simplify TickDataLens tick traversal

Use plain Solidity for tick traversal and rollover data calculation now that derived values are computed outside assembly.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: traverse TickDataLens ticks once

Allocate the max buffer once and trim the returned array length after filling rollover tick data in a single pass.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix: allocate TickDataLens results by actual tick count

Build the returned tick array in assembly as ticks are discovered to avoid expanding memory for the full max buffer.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore: comments

* fix: handle empty TickDataLens tick list

Co-authored-by: Cursor <cursoragent@cursor.com>

* refactor: merged last loop into first loop (#341)

* refactor: merged last loop into first loop

* fix: forge fmt

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Mark Gretzke <65617397+mgretzke@users.noreply.github.com>

* fix: require graduation for lbp params (#342)

* chore: update invariant tests (#337)

* add clearing price max invariant

* fix mock auction setup and add handleExitBid

* optimize exit bid invariant handler

Co-authored-by: Cursor <cursoragent@cursor.com>

* working state for invariant tests

* add new invariants

* rm

* fix up generators

* Simplify fuzz value generation

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix invariant checkpoint mutability

Co-authored-by: Cursor <cursoragent@cursor.com>

* Improve invariant bid generation

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix up

* rm ll

---------

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore: add v2.0.0 changelog entry

Document changes on the dev branch relative to main, including breaking
changes to the auction and factory constructors, the protocol fee
controller addition, sweep authorization, interface renames, supply
rollover settlement math, and the new lens contracts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs: update README for v2.0.0

Note the immutable protocol fee controller on the factory, add a v2.0.0
row to the factory deployment table, add a separate CCALens deployment
section, and refresh the repo structure to reflect AuctionStorage and
the lens contracts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs: refresh TechnicalDocumentation for v2.0.0

Add a Protocol Overview that walks integrators through the mechanism
end-to-end (issuance schedule, tick book, clearing price, rollover,
checkpoints, graduation, LBP handoff, fees). Rewrite the factory
section: the controller is immutable, there is no factory owner, and
there is no setProtocolFeeController. Add new Protocol Fees and Lens
Contracts sections. Add lbpInitializationParams documentation. Fix
sweep authorization (callable only by the respective recipients) and
note the protocol fee deduction in sweepCurrency. Fix the min tick
spacing (2, not 1), the min floor price bound, the ValueX7 NatSpec to
match the library, and the currencyRaisedAtClearingPriceQ96X7 name.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat: don't revert on sweepCurrency for non graduated auctions (#343)

* interface fix

* one getAddress

* update latest

* sender not deployer

* fix: checkpoint before validation hook (#346)

* SB-L-7: Clamp protocol fee to currency raised in sweepCurrency (#354)

* fix: clamp protocol fee to currency raised in sweepCurrency (L-7)

sweepCurrency() queries the PROTOCOL_FEE_CONTROLLER at sweep time and
computed `currencyRaised - protocolFeeAmount` with no bound. A misbehaving
or misconfigured fee controller returning protocolFeeAmount > currencyRaised
underflowed the subtraction and reverted, permanently bricking the sweep.

Clamp protocolFeeAmount to currencyRaised before the subtraction so the
sweep always proceeds (full amount sent as the protocol fee, zero swept to
the funds recipient).

Adds a BTT fuzz case (and tree branch) asserting the sweep succeeds and
clamps when the controller returns a fee greater than the currency raised.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: snapshots

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: mgretzke <m.gretzke@vimage.de>

* fix: apply SB informational audit fixes (N-2 through N-6) (#353)

N-2: add missing @param _cumulativeMps natspec to
     _iterateOverTicksAndFindClearingPrice
N-3: AuctionStateLens.parseRevertReason now bubbles up any non-empty
     revert reason (incl. the 4-byte CheckpointFailed selector) instead
     of only reasons longer than 32 bytes, so CheckpointFailed is
     reachable from state(); InvalidRevertReasonLength now only fires on
     empty revert data. Adds a lens test covering a reverting checkpoint.
N-4: remove unnecessary `abstract` from StepStorage (all methods implemented)
N-5: fix "can claimed" -> "can be claimed" comment typo
N-6: remove unused imports (IERC20Minimal, BlockNumberish, Currency,
     FixedPoint96, ConstantsLib, FixedPointMathLib) across 5 files

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix: handle empty next active tick demand (#345)

* OZ-notes: Apply note-level audit fixes (N-01 through N-05) (#352)

* refactor: use ValueX7 operators

* chore: remove validation hook mode support

* chore: hide duplicate protocol fee getter

* refactor: make Q96 price naming consistent

* chore: remove unused DemandLib import

* Prevent same-block force iteration from changing bid admission (#355)

* Prevent same-block force iteration admission changes

* fix merge

---------

Co-authored-by: Eric Zhong <eric.zhong@uniswap.org>

* chore: update changelog

* chore: fix gas snaps

---------

Co-authored-by: mgretzke <m.gretzke@vimage.de>
Co-authored-by: Mark Gretzke <65617397+mgretzke@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: dianakocsis <diana.kocsis@uniswap.org>
Co-authored-by: diana <dlkocsis04@gmail.com>
Co-authored-by: devtooligan <devtooligan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant