Skip to content
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

Merged
merged 7 commits into from Jan 17, 2023
Merged

Tracking OPC fees #593

merged 7 commits into from Jan 17, 2023

Conversation

jamiehewitt15
Copy link
Member

@jamiehewitt15 jamiehewitt15 commented Jan 3, 2023

Fixes #589

Changes proposed in this PR:

  • Adding oceanFeeAmount to fixedRateExchangeSwap entity
  • Updating tests

@jamiehewitt15 jamiehewitt15 marked this pull request as ready for review January 3, 2023 17:09
@jamiehewitt15 jamiehewitt15 self-assigned this Jan 4, 2023
// Track OPC swap fee
swap.oceanFeeAmount = weiToDecimal(
event.params.oceanFeeAmount.toBigDecimal(),
BigInt.fromI32(18).toI32()
Copy link
Member

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')
Copy link
Member

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 ?

Copy link
Member Author

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

@alexcos20
Copy link
Member

I know that original issue was about OPFC fees, but let's add marketFeeAmount and consumeMarketFeeAmount as well

@jamiehewitt15
Copy link
Member Author

I know that original issue was about OPFC fees, but let's add marketFeeAmount and consumeMarketFeeAmount as well

@alexcos20 I've added them, can you let me know if you're happy with the changes?

@alexcos20
Copy link
Member

lgtm, we can merge it
Thanks

@jamiehewitt15 jamiehewitt15 merged commit 9c56b00 into main Jan 17, 2023
@jamiehewitt15 jamiehewitt15 deleted the issue-589-OPC-fees branch January 17, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FixedRateExchange: add OPC fees to fixedRateExchangeSwap entity
2 participants