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
cfe590d8
Unverified
Commit
cfe590d8
authored
Jul 06, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(devx): show a warning when a call fails due to insufficient gas allowed
parent
2ee9b16c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
updater.tsx
src/state/multicall/updater.tsx
+24
-1
No files found.
src/state/multicall/updater.tsx
View file @
cfe590d8
...
@@ -12,6 +12,8 @@ import { useAppDispatch, useAppSelector } from 'state/hooks'
...
@@ -12,6 +12,8 @@ import { useAppDispatch, useAppSelector } from 'state/hooks'
import
{
Call
,
parseCallKey
}
from
'
./utils
'
import
{
Call
,
parseCallKey
}
from
'
./utils
'
import
{
UniswapInterfaceMulticall
}
from
'
types/v3
'
import
{
UniswapInterfaceMulticall
}
from
'
types/v3
'
const
DEFAULT_GAS_REQUIRED
=
1
_000_000
/**
/**
* Fetches a chunk of calls, enforcing a minimum block number constraint
* Fetches a chunk of calls, enforcing a minimum block number constraint
* @param multicall multicall contract to fetch against
* @param multicall multicall contract to fetch against
...
@@ -31,11 +33,32 @@ async function fetchChunk(
...
@@ -31,11 +33,32 @@ async function fetchChunk(
let
results
:
{
success
:
boolean
;
returnData
:
string
}[]
let
results
:
{
success
:
boolean
;
returnData
:
string
}[]
try
{
try
{
const
{
blockNumber
,
returnData
}
=
await
multicall
.
callStatic
.
multicall
(
const
{
blockNumber
,
returnData
}
=
await
multicall
.
callStatic
.
multicall
(
chunk
.
map
((
obj
)
=>
({
target
:
obj
.
address
,
callData
:
obj
.
callData
,
gasLimit
:
obj
.
gasRequired
??
1
_000_000
})),
chunk
.
map
((
obj
)
=>
({
target
:
obj
.
address
,
callData
:
obj
.
callData
,
gasLimit
:
obj
.
gasRequired
??
DEFAULT_GAS_REQUIRED
,
})),
{
blockTag
:
minBlockNumber
}
{
blockTag
:
minBlockNumber
}
)
)
resultsBlockNumber
=
blockNumber
.
toNumber
()
resultsBlockNumber
=
blockNumber
.
toNumber
()
results
=
returnData
results
=
returnData
if
(
process
.
env
.
NODE_ENV
===
'
development
'
)
{
returnData
.
forEach
(({
gasUsed
,
returnData
,
success
},
i
)
=>
{
if
(
!
success
&&
returnData
.
length
===
2
&&
gasUsed
.
gte
(
Math
.
floor
((
chunk
[
i
].
gasRequired
??
DEFAULT_GAS_REQUIRED
)
*
0.95
))
)
{
console
.
warn
(
`A call failed due to requiring
${
gasUsed
.
toString
()}
vs. allowed
${
chunk
[
i
].
gasRequired
??
DEFAULT_GAS_REQUIRED
}
`,
chunk[i]
)
}
})
}
} catch (error) {
} catch (error) {
console.debug('Failed to fetch chunk', error)
console.debug('Failed to fetch chunk', error)
throw error
throw error
...
...
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