diff --git a/schema.graphql b/schema.graphql index 5ba2535..3b6c75d 100644 --- a/schema.graphql +++ b/schema.graphql @@ -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 } diff --git a/src/mappings/pool.ts b/src/mappings/pool.ts index 2bf21eb..6022e30 100644 --- a/src/mappings/pool.ts +++ b/src/mappings/pool.ts @@ -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 diff --git a/src/mappings/utils/poolUtils.ts b/src/mappings/utils/poolUtils.ts index 760e74d..47730c3 100644 --- a/src/mappings/utils/poolUtils.ts +++ b/src/mappings/utils/poolUtils.ts @@ -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 +}