Conversation
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Collaborator
Builds ready [4cbdce7]
Page Load Metrics (460 ± 72 ms)
|
Collaborator
Builds ready [609b0d7]
Page Load Metrics (427 ± 59 ms)
|
Gudahtt
reviewed
Oct 26, 2020
Collaborator
Builds ready [24a011e]
Page Load Metrics (460 ± 61 ms)
|
24a011e to
6dc0b6d
Compare
Contributor
Author
|
I just pushed a number of changes, including a rebase onto develop. I will reply to previous comments and add further commentary on latest changes in a little while. |
Contributor
Author
|
6dc0b6d Added unit tests for _findTopQuoteAndCalculateSavings for the case of ERC-20 -> ERC-20 swaps when the destination conversion rate is known. We should also add unit tests for:
So 5 sets of unit tests to add. |
Collaborator
Builds ready [d1f4ddc]
Page Load Metrics (456 ± 59 ms)
|
d1f4ddc to
e4b9cd3
Compare
…alculateSavings Cleaner structuring of conditionals for setting tokenValueOfQuoteForSorting, ethValueOfQuote and metaMaskFeeInEth in swaps controller Stop subtracting medianMetaMaskFee from savings, but include it in savings data Another fix and refactor to savings calculations in _findTopQuoteAndCalculateSavings
e4b9cd3 to
2217b02
Compare
Contributor
Author
|
@Gudahtt @rekmarks This is again ready for review. Some notables changes that have been made:
|
Collaborator
Builds ready [2217b02]
Page Load Metrics (494 ± 72 ms)
|
Gudahtt
reviewed
Nov 5, 2020
…TH is the source token
Collaborator
Builds ready [e52eb94]
Page Load Metrics (375 ± 59 ms)
|
Contributor
Author
|
@Gudahtt comments have been addressed |
Collaborator
Builds ready [1458ad7]
Page Load Metrics (543 ± 74 ms)
|
Gudahtt
reviewed
Nov 6, 2020
…cted results helper functions
Collaborator
Builds ready [e4bdc81]
Page Load Metrics (421 ± 63 ms)
|
…rall values equal to the median
Collaborator
Builds ready [ec9f935]
Page Load Metrics (571 ± 80 ms)
|
Gudahtt
reviewed
Nov 9, 2020
Collaborator
Builds ready [59faf71]
Page Load Metrics (448 ± 58 ms)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR replaces #9662, and fixes some additional issues
The most fundamental change made in this PR is an update to the basic formula used for calculating total savings:
And so the the
savings.totalproperty is now calculated directly from the overall eth value of the best trade to the overall eth value of the median trade. Related to this is thatsavings.performanceis now calculated by subtracting fee savings from total savings.Another important fix is that what was previously called
ethValueOfTradeis no longer used in calculations of values that will be shown to the user on the front end. It has been renamed totokenValueOfQuoteForSortingto reflect its purpose. This variable assumes a tokenConversionRate of 1 if none is available, which is fine for comparing quotes to calculate the top quote in such cases, but would be meaningless or misleading if used to calculate user facing values. A newethValueOfQuotevariable has been created that defaults the conversion rate to 0 if not available, which will result in ethValueOfQuote being zero (in this case, the UI will have to choose not to render savings data).Also important change is that
savings.feeis now calculated by comparing the fee of the best quote to the fee of the quote with the media value, as opposed to comparing the fee of the best quote to the median fee. To support this, thegetMedianfunction has been refactored to a function that takes a list of quotes and returns an object with relevant savings information from the quote with the mediaethValueOfQuoteFinally, this PR ensures that the metamask fee is accounted for in the savings calculations and makes that information available in the savings property for use in the UI
There are some other code refactors made to improve readability given the above changes.