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
@@ -316,6 +317,121 @@ Any validator that does not submit a price within this period is considered to h
316
317
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
318
The median price is then set as the Price.
318
319
320
+
#### Price Aggregation logic
321
+
322
+
**Input**
323
+
324
+
A list of PriceFeedInfo objects, each containing:
325
+
-`Price`: The reported price from the feeder
326
+
-`Deviation`: The price deviation
327
+
-`Power`: The feeder's power
328
+
-`Timestamp`: The time at which the price is reported
329
+
330
+
**Objective**
331
+
332
+
An aggregated price from the list of priceFeedInfo.
333
+
334
+
**Assumption**
335
+
336
+
1. No PriceFeedInfo has a power that exceeds 25% of the total power in the list.
337
+
338
+
**Procedure**
339
+
340
+
1. Order the List:
341
+
342
+
- Sort the list by `Timestamp` in descending order (latest timestamp first).
343
+
- For entries with the same `Timestamp`, sort by `Power` in descending order.
344
+
345
+
2. Apply Power Weights:
346
+
347
+
- Calculate the total power from the list.
348
+
- Assign weights to the powers in segments as follows:
349
+
- The first 1/32 of the total power is multiplied by 6.
350
+
- The next 1/16 of the total power is multiplied by 4.
351
+
- The next 1/8 of the total power is multiplied by 2.
352
+
- The next 1/4 of the total power is multiplied by 1.1.
353
+
- If PriceFeedInfo overlaps between segments, split it into parts corresponding to each segment and assign the respective multiplier.
354
+
- Any power that falls outside these segments will have a multiplier of 1.
355
+
356
+
3. Generate Points:
357
+
358
+
- For each PriceFeedInfo (or its parts if split), generate three points:
359
+
- One at the `Price` with the assigned `Power`.
360
+
- One at `Price + Deviation` with the assigned `Power`.
361
+
- One at `Price - Deviation` with the assigned `Power`.
362
+
363
+
4. Calculating Weight Median
364
+
365
+
- Compute the weighted median of the generated points to determine the final aggregated price.
366
+
- The weighted median price is the price at which the cumulative power (sorted by increasing price) crosses half of the total weighted power.
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