From d910d6bf09d4a64e071fbe42df6db8a1674a3dd1 Mon Sep 17 00:00:00 2001 From: Alice <34962750+hensha256@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:50:40 -0400 Subject: [PATCH] fix(v4-sdk): Update initializePool parameters (#179) --- sdks/v4-sdk/src/PositionManager.test.ts | 12 +++--------- sdks/v4-sdk/src/PositionManager.ts | 11 ++++------- sdks/v4-sdk/src/utils/abi.ts | 14 ++++++++++---- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/sdks/v4-sdk/src/PositionManager.test.ts b/sdks/v4-sdk/src/PositionManager.test.ts index edfb82792..b258efcd3 100644 --- a/sdks/v4-sdk/src/PositionManager.test.ts +++ b/sdks/v4-sdk/src/PositionManager.test.ts @@ -67,10 +67,9 @@ describe('PositionManager', () => { * 1) "initializePool((address,address,uint24,int24,address),uint160,bytes)" (0x0000000000000000000000000000000000000001, 0x0000000000000000000000000000000000000002, 3000, 60, 0x0000000000000000000000000000000000000000) 79228162514264337593543950336 - 0x00 */ expect(calldata).toEqual( - '0x3b1fda97000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000' + '0xf7020405000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000' ) expect(value).toEqual('0x00') }) @@ -84,10 +83,9 @@ describe('PositionManager', () => { * 1) "initializePool((address,address,uint24,int24,address),uint160,bytes)" (0x0000000000000000000000000000000000000001, 0x0000000000000000000000000000000000000002, 3000, 60, 0x1100000000000000000000000000000000002401) 79228162514264337593543950336 - 0x00 */ expect(calldata).toEqual( - '0x3b1fda97000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000001100000000000000000000000000000000002401000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000' + '0xf7020405000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000003c00000000000000000000000011000000000000000000000000000000000024010000000000000000000000000000000000000001000000000000000000000000' ) expect(value).toEqual('0x00') }) @@ -219,11 +217,7 @@ describe('PositionManager', () => { const calldataList = Multicall.decodeMulticall(calldata) // Expect initializePool to be called correctly expect(calldataList[0]).toEqual( - V4PositionManager.INTERFACE.encodeFunctionData('initializePool', [ - pool_0_1.poolKey, - SQRT_PRICE_1_1.toString(), - EMPTY_BYTES, - ]) + V4PositionManager.INTERFACE.encodeFunctionData('initializePool', [pool_0_1.poolKey, SQRT_PRICE_1_1.toString()]) ) const planner = new V4Planner() const { amount0: amount0Max, amount1: amount1Max } = position.mintAmountsWithSlippage(slippageTolerance) diff --git a/sdks/v4-sdk/src/PositionManager.ts b/sdks/v4-sdk/src/PositionManager.ts index fa32188c5..d80a3f0cb 100644 --- a/sdks/v4-sdk/src/PositionManager.ts +++ b/sdks/v4-sdk/src/PositionManager.ts @@ -214,9 +214,9 @@ export abstract class V4PositionManager { /** * Public methods to encode method parameters for different actions on the PositionManager contract */ - public static createCallParameters(poolKey: PoolKey, sqrtPriceX96: BigintIsh, hookData?: string): MethodParameters { + public static createCallParameters(poolKey: PoolKey, sqrtPriceX96: BigintIsh): MethodParameters { return { - calldata: this.encodeInitializePool(poolKey, sqrtPriceX96, hookData), + calldata: this.encodeInitializePool(poolKey, sqrtPriceX96), value: toHex(0), } } @@ -237,9 +237,7 @@ export abstract class V4PositionManager { // Encode initialize pool. if (isMint(options) && shouldCreatePool(options)) { // No planner used here because initializePool is not supported as an Action - calldataList.push( - V4PositionManager.encodeInitializePool(position.pool.poolKey, options.sqrtPriceX96!, options.hookData) - ) + calldataList.push(V4PositionManager.encodeInitializePool(position.pool.poolKey, options.sqrtPriceX96!)) } // adjust for slippage @@ -412,11 +410,10 @@ export abstract class V4PositionManager { } // Initialize a pool - private static encodeInitializePool(poolKey: PoolKey, sqrtPriceX96: BigintIsh, hookData?: string): string { + private static encodeInitializePool(poolKey: PoolKey, sqrtPriceX96: BigintIsh): string { return V4PositionManager.INTERFACE.encodeFunctionData(PositionFunctions.INITIALIZE_POOL, [ poolKey, sqrtPriceX96.toString(), - hookData ?? '0x', ]) } diff --git a/sdks/v4-sdk/src/utils/abi.ts b/sdks/v4-sdk/src/utils/abi.ts index fd4454559..8d04c0437 100644 --- a/sdks/v4-sdk/src/utils/abi.ts +++ b/sdks/v4-sdk/src/utils/abi.ts @@ -6,6 +6,7 @@ export const abi = [ { name: '_poolManager', type: 'address', internalType: 'contract IPoolManager' }, { name: '_permit2', type: 'address', internalType: 'contract IAllowanceTransfer' }, { name: '_unsubscribeGasLimit', type: 'uint256', internalType: 'uint256' }, + { name: '_tokenDescriptor', type: 'address', internalType: 'contract IPositionDescriptor' }, ], stateMutability: 'nonpayable', }, @@ -85,7 +86,6 @@ export const abi = [ ], }, { name: 'sqrtPriceX96', type: 'uint160', internalType: 'uint160' }, - { name: 'hookData', type: 'bytes', internalType: 'bytes' }, ], outputs: [{ name: '', type: 'int24', internalType: 'int24' }], stateMutability: 'payable', @@ -358,12 +358,19 @@ export const abi = [ outputs: [{ name: '', type: 'string', internalType: 'string' }], stateMutability: 'view', }, + { + type: 'function', + name: 'tokenDescriptor', + inputs: [], + outputs: [{ name: '', type: 'address', internalType: 'contract IPositionDescriptor' }], + stateMutability: 'view', + }, { type: 'function', name: 'tokenURI', - inputs: [{ name: '', type: 'uint256', internalType: 'uint256' }], + inputs: [{ name: 'tokenId', type: 'uint256', internalType: 'uint256' }], outputs: [{ name: '', type: 'string', internalType: 'string' }], - stateMutability: 'pure', + stateMutability: 'view', }, { type: 'function', @@ -494,7 +501,6 @@ export const abi = [ { type: 'error', name: 'NotPoolManager', inputs: [] }, { type: 'error', name: 'NotSubscribed', inputs: [] }, { type: 'error', name: 'SignatureDeadlineExpired', inputs: [] }, - { type: 'error', name: 'SliceOutOfBounds', inputs: [] }, { type: 'error', name: 'Unauthorized', inputs: [] }, { type: 'error', name: 'UnsupportedAction', inputs: [{ name: 'action', type: 'uint256', internalType: 'uint256' }] }, {