2021-09-02 11:08:47 +02:00
type Token @entity {
id : ID ! #
symbol : String #
name : String #
decimals : Int ! #
address : String ! #
2021-10-28 18:48:53 +02:00
cap : BigDecimal #
supply : BigDecimal #
2021-09-02 11:08:47 +02:00
isDatatoken : Boolean ! #
2021-10-28 18:48:53 +02:00
owner : String # address of ERC721 that owns the token, valid only for datatokens
2021-11-04 16:00:43 +01:00
minter : [ User ! ] # array of addresses with minter role, can be user wallet address, dispenser etc.
2021-10-28 18:48:53 +02:00
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
2021-11-12 14:22:35 +01:00
holderCount : BigInt # Number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts
2021-09-02 11:08:47 +02:00
orderCount : BigInt # Number of orders executed for this datatoken
2021-11-10 13:47:44 +01:00
createdTimestamp : Int # Block time datatoken was created
2021-09-02 11:08:47 +02:00
tx : Bytes # Datatoken creation transaction id
block : Int # Block number when it was created
2021-07-30 09:36:44 +02:00
}
2021-05-13 08:19:21 +02:00
2021-11-04 16:00:43 +01:00
type TokenValuePair @entity {
id : ID !
2021-10-28 18:48:53 +02:00
token : Token !
value : BigDecimal !
}
2021-11-04 16:00:43 +01:00
type Nft @entity {
id : ID ! # nft address
2021-10-28 18:48:53 +02:00
symbol : String ! #
name : String ! #
tokenUri : String ! #
2021-11-04 16:00:43 +01:00
owner : String ! # owner of the nft
address : String ! #
2021-10-28 18:48:53 +02:00
providerUrl : String # provider url that can decrypt the ddo
assetState : Int ! # state of the asset (described in docs)
2021-11-04 16:00:43 +01:00
managerRole : [ String ! ]
erc20DeployerRole : [ String ! ]
storeUpdateRole : [ String ! ]
metadataRole : [ String ! ] # addresses that can update the metadata
2021-10-28 18:48:53 +02:00
2021-11-04 16:00:43 +01:00
template : String ! # template address
2021-11-10 13:47:44 +01:00
createdTimestamp : Int ! # Block time pool was created
2021-11-04 16:00:43 +01:00
tx : Bytes # Pool creation transaction id
block : Int # Block number when it was created
2021-10-28 18:48:53 +02:00
}
2021-07-30 09:36:44 +02:00
type Pool @entity {
2021-10-28 18:48:53 +02:00
id : ID ! # Pool address
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
2021-09-02 11:08:47 +02:00
2021-10-28 18:48:53 +02:00
symbol : String # Pool token symbol
name : String # Pool token name
cap : BigDecimal # Maximum supply if any, converted from wei
isActive : Boolean ! # pool is active
2021-07-30 09:36:44 +02:00
2021-11-12 14:22:35 +01:00
baseToken : PoolToken ! @derivedFrom ( field : "pool" )
datatoken : PoolToken ! @derivedFrom ( field : "pool" )
2021-10-28 18:48:53 +02:00
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
2021-11-04 16:00:43 +01:00
totalPoolFee : [ TokenValuePair ! ] ! # actual value of fee collected in both tokens
totalOpfFee : [ TokenValuePair ! ] ! # actual value of fee collected in both tokens
totalMarketFee : [ TokenValuePair ! ] ! # actual value of fee collected in both tokens
2021-07-30 09:36:44 +02:00
2021-11-04 16:00:43 +01:00
currentOpfFee : [ TokenValuePair ! ] ! # fee after collection totalFee - colectedFee
currentMarketFee : [ TokenValuePair ! ] ! # fee after collection totalFee - colectedFee
2021-09-02 11:08:47 +02:00
2021-10-28 18:48:53 +02:00
totalWeight : BigDecimal ! # it's always 100
totalShares : BigDecimal ! # Total pool token shares
2021-11-04 16:00:43 +01:00
totalSwapVolume : [ TokenValuePair ! ] ! # total tokens that were swaped
2021-09-02 11:08:47 +02:00
2021-10-28 18:48:53 +02:00
spotPrice : BigDecimal ! # spot price
joinCount : BigInt ! # liquidity has been added
exitCount : BigInt ! # liquidity has been removed
2021-07-30 09:36:44 +02:00
swapCount : BigInt !
2021-10-28 18:48:53 +02:00
transactionCount : BigInt ! # Number of transactions in this pool involving liquidity changes
2021-09-02 11:08:47 +02:00
2021-11-10 13:47:44 +01:00
createdTimestamp : Int ! # Block time pool was created
2021-10-28 18:48:53 +02:00
tx : Bytes # Pool creation transaction id
block : Int # Block number when it was created
2021-07-30 09:36:44 +02:00
2021-11-04 16:00:43 +01:00
shares : [ PoolShare ! ] @derivedFrom ( field : "pool" )
2021-09-10 12:49:37 +02:00
transactions : [ PoolTransaction ! ] @derivedFrom ( field : "pool" )
2020-11-20 13:12:02 +01:00
}
2021-10-28 18:48:53 +02:00
# should not pe @entity
2020-11-20 13:12:02 +01:00
type PoolToken @entity {
2021-10-28 18:48:53 +02:00
id : ID ! # poolId + token address
pool : Pool ! #
2021-09-08 13:34:33 +02:00
token : Token !
2021-10-28 18:48:53 +02:00
balance : BigDecimal ! # balance of the token in this pool
denormWeight : BigDecimal ! # weight of token in the pool (50% for our pools)
2020-11-20 13:12:02 +01:00
}
2021-10-28 18:48:53 +02:00
# we will need to track pool share tx between users - bpool transfer tx event
2020-11-20 13:12:02 +01:00
type PoolShare @entity {
2021-10-28 18:48:53 +02:00
id : ID ! # poolId + userAddress
2021-09-08 13:34:33 +02:00
user : User !
pool : Pool !
2021-05-13 08:19:21 +02:00
balance : BigDecimal !
2020-11-20 13:12:02 +01:00
}
2021-11-12 14:22:35 +01:00
2021-09-10 12:49:37 +02:00
type PoolTransaction @entity {
2021-10-28 18:48:53 +02:00
id : ID ! # tx + caller
pool : Pool ! # Pool related to this tx
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
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 !
2021-11-12 14:22:35 +01:00
event : String # TODO: what is this?
2021-05-13 08:19:21 +02:00
tx : Bytes !
block : Int !
2021-11-12 14:22:35 +01:00
timestamp : Int !
gasLimit : BigDecimal !
gasPrice : BigDecimal ! # in eth
2021-05-13 08:19:21 +02:00
2021-10-28 18:48:53 +02:00
# change to baseToken and dataToken
2021-11-12 14:22:35 +01:00
baseToken : TokenValuePair # tokens transfered , if value is negative it means it was removed,
datatoken : TokenValuePair
2020-11-20 13:12:02 +01:00
}
2021-09-13 15:20:29 +02:00
type Order @entity { # renamed from TokenOrder to Order
id : ID ! # datatokenId + userAddress + tx
token : Token !
2021-05-13 08:19:21 +02:00
consumer : User !
payer : User !
amount : BigDecimal !
serviceId : Int !
2021-10-28 18:48:53 +02:00
# 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-05-13 08:19:21 +02:00
2021-11-10 13:47:44 +01:00
createdTimestamp : Int !
2021-05-13 08:19:21 +02:00
tx : Bytes
block : Int !
2020-11-26 12:10:45 +01:00
}
2021-10-28 18:48:53 +02:00
# to be removed, mabye for pool shares only
2020-11-26 07:38:08 +01:00
type TokenTransaction @entity {
2021-05-13 08:19:21 +02:00
id : ID ! # Log ID
event : String
2021-09-13 15:20:29 +02:00
token : Token
user : User
2021-05-13 08:19:21 +02:00
block : Int !
gasUsed : BigDecimal !
gasPrice : BigDecimal !
2021-11-10 13:47:44 +01:00
createdTimestamp : Int !
2021-05-13 08:19:21 +02:00
tx : Bytes !
2020-11-26 07:38:08 +01:00
}
2020-12-02 11:07:09 +01:00
type User @entity {
2021-05-13 08:19:21 +02:00
id : ID !
2021-09-13 15:20:29 +02:00
sharesOwned : [ PoolShare ! ] @derivedFrom ( field : "user" )
2021-11-04 16:00:43 +01:00
tokenBalancesOwned : [ TokenValuePair ! ]
2021-09-13 15:20:29 +02:00
tokensOwned : [ Token ! ] @derivedFrom ( field : "minter" )
poolTransactions : [ PoolTransaction ! ] @derivedFrom ( field : "user" )
orders : [ Order ! ] @derivedFrom ( field : "payer" )
2021-05-13 08:19:21 +02:00
freSwaps : [ FixedRateExchangeSwap ! ] @derivedFrom ( field : "by" )
2020-12-02 11:07:09 +01:00
}
2021-03-10 22:36:51 +01:00
type FixedRateExchange @entity {
2021-09-13 15:20:29 +02:00
id : ID ! # fixed rate exchange id
2021-11-04 16:00:43 +01:00
owner : User !
2021-09-13 15:20:29 +02:00
datatoken : Token !
baseToken : Token !
2021-10-28 18:48:53 +02:00
price : BigDecimal !
2021-05-13 08:19:21 +02:00
active : Boolean !
2021-10-28 18:48:53 +02:00
totalSwapValue : BigDecimal ! # amount of total basetokens spent
allowedSwapper : String # address that is allowed to swap tokens
2021-11-10 13:47:44 +01:00
supply : BigInt !
2021-10-28 18:48:53 +02:00
withMint : Boolean # if the owner allowes the fre to mint
isMinter : Boolean # if the fre has the minter role on the datatoken
2021-05-13 08:19:21 +02:00
updates : [ FixedRateExchangeUpdate ! ] @derivedFrom ( field : "exchangeId" )
swaps : [ FixedRateExchangeSwap ! ] @derivedFrom ( field : "exchangeId" )
2021-11-10 13:47:44 +01:00
createdTimestamp : Int !
tx : Bytes
block : Int !
2021-03-10 22:36:51 +01:00
}
type FixedRateExchangeUpdate @entity {
2021-05-13 08:19:21 +02:00
id : ID !
exchangeId : FixedRateExchange !
2021-10-28 18:48:53 +02:00
2021-11-10 13:47:44 +01:00
oldPrice : BigDecimal
newPrice : BigDecimal
2021-10-28 18:48:53 +02:00
2021-11-10 13:47:44 +01:00
oldActive : Boolean
newActive : Boolean
2021-10-28 18:48:53 +02:00
oldAllowedSwapper : String
newAllowedSwapper : String
2021-05-13 08:19:21 +02:00
block : Int !
2021-11-10 13:47:44 +01:00
createdTimestamp : Int !
2021-05-13 08:19:21 +02:00
tx : Bytes !
2021-03-10 22:36:51 +01:00
}
type FixedRateExchangeSwap @entity {
2021-05-13 08:19:21 +02:00
id : ID !
exchangeId : FixedRateExchange !
by : User !
baseTokenAmount : BigDecimal !
dataTokenAmount : BigDecimal !
block : Int !
2021-11-10 13:47:44 +01:00
createdTimestamp : Int !
2021-05-13 08:19:21 +02:00
tx : Bytes !
}
2021-10-28 18:48:53 +02:00
# 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
2021-05-13 08:19:21 +02:00
type Dispenser @entity {
2021-10-28 18:48:53 +02:00
id : ID ! # it's the datatoken address
2021-10-27 12:06:30 +02:00
active : Boolean !
2021-05-13 08:19:21 +02:00
owner : User !
2021-10-28 18:48:53 +02:00
datatoken : Token !
2021-11-10 13:47:44 +01:00
allowedSwapper : String
2021-10-28 18:48:53 +02:00
isMinter : Boolean # if the fre has the minter role on the datatoken
maxTokens : BigDecimal ! # max tokens that can be dispensed
maxBalance : BigDecimal ! # max balance of requester. If the balance is higher, the dispense is rejected
balance : BigDecimal ! # how many tokens are left
2021-11-04 16:00:43 +01:00
dispenses : [ DispenserTransaction ! ] @derivedFrom ( field : "dispenser" )
2021-05-13 08:19:21 +02:00
}
type DispenserTransaction @entity {
2021-11-10 13:47:44 +01:00
id : ID !
2021-10-28 18:48:53 +02:00
dispenser : Dispenser !
2021-05-13 08:19:21 +02:00
user : User !
amount : BigDecimal !
2021-10-28 18:48:53 +02:00
2021-05-13 08:19:21 +02:00
block : Int !
2021-11-10 13:47:44 +01:00
createdTimestamp : Int !
2021-05-13 08:19:21 +02:00
tx : Bytes !
2021-09-02 16:57:14 +02:00
}
type PoolSnapshot @entity {
id : ID !
pool : Pool !
totalShares : BigDecimal !
2021-09-15 11:53:50 +02:00
swapVolume : BigDecimal ! # swap value 24h
swapFees : BigDecimal ! # swap fee value 24h
2021-11-10 13:47:44 +01:00
createdTimestamp : Int ! # date without time
2021-09-15 11:53:50 +02:00
spotPrice : BigDecimal ! # TODO: last spot price or first one?
2021-09-02 16:57:14 +02:00
tokens : [ PoolSnapshotTokenValue ! ] @derivedFrom ( field : "poolSnapshot" )
}
2021-10-28 18:48:53 +02:00
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 !
2021-11-04 16:00:43 +01:00
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
2021-10-28 18:48:53 +02:00
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
2021-11-04 16:00:43 +01:00
totalOrderVolume : BigDecimal # probably remove due to inconsistencies and imposibility to calculate
2021-10-28 18:48:53 +02:00
}
2021-09-13 15:20:29 +02:00
type MetadataUpdate @entity {
id : ID ! # update tx + datatokenAddress
2021-11-04 16:00:43 +01:00
datatoken : Token !
2021-09-13 15:20:29 +02:00
datatokenAddress : String !
userAddress : String !
block : Int !
2021-11-10 13:47:44 +01:00
createdTimestamp : Int !
2021-09-13 15:20:29 +02:00
tx : Bytes !
}