diff --git a/packages/data/__mocks__/burned.ts b/packages/data/__mocks__/burned.ts index 72f59d902..54b54dd36 100644 --- a/packages/data/__mocks__/burned.ts +++ b/packages/data/__mocks__/burned.ts @@ -6,15 +6,15 @@ export const burnedMock = { id: '0x320e4bcaccb2b445ab8521e8a35e850db8145f29d689c64613e10bc3fc5cffcb-237', source: 'sUSD', timestamp: '1614910767', - value: '5954277455094130661333214', + value: '5954277.455094130661333214', }, formatted: { account: '0x042ed37d32b88ab6b1c2e7b8a400dcdc728050bc', block: 11975546, - gasPrice: '127000000000', + gasPrice: 127000000000, id: '0x320e4bcaccb2b445ab8521e8a35e850db8145f29d689c64613e10bc3fc5cffcb-237', source: 'sUSD', timestamp: 1614910767000, - value: '5954277.455094130661333214', + value: 5954277.455094130661333214, }, }; diff --git a/packages/data/__mocks__/dailyBurned.ts b/packages/data/__mocks__/dailyBurned.ts index d422780b0..d3ff2afd6 100644 --- a/packages/data/__mocks__/dailyBurned.ts +++ b/packages/data/__mocks__/dailyBurned.ts @@ -1,12 +1,12 @@ export const dailyBurnedMock = { response: { id: '1627446407', - value: '5954277455094130661333214', - totalDebt: '5954277455094130661333214', + value: '5954277.455094130661333214', + totalDebt: '5954277.455094130661333214', }, formatted: { id: '1627446407', - value: '5954277.455094130661333214', - totalDebt: '5954277.455094130661333214', + value: 5954277.455094130661333214, + totalDebt: 5954277.455094130661333214, }, }; diff --git a/packages/data/__mocks__/dailyIssued.ts b/packages/data/__mocks__/dailyIssued.ts index 23f772e56..50625e4e4 100644 --- a/packages/data/__mocks__/dailyIssued.ts +++ b/packages/data/__mocks__/dailyIssued.ts @@ -1,12 +1,12 @@ export const dailyIssuedMock = { response: { id: '1627446407', - value: '5954277455094130661333214', - totalDebt: '5954277455094130661333214', + value: '5954277.455094130661333214', + totalDebt: '5954277.455094130661333214', }, formatted: { id: '1627446407', - value: '5954277.455094130661333214', - totalDebt: '5954277.455094130661333214', + value: 5954277.455094130661333214, + totalDebt: 5954277.455094130661333214, }, }; diff --git a/packages/data/__mocks__/debtSnapshot.ts b/packages/data/__mocks__/debtSnapshot.ts index 7f534d2e6..1b1419251 100644 --- a/packages/data/__mocks__/debtSnapshot.ts +++ b/packages/data/__mocks__/debtSnapshot.ts @@ -4,17 +4,17 @@ export const debtSnapshotMock = { block: '11975546', id: '0x320e4bcaccb2b445ab8521e8a35e850db8145f29d689c64613e10bc3fc5cffcb-237', timestamp: '1614910767', - collateral: '5954277455094130661333214', - debtBalanceOf: '954277455094130661333214', - balanceOf: '4277455094130661333214', + collateral: '5954277.455094130661333214', + debtBalanceOf: '954277.455094130661333214', + balanceOf: '4277.455094130661333214', }, formatted: { account: '0x042ed37d32b88ab6b1c2e7b8a400dcdc728050bc', block: 11975546, id: '0x320e4bcaccb2b445ab8521e8a35e850db8145f29d689c64613e10bc3fc5cffcb-237', timestamp: 1614910767000, - collateral: '5954277.455094130661333214', - debtBalanceOf: '954277.455094130661333214', - balanceOf: '4277.455094130661333214', + collateral: 5954277.455094130661333214, + debtBalanceOf: 954277.455094130661333214, + balanceOf: 4277.455094130661333214, }, }; diff --git a/packages/data/__mocks__/exchangeEntrySettleds.ts b/packages/data/__mocks__/exchangeEntrySettleds.ts index 66ef2759b..81a82a134 100644 --- a/packages/data/__mocks__/exchangeEntrySettleds.ts +++ b/packages/data/__mocks__/exchangeEntrySettleds.ts @@ -1,25 +1,25 @@ export const exchangeEntrySettledsMock = { response: { - amount: '9992880960411389', + amount: '0.009992880960411389', dest: '0x7355534400000000000000000000000000000000000000000000000000000000', destRoundIdAtPeriodEnd: '1', exchangeTimestamp: '1612821588', from: '0x042ed37d32b88ab6b1c2e7b8a400dcdc728050bc', id: '0x07ad98b4d27aa3dc80c7505e5cfca1af115d8a7c0421d150ff7c8e7c04cd046b-346', - rebate: '469106080900746546', + rebate: '0.469106080900746546', reclaim: '0', src: '0x7342544300000000000000000000000000000000000000000000000000000000', srcRoundIdAtPeriodEnd: '55340232221128667446', }, formatted: { - amount: '0.009992880960411389', + amount: 0.009992880960411389, dest: '0x7355534400000000000000000000000000000000000000000000000000000000', destRoundIdAtPeriodEnd: '1', - exchangeTimestamp: 1612821588, + exchangeTimestamp: 1612821588000, from: '0x042ed37d32b88ab6b1c2e7b8a400dcdc728050bc', id: '0x07ad98b4d27aa3dc80c7505e5cfca1af115d8a7c0421d150ff7c8e7c04cd046b-346', - rebate: '0.469106080900746546', - reclaim: '0.0', + rebate: 0.469106080900746546, + reclaim: 0, src: '0x7342544300000000000000000000000000000000000000000000000000000000', srcRoundIdAtPeriodEnd: '55340232221128667446', }, diff --git a/packages/data/__mocks__/exchangeTotals.ts b/packages/data/__mocks__/exchangeTotals.ts index c597fd0a6..cd1fb7404 100644 --- a/packages/data/__mocks__/exchangeTotals.ts +++ b/packages/data/__mocks__/exchangeTotals.ts @@ -1,8 +1,8 @@ export const exchangeTotalsMock = { response: { - totalFeesGeneratedInUSD: '11641102349921181385', - exchangeUSDTally: '7772376002297375000000', - exchangers: '1', + totalFeesGeneratedInUSD: '11.641102349921181385', + exchangeUSDTally: '7772.376002297375', + exchangers: 1, id: '1723502', trades: '1', }, diff --git a/packages/data/__mocks__/feesClaimed.ts b/packages/data/__mocks__/feesClaimed.ts index d21decf81..5ce8cec99 100644 --- a/packages/data/__mocks__/feesClaimed.ts +++ b/packages/data/__mocks__/feesClaimed.ts @@ -4,15 +4,15 @@ export const feesClaimedMock = { block: '11975546', id: '0x320e4bcaccb2b445ab8521e8a35e850db8145f29d689c64613e10bc3fc5cffcb-237', timestamp: '1614910767', - value: '5954277455094130661333214', - rewards: '954277455094130661333214', + value: '5954277.455094130661333214', + rewards: '954277.455094130661333214', }, formatted: { account: '0x042ed37d32b88ab6b1c2e7b8a400dcdc728050bc', block: 11975546, id: '0x320e4bcaccb2b445ab8521e8a35e850db8145f29d689c64613e10bc3fc5cffcb-237', timestamp: 1614910767000, - value: '5954277.455094130661333214', - rewards: '954277.455094130661333214', + value: 5954277.455094130661333214, + rewards: 954277.455094130661333214, }, }; diff --git a/packages/data/__mocks__/issued.ts b/packages/data/__mocks__/issued.ts index 7e0fa473e..7f67e52aa 100644 --- a/packages/data/__mocks__/issued.ts +++ b/packages/data/__mocks__/issued.ts @@ -6,15 +6,15 @@ export const issuedMock = { id: '0x320e4bcaccb2b445ab8521e8a35e850db8145f29d689c64613e10bc3fc5cffcb-237', source: 'sUSD', timestamp: '1614910767', - value: '5954277455094130661333214', + value: '5954277.455094130661333214', }, formatted: { account: '0x042ed37d32b88ab6b1c2e7b8a400dcdc728050bc', block: 11975546, - gasPrice: '127000000000', + gasPrice: 127000000000, id: '0x320e4bcaccb2b445ab8521e8a35e850db8145f29d689c64613e10bc3fc5cffcb-237', source: 'sUSD', timestamp: 1614910767000, - value: '5954277.455094130661333214', + value: 5954277.455094130661333214, }, }; diff --git a/packages/data/__mocks__/rates.ts b/packages/data/__mocks__/rates.ts index 02808046c..8a07ba849 100644 --- a/packages/data/__mocks__/rates.ts +++ b/packages/data/__mocks__/rates.ts @@ -3,7 +3,7 @@ export const ratesMock = { block: '12110296', currencyKey: '0x534e580000000000000000000000000000000000000000000000000000000000', id: '0x2470d3b05f019581cf8df76a522db5c48780ef5dc0118977ba1e45056c4d6072-SNX', - rate: '16480000000000000000', + rate: '16.48', synth: 'SNX', timestamp: '1616704370', }, @@ -11,7 +11,7 @@ export const ratesMock = { block: 12110296, currencyKey: '0x534e580000000000000000000000000000000000000000000000000000000000', id: '0x2470d3b05f019581cf8df76a522db5c48780ef5dc0118977ba1e45056c4d6072-SNX', - rate: '16.48', + rate: 16.48, synth: 'SNX', timestamp: 1616704370000, }, diff --git a/packages/data/__mocks__/snxHolder.ts b/packages/data/__mocks__/snxHolder.ts index 491b4f78e..d507fc79b 100644 --- a/packages/data/__mocks__/snxHolder.ts +++ b/packages/data/__mocks__/snxHolder.ts @@ -1,26 +1,26 @@ export const snxHolderMock = { response: { - balanceOf: '68069683028764', + balanceOf: '0.000068069683028764', block: '10108119', - claims: null, - collateral: '68069683028764', - debtEntryAtIndex: '1000000000000000000000000000', + claims: '5', + collateral: '0.000068069683028764', + debtEntryAtIndex: '22152845382348635959243347', id: '0x0000000000000000000000000000000000000001', initialDebtOwnership: '0', - mints: null, + mints: '6', timestamp: '1590049259', - transferable: '68069683028764', + transferable: '0.000068069683028764', }, formatted: { - balanceOf: '0.000068069683028764', + balanceOf: 0.000068069683028764, block: 10108119, - claims: null, - collateral: '0.000068069683028764', - debtEntryAtIndex: '1000000000.0', + claims: 5, + collateral: 0.000068069683028764, + debtEntryAtIndex: '22152845382348635959243347', id: '0x0000000000000000000000000000000000000001', - initialDebtOwnership: '0.0', - mints: null, + initialDebtOwnership: 0, + mints: 6, timestamp: 1590049259000, - transferable: '0.000068069683028764', + transferable: 0.000068069683028764, }, }; diff --git a/packages/data/__mocks__/snxPrice.ts b/packages/data/__mocks__/snxPrice.ts index fb4a429cf..a5a97b984 100644 --- a/packages/data/__mocks__/snxPrice.ts +++ b/packages/data/__mocks__/snxPrice.ts @@ -5,6 +5,6 @@ export const snxPriceMock = { }, formatted: { id: '18712', - averagePrice: '16.48', + averagePrice: 16.48, }, }; diff --git a/packages/data/__mocks__/synthExchanges.ts b/packages/data/__mocks__/synthExchanges.ts index 10fe83d6b..797ce9f52 100644 --- a/packages/data/__mocks__/synthExchanges.ts +++ b/packages/data/__mocks__/synthExchanges.ts @@ -1,58 +1,39 @@ -export const synthExchangesMockL1 = { +export const synthExchangesMock = { response: { account: '0x60d4f28f407121bca015d47cdc9b9b4546b5a9c7', block: '12116438', - feesInUSD: '747549034706154047462', + feesInUSD: '747.549034706154047462', from: '0x0eb59acd1f0b73970e5b2fd095bf373ce569e4a9', - fromAmount: '249183011568718006275302', - fromAmountInUSD: '249183011568718006275302', + fromAmount: '249183.011568718006275302', + fromAmountInUSD: '249183.011568718006275302', fromCurrencyKey: '0x7355534400000000000000000000000000000000000000000000000000000000', fromSynth: 'sUSD', gasPrice: '142100000000', id: '0x5771afba4755d73e1becf5b58640b48b999b01ac267c4d39334916ee90285088-232', timestamp: '1616785448', toAddress: '0x60d4f28f407121bca015d47cdc9b9b4546b5a9c7', - toAmount: '4628088422134899435', - toAmountInUSD: '248435462534011852227840', + toAmount: '4.628088422134899435', + toAmountInUSD: '248435.46253401185222784', toCurrencyKey: '0x7342544300000000000000000000000000000000000000000000000000000000', toSynth: 'sBTC', }, formatted: { account: '0x60d4f28f407121bca015d47cdc9b9b4546b5a9c7', block: 12116438, - feesInUSD: '747.549034706154047462', + feesInUSD: 747.549034706154047462, from: '0x0eb59acd1f0b73970e5b2fd095bf373ce569e4a9', - fromAmount: '249183.011568718006275302', - fromAmountInUSD: '249183.011568718006275302', + fromAmount: 249183.011568718006275302, + fromAmountInUSD: 249183.011568718006275302, fromCurrencyKey: 'sUSD', fromSynth: 'sUSD', - gasPrice: '142100000000', + gasPrice: 142100000000, id: '0x5771afba4755d73e1becf5b58640b48b999b01ac267c4d39334916ee90285088-232', timestamp: 1616785448000, toAddress: '0x60d4f28f407121bca015d47cdc9b9b4546b5a9c7', - toAmount: '4.628088422134899435', - toAmountInUSD: '248435.46253401185222784', + toAmount: 4.628088422134899435, + toAmountInUSD: 248435.46253401185222784, toCurrencyKey: 'sBTC', toSynth: 'sBTC', hash: '0x5771afba4755d73e1becf5b58640b48b999b01ac267c4d39334916ee90285088', }, }; - -export const synthExchangesMockL2 = { - response: { - ...synthExchangesMockL1.response, - fromAmount: '249183.011568718006275302', - toAmount: '4.628088422134899435', - fromAmountInUSD: '249183.011568718006275302', - toAmountInUSD: '248435.462534011852227840', - feesInUSD: '747.549034706154047462', - }, - formatted: { - ...synthExchangesMockL1.formatted, - fromAmount: '249183.011568718006275302', - toAmount: '4.628088422134899435', - fromAmountInUSD: '249183.01', - toAmountInUSD: '248435.46', - feesInUSD: '747.55', - }, -}; diff --git a/packages/data/__mocks__/synthHolders.ts b/packages/data/__mocks__/synthHolders.ts index 3da4dc0d0..9655b2def 100644 --- a/packages/data/__mocks__/synthHolders.ts +++ b/packages/data/__mocks__/synthHolders.ts @@ -1,6 +1,6 @@ export const synthHoldersMock = { response: { - balanceOf: '90038854631941946067435170', + balanceOf: '90038854.63194194', id: '0x6c5024cd4f8a59110119c56f8933403a539555eb-sUSD', synth: 'sUSD', }, diff --git a/packages/data/__tests__/queries.test.ts b/packages/data/__tests__/queries.test.ts index 6f15f3581..ab0eab89c 100644 --- a/packages/data/__tests__/queries.test.ts +++ b/packages/data/__tests__/queries.test.ts @@ -4,8 +4,7 @@ import { parseIssued, parseRates, parseSynthetix, - parseSynthExchangesL1, - parseSynthExchangesL2, + parseSynthExchanges, parseBurned, parseFeesClaimed, parseSnxPrice, @@ -29,8 +28,7 @@ import { ratesMock, feesClaimedMock, synthetixMock, - synthExchangesMockL1, - synthExchangesMockL2, + synthExchangesMock, debtSnapshotMock, snxHolderMock, shortsMock, @@ -98,12 +96,9 @@ describe('@synthetixio/data tests', () => { }); describe('exchanges query', () => { - test('should parse the response correctly for L1 and L2', () => { - const parsedOutputL1 = parseSynthExchangesL1(synthExchangesMockL1.response); - expect(synthExchangesMockL1.formatted).toEqual(parsedOutputL1); - - const parsedOutputL2 = parseSynthExchangesL2(synthExchangesMockL2.response); - expect(synthExchangesMockL2.formatted).toEqual(parsedOutputL2); + test('should parse the response correctly', () => { + const parsedOutput = parseSynthExchanges(synthExchangesMock.response); + expect(synthExchangesMock.formatted).toEqual(parsedOutput); }); test('should return exchanges from l1', async () => { @@ -375,8 +370,8 @@ describe('@synthetixio/data tests', () => { expect(exchangeEntrySettleds.length).toEqual(1); const exchangeEntrySettled = exchangeEntrySettleds[0]!; expect(exchangeEntrySettled.from).toEqual('0xe51b3d74b9e8203b5e817e691a5d0d7f00898fbd'); - expect(exchangeEntrySettled.reclaim).toEqual('150.57812586144'); - expect(exchangeEntrySettled.rebate).toEqual('0.0'); + expect(exchangeEntrySettled.reclaim).toEqual(150.57812586144); + expect(exchangeEntrySettled.rebate).toEqual(0); }); }); diff --git a/packages/data/queries/burned/parse.ts b/packages/data/queries/burned/parse.ts index 6182370ed..90dc24e51 100644 --- a/packages/data/queries/burned/parse.ts +++ b/packages/data/queries/burned/parse.ts @@ -1,5 +1,5 @@ import { Burned } from '../../generated/graphql'; -import { formatTimestamp, formatEther } from '../../src/utils'; +import { formatTimestamp } from '../../src/utils'; export const parseBurned = ({ account, @@ -12,9 +12,9 @@ export const parseBurned = ({ }: Burned): Burned => ({ account, block: Number(block), - gasPrice, + gasPrice: Number(gasPrice), id, source, timestamp: formatTimestamp(timestamp), - value: formatEther(value), + value: Number(value), }); diff --git a/packages/data/queries/dailyBurned/dailyBurned.ts b/packages/data/queries/dailyBurned/dailyBurned.ts index 27ce9f524..d96ff6f6d 100644 --- a/packages/data/queries/dailyBurned/dailyBurned.ts +++ b/packages/data/queries/dailyBurned/dailyBurned.ts @@ -12,7 +12,7 @@ export const createDailyBurnedQuery = (params?: DailyBurnedQueryParams): string ) { id value - totalDebt + totalDebt } } `; diff --git a/packages/data/queries/dailyBurned/parse.ts b/packages/data/queries/dailyBurned/parse.ts index 99f8f1686..29fde5fd3 100644 --- a/packages/data/queries/dailyBurned/parse.ts +++ b/packages/data/queries/dailyBurned/parse.ts @@ -1,8 +1,7 @@ import { DailyBurned } from '../../generated/graphql'; -import { formatEther } from '../../src/utils'; export const parseDailyBurned = ({ id, value, totalDebt }: DailyBurned): DailyBurned => ({ id, - value: formatEther(value), - totalDebt: formatEther(totalDebt), + value: Number(value), + totalDebt: Number(totalDebt), }); diff --git a/packages/data/queries/dailyIssued/parse.ts b/packages/data/queries/dailyIssued/parse.ts index dcb78f434..857ddc1cf 100644 --- a/packages/data/queries/dailyIssued/parse.ts +++ b/packages/data/queries/dailyIssued/parse.ts @@ -1,8 +1,7 @@ import { DailyIssued } from '../../generated/graphql'; -import { formatEther } from '../../src/utils'; export const parseDailyIssued = ({ id, value, totalDebt }: DailyIssued): DailyIssued => ({ id, - value: formatEther(value), - totalDebt: formatEther(totalDebt), + value: Number(value), + totalDebt: Number(totalDebt), }); diff --git a/packages/data/queries/debtSnapshot/parse.ts b/packages/data/queries/debtSnapshot/parse.ts index ba2923cf6..e47b71552 100644 --- a/packages/data/queries/debtSnapshot/parse.ts +++ b/packages/data/queries/debtSnapshot/parse.ts @@ -1,5 +1,5 @@ import { DebtSnapshot } from '../../generated/graphql'; -import { formatTimestamp, formatEther } from '../../src/utils'; +import { formatTimestamp } from '../../src/utils'; export const parseDebtSnapshot = ({ account, @@ -14,7 +14,7 @@ export const parseDebtSnapshot = ({ block: Number(block), id, timestamp: formatTimestamp(timestamp), - collateral: formatEther(collateral), - debtBalanceOf: formatEther(debtBalanceOf), - balanceOf: formatEther(balanceOf), + collateral: Number(collateral), + debtBalanceOf: Number(debtBalanceOf), + balanceOf: Number(balanceOf), }); diff --git a/packages/data/queries/exchangeEntrySettleds/parse.ts b/packages/data/queries/exchangeEntrySettleds/parse.ts index a5d6ff5d4..9405ed8b2 100644 --- a/packages/data/queries/exchangeEntrySettleds/parse.ts +++ b/packages/data/queries/exchangeEntrySettleds/parse.ts @@ -1,5 +1,5 @@ import { ExchangeEntrySettled } from '../../generated/graphql'; -import { formatEther } from '../../src/utils'; +import { formatTimestamp } from '../../src/utils'; export const parseExchangeEntrySettleds = ({ id, @@ -16,35 +16,11 @@ export const parseExchangeEntrySettleds = ({ id, from, src, - amount: formatEther(amount), + amount: Number(amount), dest, - reclaim: formatEther(reclaim), - rebate: formatEther(rebate), + reclaim: Number(reclaim), + rebate: Number(rebate), srcRoundIdAtPeriodEnd, destRoundIdAtPeriodEnd, - exchangeTimestamp: Number(exchangeTimestamp), -}); - -export const parseExchangeEntrySettledsKovan = ({ - id, - from, - src, - amount, - dest, - reclaim, - rebate, - srcRoundIdAtPeriodEnd, - destRoundIdAtPeriodEnd, - exchangeTimestamp, -}: ExchangeEntrySettled): ExchangeEntrySettled => ({ - id, - from, - src, - amount, - dest, - reclaim, - rebate, - srcRoundIdAtPeriodEnd, - destRoundIdAtPeriodEnd, - exchangeTimestamp: Number(exchangeTimestamp), + exchangeTimestamp: formatTimestamp(exchangeTimestamp), }); diff --git a/packages/data/queries/exchangeTotals/parse.ts b/packages/data/queries/exchangeTotals/parse.ts index 5bdf7fe6b..170f38586 100644 --- a/packages/data/queries/exchangeTotals/parse.ts +++ b/packages/data/queries/exchangeTotals/parse.ts @@ -1,6 +1,5 @@ import { DailyTotal } from '../../generated/graphql'; import { ExchangeTotals } from '../../src/types'; -import { formatEther } from '../../src/utils'; export const parseExchangeTotals = ({ id, @@ -12,6 +11,6 @@ export const parseExchangeTotals = ({ id: Number(id), trades: Number(trades), exchangers: Number(exchangers), - exchangeUSDTally: Number(formatEther(exchangeUSDTally)), - totalFeesGeneratedInUSD: Number(formatEther(totalFeesGeneratedInUSD)), + exchangeUSDTally: Number(exchangeUSDTally), + totalFeesGeneratedInUSD: Number(totalFeesGeneratedInUSD), }); diff --git a/packages/data/queries/exchangeTotals/query.ts b/packages/data/queries/exchangeTotals/query.ts index 8dfab5dfa..08a3fb159 100644 --- a/packages/data/queries/exchangeTotals/query.ts +++ b/packages/data/queries/exchangeTotals/query.ts @@ -2,7 +2,7 @@ import { gql } from 'graphql-request'; import { ExchangeTotalsParams } from '../../src/types'; import { createGQLBlockNumberString } from '../../src/utils'; -export const ENTITY_MAP: Record = { +const TIMESERIES_QUERIES: Record = { '1d': 'dailyTotals', '15m': 'fifteenMinuteTotals', all: 'totals', @@ -28,5 +28,5 @@ export const createExchangeTotalsQuery = (params: ExchangeTotalsParams): string }; export function getExchangeTotalsQueryResponseAttr(timeSeries: string): string { - return ENTITY_MAP[timeSeries]; + return TIMESERIES_QUERIES[timeSeries]; } diff --git a/packages/data/queries/feesClaimed/parse.ts b/packages/data/queries/feesClaimed/parse.ts index b39a4c885..893c88a38 100644 --- a/packages/data/queries/feesClaimed/parse.ts +++ b/packages/data/queries/feesClaimed/parse.ts @@ -1,5 +1,5 @@ import { FeesClaimed } from '../../generated/graphql'; -import { formatTimestamp, formatEther } from '../../src/utils'; +import { formatTimestamp } from '../../src/utils'; export const parseFeesClaimed = ({ account, @@ -13,6 +13,6 @@ export const parseFeesClaimed = ({ block: Number(block), id, timestamp: formatTimestamp(timestamp), - value: formatEther(value), - rewards: formatEther(rewards), + value: Number(value), + rewards: Number(rewards), }); diff --git a/packages/data/queries/index.ts b/packages/data/queries/index.ts index 94b7a167a..3296e68e4 100644 --- a/packages/data/queries/index.ts +++ b/packages/data/queries/index.ts @@ -1,9 +1,4 @@ -export { - createSynthExchangesQuery, - parseSynthExchangesL1, - parseSynthExchangesL1Kovan, - parseSynthExchangesL2, -} from './synthExchanges'; +export { createSynthExchangesQuery, parseSynthExchanges } from './synthExchanges'; export { createSynthetixQuery, parseSynthetix } from './synthetix'; export { createIssuedQuery, parseIssued } from './issued'; export { createBurnedQuery, parseBurned } from './burned'; @@ -11,13 +6,12 @@ export { createDailyIssuedQuery, parseDailyIssued } from './dailyIssued'; export { createDailyBurnedQuery, parseDailyBurned } from './dailyBurned'; export { createRateUpdatesQuery, parseRates } from './rateUpdates'; export { createFeesClaimedQuery, parseFeesClaimed } from './feesClaimed'; -export { parseSnxPrice, createSnxPriceQuery } from './snxPrice'; +export { parseSnxPrice, createSnxPriceQuery, getSNXPricesQueryResponseAttr } from './snxPrice'; export { parseDebtSnapshot, createDebtSnapshotQuery } from './debtSnapshot'; export { parseSnxHolder, createSnxHolderQuery } from './snxHolders'; export { parseShort, createShortsQuery } from './shorts'; export { parseExchangeEntrySettleds, - parseExchangeEntrySettledsKovan, createExchangeEntrySettledsQuery, } from './exchangeEntrySettleds'; export { diff --git a/packages/data/queries/issued/parse.ts b/packages/data/queries/issued/parse.ts index b01ae5c2b..434be6577 100644 --- a/packages/data/queries/issued/parse.ts +++ b/packages/data/queries/issued/parse.ts @@ -1,5 +1,5 @@ import { Issued } from '../../generated/graphql'; -import { formatTimestamp, formatEther } from '../../src/utils'; +import { formatTimestamp } from '../../src/utils'; export const parseIssued = ({ account, @@ -12,9 +12,9 @@ export const parseIssued = ({ }: Issued): Issued => ({ account, block: Number(block), - gasPrice, + gasPrice: Number(gasPrice), id, source, timestamp: formatTimestamp(timestamp), - value: formatEther(value), + value: Number(value), }); diff --git a/packages/data/queries/rateUpdates/parse.ts b/packages/data/queries/rateUpdates/parse.ts index c7fa3317d..2fcb75049 100644 --- a/packages/data/queries/rateUpdates/parse.ts +++ b/packages/data/queries/rateUpdates/parse.ts @@ -1,14 +1,14 @@ import { RateUpdate } from '../../generated/graphql'; -import { formatTimestamp, formatEther } from '../../src/utils'; +import { formatTimestamp } from '../../src/utils'; -export const parseRates = (rate: RateUpdate, networkId?: number): RateUpdate => { +export const parseRates = (rate: RateUpdate): RateUpdate => { const { block, currencyKey, id, rate: rateValue, synth, timestamp } = rate; return { block: Number(block), currencyKey, id, - rate: formatEther(rateValue), + rate: Number(rateValue), synth, timestamp: formatTimestamp(timestamp), }; diff --git a/packages/data/queries/snxHolders/parse.ts b/packages/data/queries/snxHolders/parse.ts index da081dbbe..5a1def394 100644 --- a/packages/data/queries/snxHolders/parse.ts +++ b/packages/data/queries/snxHolders/parse.ts @@ -1,5 +1,5 @@ import { SnxHolder } from '../../generated/graphql'; -import { formatTimestamp, formatEther } from '../../src/utils'; +import { formatTimestamp } from '../../src/utils'; export const parseSnxHolder = ({ id, @@ -15,12 +15,12 @@ export const parseSnxHolder = ({ }: SnxHolder): SnxHolder => ({ block: Number(block), id, - collateral: formatEther(collateral), - balanceOf: formatEther(balanceOf), - transferable: formatEther(transferable), - initialDebtOwnership: formatEther(initialDebtOwnership), - debtEntryAtIndex: formatEther(debtEntryAtIndex), - mints: mints != null ? formatEther(mints) : null, - claims: claims != null ? formatEther(claims) : null, + collateral: Number(collateral), + balanceOf: Number(balanceOf), + transferable: Number(transferable), + initialDebtOwnership: Number(initialDebtOwnership), + debtEntryAtIndex: debtEntryAtIndex ?? null, + mints: mints != null ? Number(mints) : null, + claims: claims != null ? Number(claims) : null, timestamp: formatTimestamp(timestamp), }); diff --git a/packages/data/queries/snxPrice/parse.ts b/packages/data/queries/snxPrice/parse.ts index d1c668241..fb3df7fa5 100644 --- a/packages/data/queries/snxPrice/parse.ts +++ b/packages/data/queries/snxPrice/parse.ts @@ -1,9 +1,8 @@ import { DailySnxPrice, FifteenMinuteSnxPrice } from '../../generated/graphql'; -import { formatEther } from '../../src/utils'; type SnxPriceSansCount = Omit | Omit; export const parseSnxPrice = ({ id, averagePrice }: SnxPriceSansCount): SnxPriceSansCount => ({ id, - averagePrice, + averagePrice: Number(averagePrice), }); diff --git a/packages/data/queries/snxPrice/snxPrice.ts b/packages/data/queries/snxPrice/snxPrice.ts index a4f496744..2362db9c7 100644 --- a/packages/data/queries/snxPrice/snxPrice.ts +++ b/packages/data/queries/snxPrice/snxPrice.ts @@ -1,9 +1,14 @@ import { gql } from 'graphql-request'; import { SnxPriceParams } from '../../src/types'; -import { timeSeriesEntityMap } from '../../src/constants'; import { createGQLWhereString, createGQLBlockNumberString } from '../../src/utils'; +const TIMESERIES_QUERIES: Record = { + '1d': 'dailySNXPrices', + '15m': 'fifteenMinuteSNXPrices', +}; + export const createSnxPriceQuery = (params: SnxPriceParams): string => { + const query = getSNXPricesQueryResponseAttr(params.timeSeries); // throw if undefined? const whereString = createGQLWhereString( Object.entries({ id_lt: @@ -13,8 +18,8 @@ export const createSnxPriceQuery = (params: SnxPriceParams): string => { }) ); return gql` - query snxPrices($autoGeneratedPaginationField: Int, $max: Int, $timeSeries: String) { - ${timeSeriesEntityMap[params.timeSeries]}( + query ${query}($autoGeneratedPaginationField: Int, $max: Int, $timeSeries: String) { + ${query}( first: $max${createGQLBlockNumberString(params?.blockNumber ?? null)} where: ${whereString} orderBy: id @@ -25,3 +30,7 @@ export const createSnxPriceQuery = (params: SnxPriceParams): string => { } }`; }; + +export function getSNXPricesQueryResponseAttr(timeSeries: string): string { + return TIMESERIES_QUERIES[timeSeries]; +} diff --git a/packages/data/queries/synthExchanges/parse.ts b/packages/data/queries/synthExchanges/parse.ts index 5cb845119..c13a419fa 100644 --- a/packages/data/queries/synthExchanges/parse.ts +++ b/packages/data/queries/synthExchanges/parse.ts @@ -1,8 +1,8 @@ import { SynthExchange } from '../../generated/graphql'; import { SynthExchangeExpanded } from '../../src/types'; -import { formatTimestamp, getHashFromId, hexToAscii, formatEther } from '../../src/utils'; +import { formatTimestamp, getHashFromId, hexToAscii } from '../../src/utils'; -export const parseSynthExchangesL1 = ({ +export const parseSynthExchanges = ({ account, block, feesInUSD, @@ -22,92 +22,18 @@ export const parseSynthExchangesL1 = ({ }: SynthExchange): SynthExchangeExpanded => ({ account, block: Number(block), - feesInUSD: formatEther(feesInUSD), + feesInUSD: Number(feesInUSD), from, - fromAmount: formatEther(fromAmount), - fromAmountInUSD: formatEther(fromAmountInUSD), + fromAmount: Number(fromAmount), + fromAmountInUSD: Number(fromAmountInUSD), fromCurrencyKey: hexToAscii(fromCurrencyKey), fromSynth, - gasPrice, - id, - timestamp: formatTimestamp(timestamp), - toAddress, - toAmount: formatEther(toAmount), - toAmountInUSD: formatEther(toAmountInUSD), - toCurrencyKey: hexToAscii(toCurrencyKey), - toSynth, - hash: getHashFromId(id), -}); - -export const parseSynthExchangesL1Kovan = ({ - account, - block, - feesInUSD, - from, - fromAmount, - fromAmountInUSD, - fromCurrencyKey, - fromSynth, - gasPrice, - id, - timestamp, - toAddress, - toAmount, - toAmountInUSD, - toCurrencyKey, - toSynth, -}: SynthExchange): SynthExchangeExpanded => ({ - account, - block: Number(block), - feesInUSD, - from, - fromAmount, - fromAmountInUSD, - fromCurrencyKey: hexToAscii(fromCurrencyKey), - fromSynth, - gasPrice, - id, - timestamp: formatTimestamp(timestamp), - toAddress, - toAmount, - toAmountInUSD, - toCurrencyKey: hexToAscii(toCurrencyKey), - toSynth, - hash: getHashFromId(id), -}); - -export const parseSynthExchangesL2 = ({ - account, - block, - feesInUSD, - from, - fromAmount, - fromAmountInUSD, - fromCurrencyKey, - fromSynth, - gasPrice, - id, - timestamp, - toAddress, - toAmount, - toAmountInUSD, - toCurrencyKey, - toSynth, -}: SynthExchange): SynthExchangeExpanded => ({ - account, - block: Number(block), - feesInUSD: parseFloat(feesInUSD).toFixed(2), - from, - fromAmount: fromAmount, - fromAmountInUSD: parseFloat(fromAmountInUSD).toFixed(2), - fromCurrencyKey: hexToAscii(fromCurrencyKey), - fromSynth, - gasPrice, + gasPrice: Number(gasPrice), id, timestamp: formatTimestamp(timestamp), toAddress, - toAmount: toAmount, - toAmountInUSD: parseFloat(toAmountInUSD).toFixed(2), + toAmount: Number(toAmount), + toAmountInUSD: Number(toAmountInUSD), toCurrencyKey: hexToAscii(toCurrencyKey), toSynth, hash: getHashFromId(id), diff --git a/packages/data/queries/synthHolders/parse.ts b/packages/data/queries/synthHolders/parse.ts index 8cd911a13..40e3e484a 100644 --- a/packages/data/queries/synthHolders/parse.ts +++ b/packages/data/queries/synthHolders/parse.ts @@ -1,6 +1,5 @@ import { SynthHolder as UnformattedSynthHolder } from '../../generated/graphql'; import { SynthHolder } from '../../src/types'; -import { formatEther } from '../../src/utils'; export const parseSynthHolders = ({ id, @@ -9,5 +8,5 @@ export const parseSynthHolders = ({ }: UnformattedSynthHolder): SynthHolder => ({ address: id.split('-')[0], synth, - balanceOf: Number(formatEther(balanceOf)), + balanceOf: Number(balanceOf), }); diff --git a/packages/data/src/constants.ts b/packages/data/src/constants.ts index 397267bbe..0bffd8eee 100644 --- a/packages/data/src/constants.ts +++ b/packages/data/src/constants.ts @@ -23,6 +23,4 @@ export const l2Endpoints = { shortsKovan: 'https://api.thegraph.com/subgraphs/name/killerbyte/optimism-kovan-shorts', }; -export const timeSeriesEntityMap = { '1d': 'dailySNXPrices', '15m': 'fifteenMinuteSNXPrices' }; - export const GQL_RESPONSE_LIMIT = 999; diff --git a/packages/data/src/index.ts b/packages/data/src/index.ts index 987029dcb..673df1e87 100644 --- a/packages/data/src/index.ts +++ b/packages/data/src/index.ts @@ -4,7 +4,7 @@ import { request } from 'graphql-request'; // eslint-disable-next-line import/no-unresolved import { NetworkId } from '@synthetixio/contracts-interface'; -import { l1Endpoints, l2Endpoints, timeSeriesEntityMap } from './constants'; +import { l1Endpoints, l2Endpoints } from './constants'; import * as queries from '../queries'; import { formatParams, requestHelper } from './utils'; import { @@ -120,15 +120,7 @@ const synthetixData = ({ networkId }: { networkId: NetworkId }) => ({ [NetworkId['Mainnet-Ovm']]: l2Endpoints.exchanges, }, }); - return response != null - ? response.synthExchanges.map( - networkId === NetworkId.Mainnet - ? queries.parseSynthExchangesL1 - : networkId === NetworkId.Kovan - ? queries.parseSynthExchangesL1Kovan - : queries.parseSynthExchangesL2 - ) - : null; + return response != null ? response.synthExchanges.map(queries.parseSynthExchanges) : null; }, synthetix: async (params?: BaseQueryParams): Promise => { const query = queries.createSynthetixQuery(params); @@ -193,7 +185,9 @@ const synthetixData = ({ networkId }: { networkId: NetworkId }) => ({ }, }); return response != null - ? response[timeSeriesEntityMap[params.timeSeries]].map(queries.parseSnxPrice) + ? response[queries.getSNXPricesQueryResponseAttr(params.timeSeries)].map( + queries.parseSnxPrice + ) : null; }, rateUpdates: async (params?: RateUpdateQueryParams): Promise => { @@ -253,14 +247,10 @@ const synthetixData = ({ networkId }: { networkId: NetworkId }) => ({ }, }); return response != null - ? response.exchangeEntrySettleds.map( - networkId === NetworkId.Kovan - ? queries.parseExchangeEntrySettledsKovan - : queries.parseExchangeEntrySettleds - ) + ? response.exchangeEntrySettleds.map(queries.parseExchangeEntrySettleds) : null; }, - exchangeTotals: async (params?: ExchangeTotalsParams): Promise => { + exchangeTotals: async (params: ExchangeTotalsParams): Promise => { const response = await getData({ params, queryMethod: queries.createExchangeTotalsQuery, @@ -274,7 +264,7 @@ const synthetixData = ({ networkId }: { networkId: NetworkId }) => ({ }, }); return response != null - ? response[queries.getExchangeTotalsQueryResponseAttr(params?.timeSeries ?? '')].map( + ? response[queries.getExchangeTotalsQueryResponseAttr(params.timeSeries)].map( queries.parseExchangeTotals ) : null; diff --git a/packages/queries/package-lock.json b/packages/queries/package-lock.json index 0c4cdf525..999413b6f 100644 --- a/packages/queries/package-lock.json +++ b/packages/queries/package-lock.json @@ -6,16 +6,16 @@ "packages": { "": { "name": "@synthetixio/queries", - "version": "2.49.0", + "version": "2.50.3", "license": "MIT", "dependencies": { "@snapshot-labs/snapshot.js": "^0.1.11", - "@synthetixio/contracts-interface": "2.49.0", - "@synthetixio/data": "2.49.0", - "@synthetixio/optimism-networks": "2.49.0", - "@synthetixio/providers": "2.49.0", - "@synthetixio/transaction-notifier": "2.49.0", - "@synthetixio/wei": "2.49.0", + "@synthetixio/contracts-interface": "^2.50.3", + "@synthetixio/data": "0.0.0-a1a9cd3", + "@synthetixio/optimism-networks": "2.50.0-ovm-alpha", + "@synthetixio/providers": "2.50.0-ovm-alpha", + "@synthetixio/transaction-notifier": "2.50.0-ovm-alpha", + "@synthetixio/wei": "2.50.0-ovm-alpha", "axios": "0.21.1", "bignumber.js": "9.0.1", "date-fns": "2.19.0", @@ -907,22 +907,22 @@ } }, "node_modules/@synthetixio/contracts-interface": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/contracts-interface/-/contracts-interface-2.49.0.tgz", - "integrity": "sha512-QPu235XTugDLNzLzrM7C2MTGPoWxH5+BB0VfdA4gYql1OixPQ8ZPFyOJKAbtrlLV/bgr/ZIjVgadz8sU74/YyQ==", + "version": "2.50.3", + "resolved": "https://registry.npmjs.org/@synthetixio/contracts-interface/-/contracts-interface-2.50.3.tgz", + "integrity": "sha512-vMzMLMrsy9LvpAnj4S+VoK+Wo0zc6W3Br3WYlS0dBa0WSDNWLYYc2gMhs3uk3VPYVxFtzqFvSYY9/h1GyCzZag==", "dependencies": { "ethers": "5.4.6", "lodash": "4.17.19", - "synthetix": "2.49.0", + "synthetix": "2.50.0-ovm-alpha", "web3-utils": "1.2.11" } }, "node_modules/@synthetixio/data": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/data/-/data-2.49.0.tgz", - "integrity": "sha512-X8u++PIN8Z5mgG4Z15B2HiNkCFBJdQO9CB8Ze3kYaL4K2sDrAE9VjdjVK5zuTuEIiNzR1g4tWuHkmzvS+gjo7w==", + "version": "0.0.0-a1a9cd3", + "resolved": "https://registry.npmjs.org/@synthetixio/data/-/data-0.0.0-a1a9cd3.tgz", + "integrity": "sha512-LIl+2deLJgE/qYfDw8gABsmjdI9C4mCR7aoaI0KK7TB7v6kIOW1BdBBuOUep2HEClF9NBAbJiTiinBLwACdMeA==", "dependencies": { - "@synthetixio/contracts-interface": "2.49.0", + "@synthetixio/contracts-interface": "0.0.0-a1a9cd3", "bignumber.js": "9.0.1", "date-fns": "2.19.0", "ethers": "5.4.6", @@ -931,37 +931,48 @@ "lodash": "4.17.19" } }, + "node_modules/@synthetixio/data/node_modules/@synthetixio/contracts-interface": { + "version": "0.0.0-a1a9cd3", + "resolved": "https://registry.npmjs.org/@synthetixio/contracts-interface/-/contracts-interface-0.0.0-a1a9cd3.tgz", + "integrity": "sha512-JaPR2tjSKUhOYmoDzdfTOm0wAysigOop/x0MHvDJ+IGOevrVG5BATdY7SpEoH/hMCki9YJf6qorWcgxquwjkzQ==", + "dependencies": { + "ethers": "5.4.6", + "lodash": "4.17.19", + "synthetix": "2.50.0-ovm-alpha", + "web3-utils": "1.2.11" + } + }, "node_modules/@synthetixio/optimism-networks": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/optimism-networks/-/optimism-networks-2.49.0.tgz", - "integrity": "sha512-EgJbJHQw+vcWDnpocTHVPUIPzlzKAaJlnZ8rnf25JeOUJxL4c0tbYVL/F4JteZtrnMY5IROaqNNFmh6YpwsyQw==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/@synthetixio/optimism-networks/-/optimism-networks-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-KMqZzxcSziAkxOjKzA9Q1ZXseWjgXYjrN7ZZo3EdfB3A/9P/fitAoWrHJo/vjzZwY7ROUoFpOu7DjZ5J/cZVZw==", "dependencies": { "@eth-optimism/watcher": "^0.0.1-alpha.9" } }, "node_modules/@synthetixio/providers": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/providers/-/providers-2.49.0.tgz", - "integrity": "sha512-fNPbnBVIWbwX30NjSpqAalnpiqS4jfcPahdzZxYwRH87mE4Ja9JNXA1dE8yv5LH0e1bfUAytAxEWf8IsxIjOkQ==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/@synthetixio/providers/-/providers-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-i+X2bxq59r5DfycmUMswzm+Tic0F+QTuv74p+QESpnGyY4p4RDHz0mGEyErAIn8mEQYABynsDd3Q46gzHms4pQ==", "dependencies": { "@eth-optimism/provider": "0.0.1-alpha.14", - "@synthetixio/optimism-networks": "2.49.0", + "@synthetixio/optimism-networks": "2.50.0-ovm-alpha", "ethers": "5.4.6" } }, "node_modules/@synthetixio/transaction-notifier": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/transaction-notifier/-/transaction-notifier-2.49.0.tgz", - "integrity": "sha512-OvIJcAXXSgU4BbmOJCAKEJ5kW9M0+5Agp0dlBre7KfJuf+J1j4enSgzuVa1Y54xQZZLcbcAd2KjXN1oYwyK/bw==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/@synthetixio/transaction-notifier/-/transaction-notifier-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-aOQUx72j94+NvhP6pq/ewkLCxNO6uAjPNs5YGC4g8N2G5FJJMfZdkeGNwfWpWrNi5LbCaN6WpaWvzTlSq0hTCQ==", "dependencies": { "ethers": "5.4.6", "lodash": "4.17.19" } }, "node_modules/@synthetixio/wei": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/wei/-/wei-2.49.0.tgz", - "integrity": "sha512-BzFSnH+HyH3gPETLxkHeBpa/ka45fLWEoEk8Ske1/htzZE1zVJiF3d6slL7jGKJ5/qUbPutwGmsy87lomfi0ow==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/@synthetixio/wei/-/wei-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-d4QUW0S0ESqa/cddn87kRF47mjB+y+h1oPCIY6QLG5bVTSU8ZuY0lSbSY00LAONcsU2myc1S7waltuIQ/lXnjA==", "dependencies": { "big.js": "6.1.1", "ethers": "5.4.6" @@ -4092,9 +4103,9 @@ } }, "node_modules/synthetix": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/synthetix/-/synthetix-2.49.0.tgz", - "integrity": "sha512-u2za3sgpbaStnxlR8x4lWbz8eN6c6K8SviXGSnX9QcBk7hlbeVXYHtNX0QzNXTzGLrjvpltAJCnER2h0YgT1sw==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/synthetix/-/synthetix-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-sr1ZVisiQT6R7j1nxACJ0z7Pygka4uLnZ3d7PlwQadffUICq6du+QLZtzvn88lzawCwQGaElKT2k+2CmANeFGg==", "dependencies": { "abi-decoder": "2.3.0", "commander": "8.1.0", @@ -5069,61 +5080,74 @@ } }, "@synthetixio/contracts-interface": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/contracts-interface/-/contracts-interface-2.49.0.tgz", - "integrity": "sha512-QPu235XTugDLNzLzrM7C2MTGPoWxH5+BB0VfdA4gYql1OixPQ8ZPFyOJKAbtrlLV/bgr/ZIjVgadz8sU74/YyQ==", + "version": "2.50.3", + "resolved": "https://registry.npmjs.org/@synthetixio/contracts-interface/-/contracts-interface-2.50.3.tgz", + "integrity": "sha512-vMzMLMrsy9LvpAnj4S+VoK+Wo0zc6W3Br3WYlS0dBa0WSDNWLYYc2gMhs3uk3VPYVxFtzqFvSYY9/h1GyCzZag==", "requires": { "ethers": "5.4.6", "lodash": "4.17.19", - "synthetix": "2.49.0", + "synthetix": "2.50.0-ovm-alpha", "web3-utils": "1.2.11" } }, "@synthetixio/data": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/data/-/data-2.49.0.tgz", - "integrity": "sha512-X8u++PIN8Z5mgG4Z15B2HiNkCFBJdQO9CB8Ze3kYaL4K2sDrAE9VjdjVK5zuTuEIiNzR1g4tWuHkmzvS+gjo7w==", + "version": "0.0.0-a1a9cd3", + "resolved": "https://registry.npmjs.org/@synthetixio/data/-/data-0.0.0-a1a9cd3.tgz", + "integrity": "sha512-LIl+2deLJgE/qYfDw8gABsmjdI9C4mCR7aoaI0KK7TB7v6kIOW1BdBBuOUep2HEClF9NBAbJiTiinBLwACdMeA==", "requires": { - "@synthetixio/contracts-interface": "2.49.0", + "@synthetixio/contracts-interface": "0.0.0-a1a9cd3", "bignumber.js": "9.0.1", "date-fns": "2.19.0", "ethers": "5.4.6", "graphql": "15.5.0", "graphql-request": "3.4.0", "lodash": "4.17.19" + }, + "dependencies": { + "@synthetixio/contracts-interface": { + "version": "0.0.0-a1a9cd3", + "resolved": "https://registry.npmjs.org/@synthetixio/contracts-interface/-/contracts-interface-0.0.0-a1a9cd3.tgz", + "integrity": "sha512-JaPR2tjSKUhOYmoDzdfTOm0wAysigOop/x0MHvDJ+IGOevrVG5BATdY7SpEoH/hMCki9YJf6qorWcgxquwjkzQ==", + "requires": { + "ethers": "5.4.6", + "lodash": "4.17.19", + "synthetix": "2.50.0-ovm-alpha", + "web3-utils": "1.2.11" + } + } } }, "@synthetixio/optimism-networks": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/optimism-networks/-/optimism-networks-2.49.0.tgz", - "integrity": "sha512-EgJbJHQw+vcWDnpocTHVPUIPzlzKAaJlnZ8rnf25JeOUJxL4c0tbYVL/F4JteZtrnMY5IROaqNNFmh6YpwsyQw==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/@synthetixio/optimism-networks/-/optimism-networks-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-KMqZzxcSziAkxOjKzA9Q1ZXseWjgXYjrN7ZZo3EdfB3A/9P/fitAoWrHJo/vjzZwY7ROUoFpOu7DjZ5J/cZVZw==", "requires": { "@eth-optimism/watcher": "^0.0.1-alpha.9" } }, "@synthetixio/providers": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/providers/-/providers-2.49.0.tgz", - "integrity": "sha512-fNPbnBVIWbwX30NjSpqAalnpiqS4jfcPahdzZxYwRH87mE4Ja9JNXA1dE8yv5LH0e1bfUAytAxEWf8IsxIjOkQ==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/@synthetixio/providers/-/providers-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-i+X2bxq59r5DfycmUMswzm+Tic0F+QTuv74p+QESpnGyY4p4RDHz0mGEyErAIn8mEQYABynsDd3Q46gzHms4pQ==", "requires": { "@eth-optimism/provider": "0.0.1-alpha.14", - "@synthetixio/optimism-networks": "2.49.0", + "@synthetixio/optimism-networks": "2.50.0-ovm-alpha", "ethers": "5.4.6" } }, "@synthetixio/transaction-notifier": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/transaction-notifier/-/transaction-notifier-2.49.0.tgz", - "integrity": "sha512-OvIJcAXXSgU4BbmOJCAKEJ5kW9M0+5Agp0dlBre7KfJuf+J1j4enSgzuVa1Y54xQZZLcbcAd2KjXN1oYwyK/bw==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/@synthetixio/transaction-notifier/-/transaction-notifier-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-aOQUx72j94+NvhP6pq/ewkLCxNO6uAjPNs5YGC4g8N2G5FJJMfZdkeGNwfWpWrNi5LbCaN6WpaWvzTlSq0hTCQ==", "requires": { "ethers": "5.4.6", "lodash": "4.17.19" } }, "@synthetixio/wei": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/@synthetixio/wei/-/wei-2.49.0.tgz", - "integrity": "sha512-BzFSnH+HyH3gPETLxkHeBpa/ka45fLWEoEk8Ske1/htzZE1zVJiF3d6slL7jGKJ5/qUbPutwGmsy87lomfi0ow==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/@synthetixio/wei/-/wei-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-d4QUW0S0ESqa/cddn87kRF47mjB+y+h1oPCIY6QLG5bVTSU8ZuY0lSbSY00LAONcsU2myc1S7waltuIQ/lXnjA==", "requires": { "big.js": "6.1.1", "ethers": "5.4.6" @@ -7563,9 +7587,9 @@ } }, "synthetix": { - "version": "2.49.0", - "resolved": "https://registry.npmjs.org/synthetix/-/synthetix-2.49.0.tgz", - "integrity": "sha512-u2za3sgpbaStnxlR8x4lWbz8eN6c6K8SviXGSnX9QcBk7hlbeVXYHtNX0QzNXTzGLrjvpltAJCnER2h0YgT1sw==", + "version": "2.50.0-ovm-alpha", + "resolved": "https://registry.npmjs.org/synthetix/-/synthetix-2.50.0-ovm-alpha.tgz", + "integrity": "sha512-sr1ZVisiQT6R7j1nxACJ0z7Pygka4uLnZ3d7PlwQadffUICq6du+QLZtzvn88lzawCwQGaElKT2k+2CmANeFGg==", "requires": { "abi-decoder": "2.3.0", "commander": "8.1.0", diff --git a/packages/queries/package.json b/packages/queries/package.json index 0dd249e7d..de14e6e4f 100644 --- a/packages/queries/package.json +++ b/packages/queries/package.json @@ -62,4 +62,4 @@ "react-dom": "17.x", "react-query": "3.16.x" } -} +} \ No newline at end of file diff --git a/packages/queries/src/queries/staking/useGlobalStakingInfoQuery.ts b/packages/queries/src/queries/staking/useGlobalStakingInfoQuery.ts index 366c79856..c1c399396 100644 --- a/packages/queries/src/queries/staking/useGlobalStakingInfoQuery.ts +++ b/packages/queries/src/queries/staking/useGlobalStakingInfoQuery.ts @@ -55,7 +55,7 @@ const useGlobalStakingInfoQuery = ( unformattedCollateral, unformattedDebtEntryAtIndex, unformattedInitialDebtOwnership, - ].map((val) => wei(val)); + ].map((val) => (!val ? wei(0) : wei(val))); const debtBalance = debtEntryAtIndex.gt(0) ? totalIssuedSynths