update schema

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
mihaisc 2021-10-28 19:48:53 +03:00
parent c4633aa381
commit dd238aa614
No known key found for this signature in database
GPG Key ID: 4FB0C2329B4C6E29
2 changed files with 170 additions and 130 deletions

1
.prettierignore Normal file
View File

@ -0,0 +1 @@
*.graphql

View File

@ -1,3 +1,54 @@
type Token @entity {
id: ID! #
symbol: String #
name: String #
decimals: Int! #
address: String! #
cap: BigDecimal #
supply: BigDecimal #
isDatatoken: Boolean! #
factory: DatatokenFactory #
owner: String # address of ERC721 that owns the token, valid only for datatokens
minter: [String] # array of addresses with minter role, can be user wallet address, dispenser etc.
feeManager: String # TODO: maybe we change name , depends on audit results . It's the address that collects the payments (NOT fees)
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
orderCount: BigInt # Number of orders executed for this datatoken
createTime: Int # Block time datatoken was created
tx: Bytes # Datatoken creation transaction id
block: Int # Block number when it was created
}
type TokenValue {
token : Token!
value : BigDecimal!
}
type NftToken @entity{
id: ID! #
symbol: String! #
name: String! #
address: String!
tokenUri: String! #
owner: String!
providerUrl: String # provider url that can decrypt the ddo
assetState: Int! # state of the asset (described in docs)
managerRole: [String]
erc20DeployerRole: [String]
storeUpdateRole: [String]
metadataRole: [String] # addresses that can update the metadata
}
#TODO: do we need factories in general? We can move statistics on global object, check if we use them in a way
type PoolFactory @entity { type PoolFactory @entity {
id: ID! id: ID!
totalValueLocked: [TokenValue] # total value locked represented in the base token totalValueLocked: [TokenValue] # total value locked represented in the base token
@ -19,106 +70,60 @@ type DatatokenFactory @entity {
datatokens: [Tokens!] @derivedFrom(field: "factory") 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 {
id: ID! #
symbol: String #
name: String #
decimals: Int! #
address: String! #
cap: BigDecimal! #
supply: BigDecimal! #
isDatatoken: Boolean! #
factory: DatatokenFactory #
creator: String # TODO:
publisher: String # TODO:
minter: String # TODO:
editor: String # TODO:
holderCount: BigInt # Number of addresses holding a balance of datatoken
orderCount: BigInt # Number of orders executed for this datatoken
createTime: Int # Block time datatoken was created
tx: Bytes # Datatoken creation transaction id
block: Int # Block number when it was created
}
type Pool @entity { type Pool @entity {
id: ID! # Pool address id: ID! # Pool address
poolFactory: PoolFactory! # Pool factory poolFactory: PoolFactory! # Pool factory
controller: Bytes! # Controller address owner: String! # Owner address, pool controller
isPublicSwap: Boolean! # TODO : what is this?
isPublicSwap: Boolean! # if swap/trade is activated, probably always true
isFinalized: Boolean! # only finalized pools are relevant to us isFinalized: Boolean! # only finalized pools are relevant to us
symbol: String # Pool token symbol symbol: String # Pool token symbol
name: String # Pool token name name: String # Pool token name
cap: BigInt # Maximum supply if any cap: BigDecimal # Maximum supply if any, converted from wei
isActive: Boolean! # isActive: Boolean! # pool is active
swapFee: BigDecimal! # Swap Fees
totalWeight: BigDecimal! # TODO: What is this? 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 totalShares: BigDecimal! # Total pool token shares
totalSwapVolume: BigDecimal! # Total swap volume in main token totalSwapVolume: [TokenValue!]! # total tokens that were swaped
totalSwapFee: BigDecimal! # TODO: is this correct ? Total swap fee in main token
totalValueLocked: BigDecimal! # value locked in pool expressed in main token (captures both Ocean and Datatoken) spotPrice: BigDecimal! # spot price
spotPrice: BigDecimal!
consumePrice: BigDecimal! # TODO: still need?
# what is the point of the counts, we never used them => remove
joinCount: BigInt! # liquidity has been added joinCount: BigInt! # liquidity has been added
exitCount: BigInt! # liquidity has been removed exitCount: BigInt! # liquidity has been removed
swapCount: BigInt! swapCount: BigInt!
transactionCount: BigInt! # Number of transactions in this pool involving liquidity changes transactionCount: BigInt! # Number of transactions in this pool involving liquidity changes
// remove
datatokenAddress: String!
createTime: Int! # Block time pool was created createTime: Int! # Block time pool was created
tx: Bytes # Pool creation transaction id tx: Bytes # Pool creation transaction id
block 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!
@ -126,14 +131,18 @@ type PoolShare @entity {
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 sharesTransferAmount: BigDecimal # Number of shares transfered
sharesBalance: BigDecimal! # TODO: what is this?
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
@ -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!
withMint: Boolean # if the owner allowes the fre to mint
isMinter: Boolean # if the fre has the minter role on the datatoken
maxTokens: BigDecimal! # max tokens that can be dispensed maxTokens: BigDecimal! # max tokens that can be dispensed
maxBalance: BigDecimal! # max balance of requester. If the balance is higher, the dispense is rejected maxBalance: BigDecimal! # max balance of requester. If the balance is higher, the dispense is rejected
balance: BigDecimal! balance: BigDecimal! # how many tokens are left
datatoken: Datatoken!
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!