Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fix): multi-schema #237

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 26 additions & 22 deletions packages/indexer-nibi/src/query/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,46 @@ export const oracleQueryString = (
) => {
const oracleQuery: string[] = []

if (fields) {
if (fields?.oraclePrices) {
oracleQuery.push(
gqlQuery(
"oraclePrices",
args?.oraclePrices ?? {},
convertObjectToPropertiesString(fields.oraclePrices),
true
)
if (fields?.oraclePrices) {
oracleQuery.push(
gqlQuery(
"oraclePrices",
args.oraclePrices ?? {},
convertObjectToPropertiesString(fields.oraclePrices),
true
)
}
)
}

if (fields?.oracles) {
oracleQuery.push(
gqlQuery(
"oracles",
args?.oracles ?? {},
convertObjectToPropertiesString(fields.oracles),
true
)
if (fields?.oracles) {
oracleQuery.push(
gqlQuery(
"oracles",
args.oracles ?? {},
convertObjectToPropertiesString(fields.oracles),
true
)
}
} else {
)
}

// Default Objects

if (args.oraclePrices && !fields?.oraclePrices) {
oracleQuery.push(
gqlQuery(
"oraclePrices",
args?.oraclePrices ?? {},
args.oraclePrices ?? {},
convertObjectToPropertiesString(defaultOraclePrice),
true
)
)
}

if (args.oracles && !fields?.oracles) {
oracleQuery.push(
gqlQuery(
"oracles",
args?.oracles ?? {},
args.oracles ?? {},
convertObjectToPropertiesString(defaultOracleEntry),
true
)
Expand Down
28 changes: 21 additions & 7 deletions packages/indexer-nibi/src/query/perp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,56 +110,70 @@ export const perpQueryString = (args: QueryPerpArgs, fields?: PerpFields) => {
)
)
}
} else {
}

// Default Objects

if (args.leaderboard && !fields?.leaderboard) {
perpQuery.push(
gqlQuery(
"leaderboard",
args?.leaderboard ?? {},
args.leaderboard ?? {},
convertObjectToPropertiesString(defaultPerpLeaderboard),
true
)
)
}

if (args.market && !fields?.market) {
perpQuery.push(
gqlQuery(
"market",
args?.market ?? {},
args.market ?? {},
convertObjectToPropertiesString(defaultPerpMarket),
true
)
)
}

if (args.markets && !fields?.markets) {
perpQuery.push(
gqlQuery(
"markets",
args?.markets ?? {},
args.markets ?? {},
convertObjectToPropertiesString(defaultPerpMarket),
true
)
)
}

if (args.position && !fields?.position) {
perpQuery.push(
gqlQuery(
"position",
args?.position ?? {},
args.position ?? {},
convertObjectToPropertiesString(defaultPerpPosition),
true
)
)
}

if (args.positionChanges && !fields?.positionChanges) {
perpQuery.push(
gqlQuery(
"positionChanges",
args?.positionChanges ?? {},
args.positionChanges ?? {},
convertObjectToPropertiesString(defaultPerpPositionChanges),
true
)
)
}

if (args.position && !fields?.positionChanges) {
perpQuery.push(
gqlQuery(
"positions",
args?.positions ?? {},
args.positions ?? {},
convertObjectToPropertiesString(defaultPerpPosition),
true
)
Expand Down
168 changes: 91 additions & 77 deletions packages/indexer-nibi/src/query/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,138 +56,152 @@ export const statsQueryString = (
) => {
const statsQuery: string[] = []

if (fields) {
if (fields?.fees) {
statsQuery.push(
gqlQuery(
"fees",
args?.fees ?? {},
convertObjectToPropertiesString(fields.fees),
true
)
if (fields?.fees) {
statsQuery.push(
gqlQuery(
"fees",
args?.fees ?? {},
convertObjectToPropertiesString(fields.fees),
true
)
}

if (fields?.perpOpenInterest) {
statsQuery.push(
gqlQuery(
"perpOpenInterest",
args?.perpOpenInterest ?? {},
convertObjectToPropertiesString(fields.perpOpenInterest),
true
)
)
}

if (fields?.perpOpenInterest) {
statsQuery.push(
gqlQuery(
"perpOpenInterest",
args?.perpOpenInterest ?? {},
convertObjectToPropertiesString(fields.perpOpenInterest),
true
)
}

if (fields?.perpPnl) {
statsQuery.push(
gqlQuery(
"perpPnl",
args?.perpPnl ?? {},
convertObjectToPropertiesString(fields.perpPnl),
true
)
)
}

if (fields?.perpPnl) {
statsQuery.push(
gqlQuery(
"perpPnl",
args?.perpPnl ?? {},
convertObjectToPropertiesString(fields.perpPnl),
true
)
}

if (fields?.totals) {
statsQuery.push(
gqlQuery(
"totals",
args?.totals ?? {},
convertObjectToPropertiesString(fields.totals),
true
)
)
}

if (fields?.totals) {
statsQuery.push(
gqlQuery(
"totals",
args?.totals ?? {},
convertObjectToPropertiesString(fields.totals),
true
)
}

if (fields?.tvl) {
statsQuery.push(
gqlQuery(
"tvl",
args?.tvl ?? {},
convertObjectToPropertiesString(fields.tvl),
true
)
)
}

if (fields?.tvl) {
statsQuery.push(
gqlQuery(
"tvl",
args?.tvl ?? {},
convertObjectToPropertiesString(fields.tvl),
true
)
}

if (fields?.users) {
statsQuery.push(
gqlQuery(
"users",
args?.users ?? {},
convertObjectToPropertiesString(fields.users),
true
)
)
}

if (fields?.users) {
statsQuery.push(
gqlQuery(
"users",
args?.users ?? {},
convertObjectToPropertiesString(fields.users),
true
)
}

if (fields?.volume) {
statsQuery.push(
gqlQuery(
"volume",
args?.volume ?? {},
convertObjectToPropertiesString(fields.volume),
true
)
)
}

if (fields?.volume) {
statsQuery.push(
gqlQuery(
"volume",
args?.volume ?? {},
convertObjectToPropertiesString(fields.volume),
true
)
}
} else {
)
}

// Default Objects

if (args.fees && !fields?.fees) {
statsQuery.push(
gqlQuery(
"fees",
args?.fees ?? {},
args.fees ?? {},
convertObjectToPropertiesString(defaultStatsFees),
true
)
)
}

if (args.perpOpenInterest && !fields?.perpOpenInterest) {
statsQuery.push(
gqlQuery(
"perpOpenInterest",
args?.perpOpenInterest ?? {},
args.perpOpenInterest ?? {},
convertObjectToPropertiesString(defaultPerpOpenInterest),
true
)
)
}

if (args.perpPnl && !fields?.perpPnl) {
statsQuery.push(
gqlQuery(
"perpPnl",
args?.perpPnl ?? {},
args.perpPnl ?? {},
convertObjectToPropertiesString(defaultPerpPnl),
true
)
)
}

if (args.totals && !fields?.totals) {
statsQuery.push(
gqlQuery(
"totals",
args?.totals ?? {},
args.totals ?? {},
convertObjectToPropertiesString(defaultTotals),
true
)
)
}

if (args.tvl && !fields?.tvl) {
statsQuery.push(
gqlQuery(
"tvl",
args?.tvl ?? {},
args.tvl ?? {},
convertObjectToPropertiesString(defaultTvl),
true
)
)
}

if (args.users && !fields?.users) {
statsQuery.push(
gqlQuery(
"users",
args?.users ?? {},
args.users ?? {},
convertObjectToPropertiesString(defaultUsers),
true
)
)
}

if (args.volume && !fields?.volume) {
statsQuery.push(
gqlQuery(
"volume",
Expand Down
2 changes: 1 addition & 1 deletion packages/nibijs/docs/classes/StableSwap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down