@@ -20,6 +20,34 @@ export type FlexibleConfig<T> =
2020 | PerTradeTypeConfig < PerNetworkConfig < T > >
2121 | PerNetworkConfig < PerTradeTypeConfig < T > >
2222
23+ /**
24+ * A single forbidden sell→buy token combination for the widget.
25+ *
26+ * Used as an entry in {@link CowSwapWidgetParams.tokenPairConstraints} to
27+ * prevent users from creating orders that swap the given `sell` token for
28+ * the given `buy` token (in that direction). Reversing the direction —
29+ * trading `buy` for `sell` — is **not** blocked unless an explicit entry
30+ * for the reverse pair is also supplied.
31+ *
32+ * Addresses are matched case-insensitively against the user's selected
33+ * tokens; `chainId` must match the active widget chain for the entry to
34+ * apply.
35+ *
36+ * @example
37+ * ```ts
38+ * tokenPairConstraints: [
39+ * {
40+ * sell: { address: '0xA0b8...eB48', chainId: SupportedChainId.MAINNET },
41+ * buy: { address: '0xdAC1...1ec7', chainId: SupportedChainId.MAINNET },
42+ * },
43+ * ]
44+ * ```
45+ */
46+ export type TokenPairConstraint = {
47+ sell : { address : string ; chainId : SupportedChainId }
48+ buy : { address : string ; chainId : SupportedChainId }
49+ }
50+
2351export enum WidgetMethodsEmit {
2452 ACTIVATE = 'ACTIVATE' ,
2553 READY = 'READY' ,
@@ -453,10 +481,7 @@ export interface CowSwapWidgetParams {
453481 /**
454482 * Disables trading of specific token pair
455483 */
456- tokenPairConstraints ?: {
457- sell : { address : string ; chainId : SupportedChainId }
458- buy : { address : string ; chainId : SupportedChainId }
459- } [ ]
484+ tokenPairConstraints ?: TokenPairConstraint [ ]
460485
461486 hooks ?: Partial < {
462487 onBeforeApproval ( payload : OnApprovalPayload ) : WidgetHookResult
0 commit comments