@@ -86,6 +86,21 @@ import type { Route } from "./types/Route.js";
8686 * });
8787 * ```
8888 *
89+ * You can sort the returned routes by `popularity`:
90+ * ```ts
91+ * import { Bridge } from "thirdweb";
92+ *
93+ * // Get the 10 most popular routes starting from mainnet ETH
94+ * const routes = await Bridge.routes({
95+ * originChainId: 1,
96+ * originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
97+ * limit: 10,
98+ * offset: 0,
99+ * sortBy: "popularity",
100+ * client: thirdwebClient,
101+ * });
102+ * ```
103+ *
89104 * @param options - The options for the quote.
90105 * @param options.client - Your thirdweb client.
91106 * @param options.originChainId - Filter by a specific origin chain ID.
@@ -94,6 +109,7 @@ import type { Route } from "./types/Route.js";
94109 * @param options.destinationTokenAddress - Filter by a specific destination token address.
95110 * @param options.transactionHash - Filter by a specific transaction hash.
96111 * @param options.maxSteps - Limit the number of steps returned.
112+ * @param options.sortBy - Sort the routes by various categories.
97113 * @param options.limit - Limit the number of routes returned.
98114 * @param options.offset - Offset the number of routes returned.
99115 *
@@ -111,6 +127,7 @@ export async function routes(options: routes.Options): Promise<routes.Result> {
111127 destinationChainId,
112128 destinationTokenAddress,
113129 maxSteps,
130+ sortBy,
114131 limit,
115132 offset,
116133 } = options ;
@@ -138,6 +155,9 @@ export async function routes(options: routes.Options): Promise<routes.Result> {
138155 if ( offset ) {
139156 url . searchParams . set ( "offset" , offset . toString ( ) ) ;
140157 }
158+ if ( sortBy ) {
159+ url . searchParams . set ( "sortBy" , sortBy ) ;
160+ }
141161
142162 const response = await clientFetch ( url . toString ( ) ) ;
143163 if ( ! response . ok ) {
@@ -157,6 +177,7 @@ export declare namespace routes {
157177 destinationChainId ?: number ;
158178 destinationTokenAddress ?: ox__Address . Address ;
159179 transactionHash ?: ox__Hex . Hex ;
180+ sortBy ?: "popularity" ;
160181 maxSteps ?: number ;
161182 limit ?: number ;
162183 offset ?: number ;
0 commit comments