From 03dd396f25e5fd4622ee38fb0e400cb987b5ab69 Mon Sep 17 00:00:00 2001 From: elshenak Date: Tue, 19 Sep 2023 14:57:42 -0400 Subject: [PATCH 1/3] refactor: including avg_pct_pnl_rank into leaderboard schema --- packages/indexer-nibi/src/gql/generated.ts | 21 ++++++++++++++++++++ packages/indexer-nibi/src/gql/schema.graphql | 13 ++++++++++++ packages/nibijs/docs/classes/StableSwap.md | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/packages/indexer-nibi/src/gql/generated.ts b/packages/indexer-nibi/src/gql/generated.ts index 9394373f..748ccf09 100644 --- a/packages/indexer-nibi/src/gql/generated.ts +++ b/packages/indexer-nibi/src/gql/generated.ts @@ -249,6 +249,7 @@ export type PeriodFilter = { export type PerpLeaderboard = { readonly __typename?: "PerpLeaderboard" readonly avg_pct_pnl: Scalars["Float"]["output"] + readonly avg_pct_pnl_rank: Scalars["Int"]["output"] readonly input_margin: Scalars["Float"]["output"] readonly raw_pnl: Scalars["Float"]["output"] readonly raw_pnl_with_unrealized: Scalars["Float"]["output"] @@ -261,6 +262,7 @@ export type PerpLeaderboardFilter = { export enum PerpLeaderboardOrder { AvgPctPnl = "avg_pct_pnl", + AvgPctPnlRank = "avg_pct_pnl_rank", RawPnl = "raw_pnl", RawPnlWithUnrealized = "raw_pnl_with_unrealized", TraderAddress = "trader_address", @@ -868,9 +870,20 @@ export type StringFilter = { readonly like?: InputMaybe } +export type SubPerpMarketFilter = { + readonly pair: Scalars["String"]["input"] +} + +export type SubPerpPositionFilter = { + readonly pair?: InputMaybe + readonly trader_address: Scalars["String"]["input"] +} + export type Subscription = { readonly __typename?: "Subscription" readonly markPriceCandles: ReadonlyArray + readonly perpMarket: PerpMarket + readonly perpPositions: ReadonlyArray } export type SubscriptionMarkPriceCandlesArgs = { @@ -878,6 +891,14 @@ export type SubscriptionMarkPriceCandlesArgs = { where?: InputMaybe } +export type SubscriptionPerpMarketArgs = { + where: SubPerpMarketFilter +} + +export type SubscriptionPerpPositionsArgs = { + where: SubPerpPositionFilter +} + export type TimeFilter = { readonly eq?: InputMaybe readonly gt?: InputMaybe diff --git a/packages/indexer-nibi/src/gql/schema.graphql b/packages/indexer-nibi/src/gql/schema.graphql index 281c8a52..e3fd2be6 100644 --- a/packages/indexer-nibi/src/gql/schema.graphql +++ b/packages/indexer-nibi/src/gql/schema.graphql @@ -209,6 +209,7 @@ input PeriodFilter { type PerpLeaderboard { avg_pct_pnl: Float! + avg_pct_pnl_rank: Int! input_margin: Float! raw_pnl: Float! raw_pnl_with_unrealized: Float! @@ -221,6 +222,7 @@ input PerpLeaderboardFilter { enum PerpLeaderboardOrder { avg_pct_pnl + avg_pct_pnl_rank raw_pnl raw_pnl_with_unrealized trader_address @@ -752,11 +754,22 @@ input StringFilter { like: String } +input SubPerpMarketFilter { + pair: String! +} + +input SubPerpPositionFilter { + pair: String + trader_address: String! +} + type Subscription { markPriceCandles( limit: Int where: MarkPriceCandlesFilter ): [MarkPriceCandle!]! + perpMarket(where: SubPerpMarketFilter!): PerpMarket! + perpPositions(where: SubPerpPositionFilter!): [PerpPosition!]! } scalar Time diff --git a/packages/nibijs/docs/classes/StableSwap.md b/packages/nibijs/docs/classes/StableSwap.md index 968cb851..24b48fa0 100644 --- a/packages/nibijs/docs/classes/StableSwap.md +++ b/packages/nibijs/docs/classes/StableSwap.md @@ -178,7 +178,7 @@ y() Calculate x[j] if one makes x[i] = x Done by solving quadratic equation iteratively. -x*1**2 + x1 * (sum' - (A*n**n - 1) * D / (A _ n**n)) = D ** (n+1)/(n \*\* (2 _ n) \_ prod' \* A) +x*1\*\*2 + x1 * (sum' - (A*n\*\*n - 1) * D / (A _ n**n)) = D ** (n+1)/(n \*\* (2 _ n) \_ prod' \* A) x_1\*\*2 + b\*x_1 = c x_1 = (x_1\**2 + c) / (2*x_1 + b) From e4d3956d8b51c38a94a1d803d5f5d242abdc974b Mon Sep 17 00:00:00 2001 From: elshenak Date: Tue, 19 Sep 2023 15:02:42 -0400 Subject: [PATCH 2/3] refactor: merge conflicts --- packages/nibijs/docs/classes/StableSwap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nibijs/docs/classes/StableSwap.md b/packages/nibijs/docs/classes/StableSwap.md index 24b48fa0..968cb851 100644 --- a/packages/nibijs/docs/classes/StableSwap.md +++ b/packages/nibijs/docs/classes/StableSwap.md @@ -178,7 +178,7 @@ y() Calculate x[j] if one makes x[i] = x Done by solving quadratic equation iteratively. -x*1\*\*2 + x1 * (sum' - (A*n\*\*n - 1) * D / (A _ n**n)) = D ** (n+1)/(n \*\* (2 _ n) \_ prod' \* A) +x*1**2 + x1 * (sum' - (A*n**n - 1) * D / (A _ n**n)) = D ** (n+1)/(n \*\* (2 _ n) \_ prod' \* A) x_1\*\*2 + b\*x_1 = c x_1 = (x_1\**2 + c) / (2*x_1 + b) From 73281ea853dda30088a67cd57329a3025b2a4025 Mon Sep 17 00:00:00 2001 From: elshenak Date: Tue, 19 Sep 2023 15:09:00 -0400 Subject: [PATCH 3/3] fix: default perp leaderboard object --- packages/indexer-nibi/src/query/perpLeaderboard.ts | 1 + packages/nibijs/docs/classes/StableSwap.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/indexer-nibi/src/query/perpLeaderboard.ts b/packages/indexer-nibi/src/query/perpLeaderboard.ts index 16f4a6d7..08271f7d 100644 --- a/packages/indexer-nibi/src/query/perpLeaderboard.ts +++ b/packages/indexer-nibi/src/query/perpLeaderboard.ts @@ -6,6 +6,7 @@ import { } from "../gql/generated" export const defaultPerpLeaderboardObject: PerpLeaderboard = { + avg_pct_pnl_rank: 0, avg_pct_pnl: 0, input_margin: 0, raw_pnl: 0, diff --git a/packages/nibijs/docs/classes/StableSwap.md b/packages/nibijs/docs/classes/StableSwap.md index b7560b83..eae7b455 100644 --- a/packages/nibijs/docs/classes/StableSwap.md +++ b/packages/nibijs/docs/classes/StableSwap.md @@ -178,8 +178,8 @@ y() Calculate x[j] if one makes x[i] = x Done by solving quadratic equation iteratively. -x_1**2 + x1 * (sum' - (A*n**n - 1) _ D / (A _ n**n)) = D ** (n+1)/(n ** (2 _ n) _ prod' \* A) -x_1**2 + b\*x_1 = c +x*1**2 + x1 * (sum' - (A*n**n - 1) * D / (A _ n**n)) = D ** (n+1)/(n \*\* (2 _ n) \_ prod' \* A) +x_1\*\*2 + b\*x_1 = c x_1 = (x_1\**2 + c) / (2*x_1 + b)