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
use brk_error::Result;
use brk_indexer::Indexer;
use vecdb::Exit;
use super::Vecs;
use crate::{blocks, distribution, indexes, price, supply};
impl Vecs {
#[allow(clippy::too_many_arguments)]
pub(crate) fn compute(
&mut self,
indexer: &Indexer,
indexes: &indexes::Vecs,
prices: &price::Vecs,
blocks: &blocks::Vecs,
supply_vecs: &supply::Vecs,
distribution: &distribution::Vecs,
exit: &Exit,
) -> Result<()> {
// Activity computes first (liveliness, vaultedness, etc.)
self.activity.compute(indexer, distribution, exit)?;
self.age_range
.compute(indexer, indexes, distribution, exit)?;
// Phase 2: age-weighted aggregates, adjusted, and value are independent.
let (r1, r2) = rayon::join(
|| {
self.aggregate.compute(
indexer,
distribution,
&self.age_range,
&mut self.supply.active_supply_in_loss_share,
exit,
)
},
|| {
rayon::join(
|| {
self.adjusted
.compute(indexer, supply_vecs, &self.activity, exit)
},
|| {
self.value
.compute(indexer, prices, distribution, &self.activity, exit)
},
)
},
);
r1?;
r2.0?;
r2.1?;
// Cap depends on activity + value
self.cap
.compute(indexer, distribution, &self.activity, &self.value, exit)?;
// Phase 4: pricing and reserve_risk are independent
let (r3, r4) = rayon::join(
|| {
self.prices.compute(
indexer,
prices,
distribution,
&self.activity,
&self.supply,
&self.cap,
exit,
)
},
|| {
self.reserve_risk
.compute(indexer, blocks, prices, &self.value, exit)
},
);
r3?;
r4?;
Ok(())
}
}