Kind Realm (renderable)
Name v2
Namespace gnoswap / router
Exported functions 7
Module gno.land/r/gnoswap/router/v2
gno 0.9 render.gno gno
⧉
1 package router 2 3 import ( 4 "chain" 5 "strings" 6 7 "gno.land/p/moul/md/v0" 8 BuildSingleHopRoutePath (tokenA string, tokenB string, fee uint32) string
NewExactInParams (baseParams struct{InputToken string; OutputToken string; RouteArr string; QuoteArr string; SqrtPriceLimitX96 *gno.land/p/gnoswap/uint256/v1.Uint; Deadline int64}, amountIn int64, amountOutMin int64) struct{BaseSwapParams gno.land/r/gnoswap/router/v2.BaseSwapParams; AmountIn int64; AmountOutMin int64}
NewExactInSwapOperation (r *gno.land/r/gnoswap/router/v2.routerV1, pp struct{BaseSwapParams gno.land/r/gnoswap/router/v2.BaseSwapParams; AmountIn int64; AmountOutMin int64}) *gno.land/r/gnoswap/router/v2.ExactInSwapOperation
NewExactOutParams (baseParams struct{InputToken string; OutputToken string; RouteArr string; QuoteArr string; SqrtPriceLimitX96 *gno.land/p/gnoswap/uint256/v1.Uint; Deadline int64}, amountOut int64, amountInMax int64) struct{BaseSwapParams gno.land/r/gnoswap/router/v2.BaseSwapParams; AmountOut int64; AmountInMax int64}
NewExactOutSwapOperation (r *gno.land/r/gnoswap/router/v2.routerV1, pp struct{BaseSwapParams gno.land/r/gnoswap/router/v2.BaseSwapParams; AmountOut int64; AmountInMax int64}) *gno.land/r/gnoswap/router/v2.ExactOutSwapOperation
NewRouteParser () *gno.land/r/gnoswap/router/v2.RouteParser
NewRouterV1 (routerStore interface {GetPendingProtocolFee func(string) int64; GetPendingProtocolFees func() map[string]int64; GetSwapFee func() uint64; HasPendingProtocolFeesKey func() bool; HasSwapFeeKey func() bool; RemovePendingProtocolFee func(int, .uverse.realm, string) .uverse.error; SetPendingProtocolFee func(int, .uverse.realm, string, int64) .uverse.error; SetPendingProtocolFees func(int, .uverse.realm, map[string]int64) .uverse.error; SetSwapFee func(int, .uverse.realm, uint64) .uverse.error}) interface {DrySwapRoute func(string, string, string, string, string, string, string) (string, string, .uverse.error); ExactInSingleSwapRoute func(int, .uverse.realm, string, string, string, string, string, string, int64, string) (string, string); ExactInSwapRoute func(int, .uverse.realm, string, string, string, string, string, string, int64, string) (string, string); ExactOutSingleSwapRoute func(int, .uverse.realm, string, string, string, string, string, string, int64, string) (string, string); ExactOutSwapRoute func(int, .uverse.realm, string, string, string, string, string, string, int64, string) (string, string); GetPendingProtocolFees func() map[string]int64; GetSwapFee func() uint64; Render func(string) string; SetSwapFee func(int, .uverse.realm, uint64); SwapCallback func(int, .uverse.realm, string, string, int64, int64, .uverse.address) .uverse.error}
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
This realm does not provide renderable output (vm/qrender → NoRenderDeclError).
View on gnoweb ↗ vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.
"gno.land/p/moul/mdtable/v0"
9 ufmt "gno.land/p/nt/ufmt/v0"
10
11 "gno.land/r/gnoswap/halt/v1"
12 "gno.land/r/gnoswap/router"
13 )
14
15 const maxSwapFeeBPS uint64 = 1000
16
17 func (r *routerV1) Render(path string ) string {
18 var action string
19 switch path {
20 case "" :
21 action = md.H3( "Exact-input single-route swap" ) + "\n" +
22 "<gno-form exec=\"ExactInSingleSwapRoute\">\n" +
23 " <gno-input name=\"inputToken\" type=\"text\" placeholder=\"Approved input: gno.land/r/gnoland/wugnot.wugnot\" required=\"true\" />\n" +
24 " <gno-input name=\"outputToken\" type=\"text\" placeholder=\"Output: gno.land/r/gnoswap/gns.GNS\" required=\"true\" />\n" +
25 " <gno-input name=\"amountIn\" type=\"text\" placeholder=\"Exact input amount (base units)\" required=\"true\" />\n" +
26 " <gno-input name=\"routeArr\" type=\"text\" placeholder=\"Route: inputToken:outputToken:500\" required=\"true\" />\n" +
27 " <gno-input name=\"amountOutMin\" type=\"text\" placeholder=\"Minimum output amount (base units)\" required=\"true\" />\n" +
28 " <gno-input name=\"sqrtPriceLimitX96\" type=\"text\" placeholder=\"Q64.96 sqrt-price limit (0 = no limit)\" required=\"true\" />\n" +
29 " <gno-input name=\"deadline\" type=\"number\" placeholder=\"Future Unix timestamp (seconds)\" required=\"true\" />\n" +
30 " <gno-input name=\"referrer\" type=\"text\" placeholder=\"Optional referrer address\" />\n" +
31 "</gno-form>\n"
32 case "swap/exact-in" :
33 action = md.H3( "Exact-input multi-route swap" ) + "\n" +
34 "<gno-form exec=\"ExactInSwapRoute\">\n" +
35 " <gno-input name=\"inputToken\" type=\"text\" placeholder=\"Approved input: gno.land/r/gnoland/wugnot.wugnot\" required=\"true\" />\n" +
36 " <gno-input name=\"outputToken\" type=\"text\" placeholder=\"Output: gno.land/r/gnoswap/gns.GNS\" required=\"true\" />\n" +
37 " <gno-input name=\"amountIn\" type=\"text\" placeholder=\"Exact input amount (base units)\" required=\"true\" />\n" +
38 " <gno-input name=\"routeArr\" type=\"text\" placeholder=\"Routes: A:C:500,A:B:500*POOL*B:C:3000 (A/B/C = token keys)\" required=\"true\" />\n" +
39 " <gno-input name=\"quoteArr\" type=\"text\" placeholder=\"Route percentages: 100 or 70,30 (total 100)\" required=\"true\" />\n" +
40 " <gno-input name=\"amountOutMin\" type=\"text\" placeholder=\"Minimum output amount (base units)\" required=\"true\" />\n" +
41 " <gno-input name=\"deadline\" type=\"number\" placeholder=\"Future Unix timestamp (seconds)\" required=\"true\" />\n" +
42 " <gno-input name=\"referrer\" type=\"text\" placeholder=\"Optional referrer address\" />\n" +
43 "</gno-form>\n"
44 case "swap/exact-out" :
45 action = md.H3( "Exact-output multi-route swap" ) + "\n" +
46 "<gno-form exec=\"ExactOutSwapRoute\">\n" +
47 " <gno-input name=\"inputToken\" type=\"text\" placeholder=\"Approved input: gno.land/r/gnoland/wugnot.wugnot\" required=\"true\" />\n" +
48 " <gno-input name=\"outputToken\" type=\"text\" placeholder=\"Output: gno.land/r/gnoswap/gns.GNS\" required=\"true\" />\n" +
49 " <gno-input name=\"amountOut\" type=\"text\" placeholder=\"Exact output amount (base units)\" required=\"true\" />\n" +
50 " <gno-input name=\"routeArr\" type=\"text\" placeholder=\"Routes: A:C:500,A:B:500*POOL*B:C:3000 (A/B/C = token keys)\" required=\"true\" />\n" +
51 " <gno-input name=\"quoteArr\" type=\"text\" placeholder=\"Route percentages: 100 or 70,30 (total 100)\" required=\"true\" />\n" +
52 " <gno-input name=\"amountInMax\" type=\"text\" placeholder=\"Maximum input amount (base units)\" required=\"true\" />\n" +
53 " <gno-input name=\"deadline\" type=\"number\" placeholder=\"Future Unix timestamp (seconds)\" required=\"true\" />\n" +
54 " <gno-input name=\"referrer\" type=\"text\" placeholder=\"Optional referrer address\" />\n" +
55 "</gno-form>\n"
56 case "swap/exact-out-single" :
57 action = md.H3( "Exact-output single-route swap" ) + "\n" +
58 "<gno-form exec=\"ExactOutSingleSwapRoute\">\n" +
59 " <gno-input name=\"inputToken\" type=\"text\" placeholder=\"Approved input: gno.land/r/gnoland/wugnot.wugnot\" required=\"true\" />\n" +
60 " <gno-input name=\"outputToken\" type=\"text\" placeholder=\"Output: gno.land/r/gnoswap/gns.GNS\" required=\"true\" />\n" +
61 " <gno-input name=\"amountOut\" type=\"text\" placeholder=\"Exact output amount (base units)\" required=\"true\" />\n" +
62 " <gno-input name=\"routeArr\" type=\"text\" placeholder=\"Route: inputToken:outputToken:500\" required=\"true\" />\n" +
63 " <gno-input name=\"amountInMax\" type=\"text\" placeholder=\"Maximum input amount (base units)\" required=\"true\" />\n" +
64 " <gno-input name=\"sqrtPriceLimitX96\" type=\"text\" placeholder=\"Q64.96 sqrt-price limit (0 = no limit)\" required=\"true\" />\n" +
65 " <gno-input name=\"deadline\" type=\"number\" placeholder=\"Future Unix timestamp (seconds)\" required=\"true\" />\n" +
66 " <gno-input name=\"referrer\" type=\"text\" placeholder=\"Optional referrer address\" />\n" +
67 "</gno-form>\n"
68 default :
69 return "404\n"
70 }
71
72 swapFee := r.GetSwapFee()
73 implementation := router.GetImplementationPackagePath()
74 statusTable := mdtable.Table{
75 Headers: [] string { "Field" , "Value" },
76 Rows: [][] string {
77 { "Router package" , md.Link( "gno.land/r/gnoswap/router" , "/r/gnoswap/router" )},
78 { "Realm address" , md.InlineCode(chain.PackageAddress( "gno.land/r/gnoswap/router" ).String())},
79 { "Active implementation" , md.Link(implementation, strings.TrimPrefix(implementation, "gno.land" ))},
80 { "Router halted" , ufmt.Sprintf( "%t" , halt.IsHaltedRouter())},
81 },
82 }
83 feeTable := mdtable.Table{
84 Headers: [] string { "Field" , "Value" },
85 Rows: [][] string {
86 { "Swap fee" , ufmt.Sprintf( "%d bps" , swapFee)},
87 { "Maximum swap fee" , ufmt.Sprintf( "%d bps (10%%)" , maxSwapFeeBPS)},
88 { "Fee unit" , "1 bps = 0.01% of the output-token amount" },
89 { "Amount unit" , "Integer token base units; decimals are token-specific" },
90 },
91 }
92
93 out := md.H1( "Gnoswap Router" ) + "\n"
94 out += md.H2( "Router status" ) + "\n"
95 out += statusTable.String() + "\n"
96 out += md.H2( "Swap fee configuration" ) + "\n"
97 out += feeTable.String() + "\n"
98 out += md.H2( "Swap" ) + "\n"
99 out += md.Paragraph(
100 md.Link( "Exact input: single route" , "/r/gnoswap/router" ) + " · " +
101 md.Link( "Exact input: multiple routes" , "/r/gnoswap/router:swap/exact-in" ) + " · " +
102 md.Link( "Exact output: single route" , "/r/gnoswap/router:swap/exact-out-single" ) + " · " +
103 md.Link( "Exact output: multiple routes" , "/r/gnoswap/router:swap/exact-out" ),
104 )
105 out += action
106 return out
107 }
108