diff --git a/packages/server/src/queries/blockaid/transaction.ts b/packages/server/src/queries/blockaid/transaction.ts index 6518d5c46a..3372f16c9d 100644 --- a/packages/server/src/queries/blockaid/transaction.ts +++ b/packages/server/src/queries/blockaid/transaction.ts @@ -13,6 +13,7 @@ export interface TransactionScanRequest { * Tx hex bytes */ transaction: string; + account_address: string; metadata: { [key: string]: string }; } diff --git a/packages/server/src/queries/complex/orderbooks/pools.ts b/packages/server/src/queries/complex/orderbooks/pools.ts index 3119270d51..bbbd36a388 100644 --- a/packages/server/src/queries/complex/orderbooks/pools.ts +++ b/packages/server/src/queries/complex/orderbooks/pools.ts @@ -22,14 +22,16 @@ export function getOrderbookPools() { ttl: 1000 * 60 * 60, // 1 hour getFreshValue: () => queryCanonicalOrderbooks().then(async (data) => { - return data.map((orderbook) => { - return { - baseDenom: orderbook.base, - quoteDenom: orderbook.quote, - contractAddress: orderbook.contract_address, - poolId: orderbook.pool_id.toString(), - }; - }) as Orderbook[]; + return data + .filter((o) => o.pool_id < 2065) + .map((orderbook) => { + return { + baseDenom: orderbook.base, + quoteDenom: orderbook.quote, + contractAddress: orderbook.contract_address, + poolId: orderbook.pool_id.toString(), + }; + }) as Orderbook[]; }), }); } diff --git a/packages/trpc/src/orderbook-router.ts b/packages/trpc/src/orderbook-router.ts index f1385a1a30..b113d94886 100644 --- a/packages/trpc/src/orderbook-router.ts +++ b/packages/trpc/src/orderbook-router.ts @@ -63,7 +63,9 @@ export const orderbookRouter = createTRPCRouter({ getFreshItems: async () => { const { userOsmoAddress } = input; const pools = await getOrderbookPools(); - const contractAddresses = pools.map((p) => p.contractAddress); + const activePools = pools.filter((p) => parseInt(p.poolId) < 2065); + const contractAddresses = activePools.map((p) => p.contractAddress); + if (contractAddresses.length === 0 || userOsmoAddress.length === 0) return []; const promises = contractAddresses.map( diff --git a/packages/web/components/complex/orders-history/index.tsx b/packages/web/components/complex/orders-history/index.tsx index 93fffea1b8..19ed1e7447 100644 --- a/packages/web/components/complex/orders-history/index.tsx +++ b/packages/web/components/complex/orders-history/index.tsx @@ -84,6 +84,7 @@ export const OrderHistory = observer(() => { } = useOrderbookAllActiveOrders({ userAddress: wallet?.address ?? "", pageSize: 20, + refetchInterval: 15000, }); const groupedOrders = useMemo(() => groupOrdersByStatus(orders), [orders]); @@ -116,11 +117,14 @@ export const OrderHistory = observer(() => { paddingStart: 45, }); - const { claimAllOrders, count: filledOrdersCount } = - useOrderbookClaimableOrders({ - userAddress: wallet?.address ?? "", - disabled: isLoading || orders.length === 0 || isRefetching, - }); + const filledOrders = orders.filter((o) => o.status === "filled"); + const filledOrdersCount = filledOrders.length; + + const { claimAllOrders } = useOrderbookClaimableOrders({ + userAddress: wallet?.address ?? "", + disabled: isLoading || orders.length === 0 || isRefetching, + orders: filledOrders, + }); const claimOrders = useCallback(async () => { try { diff --git a/packages/web/hooks/limit-orders/use-orderbook.ts b/packages/web/hooks/limit-orders/use-orderbook.ts index 215c20d642..2cdfee8ade 100644 --- a/packages/web/hooks/limit-orders/use-orderbook.ts +++ b/packages/web/hooks/limit-orders/use-orderbook.ts @@ -291,6 +291,8 @@ export const useOrderbookAllActiveOrders = ({ getNextPageParam: (lastPage) => lastPage.nextCursor, initialCursor: 0, refetchInterval, + cacheTime: refetchInterval, + staleTime: refetchInterval, enabled: !!userAddress && addresses.length > 0, refetchOnMount: true, keepPreviousData: false, @@ -326,30 +328,32 @@ export const useOrderbookAllActiveOrders = ({ }; export const useOrderbookClaimableOrders = ({ - userAddress, - disabled = false, + userAddress: _, + disabled: __, + orders = [], }: { userAddress: string; disabled?: boolean; + orders: MappedLimitOrder[]; }) => { const { orderbooks } = useOrderbooks(); const { accountStore } = useStore(); const account = accountStore.getWallet(accountStore.osmosisChainId); const addresses = orderbooks.map(({ contractAddress }) => contractAddress); - const { - data: orders, - isLoading, - isFetching, - refetch, - } = api.edge.orderbooks.getClaimableOrders.useQuery( - { - userOsmoAddress: userAddress, - }, - { - enabled: !!userAddress && addresses.length > 0 && !disabled, - refetchOnMount: true, - } - ); + // const { + // data: orders, + // isLoading, + // isFetching, + // refetch, + // } = api.edge.orderbooks.getClaimableOrders.useQuery( + // { + // userOsmoAddress: userAddress, + // }, + // { + // enabled: !!userAddress && addresses.length > 0 && !disabled, + // refetchOnMount: true, + // } + // ); const claimAllOrders = useCallback(async () => { if (!account || !orders) return; @@ -379,14 +383,14 @@ export const useOrderbookClaimableOrders = ({ if (msgs.length > 0) { await account?.cosmwasm.sendMultiExecuteContractMsg("executeWasm", msgs); - await refetch(); + // await refetch(); } - }, [orders, account, addresses, refetch]); + }, [orders, account, addresses]); return { orders: orders ?? [], count: orders?.length ?? 0, - isLoading: isLoading || isFetching, + isLoading: false, claimAllOrders, }; }; diff --git a/packages/web/pages/api/transaction-scan.ts b/packages/web/pages/api/transaction-scan.ts index 71619c53d2..e05d1de9cb 100644 --- a/packages/web/pages/api/transaction-scan.ts +++ b/packages/web/pages/api/transaction-scan.ts @@ -37,6 +37,7 @@ export default async function transactionScanHandler( chain: "osmosis", transaction: unsignedTx, options: ["validation", "simulation"], + account_address: bech32Address, metadata: { type: "in_app", },