mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
fix lp fee and publish market fee (#368)
* add lp fee * add publish market fee * fix lint
This commit is contained in:
parent
ab2d80429a
commit
1cfe520dad
@ -135,11 +135,15 @@ type Pool @entity {
|
||||
datatokenLiquidity: BigDecimal!
|
||||
datatokenWeight: BigDecimal!
|
||||
|
||||
"publisher market fee : SWAP, JOIN , EXIT"
|
||||
marketSwapFee: BigDecimal!
|
||||
"publisher market fee value"
|
||||
publishMarketSwapFee: BigDecimal!
|
||||
"publisher market fee total amount"
|
||||
publishMarketSwapFeeAmount: BigDecimal
|
||||
|
||||
"liquidity provider fee"
|
||||
liquidityProviderFee: BigDecimal!
|
||||
"Liquidty provider fee value"
|
||||
liquidityProviderSwapFee: BigDecimal
|
||||
"liquidity provider fee total amount"
|
||||
liquidityProviderSwapFeeAmount: BigDecimal!
|
||||
|
||||
"OPF Fee percent, fee that goes to Ocean Protocol Foundation : SWAP"
|
||||
opcFee: BigDecimal!
|
||||
@ -177,11 +181,8 @@ type Pool @entity {
|
||||
"address of the market where the datatoken was created. This address collects market fees."
|
||||
publishMarketFeeAddress: String
|
||||
|
||||
"fee amount. Fixed value, expressed in wei in contracts, needs conversion in decimals."
|
||||
publishMarketSwapFee: BigDecimal
|
||||
|
||||
|
||||
"LP fee amount. Fixed value, expressed in wei in contracts, needs conversion in decimals."
|
||||
liquidityProviderSwapFee: BigDecimal
|
||||
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,9 @@ import {
|
||||
getPool,
|
||||
getPoolTransaction,
|
||||
getPoolShare,
|
||||
getPoolSnapshot
|
||||
getPoolSnapshot,
|
||||
getPoolLpSwapFee,
|
||||
getPoolPublisherMarketFee
|
||||
} from './utils/poolUtils'
|
||||
import { getToken } from './utils/tokenUtils'
|
||||
import { getUser } from './utils/userUtils'
|
||||
@ -219,6 +221,12 @@ export function handleSetup(event: LOG_SETUP): void {
|
||||
pool.save()
|
||||
poolTx.save()
|
||||
|
||||
const lpFee = getPoolLpSwapFee(event.address)
|
||||
pool.liquidityProviderSwapFee = lpFee
|
||||
const publisherMarketFee = getPoolPublisherMarketFee(event.address)
|
||||
pool.publishMarketSwapFee = publisherMarketFee
|
||||
|
||||
pool.save()
|
||||
const poolSnapshot = getPoolSnapshot(pool.id, event.block.timestamp.toI32())
|
||||
poolSnapshot.spotPrice = spotPrice
|
||||
poolSnapshot.baseTokenLiquidity = pool.baseTokenLiquidity
|
||||
|
@ -128,3 +128,16 @@ export function getPoolSnapshot(
|
||||
|
||||
return snapshot
|
||||
}
|
||||
|
||||
export function getPoolLpSwapFee(poolAddress: Address): BigDecimal {
|
||||
const contract = BPool.bind(poolAddress)
|
||||
const lpFeeWei = contract.getSwapFee()
|
||||
const lpFee = weiToDecimal(lpFeeWei.toBigDecimal(), 18)
|
||||
return lpFee
|
||||
}
|
||||
export function getPoolPublisherMarketFee(poolAddress: Address): BigDecimal {
|
||||
const contract = BPool.bind(poolAddress)
|
||||
const marketFeeWei = contract.getMarketFee()
|
||||
const marketFee = weiToDecimal(marketFeeWei.toBigDecimal(), 18)
|
||||
return marketFee
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user