@switch-win/sdk 1.2.1 → 1.2.3

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/ROBINHOOD.md CHANGED
@@ -1,610 +1,706 @@
1
- # Switch SDK — Robinhood Chain
2
-
3
- Production integration reference for Switch swaps on Robinhood Chain mainnet.
4
-
5
- | Setting | Value |
6
- |---|---|
7
- | API network | `robinhood` |
8
- | Chain ID | `4663` |
9
- | Native currency | ETH (18 decimals) |
10
- | Public RPC | `https://rpc.mainnet.chain.robinhood.com` |
11
- | Explorer | `https://robinhoodchain.blockscout.com` |
12
- | Quote API | `https://quote.switch.win/swap/quote` |
13
- | Tax API | `https://quote.switch.win/swap/checkTax` |
14
- | Supported liquidity | Uniswap V2, V3, and hookless static-fee V4 |
15
- | Limit orders | Not currently available |
16
-
17
- ## Contents
18
-
19
- - [Installation](#installation)
20
- - [Authentication](#authentication)
21
- - [Network configuration](#network-configuration)
22
- - [Contracts and native currency](#contracts-and-native-currency)
23
- - [Uniswap V4 routing](#uniswap-v4-routing)
24
- - [Swap integration flow](#swap-integration-flow)
25
- - [Quickstart](#quickstart)
26
- - [Tax-token checks](#tax-token-checks)
27
- - [Selecting `feeOnOutput`](#selecting-feeonoutput)
28
- - [Approving and executing](#approving-and-executing)
29
- - [Swap API reference](#swap-api-reference)
30
- - [Error handling](#error-handling)
31
- - [Partner fee sharing](#partner-fee-sharing)
32
- - [Tokens and routing](#tokens-and-routing)
33
- - [Rate limits](#rate-limits)
34
- - [Current limitations](#current-limitations)
35
-
36
- ## Installation
37
-
38
- ```bash
39
- npm install @switch-win/sdk
40
- ```
41
-
42
- ```ts
43
- import {
44
- ROBINHOOD_CHAIN,
45
- ROBINHOOD_NATIVE_ETH,
46
- ROBINHOOD_SWITCH_CONTRACTS,
47
- ROBINHOOD_UNISWAP_CONTRACTS,
48
- ROBINHOOD_TOKENS,
49
- ROBINHOOD_FEE_TOKEN_PRIORITY,
50
- ROBINHOOD_FRONTEND_DEFAULT_TOKENS,
51
- ROBINHOOD_FRONTEND_TOKEN_LIST,
52
- buildRobinhoodQuoteUrl,
53
- type BestPathResponse,
54
- } from "@switch-win/sdk";
55
- ```
56
-
57
- The same exports are available from the smaller network entrypoint:
58
-
59
- ```ts
60
- import {
61
- ROBINHOOD_CHAIN,
62
- ROBINHOOD_TOKENS,
63
- buildRobinhoodQuoteUrl,
64
- } from "@switch-win/sdk/networks/robinhood";
65
- ```
66
-
67
- ## Authentication
68
-
69
- Every request to `quote.switch.win` requires a Switch API key in the
70
- `x-api-key` header:
71
-
72
- ```ts
73
- const headers = {
74
- "x-api-key": process.env.SWITCH_API_KEY!,
75
- };
76
- ```
77
-
78
- Do not expose a production API key in browser JavaScript. Browser applications
79
- should call a same-origin server route that attaches the key before forwarding
80
- the request to Switch.
81
-
82
- ## Network configuration
83
-
84
- `ROBINHOOD_CHAIN` can be adapted directly for most wallet libraries:
85
-
86
- ```ts
87
- const robinhoodWalletChain = {
88
- chainId: `0x${ROBINHOOD_CHAIN.id.toString(16)}`,
89
- chainName: ROBINHOOD_CHAIN.name,
90
- nativeCurrency: ROBINHOOD_CHAIN.nativeCurrency,
91
- rpcUrls: [...ROBINHOOD_CHAIN.rpcUrls],
92
- blockExplorerUrls: [ROBINHOOD_CHAIN.blockExplorerUrl],
93
- };
94
-
95
- await window.ethereum.request({
96
- method: "wallet_addEthereumChain",
97
- params: [robinhoodWalletChain],
98
- });
99
- ```
100
-
101
- ## Contracts and native currency
102
-
103
- ### Switch deployment
104
-
105
- | Contract | Address |
106
- |---|---|
107
- | SwitchRouter | `0x8730C3e2cF2c8CDa8E6166837A1Ed26f46aa9E59` |
108
- | Uniswap V2 adapter | `0x7a14d7A8509a66209D4332843b983b29bF5604A4` |
109
- | Uniswap V3 adapter | `0xbcA08f296d9Ba0dc19Aa0E05D355365cE29A3205` |
1
+ # Switch SDK — Robinhood Chain
2
+
3
+ Production integration reference for Switch swaps on Robinhood Chain mainnet.
4
+
5
+ | Setting | Value |
6
+ |---|---|
7
+ | API network | `robinhood` |
8
+ | Chain ID | `4663` |
9
+ | Native currency | ETH (18 decimals) |
10
+ | Public RPC | `https://rpc.mainnet.chain.robinhood.com` |
11
+ | Explorer | `https://robinhoodchain.blockscout.com` |
12
+ | Quote API | `https://quote.switch.win/swap/quote` |
13
+ | Tax API | `https://quote.switch.win/swap/checkTax` |
14
+ | Supported liquidity | 14 adapters: Uniswap V2/V3/V4, Switch limit orders, SwapHood, Up33, Sheriff, Aeon, Catnip, PancakeSwap, RobinSwap, and SushiSwap |
15
+ | Limit orders | Available: EIP-712 ERC-20 orders plus native ETH flow |
16
+
17
+ ## Contents
18
+
19
+ - [Installation](#installation)
20
+ - [Authentication](#authentication)
21
+ - [Network configuration](#network-configuration)
22
+ - [Contracts and native currency](#contracts-and-native-currency)
23
+ - [Uniswap V4 routing](#uniswap-v4-routing)
24
+ - [Swap integration flow](#swap-integration-flow)
25
+ - [Quickstart](#quickstart)
26
+ - [Tax-token checks](#tax-token-checks)
27
+ - [Selecting `feeOnOutput`](#selecting-feeonoutput)
28
+ - [Approving and executing](#approving-and-executing)
29
+ - [Swap API reference](#swap-api-reference)
30
+ - [Error handling](#error-handling)
31
+ - [Partner fee sharing](#partner-fee-sharing)
32
+ - [Tokens and routing](#tokens-and-routing)
33
+ - [Rate limits](#rate-limits)
34
+ - [Current limitations](#current-limitations)
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ npm install @switch-win/sdk
40
+ ```
41
+
42
+ ```ts
43
+ import {
44
+ ROBINHOOD_CHAIN,
45
+ ROBINHOOD_NATIVE_ETH,
46
+ ROBINHOOD_SWITCH_CONTRACTS,
47
+ ROBINHOOD_UNISWAP_CONTRACTS,
48
+ ROBINHOOD_TOKENS,
49
+ ROBINHOOD_FEE_TOKEN_PRIORITY,
50
+ ROBINHOOD_FRONTEND_DEFAULT_TOKENS,
51
+ ROBINHOOD_FRONTEND_TOKEN_LIST,
52
+ buildRobinhoodQuoteUrl,
53
+ type BestPathResponse,
54
+ } from "@switch-win/sdk";
55
+ ```
56
+
57
+ The same exports are available from the smaller network entrypoint:
58
+
59
+ ```ts
60
+ import {
61
+ ROBINHOOD_CHAIN,
62
+ ROBINHOOD_TOKENS,
63
+ buildRobinhoodQuoteUrl,
64
+ } from "@switch-win/sdk/networks/robinhood";
65
+ ```
66
+
67
+ ## Authentication
68
+
69
+ Every request to `quote.switch.win` requires a Switch API key in the
70
+ `x-api-key` header:
71
+
72
+ ```ts
73
+ const headers = {
74
+ "x-api-key": process.env.SWITCH_API_KEY!,
75
+ };
76
+ ```
77
+
78
+ Do not expose a production API key in browser JavaScript. Browser applications
79
+ should call a same-origin server route that attaches the key before forwarding
80
+ the request to Switch.
81
+
82
+ ## Network configuration
83
+
84
+ `ROBINHOOD_CHAIN` can be adapted directly for most wallet libraries:
85
+
86
+ ```ts
87
+ const robinhoodWalletChain = {
88
+ chainId: `0x${ROBINHOOD_CHAIN.id.toString(16)}`,
89
+ chainName: ROBINHOOD_CHAIN.name,
90
+ nativeCurrency: ROBINHOOD_CHAIN.nativeCurrency,
91
+ rpcUrls: [...ROBINHOOD_CHAIN.rpcUrls],
92
+ blockExplorerUrls: [ROBINHOOD_CHAIN.blockExplorerUrl],
93
+ };
94
+
95
+ await window.ethereum.request({
96
+ method: "wallet_addEthereumChain",
97
+ params: [robinhoodWalletChain],
98
+ });
99
+ ```
100
+
101
+ ## Contracts and native currency
102
+
103
+ ### Switch deployment
104
+
105
+ | Contract | Address |
106
+ |---|---|
107
+ | SwitchRouter | `0x8730C3e2cF2c8CDa8E6166837A1Ed26f46aa9E59` |
108
+ | Uniswap V2 adapter | `0x7a14d7A8509a66209D4332843b983b29bF5604A4` |
109
+ | Uniswap V3 adapter | `0xbcA08f296d9Ba0dc19Aa0E05D355365cE29A3205` |
110
110
  | Uniswap V4 adapter | `0x754dDCD05aFbAd1cc7Bc42B9268EB586F579E7F6` |
111
-
112
- The V4 adapter was created in
113
- [deployment transaction `0x60d5...34a7`](https://robinhoodchain.blockscout.com/tx/0x60d56466a8162a643a15ecde98322ec05ea23d44d03fbd817df4ddbaef4834a7)
114
- and added to the router in
115
- [activation transaction `0x405b...1098`](https://robinhoodchain.blockscout.com/tx/0x405b49619ebfe4d1a73eb2d4601d8d1e63ae3d6fff0cd811a96c17e146971098).
116
-
117
- The router constant is the ERC-20 approval target. Always submit the swap to
118
- `quote.tx.to`; do not replace the API-provided transaction target with a
119
- hardcoded address.
120
-
121
- ### Native ETH and WETH
122
-
123
- Use `ROBINHOOD_NATIVE_ETH` when the user is selling or buying native ETH:
124
-
125
- ```text
126
- 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
127
- ```
128
-
129
- Use `ROBINHOOD_TOKENS.WETH.address` for the wrapped ERC-20:
130
-
131
- ```text
132
- 0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73
133
- ```
134
-
111
+ | SwitchLimitOrder | `0x752c50DDd3B426cAE3D7A995F313Ac74ac6B0230` |
112
+ | Native ETH flow | `0x029FfC6aF9112eA078f1D6f4a98826DDB2136cf6` |
113
+ | Switch Limit Order adapter (index 3) | `0x412F625072c10e58C619D1e0b3C95cd3d5689871` |
114
+ | SwapHood V2 adapter (index 4) | `0x6D8746f02e52944c13824fA691c6f4186E463354` |
115
+ | SwapHood V3 adapter (index 5) | `0x9645dE0AcB48F0AAefdBEb423F0558457907DE98` |
116
+ | Up33 CL adapter (index 6) | `0x388179D2FB0ABcE9b03068916aF8a3c4dfD023c8` |
117
+ | Sheriff V2 adapter (index 7) | `0xBDB3EB0355981500f58C9bc77c3E61762844A146` |
118
+ | Sheriff Algebra adapter (index 8) | `0xeFE1affb0e2Bb8A9F7d9D30751bAF679996ADA26` |
119
+ | Aeon Algebra adapter (index 9) | `0x20615954FB87360139e7DdDB519359498EbD1904` |
120
+ | Catnip V2 adapter (index 10) | `0x5b2Ca358d56490Dc86224D502522314De7707237` |
121
+ | PancakeSwap V2 adapter (index 11) | `0x3B6e71A59553143937Fef74a7B50AFD24528786E` |
122
+ | RobinSwap V3 adapter (index 12) | `0x798f77D63b46b0E019de206E111e5ea5CC16BEc8` |
123
+ | SushiSwap V3 adapter (index 13) | `0xca3EA0Fd6E31f94c81B6586836790adE638313ED` |
124
+
125
+ The V4 adapter was created in
126
+ [deployment transaction `0x60d5...34a7`](https://robinhoodchain.blockscout.com/tx/0x60d56466a8162a643a15ecde98322ec05ea23d44d03fbd817df4ddbaef4834a7)
127
+ and added to the router in
128
+ [activation transaction `0x405b...1098`](https://robinhoodchain.blockscout.com/tx/0x405b49619ebfe4d1a73eb2d4601d8d1e63ae3d6fff0cd811a96c17e146971098).
129
+
130
+ The router constant is the ERC-20 approval target. Always submit the swap to
131
+ `quote.tx.to`; do not replace the API-provided transaction target with a
132
+ hardcoded address.
133
+
134
+ ### Native ETH and WETH
135
+
136
+ Use `ROBINHOOD_NATIVE_ETH` when the user is selling or buying native ETH:
137
+
138
+ ```text
139
+ 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
140
+ ```
141
+
142
+ Use `ROBINHOOD_TOKENS.WETH.address` for the wrapped ERC-20:
143
+
144
+ ```text
145
+ 0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73
146
+ ```
147
+
135
148
  Native ETH does not require approval. WETH and every other ERC-20 input token
136
149
  must be approved for `ROBINHOOD_SWITCH_CONTRACTS.router`.
137
150
 
138
- ## Uniswap V4 routing
139
-
140
- Switch's Robinhood V4 integration is designed for canonical Uniswap V4, whose
141
- pools share one `PoolManager`. A V4 pool is identified by its complete
142
- `PoolKey`:
143
-
144
- ```ts
145
- type PoolKey = {
146
- currency0: string;
147
- currency1: string;
148
- fee: number;
149
- tickSpacing: number;
150
- hooks: string;
151
- };
152
- ```
153
-
154
- Do not treat V4 pools as V3 pools with another fee-tier list. The `fee`,
155
- `tickSpacing`, and `hooks` values are all part of pool identity, and Robinhood
156
- V4 discovery must preserve the full key. The backend selects the key and
157
- embeds adapter-specific route data in the quote; clients should submit the
158
- returned transaction unchanged rather than reconstructing V4 calldata.
159
-
160
- Phase one supports **hookless static-fee pools only** (`hooks` is the zero
161
- address, hook data is empty, and the dynamic-fee flag is not set). Pools with
162
- custom hooks or dynamic fees are not considered until their behavior and
163
- required hook data have been explicitly reviewed and allowed. This restriction
164
- does not reduce V2 or V3 routing coverage.
165
-
166
- V4 can represent native ETH as the zero-address currency. Switch routes use
167
- the canonical Robinhood WETH address, so the V4 adapter unwraps WETH when a
168
- selected pool consumes native ETH and wraps native ETH when that pool produces
169
- it. API callers should continue using `ROBINHOOD_NATIVE_ETH` for a native user
170
- input/output and `ROBINHOOD_TOKENS.WETH.address` for the ERC-20.
171
-
172
- The Robinhood Uniswap V4 adapter is deployed at
173
- `0x754dDCD05aFbAd1cc7Bc42B9268EB586F579E7F6`, whitelisted in the production
174
- SwitchRouter at adapter index `2`, and exported as
175
- `ROBINHOOD_SWITCH_CONTRACTS.uniswapV4Adapter`. Continue treating
176
- `GET /swap/adapters?network=robinhood` as the source of truth for the adapters
177
- currently available from the quote backend.
178
-
179
- The canonical Robinhood V4 infrastructure is available through
180
- `ROBINHOOD_UNISWAP_CONTRACTS`:
181
-
182
- | Contract | Address |
183
- |---|---|
184
- | PoolManager | `0x8366a39cc670b4001a1121b8f6a443a643e40951` |
185
- | PositionDescriptor | `0x9639443158e8c5efa35bd45287bf2effd3d8dc06` |
186
- | PositionManager | `0x58daec3116aae6d93017baaea7749052e8a04fa7` |
187
- | Quoter | `0x8dc178efb8111bb0973dd9d722ebeff267c98f94` |
188
- | StateView | `0xf3334192d15450cdd385c8b70e03f9a6bd9e673b` |
189
- | Universal Router | `0x8876789976decbfcbbbe364623c63652db8c0904` |
190
- | Permit2 | `0x000000000022D473030F116dDEE9F6B43aC78BA3` |
191
-
192
- Tax-token safety is unchanged: if either side is detected as a transfer-tax
193
- token, the complete route is restricted to Uniswap V2 adapter index `0`.
194
- Uniswap V3 and V4 are both excluded from that quote.
195
-
196
- ## Swap integration flow
197
-
198
- Use the same sequence as a PulseChain integration:
199
-
200
- 1. Check both tokens with `/swap/checkTax`.
201
- 2. Select `feeOnOutput` from the tax results and preferred fee-token order.
202
- 3. Request `/swap/quote` with `network=robinhood`, the selected fee mode, and
203
- `sender` when executable calldata is required.
204
- 4. Approve the API-provided router target for ERC-20 input tokens.
205
- 5. Submit `quote.tx` for fee-on-input or `quote.txFeeOnOutput` for
206
- fee-on-output.
207
- 6. Show `expectedOutputAmount`, `minAmountOut`, route allocation, and detected
208
- taxes to the user.
209
-
210
- Any swap involving a tax token is routed entirely through Uniswap V2. This
211
- also applies when both input and output are tax tokens.
212
-
213
- ## Quickstart
214
-
215
- `amount` is always a raw integer amount in the input token's smallest unit.
216
- The following requests a quote for `0.001 ETH -> USDG`:
217
-
218
- ```ts
219
- // This simple pair uses fee-on-input. See "Selecting feeOnOutput" below for
220
- // the recommended dynamic selection when community or tax tokens are involved.
221
- const feeOnOutput = false;
222
-
223
- const url = buildRobinhoodQuoteUrl({
224
- from: ROBINHOOD_NATIVE_ETH,
225
- to: ROBINHOOD_TOKENS.USDG.address,
226
- amount: 1_000_000_000_000_000n,
227
- sender: walletAddress,
228
- slippage: 50, // 0.50%, expressed in basis points
229
- feeOnOutput,
230
- });
231
-
232
- const response = await fetch(url, {
233
- headers: { "x-api-key": process.env.SWITCH_API_KEY! },
234
- });
235
-
236
- if (!response.ok) {
237
- throw new Error(`Switch quote failed: ${response.status}`);
238
- }
239
-
240
- const quote = (await response.json()) as BestPathResponse;
241
- const transaction = feeOnOutput ? quote.txFeeOnOutput : quote.tx;
242
-
243
- if (!transaction) {
244
- throw new Error("Quote did not include the selected transaction variant");
245
- }
246
- ```
247
-
248
- Equivalent curl request:
249
-
250
- ```bash
251
- curl -H "x-api-key: YOUR_KEY" \
252
- "https://quote.switch.win/swap/quote?network=robinhood&from=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&to=0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168&amount=1000000000000000&sender=0xYOUR_WALLET&slippage=50"
253
- ```
254
-
255
- Omit `sender` for a display-only quote. Fetch again with the sender immediately
256
- before execution to receive current transaction calldata.
257
-
258
- ## Tax-token checks
259
-
260
- Robinhood tokens can apply pair-specific transfer taxes. Check both input and
261
- output tokens before requesting or executing a swap:
262
-
263
- ```ts
264
- async function checkTax(token: string) {
265
- const query = new URLSearchParams({ network: "robinhood", token });
266
- const response = await fetch(
267
- `https://quote.switch.win/swap/checkTax?${query}`,
268
- { headers: { "x-api-key": process.env.SWITCH_API_KEY! } },
269
- );
270
-
271
- if (!response.ok) throw new Error(`Tax check failed: ${response.status}`);
272
- return response.json();
273
- }
274
-
275
- const [inputTax, outputTax] = await Promise.all([
276
- checkTax(tokenIn),
277
- checkTax(tokenOut),
278
- ]);
279
- ```
280
-
281
- The quote response also includes `fromTokenTax`, `toTokenTax`,
282
- `expectedOutputAmount`, and effective-slippage fields. Display these values to
283
- the user rather than estimating taxes locally.
284
-
285
- ## Selecting `feeOnOutput`
286
-
287
- `feeOnOutput` determines which side of the swap pays the Switch partner or
288
- protocol fee:
289
-
290
- | Value | Fee token | Transaction field |
291
- |---|---|---|
292
- | `false` | Input token | `quote.tx` |
293
- | `true` | Output token | `quote.txFeeOnOutput` |
294
-
295
- Choose the mode before requesting the executable quote and pass it to
296
- `buildRobinhoodQuoteUrl`. This keeps `expectedOutputAmount`, routing, and the
297
- transaction calldata aligned with the mode that will actually be submitted.
298
-
299
- For Robinhood Chain, the recommended selection order is:
300
-
301
- 1. If both sides are tax tokens, use fee-on-input (`false`) to avoid the extra
302
- output-token transfers required by fee-on-output.
303
- 2. If only the output token has buy tax, use fee-on-input (`false`) to avoid
304
- routing the taxed output through additional transfers.
305
- 3. If only the input token has sell tax, use fee-on-output (`true`) so the fee
306
- is collected in the non-tax output token.
307
- 4. Otherwise, prefer collecting tokens in this order: WETH (with native ETH
308
- treated equivalently), USDG, WALLET, SEEDCOIN, then CASHCAT.
309
- 5. If neither token is preferred, default to fee-on-input (`false`).
310
-
311
- The no-tax priority list is:
312
-
313
- | Priority | Token | Address |
314
- |---:|---|---|
315
- | 1 | WETH / native ETH | `0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73` / native sentinel |
316
- | 2 | USDG | `0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168` |
317
- | 3 | WALLET | `0x0339f5459FC690aC85F1782e15782A151b4A9E1b` |
318
- | 4 | SEEDCOIN | `0xD8d1C08A8bA4fc64BAC744f74290B89ADcb6Bf25` |
319
- | 5 | CASHCAT | `0x020bfC650A365f8BB26819deAAbF3E21291018b4` |
151
+ ### Limit orders
320
152
 
321
- The ordered ERC-20 addresses are exported as
322
- `ROBINHOOD_FEE_TOKEN_PRIORITY`. When neither side is taxed, the selector takes
323
- the fee from whichever side contains the higher-priority token. If neither
324
- side is listed, it defaults to fee-on-input.
153
+ Robinhood ERC-20 limit orders use the same EIP-712 `LimitOrder` structure as
154
+ PulseChain, with these network-specific domain values:
325
155
 
326
156
  ```ts
327
157
  import {
328
- buildRobinhoodQuoteUrl,
329
- selectRobinhoodFeeOnOutput,
330
- type BestPathResponse,
158
+ ROBINHOOD_LIMIT_ORDER_EIP712_DOMAIN,
159
+ ROBINHOOD_SWITCH_CONTRACTS,
331
160
  } from "@switch-win/sdk";
332
161
 
333
- const feeOnOutput = selectRobinhoodFeeOnOutput(
334
- tokenIn,
335
- tokenOut,
336
- inputTax,
337
- outputTax,
162
+ // { name: "SwitchLimitOrder", version: "2", chainId: 4663,
163
+ // verifyingContract: "0x752c...0230" }
164
+ await signer.signTypedData(
165
+ ROBINHOOD_LIMIT_ORDER_EIP712_DOMAIN,
166
+ LIMIT_ORDER_EIP712_TYPES,
167
+ order,
338
168
  );
339
-
340
- const quoteUrl = buildRobinhoodQuoteUrl({
341
- from: tokenIn,
342
- to: tokenOut,
343
- amount: amountIn,
344
- sender: walletAddress,
345
- slippage: 50,
346
- feeOnOutput,
347
- });
348
-
349
- const quoteResponse = await fetch(quoteUrl, {
350
- headers: { "x-api-key": process.env.SWITCH_API_KEY! },
351
- });
352
- if (!quoteResponse.ok) {
353
- throw new Error(`Switch quote failed: ${quoteResponse.status}`);
354
- }
355
-
356
- const quote = (await quoteResponse.json()) as BestPathResponse;
357
- const transaction = feeOnOutput ? quote.txFeeOnOutput : quote.tx;
358
- if (!transaction) {
359
- throw new Error("Quote did not include the selected transaction variant");
360
- }
361
169
  ```
362
170
 
363
- Do not request one fee mode and submit the other transaction variant. Taxed
364
- output tokens are especially important: `feeOnOutput=true` makes the router
365
- receive and redistribute the output, which can trigger additional transfer-tax
366
- events.
171
+ Submit signed orders to `POST /limit-orders?network=robinhood`. For
172
+ `feeOnOutput=false`, approve `ROBINHOOD_SWITCH_CONTRACTS.limitOrder`; for
173
+ `feeOnOutput=true`, approve `ROBINHOOD_SWITCH_CONTRACTS.router`.
367
174
 
368
- ## Approving and executing
369
-
370
- For ERC-20 input:
175
+ Applications should fetch `/limit-orders/config?network=robinhood` at startup
176
+ instead of relying only on static addresses. The SDK exposes this as:
371
177
 
372
178
  ```ts
373
- const token = new ethers.Contract(
374
- tokenIn,
375
- ["function approve(address spender, uint256 amount) returns (bool)"],
376
- signer,
179
+ const config = await fetchLimitOrderConfig({ network: "robinhood" });
180
+ const signing = getNetworkEIP712SigningParams(
181
+ "robinhood",
182
+ config.limitOrderContract,
183
+ );
184
+ const approvalTarget = getLimitOrderApprovalTarget(
185
+ "robinhood",
186
+ order.feeOnOutput,
187
+ { limitOrderContract: config.limitOrderContract },
377
188
  );
378
-
379
- await (
380
- await token.approve(ROBINHOOD_SWITCH_CONTRACTS.router, amountIn)
381
- ).wait();
382
- ```
383
-
384
- Then submit the transaction returned by the API:
385
-
386
- ```ts
387
- await signer.sendTransaction({
388
- to: transaction.to,
389
- data: transaction.data,
390
- value: transaction.value,
391
- });
392
- ```
393
-
394
- For native ETH input, skip approval and send the API-provided `value`.
395
-
396
- ## Swap API reference
397
-
398
- All amounts are raw integer strings in the token's smallest unit. All token and
399
- wallet values are EVM addresses.
400
-
401
- ### List adapters
402
-
403
- ```http
404
- GET https://quote.switch.win/swap/adapters?network=robinhood
405
- x-api-key: YOUR_KEY
406
189
  ```
407
190
 
408
- Robinhood currently returns:
409
-
410
- | Index | Adapter |
411
- |---:|---|
191
+ Include `limitOrderContract: config.limitOrderContract` with the submitted
192
+ signed order. Every returned order also carries its own deployment address;
193
+ operators must fill and makers must cancel against that per-order address.
194
+
195
+ Native ETH input orders are created on-chain through
196
+ `ROBINHOOD_SWITCH_CONTRACTS.nativeEthFlow` and are indexed from its events; do
197
+ not POST them as signed EOA orders. Native ETH output is represented by WETH in
198
+ the order with `unwrapOutput=true`.
199
+
200
+ ## Uniswap V4 routing
201
+
202
+ Switch's Robinhood V4 integration is designed for canonical Uniswap V4, whose
203
+ pools share one `PoolManager`. A V4 pool is identified by its complete
204
+ `PoolKey`:
205
+
206
+ ```ts
207
+ type PoolKey = {
208
+ currency0: string;
209
+ currency1: string;
210
+ fee: number;
211
+ tickSpacing: number;
212
+ hooks: string;
213
+ };
214
+ ```
215
+
216
+ Do not treat V4 pools as V3 pools with another fee-tier list. The `fee`,
217
+ `tickSpacing`, and `hooks` values are all part of pool identity, and Robinhood
218
+ V4 discovery must preserve the full key. The backend selects the key and
219
+ embeds adapter-specific route data in the quote; clients should submit the
220
+ returned transaction unchanged rather than reconstructing V4 calldata.
221
+
222
+ Phase one supports **hookless static-fee pools only** (`hooks` is the zero
223
+ address, hook data is empty, and the dynamic-fee flag is not set). Pools with
224
+ custom hooks or dynamic fees are not considered until their behavior and
225
+ required hook data have been explicitly reviewed and allowed. This restriction
226
+ does not reduce V2 or V3 routing coverage.
227
+
228
+ V4 can represent native ETH as the zero-address currency. Switch routes use
229
+ the canonical Robinhood WETH address, so the V4 adapter unwraps WETH when a
230
+ selected pool consumes native ETH and wraps native ETH when that pool produces
231
+ it. API callers should continue using `ROBINHOOD_NATIVE_ETH` for a native user
232
+ input/output and `ROBINHOOD_TOKENS.WETH.address` for the ERC-20.
233
+
234
+ The Robinhood Uniswap V4 adapter is deployed at
235
+ `0x754dDCD05aFbAd1cc7Bc42B9268EB586F579E7F6`, whitelisted in the production
236
+ SwitchRouter at adapter index `2`, and exported as
237
+ `ROBINHOOD_SWITCH_CONTRACTS.uniswapV4Adapter`. Continue treating
238
+ `GET /swap/adapters?network=robinhood` as the source of truth for the adapters
239
+ currently available from the quote backend.
240
+
241
+ The canonical Robinhood V4 infrastructure is available through
242
+ `ROBINHOOD_UNISWAP_CONTRACTS`:
243
+
244
+ | Contract | Address |
245
+ |---|---|
246
+ | PoolManager | `0x8366a39cc670b4001a1121b8f6a443a643e40951` |
247
+ | PositionDescriptor | `0x9639443158e8c5efa35bd45287bf2effd3d8dc06` |
248
+ | PositionManager | `0x58daec3116aae6d93017baaea7749052e8a04fa7` |
249
+ | Quoter | `0x8dc178efb8111bb0973dd9d722ebeff267c98f94` |
250
+ | StateView | `0xf3334192d15450cdd385c8b70e03f9a6bd9e673b` |
251
+ | Universal Router | `0x8876789976decbfcbbbe364623c63652db8c0904` |
252
+ | Permit2 | `0x000000000022D473030F116dDEE9F6B43aC78BA3` |
253
+
254
+ Tax-token safety is unchanged: if either side is detected as a transfer-tax
255
+ token, the complete route is restricted to direct-pair V2 adapters `0`, `4`,
256
+ `7`, `10`, and `11`. Concentrated-liquidity adapters are excluded from that
257
+ quote.
258
+
259
+ ## Swap integration flow
260
+
261
+ Use the same sequence as a PulseChain integration:
262
+
263
+ 1. Check both tokens with `/swap/checkTax`.
264
+ 2. Select `feeOnOutput` from the tax results and preferred fee-token order.
265
+ 3. Request `/swap/quote` with `network=robinhood`, the selected fee mode, and
266
+ `sender` when executable calldata is required.
267
+ 4. Approve the API-provided router target for ERC-20 input tokens.
268
+ 5. Submit `quote.tx` for fee-on-input or `quote.txFeeOnOutput` for
269
+ fee-on-output.
270
+ 6. Show `expectedOutputAmount`, `minAmountOut`, route allocation, and detected
271
+ taxes to the user.
272
+
273
+ Any swap involving a tax token is routed entirely through the tax-safe
274
+ direct-pair V2 adapter set (`0`, `4`, `7`, `10`, and `11`). This also applies
275
+ when both input and output are tax tokens.
276
+
277
+ ## Quickstart
278
+
279
+ `amount` is always a raw integer amount in the input token's smallest unit.
280
+ The following requests a quote for `0.001 ETH -> USDG`:
281
+
282
+ ```ts
283
+ // This simple pair uses fee-on-input. See "Selecting feeOnOutput" below for
284
+ // the recommended dynamic selection when community or tax tokens are involved.
285
+ const feeOnOutput = false;
286
+
287
+ const url = buildRobinhoodQuoteUrl({
288
+ from: ROBINHOOD_NATIVE_ETH,
289
+ to: ROBINHOOD_TOKENS.USDG.address,
290
+ amount: 1_000_000_000_000_000n,
291
+ sender: walletAddress,
292
+ slippage: 100, // 1.00%, the Robinhood frontend default
293
+ feeOnOutput,
294
+ });
295
+
296
+ const response = await fetch(url, {
297
+ headers: { "x-api-key": process.env.SWITCH_API_KEY! },
298
+ });
299
+
300
+ if (!response.ok) {
301
+ throw new Error(`Switch quote failed: ${response.status}`);
302
+ }
303
+
304
+ const quote = (await response.json()) as BestPathResponse;
305
+ const transaction = feeOnOutput ? quote.txFeeOnOutput : quote.tx;
306
+
307
+ if (!transaction) {
308
+ throw new Error("Quote did not include the selected transaction variant");
309
+ }
310
+ ```
311
+
312
+ Equivalent curl request:
313
+
314
+ ```bash
315
+ curl -H "x-api-key: YOUR_KEY" \
316
+ "https://quote.switch.win/swap/quote?network=robinhood&from=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&to=0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168&amount=1000000000000000&sender=0xYOUR_WALLET&slippage=100"
317
+ ```
318
+
319
+ Omit `sender` for a display-only quote. Fetch again with the sender immediately
320
+ before execution to receive current transaction calldata.
321
+
322
+ ## Tax-token checks
323
+
324
+ Robinhood tokens can apply pair-specific transfer taxes. Check both input and
325
+ output tokens before requesting or executing a swap:
326
+
327
+ ```ts
328
+ async function checkTax(token: string) {
329
+ const query = new URLSearchParams({ network: "robinhood", token });
330
+ const response = await fetch(
331
+ `https://quote.switch.win/swap/checkTax?${query}`,
332
+ { headers: { "x-api-key": process.env.SWITCH_API_KEY! } },
333
+ );
334
+
335
+ if (!response.ok) throw new Error(`Tax check failed: ${response.status}`);
336
+ return response.json();
337
+ }
338
+
339
+ const [inputTax, outputTax] = await Promise.all([
340
+ checkTax(tokenIn),
341
+ checkTax(tokenOut),
342
+ ]);
343
+ ```
344
+
345
+ The quote response also includes `fromTokenTax`, `toTokenTax`,
346
+ `expectedOutputAmount`, and effective-slippage fields. Display these values to
347
+ the user rather than estimating taxes locally.
348
+
349
+ ## Selecting `feeOnOutput`
350
+
351
+ `feeOnOutput` determines which side of the swap pays the Switch partner or
352
+ protocol fee:
353
+
354
+ | Value | Fee token | Transaction field |
355
+ |---|---|---|
356
+ | `false` | Input token | `quote.tx` |
357
+ | `true` | Output token | `quote.txFeeOnOutput` |
358
+
359
+ Choose the mode before requesting the executable quote and pass it to
360
+ `buildRobinhoodQuoteUrl`. This keeps `expectedOutputAmount`, routing, and the
361
+ transaction calldata aligned with the mode that will actually be submitted.
362
+
363
+ For Robinhood Chain, the recommended selection order is:
364
+
365
+ 1. If both sides are tax tokens, use fee-on-input (`false`) to avoid the extra
366
+ output-token transfers required by fee-on-output.
367
+ 2. If only the output token has buy tax, use fee-on-input (`false`) to avoid
368
+ routing the taxed output through additional transfers.
369
+ 3. If only the input token has sell tax, use fee-on-output (`true`) so the fee
370
+ is collected in the non-tax output token.
371
+ 4. Otherwise, prefer collecting tokens in this order: WETH (with native ETH
372
+ treated equivalently), USDG, WALLET, SEEDCOIN, then CASHCAT.
373
+ 5. If neither token is preferred, default to fee-on-input (`false`).
374
+
375
+ The no-tax priority list is:
376
+
377
+ | Priority | Token | Address |
378
+ |---:|---|---|
379
+ | 1 | WETH / native ETH | `0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73` / native sentinel |
380
+ | 2 | USDG | `0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168` |
381
+ | 3 | WALLET | `0x0339f5459FC690aC85F1782e15782A151b4A9E1b` |
382
+ | 4 | SEEDCOIN | `0x58f693A30F124E59b125F7c7b837b0F6bbAF5a45` |
383
+ | 5 | CASHCAT | `0x020bfC650A365f8BB26819deAAbF3E21291018b4` |
384
+
385
+ The ordered ERC-20 addresses are exported as
386
+ `ROBINHOOD_FEE_TOKEN_PRIORITY`. When neither side is taxed, the selector takes
387
+ the fee from whichever side contains the higher-priority token. If neither
388
+ side is listed, it defaults to fee-on-input.
389
+
390
+ ```ts
391
+ import {
392
+ buildRobinhoodQuoteUrl,
393
+ selectRobinhoodFeeOnOutput,
394
+ type BestPathResponse,
395
+ } from "@switch-win/sdk";
396
+
397
+ const feeOnOutput = selectRobinhoodFeeOnOutput(
398
+ tokenIn,
399
+ tokenOut,
400
+ inputTax,
401
+ outputTax,
402
+ );
403
+
404
+ const quoteUrl = buildRobinhoodQuoteUrl({
405
+ from: tokenIn,
406
+ to: tokenOut,
407
+ amount: amountIn,
408
+ sender: walletAddress,
409
+ slippage: 100,
410
+ feeOnOutput,
411
+ });
412
+
413
+ const quoteResponse = await fetch(quoteUrl, {
414
+ headers: { "x-api-key": process.env.SWITCH_API_KEY! },
415
+ });
416
+ if (!quoteResponse.ok) {
417
+ throw new Error(`Switch quote failed: ${quoteResponse.status}`);
418
+ }
419
+
420
+ const quote = (await quoteResponse.json()) as BestPathResponse;
421
+ const transaction = feeOnOutput ? quote.txFeeOnOutput : quote.tx;
422
+ if (!transaction) {
423
+ throw new Error("Quote did not include the selected transaction variant");
424
+ }
425
+ ```
426
+
427
+ Do not request one fee mode and submit the other transaction variant. Taxed
428
+ output tokens are especially important: `feeOnOutput=true` makes the router
429
+ receive and redistribute the output, which can trigger additional transfer-tax
430
+ events.
431
+
432
+ ## Approving and executing
433
+
434
+ For ERC-20 input:
435
+
436
+ ```ts
437
+ const token = new ethers.Contract(
438
+ tokenIn,
439
+ ["function approve(address spender, uint256 amount) returns (bool)"],
440
+ signer,
441
+ );
442
+
443
+ await (
444
+ await token.approve(ROBINHOOD_SWITCH_CONTRACTS.router, amountIn)
445
+ ).wait();
446
+ ```
447
+
448
+ Then submit the transaction returned by the API:
449
+
450
+ ```ts
451
+ await signer.sendTransaction({
452
+ to: transaction.to,
453
+ data: transaction.data,
454
+ value: transaction.value,
455
+ });
456
+ ```
457
+
458
+ For native ETH input, skip approval and send the API-provided `value`.
459
+
460
+ ## Swap API reference
461
+
462
+ All amounts are raw integer strings in the token's smallest unit. All token and
463
+ wallet values are EVM addresses.
464
+
465
+ ### List adapters
466
+
467
+ ```http
468
+ GET https://quote.switch.win/swap/adapters?network=robinhood
469
+ x-api-key: YOUR_KEY
470
+ ```
471
+
472
+ Robinhood currently returns:
473
+
474
+ | Index | Adapter |
475
+ |---:|---|
412
476
  | `0` | Uniswap V2 |
413
477
  | `1` | Uniswap V3 |
414
478
  | `2` | Uniswap V4 |
415
-
416
- Treat the endpoint response, not this document, as the source of truth for
417
- which adapters are currently selectable.
418
-
479
+ | `3` | Switch Limit Orders |
480
+ | `4` | SwapHood V2 |
481
+ | `5` | SwapHood V3 |
482
+ | `6` | Up33 CL |
483
+ | `7` | Sheriff V2 |
484
+ | `8` | Sheriff Algebra |
485
+ | `9` | Aeon Algebra |
486
+ | `10` | Catnip V2 |
487
+ | `11` | PancakeSwap V2 |
488
+ | `12` | RobinSwap V3 |
489
+ | `13` | SushiSwap V3 |
490
+
491
+ Treat the endpoint response, not this document, as the source of truth for
492
+ which adapters are currently selectable.
493
+
419
494
  Do not permanently hard-code the available adapter list in an integration.
420
495
  Fetch it when presenting routing-source controls. If a quote involves a tax
421
- token, the backend overrides routing to tax-safe adapter `0`; an explicit
422
- filter that excludes adapter `0` is rejected.
423
-
424
- ### Check token tax
425
-
426
- ```http
427
- GET https://quote.switch.win/swap/checkTax?network=robinhood&token=0xTOKEN
428
- ```
429
-
430
- Example response:
431
-
432
- ```json
433
- {
434
- "token": "0x...",
435
- "isTaxToken": true,
436
- "buyTaxBps": 500,
437
- "sellTaxBps": 300
438
- }
439
- ```
440
-
441
- `500` basis points is `5%`. Use the input token's `sellTaxBps` and the output
442
- token's `buyTaxBps`. When both tokens are taxed, use fee-on-input.
443
-
444
- ### Get swap quote
445
-
446
- ```http
447
- GET https://quote.switch.win/swap/quote
448
- ```
449
-
450
- | Query parameter | Required | Description |
451
- |---|:---:|---|
452
- | `network` | Yes | Must be `robinhood`. |
453
- | `from` | Yes | Input token address or `ROBINHOOD_NATIVE_ETH`. |
454
- | `to` | Yes | Output token address or `ROBINHOOD_NATIVE_ETH`. |
455
- | `amount` | Yes | Raw input amount. |
456
- | `sender` | No | Required when transaction calldata is needed. |
457
- | `receiver` | No | Output recipient; defaults to `sender`. |
458
- | `slippage` | No | Basis points; default `50` (`0.5%`). |
459
- | `fee` | No | Partner/protocol fee in basis points. |
460
- | `partnerAddress` | No | Fee-sharing recipient. |
461
- | `feeOnOutput` | No | `true` takes the fee from output; `false` takes it from input. |
462
- | `adapters` | No | Comma-separated indices returned by `/swap/adapters`, such as `0,1,2`. |
463
- | `gasPrice` | No | Quote gas price in wei. |
464
-
465
- Omitting `sender` produces a display-only quote. Request a fresh executable
466
- quote with `sender` immediately before execution.
467
-
468
- ### Quote response
469
-
470
- Important response fields:
471
-
472
- | Field | Description |
473
- |---|---|
474
- | `fromToken`, `toToken` | Normalized pair addresses. |
475
- | `totalAmountIn` | Gross input amount. |
476
- | `totalAmountOut` | Raw pool output before taxes and Switch fees. |
477
- | `expectedOutputAmount` | Expected user receipt after tax and fee, before slippage. |
478
- | `minAmountOut` | Minimum output encoded into calldata. |
479
- | `paths` | Human-readable route descriptions. |
480
- | `routeAllocation` | Structured split, hop, adapter, and pool-specific route allocation. V4 PoolKey data is encoded in the executable transaction and must not be reconstructed client-side. |
481
- | `fromTokenTax`, `toTokenTax` | Detected tax metadata. |
482
- | `effectiveSlippageBps` | Slippage plus applicable tax buffers. |
483
- | `tx` | Fee-on-input transaction; present when `sender` is supplied. |
484
- | `txFeeOnOutput` | Fee-on-output transaction; present when `sender` is supplied. |
485
-
486
- Treat the response as authoritative. Do not recalculate output taxes, route
487
- splits, minimum output, or calldata in the client.
488
-
489
- ## Error handling
490
-
491
- The API can return an `{ "error": "..." }` object for validation or routing
492
- failures. Check both the HTTP status and the response body before using quote
493
- fields.
494
-
495
- Common Robinhood errors include:
496
-
497
- - Missing or unsupported `network`.
498
- - Invalid token, sender, receiver, or partner address.
499
- - Invalid raw amount, slippage, fee, gas price, or adapter filter.
500
- - A tax-token quote explicitly excluded the Uniswap V2 adapter.
501
- - No viable route across the currently active adapters, or insufficient liquidity.
502
- - RPC timeout or public-RPC rate limiting.
503
- - Missing executable transaction because `sender` was omitted.
504
-
505
- On-chain reverts can still occur if allowance, wallet balance, slippage,
506
- liquidity, token tax, or chain state changes after quoting. Fetch a fresh quote
507
- before retrying rather than resubmitting stale calldata.
508
-
509
- ## Partner fee sharing
510
-
511
- Pass `fee` in basis points and `partnerAddress` in the quote request. The chosen
512
- fee mode determines the fee token:
513
-
514
- - `feeOnOutput=false`: collect from the input token and submit `quote.tx`.
515
- - `feeOnOutput=true`: collect from the output token and submit
516
- `quote.txFeeOnOutput`.
517
-
518
- Always pass `feeOnOutput` while quoting so routing and
519
- `expectedOutputAmount` match the transaction variant you will execute. Partner
520
- fee eligibility and revenue share are controlled by the API-key agreement; do
521
- not assume that supplying an address alone enables sharing.
522
-
523
- ## Tokens and routing
524
-
525
- ### Curated frontend token list
526
-
527
- The token dropdown contains the following ERC-20 tokens. Native ETH is merged
528
- into the UI separately from this list.
529
-
530
- | Symbol | Name | Address | Decimals |
531
- |---|---|---|---:|
532
- | WETH | Wrapped Ether | `0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73` | 18 |
533
- | USDG | Global Dollar | `0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168` | 6 |
534
- | VIRTUAL | Virtuals Protocol | `0xc6911796042b15d7Fa4F6CDe69e245DdCd3d9c31` | 18 |
535
- | CASHCAT | Cash Cat | `0x020bfC650A365f8BB26819deAAbF3E21291018b4` | 18 |
536
- | WALLET | Robinhood Wallet | `0x0339f5459FC690aC85F1782e15782A151b4A9E1b` | 18 |
537
- | seedcoin | watch it grow | `0xD8d1C08A8bA4fc64BAC744f74290B89ADcb6Bf25` | 18 |
538
- | JUGGERNAUT | The Juggernaut | `0xD7321801CAae694090694Ff55A9323139F043B88` | 18 |
539
- | HOODRAT | Hoodrat | `0x8e62F281f282686fCa6dCB39288069a93fC23F1c` | 18 |
540
- | DIH | Dog In Hood | `0x17bb0C898254406b1Ea2e8E99B0C263e26c9E4a4` | 18 |
541
- | KITSU | KITSU | `0x8d4dFaaA4198b6486E0293Fec914C2B6a821D4DC` | 18 |
542
- | WEN | Wen Lambo | `0xA80eb66b3E0CF66ccB46f8b8C9e7ff5803eEb820` | 18 |
543
- | REPE | Robinhood Pepe | `0x5266eeafF092D6136AB63D18B975A60a0Cc0C8f7` | 18 |
544
- | TENDIES | TENDIES | `0x45242320DBB855EeA8Fd36804C6487E10E97FCF9` | 18 |
545
- | GME | GameStop | `0x7e86381A763F0Ecca2bDF27C54eAC403ddD48123` | 18 |
546
- | 4663 | 4663 | `0xd4052415613B34Af236024B895574c467f65b6dD` | 18 |
496
+ token, the backend restricts routing to tax-safe adapters `0`, `4`, `7`, `10`,
497
+ and `11`; an explicit filter that excludes all of them is rejected.
498
+
499
+ ### Check token tax
500
+
501
+ ```http
502
+ GET https://quote.switch.win/swap/checkTax?network=robinhood&token=0xTOKEN
503
+ ```
504
+
505
+ Example response:
506
+
507
+ ```json
508
+ {
509
+ "token": "0x...",
510
+ "isTaxToken": true,
511
+ "buyTaxBps": 500,
512
+ "sellTaxBps": 300
513
+ }
514
+ ```
515
+
516
+ `500` basis points is `5%`. Use the input token's `sellTaxBps` and the output
517
+ token's `buyTaxBps`. When both tokens are taxed, use fee-on-input.
518
+
519
+ ### Get swap quote
520
+
521
+ ```http
522
+ GET https://quote.switch.win/swap/quote
523
+ ```
524
+
525
+ | Query parameter | Required | Description |
526
+ |---|:---:|---|
527
+ | `network` | Yes | Must be `robinhood`. |
528
+ | `from` | Yes | Input token address or `ROBINHOOD_NATIVE_ETH`. |
529
+ | `to` | Yes | Output token address or `ROBINHOOD_NATIVE_ETH`. |
530
+ | `amount` | Yes | Raw input amount. |
531
+ | `sender` | No | Required when transaction calldata is needed. |
532
+ | `receiver` | No | Output recipient; defaults to `sender`. |
533
+ | `slippage` | No | Basis points; API fallback `50` (`0.5%`). The Switch Robinhood frontend explicitly requests `100` (`1%`). |
534
+ | `fee` | No | Partner/protocol fee in basis points. |
535
+ | `partnerAddress` | No | Fee-sharing recipient. |
536
+ | `feeOnOutput` | No | `true` takes the fee from output; `false` takes it from input. |
537
+ | `adapters` | No | Comma-separated indices returned by `/swap/adapters`, such as `0,1,2`. |
538
+ | `gasPrice` | No | Quote gas price in wei. |
539
+
540
+ Omitting `sender` produces a display-only quote. Request a fresh executable
541
+ quote with `sender` immediately before execution.
542
+
543
+ ### Quote response
544
+
545
+ Important response fields:
546
+
547
+ | Field | Description |
548
+ |---|---|
549
+ | `fromToken`, `toToken` | Normalized pair addresses. |
550
+ | `totalAmountIn` | Gross input amount. |
551
+ | `totalAmountOut` | Raw pool output before taxes and Switch fees. |
552
+ | `expectedOutputAmount` | Expected user receipt after tax and fee, before slippage. |
553
+ | `minAmountOut` | Minimum output encoded into calldata. |
554
+ | `paths` | Human-readable route descriptions. |
555
+ | `routeAllocation` | Structured split, hop, adapter, and pool-specific route allocation. V4 PoolKey data is encoded in the executable transaction and must not be reconstructed client-side. |
556
+ | `fromTokenTax`, `toTokenTax` | Detected tax metadata. |
557
+ | `effectiveSlippageBps` | Slippage plus applicable tax buffers. |
558
+ | `tx` | Fee-on-input transaction; present when `sender` is supplied. |
559
+ | `txFeeOnOutput` | Fee-on-output transaction; present when `sender` is supplied. |
560
+
561
+ Treat the response as authoritative. Do not recalculate output taxes, route
562
+ splits, minimum output, or calldata in the client.
563
+
564
+ ## Error handling
565
+
566
+ The API can return an `{ "error": "..." }` object for validation or routing
567
+ failures. Check both the HTTP status and the response body before using quote
568
+ fields.
569
+
570
+ Common Robinhood errors include:
571
+
572
+ - Missing or unsupported `network`.
573
+ - Invalid token, sender, receiver, or partner address.
574
+ - Invalid raw amount, slippage, fee, gas price, or adapter filter.
575
+ - A tax-token quote explicitly excluded every tax-safe direct-pair V2 adapter.
576
+ - No viable route across the currently active adapters, or insufficient liquidity.
577
+ - RPC timeout or public-RPC rate limiting.
578
+ - Missing executable transaction because `sender` was omitted.
579
+
580
+ On-chain reverts can still occur if allowance, wallet balance, slippage,
581
+ liquidity, token tax, or chain state changes after quoting. Fetch a fresh quote
582
+ before retrying rather than resubmitting stale calldata.
583
+
584
+ ## Partner fee sharing
585
+
586
+ Pass `fee` in basis points and `partnerAddress` in the quote request. The chosen
587
+ fee mode determines the fee token:
588
+
589
+ - `feeOnOutput=false`: collect from the input token and submit `quote.tx`.
590
+ - `feeOnOutput=true`: collect from the output token and submit
591
+ `quote.txFeeOnOutput`.
592
+
593
+ Always pass `feeOnOutput` while quoting so routing and
594
+ `expectedOutputAmount` match the transaction variant you will execute. Partner
595
+ fee eligibility and revenue share are controlled by the API-key agreement; do
596
+ not assume that supplying an address alone enables sharing.
597
+
598
+ ## Tokens and routing
599
+
600
+ ### Curated frontend token list
601
+
602
+ The token dropdown contains the following ERC-20 tokens. Native ETH is merged
603
+ into the UI separately from this list.
604
+
605
+ | Symbol | Name | Address | Decimals |
606
+ |---|---|---|---:|
607
+ | WETH | Wrapped Ether | `0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73` | 18 |
608
+ | USDG | Global Dollar | `0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168` | 6 |
609
+ | VIRTUAL | Virtuals Protocol | `0xc6911796042b15d7Fa4F6CDe69e245DdCd3d9c31` | 18 |
610
+ | CASHCAT | Cash Cat | `0x020bfC650A365f8BB26819deAAbF3E21291018b4` | 18 |
611
+ | WALLET | Robinhood Wallet | `0x0339f5459FC690aC85F1782e15782A151b4A9E1b` | 18 |
612
+ | SEEDCOIN | Seedcoin | `0x58f693A30F124E59b125F7c7b837b0F6bbAF5a45` | 18 |
613
+ | JUGGERNAUT | The Juggernaut | `0xD7321801CAae694090694Ff55A9323139F043B88` | 18 |
614
+ | HOODRAT | Hoodrat | `0x8e62F281f282686fCa6dCB39288069a93fC23F1c` | 18 |
615
+ | DIH | Dog In Hood | `0x17bb0C898254406b1Ea2e8E99B0C263e26c9E4a4` | 18 |
616
+ | KITSU | KITSU | `0x8d4dFaaA4198b6486E0293Fec914C2B6a821D4DC` | 18 |
617
+ | WEN | Wen Lambo | `0xA80eb66b3E0CF66ccB46f8b8C9e7ff5803eEb820` | 18 |
618
+ | REPE | Robinhood Pepe | `0x5266eeafF092D6136AB63D18B975A60a0Cc0C8f7` | 18 |
619
+ | TENDIES | TENDIES | `0x45242320DBB855EeA8Fd36804C6487E10E97FCF9` | 18 |
620
+ | GME | GameStop | `0x7e86381A763F0Ecca2bDF27C54eAC403ddD48123` | 18 |
621
+ | 4663 | 4663 | `0xd4052415613B34Af236024B895574c467f65b6dD` | 18 |
547
622
  | MARIAN | Lady Marian | `0x01637b14B7378B99dE75A64d50656d98488D9a4d` | 18 |
548
-
549
- The ordered list is exported as `ROBINHOOD_FRONTEND_TOKEN_LIST`.
550
-
551
- These community tokens are frontend conveniences, not an endorsement or a
552
- guarantee of liquidity, price stability, tax behavior, or contract safety.
553
- Always identify tokens by address and obtain a fresh quote and tax check.
554
-
555
- ### Routing configuration
556
-
557
- Switch currently evaluates:
558
-
559
- - Uniswap V2 adapter index `0`.
560
- - Uniswap V3 adapter index `1`.
561
- - V3 fee tiers `100`, `500`, `3000`, and `10000`.
562
- - Trusted routing hubs WETH, USDG, VIRTUAL, and CASHCAT.
563
-
564
- The prepared V4 integration reserves adapter index `2`. Once activated, it
565
- discovers hookless static-fee V4 pools by complete `PoolKey` rather than
566
- applying the V3 fee-tier list. Native-ETH V4 currencies are normalized through the WETH/native
567
- alias described above. Until `/swap/adapters` returns index `2`, V4 is not part
568
- of live production quotes.
569
-
570
- If either side is detected as a transfer-tax token, the backend restricts the
571
- entire route (including every split and intermediate hop) to Uniswap V2. V3 is
572
- not considered for that quote, and V4 will remain excluded after activation.
573
-
574
- The API may split a quote across routes and adapters. Integrators should render
575
- the returned `paths` or `routeAllocation` instead of assuming a single path.
576
-
577
- ## Rate limits
578
-
579
- Rate limits are assigned to the API key. A `429` response means the integration
580
- must back off. Use request coalescing and short-lived UI caching, avoid polling
581
- unchanged quotes, and debounce amount input before requesting a new route.
582
-
583
- For server integrations, contact Switch to coordinate the expected request
584
- rate and IP allowlisting. Do not distribute one production key across
585
- untrusted clients.
586
-
623
+ | Index | The Index | `0x56910D4409F3a0C78C64DD8D0545FF0705389870` | 18 |
624
+ | VEX | ProjectVex | `0x8Ff92566f2e81BDd68EDfAa8cde73942A723796b` | 18 |
625
+ | HOODIE | HOODIE | `0xC72c01AAB5f5678dc1d6f5C6d2B417d91D402Ba3` | 18 |
626
+ | WISHBONE | WISHBONE | `0x77581054581B9c525E7dd7a0155DE43867532d03` | 18 |
627
+ | VLAD | The Green Bull | `0x31BE8f7485e36928C9De86566c62da82d4B6BF81` | 18 |
628
+ | AEON | Aeon | `0xd4c93eD1843606f92CccA078941f3d52A585982f` | 18 |
629
+
630
+ The ordered list is exported as `ROBINHOOD_FRONTEND_TOKEN_LIST`.
631
+
632
+ These community tokens are frontend conveniences, not an endorsement or a
633
+ guarantee of liquidity, price stability, tax behavior, or contract safety.
634
+ Always identify tokens by address and obtain a fresh quote and tax check.
635
+
636
+ ### Routing configuration
637
+
638
+ The production router currently exposes fourteen ordered adapters:
639
+
640
+ | Index | Venue | Routing family |
641
+ |---:|---|---|
642
+ | `0` | Uniswap V2 | Direct-pair V2 |
643
+ | `1` | Uniswap V3 | V3 tiers `100`, `500`, `3000`, `10000` |
644
+ | `2` | Uniswap V4 | Complete hookless static-fee `PoolKey` |
645
+ | `3` | Switch limit orders | Signed/on-chain order liquidity |
646
+ | `4` | SwapHood V2 | Pair-owned variable-fee V2 |
647
+ | `5` | SwapHood V3 | Pancake V3 tiers `100`, `500`, `2500`, `10000` |
648
+ | `6` | Up33 | Slipstream CL tick spacings `1`, `10`, `50`, `60`, `100`, `200`, `2000` |
649
+ | `7` | Sheriff V2 | Pair-owned variable-fee V2 |
650
+ | `8` | Sheriff | Algebra Integral |
651
+ | `9` | Aeon | Algebra Integral with plugin-aware fees |
652
+ | `10` | Catnip | Direct-pair V2, fixed 30 bps |
653
+ | `11` | PancakeSwap | Direct-pair V2, fixed 25 bps |
654
+ | `12` | RobinSwap | V3 tiers `100`, `500`, `2500`, `3000`, `10000` |
655
+ | `13` | SushiSwap | V3 tiers `500`, `3000`, `10000` |
656
+
657
+ V4 pools are discovered by complete `PoolKey`, not by applying a V3 fee-tier
658
+ list. Native-ETH V4 currencies are normalized through the WETH/native alias
659
+ described above. V3-style and Up33 route legs preserve the exact fee tier or
660
+ tick spacing that won the quote for every direct and multi-hop allocation.
661
+
662
+ Trusted routing hubs are WETH, USDG, VIRTUAL, CASHCAT, HOODRAT, TENDIES,
663
+ JUGGERNAUT, MARIAN, and WALLET. The expanded set was selected from the
664
+ 2026-07-16 pair-connectivity audit and zero-tax checks. VEX is excluded because
665
+ it is taxed; INDEX remains an endpoint token but is excluded because its
666
+ dominant liquidity depends on V4 hooks that are not yet supported. If either side is
667
+ detected as a transfer-tax token, the backend restricts the entire route to
668
+ direct-pair V2 adapters `0`, `4`, `7`, `10`, and `11`; concentrated-liquidity
669
+ and limit-order adapters are excluded.
670
+
671
+ The API may split a quote across routes and adapters. Integrators should render
672
+ the returned `paths` or `routeAllocation` instead of assuming a single path.
673
+
674
+ ## Rate limits
675
+
676
+ Rate limits are assigned to the API key. A `429` response means the integration
677
+ must back off. Use request coalescing and short-lived UI caching, avoid polling
678
+ unchanged quotes, and debounce amount input before requesting a new route.
679
+
680
+ For server integrations, contact Switch to coordinate the expected request
681
+ rate and IP allowlisting. Do not distribute one production key across
682
+ untrusted clients.
683
+
587
684
  ## Current limitations
588
685
 
589
- - Robinhood limit orders are not deployed.
590
- - Rialto DEX is not integrated.
591
- - The production router supports Uniswap V2, V3, and supported hookless
592
- static-fee V4 liquidity. V4 participates in quotes whenever adapter index
593
- `2` is advertised by `/swap/adapters`.
686
+ - Rialto liquidity is not integrated.
687
+ - Robinhood market routing is limited to the fourteen production adapters
688
+ listed above. Always use `/swap/adapters` as the runtime source of truth.
594
689
  - The first V4 phase intentionally excludes hooked and dynamic-fee pools.
595
690
  - A V4 allocation currently selects its best single PoolKey; intra-V4
596
- multi-pool splitting is not yet enabled. V4 can still split against V2/V3.
691
+ multi-pool splitting is not yet enabled. V4 can still split against other
692
+ eligible adapters.
597
693
  - Contract and token addresses must be treated as chain-specific.
598
-
599
- See the main [SDK reference](README.md) for authentication, partner fees,
600
- response types, error handling, and the complete swap API schema.
601
-
602
- ## Support
603
-
604
- - Documentation: <https://docs.switch.win>
605
- - Website: <https://switch.win>
606
- - Quote API: <https://quote.switch.win>
607
-
608
- ## License
609
-
610
- See [LICENSE](LICENSE).
694
+
695
+ See the main [SDK reference](README.md) for authentication, partner fees,
696
+ response types, error handling, and the complete swap API schema.
697
+
698
+ ## Support
699
+
700
+ - Documentation: <https://docs.switch.win>
701
+ - Website: <https://switch.win>
702
+ - Quote API: <https://quote.switch.win>
703
+
704
+ ## License
705
+
706
+ See [LICENSE](LICENSE).