Skip to content

Commit

Permalink
Remove price updates from read tx (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
noisekit authored Nov 26, 2024
1 parent 887da31 commit 782c150
Show file tree
Hide file tree
Showing 13 changed files with 2 additions and 68 deletions.
1 change: 0 additions & 1 deletion liquidity/lib/useAccountCollateral/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
9 changes: 0 additions & 9 deletions liquidity/lib/useAccountCollateral/useAccountCollaterals.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) => {
Expand Down
1 change: 0 additions & 1 deletion liquidity/lib/useCollateralPrices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
11 changes: 1 addition & 10 deletions liquidity/lib/useCollateralPrices/useCollateralPrices.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion liquidity/lib/useLiquidityPosition/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
9 changes: 0 additions & 9 deletions liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion liquidity/lib/useLiquidityPositions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
11 changes: 1 addition & 10 deletions liquidity/lib/useLiquidityPositions/useLiquidityPositions.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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!,
Expand Down
1 change: 0 additions & 1 deletion liquidity/lib/usePoolConfiguration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
9 changes: 0 additions & 9 deletions liquidity/lib/usePoolConfiguration/usePoolConfiguration.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion liquidity/lib/useVaultsData/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
9 changes: 0 additions & 9 deletions liquidity/lib/useVaultsData/useVaultsData.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:*"
Expand Down Expand Up @@ -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:*"
Expand Down Expand Up @@ -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:*"
Expand All @@ -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:*"
Expand Down Expand Up @@ -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:*"
Expand Down Expand Up @@ -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:*"
Expand Down

0 comments on commit 782c150

Please sign in to comment.