2020-12-02 11:07:09 +01:00
|
|
|
type PoolFactory @entity {
|
2021-07-30 09:36:44 +02:00
|
|
|
id: ID!
|
2021-09-02 11:08:47 +02:00
|
|
|
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
|
|
|
|
totalSwapFee: [TokenValuePair] # 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
|
|
|
|
|
2021-07-30 09:36:44 +02:00
|
|
|
pools: [Pool!] @derivedFrom(field: "factoryID")
|
2020-11-20 13:12:02 +01:00
|
|
|
}
|
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
|
2021-07-30 09:36:44 +02:00
|
|
|
type Global @entity {
|
|
|
|
id: ID!
|
2021-09-02 11:08:47 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-07-30 09:36:44 +02:00
|
|
|
totalOrderVolume: BigDecimal
|
2021-09-02 11:08:47 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type TokenValuePair @entity {
|
|
|
|
|
|
|
|
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
|
2021-07-30 09:36:44 +02:00
|
|
|
}
|
2021-05-13 08:19:21 +02:00
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
|
|
|
|
|
2021-07-30 09:36:44 +02:00
|
|
|
type Pool @entity {
|
|
|
|
id: ID! # Pool address
|
2021-09-02 11:08:47 +02:00
|
|
|
factoryID --> poolFactory: PoolFactory!
|
2021-07-30 09:36:44 +02:00
|
|
|
controller: Bytes! # Controller address
|
2021-09-02 11:08:47 +02:00
|
|
|
publicSwap --> isPublicSwap: Boolean! # isPublicSwap
|
|
|
|
finalized --> isFinalized: Boolean! # isFinalized
|
|
|
|
|
|
|
|
// will be able to change in v4, set by market or maybe by user
|
2021-07-30 09:36:44 +02:00
|
|
|
symbol: String # Pool token symbol
|
2021-09-02 11:08:47 +02:00
|
|
|
// will be a user inputed name
|
2021-07-30 09:36:44 +02:00
|
|
|
name: String # Pool token name
|
|
|
|
cap: BigInt # Maximum supply if any
|
2021-09-02 11:08:47 +02:00
|
|
|
active --> isActive: Boolean! # isActive
|
2021-07-30 09:36:44 +02:00
|
|
|
swapFee: BigDecimal! # Swap Fees
|
|
|
|
|
|
|
|
totalWeight: BigDecimal!
|
|
|
|
totalShares: BigDecimal! # Total pool token shares
|
2021-09-02 11:08:47 +02:00
|
|
|
totalSwapVolume: BigDecimal! # Total swap volume in main token
|
|
|
|
totalSwapFee: BigDecimal! # Total swap fee in main token
|
2021-07-30 09:36:44 +02:00
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
valueLocked: BigDecimal! # value locked in pool expressed in main token (captures both Ocean and Datatoken)
|
|
|
|
//will be on token
|
2021-07-30 09:36:44 +02:00
|
|
|
datatokenReserve: BigDecimal! # Total pool reserve of Datatoken
|
2021-09-02 11:08:47 +02:00
|
|
|
// will be on token
|
|
|
|
mainTokenReserve: BigDecimal! # Total pool reserve of main token
|
|
|
|
|
2021-07-30 09:36:44 +02:00
|
|
|
spotPrice: BigDecimal!
|
|
|
|
consumePrice: BigDecimal!
|
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
// remove
|
2021-07-30 09:36:44 +02:00
|
|
|
tokenCount: BigInt! # Number of tokens in the pool
|
2021-09-02 11:08:47 +02:00
|
|
|
// remove
|
2021-07-30 09:36:44 +02:00
|
|
|
holderCount: BigInt! # Number of addresses holding a positive balance of pool shares
|
2021-09-02 11:08:47 +02:00
|
|
|
|
|
|
|
// what is the point of the counts, we never used them => remove
|
2021-07-30 09:36:44 +02:00
|
|
|
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
|
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
// remove
|
2021-07-30 09:36:44 +02:00
|
|
|
datatokenAddress: String!
|
2021-09-02 11:08:47 +02:00
|
|
|
|
2021-07-30 09:36:44 +02:00
|
|
|
createTime: Int! # Block time pool was created
|
|
|
|
tx: Bytes # Pool creation transaction id
|
2021-09-02 11:08:47 +02:00
|
|
|
block
|
2021-07-30 09:36:44 +02:00
|
|
|
|
|
|
|
tokens: [PoolToken!] @derivedFrom(field: "poolId")
|
|
|
|
shares: [PoolShare!] @derivedFrom(field: "poolId")
|
|
|
|
transactions: [PoolTransaction!] @derivedFrom(field: "poolAddress")
|
2021-09-02 11:08:47 +02:00
|
|
|
//this doesn't make sens, probably here because we had to link to pool
|
2021-07-30 09:36:44 +02:00
|
|
|
transactionsTokenValues: [PoolTransactionTokenValues!] @derivedFrom(field: "poolAddress")
|
2020-11-20 13:12:02 +01:00
|
|
|
}
|
|
|
|
|
2021-07-29 10:55:48 +02:00
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//PoolToken - all good as it is
|
|
|
|
|
2020-11-20 13:12:02 +01:00
|
|
|
type PoolToken @entity {
|
2021-07-29 10:55:48 +02:00
|
|
|
id: ID! # poolId + token address
|
2021-09-02 11:08:47 +02:00
|
|
|
// can be on multiple pools, should remove
|
2021-07-29 10:55:48 +02:00
|
|
|
poolId: Pool!
|
|
|
|
isDatatoken: Boolean!
|
|
|
|
address: String
|
|
|
|
tokenId: Datatoken
|
|
|
|
tokenAddress: String
|
|
|
|
balance: BigDecimal!
|
|
|
|
denormWeight: BigDecimal!
|
|
|
|
symbol: String
|
|
|
|
name: String
|
|
|
|
decimals: Int
|
2020-11-20 13:12:02 +01:00
|
|
|
}
|
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
// not sure if we should keep both PoolToken and Datatoken
|
|
|
|
type Datatoken @entity {
|
|
|
|
id: ID! # token address
|
|
|
|
factoryID: DatatokenFactory!
|
|
|
|
|
|
|
|
symbol: String
|
|
|
|
name: String
|
|
|
|
decimals: Int!
|
|
|
|
address: String!
|
|
|
|
cap: BigDecimal!
|
|
|
|
supply: BigDecimal!
|
|
|
|
minter: String!
|
|
|
|
publisher: String!
|
|
|
|
|
|
|
|
// do we care about this?
|
|
|
|
holderCount: BigInt! # Number of addresses holding a balance of datatoken
|
|
|
|
orderCount: BigInt! # Number of orders executed for this dataset
|
|
|
|
|
|
|
|
// remove, doesn't make any sense, especially in v4
|
|
|
|
metadataUpdateCount: BigInt!
|
|
|
|
|
|
|
|
// array
|
|
|
|
orderVolume: BigDecimal
|
|
|
|
createTime: Int! # Block time datatoken was created
|
|
|
|
tx: Bytes # Datatoken creation transaction id
|
|
|
|
|
|
|
|
balances: [TokenBalance!] @derivedFrom(field: "datatokenId")
|
|
|
|
orders: [TokenOrder!] @derivedFrom(field: "datatokenId")
|
|
|
|
updates: [MetadataUpdate!] @derivedFrom(field: "datatokenId") # list of MetadataUpdate objects
|
|
|
|
}
|
|
|
|
|
|
|
|
// if we have 2 ,we can check if union works
|
|
|
|
union Token = PoolToken | Datatoken
|
2021-07-29 10:55:48 +02:00
|
|
|
|
|
|
|
|
2020-11-20 13:12:02 +01:00
|
|
|
type PoolShare @entity {
|
2021-05-13 08:19:21 +02:00
|
|
|
id: ID! # poolId + userAddress
|
2021-09-02 11:08:47 +02:00
|
|
|
userAddress -> user: User!
|
|
|
|
poolId --> pool: Pool!
|
2021-05-13 08:19:21 +02:00
|
|
|
balance: BigDecimal!
|
2020-11-20 13:12:02 +01:00
|
|
|
}
|
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
// Will be replaced with a generic PoolTokenValue WIP
|
|
|
|
|
2020-12-02 11:07:09 +01:00
|
|
|
type PoolTransactionTokenValues @entity {
|
2021-05-13 08:19:21 +02:00
|
|
|
id: ID! # pool tx + tokenAddress
|
|
|
|
txId: PoolTransaction!
|
2021-09-02 11:08:47 +02:00
|
|
|
|
|
|
|
// should be an array of PoolToken
|
2021-05-13 08:19:21 +02:00
|
|
|
poolToken: PoolToken!
|
2021-09-02 11:08:47 +02:00
|
|
|
// not sure if needed
|
2021-05-13 08:19:21 +02:00
|
|
|
poolAddress: Pool!
|
2021-09-02 11:08:47 +02:00
|
|
|
//not sure if needed
|
2021-05-13 08:19:21 +02:00
|
|
|
userAddress: User!
|
2021-09-02 11:08:47 +02:00
|
|
|
|
|
|
|
// we will have the poolToken array, what will this be?
|
2021-05-13 08:19:21 +02:00
|
|
|
tokenAddress: String!
|
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
// value of what?
|
2021-05-13 08:19:21 +02:00
|
|
|
value: BigDecimal!
|
2021-09-02 11:08:47 +02:00
|
|
|
|
|
|
|
// should be an array if we keep this
|
2021-05-13 08:19:21 +02:00
|
|
|
tokenReserve: BigDecimal!
|
|
|
|
feeValue: BigDecimal! # Swap fee value in OCEAN
|
|
|
|
type: String!
|
2020-11-20 13:12:02 +01:00
|
|
|
}
|
|
|
|
|
2020-12-02 11:07:09 +01:00
|
|
|
type PoolTransaction @entity {
|
2021-05-13 08:19:21 +02:00
|
|
|
id: ID! # pool tx
|
2021-09-02 11:08:47 +02:00
|
|
|
poolAddress --> pool: Pool
|
|
|
|
userAddress --> user: User # User address that initiates the swap
|
|
|
|
poolAddressStr --> poolAddress: String!
|
|
|
|
userAddressStr --> userAddress: String!
|
2021-05-13 08:19:21 +02:00
|
|
|
|
|
|
|
sharesTransferAmount: BigDecimal! #
|
|
|
|
sharesBalance: BigDecimal!
|
|
|
|
|
|
|
|
spotPrice: BigDecimal!
|
2021-09-02 11:08:47 +02:00
|
|
|
// should not be here
|
2021-05-13 08:19:21 +02:00
|
|
|
consumePrice: BigDecimal!
|
|
|
|
tx: Bytes!
|
|
|
|
event: String
|
|
|
|
block: Int!
|
|
|
|
timestamp: Int!
|
|
|
|
gasUsed: BigDecimal!
|
|
|
|
gasPrice: BigDecimal!
|
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
// should be an array, we will not have only ocean, it will be the tokens array
|
2021-05-13 08:19:21 +02:00
|
|
|
oceanReserve: BigDecimal!
|
|
|
|
datatokenReserve: BigDecimal!
|
|
|
|
|
|
|
|
tokens: [PoolTransactionTokenValues!] @derivedFrom(field: "txId")
|
2020-11-20 13:12:02 +01:00
|
|
|
}
|
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
|
|
|
|
// we will have 2 dt factories ?
|
2020-12-02 11:07:09 +01:00
|
|
|
type DatatokenFactory @entity {
|
2021-05-13 08:19:21 +02:00
|
|
|
id: ID!
|
2020-12-02 11:07:09 +01:00
|
|
|
|
2021-05-13 08:19:21 +02:00
|
|
|
tokenCount: Int! # Number of datatokens
|
|
|
|
datatokens: [Datatoken!] @derivedFrom(field: "factoryID")
|
2020-11-26 07:38:08 +01:00
|
|
|
}
|
|
|
|
|
2021-03-04 11:38:20 +01:00
|
|
|
|
|
|
|
type MetadataUpdate @entity {
|
2021-05-13 08:19:21 +02:00
|
|
|
id: ID! # update tx + datatokenAddress
|
|
|
|
datatokenId: Datatoken!
|
2021-03-04 11:38:20 +01:00
|
|
|
|
2021-05-13 08:19:21 +02:00
|
|
|
datatokenAddress: String!
|
|
|
|
userAddress: String!
|
2021-03-04 11:38:20 +01:00
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
//all fields from the market edit
|
|
|
|
name
|
|
|
|
description
|
|
|
|
author
|
|
|
|
links
|
|
|
|
timeout
|
|
|
|
|
|
|
|
|
2021-05-13 08:19:21 +02:00
|
|
|
block: Int!
|
|
|
|
timestamp: Int!
|
|
|
|
tx: Bytes!
|
2020-11-26 07:38:08 +01:00
|
|
|
}
|
|
|
|
|
2021-09-02 11:08:47 +02:00
|
|
|
type Asset {
|
|
|
|
|
|
|
|
did
|
|
|
|
name
|
|
|
|
description
|
|
|
|
author
|
|
|
|
services ? [ access, compute ] ?
|
|
|
|
|
|
|
|
datatoken : Datatoken
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-26 12:10:45 +01:00
|
|
|
type TokenOrder @entity {
|
2021-05-13 08:19:21 +02:00
|
|
|
id: ID! # datatokenId + userAddress + tx
|
|
|
|
datatokenId: Datatoken!
|
|
|
|
|
|
|
|
consumer: User!
|
|
|
|
payer: User!
|
|
|
|
amount: BigDecimal!
|
|
|
|
serviceId: Int!
|
|
|
|
marketFeeCollector: User
|
|
|
|
marketFee: BigDecimal!
|
|
|
|
|
|
|
|
timestamp: Int!
|
|
|
|
tx: Bytes
|
|
|
|
block: Int!
|
2020-11-26 12:10:45 +01:00
|
|
|
}
|
|
|
|
|
2020-11-26 07:38:08 +01:00
|
|
|
type TokenBalance @entity {
|
2021-05-13 08:19:21 +02:00
|
|
|
id: ID! # datatokenId + userAddress
|
|
|
|
userAddress: User!
|
|
|
|
datatokenId: Datatoken!
|
|
|
|
balance: BigDecimal!
|
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
|
|
|
|
datatokenAddress: Datatoken
|
|
|
|
userAddress: User
|
|
|
|
|
|
|
|
block: Int!
|
|
|
|
gasUsed: BigDecimal!
|
|
|
|
gasPrice: BigDecimal!
|
|
|
|
timestamp: Int!
|
|
|
|
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!
|
|
|
|
|
|
|
|
sharesOwned: [PoolShare!] @derivedFrom(field: "userAddress")
|
|
|
|
tokenBalancesOwned: [TokenBalance!] @derivedFrom(field: "userAddress")
|
|
|
|
tokensOwned: [Datatoken!] @derivedFrom(field: "minter")
|
|
|
|
poolTransactions: [PoolTransaction!] @derivedFrom(field: "userAddress")
|
|
|
|
poolTransactionsTokenValues: [PoolTransactionTokenValues!]
|
|
|
|
@derivedFrom(field: "userAddress")
|
|
|
|
tokenTransactions: [TokenTransaction!] @derivedFrom(field: "userAddress")
|
|
|
|
orders: [TokenOrder!] @derivedFrom(field: "payer")
|
|
|
|
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-05-13 08:19:21 +02:00
|
|
|
id: ID! # fixed rate exchange id
|
|
|
|
exchangeOwner: User!
|
|
|
|
datatoken: Datatoken!
|
2021-09-02 11:08:47 +02:00
|
|
|
// will be a token not just an address
|
2021-05-13 08:19:21 +02:00
|
|
|
baseToken: String!
|
2021-09-02 11:08:47 +02:00
|
|
|
// no need for this, since it will be on token
|
2021-08-13 16:04:18 +02:00
|
|
|
baseTokenSymbol: String!
|
2021-05-13 08:19:21 +02:00
|
|
|
rate: BigDecimal!
|
|
|
|
active: Boolean!
|
|
|
|
updates: [FixedRateExchangeUpdate!] @derivedFrom(field: "exchangeId")
|
|
|
|
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
|
2021-03-10 22:36:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type FixedRateExchangeUpdate @entity {
|
2021-05-13 08:19:21 +02:00
|
|
|
id: ID!
|
|
|
|
exchangeId: FixedRateExchange!
|
|
|
|
oldRate: BigDecimal!
|
|
|
|
newRate: BigDecimal!
|
|
|
|
oldActive: Boolean!
|
|
|
|
newActive: Boolean!
|
|
|
|
block: Int!
|
|
|
|
timestamp: Int!
|
|
|
|
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!
|
|
|
|
timestamp: Int!
|
|
|
|
tx: Bytes!
|
|
|
|
}
|
|
|
|
|
|
|
|
type Dispenser @entity {
|
|
|
|
id: ID! # dispenser datatoken
|
|
|
|
active: Boolean!
|
|
|
|
owner: User!
|
|
|
|
minterApproved: Boolean!
|
|
|
|
isTrueMinter: Boolean!
|
|
|
|
maxTokens: BigDecimal!
|
|
|
|
maxBalance: BigDecimal!
|
|
|
|
balance: BigDecimal!
|
|
|
|
datatoken: Datatoken!
|
|
|
|
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenserId")
|
|
|
|
}
|
|
|
|
|
|
|
|
type DispenserTransaction @entity {
|
|
|
|
id: ID!
|
|
|
|
dispenserId: Dispenser!
|
|
|
|
datatoken: Datatoken!
|
|
|
|
user: User!
|
|
|
|
amount: BigDecimal!
|
|
|
|
block: Int!
|
|
|
|
timestamp: Int!
|
|
|
|
tx: Bytes!
|
|
|
|
type: String!
|
|
|
|
}
|