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

Add native currency support to SwapOrderHelper #1491

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

fmrsabino
Copy link
Collaborator

  • SwapOrderHelper now supports swaps with the respective chain native tokens.
  • The Native Token is represented with the address 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE (https://docs.cow.fi/cow-protocol/reference/sdks/cow-sdk/modules#buy_eth_address)
  • If we fail to retrieve the native currency data (from the Safe Config Service), the decoding fails, and it attempts to decode it as a Custom transaction. The main reason for this is that Native Currencies might have different decimals which are important for showing the correct number of tokens being transferred.

- `SwapOrderHelper` now supports swaps with the respective chain native tokens.
- The Native Token is represented with the address `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` (https://docs.cow.fi/cow-protocol/reference/sdks/cow-sdk/modules#buy_eth_address)
- If we fail to retrieve the native currency data (from the Safe Config Service), the decoding fails, and it attempts to decode it as a Custom transaction. The main reason for this is that Native Currencies might have different decimals which are important for showing the correct number of tokens being transferred.
@fmrsabino fmrsabino self-assigned this Apr 30, 2024
@fmrsabino fmrsabino requested a review from a team as a code owner April 30, 2024 10:34
@coveralls
Copy link

Pull Request Test Coverage Report for Build 8893325428

Details

  • 8 of 8 (100.0%) changed or added relevant lines in 1 file are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.04%) to 92.257%

Files with Coverage Reduction New Missed Lines %
src/routes/transactions/entities/tests/human-description.builder.ts 4 60.0%
Totals Coverage Status
Change from base Build 8892845494: 0.04%
Covered Lines: 6896
Relevant Lines: 7213

💛 - Coveralls

@fmrsabino fmrsabino enabled auto-merge (squash) April 30, 2024 10:49
chainId: string;
address: `0x${string}`;
}): Promise<Token> {
if (args.address === SwapOrderHelper.NATIVE_CURRENCY_ADDRESS) {
Copy link
Member

Choose a reason for hiding this comment

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

Are we sure that args.address with always be checksummed? It would be a bit safer to either checksum args.address or compare them in lowercase. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Auto-merge merged the commit before I was able to tackle this. I will open a follow up PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tackled it here: #1493

@fmrsabino fmrsabino merged commit d06fbdd into main Apr 30, 2024
16 checks passed
@fmrsabino fmrsabino deleted the add-native-token-support branch April 30, 2024 10:53
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.

None yet

4 participants