-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
341091b
commit 955f76d
Showing
8 changed files
with
472 additions
and
89 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' | ||
|
||
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,23 @@ | ||
import gql from 'graphql-tag' | ||
|
||
export const PAIRS_DATA_FOR_REWARDS = ({ pairIds = [] }) => { | ||
const poolsString = `[${pairIds.map(pool => `"${pool}"`).join(',')}]` | ||
let queryString = ` | ||
query pairDayDatas { | ||
pairDayDatas( | ||
where: { | ||
pairIn: ${poolsString}, | ||
} | ||
orderBy: "date" | ||
orderByDirection: "desc" | ||
first: ${10 * pairIds.length} | ||
) { | ||
pairId | ||
date | ||
dailyVolumeUSD | ||
reserveUSD | ||
} | ||
} | ||
` | ||
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
Oops, something went wrong.