From 56bef2acb0b35dcce576d5d22d33258454391639 Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Thu, 17 Oct 2024 10:43:14 -0400 Subject: [PATCH] chore: remove stats and update default feature flags --- .husky/pre-commit | 1 + src/gql/heart-monitor/heart-monitor.test.ts | 80 ----------- src/gql/heart-monitor/heart-monitor.ts | 12 -- src/gql/query/index.ts | 1 - src/gql/query/stats.ts | 147 -------------------- src/gql/utils/defaultObjects.ts | 106 +------------- src/sdk/tx/index.ts | 1 + 7 files changed, 4 insertions(+), 344 deletions(-) delete mode 100644 src/gql/query/stats.ts diff --git a/.husky/pre-commit b/.husky/pre-commit index 5369480d..e0973e00 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,3 +2,4 @@ . "$(dirname "$0")/_/husky.sh" yarn lint-staged +yarn generate-barrels diff --git a/src/gql/heart-monitor/heart-monitor.test.ts b/src/gql/heart-monitor/heart-monitor.test.ts index 374210a9..b2c87c4e 100644 --- a/src/gql/heart-monitor/heart-monitor.test.ts +++ b/src/gql/heart-monitor/heart-monitor.test.ts @@ -7,8 +7,6 @@ import { QueryGovernanceArgs, QueryIbcArgs, QueryOracleArgs, - QueryStatsArgs, - GQLStatsFields, communityPoolQueryString, QueryWasmArgs, GqlWasmFields, @@ -24,19 +22,12 @@ import { defaultIbcTransfer, defaultOracleEntry, defaultOraclePrice, - defaultPerpOpenInterest, - defaultPerpPnl, defaultRedelegations, - defaultStatsFees, defaultToken, - defaultTotals, - defaultTvl, defaultUnbondings, defaultUser, defaultUserContract, - defaultUsers, defaultValidator, - defaultVolume, GQLDistributionCommission, GQLOraclePrice, GQLQueryGqlCommunityPoolArgs, @@ -414,28 +405,6 @@ test("queryBatchHandler", async () => { } }) -const testStats = async (args: QueryStatsArgs, fields: GQLStatsFields) => { - const resp = await heartMonitor.stats(args, fields) - expect(resp).toHaveProperty("stats") - - if (resp.GQLStats) { - const { GQLStats } = resp - - checkFields( - [GQLStats], - [ - "totals", - "fees", - "perpOpenInterest", - "tvl", - "perpPnl", - "users", - "volume", - ] - ) - } -} - const testStaking = async ( args: QueryStakingArgs, fields: GQLStakingFields @@ -501,55 +470,6 @@ test.skip("staking", async () => { ) }) -test("stats", async () => { - await testStats( - { - totals: { - limit: 1, - }, - fees: { - limit: 1, - }, - perpOpenInterest: { - limit: 1, - }, - tvl: { - limit: 1, - }, - perpPnl: { - limit: 1, - }, - users: { - limit: 1, - }, - volume: { - limit: 1, - }, - }, - { - totals: defaultTotals, - fees: defaultStatsFees, - perpOpenInterest: defaultPerpOpenInterest, - tvl: defaultTvl, - perpPnl: defaultPerpPnl, - users: defaultUsers, - volume: defaultVolume, - } - ) - await testStats( - {}, - { - totals: defaultTotals, - fees: defaultStatsFees, - perpOpenInterest: defaultPerpOpenInterest, - tvl: defaultTvl, - perpPnl: defaultPerpPnl, - users: defaultUsers, - volume: defaultVolume, - } - ) -}) - const testWasm = async (args: QueryWasmArgs, fields: GqlWasmFields) => { const resp = await heartMonitor.wasm(args, fields) expect(resp).toHaveProperty("wasm") diff --git a/src/gql/heart-monitor/heart-monitor.ts b/src/gql/heart-monitor/heart-monitor.ts index 1ff4f11e..eeacbb15 100644 --- a/src/gql/heart-monitor/heart-monitor.ts +++ b/src/gql/heart-monitor/heart-monitor.ts @@ -16,10 +16,6 @@ import { communityPool, distributionCommissions, users, - GqlOutStats, - QueryStatsArgs, - GQLStatsFields, - stats, GqlOutGovernance, QueryGovernanceArgs, governance, @@ -118,11 +114,6 @@ export interface IHeartMonitor { fields: DeepPartial ) => Promise - readonly stats: ( - args: QueryStatsArgs, - fields: DeepPartial - ) => Promise - readonly user: ( args: GQLQueryGqlUserArgs, fields: DeepPartial @@ -213,9 +204,6 @@ export class HeartMonitor implements IHeartMonitor { fields: DeepPartial ) => staking(args, this.gqlEndpt, fields) - stats = async (args: QueryStatsArgs, fields: DeepPartial) => - stats(args, this.gqlEndpt, fields) - user = async (args: GQLQueryGqlUserArgs, fields: DeepPartial) => user(args, this.gqlEndpt, fields) diff --git a/src/gql/query/index.ts b/src/gql/query/index.ts index d82f41ca..24fc9918 100644 --- a/src/gql/query/index.ts +++ b/src/gql/query/index.ts @@ -11,7 +11,6 @@ export * from "./inflation" export * from "./oracle" export * from "./proxies" export * from "./staking" -export * from "./stats" export * from "./user" export * from "./users" export * from "./wasm" diff --git a/src/gql/query/stats.ts b/src/gql/query/stats.ts deleted file mode 100644 index c388e8a9..00000000 --- a/src/gql/query/stats.ts +++ /dev/null @@ -1,147 +0,0 @@ -import { - convertObjectToPropertiesString, - doGqlQuery, - gqlQuery, - GQLQuery, - GQLStatsGqlFeesArgs, - GQLStatsFees, - GQLStatsPerpOpenInterest, - GQLStatsPerpPnl, - GQLStatsTotals, - GQLStatsTvl, - GQLStatsUsers, - GQLStatsVolume, - GQLStatsGqlPerpOpenInterestArgs, - GQLStatsGqlPerpPnlArgs, - GQLStatsGqlTotalsArgs, - GQLStatsGqlTvlArgs, - GQLStatsGqlUsersArgs, - GQLStatsGqlVolumeArgs, - DeepPartial, -} from ".." - -export type QueryStatsArgs = { - fees?: GQLStatsGqlFeesArgs - perpOpenInterest?: GQLStatsGqlPerpOpenInterestArgs - perpPnl?: GQLStatsGqlPerpPnlArgs - totals?: GQLStatsGqlTotalsArgs - tvl?: GQLStatsGqlTvlArgs - users?: GQLStatsGqlUsersArgs - volume?: GQLStatsGqlVolumeArgs -} - -export interface GqlOutStats { - GQLStats?: GQLQuery["stats"] -} - -export type GQLStatsFields = DeepPartial<{ - fees?: DeepPartial - perpOpenInterest?: DeepPartial - perpPnl?: DeepPartial - totals?: DeepPartial - tvl?: DeepPartial - users?: DeepPartial - volume?: DeepPartial -}> - -export const GQLStatsQueryString = ( - args: QueryStatsArgs, - fields: GQLStatsFields -) => { - const GQLStatsQuery: string[] = [] - - if (fields.fees) { - GQLStatsQuery.push( - gqlQuery( - "fees", - args.fees ?? {}, - convertObjectToPropertiesString(fields.fees), - true - ) - ) - } - - if (fields.perpOpenInterest) { - GQLStatsQuery.push( - gqlQuery( - "perpOpenInterest", - args.perpOpenInterest ?? {}, - convertObjectToPropertiesString(fields.perpOpenInterest), - true - ) - ) - } - - if (fields.perpPnl) { - GQLStatsQuery.push( - gqlQuery( - "perpPnl", - args.perpPnl ?? {}, - convertObjectToPropertiesString(fields.perpPnl), - true - ) - ) - } - - if (fields.totals) { - GQLStatsQuery.push( - gqlQuery( - "totals", - args.totals ?? {}, - convertObjectToPropertiesString(fields.totals), - true - ) - ) - } - - if (fields.tvl) { - GQLStatsQuery.push( - gqlQuery( - "tvl", - args.tvl ?? {}, - convertObjectToPropertiesString(fields.tvl), - true - ) - ) - } - - if (fields.users) { - GQLStatsQuery.push( - gqlQuery( - "users", - args.users ?? {}, - convertObjectToPropertiesString(fields.users), - true - ) - ) - } - - if (fields.volume) { - GQLStatsQuery.push( - gqlQuery( - "volume", - args.volume ?? {}, - convertObjectToPropertiesString(fields.volume), - true - ) - ) - } - - return ` - stats { - ${GQLStatsQuery.join("\n")} - } - ` -} - -export const stats = async ( - args: QueryStatsArgs, - endpt: string, - fields: GQLStatsFields -): Promise => - doGqlQuery( - `{ - ${GQLStatsQueryString(args, fields)} - }`, - endpt - ) diff --git a/src/gql/utils/defaultObjects.ts b/src/gql/utils/defaultObjects.ts index 72cf978e..09ec535d 100644 --- a/src/gql/utils/defaultObjects.ts +++ b/src/gql/utils/defaultObjects.ts @@ -28,13 +28,6 @@ import { GQLSpotPoolSwap, GQLStakingActionType, GQLStakingHistoryItem, - GQLStatsFees, - GQLStatsPerpOpenInterest, - GQLStatsPerpPnl, - GQLStatsTotals, - GQLStatsTvl, - GQLStatsUsers, - GQLStatsVolume, GQLToken, GQLUnbonding, GQLUser, @@ -268,101 +261,6 @@ export const defaultSpotPoolSwap: GQLSpotPoolSwap = { user: defaultUser, } -export const defaultStatsFees: GQLStatsFees = { - feesLiquidations: 0, - feesLiquidationsCumulative: 0, - feesPerp: 0, - feesPerpCumulative: 0, - feesSwap: 0, - feesSwapCumulative: 0, - feesTotal: 0, - feesTotalCumulative: 0, - period: 0, - periodInterval: "", - periodStartTs: "", -} - -export const defaultPerpOpenInterest: GQLStatsPerpOpenInterest = { - openInterestLong: 0, - openInterestShort: 0, - openInterestTotal: 0, - period: 0, - periodInterval: "", - periodStartTs: "", -} - -export const defaultPerpPnl: GQLStatsPerpPnl = { - loss: 0, - lossCumulative: 0, - netPnl: 0, - netPnlCumulative: 0, - period: 0, - periodInterval: "", - periodStartTs: "", - profit: 0, - profitCumulative: 0, -} - -export const defaultTotals: GQLStatsTotals = { - period: 0, - periodInterval: "", - periodStartTs: "", - totalPerp: 0, - totalFeesPerp: 0, - totalFeesLiquidations: 0, - totalOpenInterest: 0, - totalTransactions: 0, - totalSwap: 0, - totalTvl: 0, -} - -export const defaultTvl: GQLStatsTvl = { - period: 0, - periodInterval: "", - periodStartTs: "", - tvlPerp: 0, - tvlStablecoin: 0, - tvlStaking: 0, - tvlSwap: 0, - tvlTotal: 0, -} - -export const defaultUsers: GQLStatsUsers = { - newUsersLp: 0, - newUsersLpCumulative: 0, - newUsersPerp: 0, - newUsersPerpCumulative: 0, - newUsersSwap: 0, - newUsersSwapCumulative: 0, - newUsersTotal: 0, - newUsersTotalCumulative: 0, - period: 0, - periodInterval: "", - periodStartTs: "", - userActionsPerp: 0, - uniqueUsersLp: 0, - uniqueUsersPerp: 0, - uniqueUsersSwap: 0, - uniqueUsersTotal: 0, - userActionsLp: 0, - userActionsSwap: 0, - userActionsTotal: 0, - newAuthUsers: 0, - newAuthUsersCumulative: 0, -} - -export const defaultVolume: GQLStatsVolume = { - volumePerp: 0, - volumePerpCumulative: 0, - volumeSwap: 0, - volumeSwapCumulative: 0, - volumeTotal: 0, - volumeTotalCumulative: 0, - period: 0, - periodInterval: "", - periodStartTs: "", -} - export const defaultUnbondings: GQLUnbonding = { amount: 0, completion_time: "", @@ -444,8 +342,8 @@ export const defaultInflationInfo: GQLInflationInfo = { export const defaultFeatureFlags: GQLFeatureFlags = { gov: true, oracle: true, - perp: true, - spot: true, + perp: false, + spot: false, staking: true, wasm: true, } diff --git a/src/sdk/tx/index.ts b/src/sdk/tx/index.ts index 3650d68b..23e3833e 100644 --- a/src/sdk/tx/index.ts +++ b/src/sdk/tx/index.ts @@ -2,6 +2,7 @@ * @file Automatically generated by barrelsby. */ +export * from "./account" export * from "./event" export * from "./signer" export * from "./txClient"