pub struct Distributor<'a> { /* private fields */ }Expand description
The Distributor endpoints, reached with
FyuzClient::distributor.
The Distributor pays back a share of platform fees every round: most of the pot pro-rata by points, the remainder to one VRF-picked winner. Everything here is a public read of that ledger.
Every *_wei field is an exact decimal string. Lifetime totals run past
2^53, so parsing them into f64 corrupts them silently. See the
models docs.
let client = fyuz::FyuzClient::new()?;
let stats = client.distributor().get_stats().await?;
println!("{} wei paid out over {} rounds", stats.total_paid_wei, stats.rounds_settled);Implementations§
Source§impl<'a> Distributor<'a>
impl<'a> Distributor<'a>
Sourcepub async fn get_stats(&self) -> Result<PayoutStats>
pub async fn get_stats(&self) -> Result<PayoutStats>
GET /distributor/stats — lifetime payback totals.
let client = fyuz::FyuzClient::new()?;
let stats = client.distributor().get_stats().await?;
// Decimal string, not a number: print it, do not parse it.
println!("largest single payout: {} wei", stats.largest_payout_wei);Sourcepub async fn get_pot(&self) -> Result<Pot>
pub async fn get_pot(&self) -> Result<Pot>
GET /distributor/pot — the live undistributed pot and the parameters
needed to price a point.
Pot::pot_bnb and Pot::total_points are None when the value could
not be read. That is unknown, not zero — hide the figure rather than
showing 0.
let client = fyuz::FyuzClient::new()?;
let pot = client.distributor().get_pot().await?;
if let (Some(bnb), Some(points)) = (pot.pot_bnb, pot.total_points) {
println!("{:.6} BNB per point", bnb * pot.distribute_bps / 10_000.0 / points);
}GET /distributor/shares — the share allocation for the current window,
plus the exact calldata the round-runner posts on-chain.
use fyuz::SharesParams;
let client = fyuz::FyuzClient::new()?;
let shares = client.distributor().get_shares(&SharesParams::new().limit(50)).await?;
println!("{} holders, calldata {} bytes", shares.holders.len(), shares.packed.len() / 2 - 1);Sourcepub async fn list_rounds(
&self,
params: &RoundsParams,
) -> Result<Vec<RoundReceipt>>
pub async fn list_rounds( &self, params: &RoundsParams, ) -> Result<Vec<RoundReceipt>>
GET /distributor/rounds — the public payout ledger, newest first.
use fyuz::RoundsParams;
let client = fyuz::FyuzClient::new()?;
for round in client.distributor().list_rounds(&RoundsParams::new().limit(5)).await? {
// `None` means "not indexed yet", never zero.
match round.distributed_wei.as_deref() {
Some(wei) => println!("round {}: {wei} wei", round.round_id),
None => println!("round {}: pending settlement", round.round_id),
}
}Sourcepub async fn get_round(&self, id: i64) -> Result<RoundDetail>
pub async fn get_round(&self, id: i64) -> Result<RoundDetail>
GET /distributor/rounds/{id} — one round’s receipt and its recipient
list.
The receipt fields are flattened into the top level of the JSON object;
in Rust they live under RoundDetail::round.
Answers 404 for an unknown round.
let client = fyuz::FyuzClient::new()?;
let detail = client.distributor().get_round(7).await?;
println!("round {} paid {} wallets", detail.round.round_id, detail.payouts.len());Sourcepub async fn get_payouts(&self, address: &str) -> Result<AddressPayouts>
pub async fn get_payouts(&self, address: &str) -> Result<AddressPayouts>
GET /distributor/payouts/{address} — every payout one wallet has
received.
let client = fyuz::FyuzClient::new()?;
let paid = client
.distributor()
.get_payouts("0x1111111111111111111111111111111111111111")
.await?;
println!("{} wei across {} rounds", paid.total_wei, paid.rounds_paid);Sourcepub async fn get_claimable(&self, address: &str) -> Result<Claimable>
pub async fn get_claimable(&self, address: &str) -> Result<Claimable>
GET /distributor/claimable/{address} — wei owed from payout pushes the
contract could not complete.
Claimable::claimable_wei is None when the RPC is unreachable or no
Distributor is configured. Hide the banner in that case rather than
telling someone they are owed nothing.
let client = fyuz::FyuzClient::new()?;
let c = client
.distributor()
.get_claimable("0x1111111111111111111111111111111111111111")
.await?;
match c.claimable_wei.as_deref() {
Some("0") => println!("nothing pending"),
Some(wei) => println!("{wei} wei claimable from {:?}", c.distributor_address),
None => println!("unknown — do not render a zero here"),
}