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.26 Kb · 60 lines
 1package pool
 2
 3import (
 4	"chain"
 5	"strings"
 6
 7	"gno.land/p/moul/md/v0"
 8	"gno.land/p/moul/mdtable/v0"
 9	ufmt "gno.land/p/nt/ufmt/v0"
10
11	"gno.land/r/gnoswap/halt/v1"
12	poolRoot "gno.land/r/gnoswap/pool"
13)
14
15func (p *poolV1) Render(path string) string {
16	if path != "" {
17		return "404\n"
18	}
19
20	feeAmountTickSpacing := p.store.GetFeeAmountTickSpacing()
21	protocolFee := p.store.GetSlot0FeeProtocol()
22	implementation := poolRoot.GetImplementationPackagePath()
23	implementationTable := mdtable.Table{
24		Headers: []string{"Field", "Value"},
25		Rows: [][]string{
26			{"Realm address", md.InlineCode(chain.PackageAddress("gno.land/r/gnoswap/pool").String())},
27			{"Active implementation", md.Link(implementation, strings.TrimPrefix(implementation, "gno.land"))},
28			{"Pool operations halted", ufmt.Sprintf("%t", halt.IsHaltedPool())},
29			{"Protocol-fee operations halted", ufmt.Sprintf("%t", halt.IsHaltedProtocolFee())},
30			{"Withdrawals halted", ufmt.Sprintf("%t", halt.IsHaltedWithdraw())},
31		},
32	}
33	feeTable := mdtable.Table{
34		Headers: []string{"Field", "Value"},
35		Rows: [][]string{
36			{"Stored pool records", ufmt.Sprintf("%d", p.store.GetPools().Size())},
37			{"Pool creation fee (GNS base units; 6 decimals)", ufmt.Sprintf("%d", p.store.GetPoolCreationFee())},
38			{"Withdrawal fee", ufmt.Sprintf("%d bps", p.store.GetWithdrawalFeeBPS())},
39			{"Fee tiers (pips)", "100 (0.01%) / 500 (0.05%) / 3000 (0.30%) / 10000 (1.00%)"},
40			{"Tick spacing (ticks; same tier order)", ufmt.Sprintf("%d / %d / %d / %d",
41				feeAmountTickSpacing[100],
42				feeAmountTickSpacing[500],
43				feeAmountTickSpacing[3000],
44				feeAmountTickSpacing[10000],
45			)},
46			{"Protocol fee denominators (token0 / token1)", ufmt.Sprintf("%d / %d", protocolFee&15, protocolFee>>4)},
47		},
48	}
49
50	out := md.H1("Gnoswap Pool") + "\n"
51	out += md.Paragraph(`Pool creation fees are charged in GNS. GNS amounts use the token's six-decimal
52base units; pool token amounts use each token's own base units. Withdrawal fees
53apply to collected swap fees and are expressed in basis points. Protocol fee
54denominators apply to swap fees; zero disables the corresponding token's fee.`)
55	out += md.H2("Implementation and operation status") + "\n"
56	out += implementationTable.String() + "\n"
57	out += md.H2("Pools and fee configuration") + "\n"
58	out += feeTable.String()
59	return out
60}