From 782c150cafa7e4c93e3b5e4028c6af14da1da785 Mon Sep 17 00:00:00 2001 From: Noisekit <28145325+noisekit@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:29:58 +1100 Subject: [PATCH] Remove price updates from read tx (#69) --- liquidity/lib/useAccountCollateral/package.json | 1 - .../lib/useAccountCollateral/useAccountCollaterals.ts | 9 --------- liquidity/lib/useCollateralPrices/package.json | 1 - .../lib/useCollateralPrices/useCollateralPrices.ts | 11 +---------- liquidity/lib/useLiquidityPosition/package.json | 1 - .../lib/useLiquidityPosition/useLiquidityPosition.ts | 9 --------- liquidity/lib/useLiquidityPositions/package.json | 1 - .../useLiquidityPositions/useLiquidityPositions.ts | 11 +---------- liquidity/lib/usePoolConfiguration/package.json | 1 - .../lib/usePoolConfiguration/usePoolConfiguration.ts | 9 --------- liquidity/lib/useVaultsData/package.json | 1 - liquidity/lib/useVaultsData/useVaultsData.ts | 9 --------- yarn.lock | 6 ------ 13 files changed, 2 insertions(+), 68 deletions(-) diff --git a/liquidity/lib/useAccountCollateral/package.json b/liquidity/lib/useAccountCollateral/package.json index 500ac9599..22c5358c7 100644 --- a/liquidity/lib/useAccountCollateral/package.json +++ b/liquidity/lib/useAccountCollateral/package.json @@ -6,7 +6,6 @@ "dependencies": { "@snx-v3/tsHelpers": "workspace:*", "@snx-v3/useBlockchain": "workspace:*", - "@snx-v3/useCollateralPriceUpdates": "workspace:*", "@snx-v3/useCollateralTypes": "workspace:*", "@snx-v3/useCoreProxy": "workspace:*", "@snx-v3/useSystemToken": "workspace:*", diff --git a/liquidity/lib/useAccountCollateral/useAccountCollaterals.ts b/liquidity/lib/useAccountCollateral/useAccountCollaterals.ts index 5d3982cdc..3846cccf5 100644 --- a/liquidity/lib/useAccountCollateral/useAccountCollaterals.ts +++ b/liquidity/lib/useAccountCollateral/useAccountCollaterals.ts @@ -1,6 +1,5 @@ import { contractsHash } from '@snx-v3/tsHelpers'; import { useNetwork, useProvider } from '@snx-v3/useBlockchain'; -import { getPriceUpdates, getPythFeedIds } from '@snx-v3/useCollateralPriceUpdates'; import { useCollateralTypes } from '@snx-v3/useCollateralTypes'; import { useCoreProxy } from '@snx-v3/useCoreProxy'; import { useSystemToken } from '@snx-v3/useSystemToken'; @@ -118,14 +117,6 @@ export function useAccountCollaterals({ accountId }: { accountId?: string }) { }); const allCalls = [...calls]; - const priceUpdateTx = (await getPriceUpdates( - (await getPythFeedIds(network)) as string[], - network - ).catch(() => undefined)) as any; - if (priceUpdateTx) { - allCalls.unshift(priceUpdateTx); - } - const data = await erc7412Call(network, provider, allCalls, decoder, 'useAccountCollateral'); return data.map((x) => { diff --git a/liquidity/lib/useCollateralPrices/package.json b/liquidity/lib/useCollateralPrices/package.json index dfb5d468b..c155dafc0 100644 --- a/liquidity/lib/useCollateralPrices/package.json +++ b/liquidity/lib/useCollateralPrices/package.json @@ -7,7 +7,6 @@ "@snx-v3/isBaseAndromeda": "workspace:*", "@snx-v3/tsHelpers": "workspace:*", "@snx-v3/useBlockchain": "workspace:*", - "@snx-v3/useCollateralPriceUpdates": "workspace:*", "@snx-v3/useCollateralTypes": "workspace:*", "@snx-v3/useCoreProxy": "workspace:*", "@snx-v3/useGetUSDTokens": "workspace:*", diff --git a/liquidity/lib/useCollateralPrices/useCollateralPrices.ts b/liquidity/lib/useCollateralPrices/useCollateralPrices.ts index 2579c5cf8..ffc2de7cd 100644 --- a/liquidity/lib/useCollateralPrices/useCollateralPrices.ts +++ b/liquidity/lib/useCollateralPrices/useCollateralPrices.ts @@ -1,12 +1,11 @@ import { isBaseAndromeda } from '@snx-v3/isBaseAndromeda'; -import { stringToHash, contractsHash } from '@snx-v3/tsHelpers'; +import { contractsHash, stringToHash } from '@snx-v3/tsHelpers'; import { Network, useDefaultProvider, useNetwork, useProviderForChain, } from '@snx-v3/useBlockchain'; -import { getPriceUpdates, getPythFeedIds } from '@snx-v3/useCollateralPriceUpdates'; import { useCollateralTypes } from '@snx-v3/useCollateralTypes'; import { useCoreProxy } from '@snx-v3/useCoreProxy'; import { useGetUSDTokens } from '@snx-v3/useGetUSDTokens'; @@ -101,14 +100,6 @@ export const useCollateralPrices = (customNetwork?: Network) => { const allCalls = [...calls]; - const priceUpdateTx = (await getPriceUpdates( - (await getPythFeedIds(targetNetwork)) as string[], - targetNetwork - ).catch(() => undefined)) as any; - if (priceUpdateTx) { - allCalls.unshift(priceUpdateTx); - } - const prices = await erc7412Call( targetNetwork, provider, diff --git a/liquidity/lib/useLiquidityPosition/package.json b/liquidity/lib/useLiquidityPosition/package.json index 0eb706453..d36a94587 100644 --- a/liquidity/lib/useLiquidityPosition/package.json +++ b/liquidity/lib/useLiquidityPosition/package.json @@ -7,7 +7,6 @@ "@snx-v3/tsHelpers": "workspace:*", "@snx-v3/useAccountCollateral": "workspace:*", "@snx-v3/useBlockchain": "workspace:*", - "@snx-v3/useCollateralPriceUpdates": "workspace:*", "@snx-v3/useCollateralPrices": "workspace:*", "@snx-v3/useCollateralTypes": "workspace:*", "@snx-v3/useCoreProxy": "workspace:*", diff --git a/liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts b/liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts index 1fc811c58..eb0bdcfc8 100644 --- a/liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts +++ b/liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts @@ -2,7 +2,6 @@ import { contractsHash } from '@snx-v3/tsHelpers'; import { AccountCollateralType, loadAccountCollateral } from '@snx-v3/useAccountCollateral'; import { useNetwork, useProviderForChain } from '@snx-v3/useBlockchain'; import { loadPrices } from '@snx-v3/useCollateralPrices'; -import { getPriceUpdates, getPythFeedIds } from '@snx-v3/useCollateralPriceUpdates'; import { useCollateralTypes } from '@snx-v3/useCollateralTypes'; import { useCoreProxy } from '@snx-v3/useCoreProxy'; import { useSystemToken } from '@snx-v3/useSystemToken'; @@ -126,14 +125,6 @@ export const useLiquidityPosition = ({ const allCalls = priceCalls.concat(positionCalls).concat(accountCollateralCalls); - const priceUpdateTx = (await getPriceUpdates( - (await getPythFeedIds(network)) as string[], - network - ).catch(() => undefined)) as any; - if (priceUpdateTx) { - allCalls.unshift(priceUpdateTx); - } - return await erc7412Call( network, provider, diff --git a/liquidity/lib/useLiquidityPositions/package.json b/liquidity/lib/useLiquidityPositions/package.json index fa197ebb1..1819fafcb 100644 --- a/liquidity/lib/useLiquidityPositions/package.json +++ b/liquidity/lib/useLiquidityPositions/package.json @@ -7,7 +7,6 @@ "@snx-v3/calculations": "workspace:*", "@snx-v3/tsHelpers": "workspace:*", "@snx-v3/useBlockchain": "workspace:*", - "@snx-v3/useCollateralPriceUpdates": "workspace:*", "@snx-v3/useCollateralPrices": "workspace:*", "@snx-v3/useCollateralTypes": "workspace:*", "@snx-v3/useCoreProxy": "workspace:*", diff --git a/liquidity/lib/useLiquidityPositions/useLiquidityPositions.ts b/liquidity/lib/useLiquidityPositions/useLiquidityPositions.ts index 2e05ab925..f7f9db7c7 100644 --- a/liquidity/lib/useLiquidityPositions/useLiquidityPositions.ts +++ b/liquidity/lib/useLiquidityPositions/useLiquidityPositions.ts @@ -1,8 +1,7 @@ import { calculateCRatio } from '@snx-v3/calculations'; -import { keyBy, stringToHash, contractsHash } from '@snx-v3/tsHelpers'; +import { contractsHash, keyBy, stringToHash } from '@snx-v3/tsHelpers'; import { useNetwork, useProviderForChain } from '@snx-v3/useBlockchain'; import { loadPrices } from '@snx-v3/useCollateralPrices'; -import { getPriceUpdates, getPythFeedIds } from '@snx-v3/useCollateralPriceUpdates'; import { CollateralType, useCollateralTypes } from '@snx-v3/useCollateralTypes'; import { useCoreProxy } from '@snx-v3/useCoreProxy'; import { loadPosition } from '@snx-v3/useLiquidityPosition'; @@ -99,14 +98,6 @@ export const useLiquidityPositions = ({ accountId }: { accountId?: string }) => const allCalls = priceCalls.concat(positionCalls).concat(availableCollateralCalls); const singlePositionDecoder = positionCallsAndData.at(0)?.decoder; - const priceUpdateTx = (await getPriceUpdates( - (await getPythFeedIds(network)) as string[], - network - ).catch(() => undefined)) as any; - if (priceUpdateTx) { - allCalls.unshift(priceUpdateTx); - } - return await erc7412Call( network, provider!, diff --git a/liquidity/lib/usePoolConfiguration/package.json b/liquidity/lib/usePoolConfiguration/package.json index 42ef9e7ce..a133217d9 100644 --- a/liquidity/lib/usePoolConfiguration/package.json +++ b/liquidity/lib/usePoolConfiguration/package.json @@ -6,7 +6,6 @@ "dependencies": { "@snx-v3/tsHelpers": "workspace:*", "@snx-v3/useBlockchain": "workspace:*", - "@snx-v3/useCollateralPriceUpdates": "workspace:*", "@snx-v3/useCoreProxy": "workspace:*", "@snx-v3/withERC7412": "workspace:*", "@snx-v3/zod": "workspace:*", diff --git a/liquidity/lib/usePoolConfiguration/usePoolConfiguration.ts b/liquidity/lib/usePoolConfiguration/usePoolConfiguration.ts index a0d28e27d..4ec2fe92a 100644 --- a/liquidity/lib/usePoolConfiguration/usePoolConfiguration.ts +++ b/liquidity/lib/usePoolConfiguration/usePoolConfiguration.ts @@ -1,6 +1,5 @@ import { contractsHash } from '@snx-v3/tsHelpers'; import { useNetwork, useProvider } from '@snx-v3/useBlockchain'; -import { getPriceUpdates, getPythFeedIds } from '@snx-v3/useCollateralPriceUpdates'; import { useCoreProxy } from '@snx-v3/useCoreProxy'; import { erc7412Call } from '@snx-v3/withERC7412'; import { SmallIntSchema, WeiSchema } from '@snx-v3/zod'; @@ -57,14 +56,6 @@ export const usePoolConfiguration = (poolId?: string) => { markets.map((m) => CoreProxyContract.populateTransaction.isMarketCapacityLocked(m.id)) ); - const priceUpdateTx = (await getPriceUpdates( - (await getPythFeedIds(network)) as string[], - network - ).catch(() => undefined)) as any; - if (priceUpdateTx) { - allCalls.unshift(priceUpdateTx); - } - const decoded = await erc7412Call( network, provider, diff --git a/liquidity/lib/useVaultsData/package.json b/liquidity/lib/useVaultsData/package.json index 2ab038153..eef98b2be 100644 --- a/liquidity/lib/useVaultsData/package.json +++ b/liquidity/lib/useVaultsData/package.json @@ -5,7 +5,6 @@ "version": "0.0.1", "dependencies": { "@snx-v3/useBlockchain": "workspace:*", - "@snx-v3/useCollateralPriceUpdates": "workspace:*", "@snx-v3/useCollateralTypes": "workspace:*", "@snx-v3/useCoreProxy": "workspace:*", "@snx-v3/withERC7412": "workspace:*", diff --git a/liquidity/lib/useVaultsData/useVaultsData.ts b/liquidity/lib/useVaultsData/useVaultsData.ts index abb0b738b..884f01dc0 100644 --- a/liquidity/lib/useVaultsData/useVaultsData.ts +++ b/liquidity/lib/useVaultsData/useVaultsData.ts @@ -1,5 +1,4 @@ import { Network, useNetwork, useProviderForChain } from '@snx-v3/useBlockchain'; -import { getPriceUpdates, getPythFeedIds } from '@snx-v3/useCollateralPriceUpdates'; import { useCollateralTypes } from '@snx-v3/useCollateralTypes'; import { useCoreProxy } from '@snx-v3/useCoreProxy'; import { erc7412Call } from '@snx-v3/withERC7412'; @@ -56,14 +55,6 @@ export const useVaultsData = (poolId?: number, customNetwork?: Network) => { const allCalls = await Promise.all([collateralCallsP, debtCallsP]); - const priceUpdateTx = (await getPriceUpdates( - (await getPythFeedIds(targetNetwork)) as string[], - targetNetwork - ).catch(() => undefined)) as any; - if (priceUpdateTx) { - allCalls.unshift(priceUpdateTx); - } - return await erc7412Call( targetNetwork, provider, diff --git a/yarn.lock b/yarn.lock index d8623e5a7..faa98ddfc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5297,7 +5297,6 @@ __metadata: dependencies: "@snx-v3/tsHelpers": "workspace:*" "@snx-v3/useBlockchain": "workspace:*" - "@snx-v3/useCollateralPriceUpdates": "workspace:*" "@snx-v3/useCollateralTypes": "workspace:*" "@snx-v3/useCoreProxy": "workspace:*" "@snx-v3/useSystemToken": "workspace:*" @@ -5545,7 +5544,6 @@ __metadata: "@snx-v3/isBaseAndromeda": "workspace:*" "@snx-v3/tsHelpers": "workspace:*" "@snx-v3/useBlockchain": "workspace:*" - "@snx-v3/useCollateralPriceUpdates": "workspace:*" "@snx-v3/useCollateralTypes": "workspace:*" "@snx-v3/useCoreProxy": "workspace:*" "@snx-v3/useGetUSDTokens": "workspace:*" @@ -5770,7 +5768,6 @@ __metadata: "@snx-v3/tsHelpers": "workspace:*" "@snx-v3/useAccountCollateral": "workspace:*" "@snx-v3/useBlockchain": "workspace:*" - "@snx-v3/useCollateralPriceUpdates": "workspace:*" "@snx-v3/useCollateralPrices": "workspace:*" "@snx-v3/useCollateralTypes": "workspace:*" "@snx-v3/useCoreProxy": "workspace:*" @@ -5792,7 +5789,6 @@ __metadata: "@snx-v3/calculations": "workspace:*" "@snx-v3/tsHelpers": "workspace:*" "@snx-v3/useBlockchain": "workspace:*" - "@snx-v3/useCollateralPriceUpdates": "workspace:*" "@snx-v3/useCollateralPrices": "workspace:*" "@snx-v3/useCollateralTypes": "workspace:*" "@snx-v3/useCoreProxy": "workspace:*" @@ -5913,7 +5909,6 @@ __metadata: dependencies: "@snx-v3/tsHelpers": "workspace:*" "@snx-v3/useBlockchain": "workspace:*" - "@snx-v3/useCollateralPriceUpdates": "workspace:*" "@snx-v3/useCoreProxy": "workspace:*" "@snx-v3/withERC7412": "workspace:*" "@snx-v3/zod": "workspace:*" @@ -6317,7 +6312,6 @@ __metadata: resolution: "@snx-v3/useVaultsData@workspace:liquidity/lib/useVaultsData" dependencies: "@snx-v3/useBlockchain": "workspace:*" - "@snx-v3/useCollateralPriceUpdates": "workspace:*" "@snx-v3/useCollateralTypes": "workspace:*" "@snx-v3/useCoreProxy": "workspace:*" "@snx-v3/withERC7412": "workspace:*"