-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-spec.yaml
644 lines (640 loc) · 25.1 KB
/
api-spec.yaml
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
openapi: 3.0.0
info:
title: Beanstalk API
version: 1.0.0
description: REST API for getting information as to the current and historical state of Beanstalk and related protocols.
servers:
- url: 'https://api.bean.money'
tags:
- name: Basin
- name: Silo
- name: Snapshot
- name: Price
paths:
/basin/tickers:
get:
tags:
- Basin
summary: Retrieve tickers and 24h stats
operationId: getTickers
parameters:
- $ref: '#/components/parameters/blockNumber'
- $ref: '#/components/parameters/timestamp'
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: array
items:
type: object
properties:
ticker_id:
type: string
description: Unique identifier for the ticker
example: "0xbea0000029ad1c77d3d5d23ba2d8893db9d1efab_0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
base_currency:
type: string
description: Base currency identifier
example: "0xbea0000029ad1c77d3d5d23ba2d8893db9d1efab"
target_currency:
type: string
description: Target currency identifier
example: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
pool_id:
type: string
description: Pool identifier
example: "0xbea0e11282e2bb5893bece110cf199501e872bad"
last_price:
type: number
format: float
description: Last recorded price
example: 0.000389236771196659
base_volume:
type: number
format: float
description: 24h volume of the base currency
example: 176336.03559
target_volume:
type: number
format: float
description: 24h volume of the target currency
example: 68.71107371221171
liquidity_in_usd:
type: integer
description: Liquidity in USD
example: 27491580
depth2:
type: object
description: Amount of tokens that can be bought or sold to move the price by 2% in either direction
properties:
buy:
type: array
description: +2% depth
items:
type: number
format: float
example: [141161.504702, 38.581398312538454]
sell:
type: array
description: -2% depth
items:
type: number
format: float
example: [145461.021768, 39.75651599669613]
high:
type: number
format: float
description: Highest 24h price
example: 0.000392979136931714
low:
type: number
format: float
description: Lowest 24h price
example: 0.000383640247389837
/basin/historical_trades:
get:
tags:
- Basin
summary: Retrieve historical trades
operationId: getHistoricalTrades
parameters:
- name: ticker_id
in: query
required: true
description: Unique identifier for the ticker
schema:
type: string
example: "0xbea0000029ad1c77d3d5d23ba2d8893db9d1efab_0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
- name: type
in: query
required: false
description: Type of the trade (buy or sell). Defaults to both.
schema:
type: string
example: "buy | sell"
- name: limit
in: query
description: Limit the number of results returned. Defaults to 500.
schema:
type: integer
example: 50
- name: start_time
in: query
description: Start time for filtering trades. Defaults to end_time minus 7 days.
schema:
type: string
format: date-time
example: "2024-05-01T00:00:00.000Z"
- name: end_time
in: query
description: End time for filtering trades. Defaults to today.
schema:
type: string
format: date-time
example: "2024-05-01T00:00:00.000Z"
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
buy:
type: array
items:
$ref: '#/components/schemas/Trade'
sell:
type: array
items:
$ref: '#/components/schemas/Trade'
/silo/yield:
post:
tags:
- Silo
summary: Calculates and retrieves silo yields at a single season. Optional inputs allows refined control over the calculation.
operationId: siloYield
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
season:
type: integer
description: Season number. Defaults to the current season.
tokens:
type: array
items:
type: string
description: An array of EVM token addresses. Defaults to all whitelisted tokens
emaWindows:
type: array
items:
type: integer
default: [24, 168, 720]
description: An array of EMA window sizes. Each is the number of seasons to use in the lookback. Defaults to 24h, 7d, and 30d windows.
options:
type: object
properties:
initType:
type: string
enum: [NEW, AVERAGE]
description: Indicates whether to calculate from the basis of a new silo deposit, or the average silo deposit.
default: "AVERAGE"
initUserValues:
type: array
items:
type: object
properties:
stalkPerBdv:
type: number
description: "(user deposited stalk) / (user deposited bdv + user germinating bdv)"
germinating:
type: array
items:
type: number
description: "[Even, Odd] germinating stalk ratio of this deposit type. Each entry should be computed as: (user germinating stalk) / (user deposited bdv + user germinating bdv)"
default: [0, 0]
description: Each entry in the array corresponds to the requested token at the same index.
description: Initial values of a deposit starting state. Takes precedence over initType
ema:
type: array
items:
$ref: '#/components/schemas/EmaInfo'
description: Override values to use for the ema
catchUpRate:
type: number
description: Target number of hours for a deposit's grown stalk to catch up (for gauge only)
default: 4320
duration:
type: number
description: The duration for which to calculate the apy, in seasons
default: 8760
skipValidation:
type: boolean
description: Indicates whether any parameter validation should be skipped
default: false
description: Options that control the calculation itself
responses:
200:
description: Successful response
content:
application/json:
schema:
type: object
properties:
season:
type: integer
description: Season number
yields:
type: object
additionalProperties:
type: object
description: Yields data for a window.
additionalProperties:
type: object
properties:
bean:
type: number
format: float
description: The annualized growth in bean count
stalk:
type: number
format: float
description: The annualized growth in stalk count
ownership:
type: number
format: float
description: The annualized growth in silo ownership percentage
description: Yields for each whitelisted token
description: Yields for each available ema window.
example:
"720":
"0xbea0005b8599265d41256905a9b3073d397812e4":
bean: 0
stalk: 1.749468280393595
ownership: 1.415032727943025
initType:
type: string
enum: [NEW, AVERAGE, CUSTOM]
description: The initType used in the calculation. Custom if initUserValues was used instead.
ema:
type: object
additionalProperties:
$ref: '#/components/schemas/EmaInfo'
description: EMA calculation details for each requested window.
example:
"720":
effectiveWindow: 350
beansPerSeason: "213456789"
required:
- season
- yields
- initType
- ema
/silo/yield-history:
post:
tags:
- Silo
summary: Retrieves silo yields already stored in the database.
operationId: yieldHistory
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
token:
type: string
format: address
description: The whitelisted token address.
example: "0xabcd"
emaWindow:
type: integer
enum: [24, 168, 720]
description: The EMA window size. Corresponds to a 24h, 7d, and 30d vAPY.
initType:
type: string
enum: [NEW, AVERAGE]
description: Whether to retrieve yields calculated based on a new silo deposit or the average silo deposit.
fromSeason:
type: integer
description: The earliest season to appear in the result. Guaranteed to be included if a result for it exists (regardless of interval)
example: 20000
toSeason:
type: integer
description: The latest season to appear in the result. Guaranteed to be included if a result for it exists (regardless of interval)
example: 25000
interval:
type: integer
description: Specifies a skip interval between seasons in the result. i.e. interval of 10 will return an entry for every 10 seasons in the response.
example: 0
required:
- token
- emaWindow
- initType
- fromSeason
- toSeason
responses:
200:
description: Successful response
content:
application/json:
schema:
type: object
additionalProperties:
type: object
properties:
bean:
type: number
format: float
description: The annualized growth in bean count
stalk:
type: number
format: float
description: The annualized growth in stalk count
ownership:
type: number
format: float
description: The annualized growth in silo ownership percentage
description: Yield breakdown for the season.
description: Mapping of season numbers to their yield data.
example:
"10000":
bean: 0
stalk: 0.8661584416280589
ownership: 0.6056560518900254
"10001":
bean: 0
stalk: 0.8642958966146155
ownership: 0.6044476224863509
"10002":
bean: 0
stalk: 0.8642958966146155
ownership: 0.6044476224863509
/silo/deposits:
post:
tags:
- Silo
summary: Retrieves detailed information about Deposits in the silo.
operationId: siloDeposits
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
account:
type: string
format: address
description: EVM address of a depositor. Default is all accounts
example: "0xabcd"
token:
type: string
format: address
description: EVM address of a whitelisted token. Default is all tokens
example: "0xef01"
sort:
type: object
properties:
type:
type: string
enum: [absolute, relative]
description: Absolute sorting will return the largest absolue differences, while relative will return largest relative differences. Absolute sorting will thus prefer larger farmers.
field:
type: string
enum: [bdv, stalk, seeds]
description: The field to sort by with the given strategy
description: Sorts the result based on the difference in actual values vs the would-be values upon a lambda convert.
lambdaBdvChange:
type: string
enum: [increase, decrease]
description: Specifies whether to filter for would-be increasing or decreasing bdv upon a lambda convert. Default is to return both.
limit:
type: integer
description: The maximum number of results to return.
default: 100
skip:
type: integer
description: The number of results to skip (for pagination).
default: 0
responses:
200:
description: Successful response
content:
application/json:
schema:
type: object
properties:
lastUpdated:
type: integer
description: The last block number in which the list of deposits was updated and the lambda stats checked for large fluctuations.
deposits:
type: array
items:
type: object
properties:
chain:
type: string
description: The blockchain network (e.g., 'arb' for Arbitrum).
account:
type: string
format: address
description: The depositor's EVM address.
token:
type: string
format: address
description: The deposited token's EVM address.
stem:
type: string
description: The stem associated with the deposit.
mowStem:
type: string
description: The stem in which this deposit was last mown.
depositedAmount:
type: string
description: The amount of tokens deposited.
depositedBdv:
type: string
description: The current recorded bdv of the deposited amount.
baseStalk:
type: string
description: The base stalk portion of the deposit's stalk.
grownStalk:
type: string
description: The grown stalk portion of the deposit's stalk
mowableStalk:
type: string
description: The amount of stalk that would be accrue to the deposit upon a mow.
currentStalk:
type: string
description: The current recorded stalk for this deposit.
currentSeeds:
type: string
description: The current recorded seeds for this deposit.
bdvOnLambda:
type: string
description: The bdv of this deposit if a lambda convert were to occur now.
stalkOnLambda:
type: string
description: The amount of stalk of this deposit if a lambda convert were to occur now. This includes the affect of a mow.
seedsOnLambda:
type: string
description: The amount of seeds of this deposit if a lambda convert were to occur now.
example:
lastUpdated: 267360284
deposits:
- chain: "arb"
account: "0x3d138e67dfac9a7af69d2694470b0b6d37721b06"
token: "0xbea0005b8599265d41256905a9b3073d397812e4"
stem: "14945036521"
mowStem: "39978964924"
depositedAmount: "5489953983"
depositedBdv: "19685712512"
baseStalk: "196857125120000000000"
grownStalk: "492810717587449278336"
mowableStalk: "42783894565816732800"
currentStalk: "689667842707449278336"
currentSeeds: "123527216069999616"
bdvOnLambda: "5489953983"
stalkOnLambda: "204266232677503621224"
seedsOnLambda: "34449285564797544"
/price:
get:
tags:
- Price
summary: Retrieve the current Bean price, liquidity, and deltaB
operationId: price
parameters:
- $ref: '#/components/parameters/blockNumber'
- $ref: '#/components/parameters/timestamp'
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
block:
type: integer
description: On-chain Ethereum block number of the requested price data
example: 19804698
timestamp:
type: integer
description: Unix timestamp of the block, in seconds
example: 1714921799
token:
type: string
description: Ethereum address of the token
example: "0xbea0000029ad1c77d3d5d23ba2d8893db9d1efab"
usdPrice:
type: number
format: double
description: Current price of the token in USD
example: 0.9994
liquidityUSD:
type: number
format: double
description: Total liquidity in USD
example: 28235107.24
deltaB:
type: integer
description: Beanstalk Protocol deltaB
example: -4331
/snapshot/voting-power:
get:
tags:
- Snapshot
summary: Retrieve the current Bean price, liquidity, and deltaB
operationId: voting-power
parameters:
- name: addresses
in: query
required: true
description: Comma-separated EVM addresses
schema:
type: string
example: 0xabcd,0xef01
- name: snapshot
in: query
required: true
description: EVM block number used to compute voting power on the given addresses
schema:
type: integer
example: 267347585
responses:
200:
description: Successful response
content:
application/json:
schema:
type: object
properties:
score:
type: array
items:
type: object
properties:
address:
type: string
format: address
description: EVM address of the voter
example: "0xabcd"
score:
type: number
format: float
description: Voting power associated with this EVM address, including any delegated votes.
example: 1500.60
stalkholders:
type: object
additionalProperties:
type: number
format: float
example: 500.20
description: Mapping of EVM addresses and their voting power contributing to the primary address' vote.
example:
"0xabcd": 266.32
"0xcdef": 1234.28
components:
parameters:
blockNumber:
name: blockNumber
in: query
required: false
description: Ethereum block number. Defaults to the latest block.
schema:
type: integer
example: 19000000
timestamp:
name: timestamp
in: query
required: false
description: Unix timestamp, in seconds or milliseconds. Default behavior is to use blockNumber instead.
schema:
type: integer
example: 1715204400
schemas:
Trade:
type: object
properties:
trade_id:
type: integer
format: int64
example: 198245000283
price:
type: number
format: float
example: 0.000318525481173441
base_volume:
type: number
format: float
example: 122.35605
target_volume:
type: number
format: float
example: 0.03897351970073168
trade_timestamp:
type: integer
format: int64
description: Unix timestamp of the trade, in milliseconds
example: 1715161115000
type:
type: string
example: "buy | sell"
EmaInfo:
type: object
properties:
effectiveWindow:
type: integer
description: The effective window used for the EMA. This is relevant if fewer datapoints were available than requested.
beansPerSeason:
type: string
description: The number of seasonal reward beans as a BigInt string
example: "213456789"