mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
up
This commit is contained in:
parent
64cdaf8993
commit
b469174136
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -199,13 +199,13 @@ type PoolTransaction @entity {
|
|||||||
"number of shares transfered"
|
"number of shares transfered"
|
||||||
sharesTransferAmount: BigDecimal
|
sharesTransferAmount: BigDecimal
|
||||||
|
|
||||||
"pool fee percent, fee goes to all liquidity providers : SWAP, JOIN , EXIT"
|
"pool fee value, fee goes to all liquidity providers : SWAP, JOIN , EXIT"
|
||||||
poolFee: BigDecimal!
|
poolFee: BigDecimal!
|
||||||
|
|
||||||
"OPF Fee percent, fee that goes to Ocean Protocol Foundation : SWAP"
|
"OPF Fee value, fee that goes to Ocean Protocol Foundation : SWAP"
|
||||||
opfFee: BigDecimal!
|
opfFee: BigDecimal!
|
||||||
|
|
||||||
"fee that goes to the publishing market"
|
"market fee value, fee that goes to the publishing market"
|
||||||
marketFee: BigDecimal!
|
marketFee: BigDecimal!
|
||||||
|
|
||||||
"block time when pool was created"
|
"block time when pool was created"
|
||||||
@ -232,8 +232,9 @@ type PoolTransaction @entity {
|
|||||||
datatokenValue: BigDecimal
|
datatokenValue: BigDecimal
|
||||||
}
|
}
|
||||||
|
|
||||||
type Order @entity { # renamed from TokenOrder to Order
|
type Order @entity {
|
||||||
id: ID! # datatokenId + userAddress + tx
|
"transaction hash - token address - from address"
|
||||||
|
id: ID!
|
||||||
token: Token!
|
token: Token!
|
||||||
|
|
||||||
consumer: User!
|
consumer: User!
|
||||||
@ -243,11 +244,11 @@ type Order @entity { # renamed from Toke
|
|||||||
|
|
||||||
|
|
||||||
# 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)
|
||||||
publishingMarketAddress: User
|
publishingMarket: User
|
||||||
publishingMarketToken: Token #
|
publishingMarketToken: Token #
|
||||||
publishingMarketAmmount: BigDecimal #call contract to get fee ammount
|
publishingMarketAmmount: BigDecimal #call contract to get fee ammount
|
||||||
|
|
||||||
consumerMarketAddress: User
|
consumerMarket: User
|
||||||
consumerMarketToken: Token #
|
consumerMarketToken: Token #
|
||||||
consumerMarketAmmount: BigDecimal #call contract to get fee ammount
|
consumerMarketAmmount: BigDecimal #call contract to get fee ammount
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
import {
|
|
||||||
MinterApproved,
|
|
||||||
OrderStarted
|
|
||||||
} from '../@types/ERC20Template/ERC20Template'
|
|
||||||
// TODO: no events in contracts , it's ok !!
|
|
||||||
export function handleMinterApproved(event: MinterApproved): void {}
|
|
||||||
|
|
||||||
// TODO: to complicated at this point, return after basic events implemented ¯\_(ツ)_/¯
|
|
||||||
export function handleOrderStarted(event: OrderStarted): void {}
|
|
78
src/mappings/erc20Templates.ts
Normal file
78
src/mappings/erc20Templates.ts
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
import { OrderStarted } from '../@types/ERC20Template/ERC20Template'
|
||||||
|
import { Order } from '../@types/schema'
|
||||||
|
import {
|
||||||
|
ConsumeMarketFees,
|
||||||
|
PublishMarketFees
|
||||||
|
} from '../@types/templates/ERC20Template/ERC20Template'
|
||||||
|
import { integer } from './utils/constants'
|
||||||
|
import { weiToDecimal } from './utils/generic'
|
||||||
|
import { getToken } from './utils/tokenUtils'
|
||||||
|
import { getUser } from './utils/userUtils'
|
||||||
|
|
||||||
|
function getOrderId(tx: string, tokenAddress: string, fromAddress: string) {
|
||||||
|
return `${tx}-${tokenAddress}-${fromAddress}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleOrderStarted(event: OrderStarted): void {
|
||||||
|
const order = new Order(
|
||||||
|
getOrderId(
|
||||||
|
event.transaction.hash.toHex(),
|
||||||
|
event.address.toHex(),
|
||||||
|
event.transaction.from.toHex()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
const token = getToken(event.address.toHex())
|
||||||
|
order.token = token.id
|
||||||
|
token.orderCount = token.orderCount.plus(integer.ONE)
|
||||||
|
|
||||||
|
const consumer = getUser(event.params.consumer.toHex())
|
||||||
|
order.consumer = consumer.id
|
||||||
|
|
||||||
|
const payer = getUser(event.params.payer.toHex())
|
||||||
|
order.payer = payer.id
|
||||||
|
|
||||||
|
order.amount = weiToDecimal(
|
||||||
|
event.params.amount.toBigDecimal(),
|
||||||
|
token.decimals
|
||||||
|
)
|
||||||
|
|
||||||
|
order.serviceId = event.params.serviceId
|
||||||
|
|
||||||
|
const publishMarket = getUser(event.params.publishMarketAddress.toHex())
|
||||||
|
order.publishingMarket = publishMarket.id
|
||||||
|
|
||||||
|
const consumeMarket = getUser(event.params.consumeFeeMarketAddress.toHex())
|
||||||
|
order.consumerMarket = consumeMarket.id
|
||||||
|
|
||||||
|
order.createdTimestamp = event.block.timestamp.toI32()
|
||||||
|
order.tx = event.transaction.hash
|
||||||
|
order.block = event.block.number.toI32()
|
||||||
|
|
||||||
|
order.save()
|
||||||
|
token.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handlePublishMarketFees(event: PublishMarketFees): void {
|
||||||
|
const order = Order.load(
|
||||||
|
getOrderId(
|
||||||
|
event.transaction.hash.toHex(),
|
||||||
|
event.address.toHex(),
|
||||||
|
event.transaction.from.toHex()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
order.save()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function handleConsumeMarketFees(event: ConsumeMarketFees): void {
|
||||||
|
const order = Order.load(
|
||||||
|
getOrderId(
|
||||||
|
event.transaction.hash.toHex(),
|
||||||
|
event.address.toHex(),
|
||||||
|
event.transaction.from.toHex()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
order.save()
|
||||||
|
}
|
@ -105,6 +105,7 @@ export function handleDeactivated(event: ExchangeDeactivated): void {
|
|||||||
)
|
)
|
||||||
newExchangeUpdate.oldActive = fixedRateExchange.active
|
newExchangeUpdate.oldActive = fixedRateExchange.active
|
||||||
newExchangeUpdate.newActive = false
|
newExchangeUpdate.newActive = false
|
||||||
|
|
||||||
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
|
||||||
newExchangeUpdate.tx = event.transaction.hash
|
newExchangeUpdate.tx = event.transaction.hash
|
||||||
newExchangeUpdate.block = event.block.number.toI32()
|
newExchangeUpdate.block = event.block.number.toI32()
|
||||||
|
@ -98,7 +98,7 @@ templates:
|
|||||||
kind: ethereum/events
|
kind: ethereum/events
|
||||||
apiVersion: 0.0.5
|
apiVersion: 0.0.5
|
||||||
language: wasm/assemblyscript
|
language: wasm/assemblyscript
|
||||||
file: ./src/mappings/erc20Template.ts
|
file: ./src/mappings/erc20Templates.ts
|
||||||
entities:
|
entities:
|
||||||
- ERC20Template
|
- ERC20Template
|
||||||
abis:
|
abis:
|
||||||
@ -114,7 +114,11 @@ templates:
|
|||||||
- event: OrderStarted(indexed address,address,uint256,uint256,uint256,indexed address,indexed address,uint256)
|
- event: OrderStarted(indexed address,address,uint256,uint256,uint256,indexed address,indexed address,uint256)
|
||||||
handler: handleOrderStarted
|
handler: handleOrderStarted
|
||||||
- event: NewPaymentCollector(indexed address,indexed address,uint256,uint256)
|
- event: NewPaymentCollector(indexed address,indexed address,uint256,uint256)
|
||||||
handler: handlerNewPaymentCollector
|
handler: handleNewPaymentCollector
|
||||||
|
- event: PublishMarketFees(indexed address,indexed address,uint256)
|
||||||
|
handler: handlePublishMarketFees
|
||||||
|
- event: ConsumeMarketFees(indexed address,indexed address,uint256)
|
||||||
|
handler: handleConsumeMarketFees
|
||||||
- kind: ethereum/contract
|
- kind: ethereum/contract
|
||||||
name: BFactory
|
name: BFactory
|
||||||
network: barge
|
network: barge
|
||||||
@ -165,8 +169,8 @@ templates:
|
|||||||
handler: handleBpt
|
handler: handleBpt
|
||||||
- event: Transfer(indexed address,indexed address,uint256)
|
- event: Transfer(indexed address,indexed address,uint256)
|
||||||
handler: handlerBptTransfer
|
handler: handlerBptTransfer
|
||||||
- event: SWAP_FEES(uint,uint,uint,address)
|
# - event: SWAP_FEES(uint,uint,uint,address)
|
||||||
handler: handlerSwapFees
|
# handler: handlerSwapFees
|
||||||
|
|
||||||
features:
|
features:
|
||||||
- nonFatalErrors
|
- nonFatalErrors
|
||||||
|
Loading…
Reference in New Issue
Block a user