-
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.
Merge pull request #233 from jediswaplabs/167-show-usd-value-for-toke…
…ns-in-swap-page-and-lp-page 167 show usd value for tokens in swap page and lp page
- Loading branch information
Showing
15 changed files
with
527 additions
and
132 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,46 @@ | ||
import { ApolloClient } from '@apollo/client' | ||
import { ChainId } from '@vnaysn/jediswap-sdk-core' | ||
import { InMemoryCache } from 'apollo-cache-inmemory' | ||
import { HttpLink } from 'apollo-link-http' | ||
|
||
const 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 | ||
} | ||
} | ||
}, | ||
}) | ||
|
||
export const jediSwapClient = new ApolloClient({ | ||
link: new HttpLink({ | ||
uri: 'https://api.v2.jediswap.xyz/graphql', | ||
}), | ||
cache, | ||
shouldBatch: true, | ||
}) | ||
|
||
export const jediSwapClientSepolia = new ApolloClient({ | ||
link: new HttpLink({ | ||
uri: 'https://api.v2.sepolia.jediswap.xyz/graphql', | ||
}), | ||
cache, | ||
shouldBatch: true, | ||
}) | ||
|
||
export const getClient = (chainId) => { | ||
return !chainId || chainId === ChainId.MAINNET ? jediSwapClient : jediSwapClientSepolia | ||
} |
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}}) { | ||
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.