Skip to content

docs(partner): audit & correct partner-integration docs; fix ratesRefetchInterval prop - #12474

Merged
kaladinlight merged 9 commits into
developfrom
docs/partner-integration-docs
Jun 30, 2026
Merged

docs(partner): audit & correct partner-integration docs; fix ratesRefetchInterval prop#12474
kaladinlight merged 9 commits into
developfrom
docs/partner-integration-docs

Conversation

@kaladinlight

@kaladinlight kaladinlight commented Jun 30, 2026

Copy link
Copy Markdown
Member

Description

Accuracy audit of the partner-integration documentation set, verifying every concrete claim against the actual implementation (swap-widget, public-api, swap-service, affiliate-dashboard) and correcting the discrepancies found. Includes one small code fix uncovered during the review.

Docs reviewed & corrected:

  • docs/affiliates.md — partner code is partner-chosen (not "issued"); walletConnectProjectId not strictly required when the host owns AppKit; scoped the endpoints-table heading; clarified partnerBps only appears on attributed quotes.
  • packages/public-api/docs/introduction.md — corrected rate-limit description (fixed window + app-wide global limiter on top of per-group limits).
  • packages/public-api/docs/rest-api-guide.md — dropped the unobservable pending swap status (binding a txHash immediately moves it to submitted).
  • packages/public-api/docs/swap-widget-sdk.md — install command now lists all required peer deps.
  • packages/swap-widget/README.md — Bitcoin/Solana AppKit adapters documented as required peers (they're statically imported); documented the literal apiBaseUrl default; dual AppKit-init guidance.
  • docs/architecture/affiliate-system.md — verified the attribution model end-to-end (only the total affiliateBps reaches the swapper; the split + partner address are off-chain settlement metadata); removed tangential swapper affiliate-constant references.

Code fix:

  • fix(swap-widget): wire ratesRefetchInterval prop through to useSwapRates — the prop was declared on SwapWidgetProps but never threaded to useSwapRates, so it had no effect. Now flows through the component tree like allowedSwapperNames; an unset prop still falls back to the existing 15s default.

Issue (if applicable)

closes #

Risk

Low. Documentation-only except one self-contained swap-widget prop-wiring fix. The fix mirrors the existing allowedSwapperNames threading and preserves prior behavior when the prop is unset (15s refetch default). No new or modified on-chain transactions; no protocol, wallet, or contract interactions affected.

Testing

Engineering

  • Every documented claim was verified against source (endpoints, headers, fee fields, types, chain-ID constants, enum values, env vars, middleware/registration flow).
  • Code change: pnpm exec eslint on the changed files and tsc --noEmit for the swap-widget package both pass clean. ratesRefetchInterval now propagates SwapWidget → SwapWidgetCore → SwapWidgetContent → useSwapDisplayValues → useSwapRates; verify by passing e.g. ratesRefetchInterval={5000} and observing the rates refetch cadence; omitting it keeps the 15s default.

Operations

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

Docs-only plus a non-user-facing widget prop default; no operations testing required.

Screenshots (if applicable)

N/A

Summary by CodeRabbit

  • New Features

    • Added configurable swap rate refresh timing for the widget.
    • Updated affiliate attribution to use partner codes and the X-Partner-Code header.
    • Expanded REST and widget guidance with clearer swap, quote, and status workflows.
  • Documentation

    • Reworked affiliate docs to reflect the current partner-code flow and reporting endpoints.
    • Refreshed public API, widget SDK, and swap-widget README content with setup, error, and rate-limit details.

kaladinlight and others added 9 commits June 30, 2026 12:25
…docs

Bring partner-facing integration docs in line with the current implementation
(props/headers/endpoints had drifted ~3 months behind code).

- swap-widget README: rewrite as the canonical widget reference — correct props
  (sellFilters/buyFilters, removed walletClient/affiliate props), required
  walletConnectProjectId, accurate chains/swappers, exports, peer deps, CSS import
- public-api swap-widget-sdk.md: reduce to a pointer to the canonical README
- public-api introduction.md / rest-api-guide.md: add base URL, response/error
  envelope, status values, quote/rate expiry, polling, params, rate limits
- affiliates.md: fix to X-Partner-Code only; partnerCode-based stats/swaps; clarify
  attribution model; correct dashboard URL; drop web-app-only related-asset fee claim
- affiliate-system.md: describe implemented architecture and the on-chain-fee vs
  off-chain-settlement attribution model
- remove affiliate-data-model.md (stale design spec; schema lives in microservices)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…st owns AppKit

The widget renders once Reown AppKit is initialized, which is satisfied either
by passing walletConnectProjectId (widget self-initializes) or by the host app
initializing AppKit and the widget reading the shared singleton (see
ExternalWalletApp demo). Docs previously stated the prop was unconditionally
required to render.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- partner code is partner-chosen at registration, not issued
- scope the endpoints table heading to "Affiliate API Endpoints"
- note partnerBps only appears on partner-attributed quotes
- standardize the partner-code placeholder across docs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- note the app-wide global limiter that applies on top of per-group limits
- fix "sliding window" to "fixed window" (express-rate-limit MemoryStore)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A status call requires a bound txHash, and binding immediately sets the
status to submitted, so clients never observe the internal pending state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The widget statically imports the Bitcoin/Solana AppKit adapters and tsup
externalizes them, so a consumer must install all of them or the build fails
to resolve. The previous command omitted the Bitcoin/Solana peers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The prop was declared on SwapWidgetProps but never threaded to useSwapRates,
so it had no effect and rates always refetched at the hardcoded 15s default.
Thread it through the component tree like allowedSwapperNames; an unset prop
still falls back to the 15s default in useSwapRates.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- the Bitcoin/Solana AppKit adapters are statically imported at load, so list
  them as required peers rather than optional add-ons
- document the literal apiBaseUrl default (https://api.shapeshift.com)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e doc

Those constants are ShapeShift's own protocol affiliate-account identifiers,
not part of the partner attribution system this doc describes. One of the
referenced files (CowSwapper/constants.ts) didn't contain an affiliate
constant anyway.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kaladinlight
kaladinlight requested a review from a team as a code owner June 30, 2026 21:14
@coderabbitai

coderabbitai Bot commented Jun 30, 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f90acaf1-9bdc-46c0-8976-4a12763489d0

📥 Commits

Reviewing files that changed from the base of the PR and between 42a0c05 and d667a77.

📒 Files selected for processing (9)
  • docs/affiliates.md
  • docs/architecture/affiliate-data-model.md
  • docs/architecture/affiliate-system.md
  • packages/public-api/docs/introduction.md
  • packages/public-api/docs/rest-api-guide.md
  • packages/public-api/docs/swap-widget-sdk.md
  • packages/swap-widget/README.md
  • packages/swap-widget/src/components/SwapWidget.tsx
  • packages/swap-widget/src/hooks/useSwapDisplayValues.ts
💤 Files with no reviewable changes (1)
  • docs/architecture/affiliate-data-model.md

📝 Walkthrough

Walkthrough

This PR rewrites affiliate-related documentation across docs/affiliates.md, docs/architecture/affiliate-system.md, and packages/public-api docs to describe a partner-code-based attribution model using the X-Partner-Code header, removes affiliate-data-model.md, updates the swap-widget README, and adds an optional ratesRefetchInterval parameter to SwapWidget and useSwapDisplayValues.

Changes

Affiliate documentation rewrite

Layer / File(s) Summary
Affiliate quick-start, fees and endpoints doc
docs/affiliates.md
Rewrites quick start, headers, fees, revenue attribution, and endpoint sections to use partnerCode/X-Partner-Code instead of affiliate address/bps.
Affiliate system architecture doc rewrite
docs/architecture/affiliate-system.md, docs/architecture/affiliate-data-model.md
Reframes architecture doc as "implemented" partner-code attribution flow with middleware, swap-service persistence, dashboard, and endpoints; removes the superseded data-model doc.
Public API REST and intro docs updates
packages/public-api/docs/introduction.md, packages/public-api/docs/rest-api-guide.md
Adds base URL/versioning, partner-code attribution guidance, asset discovery, rates/quote/execute/status flow details, status error codes, and affiliate reporting endpoints.
Swap Widget SDK and README documentation
packages/public-api/docs/swap-widget-sdk.md, packages/swap-widget/README.md
Shortens the SDK doc to point to the README and rewrites the README's installation, wallet connection, props reference, exported types/hooks, and partner code/affiliate revenue sections.

Swap rates refetch interval

Layer / File(s) Summary
ratesRefetchInterval threading through widget and hook
packages/swap-widget/src/components/SwapWidget.tsx, packages/swap-widget/src/hooks/useSwapDisplayValues.ts
Adds optional ratesRefetchInterval prop threaded from SwapWidget through SwapWidgetCore/SwapWidgetContent into useSwapDisplayValues, which forwards it to useSwapRates as refetchInterval.

Sequence Diagram(s)

sequenceDiagram
  participant Widget
  participant PublicAPI
  participant SwapService
  Widget->>PublicAPI: swap request with X-Partner-Code header
  PublicAPI->>SwapService: resolvePartnerCode(partnerCode)
  SwapService-->>PublicAPI: partnerAddress, partnerBps, shapeshiftBps
  PublicAPI->>PublicAPI: compute affiliateBps
  PublicAPI->>SwapService: register swap with partner split metadata
  PublicAPI-->>Widget: swap response with affiliateBps
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • shapeshift/web#12407: Both PRs modify packages/swap-widget/src/hooks/useSwapDisplayValues.ts, with this PR adding ratesRefetchInterval forwarding into useSwapRates.

Poem

A rabbit hops through docs anew,
Partner codes replace the old, it's true 🐰
X-Partner-Code now leads the way,
Rates refetch faster, come what may,
Hop hop hooray for code so spry! 🥕

🚥 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 summarizes the main doc audit and the ratesRefetchInterval wiring fix, matching the pull request scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 docs/partner-integration-docs

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.

@kaladinlight
kaladinlight merged commit d325205 into develop Jun 30, 2026
4 checks passed
@kaladinlight
kaladinlight deleted the docs/partner-integration-docs branch June 30, 2026 21:27
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