@switch-win/sdk 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/GASLESS.md +407 -0
  3. package/LIMIT-ORDERS.md +212 -198
  4. package/README.md +131 -105
  5. package/ROBINHOOD.md +201 -198
  6. package/abi/GaslessSwitchV2ABI.json +1095 -0
  7. package/dist/constants.d.ts +276 -0
  8. package/dist/constants.d.ts.map +1 -0
  9. package/dist/constants.js +403 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/gasless-client.d.ts +81 -0
  12. package/dist/gasless-client.d.ts.map +1 -0
  13. package/dist/gasless-client.js +467 -0
  14. package/dist/gasless-client.js.map +1 -0
  15. package/dist/gasless-index.d.ts +5 -0
  16. package/dist/gasless-index.d.ts.map +1 -0
  17. package/dist/gasless-index.js +5 -0
  18. package/dist/gasless-index.js.map +1 -0
  19. package/dist/gasless-operators.d.ts +32 -0
  20. package/dist/gasless-operators.d.ts.map +1 -0
  21. package/dist/gasless-operators.js +132 -0
  22. package/dist/gasless-operators.js.map +1 -0
  23. package/dist/gasless-store.d.ts +18 -0
  24. package/dist/gasless-store.d.ts.map +1 -0
  25. package/dist/gasless-store.js +83 -0
  26. package/dist/gasless-store.js.map +1 -0
  27. package/dist/gasless-types.d.ts +218 -0
  28. package/dist/gasless-types.d.ts.map +1 -0
  29. package/dist/gasless-types.js +2 -0
  30. package/dist/gasless-types.js.map +1 -0
  31. package/dist/gasless.d.ts +135 -0
  32. package/dist/gasless.d.ts.map +1 -0
  33. package/dist/gasless.js +513 -0
  34. package/dist/gasless.js.map +1 -0
  35. package/dist/index.d.ts +29 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +30 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/limit-orders.d.ts +440 -0
  40. package/dist/limit-orders.d.ts.map +1 -0
  41. package/dist/limit-orders.js +387 -0
  42. package/dist/limit-orders.js.map +1 -0
  43. package/dist/networks/index.d.ts +3 -0
  44. package/dist/networks/index.d.ts.map +1 -0
  45. package/dist/networks/index.js +2 -0
  46. package/dist/networks/index.js.map +1 -0
  47. package/dist/networks/robinhood.d.ts +536 -0
  48. package/dist/networks/robinhood.d.ts.map +1 -0
  49. package/dist/networks/robinhood.js +489 -0
  50. package/dist/networks/robinhood.js.map +1 -0
  51. package/dist/types.d.ts +436 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/types.js +19 -0
  54. package/dist/types.js.map +1 -0
  55. package/examples/gasless-nextjs-proxy.ts +87 -0
  56. package/examples/gasless-operator.ts +76 -0
  57. package/examples/gasless-swap.ts +170 -0
  58. package/examples/limit-order-ethers.ts +195 -0
  59. package/examples/nextjs-proxy.ts +82 -0
  60. package/examples/react-hooks.tsx +396 -0
  61. package/examples/swap-ethers.ts +209 -0
  62. package/examples/swap-web3py.py +267 -0
  63. package/package.json +53 -12
  64. package/src/constants.ts +181 -178
  65. package/src/gasless-client.ts +823 -0
  66. package/src/gasless-index.ts +4 -0
  67. package/src/gasless-operators.ts +227 -0
  68. package/src/gasless-store.ts +137 -0
  69. package/src/gasless-types.ts +258 -0
  70. package/src/gasless.ts +756 -0
  71. package/src/index.ts +69 -63
  72. package/src/limit-orders.ts +206 -195
  73. package/src/types.ts +80 -55
package/src/types.ts CHANGED
@@ -25,10 +25,10 @@ export interface BestPathResponse {
25
25
  receiver?: string;
26
26
  /** Total input amount in wei */
27
27
  totalAmountIn: string;
28
- /**
29
- * Quoted route output in wei before the Switch protocol fee and slippage.
30
- * Adapter-native quotes may already include token-tax effects (for example,
31
- * the Flap Portal quote).
28
+ /**
29
+ * Quoted route output in wei before the Switch protocol fee and slippage.
30
+ * Adapter-native quotes may already include token-tax effects (for example,
31
+ * the Flap Portal quote).
32
32
  */
33
33
  totalAmountOut: string;
34
34
  /**
@@ -40,17 +40,17 @@ export interface BestPathResponse {
40
40
  * multipliers to `totalAmountOut`.
41
41
  */
42
42
  expectedOutputAmount: string;
43
- /**
44
- * Minimum acceptable output after taxes, fee, and slippage.
45
- *
46
- * Tax accounting is adapter-specific. Use this API value directly rather
47
- * than recomputing it from the reported tax rates. This is encoded in the
48
- * `tx` calldata as `_minTotalAmountOut`.
43
+ /**
44
+ * Minimum acceptable output after taxes, fee, and slippage.
45
+ *
46
+ * Tax accounting is adapter-specific. Use this API value directly rather
47
+ * than recomputing it from the reported tax rates. This is encoded in the
48
+ * `tx` calldata as `_minTotalAmountOut`.
49
49
  */
50
50
  minAmountOut: string;
51
51
  /** Human-readable path descriptions */
52
52
  paths: SwapPath[];
53
- /** Human-readable structured route breakdown for display and analytics. */
53
+ /** Human-readable structured route breakdown for display and analytics. */
54
54
  routeAllocation?: RouteAllocationPlan;
55
55
  /** Ready-to-send transaction with fee on **input** (default). Only present when `sender` query param is provided. */
56
56
  tx?: SwapTransaction;
@@ -62,6 +62,15 @@ export interface BestPathResponse {
62
62
  * the output token). See the README for recommended strategies.
63
63
  */
64
64
  txFeeOnOutput?: SwapTransaction;
65
+ /** Transaction matching the requested fee mode. Never broadcast this for a gasless order. */
66
+ selectedTx?: SwapTransaction;
67
+ protocolFeeBps?: number;
68
+ feeOnOutput?: boolean;
69
+ quoteGasPrice?: string;
70
+ quoteBlockNumber?: number;
71
+ gaslessExecution?: import("./gasless-types.js").GaslessPreviewResult;
72
+ /** Conservative server recommendation; normal quotes report not_checked. */
73
+ gaslessEligibility?: import("./gasless-types.js").GaslessEligibility;
65
74
  /**
66
75
  * Transfer tax info for the input token.
67
76
  * Present when the API detects whether the token has a fee-on-transfer mechanism.
@@ -116,8 +125,8 @@ export interface SwapTransaction {
116
125
  to: string;
117
126
  /** ABI-encoded `goSwitch()` calldata */
118
127
  data: string;
119
- /** Native currency to send (wei). `"0"` for ERC-20 input tokens. */
120
- value: string;
128
+ /** Native currency to send (wei). `"0"` for ERC-20 input tokens. */
129
+ value: string;
121
130
  }
122
131
 
123
132
  // -- Human-readable paths --
@@ -159,7 +168,7 @@ export interface SwapPathLeg {
159
168
  percentage?: number;
160
169
  }
161
170
 
162
- // -- Human-readable route allocation --
171
+ // -- Human-readable route allocation --
163
172
 
164
173
  /** Top-level route allocation plan */
165
174
  export interface RouteAllocationPlan {
@@ -192,16 +201,16 @@ export interface HopAllocationPlan {
192
201
  }
193
202
 
194
203
  /** A single adapter leg within a hop */
195
- export interface HopAdapterAllocationPlan {
196
- /** Human-readable DEX adapter name */
197
- adapter: string;
204
+ export interface HopAdapterAllocationPlan {
205
+ /** Human-readable DEX adapter name */
206
+ adapter: string;
198
207
  /** Input amount routed through this adapter (wei) */
199
208
  amountIn: string;
200
- /** Expected output from this adapter (wei) */
201
- amountOut: string;
202
- /** V3 fee tier or concentrated-liquidity tick-spacing hint. Zero for adapters that do not use it. */
203
- fee?: number;
204
- }
209
+ /** Expected output from this adapter (wei) */
210
+ amountOut: string;
211
+ /** V3 fee tier or concentrated-liquidity tick-spacing hint. Zero for adapters that do not use it. */
212
+ fee?: number;
213
+ }
205
214
 
206
215
  // -- Error response --
207
216
 
@@ -314,24 +323,24 @@ export interface LimitOrderParams {
314
323
  * A signed limit order — the order parameters plus the EIP-712 signature.
315
324
  * This is what gets submitted to the Switch backend via `POST /limit-orders`.
316
325
  */
317
- export interface SignedLimitOrder extends LimitOrderParams {
318
- /** EIP-712 signature of the order struct, produced by the maker's wallet */
319
- signature: string;
320
- /**
321
- * SwitchLimitOrder deployment used in the EIP-712 domain.
322
- * Include this when submitting Robinhood orders or orders signed against an
323
- * older supported deployment so the backend verifies the correct domain.
324
- */
325
- limitOrderContract?: string;
326
- }
326
+ export interface SignedLimitOrder extends LimitOrderParams {
327
+ /** EIP-712 signature of the order struct, produced by the maker's wallet */
328
+ signature: string;
329
+ /**
330
+ * SwitchLimitOrder deployment used in the EIP-712 domain.
331
+ * Include this when submitting Robinhood orders or orders signed against an
332
+ * older supported deployment so the backend verifies the correct domain.
333
+ */
334
+ limitOrderContract?: string;
335
+ }
327
336
 
328
337
  // -- API request/response types --
329
338
 
330
339
  /** Body for `POST /limit-orders` */
331
340
  export type CreateLimitOrderRequest = SignedLimitOrder;
332
341
 
333
- /** @deprecated Current hosted API cancellation is on-chain only. */
334
- export interface CancelLimitOrderRequest {
342
+ /** @deprecated Current hosted API cancellation is on-chain only. */
343
+ export interface CancelLimitOrderRequest {
335
344
  /** Maker address */
336
345
  maker: string;
337
346
  /** Nonce of the order to cancel */
@@ -367,7 +376,7 @@ export interface LimitOrderRecord {
367
376
  nonce: number;
368
377
  /** Fee mode flag */
369
378
  feeOnOutput: boolean;
370
- /** Unwrap wrapped-native output to PLS/ETH on the selected network */
379
+ /** Unwrap wrapped-native output to PLS/ETH on the selected network */
371
380
  unwrapOutput: boolean;
372
381
  /** Partner address for fee sharing */
373
382
  partnerAddress: string;
@@ -407,8 +416,8 @@ export interface CreateLimitOrderResponse {
407
416
  order: LimitOrderRecord;
408
417
  }
409
418
 
410
- /** @deprecated Current hosted API cancellation is on-chain only. */
411
- export interface CancelLimitOrderResponse {
419
+ /** @deprecated Current hosted API cancellation is on-chain only. */
420
+ export interface CancelLimitOrderResponse {
412
421
  success: true;
413
422
  }
414
423
 
@@ -437,29 +446,45 @@ export interface LimitOrderPair {
437
446
  }
438
447
 
439
448
  /** Response from `GET /limit-orders/stats` */
440
- export interface LimitOrderStats {
449
+ export interface LimitOrderStats {
441
450
  active: number;
442
451
  filled: number;
443
452
  cancelled: number;
444
453
  expired: number;
445
454
  total: number;
446
- }
447
-
448
- /** Response from `GET /limit-orders/config`. */
449
- export interface LimitOrderConfigResponse {
450
- limitOrderContract: string;
451
- allLimitOrderContracts: string[];
452
- plsFlowContract: string | null;
453
- allPlsFlowContracts: string[];
454
- limitOrderContractVersions: Record<string, string>;
455
- plsFlowContractVersions: Record<string, string>;
456
- eip712Domain: {
457
- name: "SwitchLimitOrder";
458
- version: "2";
459
- chainId: number;
460
- verifyingContract: string;
461
- };
462
- }
455
+ }
456
+
457
+ /** Response from `GET /limit-orders/config`. */
458
+ export interface LimitOrderConfigResponse {
459
+ limitOrderContract: string;
460
+ limitOrderRouter?: string | null;
461
+ gaslessContract?: string | null;
462
+ gaslessSettlementVersion?: number;
463
+ gaslessTaxTokensSupported?: boolean;
464
+ gaslessApprovalSpender?: string | null;
465
+ gaslessProtocolFeeBps?: number;
466
+ gaslessMaxOperatorPayoutBps?: number;
467
+ gaslessEip712Domain?: {
468
+ name: string;
469
+ version: string;
470
+ chainId: number;
471
+ verifyingContract: string;
472
+ } | null;
473
+ orderSubmissionLimitOrderContracts?: string[];
474
+ otcRoutingLimitOrderContracts?: string[];
475
+ deprecatedLimitOrderContracts?: string[];
476
+ allLimitOrderContracts: string[];
477
+ plsFlowContract: string | null;
478
+ allPlsFlowContracts: string[];
479
+ limitOrderContractVersions: Record<string, string>;
480
+ plsFlowContractVersions: Record<string, string>;
481
+ eip712Domain: {
482
+ name: "SwitchLimitOrder";
483
+ version: "2";
484
+ chainId: number;
485
+ verifyingContract: string;
486
+ };
487
+ }
463
488
 
464
489
  /** Union type for limit order mutation responses */
465
490
  export type LimitOrderMutationResponse =