fix lp fee and publish market fee (#368)

* add lp fee

* add publish market fee

* fix lint
This commit is contained in:
mihaisc 2022-03-01 14:12:15 +02:00 committed by GitHub
parent ab2d80429a
commit 1cfe520dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 9 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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
}