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
e6d0d96c
Unverified
Commit
e6d0d96c
authored
Mar 03, 2023
by
Zach Pomerantz
Committed by
GitHub
Mar 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: omit gas estimation from token.approve (#6069)
parent
dcb660d0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
10 deletions
+2
-10
useTokenAllowance.ts
src/hooks/useTokenAllowance.ts
+2
-10
No files found.
src/hooks/useTokenAllowance.ts
View file @
e6d0d96c
...
@@ -5,7 +5,6 @@ import { useTokenContract } from 'hooks/useContract'
...
@@ -5,7 +5,6 @@ import { useTokenContract } from 'hooks/useContract'
import
{
useSingleCallResult
}
from
'
lib/hooks/multicall
'
import
{
useSingleCallResult
}
from
'
lib/hooks/multicall
'
import
{
useCallback
,
useEffect
,
useMemo
,
useState
}
from
'
react
'
import
{
useCallback
,
useEffect
,
useMemo
,
useState
}
from
'
react
'
import
{
ApproveTransactionInfo
,
TransactionType
}
from
'
state/transactions/types
'
import
{
ApproveTransactionInfo
,
TransactionType
}
from
'
state/transactions/types
'
import
{
calculateGasMargin
}
from
'
utils/calculateGasMargin
'
export
function
useTokenAllowance
(
export
function
useTokenAllowance
(
token
?:
Token
,
token
?:
Token
,
...
@@ -48,15 +47,8 @@ export function useUpdateTokenAllowance(
...
@@ -48,15 +47,8 @@ export function useUpdateTokenAllowance(
if
(
!
contract
)
throw
new
Error
(
'
missing contract
'
)
if
(
!
contract
)
throw
new
Error
(
'
missing contract
'
)
if
(
!
spender
)
throw
new
Error
(
'
missing spender
'
)
if
(
!
spender
)
throw
new
Error
(
'
missing spender
'
)
let
allowance
:
BigNumberish
=
MaxUint256
.
toString
()
const
allowance
:
BigNumberish
=
MaxUint256
.
toString
()
const
estimatedGas
=
await
contract
.
estimateGas
.
approve
(
spender
,
allowance
).
catch
(()
=>
{
const
response
=
await
contract
.
approve
(
spender
,
allowance
)
// Fallback for tokens which restrict approval amounts:
allowance
=
amount
.
quotient
.
toString
()
return
contract
.
estimateGas
.
approve
(
spender
,
allowance
)
})
const
gasLimit
=
calculateGasMargin
(
estimatedGas
)
const
response
=
await
contract
.
approve
(
spender
,
allowance
,
{
gasLimit
})
return
{
return
{
response
,
response
,
info
:
{
info
:
{
...
...
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