diff --git a/.changeset/ninety-snails-smash.md b/.changeset/ninety-snails-smash.md new file mode 100644 index 00000000000..313b8424f53 --- /dev/null +++ b/.changeset/ninety-snails-smash.md @@ -0,0 +1,18 @@ +--- +"thirdweb": patch +--- + +Added the `sortBy` option to Bridge.routes + +```ts +import { Bridge } from "thirdweb"; + +const routes = await Bridge.routes({ + originChainId: 1, + originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + limit: 10, + offset: 0, + sortBy: "popularity", + client: thirdwebClient, +}); +``` \ No newline at end of file diff --git a/packages/thirdweb/src/bridge/Buy.ts b/packages/thirdweb/src/bridge/Buy.ts index 4590b597a07..73afcb8718d 100644 --- a/packages/thirdweb/src/bridge/Buy.ts +++ b/packages/thirdweb/src/bridge/Buy.ts @@ -91,6 +91,7 @@ import type { PreparedQuote, Quote } from "./types/Quote.js"; * @param options.destinationChainId - The chain ID of the destination token. * @param options.destinationTokenAddress - The address of the destination token. * @param options.amount - The amount of the destination token to receive. + * @param [options.maxSteps] - Limit the number of total steps in the route. * @param options.client - Your thirdweb client. * * @returns A promise that resolves to a non-finalized quote for the requested buy. @@ -307,6 +308,7 @@ export declare namespace quote { * @param options.sender - The address of the sender. * @param options.receiver - The address of the recipient. * @param options.purchaseData - Arbitrary data to be passed to the purchase function and included with any webhooks or status calls. + * @param [options.maxSteps] - Limit the number of total steps in the route. * @param options.client - Your thirdweb client. * * @returns A promise that resolves to a finalized quote and transactions for the requested buy. diff --git a/packages/thirdweb/src/bridge/Routes.ts b/packages/thirdweb/src/bridge/Routes.ts index fd31a718f7b..7304f4cfefa 100644 --- a/packages/thirdweb/src/bridge/Routes.ts +++ b/packages/thirdweb/src/bridge/Routes.ts @@ -86,6 +86,21 @@ import type { Route } from "./types/Route.js"; * }); * ``` * + * You can sort the returned routes by `popularity`: + * ```ts + * import { Bridge } from "thirdweb"; + * + * // Get the 10 most popular routes starting from mainnet ETH + * const routes = await Bridge.routes({ + * originChainId: 1, + * originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + * limit: 10, + * offset: 0, + * sortBy: "popularity", + * client: thirdwebClient, + * }); + * ``` + * * @param options - The options for the quote. * @param options.client - Your thirdweb client. * @param options.originChainId - Filter by a specific origin chain ID. @@ -94,6 +109,7 @@ import type { Route } from "./types/Route.js"; * @param options.destinationTokenAddress - Filter by a specific destination token address. * @param options.transactionHash - Filter by a specific transaction hash. * @param options.maxSteps - Limit the number of steps returned. + * @param options.sortBy - Sort the routes by various categories. * @param options.limit - Limit the number of routes returned. * @param options.offset - Offset the number of routes returned. * @@ -111,6 +127,7 @@ export async function routes(options: routes.Options): Promise { destinationChainId, destinationTokenAddress, maxSteps, + sortBy, limit, offset, } = options; @@ -138,6 +155,9 @@ export async function routes(options: routes.Options): Promise { if (offset) { url.searchParams.set("offset", offset.toString()); } + if (sortBy) { + url.searchParams.set("sortBy", sortBy); + } const response = await clientFetch(url.toString()); if (!response.ok) { @@ -157,6 +177,7 @@ export declare namespace routes { destinationChainId?: number; destinationTokenAddress?: ox__Address.Address; transactionHash?: ox__Hex.Hex; + sortBy?: "popularity"; maxSteps?: number; limit?: number; offset?: number; diff --git a/packages/thirdweb/src/bridge/Sell.ts b/packages/thirdweb/src/bridge/Sell.ts index e651c240426..6c59db3b703 100644 --- a/packages/thirdweb/src/bridge/Sell.ts +++ b/packages/thirdweb/src/bridge/Sell.ts @@ -91,6 +91,7 @@ import type { PreparedQuote, Quote } from "./types/Quote.js"; * @param options.destinationChainId - The chain ID of the destination token. * @param options.destinationTokenAddress - The address of the destination token. * @param options.amount - The amount of the origin token to sell. + * @param [options.maxSteps] - Limit the number of total steps in the route. * @param options.client - Your thirdweb client. * * @returns A promise that resolves to a non-finalized quote for the requested sell. @@ -298,6 +299,7 @@ export declare namespace quote { * @param options.sender - The address of the sender. * @param options.receiver - The address of the recipient. * @param options.purchaseData - Arbitrary data to be passed to the purchase function and included with any webhooks or status calls. + * @param [options.maxSteps] - Limit the number of total steps in the route. * @param options.client - Your thirdweb client. * * @returns A promise that resolves to a finalized quote and transactions for the requested sell.