Skip to content

Commit 19cbea3

Browse files
committed
fix readme
1 parent 9be8581 commit 19cbea3

File tree

1 file changed

+6
-76
lines changed

1 file changed

+6
-76
lines changed

x/feeds/README.md

Lines changed: 6 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ This module is used in the BandChain.
3939
- [MsgSubmitSignals](#msgsubmitsignals)
4040
- [End-Block](#end-block)
4141
- [Update Prices](#update-prices)
42-
- [Price aggregation logic](#price-aggregation-logic)
4342
- [Update Supported Feeds](#update-supported-feeds)
4443
- [Events](#events)
4544
- [EndBlocker](#endblocker)
@@ -315,27 +314,25 @@ Each abci end block call, the operations to update prices.
315314
At every end block, the Validator Price of all supported feeds will be obtained and checked if it is within the acceptance period (1 interval).
316315
Any validator that does not submit a price within this period is considered to have miss-reported and will be deactivated unless the Supported feeds are in a transition period.
317316
Accepted Validator Prices of the same SignalID will be weighted and median based on the recency of the price and the power of the validator who submitted the price.
318-
The median price is then set as the Price.
317+
The median price is then set as the Price. Here is the price aggregation logic:
319318

320-
#### Price Aggregation logic
321-
322-
**Input**
319+
#### Input
323320

324321
A list of PriceFeedInfo objects, each containing:
325322
- `Price`: The reported price from the feeder
326323
- `Deviation`: The price deviation
327324
- `Power`: The feeder's power
328325
- `Timestamp`: The time at which the price is reported
329326

330-
**Objective**
327+
#### Objective
331328

332-
An aggregated price from the list of priceFeedInfo.
329+
- An aggregated price from the list of priceFeedInfo.
333330

334-
**Assumption**
331+
#### Assumption
335332

336333
1. No PriceFeedInfo has a power that exceeds 25% of the total power in the list.
337334

338-
**Procedure**
335+
#### Procedure
339336

340337
1. Order the List:
341338

@@ -365,73 +362,6 @@ An aggregated price from the list of priceFeedInfo.
365362
- Compute the weighted median of the generated points to determine the final aggregated price.
366363
- The weighted median price is the price at which the cumulative power (sorted by increasing price) crosses half of the total weighted power.
367364

368-
**Example**
369-
370-
Input
371-
372-
```
373-
PriceFeedInfos = [
374-
{Price=100, Deviation=5, Power=16, Timestamp=2024-05-23 12:00:00},
375-
{Price=105, Deviation=3, Power=16, Timestamp=2024-05-23 12:05:00},
376-
{Price=110, Deviation=2, Power=16, Timestamp=2024-05-23 12:10:00},
377-
{Price=120, Deviation=1, Power=16, Timestamp=2024-05-23 12:15:00},
378-
]
379-
```
380-
381-
Procedure
382-
383-
1. Order the List:
384-
385-
```
386-
PriceFeedInfos = [
387-
{Price=120, Deviation=1, Power=16, Timestamp=2024-05-23 12:15:00},
388-
{Price=110, Deviation=2, Power=16, Timestamp=2024-05-23 12:10:00},
389-
{Price=105, Deviation=3, Power=16, Timestamp=2024-05-23 12:05:00},
390-
{Price=100, Deviation=5, Power=16, Timestamp=2024-05-23 12:00:00},
391-
]
392-
```
393-
394-
with a total power of 64
395-
396-
2. Applying weight.
397-
398-
- First 1/32 (of 64 = 2) goes to `{Price=120, Deviation=1, Power=2*6=12}`
399-
- Next 1/16 (of 64 = 4) goest to `{Price=120, Deviation=1,Power=4*4=16}`
400-
- Next 1/8 (of 64 = 8) goes to `{Price=120, Deviation=1, Power=8*2=16}`
401-
- Next 1/4 (of 64 = 16) goes to
402-
```
403-
{Price=120, Deviation=1, Power=2*1.1=2.2}
404-
{Price=110, Deviation=2, Power=14*1.1=15.4}
405-
```
406-
- The Remaining `{Price=110, Deviation=2, Power=2*1=2}`
407-
- The remaining power for all subsequent segments is 1.
408-
409-
3. Generating Points
410-
411-
There will be the following:
412-
413-
```
414-
[{Price=120, Power=12}, {Price=119, Power=12}, {Price=121, Power=12},
415-
{Price=120, Power=16}, {Price=119, Power=16}, {Price=121, Power=16},
416-
{Price=120, Power=16}, {Price=119, Power=16}, {Price=121, Power=16},
417-
{Price=120, Power=2.2}, {Price=119, Power=2.2}, {Price=121, Power=2.2},
418-
{Price=110, Power=15.4}, {Price=108, Power=15.4}, {Price=112, Power=15.4},
419-
...,
420-
{Price=105, Power=16}, {Price=102, Power=16}, {Price=108, Power=16}
421-
{Price=100, Power=16}, {Price=95, Power=16}, {Price=105, Power=16}]
422-
```
423-
424-
4. Calculating Weight Median
425-
426-
Points and Weights are
427-
```
428-
(95,16),(100,16),(102,16),(105,32),(108,33.6),(110,17.6),(112,17.6),
429-
(119,46.4),(120,46.4),(121,46.4)(95,16),(100,16),(102,16),(105,32),
430-
(108,33.6),(110,17.6),(112,17.6),(119,46.4),(120,46.4),(121,46.4)
431-
```
432-
433-
Finding the weighted median at Price=110
434-
435365
### Update supported feeds
436366

437367
At every `BlocksPerFeedsUpdate` block(s), the supported feeds will be re-calculated based on the parameters of the module (e.g. `MinInterval`, `MaxSupportedFeeds`).

0 commit comments

Comments
 (0)