-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.json
More file actions
7946 lines (7946 loc) · 379 KB
/
openapi.json
File metadata and controls
7946 lines (7946 loc) · 379 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"openapi": "3.0.3",
"info": {
"title": "0x API",
"description": "This is the official API reference for the latest 0x API (v2).",
"version": "v2"
},
"servers": [{ "url": "https://api.0x.org" }],
"paths": {
"/swap/allowance-holder/price": {
"get": {
"operationId": "swap::allowanceHolder::getPrice",
"summary": "getPrice (Allowance Holder)",
"description": "Get the indicative price for a swap using Allowance Holder to set allowances",
"tags": ["Swap"],
"parameters": [
{
"description": "Visit dashboard.0x.org to get your API Key",
"in": "header",
"name": "0x-api-key",
"required": true,
"schema": { "type": "string" }
},
{
"description": "API version",
"in": "header",
"name": "0x-version",
"required": true,
"schema": { "type": "string", "example": "v2" }
},
{
"name": "chainId",
"in": "query",
"required": true,
"schema": {
"type": "integer",
"exclusiveMinimum": true,
"minimum": 0
},
"description": "Chain ID. See [here](https://docs.0x.org/docs/introduction/supported-chains) for the list of supported chains",
"example": 1
},
{
"name": "buyToken",
"in": "query",
"required": true,
"schema": {
"type": "string",
"pattern": "^0x(?!0{40})[a-fA-F0-9]{40}$"
},
"description": "The contract address of the token to buy",
"example": "0xdac17f958d2ee523a2206206994597c13d831ec7"
},
{
"name": "sellToken",
"in": "query",
"required": true,
"schema": {
"type": "string",
"pattern": "^0x(?!0{40})[a-fA-F0-9]{40}$"
},
"description": "The contract address of the token to sell",
"example": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
},
{
"name": "sellAmount",
"in": "query",
"required": true,
"schema": { "type": "string" },
"description": "The amount of `sellToken` in `sellToken` base units to sell",
"example": "100000000"
},
{
"name": "taker",
"in": "query",
"required": false,
"schema": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
"description": "The address which holds the `sellToken` balance and has the allowance set for the swap",
"example": "0x70a9f34f9b34c64957b9c401a97bfed35b95049e"
},
{
"name": "txOrigin",
"in": "query",
"required": false,
"schema": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
"description": "The address of the external account that started the transaction. This is only needed if `taker` is a smart contract."
},
{
"name": "recipient",
"in": "query",
"required": false,
"schema": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
"description": "The address to receive the `buyToken`. If not provided, defaults to the taker address. Not supported for wrap/unwrap operations."
},
{
"name": "swapFeeRecipient",
"in": "query",
"required": false,
"schema": {
"type": "string",
"pattern": "^\\s*0x[a-fA-F0-9]{40}(\\s*,\\s*0x[a-fA-F0-9]{40})*\\s*$"
},
"description": "The wallet address to receive the specified trading fees (supports single or multiple comma-separated values). You must also specify the `swapFeeBps` in the request to use this feature. When multiple values are provided, must match length of `swapFeeBps`."
},
{
"name": "swapFeeBps",
"in": "query",
"required": false,
"schema": {
"type": "string",
"pattern": "^\\s*\\d+(\\s*,\\s*\\d+)*\\s*$"
},
"description": "The amount in Bps of the `swapFeeToken` to charge and deliver to the `swapFeeRecipient` (supports single or multiple comma-separated values). You must also specify the `swapFeeRecipient` in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us."
},
{
"name": "swapFeeToken",
"in": "query",
"required": false,
"schema": {
"type": "string",
"pattern": "^\\s*0x(?!0{40})[a-fA-F0-9]{40}(\\s*,\\s*0x(?!0{40})[a-fA-F0-9]{40})*\\s*$"
},
"description": "The contract address of the token to receive trading fees in (supports single or multiple comma-separated values). Each token must be set to the value of either the `buyToken` or the `sellToken`. If omitted, the fee token will be determined by 0x with preference to stablecoins and highly liquid assets. You must also specify the `swapFeeRecipient` and `swapFeeBps` to charge integrator fees. When multiple values are provided, must match length of `swapFeeBps`."
},
{
"name": "tradeSurplusRecipient",
"in": "query",
"required": false,
"schema": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
"description": "The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus. This feature is only available to selected integrators on a custom pricing plan. In other cases, the surplus will be collected by 0x. For assistance with a custom plan, please contact support."
},
{
"name": "tradeSurplusMaxBps",
"in": "query",
"required": false,
"schema": { "type": "integer", "minimum": 1, "maximum": 10000 },
"description": "The maximum trade surplus (positive slippage) that can be collected in Bps of the buy amount. If not provided, defaults to 10000 (100%). Must be used together with `tradeSurplusRecipient`."
},
{
"name": "gasPrice",
"in": "query",
"required": false,
"schema": { "type": "string" },
"description": "The target gas price (in wei) for the swap transaction. If not provided, the default value is based on the 0x gas price oracle"
},
{
"name": "slippageBps",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 0,
"maximum": 10000,
"default": 100
},
"description": "The maximum acceptable slippage of the `buyToken` in Bps. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100Bps"
},
{
"name": "excludedSources",
"in": "query",
"required": false,
"schema": { "type": "string" },
"description": "Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. See https://api.0x.org/sources?chainId=<chain_id> with the desired chain's ID for a full list of sources. Separate multiple sources with a comma"
},
{
"name": "sellEntireBalance",
"in": "query",
"required": false,
"schema": {
"type": "string",
"enum": ["true", "false"],
"default": "false"
},
"description": "If set to `true`, the taker's entire `sellToken` balance will be sold during trade execution. The `sellAmount` should be the maximum estimated value, as close as possible to the actual taker's balance to ensure the best routing. Selling more than the `sellAmount` may cause the trade to revert. This feature is designed for cases where the precise sell amount is determined during execution. Learn more [here](https://docs.0x.org/docs/0x-swap-api/additional-topics/sell-entire-balance)."
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"type": "object",
"properties": {
"allowanceTarget": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"nullable": true,
"description": "The target contract address for which the `taker` needs to have an allowance in order to be able to complete the swap. For swaps with the native asset (ie \"ETH\" or \"BNB\") as the `sellToken`, wrapping the native asset (i.e. \"ETH\" to \"WETH\") or unwrapping, no allowance is needed"
},
"blockNumber": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The block number at which the liquidity sources were sampled to generate the quote. This indicates the freshness of the quote"
},
"buyAmount": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The amount of `buyToken` (in `buyToken` units) that will be bought in the swap"
},
"buyToken": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The contract address of the token to buy in the swap"
},
"fees": {
"type": "object",
"properties": {
"integratorFee": {
"type": "object",
"properties": {
"amount": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The amount of token charged as the integrator fee"
},
"token": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The address of the token charged as the integrator fee"
},
"type": { "type": "string", "enum": ["volume"] }
},
"required": ["amount", "token", "type"],
"additionalProperties": false,
"nullable": true,
"description": "The specified fee to charge and deliver to the `swapFeeRecipient`."
},
"integratorFees": {
"type": "array",
"items": {
"type": "object",
"properties": {
"amount": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The amount of token charged as the integrator fee"
},
"token": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The address of the token charged as the integrator fee"
},
"type": {
"type": "string",
"enum": ["volume"]
}
},
"required": ["amount", "token", "type"],
"additionalProperties": false
},
"nullable": true,
"description": "The specified fees to charge and deliver to the `swapFeesRecipient`."
},
"zeroExFee": {
"type": "object",
"properties": {
"amount": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The amount of token charged as the 0x fee"
},
"token": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The address of the token charged as the 0x fee"
},
"type": { "type": "string", "enum": ["volume"] }
},
"required": ["amount", "token", "type"],
"additionalProperties": false,
"nullable": true,
"description": "The fee charged by 0x for the trade."
},
"gasFee": {
"type": "object",
"properties": {
"amount": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The amount of token charged as the gas fee"
},
"token": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The address of the token charged as the gas fee"
},
"type": { "type": "string", "enum": ["gas"] }
},
"required": ["amount", "token", "type"],
"additionalProperties": false,
"nullable": true,
"description": "The gas fee to be used in submitting the transaction."
}
},
"required": [
"integratorFee",
"integratorFees",
"zeroExFee",
"gasFee"
],
"additionalProperties": false,
"description": "Fees to be deducted in this transaction. It contains the `integratorFee`, `zeroExFee` and `gasFee`"
},
"gas": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"nullable": true,
"description": "The estimated gas limit that should be used to send the transaction to guarantee settlement"
},
"gasPrice": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The gas price (in wei) that should be used to send the transaction. The transaction needs to be sent with this `gasPrice` for the transaction to be successful"
},
"issues": {
"type": "object",
"properties": {
"allowance": {
"type": "object",
"properties": {
"actual": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The `taker`'s current allowance of the `spender`"
},
"spender": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The address to set the allowance on"
}
},
"required": ["actual", "spender"],
"additionalProperties": false,
"description": "Details of allowances that the `taker` must set for in order to execute the swap successfully. Null if no allowance is required",
"nullable": true
},
"balance": {
"type": "object",
"properties": {
"token": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The contract address of the `sellToken`"
},
"actual": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The current balance of the `sellToken` in the `taker` address"
},
"expected": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The balance of the `sellToken` required for the swap to execute successfully"
}
},
"required": ["token", "actual", "expected"],
"additionalProperties": false,
"description": "Details of balance of the `sellToken` that the `taker` must hold. Null if the `taker` has sufficient balance",
"nullable": true
},
"simulationIncomplete": {
"type": "boolean",
"description": "This is set to `true` when 0x cannot validate the transaction. This happens when the `taker` has an insufficient balance of the `sellToken` and 0x is unable to peform ehanced quote validation with the low balance. Note that this does not necessarily mean that the trade will revert"
},
"invalidSourcesPassed": {
"type": "array",
"items": { "type": "string" },
"description": "A list of invalid sources present in `excludedSources` request. See `https://api.0x.org/sources?chainId=` with the desired chain's ID for the list of valid sources"
}
},
"required": [
"allowance",
"balance",
"simulationIncomplete",
"invalidSourcesPassed"
],
"additionalProperties": false,
"description": "An object containing potential issues discovered during 0x validation that can prevent the swap from being executed successfully by the `taker`"
},
"liquidityAvailable": {
"type": "boolean",
"enum": [true],
"description": "This validates the availability of liquidity for the quote requested. The rest of the fields will only be returned if `true`"
},
"minBuyAmount": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The price which must be met or else the entire transaction will revert. This price is influenced by the `slippageBps` parameter. On-chain sources may encounter price movements from quote to settlement"
},
"route": {
"type": "object",
"properties": {
"fills": {
"type": "array",
"items": {
"type": "object",
"properties": {
"from": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The contract address of the input token"
},
"to": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The contract address of the output token"
},
"source": {
"type": "string",
"description": "The liquidity source used in the route"
},
"proportionBps": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The proportion of the trade to be filled by the `source`"
}
},
"required": [
"from",
"to",
"source",
"proportionBps"
],
"additionalProperties": false
},
"description": "Details of each segment that 0x routes the swap through"
},
"tokens": {
"type": "array",
"items": {
"type": "object",
"properties": {
"address": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The token address. This is the unique identifier of the token"
},
"symbol": {
"type": "string",
"description": "The token symbol. This is not guaranteed to be unique, as multiple tokens can have the same symbol"
}
},
"required": ["address", "symbol"],
"additionalProperties": false,
"description": "Properties of the tokens involved in the swap"
},
"description": "Properties of the tokens involved in the swap"
}
},
"required": ["fills", "tokens"],
"additionalProperties": false,
"description": "The path of liquidity sources to be used in executing this swap"
},
"sellAmount": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"description": "The amount of `sellToken` (in `sellToken` units) that will be sold in this swap"
},
"sellToken": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"description": "The contract address of the token to sell in the swap"
},
"tokenMetadata": {
"type": "object",
"properties": {
"buyToken": {
"type": "object",
"properties": {
"buyTaxBps": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"nullable": true,
"description": "The buy tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax"
},
"sellTaxBps": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"nullable": true,
"description": "The sell tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax"
},
"transferTaxBps": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"nullable": true,
"description": "The transfer tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax"
}
},
"required": [
"buyTaxBps",
"sellTaxBps",
"transferTaxBps"
],
"additionalProperties": false,
"description": "Swap-related metadata for the buy token"
},
"sellToken": {
"type": "object",
"properties": {
"buyTaxBps": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"nullable": true,
"description": "The buy tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax"
},
"sellTaxBps": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"nullable": true,
"description": "The sell tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax"
},
"transferTaxBps": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"nullable": true,
"description": "The transfer tax in bps of the token. Since each token could have arbitrary implementation, this field is best effort, meaning it would be set to `null` if the system is not able to determine the tax"
}
},
"required": [
"buyTaxBps",
"sellTaxBps",
"transferTaxBps"
],
"additionalProperties": false,
"description": "Swap-related metadata for the sell token"
}
},
"required": ["buyToken", "sellToken"],
"additionalProperties": false,
"description": "Swap-related metadata for the buy and sell token in the swap"
},
"totalNetworkFee": {
"allOf": [
{},
{
"type": "string",
"pattern": "^[-+]?(0|[1-9]\\d*)(\\.\\d+)?$"
}
],
"nullable": true,
"description": "The estimated total network cost of the swap. On chains where there is no L1 data cost, it is calculated as `gas` * `gasPrice`. On chains where there is an L1 data cost, it is calculated as `gas` * `gasPrice` + L1 data cost."
},
"zid": {
"type": "string",
"description": "The unique ZeroEx identifier of the request"
}
},
"required": [
"allowanceTarget",
"blockNumber",
"buyAmount",
"buyToken",
"fees",
"gas",
"gasPrice",
"issues",
"liquidityAvailable",
"minBuyAmount",
"route",
"sellAmount",
"sellToken",
"tokenMetadata",
"totalNetworkFee",
"zid"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"liquidityAvailable": {
"type": "boolean",
"enum": [false],
"description": "This validates the availability of liquidity for the quote requested. No other fields will be returned if it is `false`"
},
"zid": {
"type": "string",
"description": "The unique ZeroEx identifier of the request"
}
},
"required": ["liquidityAvailable", "zid"],
"additionalProperties": false
}
]
},
"example": {
"allowanceTarget": "0x000000000022d473030f116ddee9f6b43ac78ba3",
"blockNumber": "20114676",
"buyAmount": "100032748",
"buyToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"fees": {
"integratorFee": null,
"zeroExFee": null,
"gasFee": null
},
"gas": "288095",
"gasPrice": "7062490000",
"issues": {
"allowance": {
"actual": "0",
"spender": "0x0000000000001ff3684f28c67538d4d072c22734"
},
"balance": {
"token": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"actual": "0",
"expected": "100000000"
},
"simulationIncomplete": false,
"invalidSourcesPassed": []
},
"liquidityAvailable": true,
"minBuyAmount": "99032421",
"route": {
"fills": [
{
"from": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"to": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"source": "SolidlyV3",
"proportionBps": "10000"
}
],
"tokens": [
{
"address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"symbol": "USDC"
},
{
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"symbol": "USDT"
}
]
},
"sellAmount": "100000000",
"sellToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"tokenMetadata": {
"buyToken": { "buyTaxBps": "0", "sellTaxBps": "0" },
"sellToken": { "buyTaxBps": "0", "sellTaxBps": "0" }
},
"totalNetworkFee": "2034668056550000",
"zid": "0x111111111111111111111111"
}
}
}
},
"400": {
"description": "400 error response",
"content": {
"application/json": {
"schema": {
"anyOf": [
{ "$ref": "#/components/schemas/INPUT_INVALID" },
{ "$ref": "#/components/schemas/RECIPIENT_NOT_SUPPORTED" },
{ "$ref": "#/components/schemas/SWAP_VALIDATION_FAILED" },
{ "$ref": "#/components/schemas/TOKEN_NOT_SUPPORTED" },
{ "$ref": "#/components/schemas/USER_NOT_AUTHORIZED" }
]
}
}
}
},
"403": {
"description": "403 error response",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/TAKER_NOT_AUTHORIZED_FOR_TRADE"
},
{
"$ref": "#/components/schemas/RECIPIENT_NOT_AUTHORIZED_FOR_TRADE"
},
{ "$ref": "#/components/schemas/XSTOCKS_NOT_AUTHORIZED" }
]
}
}
}
},
"422": {
"description": "422 error response",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"$ref": "#/components/schemas/BUY_TOKEN_NOT_AUTHORIZED_FOR_TRADE"
},
{
"$ref": "#/components/schemas/SELL_TOKEN_NOT_AUTHORIZED_FOR_TRADE"
}
]
}
}
}
},
"500": {
"description": "500 error response",
"content": {
"application/json": {
"schema": {
"anyOf": [
{ "$ref": "#/components/schemas/INTERNAL_SERVER_ERROR" },
{ "$ref": "#/components/schemas/UNCATEGORIZED" }
]
}
}
}
}
}
}
},
"/swap/allowance-holder/quote": {
"get": {
"operationId": "swap::allowanceHolder::getQuote",
"summary": "getQuote (Allowance Holder)",
"description": "Get the firm quote for a swap using Allowance Holder to set allowances",
"tags": ["Swap"],
"parameters": [
{
"description": "Visit dashboard.0x.org to get your API Key",
"in": "header",
"name": "0x-api-key",
"required": true,
"schema": { "type": "string" }
},
{
"description": "API version",
"in": "header",
"name": "0x-version",
"required": true,
"schema": { "type": "string", "example": "v2" }
},
{
"name": "chainId",
"in": "query",
"required": true,
"schema": {
"type": "integer",
"exclusiveMinimum": true,
"minimum": 0
},
"description": "Chain ID. See [here](https://docs.0x.org/docs/introduction/supported-chains) for the list of supported chains",
"example": 1
},
{
"name": "buyToken",
"in": "query",
"required": true,
"schema": {
"type": "string",
"pattern": "^0x(?!0{40})[a-fA-F0-9]{40}$"
},
"description": "The contract address of the token to buy",
"example": "0xdac17f958d2ee523a2206206994597c13d831ec7"
},
{
"name": "sellToken",
"in": "query",
"required": true,
"schema": {
"type": "string",
"pattern": "^0x(?!0{40})[a-fA-F0-9]{40}$"
},
"description": "The contract address of the token to sell",
"example": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
},
{
"name": "sellAmount",
"in": "query",
"required": true,
"schema": { "type": "string" },
"description": "The amount of `sellToken` in `sellToken` base units to sell",
"example": "100000000"
},
{
"name": "taker",
"in": "query",
"required": true,
"schema": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
"description": "The address which holds the `sellToken` balance and has the allowance set for the swap",
"example": "0x70a9f34f9b34c64957b9c401a97bfed35b95049e"
},
{
"name": "txOrigin",
"in": "query",
"required": false,
"schema": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
"description": "The address of the external account that started the transaction. This is only needed if `taker` is a smart contract."
},
{
"name": "recipient",
"in": "query",
"required": false,
"schema": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
"description": "The address to receive the `buyToken`. If not provided, defaults to the taker address. Not supported for wrap/unwrap operations."
},
{
"name": "swapFeeRecipient",
"in": "query",
"required": false,
"schema": {
"type": "string",
"pattern": "^\\s*0x[a-fA-F0-9]{40}(\\s*,\\s*0x[a-fA-F0-9]{40})*\\s*$"
},
"description": "The wallet address to receive the specified trading fees (supports single or multiple comma-separated values). You must also specify the `swapFeeBps` in the request to use this feature. When multiple values are provided, must match length of `swapFeeBps`."
},
{
"name": "swapFeeBps",
"in": "query",
"required": false,
"schema": {
"type": "string",
"pattern": "^\\s*\\d+(\\s*,\\s*\\d+)*\\s*$"
},
"description": "The amount in Bps of the `swapFeeToken` to charge and deliver to the `swapFeeRecipient` (supports single or multiple comma-separated values). You must also specify the `swapFeeRecipient` in the request to use this feature. For security, this field has a default limit of 1000 Bps. If your application requires a higher value, please reach out to us."
},
{
"name": "swapFeeToken",
"in": "query",
"required": false,
"schema": {
"type": "string",
"pattern": "^\\s*0x(?!0{40})[a-fA-F0-9]{40}(\\s*,\\s*0x(?!0{40})[a-fA-F0-9]{40})*\\s*$"
},
"description": "The contract address of the token to receive trading fees in (supports single or multiple comma-separated values). Each token must be set to the value of either the `buyToken` or the `sellToken`. If omitted, the fee token will be determined by 0x with preference to stablecoins and highly liquid assets. You must also specify the `swapFeeRecipient` and `swapFeeBps` to charge integrator fees. When multiple values are provided, must match length of `swapFeeBps`."
},
{
"name": "tradeSurplusRecipient",
"in": "query",
"required": false,
"schema": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$" },
"description": "The address to receive any trade surplus. If specified, this address will receive trade surplus when applicable. Otherwise, the taker will receive the surplus. This feature is only available to selected integrators on a custom pricing plan. In other cases, the surplus will be collected by 0x. For assistance with a custom plan, please contact support."
},
{
"name": "tradeSurplusMaxBps",
"in": "query",
"required": false,
"schema": { "type": "integer", "minimum": 1, "maximum": 10000 },
"description": "The maximum trade surplus (positive slippage) that can be collected in Bps of the buy amount. If not provided, defaults to 10000 (100%). Must be used together with `tradeSurplusRecipient`."
},
{
"name": "gasPrice",
"in": "query",
"required": false,
"schema": { "type": "string" },
"description": "The target gas price (in wei) for the swap transaction. If not provided, the default value is based on the 0x gas price oracle"
},
{
"name": "slippageBps",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 0,
"maximum": 10000,
"default": 100
},
"description": "The maximum acceptable slippage of the `buyToken` in Bps. If this parameter is set to 0, no slippage will be tolerated. If not provided, the default slippage tolerance is 100Bps"
},
{
"name": "excludedSources",
"in": "query",
"required": false,
"schema": { "type": "string" },
"description": "Liquidity sources e.g. Uniswap_V3, SushiSwap, 0x_RFQ to exclude from the provided quote. `See https://api.0x.org/sources?chainId=<chain_id>` with the desired chain's ID for a full list of sources. Separate multiple sources with a comma"
},
{
"name": "sellEntireBalance",
"in": "query",
"required": false,
"schema": {
"type": "string",
"enum": ["true", "false"],
"default": "false"
},
"description": "If set to `true`, the taker's entire `sellToken` balance will be sold during trade execution. The `sellAmount` should be the maximum estimated value, as close as possible to the actual taker's balance to ensure the best routing. Selling more than the `sellAmount` may cause the trade to revert. This feature is designed for cases where the precise sell amount is determined during execution. Learn more [here](https://docs.0x.org/docs/0x-swap-api/additional-topics/sell-entire-balance)."
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"type": "object",
"properties": {
"allowanceTarget": {
"type": "string",
"pattern": "^0x[a-fA-F0-9]{40}$",
"nullable": true,
"description": "The target contract address for which the `taker` needs to have an allowance in order to be able to complete the swap. For swaps with the native asset (ie \"ETH\" or \"BNB\") as the `sellToken`, wrapping the native asset (i.e. \"ETH\" to \"WETH\") or unwrapping, no allowance is needed"
},
"blockNumber": {
"allOf": [
{},