Skip to content

fix(aggregator): populate OneClick affiliateFee from appFees - #1764

Merged
underthesun49 merged 1 commit into
masterfrom
fix/oneclick-affiliate-fee
Aug 26, 2026
Merged

fix(aggregator): populate OneClick affiliateFee from appFees#1764
underthesun49 merged 1 commit into
masterfrom
fix/oneclick-affiliate-fee

Conversation

@Thorian1te

@Thorian1te Thorian1te commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix OneClickProtocol.estimateSwap always returning fees.affiliateFee = 0 even when affiliate appFees were sent to the 1Click API
  • Resolve bps from echoed quoteRequest.appFees matching the configured affiliate recipient, with fallback to configured affiliateBps
  • Compute fee as amountIn * bps / 10000 in the input asset so wallet UIs (e.g. Asgardex) can display the affiliate fee

Closes #1763

Test plan

  • Unit tests for echoed appFees, configured-bps fallback, and no-affiliate (oneclickProtocol.test.ts)
  • yarn build --filter=@xchainjs/xchain-aggregator
  • Smoke: Asgardex OneClick quote with affiliate configured shows non-zero Affiliate Fee

Summary by CodeRabbit

  • Bug Fixes
    • OneClick swap estimates now correctly report affiliate fees when configured.
    • Fees reflect matching quote data, with configured settings used as a fallback.
    • Estimates return zero affiliate fees when no affiliate is configured.
  • Tests
    • Added coverage for affiliate fee calculations, request payloads, assets, and amounts.

estimateSwap forwarded affiliate config to the 1Click API but always
returned fees.affiliateFee = 0, so wallets showed Affiliate Fee as free.
Resolve bps from echoed quoteRequest.appFees (matching recipient), with
fallback to configured affiliateBps.

Closes #1763
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 47a7ea48-29bb-4f39-8ef7-2c6dc2d0872e

📥 Commits

Reviewing files that changed from the base of the PR and between 0b77252 and 204afbe.

📒 Files selected for processing (4)
  • .changeset/oneclick-affiliate-fee.md
  • packages/xchain-aggregator/__tests__/oneclickProtocol.test.ts
  • packages/xchain-aggregator/src/protocols/oneclick/oneclickProtocol.ts
  • packages/xchain-aggregator/src/protocols/oneclick/types.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Changes

OneClick affiliate fee calculation

Layer / File(s) Summary
Affiliate fee response contract
packages/xchain-aggregator/src/protocols/oneclick/types.ts
Adds the exported OneClickAppFee type and an optional response echo for quoteRequest.appFees.
Affiliate fee resolution
packages/xchain-aggregator/src/protocols/oneclick/oneclickProtocol.ts
Calculates affiliateFee from the matching echoed app fee, configured affiliateBps as fallback, or zero when unavailable.
Affiliate fee validation and release
packages/xchain-aggregator/__tests__/oneclickProtocol.test.ts, .changeset/oneclick-affiliate-fee.md
Tests echoed fees, fallback fees, and zero fees without affiliate configuration. Adds patch release metadata.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 204af

This localized change populates affiliate-fee values for OneClick quotes, with unit tests and a successful package build reported; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: populating OneClick affiliateFee from appFees.
Linked Issues check ✅ Passed The implementation satisfies the core objective in [#1763]. It derives the affiliate fee from echoed quoteRequest.appFees when the recipient matches and falls back to configured affiliateBps. Tests co…
Out of Scope Changes check ✅ Passed The changes are within scope for [#1763]. The implementation, public types, tests, and changeset all support OneClick affiliate fee mapping.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…
Full details: Linked Issues check

Explanation

The implementation satisfies the core objective in [#1763]. It derives the affiliate fee from echoed quoteRequest.appFees when the recipient matches and falls back to configured affiliateBps. Tests cover both paths and the no-affiliate case. The secondary outboundFee suggestion is not required for the primary issue objective.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/oneclick-affiliate-fee

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.

@underthesun49
underthesun49 merged commit 6b31c82 into master Aug 26, 2026
3 checks passed
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(aggregator): OneClick estimateSwap always returns fees.affiliateFee = 0 even when appFees are sent

2 participants