You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: x/feeds/README.md
+47-1Lines changed: 47 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -314,7 +314,53 @@ Each abci end block call, the operations to update prices.
314
314
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).
315
315
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.
316
316
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.
317
-
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:
318
+
319
+
#### Input
320
+
321
+
A list of PriceFeedInfo objects, each containing:
322
+
-`Price`: The reported price from the feeder
323
+
-`Deviation`: The price deviation
324
+
-`Power`: The feeder's power
325
+
-`Timestamp`: The time at which the price is reported
326
+
327
+
#### Objective
328
+
329
+
- An aggregated price from the list of priceFeedInfo.
330
+
331
+
#### Assumption
332
+
333
+
1. No PriceFeedInfo has a power that exceeds 25% of the total power in the list.
334
+
335
+
#### Procedure
336
+
337
+
1. Order the List:
338
+
339
+
- Sort the list by `Timestamp` in descending order (latest timestamp first).
340
+
- For entries with the same `Timestamp`, sort by `Power` in descending order.
341
+
342
+
2. Apply Power Weights:
343
+
344
+
- Calculate the total power from the list.
345
+
- Assign weights to the powers in segments as follows:
346
+
- The first 1/32 of the total power is multiplied by 6.
347
+
- The next 1/16 of the total power is multiplied by 4.
348
+
- The next 1/8 of the total power is multiplied by 2.
349
+
- The next 1/4 of the total power is multiplied by 1.1.
350
+
- If PriceFeedInfo overlaps between segments, split it into parts corresponding to each segment and assign the respective multiplier.
351
+
- Any power that falls outside these segments will have a multiplier of 1.
352
+
353
+
3. Generate Points:
354
+
355
+
- For each PriceFeedInfo (or its parts if split), generate three points:
356
+
- One at the `Price` with the assigned `Power`.
357
+
- One at `Price + Deviation` with the assigned `Power`.
358
+
- One at `Price - Deviation` with the assigned `Power`.
359
+
360
+
4. Calculating Weight Median
361
+
362
+
- Compute the weighted median of the generated points to determine the final aggregated price.
363
+
- The weighted median price is the price at which the cumulative power (sorted by increasing price) crosses half of the total weighted power.
0 commit comments