Repository navigation
fix(routes): simplify demo quote fees - #1216
Conversation
| * quote lists the provider's fee. Otherwise the fees add up per token, such as `0.0001006 ETH`. | ||
| */ | ||
| export function quoteFee(data: Record<string, unknown>) { | ||
| if (data.subsidize === true) return undefined |
There was a problem hiding this comment.
🟡 (optional) Senders of a subsidized transfer quote no longer see fees they still pay, such as source-network gas in ETH, so the quote understates their cost. quoteFee returns undefined whenever subsidize === true, which drops every listed fee. A 1:1 subsidy only guarantees the recipient amount. Fix: on subsidized quotes, hide only fees the subsidy covers and keep separately charged fees, such as those with side: 'source'. Or show the fee line whenever fees is non-empty and drop only the 'None' row.
Why this was flagged
A keyed or keyless transfer quote returns subsidize: true with a non-empty fees array. The e2e fixture transferQuote (e2e/routes-demo.test.ts:104-111) shows such a fee: 0.0001006 ETH with side: 'source', commented "Transfers can charge source-network gas in the native asset". quoteFee returns undefined at src/lib/routes-test.ts:126, so QuoteSummary (src/components/RoutesTester.tsx:1847) shows only "You send 1 USDC / Recipient gets 1 USDC.e". On the base branch every listed fee got its own 'Fee' row. src/pages/docs/routes/quotes.mdx:40 says the fees array "lists only separately charged fees", and quotes.mdx:38 tells integrators to show fees. quotes.mdx:46 says the subsidy guarantees delivery: "the recipient receives the amount sent". It says nothing about covering source-side charges. The new e2e test 'shows a subsidized transfer quote at 1:1 with no fee line' locks this in.
Verification: The trigger is a subsidized transfer quote that comes back with a non-empty fees array, such as a source-side ETH network fee. src/lib/routes-test.ts:126 returns early with if (data.subsidize === true) return undefined, before any fee is read. On the base branch, fees.map(...) rendered a "Fee" row for every listed fee, whatever subsidize was.
Simplifies the quote summary in the Routes demo's "Get a quote" step.
destinationAmountRequired.feeslist leaves out deductions already taken fromdestinationAmount, such as conversion. Routes between currencies fall back to the listed fees.The fee logic moves to
quoteFeeinsrc/lib/routes-test.ts, with unit tests.Checks
pnpm test(80 files, 1776 tests),pnpm check,pnpm check:typese2e/routes-demo.test.ts(29 tests, new one for a subsidized transfer quote) against the dev server