@switch-win/sdk 1.1.0 → 1.2.1

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/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@switch-win/sdk.svg)](https://www.npmjs.com/package/@switch-win/sdk)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/@switch-win/sdk.svg)](https://www.npmjs.com/package/@switch-win/sdk)
5
5
 
6
- > **Official integration kit for the Switch DEX Aggregator on PulseChain**
6
+ > **Official integration kit for the Switch DEX Aggregator on PulseChain and Robinhood Chain**
7
7
 
8
8
  Everything partners need to integrate Switch swaps and limit orders — API docs, TypeScript types, ABIs, constants, and ready-to-use examples.
9
9
 
10
- **Swap API:** `https://quote.switch.win`  |  **Limit Order API:** `https://quote.switch.win`  |  **Chain:** PulseChain (369)
10
+ **Swap API:** `https://quote.switch.win`  |  **Swap chains:** PulseChain (369), Robinhood Chain (4663)  |  **Limit orders:** PulseChain
11
11
 
12
12
  ---
13
13
 
@@ -20,7 +20,9 @@ Switch-SDK/
20
20
  ├── src/
21
21
  │ ├── index.ts # Main entry — re-exports everything
22
22
  │ ├── types.ts # TypeScript types (swap + limit orders)
23
- │ ├── constants.ts # Addresses, ABIs, EIP-712, PLSFlow config
23
+ │ ├── constants.ts # PulseChain addresses, ABIs, EIP-712, PLSFlow config
24
+ │ ├── networks/
25
+ │ │ └── robinhood.ts # Robinhood metadata, contracts, tokens, quote URL helper
24
26
  │ └── limit-orders.ts # Limit order helpers (build, sign, submit, query, PLSFlow)
25
27
  ├── abi/
26
28
  │ ├── SwitchRouterABI.json # Full SwitchRouter contract ABI
@@ -40,25 +42,26 @@ Switch-SDK/
40
42
 
41
43
  0. [Installation](#installation)
42
44
 
43
- ### Swaps
44
-
45
- 1. [Quickstart](#quickstart)
46
- 2. [Authentication](#authentication)
47
- 3. [Swap Integration Flow](#swap-integration-flow)
48
- 4. [Swap API Reference](#swap-api-reference)
49
- 5. [Error Handling](#error-handling)
50
- 6. [Partner Fee Sharing](#partner-fee-sharing)
45
+ ### Swaps
46
+
47
+ 1. [Quickstart](#quickstart)
48
+ 2. [Robinhood Chain](#robinhood-chain)
49
+ 3. [Authentication](#authentication)
50
+ 4. [Swap Integration Flow](#swap-integration-flow)
51
+ 5. [Swap API Reference](#swap-api-reference)
52
+ 6. [Error Handling](#error-handling)
53
+ 7. [Partner Fee Sharing](#partner-fee-sharing)
51
54
 
52
55
  ### Limit Orders
53
56
 
54
- 7. [Limit Orders](#limit-orders) — full guide in [`LIMIT-ORDERS.md`](LIMIT-ORDERS.md)
57
+ 8. [Limit Orders](#limit-orders) — full guide in [`LIMIT-ORDERS.md`](LIMIT-ORDERS.md)
55
58
 
56
59
  ### General
57
60
 
58
- 8. [Constants & Addresses](#constants--addresses)
59
- 9. [Full Integration Examples](#full-integration-examples)
60
- 10. [Rate Limits](#rate-limits)
61
- 11. [Support](#support)
61
+ 9. [Constants & Addresses](#constants--addresses)
62
+ 10. [Full Integration Examples](#full-integration-examples)
63
+ 11. [Rate Limits](#rate-limits)
64
+ 12. [Support](#support)
62
65
 
63
66
  ---
64
67
 
@@ -83,7 +86,7 @@ Get a swap quote and execute it in **three steps**:
83
86
  curl -H "x-api-key: YOUR_KEY" \
84
87
  "https://quote.switch.win/swap/quote?network=pulsechain&from=0xA1077a294dDE1B09bB078844df40758a5D0f9a27&to=0x95B303987A60C71504D99Aa1b13B4DA07b0790ab&amount=1000000000000000000&sender=0xYOUR_WALLET&slippage=100"
85
88
 
86
- # 2. Approve the SwitchRouter to spend your input token (ERC-20 only, skip for native PLS)
89
+ # 2. Approve the SwitchRouter to spend your input token (ERC-20 only; skip for native currency)
87
90
 
88
91
  # 3. Send the transaction using the `tx` object from the response:
89
92
  # { to: "0x0305...", data: "0x...", value: "0" }
@@ -103,7 +106,7 @@ const res = await fetch(
103
106
  );
104
107
  const quote: BestPathResponse = await res.json();
105
108
 
106
- // 2. Approve SwitchRouter (ERC-20 only — skip for native PLS)
109
+ // 2. Approve SwitchRouter (ERC-20 only — skip for native currency)
107
110
  const token = new ethers.Contract(fromToken, ["function approve(address,uint256)"], signer);
108
111
  await (await token.approve(SWITCH_ROUTER, amount)).wait();
109
112
 
@@ -113,7 +116,40 @@ await signer.sendTransaction(quote.tx);
113
116
 
114
117
  > **⚠️ Always use `tx.to` from the quote response** when sending swap transactions. Do NOT hardcode the router address — the contract may be redeployed.
115
118
 
116
- For a production integration with tax token handling, adapter filtering, and fee mode selection, see [Swap Integration Flow](#swap-integration-flow) and the [full examples](examples/).
119
+ For a production integration with tax token handling, adapter filtering, and fee mode selection, see [Swap Integration Flow](#swap-integration-flow) and the [full examples](examples/).
120
+
121
+ ### Robinhood Chain
122
+
123
+ Robinhood uses the same quote endpoint; set `network=robinhood`. The dedicated
124
+ module includes canonical chain metadata, deployed Switch contracts, vetted
125
+ routing hubs, and a URL builder that always includes the correct network.
126
+
127
+ For network configuration, deployed addresses, tax handling, execution, and
128
+ the complete frontend token list, see [`ROBINHOOD.md`](ROBINHOOD.md).
129
+
130
+ ```ts
131
+ import {
132
+ ROBINHOOD_NATIVE_ETH,
133
+ ROBINHOOD_TOKENS,
134
+ buildRobinhoodQuoteUrl,
135
+ } from "@switch-win/sdk/networks/robinhood";
136
+
137
+ const url = buildRobinhoodQuoteUrl({
138
+ from: ROBINHOOD_NATIVE_ETH,
139
+ to: ROBINHOOD_TOKENS.USDG.address,
140
+ amount: 1_000_000_000_000_000n,
141
+ sender: walletAddress,
142
+ slippage: 50,
143
+ });
144
+
145
+ const response = await fetch(url, {
146
+ headers: { "x-api-key": process.env.SWITCH_API_KEY! },
147
+ });
148
+ ```
149
+
150
+ Always approve `ROBINHOOD_SWITCH_CONTRACTS.router` for ERC-20 input, but submit
151
+ the transaction to `quote.tx.to` so integrations remain safe across router
152
+ upgrades. Limit-order helpers in this package remain PulseChain-only.
117
153
 
118
154
  ---
119
155
 
@@ -214,9 +250,8 @@ function determineFeeOnOutput(
214
250
  const isSellTax = fromTax.isTaxToken && fromTax.sellTaxBps > 0;
215
251
  const isBuyTax = toTax.isTaxToken && toTax.buyTaxBps > 0;
216
252
 
217
- // Both tokens are tax tokens ALWAYS fee on input.
218
- // See "Why fee-on-input for tax tokens?" below for a detailed explanation.
219
- if (isSellTax && isBuyTax) return false;
253
+ // Both tokens are taxeduse fee on input to avoid extra output transfers.
254
+ if (isSellTax && isBuyTax) return false;
220
255
 
221
256
  // Only output token is tax — fee on input (avoids router holding output tokens)
222
257
  if (isBuyTax) return false;
@@ -255,15 +290,15 @@ Fee portion: Router ──transfer──▶ FeeClaimer (3rd buy tax on fee amoun
255
290
  ```
256
291
  The output token is transferred **three times** through different addresses, each incurring a buy tax. The user receives significantly less than expected.
257
292
 
258
- **Bottom line:** When the output token has a buy tax, always use `feeOnOutput=false` so the router routes output directly to the user in a single transfer. This applies to both regular swaps and limit orders.
259
-
260
- ### Executing the Swap
293
+ **Bottom line:** When the output token has a buy tax, always use `feeOnOutput=false` so the router routes output directly to the user in a single transfer. This applies to both regular swaps and limit orders.
294
+
295
+ ### Executing the Swap
261
296
 
262
297
  Once you have a quote, execute it in two steps:
263
298
 
264
299
  #### Step 1 — Approve Token Spend (ERC-20 inputs only)
265
300
 
266
- If the input token is an **ERC-20** (not native PLS), the user must approve the SwitchRouter contract to spend `amount` tokens before submitting the swap.
301
+ If the input token is an **ERC-20** rather than the chain's native currency, the user must approve the network's SwitchRouter contract to spend `amount` tokens before submitting the swap.
267
302
 
268
303
  Before sending an approval transaction, check whether the user already has sufficient allowance to avoid wasting gas on a redundant approve:
269
304
 
@@ -291,7 +326,7 @@ const { tx } = quoteResponse;
291
326
  const txResponse = await signer.sendTransaction({
292
327
  to: tx.to,
293
328
  data: tx.data,
294
- value: tx.value, // "0" for ERC-20 inputs, amountIn for native PLS
329
+ value: tx.value, // "0" for ERC-20 inputs, amountIn for native currency
295
330
  });
296
331
 
297
332
  const receipt = await txResponse.wait();
@@ -351,7 +386,7 @@ Returns all available DEX adapters with their on-chain indices and contract addr
351
386
 
352
387
  | Param | Required | Type | Description |
353
388
  |---|---|---|---|
354
- | `network` | **Yes** | string | Target blockchain network. Currently only `"pulsechain"` is supported. |
389
+ | `network` | **Yes** | string | Target blockchain network: `"pulsechain"` or `"robinhood"`. |
355
390
 
356
391
  #### Authentication
357
392
 
@@ -420,7 +455,7 @@ Detects whether a token has a fee-on-transfer mechanism (tax token) and returns
420
455
  | Parameter | Required | Type | Description |
421
456
  |---|---|---|---|
422
457
  | `token` | **Yes** | address | Token address to check (0x + 40 hex chars) |
423
- | `network` | No | string | Target blockchain. Currently only `"pulsechain"`. |
458
+ | `network` | No | string | Target blockchain: `"pulsechain"` or `"robinhood"`. |
424
459
 
425
460
  #### Latency
426
461
 
@@ -534,9 +569,9 @@ Returns the optimal split-route for a swap and (optionally) a ready-to-send tran
534
569
 
535
570
  | Parameter | Required | Type | Default | Description |
536
571
  |---|---|---|---|---|
537
- | `network` | **Yes** | string | — | Target blockchain network. Currently only `"pulsechain"` is supported. |
538
- | `from` | **Yes** | address | — | Input token address. Use `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` for native PLS. |
539
- | `to` | **Yes** | address | — | Output token address. Use `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` for native PLS. |
572
+ | `network` | **Yes** | string | — | Target blockchain network: `"pulsechain"` or `"robinhood"`. |
573
+ | `from` | **Yes** | address | — | Input token address. Use `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` for the network's native currency (PLS or ETH). |
574
+ | `to` | **Yes** | address | — | Output token address. Use `0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` for the network's native currency (PLS or ETH). |
540
575
  | `amount` | **Yes** | string | — | Input amount in **wei** (raw integer string, no decimals). Max: 10²⁷. |
541
576
  | `sender` | No* | address | — | Sender wallet address. **Required to receive `tx` calldata in the response.** |
542
577
  | `receiver` | No | address | `sender` | Custom recipient address. If omitted, output tokens are sent to `sender`. |
@@ -625,7 +660,7 @@ GET /swap/quote?network=pulsechain&from=0xA1077a294dDE1B09bB078844df40758a5D0f9a
625
660
  "tx": {
626
661
  "to": "0x0305fcb5dA680EA6fd1B01A96C1949175B99d406",
627
662
  "data": "0x...", // ABI-encoded goSwitch() calldata with feeOnOutput = false
628
- "value": "0" // "0" for ERC-20 input; amountIn for native PLS input
663
+ "value": "0" // "0" for ERC-20 input; amountIn for native-currency input
629
664
  },
630
665
  // Same swap but with fee taken from the output token instead
631
666
  "txFeeOnOutput": {
@@ -763,7 +798,7 @@ Errors are returned as JSON with an `error` field:
763
798
  | Error | Cause |
764
799
  |---|---|
765
800
  | `"Missing required parameter: network"` | `network` query param absent |
766
- | `"This network is not supported at this time."` | `network` is not `"pulsechain"` |
801
+ | `"This network is not supported at this time."` | `network` is not a supported value (`"pulsechain"` or `"robinhood"`) |
767
802
  | `"Missing required parameters: from, to, amount"` | One or more required query params absent |
768
803
  | `"Invalid from address (must be 0x + 40 hex chars)"` | `from` is not a valid hex address |
769
804
  | `"Invalid to address (must be 0x + 40 hex chars)"` | `to` is not a valid hex address |
@@ -793,7 +828,7 @@ If the swap transaction reverts on-chain, the SwitchRouter contract returns one
793
828
  | `FinalAmountOutTooLow()` | Output after fees fell below `_minTotalAmountOut` — price moved beyond your slippage tolerance. Retry with a fresh quote or increase slippage. |
794
829
  | `ExcessiveFee()` | `_fee` exceeds the contract maximum (100 bps / 1 %). |
795
830
  | `InsufficientFee()` | `_fee` is below the protocol's `MIN_FEE`. Contact the Switch team if you need a lower fee. |
796
- | `MsgValueMismatch()` | For native PLS swaps, `msg.value` must exactly equal the route's total `amountIn`. |
831
+ | `MsgValueMismatch()` | For native-currency swaps, `msg.value` must exactly equal the route's total `amountIn`. |
797
832
  | `ZeroInput()` | No input amount was provided. |
798
833
 
799
834
  ---
@@ -846,10 +881,11 @@ function shouldFeeOnOutput(from: string, to: string, quote?: BestPathResponse):
846
881
  if (toAddr === MY_PROJECT_TOKEN) return false; // fee on input = collect input
847
882
 
848
883
  // Priority 2: Avoid collecting tax tokens (fee revenue lost to transfer tax)
849
- if (quote) {
850
- const fromIsTax = quote.fromTokenTax?.isTaxToken ?? false;
851
- const toIsTax = quote.toTokenTax?.isTaxToken ?? false;
852
- if (fromIsTax && !toIsTax) return true; // collect non-tax output
884
+ if (quote) {
885
+ const fromIsTax = quote.fromTokenTax?.isTaxToken ?? false;
886
+ const toIsTax = quote.toTokenTax?.isTaxToken ?? false;
887
+ if (fromIsTax && toIsTax) return false;
888
+ if (fromIsTax && !toIsTax) return true; // collect non-tax output
853
889
  if (toIsTax && !fromIsTax) return false; // collect non-tax input
854
890
  }
855
891
 
@@ -890,13 +926,16 @@ Covers: creating orders, approvals, `feeOnOutput` decision guide (tax tokens & o
890
926
 
891
927
  ## Constants & Addresses
892
928
 
893
- All constants are importable from [`src/constants.ts`](src/constants.ts).
929
+ PulseChain constants are importable from [`src/constants.ts`](src/constants.ts).
930
+ Robinhood constants are available from
931
+ [`src/networks/robinhood.ts`](src/networks/robinhood.ts); see the complete
932
+ [`ROBINHOOD.md`](ROBINHOOD.md) integration reference.
894
933
 
895
934
  > **⚠️ Do not hardcode the SwitchRouter address.** The router contract may be redeployed from time to time. Always use the `tx.to` (or `txFeeOnOutput.to`) address returned by the `/bestPath` API response when building your transaction. This ensures your integration automatically picks up router upgrades without code changes.
896
935
 
897
936
  | Name | Value |
898
937
  |---|---|
899
- | **Chain** | PulseChain (Chain ID `369`) |
938
+ | **Chain** | PulseChain (Chain ID `369`); Robinhood Chain uses ID `4663` and network-specific exports |
900
939
  | **SwitchRouter** | `0x0305fcb5dA680EA6fd1B01A96C1949175B99d406` |
901
940
  | **SwitchLimitOrder** (V2 — current) | `0x8e3881bdF81Fc0211383B2e576076B654F7aFD86` |
902
941
  | **SwitchLimitOrder** (V1 — legacy) | `0x0e884072a891b406C0D814907A1E2310fE5F5Deb` |
package/ROBINHOOD.md ADDED
@@ -0,0 +1,610 @@
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` |
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
+
135
+ Native ETH does not require approval. WETH and every other ERC-20 input token
136
+ must be approved for `ROBINHOOD_SWITCH_CONTRACTS.router`.
137
+
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` |
320
+
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.
325
+
326
+ ```ts
327
+ import {
328
+ buildRobinhoodQuoteUrl,
329
+ selectRobinhoodFeeOnOutput,
330
+ type BestPathResponse,
331
+ } from "@switch-win/sdk";
332
+
333
+ const feeOnOutput = selectRobinhoodFeeOnOutput(
334
+ tokenIn,
335
+ tokenOut,
336
+ inputTax,
337
+ outputTax,
338
+ );
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
+ ```
362
+
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.
367
+
368
+ ## Approving and executing
369
+
370
+ For ERC-20 input:
371
+
372
+ ```ts
373
+ const token = new ethers.Contract(
374
+ tokenIn,
375
+ ["function approve(address spender, uint256 amount) returns (bool)"],
376
+ signer,
377
+ );
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
+ ```
407
+
408
+ Robinhood currently returns:
409
+
410
+ | Index | Adapter |
411
+ |---:|---|
412
+ | `0` | Uniswap V2 |
413
+ | `1` | Uniswap V3 |
414
+ | `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
+
419
+ Do not permanently hard-code the available adapter list in an integration.
420
+ 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 |
547
+ | 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
+
587
+ ## Current limitations
588
+
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`.
594
+ - The first V4 phase intentionally excludes hooked and dynamic-fee pools.
595
+ - 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.
597
+ - 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).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@switch-win/sdk",
3
- "version": "1.1.0",
4
- "description": "Official integration kit for the Switch DEX Aggregator on PulseChain types, constants, ABIs, limit orders, and examples",
3
+ "version": "1.2.1",
4
+ "description": "Official integration kit for the Switch DEX Aggregator on PulseChain and Robinhood Chain",
5
5
  "author": "BuildTheTech",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -13,6 +13,7 @@
13
13
  "dex",
14
14
  "aggregator",
15
15
  "pulsechain",
16
+ "robinhood-chain",
16
17
  "swap",
17
18
  "limit-order",
18
19
  "eip712",
@@ -26,6 +27,8 @@
26
27
  ".": "./src/index.ts",
27
28
  "./types": "./src/types.ts",
28
29
  "./constants": "./src/constants.ts",
30
+ "./networks": "./src/networks/index.ts",
31
+ "./networks/robinhood": "./src/networks/robinhood.ts",
29
32
  "./limit-orders": "./src/limit-orders.ts",
30
33
  "./abi": "./abi/SwitchRouterABI.json",
31
34
  "./abi/limit-order": "./abi/SwitchLimitOrderABI.json"
@@ -33,7 +36,8 @@
33
36
  "files": [
34
37
  "src/",
35
38
  "abi/",
36
- "README.md"
39
+ "README.md",
40
+ "ROBINHOOD.md"
37
41
  ],
38
42
  "devDependencies": {
39
43
  "typescript": "^5.9.3"
package/src/index.ts CHANGED
@@ -109,7 +109,29 @@ export {
109
109
  fetchLimitOrderStats,
110
110
  } from "./limit-orders.js";
111
111
 
112
- export type {
113
- BuildLimitOrderOptions,
114
- ListLimitOrdersOptions,
115
- } from "./limit-orders.js";
112
+ export type {
113
+ BuildLimitOrderOptions,
114
+ ListLimitOrdersOptions,
115
+ } from "./limit-orders.js";
116
+
117
+ // Network-specific swap configuration
118
+ export {
119
+ ROBINHOOD_NETWORK,
120
+ ROBINHOOD_CHAIN,
121
+ ROBINHOOD_NATIVE_ETH,
122
+ ROBINHOOD_SWITCH_CONTRACTS,
123
+ ROBINHOOD_UNISWAP_CONTRACTS,
124
+ ROBINHOOD_TOKENS,
125
+ ROBINHOOD_FRONTEND_TOKEN_LIST,
126
+ ROBINHOOD_FRONTEND_DEFAULT_TOKENS,
127
+ ROBINHOOD_TRUSTED_INTERMEDIATES,
128
+ ROBINHOOD_FEE_TOKEN_PRIORITY,
129
+ selectRobinhoodFeeOnOutput,
130
+ buildRobinhoodQuoteUrl,
131
+ } from "./networks/robinhood.js";
132
+
133
+ export type {
134
+ RobinhoodToken,
135
+ RobinhoodQuoteParams,
136
+ RobinhoodTaxInfo,
137
+ } from "./networks/robinhood.js";
@@ -0,0 +1,20 @@
1
+ export {
2
+ ROBINHOOD_NETWORK,
3
+ ROBINHOOD_CHAIN,
4
+ ROBINHOOD_NATIVE_ETH,
5
+ ROBINHOOD_SWITCH_CONTRACTS,
6
+ ROBINHOOD_UNISWAP_CONTRACTS,
7
+ ROBINHOOD_TOKENS,
8
+ ROBINHOOD_FRONTEND_TOKEN_LIST,
9
+ ROBINHOOD_FRONTEND_DEFAULT_TOKENS,
10
+ ROBINHOOD_TRUSTED_INTERMEDIATES,
11
+ ROBINHOOD_FEE_TOKEN_PRIORITY,
12
+ selectRobinhoodFeeOnOutput,
13
+ buildRobinhoodQuoteUrl,
14
+ } from "./robinhood.js";
15
+
16
+ export type {
17
+ RobinhoodToken,
18
+ RobinhoodQuoteParams,
19
+ RobinhoodTaxInfo,
20
+ } from "./robinhood.js";
@@ -0,0 +1,321 @@
1
+ import { API_BASE } from "../constants.js";
2
+
3
+ /** API network value used by Switch endpoints. */
4
+ export const ROBINHOOD_NETWORK = "robinhood" as const;
5
+
6
+ /** Robinhood Chain mainnet metadata. */
7
+ export const ROBINHOOD_CHAIN = {
8
+ id: 4663,
9
+ name: "Robinhood Chain",
10
+ nativeCurrency: {
11
+ name: "Ether",
12
+ symbol: "ETH",
13
+ decimals: 18,
14
+ },
15
+ rpcUrls: ["https://rpc.mainnet.chain.robinhood.com"],
16
+ blockExplorerUrl: "https://robinhoodchain.blockscout.com",
17
+ } as const;
18
+
19
+ /** Native-ETH sentinel accepted by the Switch quote API. */
20
+ export const ROBINHOOD_NATIVE_ETH =
21
+ "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
22
+
23
+ /** Switch contracts deployed on Robinhood Chain. */
24
+ export const ROBINHOOD_SWITCH_CONTRACTS = {
25
+ /** ERC-20 approval target. Use quote.tx.to when submitting a swap. */
26
+ router: "0x8730C3e2cF2c8CDa8E6166837A1Ed26f46aa9E59",
27
+ routerView: "0xFF6b56d3F444eB5b7FA1db047F57140C84810376",
28
+ uniswapV2Adapter: "0x7a14d7A8509a66209D4332843b983b29bF5604A4",
29
+ uniswapV3Adapter: "0xbcA08f296d9Ba0dc19Aa0E05D355365cE29A3205",
30
+ uniswapV4Adapter: "0x754dDCD05aFbAd1cc7Bc42B9268EB586F579E7F6",
31
+ } as const;
32
+
33
+ /** Uniswap contracts used by the Robinhood Switch deployment. */
34
+ export const ROBINHOOD_UNISWAP_CONTRACTS = {
35
+ v2Factory: "0x8bcEaA40B9AcdfAedF85AdF4FF01F5Ad6517937f",
36
+ v3Factory: "0x1f7d7550B1b028f7571E69A784071F0205FD2EfA",
37
+ v3QuoterV2: "0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7",
38
+ v3SwapRouter02: "0xCaf681a66D020601342297493863E78C959E5cb2",
39
+ /** Canonical Uniswap V4 singleton and periphery deployments. */
40
+ v4PoolManager: "0x8366a39cc670b4001a1121b8f6a443a643e40951",
41
+ v4PositionDescriptor: "0x9639443158e8c5efa35bd45287bf2effd3d8dc06",
42
+ v4PositionManager: "0x58daec3116aae6d93017baaea7749052e8a04fa7",
43
+ v4Quoter: "0x8dc178efb8111bb0973dd9d722ebeff267c98f94",
44
+ v4StateView: "0xf3334192d15450cdd385c8b70e03f9a6bd9e673b",
45
+ v4UniversalRouter: "0x8876789976decbfcbbbe364623c63652db8c0904",
46
+ permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
47
+ } as const;
48
+
49
+ export interface RobinhoodToken {
50
+ readonly address: string;
51
+ readonly symbol: string;
52
+ readonly name: string;
53
+ readonly decimals: number;
54
+ }
55
+
56
+ /**
57
+ * Tokens in the Switch Robinhood frontend's curated list.
58
+ *
59
+ * Community-token addresses must never be selected by symbol alone; clones
60
+ * can share the same symbol. The addresses, symbols, and decimals below were
61
+ * checked against Robinhood Chain on 2026-07-11.
62
+ */
63
+ export const ROBINHOOD_TOKENS = {
64
+ WETH: {
65
+ address: "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",
66
+ symbol: "WETH",
67
+ name: "Wrapped Ether",
68
+ decimals: 18,
69
+ },
70
+ USDG: {
71
+ address: "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",
72
+ symbol: "USDG",
73
+ name: "Global Dollar",
74
+ decimals: 6,
75
+ },
76
+ VIRTUAL: {
77
+ address: "0xc6911796042b15d7Fa4F6CDe69e245DdCd3d9c31",
78
+ symbol: "VIRTUAL",
79
+ name: "Virtuals Protocol",
80
+ decimals: 18,
81
+ },
82
+ CASHCAT: {
83
+ address: "0x020bfC650A365f8BB26819deAAbF3E21291018b4",
84
+ symbol: "CASHCAT",
85
+ name: "Cash Cat",
86
+ decimals: 18,
87
+ },
88
+ WALLET: {
89
+ address: "0x0339f5459FC690aC85F1782e15782A151b4A9E1b",
90
+ symbol: "WALLET",
91
+ name: "Robinhood Wallet",
92
+ decimals: 18,
93
+ },
94
+ SEEDCOIN: {
95
+ address: "0xD8d1C08A8bA4fc64BAC744f74290B89ADcb6Bf25",
96
+ symbol: "seedcoin",
97
+ name: "watch it grow",
98
+ decimals: 18,
99
+ },
100
+ JUGGERNAUT: {
101
+ address: "0xD7321801CAae694090694Ff55A9323139F043B88",
102
+ symbol: "JUGGERNAUT",
103
+ name: "The Juggernaut",
104
+ decimals: 18,
105
+ },
106
+ HOODRAT: {
107
+ address: "0x8e62F281f282686fCa6dCB39288069a93fC23F1c",
108
+ symbol: "HOODRAT",
109
+ name: "Hoodrat",
110
+ decimals: 18,
111
+ },
112
+ DIH: {
113
+ address: "0x17bb0C898254406b1Ea2e8E99B0C263e26c9E4a4",
114
+ symbol: "DIH",
115
+ name: "Dog In Hood",
116
+ decimals: 18,
117
+ },
118
+ KITSU: {
119
+ address: "0x8d4dFaaA4198b6486E0293Fec914C2B6a821D4DC",
120
+ symbol: "KITSU",
121
+ name: "KITSU",
122
+ decimals: 18,
123
+ },
124
+ WEN: {
125
+ address: "0xA80eb66b3E0CF66ccB46f8b8C9e7ff5803eEb820",
126
+ symbol: "WEN",
127
+ name: "Wen Lambo",
128
+ decimals: 18,
129
+ },
130
+ REPE: {
131
+ address: "0x5266eeafF092D6136AB63D18B975A60a0Cc0C8f7",
132
+ symbol: "REPE",
133
+ name: "Robinhood Pepe",
134
+ decimals: 18,
135
+ },
136
+ TENDIES: {
137
+ address: "0x45242320DBB855EeA8Fd36804C6487E10E97FCF9",
138
+ symbol: "TENDIES",
139
+ name: "TENDIES",
140
+ decimals: 18,
141
+ },
142
+ GME: {
143
+ address: "0x7e86381A763F0Ecca2bDF27C54eAC403ddD48123",
144
+ symbol: "GME",
145
+ name: "GameStop",
146
+ decimals: 18,
147
+ },
148
+ TOKEN_4663: {
149
+ address: "0xd4052415613B34Af236024B895574c467f65b6dD",
150
+ symbol: "4663",
151
+ name: "4663",
152
+ decimals: 18,
153
+ },
154
+ MARIAN: {
155
+ address: "0x01637b14B7378B99dE75A64d50656d98488D9a4d",
156
+ symbol: "MARIAN",
157
+ name: "Lady Marian",
158
+ decimals: 18,
159
+ },
160
+ } as const satisfies Readonly<Record<string, RobinhoodToken>>;
161
+
162
+ /** Exact ERC-20 ordering used by the Switch Robinhood token dropdown. */
163
+ export const ROBINHOOD_FRONTEND_TOKEN_LIST = [
164
+ ROBINHOOD_TOKENS.WETH,
165
+ ROBINHOOD_TOKENS.USDG,
166
+ ROBINHOOD_TOKENS.VIRTUAL,
167
+ ROBINHOOD_TOKENS.CASHCAT,
168
+ ROBINHOOD_TOKENS.WALLET,
169
+ ROBINHOOD_TOKENS.SEEDCOIN,
170
+ ROBINHOOD_TOKENS.JUGGERNAUT,
171
+ ROBINHOOD_TOKENS.HOODRAT,
172
+ ROBINHOOD_TOKENS.DIH,
173
+ ROBINHOOD_TOKENS.KITSU,
174
+ ROBINHOOD_TOKENS.WEN,
175
+ ROBINHOOD_TOKENS.REPE,
176
+ ROBINHOOD_TOKENS.TENDIES,
177
+ ROBINHOOD_TOKENS.GME,
178
+ ROBINHOOD_TOKENS.TOKEN_4663,
179
+ ROBINHOOD_TOKENS.MARIAN,
180
+ ] as const satisfies readonly RobinhoodToken[];
181
+
182
+ /**
183
+ * Tokens used to initialize the Robinhood swap UI.
184
+ *
185
+ * The current default pair is native ETH -> USDG. WETH remains in this set so
186
+ * native/wrapped lookup and token selection use the canonical deployment.
187
+ */
188
+ export const ROBINHOOD_FRONTEND_DEFAULT_TOKENS = [
189
+ {
190
+ address: ROBINHOOD_NATIVE_ETH,
191
+ symbol: "ETH",
192
+ name: "Ether",
193
+ decimals: 18,
194
+ },
195
+ ROBINHOOD_TOKENS.WETH,
196
+ ROBINHOOD_TOKENS.USDG,
197
+ ] as const satisfies readonly RobinhoodToken[];
198
+
199
+ /**
200
+ * Production trusted-hop addresses, ordered by routing usefulness.
201
+ *
202
+ * The 2026-07-11 audit enumerated every pool creation from the Robinhood
203
+ * Uniswap V2/V3 factories, then required multiple meaningful counterparties
204
+ * and a successful zero-tax simulation. Keep this list synchronized with the
205
+ * Robinhood backend routing configuration.
206
+ */
207
+ export const ROBINHOOD_TRUSTED_INTERMEDIATES = [
208
+ ROBINHOOD_TOKENS.WETH.address,
209
+ ROBINHOOD_TOKENS.USDG.address,
210
+ ROBINHOOD_TOKENS.VIRTUAL.address,
211
+ ROBINHOOD_TOKENS.CASHCAT.address,
212
+ ] as const;
213
+
214
+ /** Preferred Robinhood fee tokens, from highest to lowest priority. */
215
+ export const ROBINHOOD_FEE_TOKEN_PRIORITY = [
216
+ ROBINHOOD_TOKENS.WETH.address,
217
+ ROBINHOOD_TOKENS.USDG.address,
218
+ ROBINHOOD_TOKENS.WALLET.address,
219
+ ROBINHOOD_TOKENS.SEEDCOIN.address,
220
+ ROBINHOOD_TOKENS.CASHCAT.address,
221
+ ] as const;
222
+
223
+ const ROBINHOOD_FEE_PRIORITY_BY_ADDRESS = new Map<string, number>(
224
+ ROBINHOOD_FEE_TOKEN_PRIORITY.map((address, index) => [
225
+ address.toLowerCase(),
226
+ index + 1,
227
+ ]),
228
+ );
229
+ ROBINHOOD_FEE_PRIORITY_BY_ADDRESS.set(
230
+ ROBINHOOD_NATIVE_ETH.toLowerCase(),
231
+ 1,
232
+ );
233
+
234
+ /** Minimum directional tax data required for fee-mode selection. */
235
+ export interface RobinhoodTaxInfo {
236
+ isTaxToken: boolean;
237
+ buyTaxBps: number;
238
+ sellTaxBps: number;
239
+ }
240
+
241
+ /**
242
+ * Select the safer/preferred fee side for a Robinhood swap.
243
+ *
244
+ * Tax safety takes precedence over fee-token preference. Native ETH is treated
245
+ * as equivalent to WETH. `false` means fee on input; `true` means fee on output.
246
+ */
247
+ export function selectRobinhoodFeeOnOutput(
248
+ from: string,
249
+ to: string,
250
+ fromTax: RobinhoodTaxInfo,
251
+ toTax: RobinhoodTaxInfo,
252
+ ): boolean {
253
+ const inputHasSellTax = fromTax.isTaxToken && fromTax.sellTaxBps > 0;
254
+ const outputHasBuyTax = toTax.isTaxToken && toTax.buyTaxBps > 0;
255
+
256
+ if (inputHasSellTax && outputHasBuyTax) return false;
257
+ if (outputHasBuyTax) return false;
258
+ if (inputHasSellTax) return true;
259
+
260
+ const inputPriority =
261
+ ROBINHOOD_FEE_PRIORITY_BY_ADDRESS.get(from.toLowerCase()) ?? Infinity;
262
+ const outputPriority =
263
+ ROBINHOOD_FEE_PRIORITY_BY_ADDRESS.get(to.toLowerCase()) ?? Infinity;
264
+
265
+ if (outputPriority < inputPriority) return true;
266
+ if (inputPriority < outputPriority) return false;
267
+ if (inputPriority !== Infinity) return true;
268
+ return false;
269
+ }
270
+
271
+ export interface RobinhoodQuoteParams {
272
+ from: string;
273
+ to: string;
274
+ /** Raw integer input amount in the input token's smallest unit. */
275
+ amount: string | bigint;
276
+ sender?: string;
277
+ receiver?: string;
278
+ /** Slippage in basis points. */
279
+ slippage?: number;
280
+ /** Partner fee in basis points. */
281
+ fee?: number;
282
+ partnerAddress?: string;
283
+ feeOnOutput?: boolean;
284
+ adapters?: string | readonly number[];
285
+ }
286
+
287
+ /** Build a Robinhood quote URL with the required network value included. */
288
+ export function buildRobinhoodQuoteUrl(
289
+ params: RobinhoodQuoteParams,
290
+ apiBase: string = API_BASE,
291
+ ): string {
292
+ const query = new URLSearchParams({
293
+ network: ROBINHOOD_NETWORK,
294
+ from: params.from,
295
+ to: params.to,
296
+ amount: params.amount.toString(),
297
+ });
298
+
299
+ if (params.sender) query.set("sender", params.sender);
300
+ if (params.receiver) query.set("receiver", params.receiver);
301
+ if (params.slippage !== undefined) {
302
+ query.set("slippage", params.slippage.toString());
303
+ }
304
+ if (params.fee !== undefined) query.set("fee", params.fee.toString());
305
+ if (params.partnerAddress) {
306
+ query.set("partnerAddress", params.partnerAddress);
307
+ }
308
+ if (params.feeOnOutput !== undefined) {
309
+ query.set("feeOnOutput", params.feeOnOutput.toString());
310
+ }
311
+ if (params.adapters !== undefined) {
312
+ query.set(
313
+ "adapters",
314
+ Array.isArray(params.adapters)
315
+ ? params.adapters.join(",")
316
+ : String(params.adapters),
317
+ );
318
+ }
319
+
320
+ return `${apiBase.replace(/\/$/, "")}/swap/quote?${query.toString()}`;
321
+ }
package/src/types.ts CHANGED
@@ -116,8 +116,8 @@ export interface SwapTransaction {
116
116
  to: string;
117
117
  /** ABI-encoded `goSwitch()` calldata */
118
118
  data: string;
119
- /** Native PLS to send (wei). `"0"` for ERC-20 input tokens. */
120
- value: string;
119
+ /** Native currency to send (wei). `"0"` for ERC-20 input tokens. */
120
+ value: string;
121
121
  }
122
122
 
123
123
  // -- Human-readable paths --