From c6ac9283e3910414b224d70830bca0b67672e259 Mon Sep 17 00:00:00 2001 From: azebuado <306174565+azebuado@users.noreply.github.com> Date: Fri, 20 Nov 2026 16:31:07 +0000 Subject: [PATCH] feat(widget): add prioritizedTokens widget setting entry --- docs/cow-protocol/tutorials/widget/widget.md | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/cow-protocol/tutorials/widget/widget.md b/docs/cow-protocol/tutorials/widget/widget.md index 45f2f867b..c830947f6 100644 --- a/docs/cow-protocol/tutorials/widget/widget.md +++ b/docs/cow-protocol/tutorials/widget/widget.md @@ -400,6 +400,7 @@ createCowSwapWidget(document.getElementById('cowswap-widget'), { | `customTokens` | `TokenInfo[]` | --- | Use tokens not in the default token lists by passing an array of ERC-20 token info objects. See also `tokenLists` for list-based configuration. | | `hideRecentTokens` | `boolean` | false | Hides the "Recent tokens" section in the token selector. | | `hideFavoriteTokens` | `boolean` | false | Hides the "Favorite tokens" section in the token selector. | +| `prioritizedTokens` | `Partial>` | --- | Token addresses per network to move up in the token selector, right after the native token and the tokens the wallet holds. See [Prioritized tokens](#prioritizedtokens) section for more details. | | `disableTokenImport` | `boolean` | false | Disables adding custom tokens and custom token lists by the user. | | `disableEIP2612Permits` | `boolean` | false | Disables the EIP-2612 permit signing flow. When `true`, the widget never signs an off-chain permit and always sends an on-chain approval transaction, even for tokens that support permit. | | `disableInfiniteApprove` | `boolean` | false | Disables infinite (`MAX_UINT256`) ERC-20 approvals. When `true`, every approval transaction approves only the exact trade-size amount, and the "Partial approval" toggle in Settings is shown but locked on. | @@ -523,6 +524,39 @@ const params: CowSwapWidgetParams = { customTokens } createCowSwapWidget(container, { params }) ``` +### `prioritizedTokens` + +Use `prioritizedTokens` to move your own tokens up the "All tokens" list in the token selector, without hiding the others. The list is keyed by chain id, and the selector uses the list of the network it shows, including a bridge destination network. + +The list is ordered as follows: + +1. The native token +2. Tokens the wallet holds (a prioritized token with a balance stays in this group) +3. Prioritized tokens without a balance, in the configured order +4. All other tokens + +Only the order changes: prioritized tokens get no badge or separate section. Search results, "Favorite tokens" and "Recent tokens" are unchanged. Addresses missing from the active token lists are skipped; add them with [`customTokens`](#customtokens). + +```typescript +import { createCowSwapWidget, CowSwapWidgetParams } from '@cowprotocol/widget-lib' + +const container = document.getElementById('cowswap-widget') + +const params: CowSwapWidgetParams = { + prioritizedTokens: { + 1: [ + '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0', // wstETH + '0x5A98FcBEA516Cf06857215779Fd812CA3beF1B32', // LDO + ], + 42161: ['0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f'], // WBTC + }, +} + +createCowSwapWidget(container, { params }) +``` + +In the [widget configurator](https://widget.cow.fi), set it under Tokens → "Prioritized tokens", one address per line. + --- ## Token pair constraints