package router import ( "chain" "strings" "gno.land/p/moul/md/v0" "gno.land/p/moul/mdtable/v0" ufmt "gno.land/p/nt/ufmt/v0" "gno.land/r/gnoswap/halt/v1" "gno.land/r/gnoswap/router" ) const maxSwapFeeBPS uint64 = 1000 func (r *routerV1) Render(path string) string { var action string switch path { case "": action = md.H3("Exact-input single-route swap") + "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n" case "swap/exact-in": action = md.H3("Exact-input multi-route swap") + "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n" case "swap/exact-out": action = md.H3("Exact-output multi-route swap") + "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n" case "swap/exact-out-single": action = md.H3("Exact-output single-route swap") + "\n" + "\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "\n" default: return "404\n" } swapFee := r.GetSwapFee() implementation := router.GetImplementationPackagePath() statusTable := mdtable.Table{ Headers: []string{"Field", "Value"}, Rows: [][]string{ {"Router package", md.Link("gno.land/r/gnoswap/router", "/r/gnoswap/router")}, {"Realm address", md.InlineCode(chain.PackageAddress("gno.land/r/gnoswap/router").String())}, {"Active implementation", md.Link(implementation, strings.TrimPrefix(implementation, "gno.land"))}, {"Router halted", ufmt.Sprintf("%t", halt.IsHaltedRouter())}, }, } feeTable := mdtable.Table{ Headers: []string{"Field", "Value"}, Rows: [][]string{ {"Swap fee", ufmt.Sprintf("%d bps", swapFee)}, {"Maximum swap fee", ufmt.Sprintf("%d bps (10%%)", maxSwapFeeBPS)}, {"Fee unit", "1 bps = 0.01% of the output-token amount"}, {"Amount unit", "Integer token base units; decimals are token-specific"}, }, } out := md.H1("Gnoswap Router") + "\n" out += md.H2("Router status") + "\n" out += statusTable.String() + "\n" out += md.H2("Swap fee configuration") + "\n" out += feeTable.String() + "\n" out += md.H2("Swap") + "\n" out += md.Paragraph( md.Link("Exact input: single route", "/r/gnoswap/router") + " · " + md.Link("Exact input: multiple routes", "/r/gnoswap/router:swap/exact-in") + " · " + md.Link("Exact output: single route", "/r/gnoswap/router:swap/exact-out-single") + " · " + md.Link("Exact output: multiple routes", "/r/gnoswap/router:swap/exact-out"), ) out += action return out }