Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Unit tests fix for 2.16.1#271

Merged
alfetopito merged 3 commits intomainfrom
unit-tests-fix-for-2.16.1
Jan 3, 2023
Merged

Unit tests fix for 2.16.1#271
alfetopito merged 3 commits intomainfrom
unit-tests-fix-for-2.16.1

Conversation

@alfetopito
Copy link
Copy Markdown
Collaborator

Summary

Fix for RELEASE!! But it's a single PR so it can be squashed

Fixing unit tests and a bit of logic that was causing confusion

To Test

Should behave the same as #269

Context:
  In the beginning, there was no `executedSellAmountBeforeFees` field,
and to figure out how much was sold without the fees, we had to subtract
`executedFeeAmount` from `executedSellAmount`.
  Backend added `executedSellAmountBeforeFees` not long after, but it
was never updated.
  Now that the fee can come from more sources, it's causing confusion.
  Let's then use the field that's intended for that.
@alfetopito alfetopito marked this pull request as ready for review December 28, 2022 11:33
@alfetopito alfetopito self-assigned this Dec 28, 2022
@alfetopito alfetopito requested review from a team December 28, 2022 11:33
@github-actions
Copy link
Copy Markdown

Comment thread src/api/operator/types.ts
Comment on lines -66 to -69
executedBuyAmount?: BigNumber
sellAmount: BigNumber
executedSellAmount?: BigNumber
executedFeeAmount?: BigNumber
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was never necessary as they don't exist in the original Trade coming from the API and have equivalent non executed counterparts.

Comment thread src/utils/operator.ts
Comment on lines -173 to +177
* Mostly because `executedSellAmount` is derived from 2 fields (at time or writing)
* Mostly because `executedSellAmount` (with fees deducted) is named `executedSellAmountBeforeFees`
*
* @param order The order
*/
export function getOrderExecutedAmounts(
order: Pick<RawOrder, 'executedBuyAmount' | 'executedSellAmount' | 'executedFeeAmount' | 'executedSurplusFee'>,
): {
export function getOrderExecutedAmounts(order: Pick<RawOrder, 'executedBuyAmount' | 'executedSellAmountBeforeFees'>): {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated fn signature only with needed params and also updated the docstring

Copy link
Copy Markdown

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like in #267

@alfetopito alfetopito merged commit 3e46118 into main Jan 3, 2023
@alfetopito alfetopito deleted the unit-tests-fix-for-2.16.1 branch January 3, 2023 15:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants