Commit d59e4f33 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: hexlify tx value from SwapRouter (#5621)

Hexlifies the value returned from universal-router-sdk, which is required for ethers to accept it as input.
Fixes an error thrown by ethers (RE: un-hexlified data).
See Uniswap/universal-router-sdk#92 (fixed in Uniswap/universal-router-sdk#93 but not yet released).
parent 4c3528a0
...@@ -3,7 +3,7 @@ import { BigNumber } from '@ethersproject/bignumber' ...@@ -3,7 +3,7 @@ import { BigNumber } from '@ethersproject/bignumber'
import { Trade } from '@uniswap/router-sdk' import { Trade } from '@uniswap/router-sdk'
import { Currency, Percent, TradeType } from '@uniswap/sdk-core' import { Currency, Percent, TradeType } from '@uniswap/sdk-core'
import { SwapRouter, UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk' import { SwapRouter, UNIVERSAL_ROUTER_ADDRESS } from '@uniswap/universal-router-sdk'
import { FeeOptions } from '@uniswap/v3-sdk' import { FeeOptions, toHex } from '@uniswap/v3-sdk'
import { useWeb3React } from '@web3-react/core' import { useWeb3React } from '@web3-react/core'
import { useCallback } from 'react' import { useCallback } from 'react'
import { calculateGasMargin } from 'utils/calculateGasMargin' import { calculateGasMargin } from 'utils/calculateGasMargin'
...@@ -38,19 +38,13 @@ export function useUniversalRouterSwapCallback( ...@@ -38,19 +38,13 @@ export function useUniversalRouterSwapCallback(
inputTokenPermit: options.permit, inputTokenPermit: options.permit,
fee: options.feeOptions, fee: options.feeOptions,
}) })
const tx = const tx = {
value && !isZero(value) from: account,
? { to: UNIVERSAL_ROUTER_ADDRESS(chainId),
from: account, data,
to: UNIVERSAL_ROUTER_ADDRESS(chainId), // TODO: universal-router-sdk returns a non-hexlified value.
data, ...(value && !isZero(value) ? { value: toHex(value) } : {}),
value, }
}
: {
from: account,
to: UNIVERSAL_ROUTER_ADDRESS(chainId),
data,
}
let gasEstimate: BigNumber let gasEstimate: BigNumber
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment