From 93e6ddd6b8f00c3fee04bb17d754de6955280795 Mon Sep 17 00:00:00 2001 From: Peiman <25097709+Rickk137@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:41:52 +0330 Subject: [PATCH] Fix position issue in Mainnet (#49) * Fix position issue in mainnet * Fix deps --- .../useCollateralPriceUpdates/useCollateralPriceUpdates.ts | 4 ++++ liquidity/lib/withERC7412/package.json | 1 + liquidity/lib/withERC7412/withERC7412.ts | 3 ++- yarn.lock | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/liquidity/lib/useCollateralPriceUpdates/useCollateralPriceUpdates.ts b/liquidity/lib/useCollateralPriceUpdates/useCollateralPriceUpdates.ts index 5e0ba516..1921aba9 100644 --- a/liquidity/lib/useCollateralPriceUpdates/useCollateralPriceUpdates.ts +++ b/liquidity/lib/useCollateralPriceUpdates/useCollateralPriceUpdates.ts @@ -78,9 +78,13 @@ async function getPythFeedIdsFromCollateralList( } export const getPriceUpdates = async (priceIds: string[], network: Network) => { + if (!priceIds.length) { + return null; + } const unique = Array.from(new Set(priceIds)); const signedOffchainData = await priceService.getPriceFeedsUpdateData(unique); const PythVerfier = await importPythVerfier(network.id, network.preset); + return { to: PythVerfier.address, data: new ethers.utils.Interface(PythVerfier.abi).encodeFunctionData('updatePriceFeeds', [ diff --git a/liquidity/lib/withERC7412/package.json b/liquidity/lib/withERC7412/package.json index 5f68e594..c9d95289 100644 --- a/liquidity/lib/withERC7412/package.json +++ b/liquidity/lib/withERC7412/package.json @@ -7,6 +7,7 @@ "@pythnetwork/pyth-evm-js": "^1.42.0", "@snx-v3/constants": "workspace:*", "@snx-v3/contracts": "workspace:*", + "@snx-v3/tsHelpers": "workspace:*", "@snx-v3/useBlockchain": "workspace:*", "ethers": "^5.7.2" } diff --git a/liquidity/lib/withERC7412/withERC7412.ts b/liquidity/lib/withERC7412/withERC7412.ts index a7b0a815..78da40d3 100644 --- a/liquidity/lib/withERC7412/withERC7412.ts +++ b/liquidity/lib/withERC7412/withERC7412.ts @@ -8,6 +8,7 @@ import { importPythERC7412Wrapper, importPythVerfier, } from '@snx-v3/contracts'; +import { notNil } from '@snx-v3/tsHelpers'; import { Network, deploymentHasERC7412, getMagicProvider } from '@snx-v3/useBlockchain'; import { ethers } from 'ethers'; @@ -343,7 +344,7 @@ export async function erc7412Call<T>( const from = getDefaultFromAddress(network.name); const newCall = await withERC7412( network, - calls.map((call) => (call.from ? call : { ...call, from })), // fill missing "from" + calls.filter(notNil).map((call) => (call.from ? call : { ...call, from })), // fill missing "from" label, from ); diff --git a/yarn.lock b/yarn.lock index ef13e799..a5396286 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6357,6 +6357,7 @@ __metadata: "@pythnetwork/pyth-evm-js": "npm:^1.42.0" "@snx-v3/constants": "workspace:*" "@snx-v3/contracts": "workspace:*" + "@snx-v3/tsHelpers": "workspace:*" "@snx-v3/useBlockchain": "workspace:*" ethers: "npm:^5.7.2" languageName: unknown