Skip to content

Commit

Permalink
Merge pull request #29 from cowprotocol/tokenDerived
Browse files Browse the repository at this point in the history
Added token derived totals to make easier queries
  • Loading branch information
GabrielCamba authored Jun 8, 2022
2 parents abc4d1d + 7973595 commit 5b4a309
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
22 changes: 21 additions & 1 deletion model.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ class Token {
priceUsd: BigDecimal
allowedPools: [BigInt!]!
history: [TokenTradingEvent!]! @derivedFrom(field: "token")
hourlyTotals: [TokenHourlyTotal!]! @derivedFrom(field: "token")
dailyTotals: [TokenDailyTotal!]! @derivedFrom(field: "token")
numberOfTrades: Int!
totalVolumeUsd: BigDecimal
totalVolumeEth: BigDecimal
}
Token --o TokenTradingEvent : History
Token --o TokenDailyTotal : dailyTotals
Token --o TokenHourlyTotal : hourlyTotals
class Order {
id: ID!
Expand All @@ -46,7 +50,8 @@ class Order {
invalidateTimestamp: BigInt
presignTimestamp: BigInt
trades: [Trade!] @derivedFrom(field: "order")
isSigned: Boolean!
isSigned: Boolean
isValid: Boolean
}
Order --o Trade : trades
Expand Down Expand Up @@ -90,6 +95,7 @@ class Total {
tokens: BigInt!
orders: BigInt!
traders: BigInt!
numberOfTrades: BigInt!
settlements: BigInt!
volumeUsd: BigDecimal
volumeEth: BigDecimal
Expand All @@ -101,6 +107,7 @@ class DailyTotal {
id: ID!
timestamp: BigInt!
totalTokens: BigInt!
numberOfTrades: BigInt!
orders: BigInt!
settlements: BigInt!
volumeUsd: BigDecimal
Expand All @@ -116,6 +123,7 @@ class HourlyTotal {
id: ID!
timestamp: BigInt!
totalTokens: BigInt!
numberOfTrades: BigInt!
orders: BigInt!
settlements: BigInt!
volumeUsd: BigDecimal
Expand Down Expand Up @@ -172,6 +180,10 @@ class Pair {
id: ID!
token0: Token!
token1: Token!
token0Price: BigDecimal
token1Price: BigDecimal
token0relativePrice: BigDecimal
token1relativePrice: BigDecimal
volumeToken0: BigInt
volumeToken1: BigInt
volumeTradedEth: BigDecimal
Expand All @@ -185,6 +197,10 @@ class PairDaily {
id: ID!
token0: Token!
token1: Token!
token0Price: BigDecimal
token1Price: BigDecimal
token0relativePrice: BigDecimal
token1relativePrice: BigDecimal
timestamp: BigInt
volumeToken0: BigInt
volumeToken1: BigInt
Expand All @@ -199,6 +215,10 @@ class PairHourly {
id: ID!
token0: Token!
token1: Token!
token0Price: BigDecimal
token1Price: BigDecimal
token0relativePrice: BigDecimal
token1relativePrice: BigDecimal
timestamp: BigInt
volumeToken0: BigInt
volumeToken1: BigInt
Expand Down
4 changes: 4 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ type Token @entity {
priceUsd: BigDecimal
"History of trading for this token"
history: [TokenTradingEvent!]! @derivedFrom(field: "token")
"Hourly totals"
hourlyTotals: [TokenHourlyTotal!]! @derivedFrom(field: "token")
"Daily totals"
dailyTotals: [TokenDailyTotal!]! @derivedFrom(field: "token")
"Total trades"
numberOfTrades: Int!
"Total volume in Usd"
Expand Down

0 comments on commit 5b4a309

Please sign in to comment.