-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathrebalance-api.yaml
More file actions
495 lines (471 loc) · 13.1 KB
/
Copy pathrebalance-api.yaml
File metadata and controls
495 lines (471 loc) · 13.1 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
openapi: 3.0.3
info:
title: OIF Solver Rebalance API
description: |
Admin endpoints for cross-chain token rebalancing.
Read endpoints (GET) require JWT with `admin-all` scope.
Write endpoints (POST, PUT) require EIP-712 signed payloads.
All endpoints are under `/api/v1/admin/rebalance/`.
version: 1.0.0
servers:
- url: http://localhost:3000/api/v1
description: Local development server
paths:
/admin/rebalance/config:
get:
summary: Get rebalance configuration
description: Returns the current rebalance config including all pairs, thresholds, and global settings.
operationId: getRebalanceConfig
tags:
- Rebalance
security:
- bearerAuth: []
responses:
"200":
description: Current rebalance configuration
content:
application/json:
schema:
$ref: "#/components/schemas/RebalanceConfigResponse"
"401":
description: Unauthorized
"500":
description: Internal server error
put:
summary: Update global rebalance settings
description: |
Update enabled state, cooldown, and max pending transfers.
Requires EIP-712 signature. Config is validated before persisting.
operationId: updateRebalanceConfig
tags:
- Rebalance
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SignedUpdateRebalanceConfigRequest"
responses:
"200":
description: Config updated
content:
application/json:
schema:
$ref: "#/components/schemas/AdminActionResponse"
"401":
description: Unauthorized or invalid signature
/admin/rebalance/config/threshold:
put:
summary: Update per-pair thresholds
description: |
Update target balances, deviation band, and max bridge amount for a specific pair.
Requires EIP-712 signature. Config is validated before persisting.
operationId: updateRebalanceThreshold
tags:
- Rebalance
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SignedUpdateRebalanceThresholdRequest"
responses:
"200":
description: Threshold updated
content:
application/json:
schema:
$ref: "#/components/schemas/AdminActionResponse"
"401":
description: Unauthorized or invalid signature
/admin/rebalance/status:
get:
summary: Get rebalance status
description: |
Returns real-time balance vs threshold analysis for each configured pair.
Includes current balances, bounds, direction needed, cooldown state,
active transfer IDs, and monitor freshness timestamps.
operationId: getRebalanceStatus
tags:
- Rebalance
security:
- bearerAuth: []
responses:
"200":
description: Current rebalance status
content:
application/json:
schema:
$ref: "#/components/schemas/RebalanceStatusResponse"
/admin/rebalance/transfers:
get:
summary: Get rebalance transfers
description: Returns active (in-progress) and recent historical transfers.
operationId: getRebalanceTransfers
tags:
- Rebalance
security:
- bearerAuth: []
responses:
"200":
description: Active and historical transfers
content:
application/json:
schema:
$ref: "#/components/schemas/RebalanceTransfersResponse"
/admin/rebalance/trigger:
post:
summary: Manually trigger a rebalance
description: |
Initiate a manual cross-chain rebalance for a specific pair and direction.
Requires EIP-712 signature. The pair must exist in config and the route
must be valid (non-composer routes require a vault address).
operationId: triggerRebalance
tags:
- Rebalance
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SignedTriggerRebalanceRequest"
responses:
"200":
description: Rebalance result
content:
application/json:
schema:
$ref: "#/components/schemas/TriggerRebalanceResponse"
"401":
description: Unauthorized or invalid signature
/admin/rebalance/transfers/{transferId}/resolve:
post:
summary: Resolve a stuck transfer
description: |
Resolve a transfer in NeedsIntervention state. Three resolutions available:
mark_completed, mark_failed, or retry.
Requires EIP-712 signature. The transfer_id in the path must match the signed payload.
operationId: resolveTransfer
tags:
- Rebalance
security:
- bearerAuth: []
parameters:
- name: transferId
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/SignedResolveTransferRequest"
responses:
"200":
description: Resolution result
content:
application/json:
schema:
$ref: "#/components/schemas/ResolveTransferResponse"
"401":
description: Unauthorized or invalid signature
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
RebalanceConfigResponse:
type: object
properties:
enabled:
type: boolean
implementation:
type: string
example: "layerzero"
monitorIntervalSeconds:
type: integer
cooldownSeconds:
type: integer
maxPendingTransfers:
type: integer
pairs:
type: array
items:
$ref: "#/components/schemas/PairConfig"
PairConfig:
type: object
properties:
pairId:
type: string
example: "usdc-eth-arb"
chainA:
$ref: "#/components/schemas/PairSideConfig"
chainB:
$ref: "#/components/schemas/PairSideConfig"
targetBalanceA:
type: string
description: Target balance in base units (decimal string)
example: "10000000"
targetBalanceB:
type: string
example: "10000000"
deviationBandBps:
type: integer
description: Acceptable deviation in basis points (2000 = +/-20%)
example: 2000
maxBridgeAmount:
type: string
example: "5000000"
PairSideConfig:
type: object
properties:
chainId:
type: integer
example: 1
tokenAddress:
type: string
example: "0x<token_address>"
oftAddress:
type: string
example: "0x<oft_address>"
RebalanceStatusResponse:
type: object
properties:
pairs:
type: array
items:
$ref: "#/components/schemas/PairRebalanceStatus"
activeTransfers:
type: integer
lastCheckAt:
type: integer
nullable: true
description: Unix timestamp of last successful monitor tick (null if never ran)
nextCheckAt:
type: integer
nullable: true
description: Unix timestamp of next scheduled tick (null if disabled)
PairRebalanceStatus:
type: object
properties:
pairId:
type: string
chainA:
$ref: "#/components/schemas/PairSideStatus"
chainB:
$ref: "#/components/schemas/PairSideStatus"
deviationBandBps:
type: integer
directionNeeded:
type: string
nullable: true
enum: [a_to_b, b_to_a]
suggestedAmount:
type: string
cooldownActive:
type: boolean
activeTransferId:
type: string
nullable: true
error:
type: string
nullable: true
description: Error message if balance/bridge queries failed for this pair
PairSideStatus:
type: object
properties:
chainId:
type: integer
currentBalance:
type: string
targetBalance:
type: string
lowerBound:
type: string
upperBound:
type: string
withinBand:
type: boolean
RebalanceTransfersResponse:
type: object
properties:
active:
type: array
items:
$ref: "#/components/schemas/BridgeOperation"
history:
type: array
items:
$ref: "#/components/schemas/BridgeOperation"
BridgeOperation:
type: object
properties:
id:
type: string
format: uuid
pairId:
type: string
sourceChainId:
type: integer
destinationChainId:
type: integer
amount:
type: string
status:
type: string
enum: [submitted, relaying, pending_redemption, completed, failed, needs_intervention]
statusReason:
type: string
nullable: true
description: >
Reason for failed or needs_intervention status. Operators should
display this directly. May include insufficient native gas details
such as signer balance, required wei, and shortfall wei.
trigger:
type: string
enum: [auto, manual]
createdAt:
type: integer
description: Unix timestamp
updatedAt:
type: integer
txHash:
type: string
nullable: true
messageGuid:
type: string
nullable: true
redeemTxHash:
type: string
nullable: true
feePaid:
type: string
nullable: true
TriggerRebalanceResponse:
type: object
properties:
success:
type: boolean
message:
type: string
operationId:
type: string
nullable: true
txHash:
type: string
nullable: true
ResolveTransferResponse:
type: object
properties:
success:
type: boolean
message:
type: string
transferId:
type: string
newStatus:
type: string
AdminActionResponse:
type: object
properties:
success:
type: boolean
message:
type: string
admin:
type: string
SignedTriggerRebalanceRequest:
type: object
required: [contents, signature]
properties:
contents:
type: object
properties:
pairId:
type: string
sourceChain:
type: integer
destChain:
type: integer
amount:
type: string
nonce:
type: integer
deadline:
type: integer
signature:
type: string
description: EIP-712 signature hex string
SignedResolveTransferRequest:
type: object
required: [contents, signature]
properties:
contents:
type: object
properties:
transferId:
type: string
resolution:
type: string
enum: [mark_completed, mark_failed, retry]
reason:
type: string
nonce:
type: integer
deadline:
type: integer
signature:
type: string
SignedUpdateRebalanceConfigRequest:
type: object
required: [contents, signature]
properties:
contents:
type: object
properties:
enabled:
type: boolean
cooldownSeconds:
type: integer
maxPendingTransfers:
type: integer
nonce:
type: integer
deadline:
type: integer
signature:
type: string
SignedUpdateRebalanceThresholdRequest:
type: object
required: [contents, signature]
properties:
contents:
type: object
properties:
pairId:
type: string
targetBalanceA:
type: string
targetBalanceB:
type: string
deviationBandBps:
type: integer
maxBridgeAmount:
type: string
nonce:
type: integer
deadline:
type: integer
signature:
type: string