types.gno
9.47 Kb · 198 lines
1package router
2
3type IRouter interface {
4 // ExactInSwapRoute executes a multi-hop exact-input swap.
5 //
6 // Parameters:
7 // - _: leading implementation discriminator; callers pass 0
8 // - rlm: propagated current realm context used for swap validation and transfers
9 // - inputToken: input token contract path
10 // - outputToken: output token contract path
11 // - amountIn: exact input amount encoded as a decimal string
12 // - routeArr: comma-separated route paths, each with up to three pool hops
13 // - quoteArr: comma-separated route allocation percentages summing to 100
14 // - amountOutMin: minimum net output amount encoded as a decimal string
15 // - deadline: Unix timestamp after which the swap is rejected
16 // - referrer: optional referral address used for registration
17 //
18 // Returns:
19 // - amountIn: actual input amount consumed, encoded as a decimal string
20 // - amountOut: net output amount after router fee, encoded as a decimal string
21 ExactInSwapRoute(_ int, rlm realm, inputToken string, outputToken string, amountIn string, routeArr string, quoteArr string, amountOutMin string, deadline int64, referrer string) (string, string)
22 // ExactInSingleSwapRoute executes an exact-input swap through one pool.
23 //
24 // Parameters:
25 // - _: leading implementation discriminator; callers pass 0
26 // - rlm: propagated current realm context used for swap validation and transfers
27 // - inputToken: input token contract path
28 // - outputToken: output token contract path
29 // - amountIn: exact input amount encoded as a decimal string
30 // - routeArr: single-hop route path
31 // - amountOutMin: minimum net output amount encoded as a decimal string
32 // - sqrtPriceLimitX96: optional Q64.96 square-root price limit encoded as a decimal string
33 // - deadline: Unix timestamp after which the swap is rejected
34 // - referrer: optional referral address used for registration
35 //
36 // Returns:
37 // - amountIn: actual input amount consumed, encoded as a decimal string
38 // - amountOut: net output amount after router fee, encoded as a decimal string
39 ExactInSingleSwapRoute(_ int, rlm realm, inputToken string, outputToken string, amountIn string, routeArr string, amountOutMin string, sqrtPriceLimitX96 string, deadline int64, referrer string) (string, string)
40
41 // ExactOutSwapRoute executes a multi-hop swap for a requested net output.
42 //
43 // Parameters:
44 // - _: leading implementation discriminator; callers pass 0
45 // - rlm: propagated current realm context used for swap validation and transfers
46 // - inputToken: input token contract path
47 // - outputToken: output token contract path
48 // - amountOut: requested net output amount encoded as a decimal string
49 // - routeArr: comma-separated route paths, each with up to three pool hops
50 // - quoteArr: comma-separated route allocation percentages summing to 100
51 // - amountInMax: maximum input amount encoded as a decimal string
52 // - deadline: Unix timestamp after which the swap is rejected
53 // - referrer: optional referral address used for registration
54 //
55 // Returns:
56 // - amountIn: actual input amount consumed, encoded as a decimal string
57 // - amountOut: net output amount after router fee, encoded as a decimal string
58 ExactOutSwapRoute(_ int, rlm realm, inputToken string, outputToken string, amountOut string, routeArr string, quoteArr string, amountInMax string, deadline int64, referrer string) (string, string)
59 // ExactOutSingleSwapRoute executes an exact-output swap through one pool.
60 //
61 // Parameters:
62 // - _: leading implementation discriminator; callers pass 0
63 // - rlm: propagated current realm context used for swap validation and transfers
64 // - inputToken: input token contract path
65 // - outputToken: output token contract path
66 // - amountOut: requested net output amount encoded as a decimal string
67 // - routeArr: single-hop route path
68 // - amountInMax: maximum input amount encoded as a decimal string
69 // - sqrtPriceLimitX96: optional Q64.96 square-root price limit encoded as a decimal string
70 // - deadline: Unix timestamp after which the swap is rejected
71 // - referrer: optional referral address used for registration
72 //
73 // Returns:
74 // - amountIn: actual input amount consumed, encoded as a decimal string
75 // - amountOut: net output amount after router fee, encoded as a decimal string
76 ExactOutSingleSwapRoute(_ int, rlm realm, inputToken string, outputToken string, amountOut string, routeArr string, amountInMax string, sqrtPriceLimitX96 string, deadline int64, referrer string) (string, string)
77
78 // DrySwapRoute simulates a route without writing state or transferring tokens.
79 //
80 // Parameters:
81 // - inputToken: input token contract path
82 // - outputToken: output token contract path
83 // - specifiedAmount: exact input or output amount encoded as a decimal string
84 // - swapTypeStr: swap type string, either EXACT_IN or EXACT_OUT
85 // - strRouteArr: comma-separated encoded route paths
86 // - quoteArr: comma-separated route allocation percentages summing to 100
87 // - tokenAmountLimit: minimum output for EXACT_IN or maximum input for EXACT_OUT
88 //
89 // Returns:
90 // - amountIn: simulated input amount encoded as a decimal string
91 // - amountOut: simulated net output amount encoded as a decimal string
92 // - err: nil on success; validation, liquidity, or slippage error on failure
93 DrySwapRoute(inputToken, outputToken, specifiedAmount, swapTypeStr, strRouteArr, quoteArr, tokenAmountLimit string) (string, string, error)
94 // SwapCallback pays a pool's positive input delta during a swap.
95 //
96 // Parameters:
97 // - _: leading callback discriminator; callers pass 0
98 // - rlm: propagated current realm context; implementation verifies it is current
99 // - token0Path: token-0 contract path in canonical pool order
100 // - token1Path: token-1 contract path in canonical pool order
101 // - amount0Delta: signed token-0 delta; positive means the pool is owed tokens
102 // - amount1Delta: signed token-1 delta; positive means the pool is owed tokens
103 // - payer: address whose balance supplies the positive delta
104 //
105 // Returns:
106 // - err: nil after payment; error when realm, liquidity delta, or transfer validation fails
107 SwapCallback(_ int, rlm realm, token0Path string, token1Path string, amount0Delta int64, amount1Delta int64, payer address) error
108 // GetSwapFee reads the router fee rate.
109 //
110 // Returns:
111 // - fee: router fee in basis points
112 GetSwapFee() uint64
113 // SetSwapFee updates the router fee rate.
114 //
115 // Parameters:
116 // - _: leading call discriminator; callers pass 0
117 // - rlm: propagated current realm context used for authorized storage writes
118 // - fee: router fee in basis points
119 SetSwapFee(_ int, rlm realm, fee uint64)
120 // GetPendingProtocolFees reads pending protocol fees keyed by token path.
121 //
122 // Returns:
123 // - fees: token-path to pending-fee amount map
124 GetPendingProtocolFees() map[string]int64
125 Render(path string) string
126}
127
128type IRouterStore interface {
129 // HasSwapFeeKey reports whether a stored router fee exists.
130 //
131 // Returns:
132 // - exists: true when the swap-fee key is present
133 HasSwapFeeKey() bool
134 // GetSwapFee reads the stored router fee.
135 //
136 // Returns:
137 // - fee: configured router fee in basis points
138 GetSwapFee() uint64
139 // SetSwapFee persists the router fee.
140 //
141 // Parameters:
142 // - _: leading call discriminator; callers pass 0
143 // - rlm: propagated current realm context; storage validates current-frame status
144 // - fee: router fee in basis points
145 //
146 // Returns:
147 // - err: nil on success; storage or realm-validation error otherwise
148 SetSwapFee(_ int, rlm realm, fee uint64) error
149 // HasPendingProtocolFeesKey reports whether a stored pending-fees map exists.
150 //
151 // Returns:
152 // - exists: true when the pending-fees key is present
153 HasPendingProtocolFeesKey() bool
154 // GetPendingProtocolFees reads all pending protocol fees.
155 //
156 // Returns:
157 // - fees: token-path to pending-fee amount map
158 GetPendingProtocolFees() map[string]int64
159 // SetPendingProtocolFees replaces all pending protocol fees.
160 //
161 // Parameters:
162 // - _: leading call discriminator; callers pass 0
163 // - rlm: propagated current realm context; storage validates current-frame status
164 // - fees: token-path to pending-fee amount map to persist
165 //
166 // Returns:
167 // - err: nil on success; storage or realm-validation error otherwise
168 SetPendingProtocolFees(_ int, rlm realm, fees map[string]int64) error
169 // GetPendingProtocolFee reads one token's pending fee.
170 //
171 // Parameters:
172 // - tokenPath: token contract path to query
173 //
174 // Returns:
175 // - amount: pending amount for tokenPath, or zero if absent
176 GetPendingProtocolFee(tokenPath string) int64
177 // SetPendingProtocolFee updates one token's pending fee.
178 //
179 // Parameters:
180 // - _: leading call discriminator; callers pass 0
181 // - rlm: propagated current realm context; storage validates current-frame and write authorization
182 // - tokenPath: token contract path to update
183 // - amount: pending amount to record
184 //
185 // Returns:
186 // - err: nil on success; realm or storage authorization error otherwise
187 SetPendingProtocolFee(_ int, rlm realm, tokenPath string, amount int64) error
188 // RemovePendingProtocolFee deletes one token's pending fee.
189 //
190 // Parameters:
191 // - _: leading call discriminator; callers pass 0
192 // - rlm: propagated current realm context; storage validates current-frame and write authorization
193 // - tokenPath: token contract path to remove
194 //
195 // Returns:
196 // - err: nil on success; realm or storage authorization error otherwise
197 RemovePendingProtocolFee(_ int, rlm realm, tokenPath string) error
198}