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

feat: executedSurplusFee removal #5262

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

alfetopito
Copy link
Collaborator

Summary

Remove usages of executedSurplusFee with executedFee.

Everything should remain as is, no functional changes.

SDK related changes: cowprotocol/cow-sdk#229

Backend changes depending on this: cowprotocol/services#3184

To Test

  1. Open the explorer and check the fee field of an executed order
  • Should show same as production version
  1. Open an existing executed TWAP part and check the network costs section
  • Should show same as production version
  1. Place a new TWAP and check it once one part executes and check the network costs section
  • Should show same as production version

Copy link

vercel bot commented Dec 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cosmos ✅ Ready (Inspect) Visit Preview Dec 31, 2024 10:06am
cowfi ✅ Ready (Inspect) Visit Preview Dec 31, 2024 10:06am
explorer-dev ✅ Ready (Inspect) Visit Preview Dec 31, 2024 10:06am
sdk-tools ✅ Ready (Inspect) Visit Preview Dec 31, 2024 10:06am
swap-dev ✅ Ready (Inspect) Visit Preview Dec 31, 2024 10:06am
widget-configurator ✅ Ready (Inspect) Visit Preview Dec 31, 2024 10:06am

Comment on lines 10 to 16
// TODO: get rid of this once https://github.com/cowprotocol/services/pull/3184 is complete
const HAS_BACKEND_MIGRATED = false

function getFeeToken(order: ParsedOrder) {
if (!HAS_BACKEND_MIGRATED) {
return order.inputToken
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Until a migration is done, the fee will continue being returned in SELL token

https://cowservices.slack.com/archives/C036G0J90BU/p1735581010053059?thread_ts=1735059402.066139&cid=C036G0J90BU

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, decided to default to inputToken when the feeToken is not set.
This flag is not needed then.

Comment on lines 18 to 28
const { inputToken, outputToken } = order
const { executedFeeToken } = order.executionData

if (inputToken?.address.toLowerCase() === executedFeeToken?.toLowerCase()) {
return inputToken
}
if (outputToken?.address.toLowerCase() === executedFeeToken?.toLowerCase()) {
return outputToken
}
return undefined
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had already implemented it assuming it would be in the surplus, but that's not the case yet.

// TODO: use the value from SDK
const totalFee = CurrencyAmount.fromRawAmount(inputToken, (executedSurplusFee ?? executedFeeAmount) || 0)
const quoteSymbol = inputToken.symbol
const totalFeeAmount = CurrencyAmount.fromRawAmount(feeToken, totalFee || 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Use the totalFee available from the API

Comment on lines -38 to +46
executedSurplusFee: BigNumber | null
executedFee: BigNumber | null
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically renaming the field everywhere else.

Copy link

socket-security bot commented Dec 30, 2024

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: npm/[email protected]

View full report↗︎

Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

Probably worth it to include a unit test?

Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

Tested comparing prod with this PR, works the same

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.

2 participants