Skip to content

fix(swap): Forward disableFallback to getSwapFee in getRouterFees πŸ”§ - #2566

Closed
nunndayox-stack wants to merge 2 commits into
paraspell:mainfrom
nunndayox-stack:fix/2374-router-fees-fallback
Closed

nunndayox-stack wants to merge 2 commits into
paraspell:mainfrom
nunndayox-stack:fix/2374-router-fees-fallback

Conversation

@nunndayox-stack

Copy link
Copy Markdown

🐞 Bug Fix Pull Request

πŸ“Œ Related Issue

Closes #2374


πŸ› οΈ Description of the Fix

  • Bug description: getRouterFees called getSwapFee(dex, options) without forwarding its disableFallback argument, while the sibling getSwapOriginFee forwards it. Since getSwapFee defaults the flag to false, a caller asking for disableFallback: true still got a paymentInfo fallback fee for the exchange hop when the swap dry run failed, instead of only a dryRunError β€” breaking the TGetXcmFeeResult contract. Same class as [Bug bounty] XCM API ignores disableFallback in /xcm-feeΒ #2179.
  • Fix summary: Forward the argument: getSwapFee(dex, options, disableFallback). With a generic TDisableFallback the returned fee is possibly undefined, so the merged-hop fee now coalesces it β€” (swapChain.fee ?? 0n) + (receivingChain?.origin.fee ?? 0n) β€” mirroring the normalisation getSwapFee already applies internally (no runtime behaviour change). A new unit test asserts getSwapFee is called with (dex, options, true).

βœ… Contributor Eligibility

  • My GitHub account's commit history is at least 6 months old.
  • I have set an on-chain identity on the Polkadot People Chain for my AssetHub address and requested a registrar judgement of at least Reasonable (verifiable via Subscan).
  • Every commit in this PR is signed (-S) and includes Signed-off-by and AI-Assisted-By: <tool name(s)> (or AI-Assisted-By: None) trailers.
  • I disclose any AI tools used to help write this fix (or confirm none were used), and I understand and can explain/defend the resulting code myself.
  • This fix was authored and reviewed by a human β€” not opened autonomously by an AI agent.
  • I will respond to maintainer review questions with specific, on-topic answers within 5 days.
  • I understand πŸ”΄ High complexity fixes may require a brief live chat/call walkthrough before payout.
  • This is the only bug bounty issue I currently have reserved.

βœ… Checklist

  • My code follows the project's code style.
  • I have added tests that prove my fix is effective (if applicable).
  • I have updated the documentation where necessary.
  • I have verified the fix does not introduce new issues.

πŸ’Έ Polkadot Asset Hub Address (for Reward)

Polkadot Asset Hub Address: To be added β€” I will update this PR with my AssetHub address once my wallet and on-chain identity setup are complete, before any payout.

⚠️ Important:
Do NOT provide a centralized exchange (CEX) address (e.g., Kraken, Binance, etc.).
Rewards sent to CEX addresses may be lost and are not recoverable.


🧩 Additional Notes (Optional)

Test report (verified locally before submission): getRouterFees.test.ts 19/19 pass; full @paraspell/swap suite 60 files / 376 tests all pass; mutation check done (reverting only getRouterFees.ts makes exactly the new test fail); tsc --noEmit clean.

Transparency note: an earlier 4-fix bundle PR (#2385, closed unmerged) contained the same one-line change; this PR submits the fix standalone per the programme's one-issue-per-PR convention, and adds the type fix needed for tsc to pass.

Review request: @michaeldev5

nunndayox-stack added 2 commits November 18, 2026 22:50
getRouterFees called getSwapFee(dex, options) without the
disableFallback argument, while the sibling getSwapOriginFee
forwards it. With disableFallback: true and a failing swap dry
run, the exchange hop therefore returned a paymentInfo fallback
fee instead of only a dryRunError, breaking the
TGetXcmFeeResult<true> contract. Forward the flag, and coalesce
the merged hop fee with ?? 0n (getSwapFee already normalises the
fee the same way internally) so the conditional fee type
type-checks for a generic TDisableFallback.

Signed-off-by: nunndayox-stack <nunndayox@gmail.com>
AI-Assisted-By: Muse
Signed-off-by: nunndayox-stack <nunndayox@gmail.com>
AI-Assisted-By: Muse
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.

[Bug bounty] SWAP: getRouterFees does not forward disableFallback to getSwapFee

2 participants