Skip to content

Commit c83f1c6

Browse files
committed
[MNY-298] SDK: Remove Bridge.routes, Update Docs (#8335)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on removing the `Bridge.routes` functionality and the `useBridgeRoutes` hook from the codebase, along with related references and documentation updates in various files. ### Detailed summary - Deleted `Routes.ts`, `Routes.test.ts`, and `useBridgeRoutes.ts` files. - Removed references to `Bridge.routes` in multiple `.mdx` files and sidebar components. - Updated `index.ts` to stop exporting `routes`. - Adjusted `useSendTransactionCore` to use `Bridge.tokens` instead of `Bridge.routes`. - Removed the `PriceComparator` class and associated methods for route comparison. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Breaking Changes** * Removed the Bridge.routes API, which previously supported route discovery with filtering by chains and tokens, pagination, and sorting * Removed the useBridgeRoutes React hook * **Documentation** * Removed documentation pages covering bridge route discovery and filtering functionality * Removed related sidebar and guide navigation links * **Tests** * Removed test suites for removed APIs <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent bc02954 commit c83f1c6

File tree

16 files changed

+11
-906
lines changed

16 files changed

+11
-906
lines changed

.changeset/rotten-apes-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": minor
3+
---
4+
5+
Remove `Bridge.routes` and `useBridgeRoutes`

apps/portal/src/app/bridge/routes/page.mdx

Lines changed: 0 additions & 172 deletions
This file was deleted.

apps/portal/src/app/bridge/sell/page.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ You can execute this quote exactly like a buy. See the [Send a Payment](/payment
6060
To connect with other auth strategies, use external wallets, or sponsor gas for users, check out the following guides:
6161

6262
- [Send a Payment](/payments/send)
63-
- [Get Routes](/payments/routes)
6463

6564
## Explore Full API References
6665

apps/portal/src/app/bridge/sidebar.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ export const sidebar: SideBar = {
2828
href: `${bridgeSlug}/tokens`,
2929
name: "Get Token Prices",
3030
},
31-
{
32-
href: `${bridgeSlug}/routes`,
33-
name: "Get Routes",
34-
},
3531
{
3632
href: `${bridgeSlug}/bridge-widget-script`,
3733
name: "BridgeWidget Script",

apps/portal/src/app/bridge/swap/page.mdx

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -255,23 +255,6 @@ export class SwapManager {
255255

256256
throw new Error("Transaction timeout - please check status manually");
257257
}
258-
259-
async getAvailableRoutes(params: {
260-
originChainId?: number;
261-
originTokenAddress?: string;
262-
destinationChainId?: number;
263-
destinationTokenAddress?: string;
264-
limit?: number;
265-
}) {
266-
try {
267-
return await Bridge.routes({
268-
...params,
269-
client: this.client,
270-
});
271-
} catch (error) {
272-
throw new Error(`Failed to get routes: ${error.message}`);
273-
}
274-
}
275258
}
276259
```
277260

@@ -319,92 +302,6 @@ async function swapEthToMatic(amount: string, userAccount: Account) {
319302
}
320303
```
321304

322-
### Advanced Price Comparison
323-
324-
Compare prices across multiple routes to find the best deal:
325-
326-
```typescript
327-
interface RouteComparison {
328-
route: any;
329-
quote: SwapQuote;
330-
priceImpact: number;
331-
gasEstimate: bigint;
332-
}
333-
334-
export class PriceComparator {
335-
private swapManager: SwapManager;
336-
337-
constructor(swapManager: SwapManager) {
338-
this.swapManager = swapManager;
339-
}
340-
341-
async compareRoutes(
342-
fromToken: { chainId: number; address: string },
343-
amount: bigint,
344-
userAddress: string
345-
): Promise<RouteComparison[]> {
346-
// Get available routes
347-
const routes = await this.swapManager.getAvailableRoutes({
348-
originChainId: fromToken.chainId,
349-
originTokenAddress: fromToken.address,
350-
limit: 10,
351-
});
352-
353-
// Get quotes for each route
354-
const comparisons: RouteComparison[] = [];
355-
356-
for (const route of routes) {
357-
try {
358-
const quote = await this.swapManager.getQuote({
359-
fromChainId: route.originToken.chainId,
360-
fromTokenAddress: route.originToken.address,
361-
toChainId: route.destinationToken.chainId,
362-
toTokenAddress: route.destinationToken.address,
363-
amount,
364-
userAddress,
365-
client: this.swapManager.client,
366-
});
367-
368-
const priceImpact = this.calculatePriceImpact(quote, amount);
369-
const gasEstimate = this.estimateGasCosts(quote);
370-
371-
comparisons.push({
372-
route,
373-
quote,
374-
priceImpact,
375-
gasEstimate,
376-
});
377-
} catch (error) {
378-
console.warn(`Failed to get quote for route ${route.originToken.symbol} -> ${route.destinationToken.symbol}:`, error);
379-
}
380-
}
381-
382-
// Sort by best output amount
383-
return comparisons.sort((a, b) =>
384-
Number(b.quote.destinationAmount) - Number(a.quote.destinationAmount)
385-
);
386-
}
387-
388-
private calculatePriceImpact(quote: SwapQuote, inputAmount: bigint): number {
389-
// Simplified price impact calculation
390-
const ratio = Number(quote.destinationAmount) / Number(quote.originAmount);
391-
return Math.abs(1 - ratio) * 100; // Percentage
392-
}
393-
394-
private estimateGasCosts(quote: SwapQuote): bigint {
395-
// Sum up gas estimates from all transactions
396-
return quote.steps.reduce((total, step) => {
397-
return total + step.transactions.reduce((stepTotal: bigint, tx: any) => {
398-
return stepTotal + (tx.gasLimit || 200000n); // Default estimate
399-
}, 0n);
400-
}, 0n);
401-
}
402-
}
403-
```
404-
405-
<Callout variant="info">
406-
**Gas Optimization Tip:** For frequently traded pairs, consider caching route data to reduce API calls and improve UI responsiveness.
407-
</Callout>
408305

409306
</TabsContent>
410307
</Tabs>
@@ -415,20 +312,16 @@ export class PriceComparator {
415312
- **Cross-chain swaps** - Exchange tokens across 50+ supported chains
416313
- **Real-time quotes** - Get up-to-date pricing and execution estimates
417314
- **Route optimization** - Find the best path for any token pair
418-
- **Price comparison** - Compare multiple routes to maximize output
419315
- **Status tracking** - Monitor cross-chain transaction progress
420316

421317

422-
423318
## Going Further
424319

425320
- [Send a Payment](/payments/send) - Learn about peer-to-peer transfers
426-
- [Get Routes](/payments/routes) - Explore route discovery APIs
427-
- [Token Prices](/payments/tokens) - Access real-time token pricing
321+
- [Token Prices](/bridge/tokens) - Access real-time token pricing
428322
- [Webhooks](/payments/webhooks) - Get notified when swaps complete
429323

430324
## API Reference
431325

432326
- [Bridge.Buy.prepare](/references/typescript/v5/buy/prepare)
433-
- [Bridge.routes](/references/typescript/v5/routes)
434327
- [Bridge.status](/references/typescript/v5/status)

apps/portal/src/app/bridge/tokens/page.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ const nextTokens = await Bridge.tokens({
119119
To connect with other auth strategies, use external wallets, or sponsor gas for users, check out the following guides:
120120

121121
- [Send a Payment](/payments/send)
122-
- [Get Routes](/payments/routes)
123122

124123
## Explore Full API References
125124

apps/portal/src/app/payments/send/page.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ Once this code completes, your payment has been fully executed. Payments normall
264264

265265
- [Sell a Product](/payments/products)
266266
- [Token Prices](/payments/tokens)
267-
- [Routes](/payments/routes)
268267

269268
## Explore API References
270269

apps/portal/src/app/payments/sidebar.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ export const sidebar: SideBar = {
4949
href: `/bridge/tokens`,
5050
name: "Get Token Prices",
5151
},
52-
{
53-
href: `/bridge/routes`,
54-
name: "Get Routes",
55-
},
5652
{
5753
href: `${paymentsSlug}/webhooks`,
5854
name: "Webhooks",

apps/portal/src/app/payments/webhooks/page.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ async function verifyWebhook(
222222
To connect with other auth strategies, use external wallets, or sponsor gas for users, check out the following guides:
223223

224224
- [Send a Payment](/payments/send)
225-
- [Find Routes](/payments/routes)
226225
- [Get Token Prices](/payments/tokens)
227226

228227
## Explore Full API References

0 commit comments

Comments
 (0)