Skip to content

Commit

Permalink
Extending schema with more data
Browse files Browse the repository at this point in the history
Now tracking own shares trading by subjects and making all time
stats.

	renamed:    db/migrations/1693492520799-Data.js -> db/migrations/1693771301483-Data.js
	modified:   schema.graphql
	new file:   src/model/generated/allTimeStats.model.ts
	modified:   src/model/generated/index.ts
	modified:   src/model/generated/subject.model.ts
  • Loading branch information
abernatskiy committed Sep 3, 2023
1 parent 254c459 commit 32f38e3
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ type Subject @entity {
totalShareBuyVolume: BigInt!
totalShareSellVolume: BigInt!
subjectEthTotal: BigInt!
ownShareVolume: BigInt!
ownShareBought: BigInt!
ownShareSold: BigInt!
ethPaidForOwnShare: BigInt!
ethReceivedForOwnShare: BigInt!
ownShareTradingProfit: BigInt!
ultimateSubjectProfit: BigInt!
}

type BlockStats @entity {
Expand All @@ -41,3 +48,17 @@ type BlockStats @entity {
subjectEthTotal: BigInt!
protocolEthTotal: BigInt! # should be equal to the subject fees total
}

type AllTimeStats @entity {
id: ID!
trades: Int!
numSubjects: Int!
ethVolume: BigInt!
ethBuyVolume: BigInt!
ethSellVolume: BigInt!
shareVolume: BigInt!
shareBuyVolume: BigInt!
shareSellVolume: BigInt!
subjectEthTotal: BigInt!
protocolEthTotal: BigInt! # should be equal to the subject fees total
}
42 changes: 42 additions & 0 deletions src/model/generated/allTimeStats.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_} from "typeorm"
import * as marshal from "./marshal"

@Entity_()
export class AllTimeStats {
constructor(props?: Partial<AllTimeStats>) {
Object.assign(this, props)
}

@PrimaryColumn_()
id!: string

@Column_("int4", {nullable: false})
trades!: number

@Column_("int4", {nullable: false})
numSubjects!: number

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ethVolume!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ethBuyVolume!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ethSellVolume!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
shareVolume!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
shareBuyVolume!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
shareSellVolume!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
subjectEthTotal!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
protocolEthTotal!: bigint
}
1 change: 1 addition & 0 deletions src/model/generated/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./trade.model"
export * from "./subject.model"
export * from "./blockStats.model"
export * from "./allTimeStats.model"
21 changes: 21 additions & 0 deletions src/model/generated/subject.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,25 @@ export class Subject {

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
subjectEthTotal!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ownShareVolume!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ownShareBought!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ownShareSold!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ethPaidForOwnShare!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ethReceivedForOwnShare!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ownShareTradingProfit!: bigint

@Column_("numeric", {transformer: marshal.bigintTransformer, nullable: false})
ultimateSubjectProfit!: bigint
}

0 comments on commit 32f38e3

Please sign in to comment.