thirdweb 5.92.3 → 5.93.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/adapters/eip1193/from-eip1193.js +7 -9
- package/dist/cjs/adapters/eip1193/from-eip1193.js.map +1 -1
- package/dist/cjs/bridge/Buy.js +199 -0
- package/dist/cjs/bridge/Buy.js.map +1 -0
- package/dist/cjs/bridge/Routes.js +134 -0
- package/dist/cjs/bridge/Routes.js.map +1 -0
- package/dist/cjs/bridge/Sell.js +199 -0
- package/dist/cjs/bridge/Sell.js.map +1 -0
- package/dist/cjs/bridge/Status.js +147 -0
- package/dist/cjs/bridge/Status.js.map +1 -0
- package/dist/cjs/bridge/constants.js +5 -0
- package/dist/cjs/bridge/constants.js.map +1 -0
- package/dist/cjs/bridge/index.js +10 -0
- package/dist/cjs/bridge/index.js.map +1 -0
- package/dist/cjs/bridge/types/Quote.js +3 -0
- package/dist/cjs/bridge/types/Quote.js.map +1 -0
- package/dist/cjs/bridge/types/Route.js +3 -0
- package/dist/cjs/bridge/types/Route.js.map +1 -0
- package/dist/cjs/bridge/types/Status.js +3 -0
- package/dist/cjs/bridge/types/Status.js.map +1 -0
- package/dist/cjs/exports/bridge.js +5 -0
- package/dist/cjs/exports/bridge.js.map +1 -0
- package/dist/cjs/exports/thirdweb.js +6 -2
- package/dist/cjs/exports/thirdweb.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/WalletSelector.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/WalletSelector.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js +11 -8
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/adapters/eip1193/from-eip1193.js +7 -9
- package/dist/esm/adapters/eip1193/from-eip1193.js.map +1 -1
- package/dist/esm/bridge/Buy.js +195 -0
- package/dist/esm/bridge/Buy.js.map +1 -0
- package/dist/esm/bridge/Routes.js +131 -0
- package/dist/esm/bridge/Routes.js.map +1 -0
- package/dist/esm/bridge/Sell.js +195 -0
- package/dist/esm/bridge/Sell.js.map +1 -0
- package/dist/esm/bridge/Status.js +144 -0
- package/dist/esm/bridge/Status.js.map +1 -0
- package/dist/esm/bridge/constants.js +2 -0
- package/dist/esm/bridge/constants.js.map +1 -0
- package/dist/esm/bridge/index.js +5 -0
- package/dist/esm/bridge/index.js.map +1 -0
- package/dist/esm/bridge/types/Quote.js +2 -0
- package/dist/esm/bridge/types/Quote.js.map +1 -0
- package/dist/esm/bridge/types/Route.js +2 -0
- package/dist/esm/bridge/types/Route.js.map +1 -0
- package/dist/esm/bridge/types/Status.js +2 -0
- package/dist/esm/bridge/types/Status.js.map +1 -0
- package/dist/esm/exports/bridge.js +2 -0
- package/dist/esm/exports/bridge.js.map +1 -0
- package/dist/esm/exports/thirdweb.js +4 -0
- package/dist/esm/exports/thirdweb.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/WalletSelector.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/WalletSelector.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js +12 -9
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/adapters/eip1193/from-eip1193.d.ts +3 -1
- package/dist/types/adapters/eip1193/from-eip1193.d.ts.map +1 -1
- package/dist/types/bridge/Buy.d.ts +171 -0
- package/dist/types/bridge/Buy.d.ts.map +1 -0
- package/dist/types/bridge/Routes.d.ts +116 -0
- package/dist/types/bridge/Routes.d.ts.map +1 -0
- package/dist/types/bridge/Sell.d.ts +171 -0
- package/dist/types/bridge/Sell.d.ts.map +1 -0
- package/dist/types/bridge/Status.d.ts +108 -0
- package/dist/types/bridge/Status.d.ts.map +1 -0
- package/dist/types/bridge/constants.d.ts +2 -0
- package/dist/types/bridge/constants.d.ts.map +1 -0
- package/dist/types/bridge/index.d.ts +8 -0
- package/dist/types/bridge/index.d.ts.map +1 -0
- package/dist/types/bridge/types/Quote.d.ts +34 -0
- package/dist/types/bridge/types/Quote.d.ts.map +1 -0
- package/dist/types/bridge/types/Route.d.ts +20 -0
- package/dist/types/bridge/types/Route.d.ts.map +1 -0
- package/dist/types/bridge/types/Status.d.ts +35 -0
- package/dist/types/bridge/types/Status.d.ts.map +1 -0
- package/dist/types/exports/bridge.d.ts +2 -0
- package/dist/types/exports/bridge.d.ts.map +1 -0
- package/dist/types/exports/thirdweb.d.ts +4 -0
- package/dist/types/exports/thirdweb.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.d.ts +1 -3
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +9 -1
- package/src/adapters/eip1193/from-eip1193.ts +10 -10
- package/src/bridge/Buy.test.ts +74 -0
- package/src/bridge/Buy.ts +267 -0
- package/src/bridge/Routes.test.ts +161 -0
- package/src/bridge/Routes.ts +160 -0
- package/src/bridge/Sell.test.ts +74 -0
- package/src/bridge/Sell.ts +267 -0
- package/src/bridge/Status.test.ts +38 -0
- package/src/bridge/Status.ts +163 -0
- package/src/bridge/constants.ts +1 -0
- package/src/bridge/index.ts +8 -0
- package/src/bridge/types/Quote.ts +42 -0
- package/src/bridge/types/Route.ts +20 -0
- package/src/bridge/types/Status.ts +39 -0
- package/src/exports/bridge.ts +1 -0
- package/src/exports/thirdweb.ts +5 -0
- package/src/react/web/ui/ConnectWallet/WalletSelector.tsx +2 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +1 -6
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.tsx +14 -35
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.tsx +1 -1
- package/src/version.ts +1 -1
@@ -0,0 +1,195 @@
|
|
1
|
+
import { getClientFetch } from "../utils/fetch.js";
|
2
|
+
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
3
|
+
/**
|
4
|
+
* Retrieves a Universal Bridge quote for the provided buy intent. The quote will specify the necessary `originAmount` to receive the desired `destinationAmount`, which is specified with the `buyAmountWei` option.
|
5
|
+
*
|
6
|
+
* @example
|
7
|
+
* ```typescript
|
8
|
+
* import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
|
9
|
+
*
|
10
|
+
* const quote = await Bridge.Buy.quote({
|
11
|
+
* originChainId: 1,
|
12
|
+
* originTokenAddress: NATIVE_TOKEN_ADDRESS,
|
13
|
+
* destinationChainId: 10,
|
14
|
+
* destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
|
15
|
+
* buyAmountWei: toWei("0.01"),
|
16
|
+
* client: thirdwebClient,
|
17
|
+
* });
|
18
|
+
* ```
|
19
|
+
*
|
20
|
+
* This will return a quote that might look like:
|
21
|
+
* ```typescript
|
22
|
+
* {
|
23
|
+
* originAmount: 10000026098875381n,
|
24
|
+
* destinationAmount: 1000000000000000000n,
|
25
|
+
* blockNumber: 22026509n,
|
26
|
+
* timestamp: 1741730936680,
|
27
|
+
* estimatedExecutionTimeMs: 1000
|
28
|
+
* intent: {
|
29
|
+
* originChainId: 1,
|
30
|
+
* originTokenAddress: NATIVE_TOKEN_ADDRESS,
|
31
|
+
* destinationChainId: 10,
|
32
|
+
* destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
|
33
|
+
* buyAmountWei: 1000000000000000000n
|
34
|
+
* }
|
35
|
+
* }
|
36
|
+
* ```
|
37
|
+
*
|
38
|
+
* The quote is an **estimate** for how much you would expect to pay for a specific buy. This quote is not guaranteed and you should use `Buy.prepare` to get a finalized quote with transaction data ready for execution.
|
39
|
+
* So why use `quote`? The quote function is sometimes slightly faster than `prepare`, and can be used before the user connects their wallet.
|
40
|
+
*
|
41
|
+
* You can access this functions input and output types with `Buy.quote.Options` and `Buy.quote.Result`, respectively.
|
42
|
+
*
|
43
|
+
* @param options - The options for the quote.
|
44
|
+
* @param options.originChainId - The chain ID of the origin token.
|
45
|
+
* @param options.originTokenAddress - The address of the origin token.
|
46
|
+
* @param options.destinationChainId - The chain ID of the destination token.
|
47
|
+
* @param options.destinationTokenAddress - The address of the destination token.
|
48
|
+
* @param options.buyAmountWei - The amount of the origin token to buy.
|
49
|
+
* @param options.client - Your thirdweb client.
|
50
|
+
*
|
51
|
+
* @returns A promise that resolves to a non-finalized quote for the requested buy.
|
52
|
+
*
|
53
|
+
* @throws Will throw an error if there is an issue fetching the quote.
|
54
|
+
* @bridge
|
55
|
+
* @beta
|
56
|
+
*/
|
57
|
+
export async function quote(options) {
|
58
|
+
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, buyAmountWei, client, } = options;
|
59
|
+
const clientFetch = getClientFetch(client);
|
60
|
+
const url = new URL(`${UNIVERSAL_BRIDGE_URL}/buy/quote`);
|
61
|
+
url.searchParams.set("originChainId", originChainId.toString());
|
62
|
+
url.searchParams.set("originTokenAddress", originTokenAddress);
|
63
|
+
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
64
|
+
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
65
|
+
url.searchParams.set("buyAmountWei", buyAmountWei.toString());
|
66
|
+
const response = await clientFetch(url.toString());
|
67
|
+
if (!response.ok) {
|
68
|
+
const errorJson = await response.json();
|
69
|
+
throw new Error(`${errorJson.code} | ${errorJson.message}`);
|
70
|
+
}
|
71
|
+
const { data } = await response.json();
|
72
|
+
return {
|
73
|
+
originAmount: BigInt(data.originAmount),
|
74
|
+
destinationAmount: BigInt(data.destinationAmount),
|
75
|
+
blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
|
76
|
+
timestamp: data.timestamp,
|
77
|
+
estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
|
78
|
+
intent: {
|
79
|
+
originChainId,
|
80
|
+
originTokenAddress,
|
81
|
+
destinationChainId,
|
82
|
+
destinationTokenAddress,
|
83
|
+
buyAmountWei,
|
84
|
+
},
|
85
|
+
};
|
86
|
+
}
|
87
|
+
/**
|
88
|
+
* Prepares a **finalized** Universal Bridge quote for the provided buy request with transaction data. This function will return everything `quote` does, with the addition of a series of prepared transactions and the associated expiration timestamp.
|
89
|
+
*
|
90
|
+
* @example
|
91
|
+
* ```typescript
|
92
|
+
* import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
|
93
|
+
*
|
94
|
+
* const quote = await Bridge.Buy.prepare({
|
95
|
+
* originChainId: 1,
|
96
|
+
* originTokenAddress: NATIVE_TOKEN_ADDRESS,
|
97
|
+
* destinationChainId: 10,
|
98
|
+
* destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
|
99
|
+
* buyAmountWei: toWei("0.01"),
|
100
|
+
* client: thirdwebClient,
|
101
|
+
* });
|
102
|
+
* ```
|
103
|
+
*
|
104
|
+
* This will return a quote that might look like:
|
105
|
+
* ```typescript
|
106
|
+
* {
|
107
|
+
* originAmount: 10000026098875381n,
|
108
|
+
* destinationAmount: 1000000000000000000n,
|
109
|
+
* blockNumber: 22026509n,
|
110
|
+
* timestamp: 1741730936680,
|
111
|
+
* estimatedExecutionTimeMs: 1000
|
112
|
+
* transactions: [
|
113
|
+
* {
|
114
|
+
* to: NATIVE_TOKEN_ADDRESS,
|
115
|
+
* value: 10000026098875381n,
|
116
|
+
* data: "0x",
|
117
|
+
* chainId: 10,
|
118
|
+
* type: "eip1559"
|
119
|
+
* }
|
120
|
+
* ],
|
121
|
+
* expiration: 1741730936680,
|
122
|
+
* intent: {
|
123
|
+
* originChainId: 1,
|
124
|
+
* originTokenAddress: NATIVE_TOKEN_ADDRESS,
|
125
|
+
* destinationChainId: 10,
|
126
|
+
* destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
|
127
|
+
* buyAmountWei: 1000000000000000000n
|
128
|
+
* }
|
129
|
+
* }
|
130
|
+
* ```
|
131
|
+
*
|
132
|
+
* ## Sending the transactions
|
133
|
+
* The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
|
134
|
+
* - Approvals and other preparation transactions are not included in the transactions array.
|
135
|
+
* - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address.
|
136
|
+
* - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
|
137
|
+
*
|
138
|
+
* NOTE: To get the status of each transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.
|
139
|
+
*
|
140
|
+
* You can access this functions input and output types with `Buy.prepare.Options` and `Buy.prepare.Result`, respectively.
|
141
|
+
*
|
142
|
+
* @param options - The options for the quote.
|
143
|
+
* @param options.originChainId - The chain ID of the origin token.
|
144
|
+
* @param options.originTokenAddress - The address of the origin token.
|
145
|
+
* @param options.destinationChainId - The chain ID of the destination token.
|
146
|
+
* @param options.destinationTokenAddress - The address of the destination token.
|
147
|
+
* @param options.buyAmountWei - The amount of the origin token to buy.
|
148
|
+
* @param options.sender - The address of the sender.
|
149
|
+
* @param options.receiver - The address of the recipient.
|
150
|
+
* @param options.client - Your thirdweb client.
|
151
|
+
*
|
152
|
+
* @returns A promise that resolves to a non-finalized quote for the requested buy.
|
153
|
+
*
|
154
|
+
* @throws Will throw an error if there is an issue fetching the quote.
|
155
|
+
* @bridge
|
156
|
+
* @beta
|
157
|
+
*/
|
158
|
+
export async function prepare(options) {
|
159
|
+
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, buyAmountWei, sender, receiver, client, } = options;
|
160
|
+
const clientFetch = getClientFetch(client);
|
161
|
+
const url = new URL(`${UNIVERSAL_BRIDGE_URL}/buy/prepare`);
|
162
|
+
url.searchParams.set("originChainId", originChainId.toString());
|
163
|
+
url.searchParams.set("originTokenAddress", originTokenAddress);
|
164
|
+
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
165
|
+
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
166
|
+
url.searchParams.set("buyAmountWei", buyAmountWei.toString());
|
167
|
+
url.searchParams.set("sender", sender);
|
168
|
+
url.searchParams.set("receiver", receiver);
|
169
|
+
const response = await clientFetch(url.toString());
|
170
|
+
if (!response.ok) {
|
171
|
+
const errorJson = await response.json();
|
172
|
+
throw new Error(`${errorJson.code} | ${errorJson.message}`);
|
173
|
+
}
|
174
|
+
const { data } = await response.json();
|
175
|
+
return {
|
176
|
+
originAmount: BigInt(data.originAmount),
|
177
|
+
destinationAmount: BigInt(data.destinationAmount),
|
178
|
+
blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
|
179
|
+
timestamp: data.timestamp,
|
180
|
+
estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
|
181
|
+
transactions: data.transactions.map((transaction) => ({
|
182
|
+
...transaction,
|
183
|
+
value: transaction.value ? BigInt(transaction.value) : undefined,
|
184
|
+
})),
|
185
|
+
expiration: data.expiration,
|
186
|
+
intent: {
|
187
|
+
originChainId,
|
188
|
+
originTokenAddress,
|
189
|
+
destinationChainId,
|
190
|
+
destinationTokenAddress,
|
191
|
+
buyAmountWei,
|
192
|
+
},
|
193
|
+
};
|
194
|
+
}
|
195
|
+
//# sourceMappingURL=Buy.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Buy.js","sourceRoot":"","sources":["../../../src/bridge/Buy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAsB;IAChD,MAAM,EACJ,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,YAAY,EACZ,MAAM,GACP,GAAG,OAAO,CAAC;IAEZ,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,oBAAoB,YAAY,CAAC,CAAC;IACzD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;IAC/D,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1E,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;IACzE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;IAE9D,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,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AAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YACpD,GAAG,WAAW;YACd,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;SACjE,CAAC,CAAC;QACH,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,MAAM,EAAE;YACN,aAAa;YACb,kBAAkB;YAClB,kBAAkB;YAClB,uBAAuB;YACvB,YAAY;SACb;KACF,CAAC;AACJ,CAAC"}
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import { getClientFetch } from "../utils/fetch.js";
|
2
|
+
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
3
|
+
/**
|
4
|
+
* Retrieves supported Universal Bridge routes based on the provided filters.
|
5
|
+
*
|
6
|
+
* When multiple filters are specified, a route must satisfy all filters to be included (it acts as an AND operator).
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
* ```typescript
|
10
|
+
* import { Bridge } from "thirdweb";
|
11
|
+
*
|
12
|
+
* const routes = await Bridge.routes({
|
13
|
+
* client: thirdwebClient,
|
14
|
+
* });
|
15
|
+
* ```
|
16
|
+
*
|
17
|
+
* Returned routes might look something like:
|
18
|
+
* ```typescript
|
19
|
+
* [
|
20
|
+
* {
|
21
|
+
* destinationToken: {
|
22
|
+
* address: "0x12c88a3C30A7AaBC1dd7f2c08a97145F5DCcD830",
|
23
|
+
* chainId: 1,
|
24
|
+
* decimals: 18,
|
25
|
+
* iconUri: "https://assets.coingecko.com/coins/images/37207/standard/G.jpg",
|
26
|
+
* name: "G7",
|
27
|
+
* symbol: "G7",
|
28
|
+
* },
|
29
|
+
* originToken: {
|
30
|
+
* address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
31
|
+
* chainId: 480,
|
32
|
+
* decimals: 18,
|
33
|
+
* iconUri: "https://assets.relay.link/icons/1/light.png",
|
34
|
+
* name: "Ether",
|
35
|
+
* symbol: "ETH",
|
36
|
+
* }
|
37
|
+
* },
|
38
|
+
* {
|
39
|
+
* destinationToken: {
|
40
|
+
* address: "0x4d224452801ACEd8B2F0aebE155379bb5D594381",
|
41
|
+
* chainId: 1,
|
42
|
+
* decimals: 18,
|
43
|
+
* iconUri: "https://coin-images.coingecko.com/coins/images/24383/large/apecoin.jpg?1696523566",
|
44
|
+
* name: "ApeCoin",
|
45
|
+
* symbol: "APE",
|
46
|
+
* },
|
47
|
+
* originToken: {
|
48
|
+
* address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
49
|
+
* chainId: 480,
|
50
|
+
* decimals: 18,
|
51
|
+
* iconUri: "https://assets.relay.link/icons/1/light.png",
|
52
|
+
* name: "Ether",
|
53
|
+
* symbol: "ETH",
|
54
|
+
* }
|
55
|
+
* }
|
56
|
+
* ]
|
57
|
+
* ```
|
58
|
+
*
|
59
|
+
* You can filter for specific chains or tokens:
|
60
|
+
* ```typescript
|
61
|
+
* import { Bridge } from "thirdweb";
|
62
|
+
*
|
63
|
+
* // Get all routes starting from mainnet ETH
|
64
|
+
* const routes = await Bridge.routes({
|
65
|
+
* originChainId: 1,
|
66
|
+
* originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
67
|
+
* client: thirdwebClient,
|
68
|
+
* });
|
69
|
+
* ```
|
70
|
+
*
|
71
|
+
* The returned routes will be limited based on the API. You can paginate through the results using the `limit` and `offset` parameters:
|
72
|
+
* ```typescript
|
73
|
+
* import { Bridge } from "thirdweb";
|
74
|
+
*
|
75
|
+
* // Get the first 10 routes starting from mainnet ETH
|
76
|
+
* const routes = await Bridge.routes({
|
77
|
+
* originChainId: 1,
|
78
|
+
* originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
79
|
+
* limit: 10,
|
80
|
+
* offset: 0,
|
81
|
+
* client: thirdwebClient,
|
82
|
+
* });
|
83
|
+
* ```
|
84
|
+
*
|
85
|
+
* @param options - The options for the quote.
|
86
|
+
* @param options.client - Your thirdweb client.
|
87
|
+
* @param options.originChainId - Filter by a specific origin chain ID.
|
88
|
+
* @param options.originTokenAddress - Filter by a specific origin token address.
|
89
|
+
* @param options.destinationChainId - Filter by a specific destination chain ID.
|
90
|
+
* @param options.destinationTokenAddress - Filter by a specific destination token address.
|
91
|
+
* @param options.transactionHash - Filter by a specific transaction hash.
|
92
|
+
* @param options.limit - Limit the number of routes returned.
|
93
|
+
* @param options.offset - Offset the number of routes returned.
|
94
|
+
*
|
95
|
+
* @returns A promise that resolves to an array of routes.
|
96
|
+
*
|
97
|
+
* @throws Will throw an error if there is an issue fetching the routes.
|
98
|
+
* @bridge
|
99
|
+
* @beta
|
100
|
+
*/
|
101
|
+
export async function routes(options) {
|
102
|
+
const { client, originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, limit, offset, } = options;
|
103
|
+
const clientFetch = getClientFetch(client);
|
104
|
+
const url = new URL(`${UNIVERSAL_BRIDGE_URL}/routes`);
|
105
|
+
if (originChainId) {
|
106
|
+
url.searchParams.set("originChainId", originChainId.toString());
|
107
|
+
}
|
108
|
+
if (originTokenAddress) {
|
109
|
+
url.searchParams.set("originTokenAddress", originTokenAddress);
|
110
|
+
}
|
111
|
+
if (destinationChainId) {
|
112
|
+
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
113
|
+
}
|
114
|
+
if (destinationTokenAddress) {
|
115
|
+
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
116
|
+
}
|
117
|
+
if (limit) {
|
118
|
+
url.searchParams.set("limit", limit.toString());
|
119
|
+
}
|
120
|
+
if (offset) {
|
121
|
+
url.searchParams.set("offset", offset.toString());
|
122
|
+
}
|
123
|
+
const response = await clientFetch(url.toString());
|
124
|
+
if (!response.ok) {
|
125
|
+
const errorJson = await response.json();
|
126
|
+
throw new Error(`${errorJson.code} | ${errorJson.message}`);
|
127
|
+
}
|
128
|
+
const { data } = await response.json();
|
129
|
+
return data;
|
130
|
+
}
|
131
|
+
//# sourceMappingURL=Routes.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Routes.js","sourceRoot":"","sources":["../../../src/bridge/Routes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAuB;IAClD,MAAM,EACJ,MAAM,EACN,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,EACL,MAAM,GACP,GAAG,OAAO,CAAC;IAEZ,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,oBAAoB,SAAS,CAAC,CAAC;IACtD,IAAI,aAAa,EAAE,CAAC;QAClB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,kBAAkB,EAAE,CAAC;QACvB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,kBAAkB,EAAE,CAAC;QACvB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,uBAAuB,EAAE,CAAC;QAC5B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,KAAK,EAAE,CAAC;QACV,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,CAAC,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAsB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
@@ -0,0 +1,195 @@
|
|
1
|
+
import { getClientFetch } from "../utils/fetch.js";
|
2
|
+
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
3
|
+
/**
|
4
|
+
* Retrieves a Universal Bridge quote for the provided sell intent. The quote will specify the expected `destinationAmount` that will be received in exchange for the specified `originAmount`, which is specified with the `sellAmountWei` option.
|
5
|
+
*
|
6
|
+
* @example
|
7
|
+
* ```typescript
|
8
|
+
* import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
|
9
|
+
*
|
10
|
+
* const quote = await Bridge.Sell.quote({
|
11
|
+
* originChainId: 1,
|
12
|
+
* originTokenAddress: NATIVE_TOKEN_ADDRESS,
|
13
|
+
* destinationChainId: 10,
|
14
|
+
* destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
|
15
|
+
* sellAmountWei: toWei("0.01"),
|
16
|
+
* client: thirdwebClient,
|
17
|
+
* });
|
18
|
+
* ```
|
19
|
+
*
|
20
|
+
* This will return a quote that might look like:
|
21
|
+
* ```typescript
|
22
|
+
* {
|
23
|
+
* originAmount: 1000000000000000000n,
|
24
|
+
* destinationAmount: 9999979011973735n,
|
25
|
+
* blockNumber: 22026509n,
|
26
|
+
* timestamp: 1741730936680,
|
27
|
+
* estimatedExecutionTimeMs: 1000
|
28
|
+
* intent: {
|
29
|
+
* originChainId: 1,
|
30
|
+
* originTokenAddress: NATIVE_TOKEN_ADDRESS,
|
31
|
+
* destinationChainId: 10,
|
32
|
+
* destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
|
33
|
+
* sellAmountWei: 1000000000000000000n
|
34
|
+
* }
|
35
|
+
* }
|
36
|
+
* ```
|
37
|
+
*
|
38
|
+
* The quote is an **estimate** for how much you would expect to receive for a specific sell. This quote is not guaranteed and you should use `Sell.prepare` to get a finalized quote with transaction data ready for execution.
|
39
|
+
* So why use `quote`? The quote function is sometimes slightly faster than `prepare`, and can be used before the user connects their wallet.
|
40
|
+
*
|
41
|
+
* You can access this functions input and output types with `Sell.quote.Options` and `Sell.quote.Result`, respectively.
|
42
|
+
*
|
43
|
+
* @param options - The options for the quote.
|
44
|
+
* @param options.originChainId - The chain ID of the origin token.
|
45
|
+
* @param options.originTokenAddress - The address of the origin token.
|
46
|
+
* @param options.destinationChainId - The chain ID of the destination token.
|
47
|
+
* @param options.destinationTokenAddress - The address of the destination token.
|
48
|
+
* @param options.sellAmountWei - The amount of the origin token to sell.
|
49
|
+
* @param options.client - Your thirdweb client.
|
50
|
+
*
|
51
|
+
* @returns A promise that resolves to a non-finalized quote for the requested sell.
|
52
|
+
*
|
53
|
+
* @throws Will throw an error if there is an issue fetching the quote.
|
54
|
+
* @bridge
|
55
|
+
* @beta
|
56
|
+
*/
|
57
|
+
export async function quote(options) {
|
58
|
+
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, sellAmountWei, client, } = options;
|
59
|
+
const clientFetch = getClientFetch(client);
|
60
|
+
const url = new URL(`${UNIVERSAL_BRIDGE_URL}/sell/quote`);
|
61
|
+
url.searchParams.set("originChainId", originChainId.toString());
|
62
|
+
url.searchParams.set("originTokenAddress", originTokenAddress);
|
63
|
+
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
64
|
+
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
65
|
+
url.searchParams.set("sellAmountWei", sellAmountWei.toString());
|
66
|
+
const response = await clientFetch(url.toString());
|
67
|
+
if (!response.ok) {
|
68
|
+
const errorJson = await response.json();
|
69
|
+
throw new Error(`${errorJson.code} | ${errorJson.message}`);
|
70
|
+
}
|
71
|
+
const { data } = await response.json();
|
72
|
+
return {
|
73
|
+
originAmount: BigInt(data.originAmount),
|
74
|
+
destinationAmount: BigInt(data.destinationAmount),
|
75
|
+
blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
|
76
|
+
timestamp: data.timestamp,
|
77
|
+
estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
|
78
|
+
intent: {
|
79
|
+
originChainId,
|
80
|
+
originTokenAddress,
|
81
|
+
destinationChainId,
|
82
|
+
destinationTokenAddress,
|
83
|
+
sellAmountWei,
|
84
|
+
},
|
85
|
+
};
|
86
|
+
}
|
87
|
+
/**
|
88
|
+
* Prepares a **finalized** Universal Bridge quote for the provided sell request with transaction data. This function will return everything `quote` does, with the addition of a series of prepared transactions and the associated expiration timestamp.
|
89
|
+
*
|
90
|
+
* @example
|
91
|
+
* ```typescript
|
92
|
+
* import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
|
93
|
+
*
|
94
|
+
* const quote = await Bridge.Sell.prepare({
|
95
|
+
* originChainId: 1,
|
96
|
+
* originTokenAddress: NATIVE_TOKEN_ADDRESS,
|
97
|
+
* destinationChainId: 10,
|
98
|
+
* destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
|
99
|
+
* sellAmountWei: toWei("0.01"),
|
100
|
+
* client: thirdwebClient,
|
101
|
+
* });
|
102
|
+
* ```
|
103
|
+
*
|
104
|
+
* This will return a quote that might look like:
|
105
|
+
* ```typescript
|
106
|
+
* {
|
107
|
+
* originAmount: 1000000000000000000n,
|
108
|
+
* destinationAmount: 9980000000000000000n,
|
109
|
+
* blockNumber: 22026509n,
|
110
|
+
* timestamp: 1741730936680,
|
111
|
+
* estimatedExecutionTimeMs: 1000
|
112
|
+
* transactions: [
|
113
|
+
* {
|
114
|
+
* to: NATIVE_TOKEN_ADDRESS,
|
115
|
+
* value: 9980000000000000000n,
|
116
|
+
* data: "0x",
|
117
|
+
* chainId: 10,
|
118
|
+
* type: "eip1559"
|
119
|
+
* }
|
120
|
+
* ],
|
121
|
+
* expiration: 1741730936680,
|
122
|
+
* intent: {
|
123
|
+
* originChainId: 1,
|
124
|
+
* originTokenAddress: NATIVE_TOKEN_ADDRESS,
|
125
|
+
* destinationChainId: 10,
|
126
|
+
* destinationTokenAddress: NATIVE_TOKEN_ADDRESS,
|
127
|
+
* sellAmountWei: 1000000000000000000n
|
128
|
+
* }
|
129
|
+
* }
|
130
|
+
* ```
|
131
|
+
*
|
132
|
+
* ## Sending the transactions
|
133
|
+
* The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
|
134
|
+
* - Approvals and other preparation transactions are not included in the transactions array.
|
135
|
+
* - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address.
|
136
|
+
* - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
|
137
|
+
*
|
138
|
+
* NOTE: To get the status of each transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full bridge completion on the destination chain.
|
139
|
+
*
|
140
|
+
* You can access this functions input and output types with `Sell.prepare.Options` and `Sell.prepare.Result`, respectively.
|
141
|
+
*
|
142
|
+
* @param options - The options for the quote.
|
143
|
+
* @param options.originChainId - The chain ID of the origin token.
|
144
|
+
* @param options.originTokenAddress - The address of the origin token.
|
145
|
+
* @param options.destinationChainId - The chain ID of the destination token.
|
146
|
+
* @param options.destinationTokenAddress - The address of the destination token.
|
147
|
+
* @param options.sellAmountWei - The amount of the origin token to sell.
|
148
|
+
* @param options.sender - The address of the sender.
|
149
|
+
* @param options.receiver - The address of the recipient.
|
150
|
+
* @param options.client - Your thirdweb client.
|
151
|
+
*
|
152
|
+
* @returns A promise that resolves to a non-finalized quote for the requested buy.
|
153
|
+
*
|
154
|
+
* @throws Will throw an error if there is an issue fetching the quote.
|
155
|
+
* @bridge
|
156
|
+
* @beta
|
157
|
+
*/
|
158
|
+
export async function prepare(options) {
|
159
|
+
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, sellAmountWei, sender, receiver, client, } = options;
|
160
|
+
const clientFetch = getClientFetch(client);
|
161
|
+
const url = new URL(`${UNIVERSAL_BRIDGE_URL}/sell/prepare`);
|
162
|
+
url.searchParams.set("originChainId", originChainId.toString());
|
163
|
+
url.searchParams.set("originTokenAddress", originTokenAddress);
|
164
|
+
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
165
|
+
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
166
|
+
url.searchParams.set("sellAmountWei", sellAmountWei.toString());
|
167
|
+
url.searchParams.set("sender", sender);
|
168
|
+
url.searchParams.set("receiver", receiver);
|
169
|
+
const response = await clientFetch(url.toString());
|
170
|
+
if (!response.ok) {
|
171
|
+
const errorJson = await response.json();
|
172
|
+
throw new Error(`${errorJson.code} | ${errorJson.message}`);
|
173
|
+
}
|
174
|
+
const { data } = await response.json();
|
175
|
+
return {
|
176
|
+
originAmount: BigInt(data.originAmount),
|
177
|
+
destinationAmount: BigInt(data.destinationAmount),
|
178
|
+
blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
|
179
|
+
timestamp: data.timestamp,
|
180
|
+
estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
|
181
|
+
transactions: data.transactions.map((transaction) => ({
|
182
|
+
...transaction,
|
183
|
+
value: transaction.value ? BigInt(transaction.value) : undefined,
|
184
|
+
})),
|
185
|
+
expiration: data.expiration,
|
186
|
+
intent: {
|
187
|
+
originChainId,
|
188
|
+
originTokenAddress,
|
189
|
+
destinationChainId,
|
190
|
+
destinationTokenAddress,
|
191
|
+
sellAmountWei,
|
192
|
+
},
|
193
|
+
};
|
194
|
+
}
|
195
|
+
//# sourceMappingURL=Sell.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Sell.js","sourceRoot":"","sources":["../../../src/bridge/Sell.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAsB;IAChD,MAAM,EACJ,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,aAAa,EACb,MAAM,GACP,GAAG,OAAO,CAAC;IAEZ,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,oBAAoB,aAAa,CAAC,CAAC;IAC1D,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;IAC/D,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC1E,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,yBAAyB,EAAE,uBAAuB,CAAC,CAAC;IACzE,GAAG,CAAC,YAAY,CAAC,GAAG,C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