package handlers import ( "net/http" bloomtypes "github.com/oy/openyield/x/bloom/types" ) // registerBloom wires the Bloom accrual route (REQ-044). func (s *Server) registerBloom(mux *http.ServeMux) { mux.HandleFunc("GET /bloom/{stashID}", s.handleBloom) } // bloomViewData is the template data for the Bloom accrual view. type bloomViewData struct { StashID string Found bool Record bloomtypes.BloomRecord RatePct float64 // RateBasisPoints as a percentage (450 -> 4.5) TargetRatePct float64 // TargetBloomRateBasisPoints as % MinRatePct float64 MaxRatePct float64 AccrualPeriod int64 MissionLockNote string } // handleBloom renders the Bloom accrual view (REQ-044): per-Stash BloomRecord // (AccruedGrain, RateBasisPoints as %, LastAccrualBlock) + the 4.5% target rate // (read from x/bloom/types.TargetBloomRateBasisPoints — D-073 code-constant // source-of-truth, NOT hardcoded). Bloom is conceptually close to a banned // financial term; labels use "Bloom"/"real production"/"accrual" only. func (s *Server) handleBloom(w http.ResponseWriter, r *http.Request) { stashID := r.PathValue("stashID") rec, ok := s.Store.GetBloomRecord(stashID) if !ok { http.NotFound(w, r) return } s.render(w, "bloom.html", bloomViewData{ StashID: stashID, Found: true, Record: rec, RatePct: float64(rec.RateBasisPoints) / 100, TargetRatePct: float64(bloomtypes.TargetBloomRateBasisPoints) / 100, MinRatePct: float64(bloomtypes.MinBloomRateBasisPoints) / 100, MaxRatePct: float64(bloomtypes.MaxBloomRateBasisPoints) / 100, AccrualPeriod: bloomtypes.AccrualPeriodBlocks, MissionLockNote: bloomtypes.MissionLockBloom, }) }