-
Notifications
You must be signed in to change notification settings - Fork 233
Hook Allowlist Upgrade to Hook Registry #1228
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Process completed with exit code 1.
try { | ||
const files = fs.readdirSync(hooksDir).filter((file) => file.endsWith('.json')) | ||
|
||
for (const file of files) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can parallelzie the file read.
} | ||
|
||
function loadAllHookFiles(): HookFile[] { | ||
const hooksDir = path.resolve(process.cwd(), 'lib', 'util', 'hooks', 'prod') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, im a bit unsure if we want to read from local actually, because we usually read from https://raw.githubusercontent.com
. in future, when we want to externalize the hooks config into a standalone github repo, it's easier to make the change
This PR introduces a new extensible structure for hooks to be added to Uniswap Labs routing utilizing the HookRegistry schema. As a result, this PR heavily modifies how the list of allowed hooks is generated, and simplifies the logic for manually inflating pool TVL
Summary
Details of Major Changes in hooksAddressesAllowlist.ts
HookLists
Previously hooksAddressesAllowlist.ts was a straightforward list of hardcoded hook addresses which were compiled into a single array of hook addresses mapped to chain IDs. Due to the expectation that more hook metadata (not-on-chain) information will be needed by more services and features in the future, it was necessary to start capturing more information than just a hook's addresses. To support this, the HookList format proposed by Uniswap Foundation is used to include metadata with each hook.
To allow hook builders to provide PRs and modify their hook and pool lists without interfering with other hook builders' PRs, it made sense to allow multiple HookList files to be provided, so that a hook builder can have their own list which they maintain. Therefore, the lib/util/hooks/prod directory allows multiple HookLists to exist. Those hooks that have been ported into the HookList format include some for specific builders with many pools or hooks, and one general.json file for one-off hooks that are allowlisted. Going forward, hook PRs should be formatted in the prescribed HookList format, and may add additional metadata, which may be used by Uniswap Labs for display or additional information lookup.
Allowed Hooks List Building
The hooksAddressesAllowlist.ts is restructured to be a reader of HookList files, with the output being array objects of specific information needed by different processes. This may evolve further in the future to simply compile all available HookList metadata into an array so that any process can use the single standard data format. But for now, two different lists are produced:
The hooksaddressAllowlist.ts is designed to support the addition of future HookLists. It also specifies the expected format of the modified HookList by defining the interface of a HookList.
Detail of Major Changes in v4HooksPoolsFiltering.ts
In the prior logic, v4HooksPoolsFiltering.ts performed two key functions which have been updated:
Details of Major Changes in cache-pools.ts
Previously several specific pools were hardcoded so that they would be populated into the V4 pool cache in case they are not picked up by the pool identification logic. Now, any pool which is provided through a HookList and which contains sufficient information (feeTier, tickSpacing, liquidity, token, and TVL) will be placed into the pool cache. This updated logic required all hard-coded pool information to be moved into the appropriate HookList. It also replaces the previous logic specific to bunni pools, allowing the full removal of the bunni-pools.ts file. This updated logic infers that a complete set of pool details in the HookList means that a pool should be cached.
Misc.
Resolved ROUTE-635