Skip to content

Commit

Permalink
Refactor GraphQL queries into separate files for MEX services
Browse files Browse the repository at this point in the history
  • Loading branch information
cfaur09 committed Feb 8, 2025
1 parent 59cfb51 commit 23b0151
Show file tree
Hide file tree
Showing 12 changed files with 266 additions and 253 deletions.
98 changes: 98 additions & 0 deletions src/endpoints/mex/graphql/farms.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { gql } from "graphql-request";

export const farmsQuery = gql`
query {
farms {
... on FarmModelV1_2 {
version
address
farmToken {
collection
name
ticker
__typename
}
farmingToken {
name
identifier
decimals
__typename
}
farmedToken {
name
identifier
decimals
__typename
}
farmTokenPriceUSD
farmingTokenPriceUSD
farmedTokenPriceUSD
}
... on FarmModelV1_3 {
version
address
farmToken {
collection
name
ticker
__typename
}
farmingToken {
name
identifier
decimals
__typename
}
farmedToken {
name
identifier
decimals
__typename
}
farmTokenPriceUSD
farmingTokenPriceUSD
farmedTokenPriceUSD
}
... on FarmModelV2 {
version
address
farmToken {
collection
name
ticker
__typename
}
farmingToken {
name
identifier
decimals
__typename
}
farmedToken {
name
identifier
decimals
__typename
}
farmTokenPriceUSD
farmingTokenPriceUSD
farmedTokenPriceUSD
}
}
stakingFarms {
address
farmingToken {
name
identifier
decimals
__typename
}
farmToken {
name
collection
decimals
__typename
}
}
}
`;
51 changes: 51 additions & 0 deletions src/endpoints/mex/graphql/filtered.pairs.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { gql } from "graphql-request";

export const filteredPairsQuery = (includeFarms: boolean = false) => {
const farmFields = includeFarms ? `
hasFarms
hasDualFarms` : '';

return gql`
query filteredPairs($pagination: ConnectionArgs!, $filters: PairsFilter!) {
filteredPairs(pagination: $pagination, filters: $filters) {
edges {
cursor
node {
address
liquidityPoolToken {
identifier
name
__typename
}
liquidityPoolTokenPriceUSD
firstToken {
name
identifier
previous24hPrice
__typename
}
secondToken {
name
identifier
previous24hPrice
__typename
}
firstTokenPriceUSD
secondTokenPriceUSD
state
type
lockedValueUSD
volumeUSD24h
tradesCount
tradesCount24h
deployedAt
${farmFields}
}
}
pageInfo {
hasNextPage
}
}
}
`;
};
8 changes: 8 additions & 0 deletions src/endpoints/mex/graphql/pairs.count.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { gql } from "graphql-request";

export const pairCountQuery = gql`
query PairCount {
factory {
pairCount
}
}`;
60 changes: 60 additions & 0 deletions src/endpoints/mex/graphql/settings.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { gql } from "graphql-request";

export const settingsQuery = (pairLimitCount: number) => gql`
query {
filteredPairs(pagination: {first: ${pairLimitCount}}, filters: {state: ["Active"]}) {
edges {
node {
address
}
}
}
proxy {
address
lockedAssetTokens {
collection
}
}
farms {
... on FarmModelV1_2 {
state
address
}
... on FarmModelV1_3 {
state
address
}
... on FarmModelV2 {
state
address
}
}
wrappingInfo {
address
wrappedToken {
identifier
}
}
distribution {
address
}
lockedAssetFactory {
address
}
stakingFarms {
state
address
}
stakingProxies {
address
}
factory {
address
}
simpleLockEnergy {
baseAssetToken {
identifier
}
}
}
`;
12 changes: 12 additions & 0 deletions src/endpoints/mex/graphql/staking.proxy.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { gql } from "graphql-request";

export const stakingProxyQuery = gql`
query StakingProxy {
stakingProxies {
address
dualYieldToken {
name
collection
}
}
}`;
13 changes: 13 additions & 0 deletions src/endpoints/mex/graphql/token.prices.hour.resolution.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { gql } from "graphql-request";

export const tokenPricesHourResolutionQuery = (tokenIdentifier: string) => gql`
query tokenPricesHourResolution {
values24h(
series: "${tokenIdentifier}",
metric: "priceUSD"
) {
timestamp
value
}
}
`;
9 changes: 9 additions & 0 deletions src/endpoints/mex/graphql/tokens.query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { gql } from "graphql-request";

export const tokensQuery = gql`
query tokens {
tokens {
identifier
type
}
}`;
Loading

0 comments on commit 23b0151

Please sign in to comment.