Skip to content

Commit

Permalink
pindexer: insights: correctly handle Arb and Fees (#4909)
Browse files Browse the repository at this point in the history
Previously, these were being added to the supply, instead of subtracted.

This causes the supply in the insights dashboard to be slightly
inflated.

## Testing

To test, run pindexer and compare the following queries:
```
SELECT (
  SELECT SUM(um) as staked_um
    FROM (
      SELECT * FROM supply_validators
    ) validators
    LEFT JOIN LATERAL (
      SELECT um
      FROM supply_total_staked
      WHERE validator_id = id
      ORDER BY height DESC
      LIMIT 1
    ) staked_lateral ON TRUE)
+ um + auction + dex FROM supply_total_unstaked ORDER BY height DESC LIMIT 1;
```
```
SELECT total FROM insights_supply ORDER BY height DESC LIMIT 1;
```

## Checklist before requesting a review

- [x] I have added guiding text to explain how a reviewer should test
these changes.

- [x] If this code contains consensus-breaking changes, I have added the
"consensus-breaking" label. Otherwise, I declare my belief that there
are not consensus-breaking changes, for the following reason:

  > Pindexer only
  • Loading branch information
cronokirby authored Nov 18, 2024
1 parent 63d1d33 commit a22ee1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/bin/pindexer/src/insights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl Component {
self.price_numeraire,
Box::new(move |supply| {
Ok(Supply {
total: supply.total + amount,
total: supply.total - amount,
..supply
})
}),
Expand All @@ -406,7 +406,7 @@ impl Component {
self.price_numeraire,
Box::new(move |supply| {
Ok(Supply {
total: supply.total + profit,
total: supply.total - profit,
..supply
})
}),
Expand Down

0 comments on commit a22ee1c

Please sign in to comment.