Skip to content

Commit

Permalink
feat: add missing price ids (#251)
Browse files Browse the repository at this point in the history
* feat: add missing price ids

* fix: load position price updates
  • Loading branch information
Rickk137 authored Apr 21, 2024
1 parent 2c4ae27 commit 4c47a21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const priceIds = [
'0xdcef50dd0a4cd2dcc17e45df1676dcb336a11a61c69df7a0299b0150c672d25c',
'0x3fa4252848f9f0a1480be62745a4629d9eb1322aebab8a791e344b3b9c1adcf5',
'0x39d020f60982ed892abbcd4a06a276a9f9b7bfbce003204c110b6e488f502da3',
'0x5c6c0d2386e3352356c3ab84434fafb5ea067ac2678a38a338c4a69ddc4bdb0c',
'0x5de33a9112c2b700b8d30b8a3402c103578ccfa2765696471cc672bd5cf6ac52',
];

const priceService = new EvmPriceServiceConnection(offchainMainnetEndpoint);
Expand Down
7 changes: 7 additions & 0 deletions liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { loadAccountCollateral, AccountCollateralType } from '@snx-v3/useAccount
import { useAllCollateralPriceIds } from '@snx-v3/useAllCollateralPriceIds';
import { fetchPriceUpdates, priceUpdatesToPopulatedTx } from '@snx-v3/fetchPythPrices';
import { useUSDProxy } from '@snx-v3/useUSDProxy';
import { useCollateralPriceUpdates } from '../useCollateralPriceUpdates';

const PositionCollateralSchema = z.object({
value: ZodBigNumber.transform((x) => wei(x)).optional(), // This is currently only removed on base-goreli
Expand Down Expand Up @@ -79,6 +80,7 @@ export const useLiquidityPosition = ({
const { data: CoreProxy } = useCoreProxy();
const { data: UsdProxy } = useUSDProxy();
const { network } = useNetwork();
const { data: priceUpdateTx } = useCollateralPriceUpdates();

return useQuery({
queryKey: [
Expand All @@ -89,6 +91,7 @@ export const useLiquidityPosition = ({
pool: poolId,
token: tokenAddress,
collateralPriceUpdatesLength: collateralPriceUpdates?.length,
priceUpdateTx: priceUpdateTx?.data || '',
},
],
enabled: Boolean(
Expand Down Expand Up @@ -135,6 +138,10 @@ export const useLiquidityPosition = ({
.concat(positionCalls)
.concat(accountCollateralCalls);

if (priceUpdateTx) {
allCalls.unshift(priceUpdateTx as any);
}

return await erc7412Call(
network,
CoreProxy.provider,
Expand Down
2 changes: 1 addition & 1 deletion liquidity/ui/src/pages/Manage/ManageStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const ManageStatsUi: FC<{
</Tooltip>
</Flex>
<Flex width="100%">
{liquidityPosition && aprData ? (
{aprData ? (
<Flex
gap={1}
color="gray.50"
Expand Down

0 comments on commit 4c47a21

Please sign in to comment.