Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

render.gno

2.94 Kb · 79 lines
 1package staker
 2
 3import (
 4	"chain"
 5	"math"
 6	"strings"
 7
 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/halt/v1"
13	stakerRoot "gno.land/r/gnoswap/staker"
14)
15
16func (s *stakerV1) Render(path string) string {
17	if path != "" {
18		return "404\n"
19	}
20
21	tierCounts := s.store.GetPoolTierCounts()
22	tierRatio := s.store.GetPoolTierRatio()
23	implementation := stakerRoot.GetImplementationPackagePath()
24
25	out := md.H1("Gnoswap Staker")
26	out += md.Paragraph(
27		"All GNS amounts use the token's six-decimal base units. External reward amounts use\n" +
28			"the reward token's own base units.",
29	)
30
31	out += md.H2("Implementation")
32	implementationTable := mdtable.Table{
33		Headers: []string{"Field", "Value"},
34		Rows: [][]string{
35			{"Realm address", md.InlineCode(chain.PackageAddress("gno.land/r/gnoswap/staker").String())},
36			{"Active implementation", md.Link(implementation, strings.TrimPrefix(implementation, "gno.land"))},
37			{"Staker operations halted", ufmt.Sprintf("%t", halt.IsHaltedStaker())},
38		},
39	}
40	out += implementationTable.String()
41
42	out += md.H2("Accounting and configuration")
43	accountingTable := mdtable.Table{
44		Headers: []string{"Field", "Value"},
45		Rows: [][]string{
46			{"Stored pool records", ufmt.Sprintf("%d", s.store.GetPools().Size())},
47			{"Active staked-position records", ufmt.Sprintf("%d", s.store.GetDeposits().Size())},
48			{"Stored external incentive records", ufmt.Sprintf("%d", s.store.GetExternalIncentives().Size())},
49			{"Unstaked checkpoint records", ufmt.Sprintf("%d", s.store.GetUnstakedPositions().Size())},
50			{"Cumulative GNS emission sent (base units; 6 decimals)", ufmt.Sprintf("%d", s.store.GetTotalEmissionSent())},
51			{"Cached GNS emission rate (base units/second; 6 decimals)", ufmt.Sprintf("%d", s.store.GetPoolTierCurrentEmission())},
52			{"Required GNS deposit (GNS base units; 6 decimals)", ufmt.Sprintf("%d", s.store.GetDepositGnsAmount())},
53			{"Default minimum external incentive reward (reward-token base units)", ufmt.Sprintf("%d", s.store.GetMinimumRewardAmount())},
54			{"Tier pool counts (tier 1 / tier 2 / tier 3)", ufmt.Sprintf("%d / %d / %d", tierCounts[1], tierCounts[2], tierCounts[3])},
55			{"Tier reward split (tier 1 / tier 2 / tier 3; percent)", ufmt.Sprintf("%d%% / %d%% / %d%%", tierRatio.Tier1, tierRatio.Tier2, tierRatio.Tier3)},
56			{"Unstaking fee", ufmt.Sprintf("%d bps (maximum %d bps)", s.store.GetUnstakingFee(), maxUnstakingFee)},
57			{"Allowed external incentive durations", "90 / 180 / 365 days"},
58		},
59	}
60	out += accountingTable.String()
61
62	out += md.H2("Warmup stages")
63	warmupTable := mdtable.Table{
64		Headers: []string{"Reward share", "Duration per stage"},
65	}
66	for _, warmup := range s.store.GetWarmupTemplate() {
67		duration := ufmt.Sprintf("%d seconds", warmup.TimeDuration)
68		if warmup.TimeDuration == math.MaxInt64 {
69			duration = "unbounded"
70		}
71		warmupTable.Append([]string{
72			ufmt.Sprintf("%d%%", warmup.WarmupRatio),
73			duration,
74		})
75	}
76	out += warmupTable.String()
77
78	return out
79}