Fix and rename

This commit is contained in:
trizin 2023-05-04 16:02:48 +03:00 committed by GitHub
parent c0fe3cd6b4
commit 70846eafe2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 198 additions and 206 deletions

View File

@ -1,130 +1,130 @@
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!
"address of ERC721 that owns the token, valid only for datatokens"
nft: Nft
"array of addresses with minter role" "address of ERC721 that owns the token, valid only for datatokens"
minter: [String!] nft: Nft
"array of addresses with payment manager minter role" "array of addresses with minter role"
paymentManager: [String!] minter: [String!]
"address that collects the payments (NOT fees)" "array of addresses with payment manager minter role"
paymentCollector: String paymentManager: [String!]
"address of the market where the datatoken was created. This address collects market fees." "address that collects the payments (NOT fees)"
publishMarketFeeAddress: String paymentCollector: String
"adreess of fee token (can be Ocean, ETH, etc.)" "address of the market where the datatoken was created. This address collects market fees."
publishMarketFeeToken: String publishMarketFeeAddress: String
"fee amount. Fixed value." "adreess of fee token (can be Ocean, ETH, etc.)"
publishMarketFeeAmount: BigDecimal publishMarketFeeToken: String
"template ID of the datatoken" "fee amount. Fixed value."
templateId: Int publishMarketFeeAmount: BigDecimal
"number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts" "template ID of the datatoken"
holderCount: BigInt! templateId: Int
"number of orders executed for this datatoken" "number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts"
orderCount: BigInt! holderCount: BigInt!
"orders created with the datatoken, only available for datatokens" "number of orders executed for this datatoken"
orders: [Order!] @derivedFrom(field:"datatoken") orderCount: BigInt!
"fixed rate exchanges, only available for datatokens" "orders created with the datatoken, only available for datatokens"
fixedRateExchanges: [FixedRateExchange!] @derivedFrom(field:"datatoken") orders: [Order!] @derivedFrom(field: "datatoken")
"dispensers using this token" "fixed rate exchanges, only available for datatokens"
dispensers: [Dispenser!] @derivedFrom(field:"token") fixedRateExchanges: [FixedRateExchange!] @derivedFrom(field: "datatoken")
"block time datatoken was created" "dispensers using this token"
createdTimestamp: Int! dispensers: [Dispenser!] @derivedFrom(field: "token")
"datatoken creation transaction id" "block time datatoken was created"
tx: String! createdTimestamp: Int!
"block number when it was created" "datatoken creation transaction id"
block: Int! tx: String!
lastPriceToken: Token "block number when it was created"
lastPriceValue: BigDecimal! block: Int!
lastPriceToken: Token
lastPriceValue: BigDecimal!
} }
"utility type" "utility type"
type TokenValuePair @entity { type TokenValuePair @entity {
"address of the token" "address of the token"
id : ID! id: ID!
token : Token! token: Token!
value : BigDecimal! value: BigDecimal!
} }
type Nft @entity{ type Nft @entity {
"nft address" "nft address"
id: ID! id: ID!
symbol: String! symbol: String!
name: String! name: String!
tokenUri: String tokenUri: String
"address of the owner of the nft"
owner: User!
"address of the creator of the nft"
creator: User!
"same as id, it's just for easy discoverability" "address of the owner of the nft"
address: String! owner: User!
"address of the creator of the nft"
creator: User!
"provider url that can decrypt the ddo" "same as id, it's just for easy discoverability"
providerUrl: String address: String!
"state of the asset (described in docs)" "provider url that can decrypt the ddo"
assetState: Int! providerUrl: String
managerRole: [String!] "state of the asset (described in docs)"
erc20DeployerRole: [String!] assetState: Int!
storeUpdateRole: [String!]
"addresses that can update the metadata"
metadataRole: [String!]
"template address" managerRole: [String!]
template: String! erc20DeployerRole: [String!]
storeUpdateRole: [String!]
"addresses that can update the metadata"
metadataRole: [String!]
"set if NFT is transferable" "template address"
transferable: Boolean! template: String!
"block time nft was created" "set if NFT is transferable"
createdTimestamp: Int! transferable: Boolean!
"nft creation transaction id"
tx: String!
"block number when it was created"
block: Int
"number of orders executed for all underlying datatokens" "block time nft was created"
orderCount: BigInt! createdTimestamp: Int!
"nft creation transaction id"
tx: String!
"block number when it was created"
block: Int
"has metadata" "number of orders executed for all underlying datatokens"
hasMetadata: Boolean! orderCount: BigInt!
nftData: [NftData!] @derivedFrom(field: "nft") "has metadata"
transferHistory: [NftTransferHistory!] @derivedFrom(field: "nft") hasMetadata: Boolean!
nftData: [NftData!] @derivedFrom(field: "nft")
transferHistory: [NftTransferHistory!] @derivedFrom(field: "nft")
} }
type NftData @entity{ type NftData @entity {
"nft address+key" "nft address+key"
id: ID! id: ID!
nft: Nft! nft: Nft!
key: Bytes key: Bytes
value: Bytes value: Bytes
} }
type OrderReuse @entity { type OrderReuse @entity {
id: ID! id: ID!
@ -138,11 +138,11 @@ type OrderReuse @entity {
"gas price in Wei" "gas price in Wei"
gasPrice: BigInt gasPrice: BigInt
gasUsed: BigDecimal gasUsed: BigDecimal
} }
type Order @entity { type Order @entity {
"transaction hash - token address - from address" "transaction hash - token address - from address"
id: ID! id: ID!
datatoken: Token! datatoken: Token!
consumer: User! consumer: User!
@ -151,18 +151,16 @@ type Order @entity {
serviceIndex: Int! serviceIndex: Int!
nftOwner: User! nftOwner: User!
# the fees will be updated from an event that will be created after (todo) # the fees will be updated from an event that will be created after (todo)
publishingMarket: User publishingMarket: User
publishingMarketToken: Token # publishingMarketToken: Token #
publishingMarketAmmount: BigDecimal #call contract to get fee amount publishingMarketAmmount: BigDecimal #call contract to get fee amount
providerFee: String providerFee: String
providerFeeValidUntil: BigInt providerFeeValidUntil: BigInt
consumerMarket: User consumerMarket: User
consumerMarketToken: Token # consumerMarketToken: Token #
consumerMarketAmmount: BigDecimal #call contract to get fee amount consumerMarketAmmount: BigDecimal #call contract to get fee amount
reuses: [OrderReuse!] @derivedFrom(field: "order") reuses: [OrderReuse!] @derivedFrom(field: "order")
createdTimestamp: Int! createdTimestamp: Int!
@ -182,19 +180,19 @@ type User @entity {
tokenBalancesOwned: [TokenValuePair!] tokenBalancesOwned: [TokenValuePair!]
orders: [Order!] @derivedFrom(field: "payer") orders: [Order!] @derivedFrom(field: "payer")
freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by") freSwaps: [FixedRateExchangeSwap!] @derivedFrom(field: "by")
"total number of orders made by this user" "total number of orders made by this user"
totalOrders: BigInt! totalOrders: BigInt!
"total number of orders made on assets owned by this user" "total number of orders made on assets owned by this user"
totalSales: BigInt! totalSales: BigInt!
} }
type FixedRateExchange @entity { type FixedRateExchange @entity {
"fixed rate exchange id" "fixed rate exchange id"
id: ID! id: ID!
contract: String! contract: String!
exchangeId: String! exchangeId: String!
owner: User! owner: User!
datatoken: Token! datatoken: Token!
baseToken: Token! baseToken: Token!
@ -207,13 +205,13 @@ type FixedRateExchange @entity {
price: BigDecimal! price: BigDecimal!
active: Boolean! active: Boolean!
"amount of total basetokens spent" "amount of total basetokens spent"
totalSwapValue: BigDecimal! totalSwapValue: BigDecimal!
"address that is allowed to swap tokens" "address that is allowed to swap tokens"
allowedSwapper: String allowedSwapper: String
"if the owner allowes the fre to mint" "if the owner allowes the fre to mint"
withMint: Boolean withMint: Boolean
"if the fre has the minter role on the datatoken" "if the fre has the minter role on the datatoken"
isMinter: Boolean isMinter: Boolean
updates: [FixedRateExchangeUpdate!] @derivedFrom(field: "exchangeId") updates: [FixedRateExchangeUpdate!] @derivedFrom(field: "exchangeId")
swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId") swaps: [FixedRateExchangeSwap!] @derivedFrom(field: "exchangeId")
@ -222,12 +220,11 @@ type FixedRateExchange @entity {
tx: String! tx: String!
block: Int! block: Int!
"address of the market where the datatoken was created. This address collects market fees." "address of the market where the datatoken was created. This address collects market fees."
publishMarketFeeAddress: String publishMarketFeeAddress: String
"fee amount. Fixed value"
publishMarketSwapFee: BigDecimal
"fee amount. Fixed value"
publishMarketSwapFee: BigDecimal
} }
type FixedRateExchangeUpdate @entity { type FixedRateExchangeUpdate @entity {
@ -258,39 +255,37 @@ type FixedRateExchangeSwap @entity {
createdTimestamp: Int! createdTimestamp: Int!
tx: String! tx: String!
oceanFeeAmount: BigDecimal! oceanFeeAmount: BigDecimal!
marketFeeAmount: BigDecimal! marketFeeAmount: BigDecimal!
consumeMarketFeeAmount: BigDecimal! consumeMarketFeeAmount: BigDecimal!
} }
type Dispenser @entity { type Dispenser @entity {
"token address" "token address"
id: ID! id: ID!
contract: String! contract: String!
active: Boolean! active: Boolean!
"if using the enterprise template the owner will always be the erc721 factory, for normal template it will a user" "if using the enterprise template the owner will always be the erc721 factory, for normal template it will a user"
owner: String owner: String
token: Token! token: Token!
allowedSwapper: String allowedSwapper: String
isMinter: Boolean isMinter: Boolean
"max tokens that can be dispensed" "max tokens that can be dispensed"
maxTokens: BigDecimal! maxTokens: BigDecimal!
"max balance of requester. If the balance is higher, the dispense is rejected" "max balance of requester. If the balance is higher, the dispense is rejected"
maxBalance: BigDecimal! maxBalance: BigDecimal!
"how many tokens are left" "how many tokens are left"
balance: BigDecimal! balance: BigDecimal!
block: Int! block: Int!
createdTimestamp: Int! createdTimestamp: Int!
tx: String! tx: String!
dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenser") dispenses: [DispenserTransaction!] @derivedFrom(field: "dispenser")
} }
type DispenserTransaction @entity { type DispenserTransaction @entity {
id: ID! id: ID!
dispenser: Dispenser! dispenser: Dispenser!
user: User! user: User!
amount: BigDecimal! amount: BigDecimal!
@ -302,66 +297,67 @@ type DispenserTransaction @entity {
"utility type" "utility type"
type GlobalTotalLiquidityPair @entity { type GlobalTotalLiquidityPair @entity {
"address of the token" "address of the token"
id : ID! id: ID!
globalStatistic: GlobalStatistic! globalStatistic: GlobalStatistic!
token : Token! token: Token!
value : BigDecimal! value: BigDecimal!
} }
"utility type" "utility type"
type GlobalTotalFixedSwapPair @entity { type GlobalTotalFixedSwapPair @entity {
"address of the token" "address of the token"
id : ID! id: ID!
globalStatistic: GlobalStatistic! globalStatistic: GlobalStatistic!
token : Token! token: Token!
value : BigDecimal! value: BigDecimal!
count: BigInt! count: BigInt!
} }
type GlobalStatistic @entity { type GlobalStatistic @entity {
id: ID! id: ID!
"total swap volume for each base token in fixed rate exchanges" "total swap volume for each base token in fixed rate exchanges"
totalFixedSwapVolume: [GlobalTotalFixedSwapPair!] @derivedFrom(field: "globalStatistic") totalFixedSwapVolume: [GlobalTotalFixedSwapPair!]
@derivedFrom(field: "globalStatistic")
"number of total orders. fixed rate exchange orders + dispenser orders"
orderCount: Int!
"total nfts(erc721) created" "number of total orders. fixed rate exchange orders + dispenser orders"
nftCount: Int! orderCount: Int!
"total datatokens (tokens with isDatatoken = true) created"
datatokenCount:Int!
"number of fixed rate exchanges"
fixedCount: Int!
"number of dispensers created" "total nfts(erc721) created"
dispenserCount: Int! nftCount: Int!
"total datatokens (tokens with isDatatoken = true) created"
datatokenCount: Int!
"total ocean locked in veOcean" "number of fixed rate exchanges"
totalOceanLocked:BigDecimal! fixedCount: Int!
"current version" "number of dispensers created"
version: String dispenserCount: Int!
"total ocean locked in veOcean"
totalOceanLocked: BigDecimal!
"current version"
version: String
} }
type OPC @entity { type OPC @entity {
id: ID! id: ID!
"fee in percent for swaps involving OPC approved tokens" "fee in percent for swaps involving OPC approved tokens"
swapOceanFee: BigDecimal swapOceanFee: BigDecimal
"fee in percent for swaps involving non OPC approved tokens" "fee in percent for swaps involving non OPC approved tokens"
swapNonOceanFee: BigDecimal swapNonOceanFee: BigDecimal
"fee in percent taken by OPC from orderFees" "fee in percent taken by OPC from orderFees"
orderFee: BigDecimal orderFee: BigDecimal
"fee in percent taken by OPC from providerFees" "fee in percent taken by OPC from providerFees"
providerFee: BigDecimal providerFee: BigDecimal
approvedTokens: [Token!] approvedTokens: [Token!]
} }
enum NftUpdateType { enum NftUpdateType {
METADATA_CREATED, METADATA_CREATED
METADATA_UPDATED, METADATA_UPDATED
STATE_UPDATED, STATE_UPDATED
TOKENURI_UPDATED TOKENURI_UPDATED
} }
@ -370,10 +366,10 @@ type NftUpdate @entity {
tokenUri: String tokenUri: String
nft: Nft! nft: Nft!
"provider url that can decrypt the ddo" "provider url that can decrypt the ddo"
providerUrl: String providerUrl: String
"user that made the update" "user that made the update"
userAddress: String! userAddress: String!
"state of the asset in this update" "state of the asset in this update"
@ -387,7 +383,7 @@ type NftUpdate @entity {
tx: String! tx: String!
} }
type Template @entity{ type Template @entity {
id: ID! id: ID!
fixedRateTemplates: [String!] fixedRateTemplates: [String!]
dispenserTemplates: [String!] dispenserTemplates: [String!]
@ -395,11 +391,11 @@ type Template @entity{
} }
# Not tracking allocationToId or idToAllocation # Not tracking allocationToId or idToAllocation
type VeAllocateUser @entity{ type VeAllocateUser @entity {
"id = {user}" "id = {user}"
id: ID! id: ID!
veAllocation: [VeAllocation!] @derivedFrom(field: "allocationUser") veAllocation: [VeAllocation!] @derivedFrom(field: "allocationUser")
allocatedTotal: BigDecimal! allocatedTotal: BigDecimal!
block: Int! block: Int!
@ -409,7 +405,7 @@ type VeAllocateUser @entity{
veOcean: VeOCEAN! veOcean: VeOCEAN!
} }
type VeAllocateId @entity{ type VeAllocateId @entity {
"id = {DataNFT Address}-{chain id}" "id = {DataNFT Address}-{chain id}"
id: ID! id: ID!
nftAddress: String! nftAddress: String!
@ -431,7 +427,7 @@ type VeAllocation @entity {
allocationUser: VeAllocateUser! allocationUser: VeAllocateUser!
allocationId: VeAllocateId! allocationId: VeAllocateId!
updates: [VeAllocationUpdate!] @derivedFrom(field: "veAllocation") updates: [VeAllocationUpdate!] @derivedFrom(field: "veAllocation")
allocated: BigDecimal! allocated: BigDecimal!
chainId: BigInt! chainId: BigInt!
@ -444,14 +440,14 @@ type VeAllocation @entity {
} }
enum veAllocationUpdateType { enum veAllocationUpdateType {
SET, SET
REMOVED REMOVED
} }
type VeAllocationUpdate @entity { type VeAllocationUpdate @entity {
"{tx}-{VeAllocation id}" "{tx}-{VeAllocation id}"
id: ID! id: ID!
veAllocation: VeAllocation! veAllocation: VeAllocation!
type: veAllocationUpdateType! type: veAllocationUpdateType!
allocatedTotal: BigDecimal! allocatedTotal: BigDecimal!
@ -469,11 +465,10 @@ type VeDelegation @entity {
tokenId: BigInt! tokenId: BigInt!
amount: BigDecimal! amount: BigDecimal!
lockedAmount: BigDecimal! lockedAmount: BigDecimal!
timeLeft: Int! timeLeftUnlock: Int!
cancelTime: BigInt! cancelTime: BigInt!
expireTime: BigInt! expireTime: BigInt!
updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation") updates: [VeDelegationUpdate!] @derivedFrom(field: "veDelegation")
} }
type VeDelegationUpdate @entity { type VeDelegationUpdate @entity {
@ -487,11 +482,10 @@ type VeDelegationUpdate @entity {
cancelTime: BigInt! cancelTime: BigInt!
expireTime: BigInt! expireTime: BigInt!
"type: CREATE_BOOST = 0, EXTEND_BOOST = 1, BURN_BOOST = 2" "type: CREATE_BOOST = 0, EXTEND_BOOST = 1, BURN_BOOST = 2"
type:Int! type: Int!
veDelegation:VeDelegation! veDelegation: VeDelegation!
} }
type VeOCEAN @entity { type VeOCEAN @entity {
"id = {user address}" "id = {user address}"
id: ID! id: ID!
@ -511,7 +505,7 @@ type VeDeposit @entity {
"id = {user address}-{tx}-{eventIndex}" "id = {user address}-{tx}-{eventIndex}"
id: ID! id: ID!
"veOcean holder" "veOcean holder"
provider:String! provider: String!
"who initiated the tx" "who initiated the tx"
sender: String! sender: String!
"amount of tokens locked" "amount of tokens locked"
@ -519,22 +513,22 @@ type VeDeposit @entity {
"unlock timestamp" "unlock timestamp"
unlockTime: BigInt! unlockTime: BigInt!
"deposit type: DEPOSIT_FOR = 0, CREATE_LOCK_TYPE = 1,INCREASE_LOCK_AMOUNT = 2,INCREASE_UNLOCK_TIME = 3, WITHDRAW = 4" "deposit type: DEPOSIT_FOR = 0, CREATE_LOCK_TYPE = 1,INCREASE_LOCK_AMOUNT = 2,INCREASE_UNLOCK_TIME = 3, WITHDRAW = 4"
type:BigInt! type: BigInt!
timestamp: BigInt! timestamp: BigInt!
block: Int! block: Int!
tx: String! tx: String!
veOcean: VeOCEAN! veOcean: VeOCEAN!
totalOceanLocked:BigDecimal! totalOceanLocked: BigDecimal!
} }
type VeFeeDistributor @entity { type VeFeeDistributor @entity {
"id = contract address" "id = contract address"
id: ID! id: ID!
"token used by FeeDistributor" "token used by FeeDistributor"
token: Token! token: Token!
claims: [VeClaim!] @derivedFrom(field: "VeFeeDistributor") claims: [VeClaim!] @derivedFrom(field: "VeFeeDistributor")
checkpoints: [VeFeeDistributorCheckPoint!] @derivedFrom(field: "VeFeeDistributor") checkpoints: [VeFeeDistributorCheckPoint!]
@derivedFrom(field: "VeFeeDistributor")
} }
type VeFeeDistributorCheckPoint @entity { type VeFeeDistributorCheckPoint @entity {
@ -567,7 +561,7 @@ type VeClaim @entity {
} }
enum DFHistoryType { enum DFHistoryType {
Allocated, Allocated
Claimed Claimed
} }
@ -579,7 +573,6 @@ type DFAvailableClaim @entity {
token: Token! token: Token!
} }
type DFHistory @entity { type DFHistory @entity {
"id = {user-id}-{txId}-{eventId}" "id = {user-id}-{txId}-{eventId}"
id: ID! id: ID!
@ -592,7 +585,6 @@ type DFHistory @entity {
tx: String! tx: String!
} }
type DFReward @entity { type DFReward @entity {
"id = {user address}" "id = {user address}"
id: ID! id: ID!

View File

@ -137,7 +137,7 @@ export function getveDelegation(
veDelegation.receiver = '' veDelegation.receiver = ''
veDelegation.delegator = '' veDelegation.delegator = ''
veDelegation.lockedAmount = BigDecimal.zero() veDelegation.lockedAmount = BigDecimal.zero()
veDelegation.timeLeft = BigInt.zero() veDelegation.timeLeftUnlock = 0
veDelegation.save() veDelegation.save()
} }
return veDelegation return veDelegation

View File

@ -30,7 +30,7 @@ export function handleDelegation(event: DelegateBoost): void {
BigInt.fromI32(18).toI32() BigInt.fromI32(18).toI32()
) )
veDelegation.lockedAmount = delegator.lockedAmount veDelegation.lockedAmount = delegator.lockedAmount
veDelegation.timeLeft = delegator.unlockTime.toI32().minus(ts) veDelegation.timeLeftUnlock = delegator.unlockTime.toI32() - ts
veDelegation.cancelTime = _cancelTime veDelegation.cancelTime = _cancelTime
veDelegation.expireTime = _expireTime veDelegation.expireTime = _expireTime
veDelegation.save() veDelegation.save()