Skip to content

fix(affiliate): show the verified on-chain partner fee and each swap's fee status - #12802

Merged
kaladinlight merged 1 commit into
developfrom
fix/affiliate-onchain-partner-fee
Oct 28, 2026
Merged

kaladinlight merged 1 commit into
developfrom
fix/affiliate-onchain-partner-fee

Conversation

@kaladinlight

@kaladinlight kaladinlight commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Description

The affiliate dashboard computed each swap's partner fee itself: from the on-chain fee when public-api could find the fee asset, otherwise from volume × partnerBps. It also badged swaps from isAffiliateVerified alone, so a verified swap the payout would not pay still showed a green check and a fee.

swap-service now sets partnerFeeUsd on /v1/affiliate/swaps only for the on-chain fee the payout will pay (shapeshift/microservices#78, deployed). This PR uses that value and gives every swap a fee status:

  • public-api
    • affiliateFeeAmountUsd is swap-service's partnerFeeUsd when set. Otherwise it is the volume × partnerBps estimate, or null for a swap that will not be paid. The on-chain recalculation and its asset lookup are removed (calculatePartnerFeeAmountUsd → estimatePartnerFeeAmountUsd).
    • New affiliateFeeStatus: earned | pending | review | failed.
    • New affiliateFeeStatusReason: what a swap is waiting on, or why it is unpaid (swap-pending, verification-pending, attribution-pending, fee-under-review, no-partner-share, swap-failed, not-attributed, fee-not-verified, no-affiliate-fee, fee-waived). Both fields are additive in the OpenAPI schema.
  • affiliate-dashboard
    • The badge follows the status: ✅ earned, 🕒 pending, ⚠️ under review, ❌ not paid. Its tooltip gives the reason in partner-facing wording.
    • Estimated fees are prefixed with ~, and swaps with no fee show a grey —.
    • A dashboard served by an older public-api treats swaps as pending, so nothing shows as earned early.

Issue (if applicable)

N/A

Risk

Low. The change is limited to the public-api affiliate swaps route and the affiliate dashboard swaps table. Existing response fields keep their meaning except affiliateFeeAmountUsd, which now reads as the verified on-chain partner fee once earned.

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

None. No on-chain transactions, wallets or swapper code are touched.

Testing

Engineering

  • vitest for packages/public-api/src/routes/affiliate passes: the fee status and reason rules, and the estimate.
  • Lint and public-api tsc pass. affiliate-dashboard tsc reports no errors in its sources; locally it fails only inside @vitejs/plugin-react's type definitions, so CI is the check there.
  • Local end to end: microservices docker compose (swap-service on fix/fee-asset-precision) was seeded with one swap per state for a partner. public-api and the dashboard ran against it, and each row showed the expected badge and fee. The final tooltip wording has not been checked in the browser yet.
  • Seeding a swap in each state needs these swap-service row fields: status, verificationStatus, isAffiliateVerified, attributionStatus, partnerBps, affiliateVerificationDetails.affiliateBps, plus an on-chain fee amount and asset for earned rows.

Operations

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

On the affiliate dashboard for a partner with recent swaps:

  • Verified, paid swaps show a green check and a plain fee.
  • In-progress swaps show a clock and a ~ fee.
  • Unpaid swaps show a red cross and —.
  • Hovering a badge shows why.
  • The total at the top still matches the sum of earned fees.

Screenshots (if applicable)

Screenshots of the seeded states to be added in review.

Summary by CodeRabbit

  • New Features
    • Affiliate swaps now show fee statuses: earned, pending, under review, or failed, with explanations where available.
    • Pending and under-review fees are marked as estimates; unavailable fee amounts remain displayed as a dash.
    • Status icons and fee styling help distinguish successful, pending, and failed fees across desktop and mobile views.

…s fee status

- Use swap-service's partnerFeeUsd as the affiliate fee, which it now sets
  only for the on-chain fee the payout will pay, instead of recomputing it
  with a separate asset lookup
- Add affiliateFeeStatus to the public api: earned (the on-chain fee),
  pending (still settling, estimate shown), review (verified but held for
  review, estimate shown) and failed (won't be paid, no fee shown), with
  affiliateFeeStatusReason saying what it's waiting on or why it's unpaid
- The dashboard badge and its tooltip follow that status, and estimated
  fees are marked with ~

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kaladinlight
kaladinlight requested a review from a team as a code owner October 28, 2026 21:36
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3987ae15-fa22-4e14-810f-a03dacd3ca77
Commits

Reviewing files that changed from the base of the PR and between e86536e and c9bbe3d.

Files selected for processing: 10
  • packages/affiliate-dashboard/src/components/swaps/SwapsTable.tsx
  • packages/affiliate-dashboard/src/components/swaps/VerifiedBadge.tsx
  • packages/affiliate-dashboard/src/hooks/useAffiliateSwaps.ts
  • packages/public-api/src/routes/affiliate/calculatePartnerFeeAmountUsd.test.ts
  • packages/public-api/src/routes/affiliate/estimatePartnerFeeAmountUsd.test.ts
  • packages/public-api/src/routes/affiliate/estimatePartnerFeeAmountUsd.ts
  • packages/public-api/src/routes/affiliate/getAffiliateSwaps.ts
  • packages/public-api/src/routes/affiliate/resolveAffiliateFeeStatus.test.ts
  • packages/public-api/src/routes/affiliate/resolveAffiliateFeeStatus.ts
  • packages/public-api/src/routes/affiliate/types.ts
Files with no reviewable changes: 1
  • packages/public-api/src/routes/affiliate/calculatePartnerFeeAmountUsd.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Walkthrough

The public API now resolves affiliate fee status and returns reported or estimated fee amounts with status details. The affiliate dashboard displays status-specific badges and fee formatting in desktop and mobile views.

Changes: Affiliate fee status and display

Layer / File(s) Summary
Status schema and resolution
packages/public-api/src/routes/affiliate/types.ts, packages/public-api/src/routes/affiliate/resolveAffiliateFeeStatus.ts, packages/public-api/src/routes/affiliate/resolveAffiliateFeeStatus.test.ts
Added schemas and types for fee status and reason. The resolver classifies swaps as earned, pending, failed, or review. Tests cover the statuses and reasons.
Fee amount and API response
packages/public-api/src/routes/affiliate/estimatePartnerFeeAmountUsd.ts, packages/public-api/src/routes/affiliate/estimatePartnerFeeAmountUsd.test.ts, packages/public-api/src/routes/affiliate/calculatePartnerFeeAmountUsd.test.ts, packages/public-api/src/routes/affiliate/getAffiliateSwaps.ts
Replaced the captured-fee calculation with a volume-based estimate. The route returns the reported amount for earned fees, null for failed fees, and an estimate for other statuses. It adds status and reason to each swap response. Tests cover the estimate cases; the previous calculation test file was removed.
Dashboard status and fee display
packages/affiliate-dashboard/src/hooks/useAffiliateSwaps.ts, packages/affiliate-dashboard/src/components/swaps/VerifiedBadge.tsx, packages/affiliate-dashboard/src/components/swaps/SwapsTable.tsx
The dashboard schema accepts fee status and reason. Badges select labels and icons from those fields. Desktop and mobile fee displays use status-aware formatting and color.

Priority: Normal

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant AffiliateDashboard
  participant getAffiliateSwaps
  participant resolveAffiliateFeeStatus
  participant estimatePartnerFeeAmountUsd
  AffiliateDashboard->>getAffiliateSwaps: Request affiliate swaps
  getAffiliateSwaps->>resolveAffiliateFeeStatus: Resolve each swap status
  getAffiliateSwaps->>estimatePartnerFeeAmountUsd: Estimate amount for non-earned, non-failed status
  getAffiliateSwaps-->>AffiliateDashboard: Return fee amount, status, and reason
Loading

Suggested reviewers: 0xapotheosis

Merge Risk: Minimal · up to c9bbe

No actionable issue remains before merge under normal checks. Confirm the swap-service response shape during deployment coordination.

Pre-merge checks: Passed 5
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 main changes: displaying the verified on-chain partner fee and the fee status for each swap.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 9 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the fee display,
A status badge lights the way.
A tilde marks an estimate,
A dash stays put when fees are null.
The swaps roll by, all neat and clear.

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

@kaladinlight
kaladinlight merged commit 83a27d0 into develop Oct 28, 2026
4 checks passed
@kaladinlight
kaladinlight deleted the fix/affiliate-onchain-partner-fee branch October 28, 2026 21:52
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.

1 participant