Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rotten-apes-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": minor
---

Remove `Bridge.routes` and `useBridgeRoutes`
Comment on lines +2 to +5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Use "major" version bump for breaking API removals.

Removing public APIs (Bridge.routes and useBridgeRoutes) is a breaking change and requires a major version bump, not minor. Additionally, the changeset description should clearly surface the breaking nature of this change.

Apply this diff to correct the version bump and improve the changeset description:

---
-"thirdweb": minor
+"thirdweb": major
---

-Remove `Bridge.routes` and `useBridgeRoutes`
+BREAKING: Remove `Bridge.routes` and `useBridgeRoutes` public APIs

Per coding guidelines and learnings: patch for non‑API changes; major for breaking API removals. Breaking changes should be surfaced prominently in PR descriptions.

🤖 Prompt for AI Agents
In .changeset/rotten-apes-sing.md around lines 2 to 5, the changeset incorrectly
uses a "minor" bump while removing public APIs (Bridge.routes and
useBridgeRoutes); change the version bump from "minor" to "major" and update the
changeset body to explicitly state this is a breaking change that removes those
public APIs and list migration guidance (e.g., alternative APIs or removal
notice) so the breaking nature is clearly surfaced in the description.

172 changes: 0 additions & 172 deletions apps/portal/src/app/bridge/routes/page.mdx

This file was deleted.

1 change: 0 additions & 1 deletion apps/portal/src/app/bridge/sell/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ You can execute this quote exactly like a buy. See the [Send a Payment](/payment
To connect with other auth strategies, use external wallets, or sponsor gas for users, check out the following guides:

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

## Explore Full API References

Expand Down
4 changes: 0 additions & 4 deletions apps/portal/src/app/bridge/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ export const sidebar: SideBar = {
href: `${bridgeSlug}/tokens`,
name: "Get Token Prices",
},
{
href: `${bridgeSlug}/routes`,
name: "Get Routes",
},
{
href: `${bridgeSlug}/bridge-widget-script`,
name: "BridgeWidget Script",
Expand Down
109 changes: 1 addition & 108 deletions apps/portal/src/app/bridge/swap/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,6 @@ export class SwapManager {

throw new Error("Transaction timeout - please check status manually");
}

async getAvailableRoutes(params: {
originChainId?: number;
originTokenAddress?: string;
destinationChainId?: number;
destinationTokenAddress?: string;
limit?: number;
}) {
try {
return await Bridge.routes({
...params,
client: this.client,
});
} catch (error) {
throw new Error(`Failed to get routes: ${error.message}`);
}
}
}
```

Expand Down Expand Up @@ -319,92 +302,6 @@ async function swapEthToMatic(amount: string, userAccount: Account) {
}
```

### Advanced Price Comparison

Compare prices across multiple routes to find the best deal:

```typescript
interface RouteComparison {
route: any;
quote: SwapQuote;
priceImpact: number;
gasEstimate: bigint;
}

export class PriceComparator {
private swapManager: SwapManager;

constructor(swapManager: SwapManager) {
this.swapManager = swapManager;
}

async compareRoutes(
fromToken: { chainId: number; address: string },
amount: bigint,
userAddress: string
): Promise<RouteComparison[]> {
// Get available routes
const routes = await this.swapManager.getAvailableRoutes({
originChainId: fromToken.chainId,
originTokenAddress: fromToken.address,
limit: 10,
});

// Get quotes for each route
const comparisons: RouteComparison[] = [];

for (const route of routes) {
try {
const quote = await this.swapManager.getQuote({
fromChainId: route.originToken.chainId,
fromTokenAddress: route.originToken.address,
toChainId: route.destinationToken.chainId,
toTokenAddress: route.destinationToken.address,
amount,
userAddress,
client: this.swapManager.client,
});

const priceImpact = this.calculatePriceImpact(quote, amount);
const gasEstimate = this.estimateGasCosts(quote);

comparisons.push({
route,
quote,
priceImpact,
gasEstimate,
});
} catch (error) {
console.warn(`Failed to get quote for route ${route.originToken.symbol} -> ${route.destinationToken.symbol}:`, error);
}
}

// Sort by best output amount
return comparisons.sort((a, b) =>
Number(b.quote.destinationAmount) - Number(a.quote.destinationAmount)
);
}

private calculatePriceImpact(quote: SwapQuote, inputAmount: bigint): number {
// Simplified price impact calculation
const ratio = Number(quote.destinationAmount) / Number(quote.originAmount);
return Math.abs(1 - ratio) * 100; // Percentage
}

private estimateGasCosts(quote: SwapQuote): bigint {
// Sum up gas estimates from all transactions
return quote.steps.reduce((total, step) => {
return total + step.transactions.reduce((stepTotal: bigint, tx: any) => {
return stepTotal + (tx.gasLimit || 200000n); // Default estimate
}, 0n);
}, 0n);
}
}
```

<Callout variant="info">
**Gas Optimization Tip:** For frequently traded pairs, consider caching route data to reduce API calls and improve UI responsiveness.
</Callout>

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



## Going Further

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

## API Reference

- [Bridge.Buy.prepare](/references/typescript/v5/buy/prepare)
- [Bridge.routes](/references/typescript/v5/routes)
- [Bridge.status](/references/typescript/v5/status)
1 change: 0 additions & 1 deletion apps/portal/src/app/bridge/tokens/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ const nextTokens = await Bridge.tokens({
To connect with other auth strategies, use external wallets, or sponsor gas for users, check out the following guides:

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

## Explore Full API References

Expand Down
1 change: 0 additions & 1 deletion apps/portal/src/app/payments/send/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ Once this code completes, your payment has been fully executed. Payments normall

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

## Explore API References

Expand Down
4 changes: 0 additions & 4 deletions apps/portal/src/app/payments/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ export const sidebar: SideBar = {
href: `/bridge/tokens`,
name: "Get Token Prices",
},
{
href: `/bridge/routes`,
name: "Get Routes",
},
{
href: `${paymentsSlug}/webhooks`,
name: "Webhooks",
Expand Down
1 change: 0 additions & 1 deletion apps/portal/src/app/payments/webhooks/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ async function verifyWebhook(
To connect with other auth strategies, use external wallets, or sponsor gas for users, check out the following guides:

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

## Explore Full API References
Expand Down
Loading
Loading