Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

[Subsidy] - Show fee breakdown adjusted for subsidy! #2590

Merged
merged 3 commits into from
Mar 25, 2022

Conversation

W3stside
Copy link
Contributor

@W3stside W3stside commented Mar 25, 2022

Summary

Adjusts fee breakdown tooltip to show optimistically the fees discounted

Explanation of maths:

  • we get fee amount from backend, we have to be optimistic and assume the fee was/is adjusted and returned properly factoring in discount.
  • we take the returned feeAmount and multiply that amount by 1 + discount to get the preSubsidyFeeAmount and show that as the crossed out "previous fee" even tho that amount is never officially returned from the backend
  • e.g user has 35% discount
  • trading GNO <> WETH
  • fee is shown as 0.0046 WETH (backend returned amount)
  • to calculate preSubsidyFeeAmount we simply do: 0.0046 * 1.35 // 0.00621 (in atomic maths using bigint)

NO DISCOUNT
image

35% DISCOUNT
image

To Test

  1. use an acct with no discount
  2. check fee breakdown
  3. switch to an account with discount
  4. check fee breakdown
  5. should match screenshots

@W3stside W3stside requested review from a team March 25, 2022 13:16
@W3stside W3stside added the RELEASE Included in the release that is being closed label Mar 25, 2022
@github-actions
Copy link
Contributor

  • 🔭 GP Swap: CoW Protocol v2 Swap UI

@W3stside
Copy link
Contributor Author

Let's post merge review I'd like this in the Kaffeekränzchen

@W3stside W3stside merged commit d8df488 into release/1.12.0 Mar 25, 2022
@elena-zh
Copy link

elena-zh commented Mar 25, 2022

Changes LGTM.
However, I find some inconsistency in the tooltip values displaying. In this tooltip we have one label and one value in green. Maybe we should have Label+value in green if we want to highlight something?
image

@elena-zh
Copy link

elena-zh commented Mar 25, 2022

Calculation seems to be a bit incorrect. In order to see an amount without a discount, it is better to divide an amount with a discount by amount (1-%discount/100). So in the case when discount is 25%, we need to divide an amount with discount by 0.75:
image

So in order to get fee with 25% discount of 2427.7727, original fee should be 3237,0303 (= 2427.7727/0.75)

@anxolin
Copy link
Contributor

anxolin commented Mar 25, 2022

@W3stside I think your math is wrong.

Is not 1+fee, it's 1/(1-fee)

explanation:
IMG_5284

@anxolin
Copy link
Contributor

anxolin commented Mar 25, 2022

Also, verified with Anna, and she thinks is better to not show the older price at all. So at the end not even the calculation is needed.

Just showing the discounted amount (basically not show the original fee)
image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
RELEASE Included in the release that is being closed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants