New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking OPC fees #593
Tracking OPC fees #593
Conversation
src/mappings/fixedRateExchange.ts
Outdated
// Track OPC swap fee | ||
swap.oceanFeeAmount = weiToDecimal( | ||
event.params.oceanFeeAmount.toBigDecimal(), | ||
BigInt.fromI32(18).toI32() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPF Fee is always taken in baseToken, so it's not always using 18 decimals.
You should use something like:
swap.oceanFeeAmount= weiToDecimal(
event.params.oceanFeeAmount.toBigDecimal(),
BigInt.fromI32(baseToken.decimals).toI32()
)
and move this code after we have baseToken (like before swap.save() )
@@ -648,6 +650,7 @@ describe('Fixed Rate Exchange tests', async () => { | |||
assert(swaps.block === tx.blockNumber, 'incorrect value for: block') | |||
assert(swaps.createdTimestamp >= time, 'incorrect: createdTimestamp') | |||
assert(swaps.createdTimestamp < time + 25, 'incorrect: createdTimestamp 2') | |||
assert(swaps.oceanFeeAmount === oceanFeeAmount, 'incorrect: oceanFeeAmount') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should compare the value from event to whatever is stored on subgraph
Let's not do math here, because that can change anytime
IE:
const oceanFeeAmount = String((Number(dtAmount) * Number(feeAmount)) / 100)
what if OPCFee amount is changed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good point. I've updated this, thanks for the feedback
…value stored in the subgraph
I know that original issue was about OPFC fees, but let's add marketFeeAmount and consumeMarketFeeAmount as well |
…tocol/ocean-subgraph into issue-589-OPC-fees
@alexcos20 I've added them, can you let me know if you're happy with the changes? |
lgtm, we can merge it |
Fixes #589
Changes proposed in this PR:
oceanFeeAmount
tofixedRateExchangeSwap
entity