Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused graphql fields #1448

Open
wants to merge 22 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/common/graphql/graphql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export class GraphQlService {
const exchangeServiceUrl = this.apiConfigService.getExchangeServiceUrlMandatory();
const graphqlClient = new GraphQLClient(exchangeServiceUrl, {
fetch: this.createFetchWithTimeout(60_000),
headers: {
'origin': this.apiConfigService.getSelfUrl(),
cfaur09 marked this conversation as resolved.
Show resolved Hide resolved
},
});

try {
Expand Down
12 changes: 6 additions & 6 deletions src/endpoints/mex/entities/mex.pair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ export class MexPair {
@ApiProperty({ type: String, example: 'jungledex' })
exchange: MexPairExchange | undefined;

@ApiProperty({ type: Boolean, nullable: true })
hasFarms: boolean | undefined = undefined;

@ApiProperty({ type: Boolean, nullable: true })
hasDualFarms: boolean | undefined = undefined;

@ApiProperty({ type: Number, nullable: true })
tradesCount: number | undefined = undefined;

Expand All @@ -82,4 +76,10 @@ export class MexPair {

@ApiProperty({ type: Number, nullable: true })
deployedAt: number | undefined = undefined;

@ApiProperty({ type: Boolean, nullable: true })
hasFarms?: boolean;

@ApiProperty({ type: Boolean, nullable: true })
hasDualFarms?: boolean;
}
1 change: 1 addition & 0 deletions src/endpoints/mex/entities/mex.pairs..filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export class MexPairsFilter {
Object.assign(this, init);
}
exchange?: MexPairExchange;
includeFarms?: boolean;
}
12 changes: 6 additions & 6 deletions src/endpoints/mex/entities/mex.settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class MexSettings {
...response.proxy.map((x: any) => x.address),
];
settings.pairContracts = [
...response.pairs.filter((x: any) => x.state === 'Active').map((x: any) => x.address),
...response.pairs.map((x: any) => x.address),
...response.proxy.map((x: any) => x.address),
];
settings.wrapContracts = response.wrappingInfo.map((x: any) => x.address);
Expand All @@ -39,11 +39,11 @@ export class MexSettings {
settings.lockedAssetIdentifier = lockedAssetIdentifiers.find((identifier: string) => identifier.startsWith('LKMEX'));
settings.lockedAssetIdentifierV2 = lockedAssetIdentifiers.find((identifier: string) => identifier.startsWith('XMEX'));

const mexEgldPairs = response.pairs.filter((x: any) => x.firstToken.name === 'WrappedEGLD' && x.secondToken.name === 'MEX');
if (mexEgldPairs.length > 0) {
settings.wegldId = mexEgldPairs[0].firstToken.identifier;
settings.mexId = mexEgldPairs[0].secondToken.identifier;
}
const wrappedToken = response.wrappingInfo[0].wrappedToken.identifier;
const mexToken = response.simpleLockEnergy.baseAssetToken.identifier;

settings.wegldId = wrappedToken;
settings.mexId = mexToken;

return settings;
}
Expand Down
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