-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathopenapi.yml
736 lines (717 loc) · 23 KB
/
openapi.yml
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
openapi: 3.0.3
info:
title: Solver API
description: |
The API implemented by Solvers to be queried by Autopilot.
version: 0.0.1
paths:
/quote:
get:
description: Get price estimation quote.
parameters:
- in: query
name: sellToken
description: The token to sell.
schema:
$ref: "#/components/schemas/Address"
required: true
- in: query
name: buyToken
description: The token to buy.
schema:
$ref: "#/components/schemas/Address"
required: true
- in: query
name: kind
description: >-
- `buy`: amount is in buy_token, out_amount is in sell_token -
`sell`: amount is in sell_token, out_amount is in buy_token
schema:
type: string
enum:
- buy
- sell
required: true
- in: query
name: amount
description: The amount to buy or sell.
schema:
$ref: "#/components/schemas/TokenAmount"
required: true
- in: query
name: deadline
description: The time until which the caller expects a response.
schema:
$ref: "#/components/schemas/DateTime"
required: true
responses:
"200":
description: Quote successfully created.
content:
application/json:
schema:
$ref: "#/components/schemas/QuoteResponseKind"
"400":
$ref: "#/components/responses/BadRequest"
"429":
description: The solver cannot keep up. It is too busy to handle more requests.
"500":
$ref: "#/components/responses/InternalServerError"
/solve:
post:
description: |-
Solve the passed in auction.
The response contains the objective value of the solution the Solver is
able to find but not the calldata. This facilitates solvers that work
with an RFQ system. When Autopilot decides the winner of the of the
auction it prompts the corresponding solver to execute its solution
through the execute endpoint.
The Solver should respond quickly enough so that the caller of the
endpoint receives the response within the deadline indicated in the
request. This includes taking into account network delay.
Autopilot will call this endpoint at most once for the same auction id
and the following call will have a larger id.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SolveRequest"
responses:
"200":
description: Auction successfully solved.
content:
application/json:
schema:
$ref: "#/components/schemas/SolveResponse"
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/InternalServerError"
/reveal:
post:
description: >
Reveal the calldata of the previously solved auction.
This may be used by the autopilot for the shadow competition to verify
the solution before requesting its execution it on chain.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/RevealRequest"
responses:
"200":
description: Execution accepted.
content:
application/json:
schema:
$ref: "#/components/schemas/RevealResponse"
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/InternalServerError"
/settle:
post:
description: |-
Execute the previously solved auction on chain.
The auction that should be executed is identified through its id and was
recently returned by this Solver's solve endpoint.
By accepting the execute request the Solver promises to execute the
solution on chain immediately.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SettleRequest"
responses:
"200":
description: Execution accepted.
"400":
$ref: "#/components/responses/BadRequest"
"500":
$ref: "#/components/responses/InternalServerError"
components:
schemas:
Address:
description: 20 byte Ethereum address encoded as a hex with `0x` prefix.
type: string
example: "0x6810e776880c02933d47db1b9fc05908e5386b96"
TokenAmount:
description: Amount of an ERC20 token. 256 bit unsigned integer in decimal notation.
type: string
example: "1234567890"
Interaction:
type: object
properties:
target:
$ref: "#/components/schemas/Address"
value:
$ref: "#/components/schemas/TokenAmount"
callData:
description: Hex encoded bytes with `0x` prefix.
type: string
Token:
description: Token information.
type: object
properties:
address:
$ref: "#/components/schemas/Address"
price:
nullable: true
allOf:
- $ref: "#/components/schemas/TokenAmount"
description: |-
The reference price denominated in native token (i.e. 1e18
represents a token that
trades one to one with the native token). These prices are used for
solution competition
for computing surplus and converting fees to native token.
trusted:
description: |-
Whether the protocol trusts the token to be used for internalizing
trades.
Solvers are allowed to internalize trades, ie. omit the interaction
that executes the swap from token A to token B and instead use the
settlement contract balances, aka buffers, to fulfil the interaction
as long as the token the contract receives (A in the example) is
trusted.
type: boolean
Order:
description: |
Order information like what is returned by the Orderbook apis.
type: object
properties:
uid:
$ref: "#/components/schemas/OrderUID"
sellToken:
allOf:
- description: Token being sold
- $ref: "#/components/schemas/Address"
buyToken:
allOf:
- description: Token being bought
- $ref: "#/components/schemas/Address"
sellAmount:
allOf:
- description: Amount to be sold
- $ref: "#/components/schemas/TokenAmount"
buyAmount:
allOf:
- description: Amount to be bought
- $ref: "#/components/schemas/TokenAmount"
created:
description: Creation time of the order. Denominated in epoch seconds.
type: string
example: "123456"
validTo:
description: The time until which the order is valid.
type: integer
kind:
type: string
enum:
- buy
- sell
receiver:
allOf:
- description: The address that should receive the bought tokens.
- $ref: "#/components/schemas/Address"
owner:
allOf:
- description: The address that created the order.
- $ref: "#/components/schemas/Address"
partiallyFillable:
description: |-
Whether the order can be partially filled.
If this is false then the solver must fill the entire order or not
at all.
type: boolean
executed:
allOf:
- description: The amount that has already been filled.
- $ref: "#/components/schemas/TokenAmount"
preInteractions:
description: Interactions that must be executed before the order can be filled.
type: array
items:
$ref: "#/components/schemas/Interaction"
postInteractions:
description: Interactions that must be executed after the order has been filled.
type: array
items:
$ref: "#/components/schemas/Interaction"
sellTokenBalance:
type: string
enum:
- erc20
- internal
- external
buyTokenBalance:
type: string
enum:
- erc20
- internal
class:
type: string
enum:
- market
- limit
appData:
description: 32 bytes encoded as hex with `0x` prefix.
type: string
signingScheme:
type: string
enum:
- eip712
- ethsign
- presign
- eip1271
signature:
description: Hex encoded bytes with `0x` prefix.
type: string
protocolFees:
description: |-
Any protocol fee policies that apply to the order.
The solver should make sure the fee policy is applied when computing
their solution.
type: array
items:
$ref: "#/components/schemas/FeePolicy"
quote:
allOf:
- description: A winning quote.
- $ref: "#/components/schemas/Quote"
required:
- uid
- sellToken
- buyToken
- sellAmount
- buyAmount
- created
- validTo
- kind
- receiver
- owner
- partiallyFillable
- executed
- preInteractions
- postInteractions
- sellTokenBalance
- buyTokenBalance
- class
- appData
- signature
- protocolFees
BigUint:
description: A big unsigned integer encoded in decimal.
type: string
example: "1234567890"
OrderUID:
description: |-
Unique identifier for the order: 56 bytes encoded as hex with `0x`
prefix.
Bytes 0 to 32 are the order digest, bytes 30 to 52 the owner address and
bytes 52..56 valid to,
type: string
example: >-
0x30cff40d9f60caa68a37f0ee73253ad6ad72b45580c945fe3ab67596476937197854163b1b0d24e77dca702b97b5cc33e0f83dcb626122a6
QuoteResponseKind:
oneOf:
- $ref: "#/components/schemas/LegacyQuoteResponse"
- $ref: "#/components/schemas/QuoteResponse"
- $ref: "#/components/schemas/Error"
LegacyQuoteResponse:
description: |-
Successful Quote.
The Solver knows how to fill the request with these parameters.
If the request was of type `buy` then the response's buy amount has the
same value as the request's amount and the sell amount was filled in by
the server. Vice versa for type `sell`.
type: object
properties:
amount:
$ref: "#/components/schemas/TokenAmount"
interactions:
type: array
items:
$ref: "#/components/schemas/Interaction"
solver:
allOf:
- description: The address of the solver that quoted this order.
- $ref: "#/components/schemas/Address"
gas:
type: integer
description: How many units of gas this trade is estimated to cost.
txOrigin:
allOf:
- $ref: "#/components/schemas/Address"
description: Which `tx.origin` is required to make a quote simulation pass.
required:
- amount
- interactions
- solver
QuoteResponse:
description: |-
Successful Quote with JIT orders support.
The Solver knows how to fill the request with these parameters.
type: object
properties:
clearingPrices:
description: |
Mapping of hex token address to the uniform clearing price.
type: object
additionalProperties:
$ref: "#/components/schemas/BigUint"
preInteractions:
type: array
items:
$ref: "#/components/schemas/Interaction"
interactions:
type: array
items:
$ref: "#/components/schemas/Interaction"
solver:
allOf:
- $ref: "#/components/schemas/Address"
description: The address of the solver that quoted this order.
gas:
type: integer
description: How many units of gas this trade is estimated to cost.
txOrigin:
allOf:
- $ref: "#/components/schemas/Address"
description: Which `tx.origin` is required to make a quote simulation pass.
jitOrders:
type: array
items:
$ref: "#/components/schemas/JitOrder"
required:
- clearingPrices
- solver
DateTime:
description: An ISO 8601 UTC date time string.
type: string
example: "2020-12-03T18:35:18.814523Z"
Calldata:
description: hex encoded calldata with `0x` prefix.
type: object
properties:
internalized:
description: |-
The calldata without any internalized interactions encoded.
This is the calldata that can be found on chain.
type: string
example: "0x1234567890"
uninternalized:
description: |-
The calldata with all internalized interactions encoded.
This is the calldata that should be used for simulation/verification
purposes.
type: string
example: "0x1234567890"
SolveRequest:
description: Request to the solve endpoint.
type: object
properties:
id:
type: integer
description: |
The unique identifier of the auction.
orders:
type: array
items:
$ref: "#/components/schemas/Order"
description: |
The solvable orders included in the auction.
tokens:
type: array
items:
$ref: "#/components/schemas/Token"
description: |
Information about tokens used in the auction.
deadline:
$ref: "#/components/schemas/DateTime"
surplusCapturingJitOrderOwners:
type: array
items:
$ref: "#/components/schemas/Address"
description: >
List of addresses on whose surplus will count towards the objective
value of their solution (unlike other orders that were created by
the solver).
SolveResponse:
description: |
Response of the solve endpoint.
type: object
properties:
solutions:
type: array
items:
type: object
properties:
solutionId:
description: |-
The unique identifier of the solution.
This id is used to identify the solution when executing it.
type: integer
example: 1
score:
description: |
The objective value of the solution.
type: string
example: "100"
submissionAddress:
allOf:
- description: The address that will be used to submit the solution.
- $ref: "#/components/schemas/Address"
orders:
description: >
Mapping of order uid to net executed amount (including all
fees).
additionalProperties:
type: object
properties:
side:
type: string
enum:
- buy
- sell
sellToken:
allOf:
- description: Token being sold
- $ref: "#/components/schemas/Address"
buyToken:
allOf:
- description: Token being bought
- $ref: "#/components/schemas/Address"
limitSell:
type: string
description: Maximum amount to be sold.
limitBuy:
type: string
description: Minimum amount to be bought.
executedSell:
type: string
description: >-
The effective amount that left the user's wallet
including all fees.
executedBuy:
type: string
description: The effective amount the user received after all fees.
clearingPrices:
description: >
Mapping of hex token address to price.
The prices of tokens for settled user orders as passed to the
settlement contract.
type: object
additionalProperties:
$ref: "#/components/schemas/BigUint"
gas:
type: integer
SettleRequest:
description: Request to the `/settle` endpoint.
type: object
properties:
solutionId:
description: Id of the solution that should be executed.
type: integer
example: 123
submissionDeadlineLatestBlock:
description: The last block number in which the solution TX can be included.
type: integer
example: 12345
auctionId:
description: Auction ID in which the specified solution ID is competing.
type: integer
example: 123
RevealRequest:
description: Request to the `/reveal` endpoint.
type: object
properties:
solutionId:
description: Id of the solution that should be executed.
type: integer
example: 123
auctionId:
description: Auction ID in which the specified solution ID is competing.
type: integer
example: 123
RevealResponse:
description: Response of the reveal endpoint.
type: object
properties:
calldata:
$ref: "#/components/schemas/Calldata"
FeePolicy:
description: >
A fee policy that applies to an order.
The solver should make sure the fee policy is applied when computing
their solution.
type: object
oneOf:
- $ref: "#/components/schemas/SurplusFee"
- $ref: "#/components/schemas/PriceImprovement"
- $ref: "#/components/schemas/VolumeFee"
SurplusFee:
description: >
If the order receives more than limit price, pay the protocol a factor
of the difference.
type: object
properties:
kind:
type: string
enum:
- surplus
maxVolumeFactor:
description: Never charge more than that percentage of the order volume.
type: number
example: 0.1
factor:
description: >-
The factor of the user surplus that the protocol will request from
the solver after settling the order
type: number
example: 0.5
PriceImprovement:
description: >
A cut from the price improvement over the best quote is taken as a
protocol fee.
type: object
properties:
kind:
type: string
enum:
- priceImprovement
maxVolumeFactor:
description: Never charge more than that percentage of the order volume.
type: number
example: 0.01
factor:
description: >-
The factor of the user surplus that the protocol will request from
the solver after settling the order
type: number
example: 0.5
quote:
$ref: "#/components/schemas/Quote"
VolumeFee:
type: object
properties:
kind:
type: string
enum:
- volume
factor:
description: >-
The fraction of the order's volume that the protocol will request
from the solver after settling the order.
type: number
example: 0.5
Quote:
type: object
properties:
sellAmount:
$ref: "#/components/schemas/TokenAmount"
buyAmount:
$ref: "#/components/schemas/TokenAmount"
fee:
$ref: "#/components/schemas/TokenAmount"
solver:
$ref: "#/components/schemas/Address"
JitOrder:
type: object
properties:
sellToken:
$ref: "#/components/schemas/Address"
buyToken:
$ref: "#/components/schemas/Address"
sellAmount:
$ref: "#/components/schemas/TokenAmount"
buyAmount:
$ref: "#/components/schemas/TokenAmount"
executedAmount:
$ref: "#/components/schemas/TokenAmount"
receiver:
$ref: "#/components/schemas/Address"
validTo:
type: integer
side:
type: string
enum:
- buy
- sell
partiallyFillable:
type: boolean
sellTokenSource:
type: string
enum:
- erc20
- internal
- external
buyTokenSource:
type: string
enum:
- erc20
- internal
appData:
type: string
signature:
description: >-
Hex encoded bytes with `0x` prefix. The content depends on the
`signingScheme`.
For `presign`, this should contain the address of the owner.
For `eip1271`, the signature should consist of
`<owner_address><signature_bytes>`.
type: string
signingScheme:
type: string
enum:
- eip712
- ethsign
- presign
- eip1271
required:
- sellToken
- buyToken
- sellAmount
- buyAmount
- executedAmount
- receiver
- validTo
- side
- partiallyFillable
- sellTokenSource
- buyTokenSource
- appData
- signature
- signingScheme
Error:
description: Response on API errors.
type: object
properties:
kind:
description: The kind of error.
type: string
description:
description: Text describing the error.
type: string
responses:
"200":
description: The request was successful.
BadRequest:
description: |-
There is something wrong with the request.
Body potentially contains extra information.
content:
text/plain:
schema:
type: string
InternalServerError:
description: |-
Something went wrong when handling the request.
Body potentially contains extra information.
content:
text/plain:
schema:
type: string