Repository navigation
fix(affiliate): show the verified on-chain partner fee and each swap's fee status - #12802
Conversation
…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>
|
No actionable comments were generated in the recent review.
|
| 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:
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
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: 
5
-
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.
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.
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
isAffiliateVerifiedalone, so a verified swap the payout would not pay still showed a green check and a fee.swap-service now sets
partnerFeeUsdon/v1/affiliate/swapsonly 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:affiliateFeeAmountUsdis swap-service'spartnerFeeUsdwhen 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).affiliateFeeStatus:earned|pending|review|failed.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.~, and swaps with no fee show a grey—.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.None. No on-chain transactions, wallets or swapper code are touched.
Testing
Engineering
vitestforpackages/public-api/src/routes/affiliatepasses: the fee status and reason rules, and the estimate.tscpass. affiliate-dashboardtscreports no errors in its sources; locally it fails only inside@vitejs/plugin-react's type definitions, so CI is the check there.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.status,verificationStatus,isAffiliateVerified,attributionStatus,partnerBps,affiliateVerificationDetails.affiliateBps, plus an on-chain fee amount and asset for earned rows.Operations
On the affiliate dashboard for a partner with recent swaps:
~fee.—.Screenshots (if applicable)
Screenshots of the seeded states to be added in review.
Summary by CodeRabbit