Skip to content

Commit c1c9f64

Browse files
authored
fix(v4-sdk): Update exact single swap struct (#239)
1 parent 21d5ec9 commit c1c9f64

File tree

4 files changed

+6
-19
lines changed

4 files changed

+6
-19
lines changed

sdks/v4-sdk/src/utils/v4BaseActionsParser.test.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from 'chai'
22
import { WETH9 } from '@uniswap/sdk-core'
3-
import { BigNumber, ethers } from 'ethers'
3+
import { ethers } from 'ethers'
44
import { Route } from '../entities/route'
55
import { encodeRouteToPath } from './encodeRouteToPath'
66
import { V4BaseActionsParser, V4RouterCall } from './v4BaseActionsParser'
@@ -147,7 +147,6 @@ describe('Command Parser', () => {
147147
zeroForOne: true,
148148
amountIn: amount,
149149
amountOutMinimum: amount,
150-
sqrtPriceLimitX96: 0,
151150
hookData: '0x',
152151
},
153152
]),
@@ -164,7 +163,6 @@ describe('Command Parser', () => {
164163
zeroForOne: true,
165164
amountIn: amount,
166165
amountOutMinimum: amount,
167-
sqrtPriceLimitX96: BigNumber.from(0),
168166
hookData: '0x',
169167
},
170168
},
@@ -180,7 +178,6 @@ describe('Command Parser', () => {
180178
zeroForOne: true,
181179
amountOut: amount,
182180
amountInMaximum: amount,
183-
sqrtPriceLimitX96: 0,
184181
hookData: '0x',
185182
},
186183
]),
@@ -197,7 +194,6 @@ describe('Command Parser', () => {
197194
zeroForOne: true,
198195
amountOut: amount,
199196
amountInMaximum: amount,
200-
sqrtPriceLimitX96: BigNumber.from(0),
201197
hookData: '0x',
202198
},
203199
},

sdks/v4-sdk/src/utils/v4BaseActionsParser.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export type SwapExactInSingle = {
2323
readonly zeroForOne: boolean
2424
readonly amountIn: string
2525
readonly amountOutMinimum: string
26-
readonly sqrtPriceLimitX96: string
2726
readonly hookData: string
2827
}
2928

@@ -39,7 +38,6 @@ export type SwapExactOutSingle = {
3938
readonly zeroForOne: boolean
4039
readonly amountOut: string
4140
readonly amountInMaximum: string
42-
readonly sqrtPriceLimitX96: string
4341
readonly hookData: string
4442
}
4543

@@ -146,7 +144,7 @@ function parsePathKey(data: string): PathKey {
146144
}
147145

148146
function parseV4ExactInSingle(data: any[]): SwapExactInSingle {
149-
const [poolKey, zeroForOne, amountIn, amountOutMinimum, sqrtPriceLimitX96, hookData] = data
147+
const [poolKey, zeroForOne, amountIn, amountOutMinimum, hookData] = data
150148
const [currency0, currency1, fee, tickSpacing, hooks] = poolKey
151149
return {
152150
poolKey: {
@@ -159,7 +157,6 @@ function parseV4ExactInSingle(data: any[]): SwapExactInSingle {
159157
zeroForOne,
160158
amountIn,
161159
amountOutMinimum,
162-
sqrtPriceLimitX96,
163160
hookData,
164161
}
165162
}
@@ -177,7 +174,7 @@ function parseV4ExactIn(data: any[]): SwapExactIn {
177174
}
178175

179176
function parseV4ExactOutSingle(data: any[]): SwapExactOutSingle {
180-
const [poolKey, zeroForOne, amountOut, amountInMaximum, sqrtPriceLimitX96, hookData] = data
177+
const [poolKey, zeroForOne, amountOut, amountInMaximum, hookData] = data
181178
const { currency0, currency1, fee, tickSpacing, hooks } = poolKey
182179

183180
return {
@@ -191,7 +188,6 @@ function parseV4ExactOutSingle(data: any[]): SwapExactOutSingle {
191188
zeroForOne,
192189
amountOut,
193190
amountInMaximum,
194-
sqrtPriceLimitX96,
195191
hookData,
196192
}
197193
}

sdks/v4-sdk/src/utils/v4Planner.test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,13 @@ describe('RouterPlanner', () => {
7676
zeroForOne: true,
7777
amountIn: ONE_ETHER_BN,
7878
amountOutMinimum: ONE_ETHER_BN.div(2),
79-
sqrtPriceLimitX96: 0,
8079
hookData: '0x',
8180
},
8281
])
8382

8483
expect(planner.actions).toEqual('0x06')
8584
expect(planner.params[0]).toEqual(
86-
'0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000'
85+
'0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000006f05b59d3b2000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000000'
8786
)
8887
})
8988
})

sdks/v4-sdk/src/utils/v4Planner.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,13 @@ const POOL_KEY_STRUCT = '(address currency0,address currency1,uint24 fee,int24 t
6868
const PATH_KEY_STRUCT = '(address intermediateCurrency,uint256 fee,int24 tickSpacing,address hooks,bytes hookData)'
6969

7070
const SWAP_EXACT_IN_SINGLE_STRUCT =
71-
'(' +
72-
POOL_KEY_STRUCT +
73-
' poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,uint160 sqrtPriceLimitX96,bytes hookData)'
71+
'(' + POOL_KEY_STRUCT + ' poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,bytes hookData)'
7472

7573
const SWAP_EXACT_IN_STRUCT =
7674
'(address currencyIn,' + PATH_KEY_STRUCT + '[] path,uint128 amountIn,uint128 amountOutMinimum)'
7775

7876
const SWAP_EXACT_OUT_SINGLE_STRUCT =
79-
'(' +
80-
POOL_KEY_STRUCT +
81-
' poolKey,bool zeroForOne,uint128 amountOut,uint128 amountInMaximum,uint160 sqrtPriceLimitX96,bytes hookData)'
77+
'(' + POOL_KEY_STRUCT + ' poolKey,bool zeroForOne,uint128 amountOut,uint128 amountInMaximum,bytes hookData)'
8278

8379
const SWAP_EXACT_OUT_STRUCT =
8480
'(address currencyOut,' + PATH_KEY_STRUCT + '[] path,uint128 amountOut,uint128 amountInMaximum)'

0 commit comments

Comments
 (0)