Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Graphql schemas #4

Open
shenger9 opened this issue Mar 3, 2022 · 0 comments
Open

Graphql schemas #4

shenger9 opened this issue Mar 3, 2022 · 0 comments

Comments

@shenger9
Copy link
Contributor

shenger9 commented Mar 3, 2022

type Block @entity {
  id: ID! # block number

  hash: String
  number: BigInt
  timestamp: Date
}

type Extrinsic @entity {
  id: ID! # extrinsic hash

  hash: String
  block: Block

  address: Account
  method: String
  section: String
}

type Account @entity {
  id: ID! # user address
  
  address: String
  txCount: BigInt

  userProvision: [UserProvision] @derivedFrom(field: "owner")

  # history
  addProvision: [AddProvision] @derivedFrom(field: "address")
  addLiquidity: [AddLiquidity] @derivedFrom(field: "address")
  removeLiquidity: [RemoveLiquidity] @derivedFrom(field: "address")
  swap: [Swap] @derivedFrom(field: "address")
}

type Token @entity {
  id: ID!

  name: String
  decimals: Int

  amount: BigInt # total amount in every pool
  tvl: BigInt # total TVL in every pool
  tradeVolume: BigInt # total trade volume
  tradeVolumeUSD: BigInt # total trade volume in USD
  txCount: BigInt
  poolCount: number # pool count relate to the token

  dailyDate: [TokenDailyDate] @derivedFrom(field: "token")
  provisionPoolBase: [ProvisionPool] @derivedFrom(field: "token0")
  provisionPoolQuote: [ProvisionPool] @derivedFrom(field: "token1")
  poolBase: [Pool] @derivedFrom(field: "token0")
  poolQuote: [Pool] @derivedFrom(field: "token1")
}

type TokenDailyDate @entity {
  id: ID!

  token: Token!

  amount: BigInt! # total amount in every pool
  tvl: BigInt! # total TVL in every pool

  dailyTradeVolume: BigInt! # total trade volume
  dailyTradeVolumeUSD: BigInt! # total trade volume in USD
  dailyTxCount: BigInt!

  timestamp: Date
}

type ProvisionPool @entity {
  id: ID!  #token0-token1

  pool: Token
  token0: Token
  token1: Token

  token0Amount: BigInt
  token1Amount: BigInt

  initializeShare: BigInt

  startAt: Date
  startAtBlock: Block
  endAt: Date
  endAtBlock: Block

  txCount: BigInt

  hourlyDate: [ProvisionPoolHourlyDate] @derivedFrom(field: "pool")
  userProvisions: [UserProvision] @derivedFrom(field: "pool")

  # history
  addProvision: [AddProvision] @derivedFrom(field: "pool")
  provisionToEnabled: [ProvisionToEnabled] @derivedFrom(field: "pool")
  listProvision: [ListProvision] @derivedFrom(field: "pool")
}

type ProvisionPoolHourlyDate @entity {
  id: ID! # token0-token1

  pool: Token

  token0Amount: BigInt
  token1Amount: BigInt
  price0: BigInt # exchange rate of token0/token1
  price1: BigInt # exchange rate of token1/token0
  hourlyToken0InAmount: BigInt
  hourlyToken1InAmount: BigInt

  timestamp: Date
}

type UserProvision @entity {
  id: ID! #token0-token1-user

  owner: Account

  pool: ProvisionPool

  token0Amount: BigInt
  token1Amount: BigInt
}

type Pool @entity {
  id: ID! # token0-token1

  token0: Token
  token1: Token

  # amount * price
  token0Amount: BigInt
  token1Amount: BigInt
  token0Price: BigInt # the exchange rate token0:token1
  token1Price: BigInt # the exchange rate token1:token0

  # total trade fee accumulate
  feeVolume: BigInt
  feeToken0Amount: BigInt
  feeToken1Amount: BigInt

  token0TradeVolume: BigInt
  token1TradeVolume: BigInt
  tradeVolumeUSD: BigInt

  token0TVL: BigInt
  token1TVL: BigInt
  totalTVL: BigInt

  txCount: BigInt

  hourlyData: [HourlyPool] @derivedFrom(field: "pool")
  dayData: [DailyPool] @derivedFrom(field: "pool")
}

type HourlyPool @entity {
  id: ID! # token0-token1-timestamp

  pool: Pool
  timestamp: Date

  token0: Token
  token1: Token

  # amount & price
  token0Amount: BigInt
  token1Amount: BigInt
  token0Price: BigInt
  token1Price: BigInt
 
  # total trade fee accumulate
  feeVolumeUSD: BigInt
  feeToken0Amount: BigInt
  feeToken1Amount: BigInt

  # hourly trade volume
  hourlyToken0TradeVolume: BigInt
  hourlyToken1TradeVolume: BigInt
  hourlyTradeVolumeUSD: BigInt
 
  # trade volume
  token0TradeVolume: BigInt
  token1TradeVolume: BigInt
  tradeVolumeUSD: BigInt

  # TVL
  token0TVL: BigInt
  token1TVL: BigInt
  totalTVL: BigInt

  txCount: BigInt

 # for track price change
  token0Open: BigInt
  token0High: BigInt
  token0Low: BigInt
  token0Close: BigInt

  token1Open: BigInt
  token1High: BigInt
  token1Low: BigInt
  token1Close: BigInt
}

type DailyPool @entity {
  id: ID! # token0-token1-timestamp

  pool: Pool
  timestamp: Date

  token0: Token
  token1: Token

  # amount & price
  token0Amount: BigInt
  token1Amount: BigInt
  token0Price: BigInt
  token1Price: BigInt
 
  # total trade fee accumulate
  feeVolumeUSD: BigInt
  feeToken0Amount: BigInt
  feeToken1Amount: BigInt

  # daily trade volume
  dailyToken0TradeVolume: BigInt
  dailyToken1TradeVolume: BigInt
  dailyTradeVolumeUSD: BigInt

  # trade volume
  token0TradeVolume: BigInt
  token1TradeVolume: BigInt
  tradeVolumeUSD: BigInt
 
  # TVL
  token0TVL: BigInt
  token1TVL: BigInt
  totalTVL: BigInt

  txCount: BigInt

  # for track price change
  token0Open: BigInt
  token0High: BigInt
  token0Low: BigInt
  token0Close: BigInt

  token1Open: BigInt
  token1High: BigInt
  token1Low: BigInt
  token1Close: BigInt
}

type Dex @entity {
  id: ID!

  poolCount: Int

  tradeVolumeUSD: BigInt # total trade volume
  totalTVL: BigInt

  hourlyDex: [HourDex]
  dailyDex: [DailyDex]
}

type HourDex @entity {
  id: ID!

  poolCount: Int

  hourlyTradeVolumeUSD: BigInt

  tradeVolumeUSD: BigInt # total trade volume
  totalTVL: BigInt # total tvl

  timestamp: Date
}

type DailyDex @entity {
  id: ID!

  poolCount: Int

  dailyTradeVolumeUSD: BigInt

  tradeVolumeUSD: BigInt # total trade volume
  totalTVL: BigInt # total tvl

  timestamp: Date
}

type PriceBundle @entity {
  id: ID!
  block: Block

  Token: Token
  price: BigInt
}

# history entities
type ProvisionToEnabled @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  token0Amount: BigInt
  token1Amount: BigInt
  totalShareAmount: BigInt

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type ListProvision @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type AddProvision @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  token0Amount: BigInt
  token1Amount: BigInt
  price0: BigInt
  price1: BigInt

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type AddLiquidity @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  token0Amount: BigInt
  token1Amount: BigInt
  price0: BigInt
  price1: BigInt

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type RemoveLiquidity @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  token0Amount: BigInt
  token1Amount: BigInt
  shareAmount: BigInt
  price0: BigInt
  price1: BigInt

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type Swap @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  ```javascript
type Block @entity {
  id: ID! # block number

  hash: String
  number: BigInt
  timestamp: Date
}

type Extrinsic @entity {
  id: ID! # extrinsic hash

  hash: String
  block: Block

  address: Account
  method: String
  section: String
}

type Account @entity {
  id: ID! # user address
  
  address: String
  txCount: BigInt

  userProvision: [UserProvision] @derivedFrom(field: "owner")

  # history
  addProvision: [AddProvision] @derivedFrom(field: "address")
  addLiquidity: [AddLiquidity] @derivedFrom(field: "address")
  removeLiquidity: [RemoveLiquidity] @derivedFrom(field: "address")
  swap: [Swap] @derivedFrom(field: "address")
}

type Token @entity {
  id: ID!

  name: String
  decimals: Int

  amount: BigInt # total amount in every pool
  tvl: BigInt # total TVL in every pool
  tradeVolume: BigInt # total trade volume
  tradeVolumeUSD: BigInt # total trade volume in USD
  txCount: BigInt
  poolCount: number # pool count relate to the token

  dailyDate: [TokenDailyDate] @derivedFrom(field: "token")
  provisionPoolBase: [ProvisionPool] @derivedFrom(field: "token0")
  provisionPoolQuote: [ProvisionPool] @derivedFrom(field: "token1")
  poolBase: [Pool] @derivedFrom(field: "token0")
  poolQuote: [Pool] @derivedFrom(field: "token1")
}

type TokenDailyDate @entity {
  id: ID!

  token: Token!

  amount: BigInt! # total amount in every pool
  tvl: BigInt! # total TVL in every pool

  dailyTradeVolume: BigInt! # total trade volume
  dailyTradeVolumeUSD: BigInt! # total trade volume in USD
  dailyTxCount: BigInt!

  timestamp: Date
}

type ProvisionPool @entity {
  id: ID!  #token0-token1

  pool: Token
  token0: Token
  token1: Token

  token0Amount: BigInt
  token1Amount: BigInt

  initializeShare: BigInt

  startAt: Date
  startAtBlock: Block
  endAt: Date
  endAtBlock: Block

  txCount: BigInt

  hourlyDate: [ProvisionPoolHourlyDate] @derivedFrom(field: "pool")
  userProvisions: [UserProvision] @derivedFrom(field: "pool")

  # history
  addProvision: [AddProvision] @derivedFrom(field: "pool")
  provisionToEnabled: [ProvisionToEnabled] @derivedFrom(field: "pool")
  listProvision: [ListProvision] @derivedFrom(field: "pool")
}

type ProvisionPoolHourlyDate @entity {
  id: ID! # token0-token1

  pool: Token

  token0Amount: BigInt
  token1Amount: BigInt
  price0: BigInt # exchange rate of token0/token1
  price1: BigInt # exchange rate of token1/token0
  hourlyToken0InAmount: BigInt
  hourlyToken1InAmount: BigInt

  timestamp: Date
}

type UserProvision @entity {
  id: ID! #token0-token1-user

  owner: Account

  pool: ProvisionPool

  token0Amount: BigInt
  token1Amount: BigInt
}

type Pool @entity {
  id: ID! # token0-token1

  token0: Token
  token1: Token

  # amount * price
  token0Amount: BigInt
  token1Amount: BigInt
  token0Price: BigInt # the exchange rate token0:token1
  token1Price: BigInt # the exchange rate token1:token0

  # total trade fee accumulate
  feeVolume: BigInt
  feeToken0Amount: BigInt
  feeToken1Amount: BigInt

  token0TradeVolume: BigInt
  token1TradeVolume: BigInt
  tradeVolumeUSD: BigInt

  token0TVL: BigInt
  token1TVL: BigInt
  totalTVL: BigInt

  txCount: BigInt

  hourlyData: [HourlyPool] @derivedFrom(field: "pool")
  dayData: [DailyPool] @derivedFrom(field: "pool")
}

type HourlyPool @entity {
  id: ID! # token0-token1-timestamp

  pool: Pool
  timestamp: Date

  token0: Token
  token1: Token

  # amount & price
  token0Amount: BigInt
  token1Amount: BigInt
  token0Price: BigInt
  token1Price: BigInt
 
  # total trade fee accumulate
  feeVolumeUSD: BigInt
  feeToken0Amount: BigInt
  feeToken1Amount: BigInt

  # hourly trade volume
  hourlyToken0TradeVolume: BigInt
  hourlyToken1TradeVolume: BigInt
  hourlyTradeVolumeUSD: BigInt
 
  # trade volume
  token0TradeVolume: BigInt
  token1TradeVolume: BigInt
  tradeVolumeUSD: BigInt

  # TVL
  token0TVL: BigInt
  token1TVL: BigInt
  totalTVL: BigInt

  txCount: BigInt

 # for track price change
  token0Open: BigInt
  token0High: BigInt
  token0Low: BigInt
  token0Close: BigInt

  token1Open: BigInt
  token1High: BigInt
  token1Low: BigInt
  token1Close: BigInt
}

type DailyPool @entity {
  id: ID! # token0-token1-timestamp

  pool: Pool
  timestamp: Date

  token0: Token
  token1: Token

  # amount & price
  token0Amount: BigInt
  token1Amount: BigInt
  token0Price: BigInt
  token1Price: BigInt
 
  # total trade fee accumulate
  feeVolumeUSD: BigInt
  feeToken0Amount: BigInt
  feeToken1Amount: BigInt

  # daily trade volume
  dailyToken0TradeVolume: BigInt
  dailyToken1TradeVolume: BigInt
  dailyTradeVolumeUSD: BigInt

  # trade volume
  token0TradeVolume: BigInt
  token1TradeVolume: BigInt
  tradeVolumeUSD: BigInt
 
  # TVL
  token0TVL: BigInt
  token1TVL: BigInt
  totalTVL: BigInt

  txCount: BigInt

  # for track price change
  token0Open: BigInt
  token0High: BigInt
  token0Low: BigInt
  token0Close: BigInt

  token1Open: BigInt
  token1High: BigInt
  token1Low: BigInt
  token1Close: BigInt
}

type Dex @entity {
  id: ID!

  poolCount: Int

  tradeVolumeUSD: BigInt # total trade volume
  totalTVL: BigInt

  hourlyDex: [HourDex]
  dailyDex: [DailyDex]
}

type HourDex @entity {
  id: ID!

  poolCount: Int

  hourlyTradeVolumeUSD: BigInt

  tradeVolumeUSD: BigInt # total trade volume
  totalTVL: BigInt # total tvl

  timestamp: Date
}

type DailyDex @entity {
  id: ID!

  poolCount: Int

  dailyTradeVolumeUSD: BigInt

  tradeVolumeUSD: BigInt # total trade volume
  totalTVL: BigInt # total tvl

  timestamp: Date
}

type PriceBoundle @entity {
  id: ID!
  block: Block

  Token: Token
  price: BigInt
}

# history entities
type ProvisionToEnabled @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  token0Amount: BigInt
  token1Amount: BigInt
  totalShareAmount: BigInt

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type ListProvision @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type AddProvision @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  token0Amount: BigInt
  token1Amount: BigInt
  price0: BigInt
  price1: BigInt

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type AddLiquidity @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  token0Amount: BigInt
  token1Amount: BigInt
  price0: BigInt
  price1: BigInt

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type RemoveLiquidity @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  token0Amount: BigInt
  token1Amount: BigInt
  shareAmount: BigInt
  price0: BigInt
  price1: BigInt

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}

type Swap @entity {
  id: ID!

  address: Account
  pool: Token

  token0: Token
  token1: Token
  token0InAmount: BigInt
  token1OutAmount: BigInt
  tradePath: [Token]
  price0: BigInt
  price1: BigInt

  block: Block
  extrinsic: Extrinsic
  timestamp: Date
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant