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

Merged
merged 5 commits into from
Jan 6, 2025
Merged

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)
cowfi ✅ Ready (Inspect) Visit Preview Jan 6, 2025 2:47pm
explorer-dev ✅ Ready (Inspect) Visit Preview Jan 6, 2025 2:47pm
swap-dev ✅ Ready (Inspect) Visit Preview Jan 6, 2025 2:47pm
3 Skipped Deployments
Name Status Preview Updated (UTC)
cosmos ⬜️ Ignored (Inspect) Visit Preview Jan 6, 2025 2:47pm
sdk-tools ⬜️ Ignored (Inspect) Visit Preview Jan 6, 2025 2:47pm
widget-configurator ⬜️ Ignored (Inspect) Visit Preview Jan 6, 2025 2:47pm

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

Report too large to display inline

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

Copy link

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Protestware or potentially unwanted behavior npm/[email protected]
  • Note: The script attempts to run a local post-install script, which could potentially contain malicious code. The error handling suggests that it is designed to fail silently, which is a common tactic in malicious scripts.
⚠︎
Protestware or potentially unwanted behavior npm/[email protected]
  • Note: This package prints a protestware console message on install regarding Ukraine for users with Russian language locale
⚠︎
Critical CVE npm/[email protected] ⚠︎

View full report↗︎

Next steps

What is protestware?

This package is a joke, parody, or includes undocumented or hidden behavior unrelated to its primary function.

Consider that consuming this package may come along with functionality unrelated to its primary purpose.

What is a critical CVE?

Contains a Critical Common Vulnerability and Exposure (CVE).

Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

@alfetopito alfetopito merged commit 3be8a65 into develop Jan 6, 2025
11 checks passed
@alfetopito alfetopito deleted the feat/executedSurplusFee-removal branch January 6, 2025 14:49
@github-actions github-actions bot locked and limited conversation to collaborators Jan 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants