Skip to content

Commit

Permalink
refactor: including avg_pct_pnl_rank into leaderboard schema (#228)
Browse files Browse the repository at this point in the history
* refactor: including avg_pct_pnl_rank into leaderboard schema

* refactor: merge conflicts

* fix: default perp leaderboard object
  • Loading branch information
CalicoNino authored Sep 20, 2023
1 parent a4ddef5 commit 317eea5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
21 changes: 21 additions & 0 deletions packages/indexer-nibi/src/gql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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",
Expand Down Expand Up @@ -868,16 +870,35 @@ export type StringFilter = {
readonly like?: InputMaybe<Scalars["String"]["input"]>
}

export type SubPerpMarketFilter = {
readonly pair: Scalars["String"]["input"]
}

export type SubPerpPositionFilter = {
readonly pair?: InputMaybe<Scalars["String"]["input"]>
readonly trader_address: Scalars["String"]["input"]
}

export type Subscription = {
readonly __typename?: "Subscription"
readonly markPriceCandles: ReadonlyArray<MarkPriceCandle>
readonly perpMarket: PerpMarket
readonly perpPositions: ReadonlyArray<PerpPosition>
}

export type SubscriptionMarkPriceCandlesArgs = {
limit?: InputMaybe<Scalars["Int"]["input"]>
where?: InputMaybe<MarkPriceCandlesFilter>
}

export type SubscriptionPerpMarketArgs = {
where: SubPerpMarketFilter
}

export type SubscriptionPerpPositionsArgs = {
where: SubPerpPositionFilter
}

export type TimeFilter = {
readonly eq?: InputMaybe<Scalars["Time"]["input"]>
readonly gt?: InputMaybe<Scalars["Time"]["input"]>
Expand Down
13 changes: 13 additions & 0 deletions packages/indexer-nibi/src/gql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -221,6 +222,7 @@ input PerpLeaderboardFilter {

enum PerpLeaderboardOrder {
avg_pct_pnl
avg_pct_pnl_rank
raw_pnl
raw_pnl_with_unrealized
trader_address
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/indexer-nibi/src/query/perpLeaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/nibijs/docs/classes/StableSwap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 317eea5

Please sign in to comment.