-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graphql setup, usd queries integrated to swap and position page
- Loading branch information
1 parent
78657c1
commit 92d3954
Showing
11 changed files
with
410 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ApolloClient } from '@apollo/client' | ||
import { InMemoryCache } from 'apollo-cache-inmemory' | ||
import { HttpLink } from 'apollo-link-http' | ||
import { getApiUrl } from 'constants/tokens' | ||
|
||
export const jediSwapClient = new ApolloClient({ | ||
link: new HttpLink({ | ||
uri: getApiUrl(), | ||
headers: { | ||
// 'm-color': 'blue', | ||
}, | ||
}), | ||
cache: new InMemoryCache({ | ||
dataIdFromObject: (object) => { | ||
switch (object.__typename) { | ||
case 'TokenDayData': { | ||
return `${object.tokenAddress}${object.datetime}` | ||
} | ||
case 'FactoryDayData': { | ||
return `${object.id}${object.dayId}` | ||
} | ||
case 'Token': { | ||
return `${object.tokenAddress}${object.name}` | ||
} | ||
case 'Pool': { | ||
return `${object.poolAddress}${object.datetime}` | ||
} | ||
default: { | ||
return object.id || object._id | ||
} | ||
} | ||
}, | ||
}), | ||
shouldBatch: true, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import gql from 'graphql-tag' | ||
|
||
const TokenFields = ` | ||
fragment TokenFields on Token { | ||
tokenAddress | ||
name | ||
symbol | ||
derivedETH | ||
volume | ||
volumeUSD | ||
untrackedVolumeUSD | ||
totalValueLocked | ||
totalValueLockedUSD | ||
txCount | ||
feesUSD | ||
} | ||
` | ||
|
||
export const TOKENS_DATA = ({ tokenIds = [] }) => { | ||
const tokenString = `[${tokenIds.map((token) => `"${token}"`).join(',')}]` | ||
|
||
let queryString = ` | ||
${TokenFields} | ||
query tokensData { | ||
tokensData(first: 500, where: {tokenAddressIn: ${tokenString}, periodIn: "one_day"}) { | ||
token{...TokenFields} | ||
period | ||
} | ||
} | ||
` | ||
return gql(queryString) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.