Commit 38cde648 authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

fix: add a catch on collect static call (#6491)

* fix: add a catch on collect static call

* comment
parent 33c09911
...@@ -27,21 +27,26 @@ export function useV3PositionFees( ...@@ -27,21 +27,26 @@ export function useV3PositionFees(
// latestBlockNumber is included to ensure data stays up-to-date every block // latestBlockNumber is included to ensure data stays up-to-date every block
const [amounts, setAmounts] = useState<[BigNumber, BigNumber] | undefined>() const [amounts, setAmounts] = useState<[BigNumber, BigNumber] | undefined>()
useEffect(() => { useEffect(() => {
if (positionManager && tokenIdHexString && owner) { ;(async function getFees() {
positionManager.callStatic if (positionManager && tokenIdHexString && owner) {
.collect( try {
{ const results = await positionManager.callStatic.collect(
tokenId: tokenIdHexString, {
recipient: owner, // some tokens might fail if transferred to address(0) tokenId: tokenIdHexString,
amount0Max: MAX_UINT128, recipient: owner, // some tokens might fail if transferred to address(0)
amount1Max: MAX_UINT128, amount0Max: MAX_UINT128,
}, amount1Max: MAX_UINT128,
{ from: owner } // need to simulate the call as the owner },
) { from: owner } // need to simulate the call as the owner
.then((results) => { )
setAmounts([results.amount0, results.amount1]) setAmounts([results.amount0, results.amount1])
}) } catch {
} // If the static call fails, the default state will remain for `amounts`.
// This case is handled by returning unclaimed fees as empty.
// TODO(INFRA-178): Look into why we have failures with call data being 0x.
}
}
})()
}, [positionManager, tokenIdHexString, owner, latestBlockNumber]) }, [positionManager, tokenIdHexString, owner, latestBlockNumber])
if (pool && amounts) { if (pool && amounts) {
......
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