mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
update schema
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
parent
c4633aa381
commit
dd238aa614
1
.prettierignore
Normal file
1
.prettierignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.graphql
|
299
schema.graphql
299
schema.graphql
@ -1,63 +1,23 @@
|
|||||||
type PoolFactory @entity {
|
|
||||||
id: ID!
|
|
||||||
totalValueLocked: [TokenValue] # total value locked represented in the base token
|
|
||||||
totalLiquidity: [TokenValue] # total liquidity for each base token
|
|
||||||
totalSwapVolume: [TokenValue] # total swap volume for each base token
|
|
||||||
totalSwapFee: [TokenValue] # All the swap fee in Ocean
|
|
||||||
|
|
||||||
poolCount: Int! # Number of pools
|
|
||||||
finalizedPoolCount: Int! # Number of finalized pools
|
|
||||||
orderCount: BigInt # Number of total consumes
|
|
||||||
totalOrderVolume: BigDecimal # probably remove due to inconsistencies and imposibility to calculate
|
|
||||||
|
|
||||||
pools: [Pool!] @derivedFrom(field: "factoryID")
|
|
||||||
}
|
|
||||||
|
|
||||||
type DatatokenFactory @entity {
|
|
||||||
id: ID!
|
|
||||||
tokenCount: Int! # Number of datatokens
|
|
||||||
datatokens: [Tokens!] @derivedFrom(field: "factory")
|
|
||||||
}
|
|
||||||
|
|
||||||
type Global @entity {
|
|
||||||
id: ID!
|
|
||||||
|
|
||||||
totalValueLocked: [TokenValuePair] # total value locked represented in the base token
|
|
||||||
totalLiquidity: [TokenValuePair] # total liquidity for each base token
|
|
||||||
totalSwapVolume: [TokenValuePair] # total swap volume for each base token. pools and fre
|
|
||||||
|
|
||||||
totalOrderVolume: BigDecimal
|
|
||||||
|
|
||||||
orderCount: BigInt # Number of total consumes, pools + fre
|
|
||||||
|
|
||||||
poolCount: Int! # Number of pools for all factories
|
|
||||||
finalizedPoolCount: Int! # Number of finalized pools for all factories
|
|
||||||
}
|
|
||||||
|
|
||||||
type TokenValue {
|
|
||||||
|
|
||||||
token : Token!
|
|
||||||
value : BigDecimal!
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type Token @entity {
|
type Token @entity {
|
||||||
id: ID! #
|
id: ID! #
|
||||||
symbol: String #
|
symbol: String #
|
||||||
name: String #
|
name: String #
|
||||||
decimals: Int! #
|
decimals: Int! #
|
||||||
address: String! #
|
address: String! #
|
||||||
cap: BigDecimal! #
|
cap: BigDecimal #
|
||||||
supply: BigDecimal! #
|
supply: BigDecimal #
|
||||||
isDatatoken: Boolean! #
|
isDatatoken: Boolean! #
|
||||||
|
|
||||||
factory: DatatokenFactory #
|
factory: DatatokenFactory #
|
||||||
|
|
||||||
creator: String # TODO:
|
owner: String # address of ERC721 that owns the token, valid only for datatokens
|
||||||
publisher: String # TODO:
|
minter: [String] # array of addresses with minter role, can be user wallet address, dispenser etc.
|
||||||
minter: String # TODO:
|
feeManager: String # TODO: maybe we change name , depends on audit results . It's the address that collects the payments (NOT fees)
|
||||||
editor: String # TODO:
|
publishMarketFeeAddress: String # address of the market where the datatoken was created. This address collects market fees.
|
||||||
|
publishMarketFeeToken: String # adreess of fee token (can be Ocean, ETH, etc.)
|
||||||
|
publishMarketFeeAmmount: BigDecimal # fee amount. Fixed value, expressed in wei in contracts, needs conversion in decimals.
|
||||||
|
templateId: Int # template ID of the datatoken
|
||||||
|
|
||||||
holderCount: BigInt # Number of addresses holding a balance of datatoken
|
holderCount: BigInt # Number of addresses holding a balance of datatoken
|
||||||
orderCount: BigInt # Number of orders executed for this datatoken
|
orderCount: BigInt # Number of orders executed for this datatoken
|
||||||
|
|
||||||
@ -66,75 +26,124 @@ type Token @entity {
|
|||||||
block: Int # Block number when it was created
|
block: Int # Block number when it was created
|
||||||
}
|
}
|
||||||
|
|
||||||
type Pool @entity {
|
type TokenValue {
|
||||||
id: ID! # Pool address
|
token : Token!
|
||||||
poolFactory: PoolFactory! # Pool factory
|
value : BigDecimal!
|
||||||
controller: Bytes! # Controller address
|
}
|
||||||
isPublicSwap: Boolean! # TODO : what is this?
|
|
||||||
isFinalized: Boolean! # only finalized pools are relevant to us
|
|
||||||
|
|
||||||
symbol: String # Pool token symbol
|
|
||||||
name: String # Pool token name
|
|
||||||
cap: BigInt # Maximum supply if any
|
|
||||||
isActive: Boolean! #
|
|
||||||
swapFee: BigDecimal! # Swap Fees
|
|
||||||
|
|
||||||
totalWeight: BigDecimal! # TODO: What is this?
|
type NftToken @entity{
|
||||||
totalShares: BigDecimal! # Total pool token shares
|
id: ID! #
|
||||||
totalSwapVolume: BigDecimal! # Total swap volume in main token
|
symbol: String! #
|
||||||
totalSwapFee: BigDecimal! # TODO: is this correct ? Total swap fee in main token
|
name: String! #
|
||||||
|
address: String!
|
||||||
|
tokenUri: String! #
|
||||||
|
owner: String!
|
||||||
|
|
||||||
totalValueLocked: BigDecimal! # value locked in pool expressed in main token (captures both Ocean and Datatoken)
|
providerUrl: String # provider url that can decrypt the ddo
|
||||||
|
assetState: Int! # state of the asset (described in docs)
|
||||||
|
|
||||||
spotPrice: BigDecimal!
|
managerRole: [String]
|
||||||
consumePrice: BigDecimal! # TODO: still need?
|
erc20DeployerRole: [String]
|
||||||
|
storeUpdateRole: [String]
|
||||||
|
metadataRole: [String] # addresses that can update the metadata
|
||||||
|
}
|
||||||
|
|
||||||
# what is the point of the counts, we never used them => remove
|
#TODO: do we need factories in general? We can move statistics on global object, check if we use them in a way
|
||||||
joinCount: BigInt! # liquidity has been added
|
type PoolFactory @entity {
|
||||||
exitCount: BigInt! # liquidity has been removed
|
id: ID!
|
||||||
swapCount: BigInt!
|
totalValueLocked: [TokenValue] # total value locked represented in the base token
|
||||||
transactionCount: BigInt! # Number of transactions in this pool involving liquidity changes
|
totalLiquidity: [TokenValue] # total liquidity for each base token
|
||||||
|
totalSwapVolume: [TokenValue] # total swap volume for each base token
|
||||||
// remove
|
totalSwapFee: [TokenValue] # All the swap fee in Ocean
|
||||||
datatokenAddress: String!
|
|
||||||
|
poolCount: Int! # Number of pools
|
||||||
|
finalizedPoolCount: Int! # Number of finalized pools
|
||||||
|
orderCount: BigInt # Number of total consumes
|
||||||
|
totalOrderVolume: BigDecimal # probably remove due to inconsistencies and imposibility to calculate
|
||||||
|
|
||||||
createTime: Int! # Block time pool was created
|
pools: [Pool!] @derivedFrom(field: "factoryID")
|
||||||
tx: Bytes # Pool creation transaction id
|
}
|
||||||
block
|
|
||||||
|
|
||||||
|
type DatatokenFactory @entity {
|
||||||
|
id: ID!
|
||||||
|
tokenCount: Int! # Number of datatokens
|
||||||
|
datatokens: [Tokens!] @derivedFrom(field: "factory")
|
||||||
|
}
|
||||||
|
|
||||||
|
type Pool @entity {
|
||||||
|
id: ID! # Pool address
|
||||||
|
poolFactory: PoolFactory! # Pool factory
|
||||||
|
owner: String! # Owner address, pool controller
|
||||||
|
|
||||||
|
isPublicSwap: Boolean! # if swap/trade is activated, probably always true
|
||||||
|
isFinalized: Boolean! # only finalized pools are relevant to us
|
||||||
|
|
||||||
|
symbol: String # Pool token symbol
|
||||||
|
name: String # Pool token name
|
||||||
|
cap: BigDecimal # Maximum supply if any, converted from wei
|
||||||
|
isActive: Boolean! # pool is active
|
||||||
|
|
||||||
|
poolFee: BigDecimal! # Pool Fee percent, fee goes to all liquidity providers : SWAP, JOIN , EXIT
|
||||||
|
opfFee: BigDecimal! # OPF Fee percent, fee that goes to Ocean Protocol Foundation : SWAP
|
||||||
|
marketFee: BigDecimal! # Market fee percent, fee that goes to the market where the pool was created : SWAP
|
||||||
|
totalPoolFee: [TokenValue!]! # actual value of fee collected in both tokens
|
||||||
|
totalOpfFee: [TokenValue!]! # actual value of fee collected in both tokens
|
||||||
|
totalMarketFee: [TokenValue!]! # actual value of fee collected in both tokens
|
||||||
|
|
||||||
|
currentOpfFee: [TokenValue!]! # fee after collection totalFee - colectedFee
|
||||||
|
currentMarketFee: [TokenValue!]! # fee after collection totalFee - colectedFee
|
||||||
|
|
||||||
|
totalWeight: BigDecimal! # it's always 100
|
||||||
|
totalShares: BigDecimal! # Total pool token shares
|
||||||
|
totalSwapVolume: [TokenValue!]! # total tokens that were swaped
|
||||||
|
|
||||||
|
spotPrice: BigDecimal! # spot price
|
||||||
|
|
||||||
|
joinCount: BigInt! # liquidity has been added
|
||||||
|
exitCount: BigInt! # liquidity has been removed
|
||||||
|
swapCount: BigInt!
|
||||||
|
transactionCount: BigInt! # Number of transactions in this pool involving liquidity changes
|
||||||
|
|
||||||
|
createTime: Int! # Block time pool was created
|
||||||
|
tx: Bytes # Pool creation transaction id
|
||||||
|
block: Int # Block number when it was created
|
||||||
|
|
||||||
|
# split in basetokne and datatoken like in fre
|
||||||
tokens: [PoolToken!] @derivedFrom(field: "poolId")
|
tokens: [PoolToken!] @derivedFrom(field: "poolId")
|
||||||
shares: [PoolShare!] @derivedFrom(field: "poolId")
|
shares: [PoolShare!] @derivedFrom(field: "poolId")
|
||||||
transactions: [PoolTransaction!] @derivedFrom(field: "pool")
|
transactions: [PoolTransaction!] @derivedFrom(field: "pool")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# should not pe @entity
|
||||||
type PoolToken @entity {
|
type PoolToken @entity {
|
||||||
id: ID! # poolId + token address
|
id: ID! # poolId + token address
|
||||||
pool: Pool! #
|
pool: Pool! #
|
||||||
isDatatoken: Boolean! # if the token is a datatoken , not sure if this makes sense since it is duplicate information found on token
|
|
||||||
token: Token!
|
token: Token!
|
||||||
balance: BigDecimal! # balance of the token in this pool
|
balance: BigDecimal! # balance of the token in this pool
|
||||||
denormWeight: BigDecimal!
|
denormWeight: BigDecimal! # weight of token in the pool (50% for our pools)
|
||||||
symbol: String # should we keep this, it is found on token?
|
|
||||||
name: String # should we keep this, it is found on token?
|
|
||||||
decimals: Int # should we keep this, it is found on token?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# we will need to track pool share tx between users - bpool transfer tx event
|
||||||
type PoolShare @entity {
|
type PoolShare @entity {
|
||||||
id: ID! # poolId + userAddress
|
id: ID! # poolId + userAddress
|
||||||
user: User!
|
user: User!
|
||||||
pool: Pool!
|
pool: Pool!
|
||||||
balance: BigDecimal!
|
balance: BigDecimal!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#check balancer v2 graph TX
|
||||||
type PoolTransaction @entity {
|
type PoolTransaction @entity {
|
||||||
id: ID! # pool tx
|
id: ID! # tx + caller
|
||||||
pool: Pool # Pool related to this tx
|
pool: Pool! # Pool related to this tx
|
||||||
user: User # User that initiates the swap
|
user: User! # User that initiates the tx
|
||||||
|
type: Int # 0 - JOIN, 1 - EXIT , 2 - SWAP, maybe change to enum
|
||||||
sharesTransferAmount: BigDecimal! # Number of shares transfered
|
|
||||||
sharesBalance: BigDecimal! # TODO: what is this?
|
sharesTransferAmount: BigDecimal # Number of shares transfered
|
||||||
|
|
||||||
|
poolFee: BigDecimal! # Pool Fee percent, fee goes to all liquidity providers : SWAP, JOIN , EXIT
|
||||||
|
opfFee: BigDecimal! # OPF Fee percent, fee that goes to Ocean Protocol Foundation : SWAP
|
||||||
|
marketFee: BigDecimal!
|
||||||
|
|
||||||
tx: Bytes!
|
tx: Bytes!
|
||||||
event: String
|
event: String
|
||||||
block: Int!
|
block: Int!
|
||||||
@ -142,7 +151,8 @@ type PoolTransaction @entity {
|
|||||||
gasUsed: BigDecimal!
|
gasUsed: BigDecimal!
|
||||||
gasPrice: BigDecimal!
|
gasPrice: BigDecimal!
|
||||||
|
|
||||||
tokens: [TokenValue!] # tokens transfered
|
# change to baseToken and dataToken
|
||||||
|
tokens: [TokenValue!] # tokens transfered , if value is negative it means it was removed.
|
||||||
}
|
}
|
||||||
|
|
||||||
type Order @entity { # renamed from TokenOrder to Order
|
type Order @entity { # renamed from TokenOrder to Order
|
||||||
@ -153,14 +163,23 @@ type Order @entity { # renamed from Toke
|
|||||||
payer: User!
|
payer: User!
|
||||||
amount: BigDecimal!
|
amount: BigDecimal!
|
||||||
serviceId: Int!
|
serviceId: Int!
|
||||||
marketFeeCollector: User
|
|
||||||
marketFee: BigDecimal!
|
|
||||||
|
# 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
|
||||||
|
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
tx: Bytes
|
tx: Bytes
|
||||||
block: Int!
|
block: Int!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# to be removed, mabye for pool shares only
|
||||||
type TokenTransaction @entity {
|
type TokenTransaction @entity {
|
||||||
id: ID! # Log ID
|
id: ID! # Log ID
|
||||||
event: String
|
event: String
|
||||||
@ -180,7 +199,6 @@ type User @entity {
|
|||||||
tokenBalancesOwned: [TokenValue!]
|
tokenBalancesOwned: [TokenValue!]
|
||||||
tokensOwned: [Token!] @derivedFrom(field: "minter")
|
tokensOwned: [Token!] @derivedFrom(field: "minter")
|
||||||
poolTransactions: [PoolTransaction!] @derivedFrom(field: "user")
|
poolTransactions: [PoolTransaction!] @derivedFrom(field: "user")
|
||||||
tokenTransactions: [TokenTransaction!] @derivedFrom(field: "user")
|
|
||||||
orders: [Order!] @derivedFrom(field: "payer")
|
orders: [Order!] @derivedFrom(field: "payer")
|
||||||
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
|
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
|
||||||
}
|
}
|
||||||
@ -190,9 +208,14 @@ type FixedRateExchange @entity {
|
|||||||
exchangeOwner: User!
|
exchangeOwner: User!
|
||||||
datatoken: Token!
|
datatoken: Token!
|
||||||
baseToken: Token!
|
baseToken: Token!
|
||||||
rate: BigDecimal!
|
price: BigDecimal!
|
||||||
active: Boolean!
|
active: Boolean!
|
||||||
suppy: Int!
|
totalSwapValue: BigDecimal! # amount of total basetokens spent
|
||||||
|
allowedSwapper: String # address that is allowed to swap tokens
|
||||||
|
supply: Int!
|
||||||
|
withMint: Boolean # if the owner allowes the fre to mint
|
||||||
|
isMinter: Boolean # if the fre has the minter role on the datatoken
|
||||||
|
|
||||||
updates: [FixedRateExchangeUpdate!] @derivedFrom(field: "exchangeId")
|
updates: [FixedRateExchangeUpdate!] @derivedFrom(field: "exchangeId")
|
||||||
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
|
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
|
||||||
}
|
}
|
||||||
@ -200,10 +223,16 @@ type FixedRateExchange @entity {
|
|||||||
type FixedRateExchangeUpdate @entity {
|
type FixedRateExchangeUpdate @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
exchangeId: FixedRateExchange!
|
exchangeId: FixedRateExchange!
|
||||||
oldRate: BigDecimal!
|
|
||||||
newRate: BigDecimal!
|
oldPrice: BigDecimal!
|
||||||
|
newPrice: BigDecimal!
|
||||||
|
|
||||||
oldActive: Boolean!
|
oldActive: Boolean!
|
||||||
newActive: Boolean!
|
newActive: Boolean!
|
||||||
|
|
||||||
|
oldAllowedSwapper: String
|
||||||
|
newAllowedSwapper: String
|
||||||
|
|
||||||
block: Int!
|
block: Int!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
tx: Bytes!
|
tx: Bytes!
|
||||||
@ -220,43 +249,35 @@ type FixedRateExchangeSwap @entity {
|
|||||||
tx: Bytes!
|
tx: Bytes!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# since in the template that we will use minterApproved is sort of "bundled" with isTrueMinter i think we should have only one field here to easily check if dispenser cand mint
|
||||||
|
|
||||||
type Dispenser @entity {
|
type Dispenser @entity {
|
||||||
id: ID! # it's the datatoken address
|
id: ID! # it's the datatoken address
|
||||||
active: Boolean!
|
active: Boolean!
|
||||||
owner: User!
|
owner: User!
|
||||||
minterApproved: Boolean!
|
datatoken: Token!
|
||||||
isTrueMinter: Boolean!
|
|
||||||
maxTokens: BigDecimal! # max tokens that can be dispensed
|
withMint: Boolean # if the owner allowes the fre to mint
|
||||||
maxBalance: BigDecimal! # max balance of requester. If the balance is higher, the dispense is rejected
|
isMinter: Boolean # if the fre has the minter role on the datatoken
|
||||||
balance: BigDecimal!
|
maxTokens: BigDecimal! # max tokens that can be dispensed
|
||||||
datatoken: Datatoken!
|
maxBalance: BigDecimal! # max balance of requester. If the balance is higher, the dispense is rejected
|
||||||
|
balance: BigDecimal! # how many tokens are left
|
||||||
|
|
||||||
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenserId")
|
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenserId")
|
||||||
}
|
}
|
||||||
|
|
||||||
type DispenserTransaction @entity {
|
type DispenserTransaction @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
dispenserId: Dispenser!
|
dispenser: Dispenser!
|
||||||
datatoken: Token!
|
datatoken: Token!
|
||||||
user: User!
|
user: User!
|
||||||
amount: BigDecimal!
|
amount: BigDecimal!
|
||||||
|
|
||||||
block: Int!
|
block: Int!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
tx: Bytes!
|
tx: Bytes!
|
||||||
type: String!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type PoolSnapshotTokenValue @entity {
|
|
||||||
id: ID! # pool tx + tokenAddress
|
|
||||||
token: Token!
|
|
||||||
value: BigDecimal!
|
|
||||||
tokenReserve: BigDecimal!
|
|
||||||
feeValue: BigDecimal! # Swap fee value in OCEAN
|
|
||||||
type: String!
|
|
||||||
poolSnapshot: PoolSnapshot!
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
type PoolSnapshot @entity {
|
type PoolSnapshot @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
pool: Pool!
|
pool: Pool!
|
||||||
@ -268,8 +289,28 @@ type PoolSnapshot @entity {
|
|||||||
tokens: [PoolSnapshotTokenValue!] @derivedFrom(field: "poolSnapshot")
|
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!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Global @entity {
|
||||||
|
id: ID!
|
||||||
|
|
||||||
|
totalValueLocked: [TokenValuePair] # total value locked represented in the base token , basically 2x liqudity for each base token
|
||||||
|
totalLiquidity: [TokenValuePair] # total liquidity for each base token
|
||||||
|
totalSwapVolume: [TokenValuePair] # total swap volume for each base token. pools and fre
|
||||||
|
|
||||||
|
orderCount: BigInt # Number of total consumes, pools + fre
|
||||||
|
|
||||||
|
poolCount: Int! # Number of pools for all factories
|
||||||
|
finalizedPoolCount: Int! # Number of finalized pools for all factories
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# shouldn't we move this to aquarius?
|
|
||||||
type MetadataUpdate @entity {
|
type MetadataUpdate @entity {
|
||||||
id: ID! # update tx + datatokenAddress
|
id: ID! # update tx + datatokenAddress
|
||||||
datatokenId: Datatoken!
|
datatokenId: Datatoken!
|
||||||
@ -277,8 +318,6 @@ type MetadataUpdate @entity {
|
|||||||
datatokenAddress: String!
|
datatokenAddress: String!
|
||||||
userAddress: String!
|
userAddress: String!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
block: Int!
|
block: Int!
|
||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
tx: Bytes!
|
tx: Bytes!
|
||||||
|
Loading…
Reference in New Issue
Block a user