Skip to content

Commit

Permalink
remove sqrt param from single structs
Browse files Browse the repository at this point in the history
  • Loading branch information
hensha256 committed Jan 10, 2025
1 parent 0bfffa3 commit 005df07
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
6 changes: 1 addition & 5 deletions sdks/v4-sdk/src/utils/v4BaseActionsParser.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai'
import { WETH9 } from '@uniswap/sdk-core'
import { BigNumber, ethers } from 'ethers'
import { ethers } from 'ethers'
import { Route } from '../entities/route'
import { encodeRouteToPath } from './encodeRouteToPath'
import { V4BaseActionsParser, V4RouterCall } from './v4BaseActionsParser'
Expand Down Expand Up @@ -147,7 +147,6 @@ describe('Command Parser', () => {
zeroForOne: true,
amountIn: amount,
amountOutMinimum: amount,
sqrtPriceLimitX96: 0,
hookData: '0x',
},
]),
Expand All @@ -164,7 +163,6 @@ describe('Command Parser', () => {
zeroForOne: true,
amountIn: amount,
amountOutMinimum: amount,
sqrtPriceLimitX96: BigNumber.from(0),
hookData: '0x',
},
},
Expand All @@ -180,7 +178,6 @@ describe('Command Parser', () => {
zeroForOne: true,
amountOut: amount,
amountInMaximum: amount,
sqrtPriceLimitX96: 0,
hookData: '0x',
},
]),
Expand All @@ -197,7 +194,6 @@ describe('Command Parser', () => {
zeroForOne: true,
amountOut: amount,
amountInMaximum: amount,
sqrtPriceLimitX96: BigNumber.from(0),
hookData: '0x',
},
},
Expand Down
8 changes: 2 additions & 6 deletions sdks/v4-sdk/src/utils/v4BaseActionsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export type SwapExactInSingle = {
readonly zeroForOne: boolean
readonly amountIn: string
readonly amountOutMinimum: string
readonly sqrtPriceLimitX96: string
readonly hookData: string
}

Expand All @@ -39,7 +38,6 @@ export type SwapExactOutSingle = {
readonly zeroForOne: boolean
readonly amountOut: string
readonly amountInMaximum: string
readonly sqrtPriceLimitX96: string
readonly hookData: string
}

Expand Down Expand Up @@ -146,7 +144,7 @@ function parsePathKey(data: string): PathKey {
}

function parseV4ExactInSingle(data: any[]): SwapExactInSingle {
const [poolKey, zeroForOne, amountIn, amountOutMinimum, sqrtPriceLimitX96, hookData] = data
const [poolKey, zeroForOne, amountIn, amountOutMinimum, hookData] = data
const [currency0, currency1, fee, tickSpacing, hooks] = poolKey
return {
poolKey: {
Expand All @@ -159,7 +157,6 @@ function parseV4ExactInSingle(data: any[]): SwapExactInSingle {
zeroForOne,
amountIn,
amountOutMinimum,
sqrtPriceLimitX96,
hookData,
}
}
Expand All @@ -177,7 +174,7 @@ function parseV4ExactIn(data: any[]): SwapExactIn {
}

function parseV4ExactOutSingle(data: any[]): SwapExactOutSingle {
const [poolKey, zeroForOne, amountOut, amountInMaximum, sqrtPriceLimitX96, hookData] = data
const [poolKey, zeroForOne, amountOut, amountInMaximum, hookData] = data
const { currency0, currency1, fee, tickSpacing, hooks } = poolKey

return {
Expand All @@ -191,7 +188,6 @@ function parseV4ExactOutSingle(data: any[]): SwapExactOutSingle {
zeroForOne,
amountOut,
amountInMaximum,
sqrtPriceLimitX96,
hookData,
}
}
Expand Down
3 changes: 1 addition & 2 deletions sdks/v4-sdk/src/utils/v4Planner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ describe('RouterPlanner', () => {
zeroForOne: true,
amountIn: ONE_ETHER_BN,
amountOutMinimum: ONE_ETHER_BN.div(2),
sqrtPriceLimitX96: 0,
hookData: '0x',
},
])

expect(planner.actions).toEqual('0x06')
expect(planner.params[0]).toEqual(
'0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000000'
'0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000006f05b59d3b2000000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000000'
)
})
})
Expand Down
8 changes: 2 additions & 6 deletions sdks/v4-sdk/src/utils/v4Planner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,13 @@ const POOL_KEY_STRUCT = '(address currency0,address currency1,uint24 fee,int24 t
const PATH_KEY_STRUCT = '(address intermediateCurrency,uint256 fee,int24 tickSpacing,address hooks,bytes hookData)'

const SWAP_EXACT_IN_SINGLE_STRUCT =
'(' +
POOL_KEY_STRUCT +
' poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,uint160 sqrtPriceLimitX96,bytes hookData)'
'(' + POOL_KEY_STRUCT + ' poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,bytes hookData)'

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

const SWAP_EXACT_OUT_SINGLE_STRUCT =
'(' +
POOL_KEY_STRUCT +
' poolKey,bool zeroForOne,uint128 amountOut,uint128 amountInMaximum,uint160 sqrtPriceLimitX96,bytes hookData)'
'(' + POOL_KEY_STRUCT + ' poolKey,bool zeroForOne,uint128 amountOut,uint128 amountInMaximum,bytes hookData)'

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

0 comments on commit 005df07

Please sign in to comment.