render.gno
1.54 Kb · 45 lines
1package protocol_fee
2
3import (
4 "chain"
5 "strings"
6
7 prbac "gno.land/p/gnoswap/rbac/v1"
8 "gno.land/p/moul/md/v0"
9 "gno.land/p/moul/mdtable/v0"
10 ufmt "gno.land/p/nt/ufmt/v0"
11
12 "gno.land/r/gnoswap/access/v1"
13 "gno.land/r/gnoswap/halt/v1"
14 "gno.land/r/gnoswap/protocol_fee"
15)
16
17func (pf *protocolFeeV1) Render(path string) string {
18 if path != "" {
19 return "404\n"
20 }
21
22 devOpsPct := pf.GetDevOpsPct()
23 govStakerPct := pf.GetGovStakerPct()
24 implementation := protocol_fee.GetImplementationPackagePath()
25 table := mdtable.Table{
26 Headers: []string{"Field", "Value"},
27 Rows: [][]string{
28 {"Realm address", md.InlineCode(chain.PackageAddress("gno.land/r/gnoswap/protocol_fee").String())},
29 {"Active implementation", md.Link(implementation, strings.TrimPrefix(implementation, "gno.land"))},
30 {"DevOps allocation", ufmt.Sprintf("%d bps", devOpsPct)},
31 {"Governance-staker allocation", ufmt.Sprintf("%d bps", govStakerPct)},
32 {"Distribution-rate unit", "1 bps = 0.01%; 10,000 bps = 100%"},
33 {"DevOps recipient", md.InlineCode(access.MustGetAddress(prbac.ROLE_DEVOPS.String()).String())},
34 {"Governance-staker recipient", md.InlineCode(access.MustGetAddress(prbac.ROLE_GOV_STAKER.String()).String())},
35 {"Current accrual epoch", ufmt.Sprintf("%d", pf.GetAccrualEpoch())},
36 {"Protocol-fee halted", ufmt.Sprintf("%t", halt.IsHaltedProtocolFee())},
37 {"Withdrawals halted", ufmt.Sprintf("%t", halt.IsHaltedWithdraw())},
38 },
39 }
40
41 out := md.H1("Gnoswap Protocol Fee") + "\n"
42 out += md.H2("Configuration and distribution") + "\n"
43 out += table.String()
44 return out
45}