Skip to content

Commit

Permalink
fix stableswap subgraph query (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
mul53 authored Apr 28, 2022
1 parent b731810 commit 60aa53b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fuseio/earn-sdk",
"version": "1.0.1",
"version": "1.0.2",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
5 changes: 5 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ export const MASTERCHEF_V3_SUBGRAPH_URL = 'https://api.thegraph.com/subgraphs/na
export const xVOLT = '0x97a6e78c9208c21afaDa67e7E61d7ad27688eFd1'
export const VOLT = '0x34Ef2Cc892a88415e9f02b91BfA9c91fC0bE6bD4'

export const STABLESWAP_POOL_LP_HASH = {
'0xa3c1046290b490e629e11ace35863cb0cae382ab': '0x2a68d7c6ea986fa06b2665d08b4d08f5e7af960c',
'0xc71cab88c1674a39a3e2841274e54e34d709af91': '0x83d158beadbb3445ac901cfd0ca33fb30ccc8f53'
}

export const STABLESWAP_POOLS = ['0x2a68D7C6Ea986fA06B2665d08b4D08F5e7aF960c', '0x83D158Beadbb3445AC901cFd0ca33FB30CCC8f53']
2 changes: 1 addition & 1 deletion src/graphql/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function pairQuery (address: string) {
export function stablePoolQuery (poolAddress: string) {
return gql`
{
swaps(id: "${poolAddress.toLowerCase()}") {
swap(id: "${poolAddress.toLowerCase()}") {
numTokens
balances
lpTokenSupply
Expand Down
12 changes: 6 additions & 6 deletions src/utils/fetchChefPairInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NetworkId } from '../constants'
import { NetworkId, STABLESWAP_POOL_LP_HASH } from '../constants'
import { pairQuery, stablePoolQuery } from '../graphql/query'
import { stableswapClient, voltageClient } from '../graphql'
import { isStableswap } from '.'
Expand All @@ -7,13 +7,13 @@ async function fetchPairInfoVoltage (address: string) {
let result
if (isStableswap(address)) {
result = await stableswapClient.query({
query: stablePoolQuery(address)
query: stablePoolQuery(STABLESWAP_POOL_LP_HASH[address.toLowerCase()])
})
const tokens = result?.data?.swaps?.tokens
const reserves = result?.data?.swaps?.balances
const tokens = result?.data?.swap?.tokens
const reserves = result?.data?.swap?.balances
return {
reserveUSD: result?.data?.swaps?.lpTokenSupply * 1,
totalSupply: result?.data?.swaps?.lpTokenSupply,
reserveUSD: result?.data?.swap?.lpTokenSupply * 1,
totalSupply: result?.data?.swap?.lpTokenSupply,
tokens,
totalReserves: reserves
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigNumber } from 'bignumber.js'
import { MASTERCHEF_V2_ADDRESS, MASTERCHEF_V3_ADDRESS, STABLESWAP_POOLS } from '../constants'
import { MASTERCHEF_V2_ADDRESS, MASTERCHEF_V3_ADDRESS, STABLESWAP_POOL_LP_HASH } from '../constants'
import { masterChefV2Client, masterChefV3Client } from '../graphql'
import { Chef } from '../rewards/ChefRewardProgram'

Expand Down Expand Up @@ -52,5 +52,5 @@ export function getChefSubgraph (chef: Chef) {
}

export function isStableswap (address: string) {
return STABLESWAP_POOLS.includes(address)
return !!STABLESWAP_POOL_LP_HASH[address]
}

0 comments on commit 60aa53b

Please sign in to comment.