Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
11a4fa23
Unverified
Commit
11a4fa23
authored
Apr 26, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the approve callback from trade bug
parent
5358b4dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
useApproveCallback.ts
src/hooks/useApproveCallback.ts
+3
-2
No files found.
src/hooks/useApproveCallback.ts
View file @
11a4fa23
...
...
@@ -2,9 +2,10 @@ import { MaxUint256 } from '@ethersproject/constants'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
TokenAmount
,
CurrencyAmount
,
ETHER
,
ChainId
}
from
'
@uniswap/sdk-core
'
import
{
Trade
as
V2Trade
}
from
'
@uniswap/v2-sdk
'
import
{
SWAP_ROUTER_ADDRESS
,
Trade
as
V3Trade
}
from
'
@uniswap/v3-sdk
'
import
{
Trade
as
V3Trade
}
from
'
@uniswap/v3-sdk
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
V2_ROUTER_ADDRESS
}
from
'
../constants
'
import
{
SWAP_ROUTER_ADDRESSES
}
from
'
../constants/v3
'
import
{
Field
}
from
'
../state/swap/actions
'
import
{
useTransactionAdder
,
useHasPendingApproval
}
from
'
../state/transactions/hooks
'
import
{
computeSlippageAdjustedAmounts
}
from
'
../utils/prices
'
...
...
@@ -102,7 +103,7 @@ export function useApproveCallback(
// wraps useApproveCallback in the context of a swap
export
function
useApproveCallbackFromTrade
(
trade
?:
V2Trade
|
V3Trade
,
allowedSlippage
=
0
)
{
const
{
chainId
}
=
useActiveWeb3React
()
const
swapRouterAddress
=
SWAP_ROUTER_ADDRESS
[
chainId
as
ChainId
]
const
swapRouterAddress
=
SWAP_ROUTER_ADDRESS
ES
[
chainId
as
ChainId
]
const
amountToApprove
=
useMemo
(
()
=>
(
trade
?
computeSlippageAdjustedAmounts
(
trade
,
allowedSlippage
)[
Field
.
INPUT
]
:
undefined
),
[
trade
,
allowedSlippage
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment