diff --git a/src/pages/initialize/HookDataInit.solsnippet b/src/pages/initialize/HookDataInit.solsnippet index 7d6376c6..9070632e 100644 --- a/src/pages/initialize/HookDataInit.solsnippet +++ b/src/pages/initialize/HookDataInit.solsnippet @@ -1,4 +1,4 @@ -IPoolManager manager = IPoolManager(0x01); +PoolInitializeTest initializeRouter = PoolInitializeTest(0x01); address hook = address(0x80); // prefix indicates the hook only has a beforeInitialize() function address token0 = address(0x11); @@ -19,4 +19,4 @@ PoolKey memory pool = PoolKey({ tickSpacing: tickSpacing, hooks: IHooks(hook) }); -manager.initialize(pool, startingPrice, hookData); \ No newline at end of file +initializeRouter.initialize(pool, startingPrice, hookData); \ No newline at end of file diff --git a/src/pages/initialize/Hookless.solsnippet b/src/pages/initialize/Hookless.solsnippet index 747d8c34..bf71b4dd 100644 --- a/src/pages/initialize/Hookless.solsnippet +++ b/src/pages/initialize/Hookless.solsnippet @@ -1,4 +1,4 @@ -IPoolManager manager = IPoolManager(0x01); +PoolInitializeTest initializeRouter = PoolInitializeTest(0x01); address token0 = address(0x11); address token1 = address(0x22); @@ -18,4 +18,4 @@ PoolKey memory pool = PoolKey({ tickSpacing: tickSpacing, hooks: IHooks(address(0x0)) // !!! Hookless pool is address(0x0) }); -manager.initialize(pool, startingPrice, hookData); \ No newline at end of file +initializeRouter.initialize(pool, startingPrice, hookData); \ No newline at end of file diff --git a/src/pages/initialize/PoolInitialize.sol b/src/pages/initialize/PoolInitialize.sol index 2e2fbba0..6250ea1b 100644 --- a/src/pages/initialize/PoolInitialize.sol +++ b/src/pages/initialize/PoolInitialize.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.20; import {IPoolManager} from "@uniswap/v4-core/contracts/interfaces/IPoolManager.sol"; +import {PoolInitializeTest} from "@uniswap/v4-core/contracts/test/PoolInitializeTest.sol"; import {IHooks} from "@uniswap/v4-core/contracts/interfaces/IHooks.sol"; import {PoolKey} from "@uniswap/v4-core/contracts/types/PoolKey.sol"; import {CurrencyLibrary, Currency} from "@uniswap/v4-core/contracts/types/Currency.sol"; @@ -9,8 +10,8 @@ import {CurrencyLibrary, Currency} from "@uniswap/v4-core/contracts/types/Curren contract PoolInitialize { using CurrencyLibrary for Currency; - // set the pool manager address - IPoolManager manager = IPoolManager(0x01); + // set the initialize router + PoolInitializeTest initializeRouter = PoolInitializeTest(0x02); function init( address token0, @@ -33,6 +34,6 @@ contract PoolInitialize { tickSpacing: tickSpacing, hooks: IHooks(hook) }); - manager.initialize(pool, sqrtPriceX96, hookData); + initializeRouter.initialize(pool, sqrtPriceX96, hookData); } } diff --git a/src/pages/initialize/index.html.ts b/src/pages/initialize/index.html.ts index b9759498..dfb3c711 100644 --- a/src/pages/initialize/index.html.ts +++ b/src/pages/initialize/index.html.ts @@ -15,15 +15,15 @@ export const keywords = [ export const codes = [ { fileName: "HookDataInit.sol", - code: "SVBvb2xNYW5hZ2VyIG1hbmFnZXIgPSBJUG9vbE1hbmFnZXIoMHgwMSk7CgphZGRyZXNzIGhvb2sgPSBhZGRyZXNzKDB4ODApOyAvLyBwcmVmaXggaW5kaWNhdGVzIHRoZSBob29rIG9ubHkgaGFzIGEgYmVmb3JlSW5pdGlhbGl6ZSgpIGZ1bmN0aW9uCmFkZHJlc3MgdG9rZW4wID0gYWRkcmVzcygweDExKTsKYWRkcmVzcyB0b2tlbjEgPSBhZGRyZXNzKDB4MjIpOwp1aW50MjQgc3dhcEZlZSA9IDMwMDA7IC8vIDAuMzAlIGZlZSB0aWVyCmludDI0IHRpY2tTcGFjaW5nID0gNjA7CgovLyBmbG9vcihzcXJ0KDEpICogMl45NikKdWludDE2MCBzdGFydGluZ1ByaWNlID0gNzkyMjgxNjI1MTQyNjQzMzc1OTM1NDM5NTAzMzY7CgovLyBBc3N1bWUgdGhlIGN1c3RvbSBob29rIHJlcXVpcmVzIGEgdGltZXN0YW1wIHdoZW4gaW5pdGlhbGl6aW5nIGl0CmJ5dGVzIG1lbW9yeSBob29rRGF0YSA9IGFiaS5lbmNvZGUoYmxv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jApLAogICAgY3VycmVuY3kxOiBDdXJyZW5jeS53cmFwKHRva2VuMSksCiAgICBmZWU6IHN3YXBGZWUsCiAgICB0aWNrU3BhY2luZzogdGlja1NwYWNpbmcsCiAgICBob29rczogSUhvb2tzKGhvb2spCn0pOwppbml0aWFsaXplUm91dGVyLmluaXRpYWxpemUocG9vbCwgc3RhcnRpbmdQcmljZSwgaG9va0RhdGEpOw==", }, { fileName: "Hookless.sol", - code: "SVBvb2xNYW5hZ2VyIG1hbmFnZXIgPSBJUG9vbE1hbmFnZXIoMHgwMSk7CgphZGRyZXNzIHRva2VuMCA9IGFkZHJlc3MoMHgxMSk7CmFkZHJlc3MgdG9rZW4xID0gYWRkcmVzcygweDIyKTsKdWludDI0IHN3YXBGZWUgPSA1MDA7IC8vIDAuMDUlIGZlZSB0aWVyCmludDI0IHRpY2tTcGFjaW5nID0gMTA7CgovLyBmbG9vcihzcXJ0KDEpICogMl45NikKdWludDE2MCBzdGFydGluZ1ByaWNlID0gNzkyMjgxNjI1MTQyNjQzMzc1OTM1NDM5NTAzMzY7CgovLyBob29rbGVzcyBwb29sIGRvZXNudCBleHBlY3QgYW55IGluaXRpYWxpemF0aW9uIGRhdGEKYnl0ZXMgbWVtb3J5IGhvb2tEYXRhID0gbmV3IGJ5dGVzKDApOwoKUG9vbEtleSBtZW1vcnkgcG9vbCA9IFBvb2xLZXkoewogICAgY3VycmVuY3kwOiBDdXJyZW5jeS53cmFwKHRva2VuMCksCiAgICBjdXJyZW5jeTE6IEN1cnJlbmN5LndyYXAodG9rZW4xKSwKICAgIGZlZTogc3dhcEZlZSwKICAgIHRpY2tTcGFjaW5nOiB0aWNrU3BhY2luZywKICAgIGhvb2tzOiBJSG9va3MoYWRkcmVzcygweDApKSAvLyAhISEgSG9va2xlc3MgcG9vbCBpcyBhZGRyZXNzKDB4MCkKfSk7Cm1hbmFnZXIuaW5pdGlhbGl6ZShwb29sLCBzdGFydGluZ1ByaWNlLCBob29rRGF0YSk7", + code: "UG9v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FsaXplUm91dGVyID0gUG9vbEluaXRpYWxpemVUZXN0KDB4MDIpOwoKICAgIGZ1bmN0aW9uIGluaXQoCiAgICAgICAgYWRkcmVzcyB0b2tlbjAsCiAgICAgICAgYWRkcmVzcyB0b2tlbjEsCiAgICAgICAgdWludDI0IHN3YXBGZWUsCiAgICAgICAgaW50MjQgdGlja1NwYWNpbmcsCiAgICAgICAgYWRkcmVzcyBob29rLAogICAgICAgIHVpbnQxNjAgc3FydFByaWNlWDk2LAogICAgICAgIGJ5dGVzIGNhbGxkYXRhIGhvb2tEYXRhCiAgICApIGV4dGVybmFsIHsKICAgICAgICAvLyBzb3J0IHlvdXIgdG9rZW5zISB2NCByZXF1aXJlcyB0b2tlbjAgPCB0b2tlbjEKICAgICAgICBpZiAodG9rZW4wID4gdG9rZW4xKSB7CiAgICAgICAgICAgICh0b2tlbjAsIHRva2VuMSkgPSAodG9rZW4xLCB0b2tlbjApOwogICAgICAgIH0KCiAgICAgICAgUG9vbEtleSBtZW1vcnkgcG9vbCA9IFBvb2xLZXkoewogICAgICAgICAgICBjdXJyZW5jeTA6IEN1cnJlbmN5LndyYXAodG9rZW4wKSwKICAgICAgICAgICAgY3VycmVuY3kxOiBDdXJyZW5jeS53cmFwKHRva2VuMSksCiAgICAgICAgICAgIGZlZTogc3dhcEZlZSwKICAgICAgICAgICAgdGlja1NwYWNpbmc6IHRpY2tTcGFjaW5nLAogICAgICAgICAgICBob29rczogSUhvb2tzKGhvb2spCiAgICAgICAgfSk7CiAgICAgICAgaW5pdGlhbGl6ZVJvdXRlci5pbml0aWFsaXplKHBvb2wsIHNxcnRQcmljZVg5NiwgaG9va0RhdGEpOwogICAgfQp9Cg==", }, ] @@ -45,6 +45,7 @@ const html = `
Hooks are not mandatory, you can create a pool without a hook
-IPoolManager manager = IPoolManager(0x01);
+PoolInitializeTest initializeRouter = PoolInitializeTest(0x01);
address token0 = address(0x11);
address token1 = address(0x22);
@@ -101,9 +102,9 @@ PoolKey memory pool address(0x0)) // !!! Hookless pool is address(0x0)
});
-manager.initialize(pool, startingPrice, hookData);
+initializeRouter.initialize(pool, startingPrice, hookData);
Some hooks may require initialization data, i.e. block.timestamp
-IPoolManager manager = IPoolManager(0x01);
+PoolInitializeTest initializeRouter = PoolInitializeTest(0x01);
address hook = address(0x80); // prefix indicates the hook only has a beforeInitialize() function
address token0 = address(0x11);
@@ -124,7 +125,7 @@ PoolKey memory pool