CultLib/packages/heimdall-stake/examples/first_call.rs
Libby ae33ba4842 heimdall-stake: stake function and splitting-gain report (Rust, zero deps)
weight = 1 + log_b(amount/unit) in integer cents and micro-weights with an integer-only
log, plus floor, per-identity cap and minimum amount per identity; splitting_gain/curve
report what splitting a budget over k identities does. 11 property tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-06 02:30:58 +00:00

11 lines
573 B
Rust

use heimdall_stake::*;
fn main() {
let p = Params::meta_example();
println!("100 EUR -> {}", weight(&p, 100_00).unwrap() as f64 / MICRO as f64);
println!("10,000 EUR -> {}", weight(&p, 10_000_00).unwrap() as f64 / MICRO as f64);
let costly = Params { min_amount_per_identity_cents: 50_00, ..p };
for k in [1, 2, 3, 10] {
let r = splitting_gain(&costly, 100_00, k).unwrap();
println!("100 EUR in {k:>2} identities: {:.2} vs {:.2} (gain {:+.2})", r.split_total as f64 / 1e6, r.one_identity as f64 / 1e6, r.gain as f64 / 1e6);
}
}