Skip to content

circuit breaker pool extension#326

Open
moodysalem wants to merge 12 commits into
mainfrom
circuit-breaker
Open

circuit breaker pool extension#326
moodysalem wants to merge 12 commits into
mainfrom
circuit-breaker

Conversation

@moodysalem

Copy link
Copy Markdown
Member

Add circuit breaker Ekubo extension with black-swan swap protection

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new CircuitBreaker pool extension intended to pause swaps after large within-block tick movement (“black swan” protection), along with supporting packed state + helper library and a dedicated test suite (including a gas snapshot).

Changes:

  • Introduces CircuitBreaker extension with beforeInitializePool, beforeSwap, and afterSwap hooks to enforce tick-movement limits and halting.
  • Adds CircuitBreakerPoolState packed type + CircuitBreakerLib helper functions for reading state and determining fuse status.
  • Adds CircuitBreaker.t.sol tests and a snapshot entry for swap gas measurement.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/extensions/CircuitBreaker.sol Implements circuit breaker extension logic and storage for per-pool state.
src/types/circuitBreakerPoolState.sol Adds packed state encoding/decoding helpers for last swap timestamp + block start tick.
src/libraries/CircuitBreakerLib.sol Adds convenience getters for pool state, reset time, elapsed time, and fuse-tripped checks.
src/interfaces/extensions/ICircuitBreaker.sol Defines extension interface (params + errors).
test/extensions/CircuitBreaker.t.sol Adds tests covering registration, init, revert paths, fuse behavior, and gas snapshot.
snapshots/CircuitBreakerTest.json Stores gas snapshot for a representative circuit-breaker swap scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/types/circuitBreakerPoolState.sol
Comment thread test/extensions/CircuitBreaker.t.sol Outdated
Comment thread src/extensions/CircuitBreaker.sol Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/extensions/CircuitBreaker.sol
Comment thread src/extensions/CircuitBreaker.sol

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/extensions/CircuitBreaker.sol
Comment thread src/libraries/CircuitBreakerLib.sol Outdated
Comment thread test/extensions/CircuitBreaker.t.sol Outdated
@moodysalem

Copy link
Copy Markdown
Member Author

@copilot apply changes based on the comments in this thread

Copilot AI commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

Applied the requested thread fixes in commit 1f00f35: constructor now rejects haltDuration == 0, CircuitBreakerLib.resetTime() now directly uses lastSwapTimestamp + HALT_DURATION, and the unused using CircuitBreakerLib for ICircuitBreaker; directive was removed from the test file.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/extensions/CircuitBreaker.sol Outdated
Comment thread test/extensions/CircuitBreaker.t.sol Outdated
moodysalem and others added 2 commits April 19, 2026 18:21
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@moodysalem

Copy link
Copy Markdown
Member Author

@copilot fix the tests

Agent-Logs-Url: https://github.com/EkuboProtocol/evm-contracts/sessions/20730d73-f8f7-486e-baf5-20aa2dbc781e

Co-authored-by: moodysalem <7897876+moodysalem@users.noreply.github.com>

Copilot AI commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

@copilot fix the tests

Fixed. Commit e8423b5 updates snapshots/CircuitBreakerTest.json so the circuit breaker gas snapshot matches current test output (94056 -> 93907), which resolves the CI test failure.

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.

3 participants