Skip to content
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
b808c2b
init hooks wizard
gonzaotc Aug 11, 2025
1e007d7
add hook utilities
gonzaotc Aug 12, 2025
faba830
add initial hooks controls
gonzaotc Aug 12, 2025
b03c350
remove readme
gonzaotc Aug 12, 2025
e078e95
up generation
gonzaotc Aug 13, 2025
b6115c1
up
gonzaotc Aug 13, 2025
e0f654e
add reliable hooks organization and utilities tooltips
gonzaotc Aug 13, 2025
db952de
add initial tooltips
gonzaotc Aug 13, 2025
0b5ae64
add uniswap deps
gonzaotc Aug 13, 2025
5dfb647
fix prepare error
gonzaotc Aug 13, 2025
45d7d64
add uniswap hooks hyperlinks
gonzaotc Aug 13, 2025
194b355
iterate hooks tooltips
gonzaotc Aug 13, 2025
b7be91c
fix kind sanitization
gonzaotc Aug 14, 2025
c650954
up tooltip
gonzaotc Aug 14, 2025
762b5a1
update remappings
gonzaotc Aug 18, 2025
20c07d8
fix addUsing compilation via addImportOnly addition
gonzaotc Aug 19, 2025
4de46d6
add erc1155 shares
gonzaotc Aug 19, 2025
0b02d69
add optional override "compatibleSemver" to printContract
gonzaotc Aug 19, 2025
6d9ff54
add a hooks folder containing each hook static data
gonzaotc Aug 19, 2025
d1b7b51
fix BaseHook compilation
gonzaotc Aug 19, 2025
c061c4f
add base hook function overrides
gonzaotc Aug 19, 2025
004965c
add required overrides
gonzaotc Aug 20, 2025
a0c05c5
merge with origin, add printContract option for additional libraries
gonzaotc Aug 20, 2025
0580129
solve conflicts with origin
gonzaotc Aug 20, 2025
71f3786
lint ui
gonzaotc Aug 20, 2025
e2784c3
update hooks snapshots
gonzaotc Aug 20, 2025
88d1d53
update snapshots
gonzaotc Aug 20, 2025
1546b24
add permissions component
gonzaotc Aug 21, 2025
344e8c4
up hooks permissions
gonzaotc Aug 21, 2025
8feecce
up
gonzaotc Aug 21, 2025
2dbe171
reorder perms
gonzaotc Aug 21, 2025
79c3b8a
up snapshots
gonzaotc Aug 21, 2025
3962a18
up pausability construction
gonzaotc Aug 22, 2025
5a287ff
fix pausability conficting overrides on custom functions
gonzaotc Aug 22, 2025
b7e605e
add automatic types importing
gonzaotc Aug 22, 2025
0d436ef
fix double import bug
gonzaotc Aug 22, 2025
7b06a4d
add required import paths
gonzaotc Aug 22, 2025
48582fd
fix compilation
gonzaotc Aug 22, 2025
041d6d8
lint
gonzaotc Aug 22, 2025
4163fee
up
gonzaotc Aug 22, 2025
bf1ff20
reorder controls
gonzaotc Aug 22, 2025
c0881ae
up tooltips & normalize hook names in UI
gonzaotc Aug 25, 2025
af17f95
lint
gonzaotc Aug 25, 2025
43fe35f
update uniswap-hooks package commit reference
gonzaotc Aug 25, 2025
dedffd8
update uniswap-hooks package commit reference
gonzaotc Aug 25, 2025
34f020e
up ava snapshots for basedynamicfee
gonzaotc Aug 25, 2025
96f25f7
up tooltips & shortcut permissions in ui
gonzaotc Aug 25, 2025
5c1c8ed
add lateral size to the hooks wizard selector panel
gonzaotc Aug 25, 2025
8cf50c9
Merge branch 'master' of github.com:OpenZeppelin/contracts-wizard int…
gonzaotc Aug 25, 2025
d0652cf
add try the ui builder component to hooks html
gonzaotc Aug 25, 2025
59e99dc
Add simple download button
gonzaotc Aug 25, 2025
302ef9d
download foundry project wip
gonzaotc Aug 25, 2025
305d7be
empty changelog
gonzaotc Aug 25, 2025
4adb616
removed openzeppelin community from inject hyperlinks
gonzaotc Aug 25, 2025
8b947af
up version tag
gonzaotc Aug 25, 2025
4fade89
refactor addUsing towards addLibrary
gonzaotc Aug 25, 2025
5b348a2
simplify get imports
gonzaotc Aug 25, 2025
f1ee4f9
print hooks functions if permissions are enabled
gonzaotc Aug 26, 2025
7e5cb2f
add permission depency auto-selection and permission function additio…
gonzaotc Aug 27, 2025
1f2ab4c
solve conflicting override
gonzaotc Aug 27, 2025
ae40d10
Add ExpandableSection and use in Hook Permissions
gonzaotc Aug 27, 2025
4e5ea07
up ava snapshots
gonzaotc Aug 27, 2025
38da7e1
modularize SharesControlsSection and make Utilities collapsable
gonzaotc Aug 27, 2025
75fda2f
up remappings in uniswap hooks repo
gonzaotc Aug 27, 2025
a89a016
reorganize shares tab
gonzaotc Aug 28, 2025
9b83ef6
make shares required in BaseCustomAccounting and CustomCurve
gonzaotc Aug 28, 2025
222a421
up base override fee permissions
gonzaotc Aug 28, 2025
c61b0e2
fix a state bug in permission selection
gonzaotc Aug 28, 2025
23f8c21
remove log
gonzaotc Aug 28, 2025
7c20743
simplify hook names
gonzaotc Aug 29, 2025
960ae35
Merge branch 'master' of github.com:OpenZeppelin/contracts-wizard int…
gonzaotc Aug 29, 2025
c637945
update imports
gonzaotc Aug 29, 2025
af18d7f
up tests
gonzaotc Aug 29, 2025
054bce0
enhance tooltips
gonzaotc Aug 29, 2025
ca4d391
merge with origin
gonzaotc Sep 24, 2025
4b39243
Merge branch 'master' of github.com:OpenZeppelin/contracts-wizard int…
gonzaotc Oct 1, 2025
dda3ca4
add rehypothecation hook and hookfee
gonzaotc Oct 2, 2025
30352d8
implemented better shares config handling in core and ui
gonzaotc Oct 3, 2025
4b2815d
remove pool manager construction param
gonzaotc Oct 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/core/solidity/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface Contract {
license: string;
parents: Parent[];
natspecTags: NatspecTag[];
using: Using[];
imports: ImportContract[];
functions: ContractFunction[];
constructorCode: string[];
Expand Down Expand Up @@ -133,6 +134,15 @@ export class ContractBuilder implements Contract {
return !present;
}

addUsing(library: ImportContract, usingFor: string): boolean {
const exists = this.using.some(u => u.library.name === library.name && u.usingFor === usingFor);
if (!exists) {
this.using.push({ library, usingFor });
return true;
}
return false;
}

addOverride(parent: ReferencedContract, baseFn: BaseFunction, mutability?: FunctionMutability) {
const fn = this.addFunction(baseFn);
fn.override.add(parent);
Expand Down
18 changes: 18 additions & 0 deletions packages/core/solidity/src/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function printContract(contract: Contract, opts?: Options): string {
[`contract ${contract.name}`, ...printInheritance(contract, helpers), '{'].join(' '),

spaceBetween(
printUsing(contract, helpers),
contract.variables,
printConstructor(contract, helpers),
...fns.code,
Expand Down Expand Up @@ -260,3 +261,20 @@ function printImports(imports: ImportContract[], helpers: Helpers): string[] {

return lines;
}

function printUsing(contract: Contract, { transformName }: Helpers): string[] {
if (!contract.using || contract.using.length === 0) {
return [];
}

// Emit in stable order by library then type to keep output deterministic
const entries = [...contract.using].sort((a, b) => {
if (a.library.name < b.library.name) return -1;
if (a.library.name > b.library.name) return 1;
if (a.usingFor < b.usingFor) return -1;
if (a.usingFor > b.usingFor) return 1;
return 0;
});

return entries.map(u => `using ${transformName(u.library)} for ${u.usingFor};`);
}
4 changes: 4 additions & 0 deletions packages/core/uniswap-hooks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/cache
/artifacts
/contracts/generated
/openzeppelin-contracts.json
6 changes: 6 additions & 0 deletions packages/core/uniswap-hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog


## 0.0.1 (2025-08-11)

- Initial version. (PR link)
661 changes: 661 additions & 0 deletions packages/core/uniswap-hooks/LICENSE

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/core/uniswap-hooks/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
OpenZeppelin Contracts Wizard
Copyright (C) 2021-2025 Zeppelin Group Ltd

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
1 change: 1 addition & 0 deletions packages/core/uniswap-hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# OpenZeppelin Contracts Wizard for Uniswap Hooks
9 changes: 9 additions & 0 deletions packages/core/uniswap-hooks/ava.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
extensions: ['ts'],
require: ['ts-node/register'],
watchmode: {
ignoreChanges: ['contracts', 'artifacts', 'cache'],
},
timeout: '10m',
workerThreads: false,
};
38 changes: 38 additions & 0 deletions packages/core/uniswap-hooks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@openzeppelin/wizard-uniswap-hooks",
"version": "0.0.1",
"description": "A boilerplate generator to get started with OpenZeppelin Contracts for Uniswap Hooks",
"license": "AGPL-3.0-only",
"repository": "https://github.com/OpenZeppelin/contracts-wizard",
"main": "dist/index.js",
"ts:main": "src/index.ts",
"files": [
"LICENSE",
"NOTICE",
"/dist",
"/src",
"!**/*.test.*"
],
"scripts": {
"prepare": "tsc",
"prepublish": "rimraf dist *.tsbuildinfo && hardhat clean",
"test": "ava",
"test:update-snapshots": "ava --update-snapshots",
"test:watch": "ava --watch"
},
"devDependencies": {
"@openzeppelin/contracts": "^5.3.0",
"@openzeppelin/uniswap-hooks": "https://github.com/OpenZeppelin/uniswap-hooks",
"@uniswap/v4-core": "^1.0.2",
"@uniswap/v4-periphery": "^1.0.3",
"@types/node": "^20.0.0",
"@types/semver": "^7.5.7",
"ava": "^6.0.0",
"hardhat": "^2.22.11",
"rimraf": "^5.0.0",
"semver": "^7.6.0",
"solidity-ast": "^0.4.18",
"ts-node": "^10.4.0",
"typescript": "^5.0.0"
}
}
16 changes: 16 additions & 0 deletions packages/core/uniswap-hooks/src/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { WizardContractAPI, AccessControlAPI } from '@openzeppelin/wizard/src/api';

import {
printHooks,
defaults as hooksDefaults,
isAccessControlRequired as hooksIsAccessControlRequired,
} from './hooks';
import type { HooksOptions } from './hooks';

export type Hooks = WizardContractAPI<HooksOptions> & AccessControlAPI<HooksOptions>;

export const hooks: Hooks = {
print: printHooks,
defaults: hooksDefaults,
isAccessControlRequired: hooksIsAccessControlRequired,
};
16 changes: 16 additions & 0 deletions packages/core/uniswap-hooks/src/build-generic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Contract } from '@openzeppelin/wizard/src/contract';
import type { HooksOptions } from './hooks';
import { buildHooks } from './hooks';

export interface KindedOptions {
Hooks: { kind: 'Hooks' } & HooksOptions;
}

export type GenericOptions = KindedOptions[keyof KindedOptions];

export function buildGeneric(opts: GenericOptions): Contract {
switch (opts.kind) {
case 'Hooks':
return buildHooks(opts);
}
}
33 changes: 33 additions & 0 deletions packages/core/uniswap-hooks/src/generate/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { HookName, HooksOptions } from '../hooks';
import { Hooks } from '../hooks';
import { accessOptions } from '@openzeppelin/wizard/src/set-access-control';
import { infoOptions } from '@openzeppelin/wizard/src/set-info';
import { generateAlternatives } from '@openzeppelin/wizard/src/generate/alternatives';

const booleanOptions = [true, false];

const sharesOptions = [
{ options: false, name: 'MyShares', symbol: 'MSH' },
{ options: 'ERC20', name: 'MyShares', symbol: 'MSH' },
{ options: 'ERC6909', name: 'MyShares', symbol: 'MSH' },
] as const;

const hooksOptions: HookName[] = Hooks.map(hook => hook.name);

const blueprint = {
hook: hooksOptions as readonly HookName[],
name: ['MyHook'] as const,
pausable: booleanOptions,
currencySettler: booleanOptions,
safeCast: booleanOptions,
transientStorage: booleanOptions,
access: accessOptions,
// Hooks are not upgradeable yet; fix to false
upgradeable: [false] as const,
info: infoOptions,
shares: sharesOptions,
};

export function* generateHooksOptions(): Generator<Required<HooksOptions>> {
yield* generateAlternatives(blueprint);
}
Loading
Loading