-
Notifications
You must be signed in to change notification settings - Fork 2
Angstrom Hooks with tests #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 36 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
8d0d97d
Fix names of files and implement swap tests
joaobrunoah 24a63a5
Create hook logic and tests to verify signatures
joaobrunoah 3480ff0
Fix signature test
joaobrunoah b354a32
Test error OnlyOncePerBlock
joaobrunoah 385e966
100% coverage
joaobrunoah b2b6461
Block unbalanced liquidity operations when Angstrom is locked
joaobrunoah 73c6b13
100% test coverage
joaobrunoah b48049d
Commit test
joaobrunoah 226cf6f
Run github action
joaobrunoah d955e5a
Remove unused dependency
joaobrunoah a6742b9
Natspec
joaobrunoah 77e9d60
Fix solady install
joaobrunoah 78715cf
Fix lint
joaobrunoah 1be7f44
Fix function mutability
joaobrunoah d08401b
Merge pull request #4 from balancer/angstrom-hook
joaobrunoah 2c21fea
Modify package.json to Angstrom
joaobrunoah 3fedf8e
Readme
joaobrunoah 42f0474
Fix contract names and repo
joaobrunoah d0e5949
docs: update comments and non-semantics
EndymionJkb c770e11
refactor: rename `_nodes` for clarity
EndymionJkb 5a325d7
refactor: add `isRegisteredNode` getter; add `fromValidator` modifier…
EndymionJkb e841b11
refactor: add onlyWhenLocked modifier, and isolate updates in `_unloc…
EndymionJkb 49fd080
refactor: rename validator modifier; simplify unlockAngstrom helper
EndymionJkb b63265a
refactor: simplify/rename unlock functions; move getters from mock; r…
EndymionJkb 28b2500
test: don't need leading underscores in tests
EndymionJkb f6bbc67
test: introduce intermediate test
EndymionJkb 793e9a9
fix: createHook in proper place
EndymionJkb 5b41904
test: propagate intermediate test
EndymionJkb 6632cdd
refactor: rename validator modifier; simplify onBeforeSwap
EndymionJkb 5603a14
refactor: remove redundant code
EndymionJkb 4804023
refactor: rename/reorder
EndymionJkb 124194a
refactor: remove unused function
EndymionJkb 1ca3856
refactor: one more simplification - only revert in one place for each…
EndymionJkb d5b569c
docs: adjust comments after review
EndymionJkb 6b24bc5
Merge pull request #6 from balancer/angstrom-updates-v2
EndymionJkb 459f82a
Merge pull request #7 from balancer/support-hardhat-contracts
joaobrunoah 94c94ac
Fix PR comment
joaobrunoah d23b3f8
Add event when adding/removing node
joaobrunoah ecc153e
Use OwnableAuthentication instead of Singleton
joaobrunoah b8f11ee
Use mcopy instead of a for loop
joaobrunoah b257566
Update contracts/AngstromBalancer.sol
joaobrunoah f26e69e
Unify invalid signature errors
joaobrunoah 657ac83
Change toggle to add/remove
joaobrunoah 418d2a0
Revert add/removeNode if node state is inconsistent
joaobrunoah 2f88693
Fix remappings
joaobrunoah 001b761
Fix Angstrom to use only memory signatures
joaobrunoah eba2693
Add comments
joaobrunoah e6a55a5
Use unlockAngstromWithSignature directly
joaobrunoah 7af693d
Apply suggestions from code review
joaobrunoah c0cedc6
Fix register/deregister nodes
joaobrunoah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,56 @@ | ||
| # custom-pool-v3 | ||
| # Balancer V3 Angstrom Router and Hook | ||
|
|
||
| Example of external custom pool for Balancer V3. Extend it to create new pool types. | ||
| A specialized router and hook system for Balancer V3 that implements node-based access control and block-level unlocking mechanisms for Angstrom pools. | ||
|
|
||
| # Requirements | ||
| ## Overview | ||
|
|
||
| The Angstrom Router is a combination of a batch router and hook that provides controlled access to Angstrom pools within the Balancer V3 ecosystem. It ensures that only registered nodes can perform swaps and unbalanced liquidity operations before the network is unlocked for a given block, maintaining price consistency with off-chain computations. | ||
|
|
||
| ## Key Features | ||
|
|
||
| ### 🔐 Node-Based Access Control | ||
|
|
||
| - Only registered Angstrom nodes can perform the first swap and/or liquidity transaction (before network unlock) | ||
| - Node registration is managed through authenticated `toggleNodes()` function | ||
| - Prevents unauthorized access to locked pools | ||
|
|
||
| ### 🔓 Block-Level Unlocking | ||
|
|
||
| - Network can only be unlocked once per block | ||
joaobrunoah marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Unlocking is global - once unlocked, all pools accept operations from any router | ||
|
|
||
| ### 🔄 Dual Operation Modes | ||
|
|
||
| - **Router Mode**: Direct swaps against pools, as a registered node (no signature required) | ||
| - **Hook Mode**: Operations through any router with cryptographic signature verification (node register is still required) | ||
joaobrunoah marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### 📊 Comprehensive Swap Support | ||
|
|
||
| - Exact amount in swaps (`swapExactIn`) | ||
| - Exact amount out swaps (`swapExactOut`) | ||
| - Query functions for both swap types | ||
| - Support for multi-hop routing through multiple pools | ||
|
|
||
| ### 🏊 Liquidity Hooks for pools | ||
|
|
||
| - Proportional liquidity operations (no unlock required) | ||
| - Unbalanced liquidity operations (requires network unlock) | ||
| - Hook-based validation for all liquidity operations | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Node.js v18.x (we recommend using nvm to install it) | ||
| - Yarn v4.x | ||
| - Foundry v1.0.0 | ||
|
|
||
| # Installation | ||
| ## Installation | ||
|
|
||
| If it's the first time running the project, run `sh ./scripts/install-fresh.sh` to install the dependencies and build the project. It'll download and compile V3 monorepo, creating node_modules folders in the library (these folders will be needed to use monorepo as a submodule of the angstrom project). | ||
joaobrunoah marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Testing | ||
|
|
||
| If it's the first time running the project, run `sh ./scripts/install-fresh.sh` to install the dependencies and build the project. It'll download and compile V3 monorepo, creating node_modules folders in the library (these folders will be needed to use monorepo as a submodule of the custom pool, so tests can use the base test files). | ||
| After installing the dependencies, run `yarn test:forge` to run forge tests. Also, run `yarn coverage` to generate a coverage report. | ||
|
|
||
| # Testing | ||
| ## Contributing | ||
|
|
||
| After installing the dependencies, run `yarn test` to run forge and hardhat tests. | ||
| This project is part of the Balancer ecosystem. Please refer to the main Balancer repository for contribution guidelines. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.