ocean-subgraph/schema.graphql

397 lines
14 KiB
GraphQL
Raw Normal View History

2021-09-02 11:08:47 +02:00
type Token @entity {
2021-11-15 13:04:26 +01:00
id: ID!
symbol: String
name: String
decimals: Int!
address: String!
cap: BigDecimal
supply: BigDecimal
isDatatoken: Boolean!
"address of ERC721 that owns the token, valid only for datatokens"
owner: String
"array of addresses with minter role, can be user wallet address, dispenser etc."
minter: [User!]
"TODO: maybe we change name , depends on audit results . It's the address that collects the payments (NOT fees)"
feeManager: String
"address of the market where the datatoken was created. This address collects market fees."
publishMarketFeeAddress: String
"adreess of fee token (can be Ocean, ETH, etc.)"
publishMarketFeeToken: String
"fee amount. Fixed value, expressed in wei in contracts, needs conversion in decimals."
publishMarketFeeAmmount: BigDecimal
"template ID of the datatoken"
templateId: Int
"number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts"
holderCount: BigInt
"number of orders executed for this datatoken"
orderCount: BigInt
"block time datatoken was created"
createdTimestamp: Int
"datatoken creation transaction id"
tx: Bytes
"block number when it was created"
block: Int
}
2021-11-15 13:04:26 +01:00
"utility type"
2021-11-04 16:00:43 +01:00
type TokenValuePair @entity {
id : ID!
token : Token!
value : BigDecimal!
}
2021-11-04 16:00:43 +01:00
type Nft @entity{
2021-11-15 13:04:26 +01:00
"nft address"
id: ID!
symbol: String!
name: String!
tokenUri: String!
"address of the owner of the nft"
owner: String!
"same as id, it's just for easy discoverability"
address: String!
"provider url that can decrypt the ddo"
providerUrl: String
"state of the asset (described in docs)"
assetState: Int!
2021-11-04 16:00:43 +01:00
managerRole: [String!]
erc20DeployerRole: [String!]
storeUpdateRole: [String!]
2021-11-15 13:04:26 +01:00
"addresses that can update the metadata"
metadataRole: [String!]
"template address"
template: String!
2021-11-15 13:04:26 +01:00
"block time nft was created"
createdTimestamp: Int!
"nft creation transaction id"
tx: Bytes
"block number when it was created"
block: Int
}
type Pool @entity {
2021-11-15 13:04:26 +01:00
"pool address"
id: ID!
"owner address, pool controller"
2021-11-19 15:42:17 +01:00
owner: String!
2021-11-15 13:04:26 +01:00
"only finalized pools are relevant to us"
isFinalized: Boolean!
2021-09-02 11:08:47 +02:00
2021-11-15 13:04:26 +01:00
"pool token symbol"
symbol: String
"pool token name"
name: String
"maximum supply if any, converted from wei"
2021-11-19 15:42:17 +01:00
cap: BigDecimal
2021-11-15 13:04:26 +01:00
baseToken: PoolToken!
datatoken: PoolToken!
"pool Fee percent, fee goes to all liquidity providers : SWAP, JOIN , EXIT"
poolFee: BigDecimal!
"OPF Fee percent, fee that goes to Ocean Protocol Foundation : SWAP"
opfFee: BigDecimal!
"market fee percent, fee that goes to the market where the pool was created : SWAP"
marketFee: BigDecimal!
"actual value of fee collected in both tokens"
totalPoolFee: [TokenValuePair!]!
"actual value of fee collected in both tokens"
totalOpfFee: [TokenValuePair!]!
"actual value of fee collected in both tokens"
totalMarketFee: [TokenValuePair!]!
"fee after collection = totalFee - colectedFee"
currentOpfFee: [TokenValuePair!]!
"fee after collection totalFee - colectedFee"
currentMarketFee: [TokenValuePair!]!
"it's always 100 TODO: should be removed, seems redundant"
totalWeight: BigDecimal!
"total pool token shares"
totalShares: BigDecimal!
"total tokens that were swaped"
totalSwapVolume: [TokenValuePair!]!
spotPrice: BigDecimal!
"count for when liquidity has been added"
joinCount: BigInt!
"count for when liquidity has been removed"
exitCount: BigInt!
swapCount: BigInt!
2021-11-15 13:04:26 +01:00
"number of transactions in this pool involving liquidity changes"
transactionCount: BigInt!
2021-09-02 11:08:47 +02:00
2021-11-15 13:04:26 +01:00
"block time when pool was created"
createdTimestamp: Int!
"pool creation transaction id"
tx: Bytes
"block number when it was created"
block: Int
2021-11-19 15:42:17 +01:00
shares: [PoolShares!] @derivedFrom(field: "pool")
2021-09-10 12:49:37 +02:00
transactions: [PoolTransaction!] @derivedFrom(field: "pool")
}
# should not pe @entity
type PoolToken @entity {
2021-11-15 13:04:26 +01:00
"pool address + token address"
id: ID!
pool: Pool!
2021-09-08 13:34:33 +02:00
token: Token!
2021-11-15 13:04:26 +01:00
"balance of the token in this pool"
balance: BigDecimal!
"weight of token in the pool (50% for ocean bpools)"
denormWeight: BigDecimal!
}
# we will need to track pool share tx between users - bpool transfer tx event
2021-11-19 15:42:17 +01:00
type PoolShares @entity {
2021-11-15 13:04:26 +01:00
"poolAddress + userAddress"
id: ID!
2021-09-08 13:34:33 +02:00
user: User!
pool: Pool!
2021-11-19 15:42:17 +01:00
shares: BigDecimal!
}
2021-11-15 13:04:26 +01:00
enum PoolTransactionType {
JOIN,
EXIT,
SWAP,
SETUP
}
2021-11-12 14:22:35 +01:00
2021-09-10 12:49:37 +02:00
type PoolTransaction @entity {
2021-11-15 13:04:26 +01:00
"tx address + caller address"
id: ID!
"pool related to this tx"
pool: Pool!
"user that initiates the tx"
user: User!
type: PoolTransactionType
2021-11-15 13:04:26 +01:00
"number of shares transfered"
sharesTransferAmount: BigDecimal
2021-11-15 13:04:26 +01:00
"pool fee percent, fee goes to all liquidity providers : SWAP, JOIN , EXIT"
poolFee: BigDecimal!
"OPF Fee percent, fee that goes to Ocean Protocol Foundation : SWAP"
opfFee: BigDecimal!
marketFee: BigDecimal!
2021-11-12 14:22:35 +01:00
event: String # TODO: what is this?
tx: Bytes!
block: Int!
2021-11-12 14:22:35 +01:00
timestamp: Int!
2021-11-15 13:04:26 +01:00
gasLimit: BigDecimal!
"price expressed in eth"
gasPrice: BigDecimal!
2021-11-19 15:42:17 +01:00
"base tokens transfered"
baseToken: TokenValuePair
"number of tokens transfered"
baseTokenValue: BigDecimal
2021-11-15 13:04:26 +01:00
"datatokens transfered , if value is negative it means it was removed"
2021-11-12 14:22:35 +01:00
datatoken: TokenValuePair
2021-11-19 15:42:17 +01:00
"number of tokens transfered, if value is negative it means it was removed"
datatokenValue: BigDecimal
}
type Order @entity { # renamed from TokenOrder to Order
id: ID! # datatokenId + userAddress + tx
token: Token!
consumer: User!
payer: User!
amount: BigDecimal!
serviceId: Int!
# the fees will be updated from an event that will be created after (todo)
publishingMarketAddress: User
publishingMarketToken: Token #
publishingMarketAmmount: BigDecimal #call contract to get fee ammount
consumerMarketAddress: User
consumerMarketToken: Token #
consumerMarketAmmount: BigDecimal #call contract to get fee ammount
2021-11-10 13:47:44 +01:00
createdTimestamp: Int!
tx: Bytes
block: Int!
2020-11-26 12:10:45 +01:00
}
# to be removed, mabye for pool shares only
2020-11-26 07:38:08 +01:00
type TokenTransaction @entity {
id: ID! # Log ID
event: String
token: Token
user: User
block: Int!
gasUsed: BigDecimal!
gasPrice: BigDecimal!
2021-11-10 13:47:44 +01:00
createdTimestamp: Int!
tx: Bytes!
2020-11-26 07:38:08 +01:00
}
type User @entity {
id: ID!
2021-11-19 15:42:17 +01:00
sharesOwned: [PoolShares!] @derivedFrom(field: "user")
2021-11-04 16:00:43 +01:00
tokenBalancesOwned: [TokenValuePair!]
tokensOwned: [Token!] @derivedFrom(field: "minter")
poolTransactions: [PoolTransaction!] @derivedFrom(field: "user")
orders: [Order!] @derivedFrom(field: "payer")
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
}
type FixedRateExchange @entity {
2021-11-15 13:04:26 +01:00
"fixed rate exchange id"
id: ID!
2021-11-04 16:00:43 +01:00
owner: User!
datatoken: Token!
baseToken: Token!
price: BigDecimal!
active: Boolean!
2021-11-15 13:04:26 +01:00
"amount of total basetokens spent"
totalSwapValue: BigDecimal!
"address that is allowed to swap tokens"
allowedSwapper: String
2021-11-10 13:47:44 +01:00
supply: BigInt!
2021-11-15 13:04:26 +01:00
"if the owner allowes the fre to mint"
withMint: Boolean
"if the fre has the minter role on the datatoken"
isMinter: Boolean
updates: [FixedRateExchangeUpdate!] @derivedFrom(field: "exchangeId")
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
2021-11-10 13:47:44 +01:00
createdTimestamp: Int!
tx: Bytes
block: Int!
}
type FixedRateExchangeUpdate @entity {
id: ID!
exchangeId: FixedRateExchange!
2021-11-10 13:47:44 +01:00
oldPrice: BigDecimal
newPrice: BigDecimal
2021-11-10 13:47:44 +01:00
oldActive: Boolean
newActive: Boolean
oldAllowedSwapper: String
newAllowedSwapper: String
block: Int!
2021-11-10 13:47:44 +01:00
createdTimestamp: Int!
tx: Bytes!
}
type FixedRateExchangeSwap @entity {
id: ID!
exchangeId: FixedRateExchange!
by: User!
baseTokenAmount: BigDecimal!
dataTokenAmount: BigDecimal!
block: Int!
2021-11-10 13:47:44 +01:00
createdTimestamp: Int!
tx: Bytes!
}
type Dispenser @entity {
2021-11-15 13:04:26 +01:00
"datatoken address"
id: ID!
active: Boolean!
owner: User!
datatoken: Token!
2021-11-10 13:47:44 +01:00
allowedSwapper: String
2021-11-15 13:04:26 +01:00
isMinter: Boolean
"max tokens that can be dispensed"
maxTokens: BigDecimal!
"max balance of requester. If the balance is higher, the dispense is rejected"
maxBalance: BigDecimal!
"how many tokens are left"
balance: BigDecimal!
2021-11-04 16:00:43 +01:00
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenser")
}
type DispenserTransaction @entity {
2021-11-10 13:47:44 +01:00
id: ID!
dispenser: Dispenser!
user: User!
amount: BigDecimal!
block: Int!
2021-11-10 13:47:44 +01:00
createdTimestamp: Int!
tx: Bytes!
2021-09-02 16:57:14 +02:00
}
type PoolSnapshot @entity {
id: ID!
pool: Pool!
totalShares: BigDecimal!
2021-11-15 13:04:26 +01:00
"swap value 24h"
swapVolume: BigDecimal!
"swap fee value 24h"
swapFees: BigDecimal!
"date without time"
createdTimestamp: Int!
spotPrice: BigDecimal! # TODO: last spot price or first one?
2021-09-02 16:57:14 +02:00
tokens: [PoolSnapshotTokenValue!] @derivedFrom(field: "poolSnapshot")
}
type PoolSnapshotTokenValue @entity {
id: ID! # pool tx + tokenAddress
token: Token!
value: BigDecimal!
tokenReserve: BigDecimal! # how many tokens are left in pool
poolSnapshot: PoolSnapshot!
}
2021-11-19 15:42:17 +01:00
type GlobalStats @entity {
id: ID!
2021-11-15 13:04:26 +01:00
"total value locked represented in the base token , basically 2x liqudity for each base token"
totalValueLocked: [TokenValuePair!]
"total liquidity for each base token"
totalLiquidity: [TokenValuePair!]
"total swap volume for each base token. pools and fre"
totalSwapVolume: [TokenValuePair!]
2021-11-15 13:04:26 +01:00
"number of total consumes, pools + fre"
orderCount: BigInt
"number of pools for all factories"
poolCount: Int!
"number of finalized pools for all factories"
finalizedPoolCount: Int!
"probably remove due to inconsistencies and imposibility to calculate"
totalOrderVolume: BigDecimal
}
type MetadataUpdate @entity {
id: ID! # update tx + datatokenAddress
2021-11-04 16:00:43 +01:00
datatoken: Token!
datatokenAddress: String!
userAddress: String!
block: Int!
2021-11-10 13:47:44 +01:00
createdTimestamp: Int!
tx: Bytes!
}