Skip to content

fix: starknet swaps#11770

Merged
0xApotheosis merged 1 commit intodevelopfrom
fix-starknet
Jan 23, 2026
Merged

fix: starknet swaps#11770
0xApotheosis merged 1 commit intodevelopfrom
fix-starknet

Conversation

@NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Jan 22, 2026

Description

Fixes a few things: addresses needs to be normalized before sending swaps (idk how we lost that but hey...), status check using the provider directly so we ensure consistency and reduce errors from the console

Issue (if applicable)

Spotted while testing the release

Risk

Low

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Testing

  • Try to send Starknet to a fresh acccount
  • Deploy account
  • Swap from STRK to USDC on Starknet
  • Swap from USDC to USDT on starknet
  • Swap back to STRK

Engineering

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

https://jam.dev/c/db951bdd-4924-4cef-85a9-03b46df1ea67

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced Starknet address validation and normalization across swap operations.
    • Improved transaction receipt retrieval with better error handling.
    • Added validation for swap service responses with descriptive error messages.
    • Updated default slippage tolerance for Avnu swaps.
    • Enhanced hex formatting consistency in transaction data.
  • Chores

    • Updated asset blacklist configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@NeOMakinG NeOMakinG requested a review from a team as a code owner January 22, 2026 15:32
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

This PR enhances Avnu swapper integration by normalizing Starknet addresses across multiple endpoints, updating default slippage tolerances from 0.005–0.01 to 0.02, adding address validation utilities, improving transaction receipt retrieval via raw RPC calls, and removing a blacklisted Starknet token entry.

Changes

Cohort / File(s) Summary
Avnu Slippage Configuration
packages/swapper/src/constants.ts
Updated DEFAULT_AVNU_SLIPPAGE_DECIMAL_PERCENTAGE from 0.005 to 0.02 with explanatory comment about Starknet latency considerations.
Avnu Address Normalization & Calldata Handling
packages/swapper/src/swappers/AvnuSwapper/endpoints.ts
Added toHexString utility for hex format normalization. Integrated validateAndParseAddress to normalize from and contract addresses. Increased default slippage to 0.02, added validation for non-empty avnuCalls, and updated calldata construction and hashing to use normalized addresses and hex formatting.
Avnu Trade Quote Normalization
packages/swapper/src/swappers/AvnuSwapper/swapperApi/getTradeQuote.ts
Added address normalization for sendAddress and receiveAddress using validateAndParseAddress, replacing direct references with normalized versions in quote retrieval and fee data fields.
Avnu Trade Rate Normalization
packages/swapper/src/swappers/AvnuSwapper/swapperApi/getTradeRate.ts
Introduced normalizedReceiveAddress for optional receiveAddress normalization and updated fee data fields (to/from) and final TradeRate object with normalized values.
Transaction Receipt Handling
packages/swapper/src/utils.ts
Replaced direct provider.getTransactionReceipt calls with raw RPC invocation via provider.fetch('starknet_getTransactionReceipt', [txHash]), added error/missing result handling, and simplified early return logic for pending/unknown statuses.
Blacklist Updates
scripts/generateAssetData/blacklist.json
Removed Starknet token entry starknet:SN_MAIN/erc20:0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d from blacklist.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • gomesalexandre
  • 0xApotheosis

Poem

🐰 Hippity-hop through Starknet's lanes,
Addresses normalized, slippage refrains,
Raw RPC calls, no more delays,
Avnu swaps shine in cleaner ways!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: starknet swaps' is vague and generic. While it mentions Starknet swaps, it doesn't convey the specific nature of the fixes being applied across multiple areas (address normalization, slippage adjustments, provider-based status checking, and asset blacklist updates). Use a more descriptive title that captures the primary change(s), such as 'fix: normalize Starknet addresses and adjust swap parameters' or 'fix: improve Starknet swap reliability with address normalization and provider-based status checking'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-starknet

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@0xApotheosis 0xApotheosis left a comment

Choose a reason for hiding this comment

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

Flow worked perfectly:

✅ Try to send Starknet to a fresh acccount
✅ Deploy account
✅ Swap from STRK to USDC on Starknet
✅ Swap from USDC to USDT on starknet
✅ Swap back to STRK

https://jam.dev/c/9d913ff1-ab2d-4dae-bdd1-08ee82d7746c

@0xApotheosis 0xApotheosis merged commit 7477dcf into develop Jan 23, 2026
4 checks passed
@0xApotheosis 0xApotheosis deleted the fix-starknet branch January 23, 2026 00:46
0xApotheosis pushed a commit that referenced this pull request Jan 23, 2026
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