@reptilianhq/uniswap-sdk 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/abis.d.ts CHANGED
@@ -157,5 +157,60 @@ export declare const v4PoolManagerAbi: readonly [{
157
157
  readonly name: "tick";
158
158
  }];
159
159
  }];
160
+ export declare const v4PositionManagerAbi: readonly [{
161
+ readonly name: "initializePool";
162
+ readonly type: "function";
163
+ readonly stateMutability: "payable";
164
+ readonly inputs: readonly [{
165
+ readonly type: "tuple";
166
+ readonly components: readonly [{
167
+ readonly type: "address";
168
+ readonly name: "currency0";
169
+ }, {
170
+ readonly type: "address";
171
+ readonly name: "currency1";
172
+ }, {
173
+ readonly type: "uint24";
174
+ readonly name: "fee";
175
+ }, {
176
+ readonly type: "int24";
177
+ readonly name: "tickSpacing";
178
+ }, {
179
+ readonly type: "address";
180
+ readonly name: "hooks";
181
+ }];
182
+ readonly name: "key";
183
+ }, {
184
+ readonly type: "uint160";
185
+ readonly name: "sqrtPriceX96";
186
+ }];
187
+ readonly outputs: readonly [{
188
+ readonly type: "int24";
189
+ }];
190
+ }, {
191
+ readonly name: "modifyLiquidities";
192
+ readonly type: "function";
193
+ readonly stateMutability: "payable";
194
+ readonly inputs: readonly [{
195
+ readonly type: "bytes";
196
+ readonly name: "unlockData";
197
+ }, {
198
+ readonly type: "uint256";
199
+ readonly name: "deadline";
200
+ }];
201
+ readonly outputs: readonly [];
202
+ }, {
203
+ readonly name: "multicall";
204
+ readonly type: "function";
205
+ readonly stateMutability: "payable";
206
+ readonly inputs: readonly [{
207
+ readonly type: "bytes[]";
208
+ readonly name: "data";
209
+ }];
210
+ readonly outputs: readonly [{
211
+ readonly type: "bytes[]";
212
+ readonly name: "results";
213
+ }];
214
+ }];
160
215
  export * from './v3-abis.js';
161
216
  //# sourceMappingURL=abis.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abis.d.ts","sourceRoot":"","sources":["../src/abis.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMzB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKtB,CAAC;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE3B,CAAC;AAEH,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"abis.d.ts","sourceRoot":"","sources":["../src/abis.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMzB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKtB,CAAC;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE3B,CAAC;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK/B,CAAC;AAEH,cAAc,cAAc,CAAC"}
package/dist/abis.js CHANGED
@@ -17,5 +17,11 @@ export const v4QuoterAbi = parseAbi([
17
17
  export const v4PoolManagerAbi = parseAbi([
18
18
  'event Initialize(bytes32 indexed id, address indexed currency0, address indexed currency1, uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick)',
19
19
  ]);
20
+ export const v4PositionManagerAbi = parseAbi([
21
+ 'struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }',
22
+ 'function initializePool(PoolKey key, uint160 sqrtPriceX96) payable returns (int24)',
23
+ 'function modifyLiquidities(bytes unlockData, uint256 deadline) payable',
24
+ 'function multicall(bytes[] data) payable returns (bytes[] results)',
25
+ ]);
20
26
  export * from './v3-abis.js';
21
27
  //# sourceMappingURL=abis.js.map
package/dist/abis.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"abis.js","sourceRoot":"","sources":["../src/abis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,+EAA+E;AAC/E,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;IACrC,+CAA+C;IAC/C,qHAAqH;IACrH,wEAAwE;IACxE,2EAA2E;IAC3E,kHAAkH;CACnH,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC;IAClC,+CAA+C;IAC/C,wGAAwG;IACxG,0GAA0G;IAC1G,gHAAgH;CACjH,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACvC,4KAA4K;CAC7K,CAAC,CAAC;AAEH,cAAc,cAAc,CAAC","sourcesContent":["import { parseAbi } from 'viem';\n\n// Standard v4-core/periphery selectors; extracted from the bot's read surface.\n// They do not attest compatibility of a supplied custom deployment.\nexport const v4StateViewAbi = parseAbi([\n 'function poolManager() view returns (address)',\n 'function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)',\n 'function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)',\n 'function getTickBitmap(bytes32 poolId, int16 word) view returns (uint256)',\n 'function getTickLiquidity(bytes32 poolId, int24 tick) view returns (uint128 liquidityGross, int128 liquidityNet)',\n]);\nexport const v4QuoterAbi = parseAbi([\n 'function poolManager() view returns (address)',\n 'struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }',\n 'struct QuoteExactSingleParams { PoolKey poolKey; bool zeroForOne; uint128 exactAmount; bytes hookData; }',\n 'function quoteExactInputSingle(QuoteExactSingleParams params) returns (uint256 amountOut, uint256 gasEstimate)',\n]);\nexport const v4PoolManagerAbi = parseAbi([\n 'event Initialize(bytes32 indexed id, address indexed currency0, address indexed currency1, uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick)',\n]);\n\nexport * from './v3-abis.js';\n"]}
1
+ {"version":3,"file":"abis.js","sourceRoot":"","sources":["../src/abis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEhC,+EAA+E;AAC/E,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;IACrC,+CAA+C;IAC/C,qHAAqH;IACrH,wEAAwE;IACxE,2EAA2E;IAC3E,kHAAkH;CACnH,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC;IAClC,+CAA+C;IAC/C,wGAAwG;IACxG,0GAA0G;IAC1G,gHAAgH;CACjH,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACvC,4KAA4K;CAC7K,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC3C,wGAAwG;IACxG,oFAAoF;IACpF,wEAAwE;IACxE,oEAAoE;CACrE,CAAC,CAAC;AAEH,cAAc,cAAc,CAAC","sourcesContent":["import { parseAbi } from 'viem';\n\n// Standard v4-core/periphery selectors; extracted from the bot's read surface.\n// They do not attest compatibility of a supplied custom deployment.\nexport const v4StateViewAbi = parseAbi([\n 'function poolManager() view returns (address)',\n 'function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)',\n 'function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)',\n 'function getTickBitmap(bytes32 poolId, int16 word) view returns (uint256)',\n 'function getTickLiquidity(bytes32 poolId, int24 tick) view returns (uint128 liquidityGross, int128 liquidityNet)',\n]);\nexport const v4QuoterAbi = parseAbi([\n 'function poolManager() view returns (address)',\n 'struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }',\n 'struct QuoteExactSingleParams { PoolKey poolKey; bool zeroForOne; uint128 exactAmount; bytes hookData; }',\n 'function quoteExactInputSingle(QuoteExactSingleParams params) returns (uint256 amountOut, uint256 gasEstimate)',\n]);\nexport const v4PoolManagerAbi = parseAbi([\n 'event Initialize(bytes32 indexed id, address indexed currency0, address indexed currency1, uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick)',\n]);\nexport const v4PositionManagerAbi = parseAbi([\n 'struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }',\n 'function initializePool(PoolKey key, uint160 sqrtPriceX96) payable returns (int24)',\n 'function modifyLiquidities(bytes unlockData, uint256 deadline) payable',\n 'function multicall(bytes[] data) payable returns (bytes[] results)',\n]);\n\nexport * from './v3-abis.js';\n"]}
@@ -0,0 +1,44 @@
1
+ import type { Address } from 'viem';
2
+ /**
3
+ * A v4 hook's capability bits, decoded from its address. Field names match
4
+ * Uniswap's `Hooks.sol`. Declared independently of `@uniswap/v4-sdk`'s own
5
+ * `HookPermissions` (keyed by its nominal `HookOptions` enum) so callers can
6
+ * work with plain string keys instead of importing that enum too.
7
+ */
8
+ export interface V4HookPermissions {
9
+ beforeInitialize: boolean;
10
+ afterInitialize: boolean;
11
+ beforeAddLiquidity: boolean;
12
+ afterAddLiquidity: boolean;
13
+ beforeRemoveLiquidity: boolean;
14
+ afterRemoveLiquidity: boolean;
15
+ beforeSwap: boolean;
16
+ afterSwap: boolean;
17
+ beforeDonate: boolean;
18
+ afterDonate: boolean;
19
+ beforeSwapReturnsDelta: boolean;
20
+ afterSwapReturnsDelta: boolean;
21
+ afterAddLiquidityReturnsDelta: boolean;
22
+ afterRemoveLiquidityReturnsDelta: boolean;
23
+ }
24
+ /**
25
+ * A v4 hook address encodes which PoolManager callbacks it implements in its low 14 bits
26
+ * (mined via CREATE2, so PoolManager can check permissions without an external call).
27
+ * Delegates the bit-to-callback mapping to `@uniswap/v4-sdk`'s `Hook` class rather than
28
+ * re-deriving it, so the mapping stays pinned to a versioned upstream dependency instead
29
+ * of drifting from memory.
30
+ */
31
+ export declare function decodeV4HookPermissions(address: Address): V4HookPermissions;
32
+ /**
33
+ * The permission flags a hook implements that are not in `modelled`, i.e. the
34
+ * behaviour a caller has not accounted for. Empty means every flag the hook
35
+ * sets is one the caller already knows how to price and verify.
36
+ *
37
+ * This does not judge economic safety (tax rates, whether principal is
38
+ * locked) — only whether the hook's *shape* is fully understood. That
39
+ * judgement, and what "modelled" means for a given protocol, belongs to the
40
+ * caller: a beforeSwap hook is fine to a caller that prices beforeSwap price
41
+ * moves and unsafe to one that does not.
42
+ */
43
+ export declare function unmodelledV4HookPermissions(address: Address, modelled: Iterable<keyof V4HookPermissions>): (keyof V4HookPermissions)[];
44
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,sBAAsB,EAAE,OAAO,CAAC;IAChC,qBAAqB,EAAE,OAAO,CAAC;IAC/B,6BAA6B,EAAE,OAAO,CAAC;IACvC,gCAAgC,EAAE,OAAO,CAAC;CAC3C;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAE3E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,CAAC,MAAM,iBAAiB,CAAC,GAC1C,CAAC,MAAM,iBAAiB,CAAC,EAAE,CAM7B"}
package/dist/hooks.js ADDED
@@ -0,0 +1,29 @@
1
+ import { Hook } from './official-sdk.cjs';
2
+ import { checkedAddress } from './pool.js';
3
+ /**
4
+ * A v4 hook address encodes which PoolManager callbacks it implements in its low 14 bits
5
+ * (mined via CREATE2, so PoolManager can check permissions without an external call).
6
+ * Delegates the bit-to-callback mapping to `@uniswap/v4-sdk`'s `Hook` class rather than
7
+ * re-deriving it, so the mapping stays pinned to a versioned upstream dependency instead
8
+ * of drifting from memory.
9
+ */
10
+ export function decodeV4HookPermissions(address) {
11
+ return Hook.permissions(checkedAddress(address));
12
+ }
13
+ /**
14
+ * The permission flags a hook implements that are not in `modelled`, i.e. the
15
+ * behaviour a caller has not accounted for. Empty means every flag the hook
16
+ * sets is one the caller already knows how to price and verify.
17
+ *
18
+ * This does not judge economic safety (tax rates, whether principal is
19
+ * locked) — only whether the hook's *shape* is fully understood. That
20
+ * judgement, and what "modelled" means for a given protocol, belongs to the
21
+ * caller: a beforeSwap hook is fine to a caller that prices beforeSwap price
22
+ * moves and unsafe to one that does not.
23
+ */
24
+ export function unmodelledV4HookPermissions(address, modelled) {
25
+ const allowed = new Set(modelled);
26
+ const permissions = decodeV4HookPermissions(address);
27
+ return Object.keys(permissions).filter(flag => permissions[flag] && !allowed.has(flag));
28
+ }
29
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAyB3C;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,CAAsB,CAAC;AACxE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAgB,EAChB,QAA2C;IAE3C,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,WAAW,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACrD,OAAQ,MAAM,CAAC,IAAI,CAAC,WAAW,CAAiC,CAAC,MAAM,CACrE,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAChD,CAAC;AACJ,CAAC","sourcesContent":["import { Hook } from './official-sdk.cjs';\nimport type { Address } from 'viem';\nimport { checkedAddress } from './pool.js';\n\n/**\n * A v4 hook's capability bits, decoded from its address. Field names match\n * Uniswap's `Hooks.sol`. Declared independently of `@uniswap/v4-sdk`'s own\n * `HookPermissions` (keyed by its nominal `HookOptions` enum) so callers can\n * work with plain string keys instead of importing that enum too.\n */\nexport interface V4HookPermissions {\n beforeInitialize: boolean;\n afterInitialize: boolean;\n beforeAddLiquidity: boolean;\n afterAddLiquidity: boolean;\n beforeRemoveLiquidity: boolean;\n afterRemoveLiquidity: boolean;\n beforeSwap: boolean;\n afterSwap: boolean;\n beforeDonate: boolean;\n afterDonate: boolean;\n beforeSwapReturnsDelta: boolean;\n afterSwapReturnsDelta: boolean;\n afterAddLiquidityReturnsDelta: boolean;\n afterRemoveLiquidityReturnsDelta: boolean;\n}\n\n/**\n * A v4 hook address encodes which PoolManager callbacks it implements in its low 14 bits\n * (mined via CREATE2, so PoolManager can check permissions without an external call).\n * Delegates the bit-to-callback mapping to `@uniswap/v4-sdk`'s `Hook` class rather than\n * re-deriving it, so the mapping stays pinned to a versioned upstream dependency instead\n * of drifting from memory.\n */\nexport function decodeV4HookPermissions(address: Address): V4HookPermissions {\n return Hook.permissions(checkedAddress(address)) as V4HookPermissions;\n}\n\n/**\n * The permission flags a hook implements that are not in `modelled`, i.e. the\n * behaviour a caller has not accounted for. Empty means every flag the hook\n * sets is one the caller already knows how to price and verify.\n *\n * This does not judge economic safety (tax rates, whether principal is\n * locked) — only whether the hook's *shape* is fully understood. That\n * judgement, and what \"modelled\" means for a given protocol, belongs to the\n * caller: a beforeSwap hook is fine to a caller that prices beforeSwap price\n * moves and unsafe to one that does not.\n */\nexport function unmodelledV4HookPermissions(\n address: Address,\n modelled: Iterable<keyof V4HookPermissions>,\n): (keyof V4HookPermissions)[] {\n const allowed = new Set(modelled);\n const permissions = decodeV4HookPermissions(address);\n return (Object.keys(permissions) as (keyof V4HookPermissions)[]).filter(\n flag => permissions[flag] && !allowed.has(flag),\n );\n}\n"]}
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Pool = void 0;
3
+ exports.Percent = exports.V4PositionManager = exports.Position = exports.Hook = exports.Pool = void 0;
4
4
  // Upstream 2.3.3's ESM export contains extensionless directory imports that
5
5
  // native Node cannot resolve. Its public require export works in Node and
6
6
  // bundlers. Keep this compatibility seam local instead of forking the SDK.
7
7
  var v4_sdk_1 = require("@uniswap/v4-sdk");
8
8
  Object.defineProperty(exports, "Pool", { enumerable: true, get: function () { return v4_sdk_1.Pool; } });
9
+ Object.defineProperty(exports, "Hook", { enumerable: true, get: function () { return v4_sdk_1.Hook; } });
10
+ Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return v4_sdk_1.Position; } });
11
+ Object.defineProperty(exports, "V4PositionManager", { enumerable: true, get: function () { return v4_sdk_1.V4PositionManager; } });
12
+ var sdk_core_1 = require("@uniswap/sdk-core");
13
+ Object.defineProperty(exports, "Percent", { enumerable: true, get: function () { return sdk_core_1.Percent; } });
9
14
  //# sourceMappingURL=official-sdk.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"official-sdk.cjs","sourceRoot":"","sources":["../src/official-sdk.cts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAC3E,0CAAuC;AAA9B,8FAAA,IAAI,OAAA","sourcesContent":["// Upstream 2.3.3's ESM export contains extensionless directory imports that\n// native Node cannot resolve. Its public require export works in Node and\n// bundlers. Keep this compatibility seam local instead of forking the SDK.\nexport { Pool } from '@uniswap/v4-sdk';\n"]}
1
+ {"version":3,"file":"official-sdk.cjs","sourceRoot":"","sources":["../src/official-sdk.cts"],"names":[],"mappings":";;;AAAA,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAC3E,0CAA0E;AAAjE,8FAAA,IAAI,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAChD,8CAA4C;AAAnC,mGAAA,OAAO,OAAA","sourcesContent":["// Upstream 2.3.3's ESM export contains extensionless directory imports that\n// native Node cannot resolve. Its public require export works in Node and\n// bundlers. Keep this compatibility seam local instead of forking the SDK.\nexport { Pool, Hook, Position, V4PositionManager } from '@uniswap/v4-sdk';\nexport { Percent } from '@uniswap/sdk-core';\n"]}
@@ -1,2 +1,3 @@
1
- export { Pool } from '@uniswap/v4-sdk';
1
+ export { Pool, Hook, Position, V4PositionManager } from '@uniswap/v4-sdk';
2
+ export { Percent } from '@uniswap/sdk-core';
2
3
  //# sourceMappingURL=official-sdk.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"official-sdk.d.cts","sourceRoot":"","sources":["../src/official-sdk.cts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"official-sdk.d.cts","sourceRoot":"","sources":["../src/official-sdk.cts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { type Address, type Hex } from 'viem';
2
2
  import { type V4PoolReference } from './pool.js';
3
+ import { type V4HookPermissions } from './hooks.js';
3
4
  /** Structural contract implemented by protocol SDKs; contains no transport or signer. */
4
5
  export interface V4ProviderDescriptor {
5
6
  schemaVersion: 1;
@@ -10,6 +11,15 @@ export interface V4ProviderDescriptor {
10
11
  poolManager: Address;
11
12
  startBlock: bigint;
12
13
  hooks: readonly Address[];
14
+ /**
15
+ * Permission flags this provider has reviewed across `hooks` — what its hooks
16
+ * are known to do (tax a swap, gate initialization, etc.), not judged here.
17
+ * When present, every hook in `hooks` must implement only these flags, so a
18
+ * provider that has not reviewed a hook's full behaviour cannot silently pass
19
+ * verification once that hook starts using an extra callback. Optional so a
20
+ * provider can adopt this check independently of every other provider.
21
+ */
22
+ modelledHookPermissions?: readonly (keyof V4HookPermissions)[];
13
23
  discovery: {
14
24
  address: Address;
15
25
  eventSignature: string;
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3F,OAAO,EAA+B,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAG9E,yFAAyF;AACzF,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,CAAC,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,YAAY,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,SAAS,OAAO,EAAE,CAAC;IAC1B,SAAS,EAAE;QACT,OAAO,EAAE,OAAO,CAAC;Q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AAoB,GAAG,IAAI,CAiB/E;AAED,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CAY/F;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,KAAK,EAAE,SAAS,cAAc,EAAE,EAAE,OAAO,EAAE;IAClH,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAClE,SAAS,EAAE;QAAE,qBAAqB,EAAE,OAAO,CAAA;KAAE,CAAC;CAC/C;gBA2B4B,MAAM;kBAAgB,MAAM;aAAW,MAAM;aAAW,OAAO;eAAa,MAAM;aAAW,MAAM;YAAU,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,EAAE,CAAC;IAWvK"}
package/dist/providers.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getAddress, keccak256, toBytes, zeroAddress } from 'viem';
2
2
  import { checkedAddress, getV4PoolId } from './pool.js';
3
+ import { unmodelledV4HookPermissions } from './hooks.js';
3
4
  import { invalid } from './errors.js';
4
5
  const signatures = {
5
6
  Initialize: 'Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)',
@@ -31,6 +32,13 @@ export function verifyV4ProviderDescriptor(provider) {
31
32
  if (!provider.hooks.length)
32
33
  invalid('Provider must enumerate its reviewed hooks');
33
34
  provider.hooks.forEach(checkedAddress);
35
+ if (provider.modelledHookPermissions) {
36
+ for (const hookAddress of provider.hooks) {
37
+ const unmodelled = unmodelledV4HookPermissions(hookAddress, provider.modelledHookPermissions);
38
+ if (unmodelled.length)
39
+ invalid(`Provider hook implements unmodelled permissions: ${unmodelled.join(', ')}`);
40
+ }
41
+ }
34
42
  if (!provider.poolEvents.length || provider.poolEvents.some(event => !Object.hasOwn(signatures, event)))
35
43
  invalid('Explicit supported pool events are required');
36
44
  }
@@ -1 +1 @@
1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AK,CAAC,IAAI,CAAC;oBAChE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY;oBACpE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO;oBACzG,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;iBAClF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { getAddress, keccak256, toBytes, zeroAddress, type Address, type Hex } from 'viem';\nimport { checkedAddress, getV4PoolId, type V4PoolReference } from './pool.js';\nimport { invalid } from './errors.js';\n\n/** Structural contract implemented by protocol SDKs; contains no transport or signer. */\nexport interface V4ProviderDescriptor {\n schemaVersion: 1;\n providerId: string;\n deploymentId: string;\n substrate: 'uniswap-v4';\n chainId: number;\n poolManager: Address;\n startBlock: bigint;\n hooks: readonly Address[];\n discovery: {\n address: Address;\n eventSignature: string;\n poolIdParameter: string;\n expectedRuntimeCodeHash: Hex;\n };\n poolEvents: readonly V4PoolEvent[];\n}\nexport type V4PoolEvent = 'Initialize' | 'Swap' | 'ModifyLiquidity' | 'Donate';\nconst signatures: Record<V4PoolEvent, string> = {\n Initialize: 'Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)',\n Swap: 'Swap(bytes32,address,int128,int128,uint160,uint128,int24,uint24)',\n ModifyLiquidity: 'ModifyLiquidity(bytes32,address,int24,int24,int256,bytes32)',\n Donate: 'Donate(bytes32,address,uint256,uint256)',\n};\n\n/** Evidence is historical, not execution authorization. Protocol SDKs verify its meaning. */\nexport interface V4ProviderPool extends V4PoolReference {\n providerId: string;\n deploymentId: string;\n membership: {\n sourceAddress: Address;\n eventSignature: string;\n blockNumber: bigint;\n blockHash: Hex;\n transactionHash: Hex;\n logIndex: number;\n };\n}\n\nfunction hash(value: Hex) {\n if (!/^0x[\\da-f]{64}$/i.test(value) || /^0x0{64}$/i.test(value)) invalid('Expected a nonzero bytes32 hash');\n}\nfunction block(value: bigint) {\n if (typeof value !== 'bigint' || value < 0n) invalid('Expected a nonnegative block number');\n}\nexport function verifyV4ProviderDescriptor(provider: V4ProviderDescriptor): void {\n if (provider.schemaVersion !== 1 || provider.substrate !== 'uniswap-v4') invalid('Unsupported provider composition version or substrate');\n if (!provider.providerId?.trim() || !provider.deploymentId?.trim()) invalid('Provider and deployment identifiers are required');\n if (!Number.isSafeInteger(provider.chainId) || provider.chainId <= 0) invalid('Invalid provider chain ID');\n if (checkedAddress(provider.poolManager) === zeroAddress || checkedAddress(provider.discovery.address) === zeroAddress) invalid('Provider contracts cannot be zero addresses');\n block(provider.startBlock);\n hash(provider.discovery.expectedRuntimeCodeHash);\n if (!/^[A-Za-z]\\w*\\([^)]*\\)$/.test(provider.discovery.eventSignature) || !provider.discovery.poolIdParameter) invalid('Explicit pool membership discovery is required');\n if (!provider.hooks.length) invalid('Provider must enumerate its reviewed hooks');\n provider.hooks.forEach(checkedAddress);\n if (!provider.poolEvents.length || provider.poolEvents.some(event => !Object.hasOwn(signatures, event))) invalid('Explicit supported pool events are required');\n}\n\n/** Structural/identity verification only; the protocol SDK verifies registration provenance. */\nexport function verifyV4ProviderPool(provider: V4ProviderDescriptor, pool: V4ProviderPool): void {\n verifyV4ProviderDescriptor(provider);\n if (pool.providerId !== provider.providerId || pool.deploymentId !== provider.deploymentId || pool.chainId !== provider.chainId\n || checkedAddress(pool.poolManager) !== checkedAddress(provider.poolManager)) invalid('Pool belongs to a different provider deployment');\n if (!provider.hooks.some(hook => checkedAddress(hook) === checkedAddress(pool.key.hooks))) invalid('Pool uses an unreviewed provider hook');\n if (getV4PoolId(pool.key).toLowerCase() !== pool.poolId.toLowerCase()) invalid('Pool ID differs from its full key');\n if (checkedAddress(pool.membership.sourceAddress) !== checkedAddress(provider.discovery.address)\n || pool.membership.eventSignature !== provider.discovery.eventSignature) invalid('Pool membership uses a different discovery source');\n block(pool.membership.blockNumber);\n if (pool.membership.blockNumber < provider.startBlock) invalid('Pool membership predates deployment');\n hash(pool.membership.blockHash); hash(pool.membership.transactionHash);\n if (!Number.isSafeInteger(pool.membership.logIndex) || pool.membership.logIndex < 0) invalid('Invalid membership log index');\n}\n\n/** Bounded eth_getLogs-compatible plans. Empty selections return no requests, never a wildcard.\n * Hosts must apply topics upstream, retain canonical membership evidence, and replay discovery\n * blocks when the selection changes. Each query covers its whole first block, including events\n * emitted before the registration log. Hosts own reorg rollback, cursors and finality.\n */\nexport function buildV4PoolSubscriptions(provider: V4ProviderDescriptor, pools: readonly V4ProviderPool[], options: {\n fromBlock: bigint; toBlock: bigint; maxPoolIdsPerRequest?: number;\n transport: { indexedTopicFiltering: boolean };\n}) {\n verifyV4ProviderDescriptor(provider);\n block(options.fromBlock); block(options.toBlock);\n if (options.toBlock < options.fromBlock) invalid('Invalid subscription block range');\n if (!options.transport.indexedTopicFiltering) invalid('Selective v4 indexing requires upstream indexed-topic filtering');\n const size = options.maxPoolIdsPerRequest ?? 64;\n if (!Number.isSafeInteger(size) || size < 1 || size > 256) invalid('Pool filter batch size must be between 1 and 256');\n if (pools.length > 4096) invalid('At most 4096 selected pools per planning call');\n const selected = new Map<string, V4ProviderPool>();\n for (const pool of pools) {\n verifyV4ProviderPool(provider, pool);\n const id = pool.poolId.toLowerCase();\n const previous = selected.get(id);\n if (previous && (previous.membership.blockHash.toLowerCase() !== pool.membership.blockHash.toLowerCase()\n || previous.membership.blockNumber !== pool.membership.blockNumber\n || previous.membership.transactionHash.toLowerCase() !== pool.membership.transactionHash.toLowerCase()\n || previous.membership.logIndex !== pool.membership.logIndex)) invalid('Conflicting membership evidence; reconcile canonical history before subscribing');\n selected.set(id, pool);\n }\n const groups = new Map<bigint, Hex[]>();\n for (const [id, pool] of [...selected].sort(([a], [b]) => a.localeCompare(b))) {\n const start = pool.membership.blockNumber > options.fromBlock ? pool.membership.blockNumber : options.fromBlock;\n if (start > options.toBlock) continue;\n const group = groups.get(start) ?? [];\n group.push(id as Hex);\n groups.set(start, group);\n }\n const plans: { providerId: string; deploymentId: string; chainId: number; address: Address; fromBlock: bigint; toBlock: bigint; topics: readonly [Hex, readonly Hex[]] }[] = [];\n for (const [fromBlock, ids] of [...groups].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {\n for (let offset = 0; offset < ids.length; offset += size) {\n for (const event of [...new Set(provider.poolEvents)]) plans.push({\n providerId: provider.providerId, deploymentId: provider.deploymentId,\n chainId: provider.chainId, address: getAddress(provider.poolManager), fromBlock, toBlock: options.toBlock,\n topics: [keccak256(toBytes(signatures[event])), ids.slice(offset, offset + size)],\n });\n }\n }\n return plans;\n}\n"]}
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAA0B,MAAM,MAAM,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,WAAW,EAAwB,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAA0B,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA8BtC,MAAM,UAAU,GAAgC;IAC9C,UAAU,EAAE,wEAAwE;IACpF,IAAI,EAAE,kEAAkE;IACxE,eAAe,EAAE,6DAA6D;IAC9E,MAAM,EAAE,yCAAyC;CAClD,CAAC;AAgBF,SAAS,IAAI,CAAC,KAAU;IACtB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,iCAAiC,CAAC,CAAC;AAC9G,CAAC;AACD,SAAS,KA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C,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;iBAClF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { getAddress, keccak256, toBytes, zeroAddress, type Address, type Hex } from 'viem';\nimport { checkedAddress, getV4PoolId, type V4PoolReference } from './pool.js';\nimport { unmodelledV4HookPermissions, type V4HookPermissions } from './hooks.js';\nimport { invalid } from './errors.js';\n\n/** Structural contract implemented by protocol SDKs; contains no transport or signer. */\nexport interface V4ProviderDescriptor {\n schemaVersion: 1;\n providerId: string;\n deploymentId: string;\n substrate: 'uniswap-v4';\n chainId: number;\n poolManager: Address;\n startBlock: bigint;\n hooks: readonly Address[];\n /**\n * Permission flags this provider has reviewed across `hooks` — what its hooks\n * are known to do (tax a swap, gate initialization, etc.), not judged here.\n * When present, every hook in `hooks` must implement only these flags, so a\n * provider that has not reviewed a hook's full behaviour cannot silently pass\n * verification once that hook starts using an extra callback. Optional so a\n * provider can adopt this check independently of every other provider.\n */\n modelledHookPermissions?: readonly (keyof V4HookPermissions)[];\n discovery: {\n address: Address;\n eventSignature: string;\n poolIdParameter: string;\n expectedRuntimeCodeHash: Hex;\n };\n poolEvents: readonly V4PoolEvent[];\n}\nexport type V4PoolEvent = 'Initialize' | 'Swap' | 'ModifyLiquidity' | 'Donate';\nconst signatures: Record<V4PoolEvent, string> = {\n Initialize: 'Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)',\n Swap: 'Swap(bytes32,address,int128,int128,uint160,uint128,int24,uint24)',\n ModifyLiquidity: 'ModifyLiquidity(bytes32,address,int24,int24,int256,bytes32)',\n Donate: 'Donate(bytes32,address,uint256,uint256)',\n};\n\n/** Evidence is historical, not execution authorization. Protocol SDKs verify its meaning. */\nexport interface V4ProviderPool extends V4PoolReference {\n providerId: string;\n deploymentId: string;\n membership: {\n sourceAddress: Address;\n eventSignature: string;\n blockNumber: bigint;\n blockHash: Hex;\n transactionHash: Hex;\n logIndex: number;\n };\n}\n\nfunction hash(value: Hex) {\n if (!/^0x[\\da-f]{64}$/i.test(value) || /^0x0{64}$/i.test(value)) invalid('Expected a nonzero bytes32 hash');\n}\nfunction block(value: bigint) {\n if (typeof value !== 'bigint' || value < 0n) invalid('Expected a nonnegative block number');\n}\nexport function verifyV4ProviderDescriptor(provider: V4ProviderDescriptor): void {\n if (provider.schemaVersion !== 1 || provider.substrate !== 'uniswap-v4') invalid('Unsupported provider composition version or substrate');\n if (!provider.providerId?.trim() || !provider.deploymentId?.trim()) invalid('Provider and deployment identifiers are required');\n if (!Number.isSafeInteger(provider.chainId) || provider.chainId <= 0) invalid('Invalid provider chain ID');\n if (checkedAddress(provider.poolManager) === zeroAddress || checkedAddress(provider.discovery.address) === zeroAddress) invalid('Provider contracts cannot be zero addresses');\n block(provider.startBlock);\n hash(provider.discovery.expectedRuntimeCodeHash);\n if (!/^[A-Za-z]\\w*\\([^)]*\\)$/.test(provider.discovery.eventSignature) || !provider.discovery.poolIdParameter) invalid('Explicit pool membership discovery is required');\n if (!provider.hooks.length) invalid('Provider must enumerate its reviewed hooks');\n provider.hooks.forEach(checkedAddress);\n if (provider.modelledHookPermissions) {\n for (const hookAddress of provider.hooks) {\n const unmodelled = unmodelledV4HookPermissions(hookAddress, provider.modelledHookPermissions);\n if (unmodelled.length) invalid(`Provider hook implements unmodelled permissions: ${unmodelled.join(', ')}`);\n }\n }\n if (!provider.poolEvents.length || provider.poolEvents.some(event => !Object.hasOwn(signatures, event))) invalid('Explicit supported pool events are required');\n}\n\n/** Structural/identity verification only; the protocol SDK verifies registration provenance. */\nexport function verifyV4ProviderPool(provider: V4ProviderDescriptor, pool: V4ProviderPool): void {\n verifyV4ProviderDescriptor(provider);\n if (pool.providerId !== provider.providerId || pool.deploymentId !== provider.deploymentId || pool.chainId !== provider.chainId\n || checkedAddress(pool.poolManager) !== checkedAddress(provider.poolManager)) invalid('Pool belongs to a different provider deployment');\n if (!provider.hooks.some(hook => checkedAddress(hook) === checkedAddress(pool.key.hooks))) invalid('Pool uses an unreviewed provider hook');\n if (getV4PoolId(pool.key).toLowerCase() !== pool.poolId.toLowerCase()) invalid('Pool ID differs from its full key');\n if (checkedAddress(pool.membership.sourceAddress) !== checkedAddress(provider.discovery.address)\n || pool.membership.eventSignature !== provider.discovery.eventSignature) invalid('Pool membership uses a different discovery source');\n block(pool.membership.blockNumber);\n if (pool.membership.blockNumber < provider.startBlock) invalid('Pool membership predates deployment');\n hash(pool.membership.blockHash); hash(pool.membership.transactionHash);\n if (!Number.isSafeInteger(pool.membership.logIndex) || pool.membership.logIndex < 0) invalid('Invalid membership log index');\n}\n\n/** Bounded eth_getLogs-compatible plans. Empty selections return no requests, never a wildcard.\n * Hosts must apply topics upstream, retain canonical membership evidence, and replay discovery\n * blocks when the selection changes. Each query covers its whole first block, including events\n * emitted before the registration log. Hosts own reorg rollback, cursors and finality.\n */\nexport function buildV4PoolSubscriptions(provider: V4ProviderDescriptor, pools: readonly V4ProviderPool[], options: {\n fromBlock: bigint; toBlock: bigint; maxPoolIdsPerRequest?: number;\n transport: { indexedTopicFiltering: boolean };\n}) {\n verifyV4ProviderDescriptor(provider);\n block(options.fromBlock); block(options.toBlock);\n if (options.toBlock < options.fromBlock) invalid('Invalid subscription block range');\n if (!options.transport.indexedTopicFiltering) invalid('Selective v4 indexing requires upstream indexed-topic filtering');\n const size = options.maxPoolIdsPerRequest ?? 64;\n if (!Number.isSafeInteger(size) || size < 1 || size > 256) invalid('Pool filter batch size must be between 1 and 256');\n if (pools.length > 4096) invalid('At most 4096 selected pools per planning call');\n const selected = new Map<string, V4ProviderPool>();\n for (const pool of pools) {\n verifyV4ProviderPool(provider, pool);\n const id = pool.poolId.toLowerCase();\n const previous = selected.get(id);\n if (previous && (previous.membership.blockHash.toLowerCase() !== pool.membership.blockHash.toLowerCase()\n || previous.membership.blockNumber !== pool.membership.blockNumber\n || previous.membership.transactionHash.toLowerCase() !== pool.membership.transactionHash.toLowerCase()\n || previous.membership.logIndex !== pool.membership.logIndex)) invalid('Conflicting membership evidence; reconcile canonical history before subscribing');\n selected.set(id, pool);\n }\n const groups = new Map<bigint, Hex[]>();\n for (const [id, pool] of [...selected].sort(([a], [b]) => a.localeCompare(b))) {\n const start = pool.membership.blockNumber > options.fromBlock ? pool.membership.blockNumber : options.fromBlock;\n if (start > options.toBlock) continue;\n const group = groups.get(start) ?? [];\n group.push(id as Hex);\n groups.set(start, group);\n }\n const plans: { providerId: string; deploymentId: string; chainId: number; address: Address; fromBlock: bigint; toBlock: bigint; topics: readonly [Hex, readonly Hex[]] }[] = [];\n for (const [fromBlock, ids] of [...groups].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) {\n for (let offset = 0; offset < ids.length; offset += size) {\n for (const event of [...new Set(provider.poolEvents)]) plans.push({\n providerId: provider.providerId, deploymentId: provider.deploymentId,\n chainId: provider.chainId, address: getAddress(provider.poolManager), fromBlock, toBlock: options.toBlock,\n topics: [keccak256(toBytes(signatures[event])), ids.slice(offset, offset + size)],\n });\n }\n }\n return plans;\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import type { Currency } from '@uniswap/sdk-core';
2
+ import type { Address, Hex } from 'viem';
3
+ export type V4TransactionMaterial = {
4
+ to: Address;
5
+ data: Hex;
6
+ value: bigint;
7
+ };
8
+ /** Pool state as read from PoolManager/StateView (e.g. via `readV4Pool`), not yet a mint target. */
9
+ export type V4PoolState = {
10
+ currency0: Currency;
11
+ currency1: Currency;
12
+ fee: number;
13
+ tickSpacing: number;
14
+ hooks: Address;
15
+ sqrtPriceX96: bigint;
16
+ liquidity: bigint;
17
+ tickCurrent: number;
18
+ };
19
+ export type V4MintPositionParams = {
20
+ positionManager: Address;
21
+ pool: V4PoolState;
22
+ tickLower: number;
23
+ tickUpper: number;
24
+ /** Liquidity units to mint, not a token amount. */
25
+ liquidity: bigint;
26
+ recipient: Address;
27
+ /** Integer basis points, 0-10000. */
28
+ slippageToleranceBps: number;
29
+ deadlineSeconds: bigint;
30
+ /** Passed to the hook's callbacks verbatim; this SDK does not construct it. */
31
+ hookData?: Hex;
32
+ /** Atomically initializes the pool before minting. Requires `pool.sqrtPriceX96` to be the intended starting price. */
33
+ createPool?: boolean;
34
+ };
35
+ /**
36
+ * Builds unsigned calldata for `PositionManager.modifyLiquidities` minting a new v4 position.
37
+ * Delegates encoding to `@uniswap/v4-sdk`'s `V4PositionManager`/`V4PositionPlanner` (the same
38
+ * Actions/multicall encoding Uniswap's own SDK uses) rather than hand-rolling it, since v4's
39
+ * calldata is a sequence of packed actions, not a single ABI-encoded function call like v3's.
40
+ *
41
+ * No Permit2 support yet — callers must have already approved the position manager via a plain
42
+ * ERC20 approval, or the built transaction will revert on-chain. Hook-permission gating (refusing
43
+ * a pool whose hook implements more than the caller has modelled) is also the caller's
44
+ * responsibility; this function only encodes what it is given.
45
+ */
46
+ export declare function buildV4MintPositionTransaction(input: V4MintPositionParams): V4TransactionMaterial;
47
+ //# sourceMappingURL=v4-transactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v4-transactions.d.ts","sourceRoot":"","sources":["../src/v4-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAKzC,MAAM,MAAM,qBAAqB,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,oGAAoG;AACpG,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,QAAQ,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,sHAAsH;IACtH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AASF;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,CAyCjG"}
@@ -0,0 +1,57 @@
1
+ import { Percent, Pool, Position, V4PositionManager } from './official-sdk.cjs';
2
+ import { checkedAddress } from './pool.js';
3
+ import { invalid, UniswapSdkError } from './errors.js';
4
+ function slippagePercent(bps) {
5
+ if (!Number.isInteger(bps) || bps < 0 || bps > 10_000) {
6
+ invalid('slippageToleranceBps must be an integer between 0 and 10000');
7
+ }
8
+ return new Percent(bps, 10_000);
9
+ }
10
+ /**
11
+ * Builds unsigned calldata for `PositionManager.modifyLiquidities` minting a new v4 position.
12
+ * Delegates encoding to `@uniswap/v4-sdk`'s `V4PositionManager`/`V4PositionPlanner` (the same
13
+ * Actions/multicall encoding Uniswap's own SDK uses) rather than hand-rolling it, since v4's
14
+ * calldata is a sequence of packed actions, not a single ABI-encoded function call like v3's.
15
+ *
16
+ * No Permit2 support yet — callers must have already approved the position manager via a plain
17
+ * ERC20 approval, or the built transaction will revert on-chain. Hook-permission gating (refusing
18
+ * a pool whose hook implements more than the caller has modelled) is also the caller's
19
+ * responsibility; this function only encodes what it is given.
20
+ */
21
+ export function buildV4MintPositionTransaction(input) {
22
+ if (input.liquidity <= 0n)
23
+ invalid('Mint liquidity must be positive');
24
+ if (!Number.isInteger(input.tickLower) || !Number.isInteger(input.tickUpper) || input.tickLower >= input.tickUpper) {
25
+ invalid('tickLower must be an integer less than tickUpper');
26
+ }
27
+ if (input.createPool && input.pool.sqrtPriceX96 <= 0n)
28
+ invalid('createPool requires a positive initial sqrtPriceX96');
29
+ const positionManager = checkedAddress(input.positionManager);
30
+ const recipient = checkedAddress(input.recipient);
31
+ const slippageTolerance = slippagePercent(input.slippageToleranceBps);
32
+ try {
33
+ const pool = new Pool(input.pool.currency0, input.pool.currency1, input.pool.fee, input.pool.tickSpacing, checkedAddress(input.pool.hooks), input.pool.sqrtPriceX96.toString(), input.pool.liquidity.toString(), input.pool.tickCurrent);
34
+ const position = new Position({
35
+ pool,
36
+ liquidity: input.liquidity.toString(),
37
+ tickLower: input.tickLower,
38
+ tickUpper: input.tickUpper,
39
+ });
40
+ const params = V4PositionManager.addCallParameters(position, {
41
+ recipient,
42
+ createPool: input.createPool ?? false,
43
+ ...(input.createPool ? { sqrtPriceX96: input.pool.sqrtPriceX96.toString() } : {}),
44
+ useNative: pool.currency0.isNative ? pool.currency0 : undefined,
45
+ slippageTolerance,
46
+ hookData: input.hookData,
47
+ deadline: input.deadlineSeconds.toString(),
48
+ });
49
+ return { to: positionManager, data: params.calldata, value: BigInt(params.value) };
50
+ }
51
+ catch (cause) {
52
+ if (cause instanceof UniswapSdkError)
53
+ throw cause;
54
+ throw new UniswapSdkError('INVALID_ARGUMENT', 'Official Uniswap SDK rejected the mint parameters', { cause });
55
+ }
56
+ }
57
+ //# sourceMappingURL=v4-transactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v4-transactions.js","sourceRoot":"","sources":["../src/v4-transactions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ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e;YAAE,MAAM,KAAK,CAAC;QAClD,MAAM,IAAI,eAAe,CAAC,kBAAkB,EAAE,mDAAmD,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAChH,CAAC;AACH,CAAC","sourcesContent":["import type { Currency } from '@uniswap/sdk-core';\nimport type { Address, Hex } from 'viem';\nimport { Percent, Pool, Position, V4PositionManager } from './official-sdk.cjs';\nimport { checkedAddress } from './pool.js';\nimport { invalid, UniswapSdkError } from './errors.js';\n\nexport type V4TransactionMaterial = { to: Address; data: Hex; value: bigint };\n\n/** Pool state as read from PoolManager/StateView (e.g. via `readV4Pool`), not yet a mint target. */\nexport type V4PoolState = {\n currency0: Currency;\n currency1: Currency;\n fee: number;\n tickSpacing: number;\n hooks: Address;\n sqrtPriceX96: bigint;\n liquidity: bigint;\n tickCurrent: number;\n};\n\nexport type V4MintPositionParams = {\n positionManager: Address;\n pool: V4PoolState;\n tickLower: number;\n tickUpper: number;\n /** Liquidity units to mint, not a token amount. */\n liquidity: bigint;\n recipient: Address;\n /** Integer basis points, 0-10000. */\n slippageToleranceBps: number;\n deadlineSeconds: bigint;\n /** Passed to the hook's callbacks verbatim; this SDK does not construct it. */\n hookData?: Hex;\n /** Atomically initializes the pool before minting. Requires `pool.sqrtPriceX96` to be the intended starting price. */\n createPool?: boolean;\n};\n\nfunction slippagePercent(bps: number): Percent {\n if (!Number.isInteger(bps) || bps < 0 || bps > 10_000) {\n invalid('slippageToleranceBps must be an integer between 0 and 10000');\n }\n return new Percent(bps, 10_000);\n}\n\n/**\n * Builds unsigned calldata for `PositionManager.modifyLiquidities` minting a new v4 position.\n * Delegates encoding to `@uniswap/v4-sdk`'s `V4PositionManager`/`V4PositionPlanner` (the same\n * Actions/multicall encoding Uniswap's own SDK uses) rather than hand-rolling it, since v4's\n * calldata is a sequence of packed actions, not a single ABI-encoded function call like v3's.\n *\n * No Permit2 support yet — callers must have already approved the position manager via a plain\n * ERC20 approval, or the built transaction will revert on-chain. Hook-permission gating (refusing\n * a pool whose hook implements more than the caller has modelled) is also the caller's\n * responsibility; this function only encodes what it is given.\n */\nexport function buildV4MintPositionTransaction(input: V4MintPositionParams): V4TransactionMaterial {\n if (input.liquidity <= 0n) invalid('Mint liquidity must be positive');\n if (!Number.isInteger(input.tickLower) || !Number.isInteger(input.tickUpper) || input.tickLower >= input.tickUpper) {\n invalid('tickLower must be an integer less than tickUpper');\n }\n if (input.createPool && input.pool.sqrtPriceX96 <= 0n) invalid('createPool requires a positive initial sqrtPriceX96');\n const positionManager = checkedAddress(input.positionManager);\n const recipient = checkedAddress(input.recipient);\n const slippageTolerance = slippagePercent(input.slippageToleranceBps);\n\n try {\n const pool = new Pool(\n input.pool.currency0,\n input.pool.currency1,\n input.pool.fee,\n input.pool.tickSpacing,\n checkedAddress(input.pool.hooks),\n input.pool.sqrtPriceX96.toString(),\n input.pool.liquidity.toString(),\n input.pool.tickCurrent,\n );\n const position = new Position({\n pool,\n liquidity: input.liquidity.toString(),\n tickLower: input.tickLower,\n tickUpper: input.tickUpper,\n });\n const params = V4PositionManager.addCallParameters(position, {\n recipient,\n createPool: input.createPool ?? false,\n ...(input.createPool ? { sqrtPriceX96: input.pool.sqrtPriceX96.toString() } : {}),\n useNative: pool.currency0.isNative ? pool.currency0 : undefined,\n slippageTolerance,\n hookData: input.hookData,\n deadline: input.deadlineSeconds.toString(),\n });\n return { to: positionManager, data: params.calldata as Hex, value: BigInt(params.value) };\n } catch (cause) {\n if (cause instanceof UniswapSdkError) throw cause;\n throw new UniswapSdkError('INVALID_ARGUMENT', 'Official Uniswap SDK rejected the mint parameters', { cause });\n }\n}\n"]}
package/dist/v4.d.ts CHANGED
@@ -5,4 +5,8 @@ export type { V4ReadClient, V4Observation, V4PoolSnapshot, V4QuoteInput, V4Quote
5
5
  export { readV4TickWindow, ticksInWord } from './depth.js';
6
6
  export type { V4Tick, V4TickWindow } from './depth.js';
7
7
  export { decodeV4PoolInitialization } from './events.js';
8
+ export { decodeV4HookPermissions, unmodelledV4HookPermissions } from './hooks.js';
9
+ export type { V4HookPermissions } from './hooks.js';
10
+ export { buildV4MintPositionTransaction } from './v4-transactions.js';
11
+ export type { V4MintPositionParams, V4PoolState, V4TransactionMaterial } from './v4-transactions.js';
8
12
  //# sourceMappingURL=v4.d.ts.map
package/dist/v4.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"v4.d.ts","sourceRoot":"","sources":["../src/v4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9E,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACnG,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACpH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"v4.d.ts","sourceRoot":"","sources":["../src/v4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9E,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACnG,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACpH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAClF,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,YAAY,EAAE,oBAAoB,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/v4.js CHANGED
@@ -2,4 +2,6 @@ export { poolKeyFromCurrencies, getV4PoolId, poolReference } from './pool.js';
2
2
  export { readV4Pool, quoteV4ExactInput, quoteV4Batch, verifyV4DeploymentWiring } from './reads.js';
3
3
  export { readV4TickWindow, ticksInWord } from './depth.js';
4
4
  export { decodeV4PoolInitialization } from './events.js';
5
+ export { decodeV4HookPermissions, unmodelledV4HookPermissions } from './hooks.js';
6
+ export { buildV4MintPositionTransaction } from './v4-transactions.js';
5
7
  //# sourceMappingURL=v4.js.map
package/dist/v4.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"v4.js","sourceRoot":"","sources":["../src/v4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEnG,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC","sourcesContent":["export { poolKeyFromCurrencies, getV4PoolId, poolReference } from './pool.js';\nexport type { V4Deployment, V4PoolKey, V4PoolReference } from './pool.js';\nexport { readV4Pool, quoteV4ExactInput, quoteV4Batch, verifyV4DeploymentWiring } from './reads.js';\nexport type { V4ReadClient, V4Observation, V4PoolSnapshot, V4QuoteInput, V4Quote, V4QuoteResult } from './reads.js';\nexport { readV4TickWindow, ticksInWord } from './depth.js';\nexport type { V4Tick, V4TickWindow } from './depth.js';\nexport { decodeV4PoolInitialization } from './events.js';\n"]}
1
+ {"version":3,"file":"v4.js","sourceRoot":"","sources":["../src/v4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEnG,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAElF,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { poolKeyFromCurrencies, getV4PoolId, poolReference } from './pool.js';\nexport type { V4Deployment, V4PoolKey, V4PoolReference } from './pool.js';\nexport { readV4Pool, quoteV4ExactInput, quoteV4Batch, verifyV4DeploymentWiring } from './reads.js';\nexport type { V4ReadClient, V4Observation, V4PoolSnapshot, V4QuoteInput, V4Quote, V4QuoteResult } from './reads.js';\nexport { readV4TickWindow, ticksInWord } from './depth.js';\nexport type { V4Tick, V4TickWindow } from './depth.js';\nexport { decodeV4PoolInitialization } from './events.js';\nexport { decodeV4HookPermissions, unmodelledV4HookPermissions } from './hooks.js';\nexport type { V4HookPermissions } from './hooks.js';\nexport { buildV4MintPositionTransaction } from './v4-transactions.js';\nexport type { V4MintPositionParams, V4PoolState, V4TransactionMaterial } from './v4-transactions.js';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reptilianhq/uniswap-sdk",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "description": "Deployment-explicit Uniswap observations and reviewed transaction material.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -119,6 +119,6 @@
119
119
  "reptilianRelease": {
120
120
  "schemaVersion": 1,
121
121
  "group": "uniswap-sdk",
122
- "sourceSha": "d02bfdd8f80b6f95c7fc573ccd4eb17e6de6a0cf"
122
+ "sourceSha": "c050f60c50fa89a88acb7976429b4c08a18fdc84"
123
123
  }
124
124
  }