diff --git a/src/queries/graphql/gaugePositions.tsx b/src/queries/graphql/gaugePositions.tsx new file mode 100644 index 0000000..84a6697 --- /dev/null +++ b/src/queries/graphql/gaugePositions.tsx @@ -0,0 +1,14 @@ +import { gql } from "graphql-request"; + +export const GET_GAUGE_POSITIONS = gql` + query UserGaugePositions($safeAddr: String!) { + gaugePositions(where: { user: $safeAddr, balance_gt: "0" }) { + gauge { + id + protocol + pool + pool_name + } + } + } +`; diff --git a/src/queries/useGetUserGaugePositions.tsx b/src/queries/useGetUserGaugePositions.tsx index ffa7958..12aff86 100644 --- a/src/queries/useGetUserGaugePositions.tsx +++ b/src/queries/useGetUserGaugePositions.tsx @@ -1,9 +1,10 @@ import { useQuery } from "@tanstack/react-query"; import { useAccount, useNetwork } from "wagmi"; -import { request, gql } from "graphql-request"; +import { request } from "graphql-request"; import { chainDetails } from "../helpers/chainDetails"; +import { GET_GAUGE_POSITIONS } from "./graphql/gaugePositions"; export interface IGaugePositions { id: string; @@ -19,25 +20,15 @@ async function getUserGaugePositions( if (!chainId) throw new Error("Missing Chain ID"); if (!chainDetails[chainId].subgraphGauges) throw new Error("No Gauge subgraph url available"); - const querySafeAddr = gql` - query UserGaugePositions { - gaugePositions( - where: { - user: "${safeAddress}" - balance_gt: "0" - } - ) { - gauge { - id - protocol - pool - pool_name - } - } - } - `; + const queryVars = { + safeAddr: `${safeAddress}`, + }; const positions = ( - await request(chainDetails[chainId].subgraphGauges, querySafeAddr) + await request( + chainDetails[chainId].subgraphGauges, + GET_GAUGE_POSITIONS, + queryVars, + ) ).gaugePositions; const gaugeResults: IGaugePositions[] = []; positions.forEach((position: any) => {