Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit ad8e180

Browse files
authored
fix: hexlify tx value from SwapRouter (#332)
1 parent 6532f84 commit ad8e180

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/hooks/useUniversalRouter.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'
22
import { TransactionResponse } from '@ethersproject/providers'
33
import { Percent } from '@uniswap/sdk-core'
44
import { SwapRouter, UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk'
5-
import { FeeOptions } from '@uniswap/v3-sdk'
5+
import { FeeOptions, toHex } from '@uniswap/v3-sdk'
66
import { useWeb3React } from '@web3-react/core'
77
import { useCallback } from 'react'
88
import { InterfaceTrade } from 'state/routing/types'
@@ -35,19 +35,13 @@ export function useUniversalRouterSwapCallback(trade: InterfaceTrade | undefined
3535
inputTokenPermit: options.permit,
3636
fee: options.feeOptions,
3737
})
38-
const tx =
39-
value && !isZero(value)
40-
? {
41-
from: account,
42-
to: UNIVERSAL_ROUTER_ADDRESS(chainId),
43-
data,
44-
value,
45-
}
46-
: {
47-
from: account,
48-
to: UNIVERSAL_ROUTER_ADDRESS(chainId),
49-
data,
50-
}
38+
const tx = {
39+
from: account,
40+
to: UNIVERSAL_ROUTER_ADDRESS(chainId),
41+
data,
42+
// TODO: universal-router-sdk returns a non-hexlified value.
43+
...(value && !isZero(value) ? { value: toHex(value) } : {}),
44+
}
5145

5246
let gasEstimate: BigNumber
5347
try {

0 commit comments

Comments
 (0)