diff --git a/e2e/routes-demo.test.ts b/e2e/routes-demo.test.ts
index 4e8ac9533..8cee6f510 100644
--- a/e2e/routes-demo.test.ts
+++ b/e2e/routes-demo.test.ts
@@ -597,6 +597,8 @@ async function chooseRoute(page: Page, from: [string, string], to: [string, stri
await pick(toSelect(page, 'Asset'), to[1])
}
const lifecycle = (page: Page) => page.locator('.routes-test-lifecycle')
+/** The quote summary: what is sent, what arrives, and any fee. */
+const quoteSummary = (page: Page) => lifecycle(page).locator('dl').first()
const button = (page: Page, name: string) => page.getByRole('button', { name, exact: true })
/** A funding method in the Transfer / Deposit address segmented control. */
const method = (page: Page, name: string) => page.getByRole('radio', { name, exact: true })
@@ -675,10 +677,11 @@ test.describe('Routes demo', () => {
await openDemo(page)
await quoteBaseTransfer(page)
- // Transfer fees are charged on top of the routed amount, here in ETH.
+ // Without 1:1 delivery, the fee is the whole gap between what is sent and what arrives.
await expect(lifecycle(page)).toContainText(
- 'You send1 USDCRecipient gets0.9991 USDC.eFee0.0001006 ETH',
+ 'You send1 USDCRecipient gets0.9991 USDC.eFee0.0009 USDC',
)
+ await expect(quoteSummary(page).getByText('Fee', { exact: true })).toHaveCount(1)
const [quote] = api.to('GET', '/v1/routes/transfers/quote')
expect(Object.fromEntries(quote.query)).toMatchObject({
amount: '1000000',
@@ -782,6 +785,23 @@ test.describe('Routes demo', () => {
expect(sent).toEqual({ Rabby: 0, MetaMask: 2 })
})
+ test('shows a subsidized transfer quote at 1:1 with no fee line', async ({ page }) => {
+ await mockRoutesApi(page, {
+ 'GET /v1/routes': [directory],
+ 'GET /v1/routes/transfers/quote': [
+ // A subsidized transfer quote keeps the provider's amount and fee, and guarantees 1:1.
+ { body: { ...transferQuote, subsidize: true, destinationAmountRequired: usd('1') } },
+ ],
+ })
+ await openDemo(page)
+ await chooseRoute(page, ['Base', 'USDC'], ['Tempo', 'USDC.e'])
+ await page.getByLabel('Amount (USDC)').fill('1')
+ await page.getByLabel('Sender on Base').fill(sender)
+ await page.getByLabel('Recipient on Tempo').fill(tempoRecipient)
+ await button(page, 'Get quote').click()
+ await expect(quoteSummary(page)).toHaveText('You send1 USDCRecipient gets1 USDC.e')
+ })
+
test('quotes subsidized 1:1 delivery and watches a deposit through delivery', async ({
page,
}) => {
@@ -811,11 +831,10 @@ test.describe('Routes demo', () => {
await page.getByLabel('Refund address on Base').fill(sender)
await button(page, 'Get quote').click()
- // Tempo covers the gap between the routed amount (0.9591) and 1:1 delivery.
- await expect(lifecycle(page)).toContainText(
- 'Recipient gets1 USDC.eCovered by Tempo0.0409 USDC.eFeesNone',
- )
- await expect(lifecycle(page)).not.toContainText('1:1 delivery preview')
+ // 1:1 delivery: the recipient gets the amount sent, with no fee line.
+ await expect(lifecycle(page)).toContainText('You send1 USDCRecipient gets1 USDC.e')
+ await expect(lifecycle(page)).not.toContainText('Covered by Tempo')
+ await expect(quoteSummary(page)).not.toContainText('Fee')
const quoteQuery = Object.fromEntries(
api.to('GET', '/v1/routes/deposit-addresses/quote')[0].query,
)
@@ -1379,10 +1398,8 @@ test.describe('Routes demo without a key', () => {
// Only an approved organization can quote 1:1 delivery, so the docs key prices the preview.
await expect(lifecycle(page)).toContainText('Recipient gets1 USDC.e')
- await expect(lifecycle(page)).toContainText('Covered by Tempo0.0409 USDC.e')
- await expect(lifecycle(page)).toContainText(
- '1:1 delivery preview from the docs demo organization. Creating a 1:1 route needs subsidy approval for your organization.',
- )
+ await expect(lifecycle(page)).not.toContainText('Covered by Tempo')
+ await expect(lifecycle(page)).not.toContainText('1:1 delivery preview')
await expect(lifecycle(page)).toContainText(
'Add your Tempo API key here to create routes with configured pricing. Get yours in the Tempo API console.',
)
@@ -1401,8 +1418,8 @@ test.describe('Routes demo without a key', () => {
await expect(page.getByLabel('Project API key')).toBeFocused()
await page.getByLabel('Project API key').fill(key)
await button(page, 'Use key').click()
- await expect(lifecycle(page)).toContainText('Covered by Tempo0.0009 USDC.e')
- await expect(lifecycle(page)).not.toContainText('1:1 delivery preview')
+ await expect(lifecycle(page)).toContainText('Recipient gets1 USDC.e')
+ await expect(lifecycle(page)).not.toContainText('Covered by Tempo')
const keyed = api.to('GET', '/v1/routes/deposit-addresses/quote').at(-1)
expect(keyed?.headers['tempo-api-key']).toBe(key)
expect(keyed?.query.get('subsidize')).toBe('true')
@@ -1425,14 +1442,15 @@ test.describe('Routes demo without a key', () => {
await page.getByLabel('Recipient on Tempo').fill(tempoRecipient)
await page.getByLabel('Refund address on Base').fill(sender)
await button(page, 'Get quote').click()
- await expect(lifecycle(page)).toContainText('1:1 delivery preview')
+ await expect(quoteSummary(page)).toHaveText('You send1 USDCRecipient gets1 USDC.e')
await addKey(page, key)
await expect(lifecycle(page)).toContainText('Recipient gets0.9591 USDC.e')
await expect(lifecycle(page)).toContainText(
'Quoted without 1:1 delivery. This organization is not approved for 1:1 delivery on this route. (routes_subsidy_not_allowed · request req_sub)',
)
- await expect(lifecycle(page)).not.toContainText('1:1 delivery preview')
+ // Without the subsidy, the one fee line returns.
+ await expect(quoteSummary(page)).toContainText('Recipient gets0.9591 USDC.eFee0.0409 USDC')
expect(
api.to('GET', '/v1/routes/deposit-addresses/quote').map((q) => q.query.get('subsidize')),
).toEqual(['true', 'false'])
diff --git a/src/components/RoutesTester.tsx b/src/components/RoutesTester.tsx
index df8f6791b..1dd956a98 100644
--- a/src/components/RoutesTester.tsx
+++ b/src/components/RoutesTester.tsx
@@ -56,6 +56,7 @@ import {
demoMethods,
linkedRoute,
quickRoutes,
+ quoteFee,
type RoutePick,
routeChoices,
routeQuoteRequest,
@@ -417,8 +418,6 @@ function RouteLifecycle({
// Why the open quote lacks 1:1 delivery, when the API refused it.
const [subsidyNotice, setSubsidyNotice] = useState('')
const [quote, setQuote] = useState
- 1:1 delivery preview from the docs demo organization. Creating a 1:1 route needs - subsidy approval for your organization. -
- )} > ) : (