proxy.gno
7.45 Kb · 311 lines
1package pool
2
3// CreatePool creates a new liquidity pool for a token pair.
4//
5// Parameters:
6// - token0Path: path of the first token
7// - token1Path: path of the second token
8// - fee: pool fee tier
9// - sqrtPriceX96: initial sqrt price (Q64.96 format)
10func CreatePool(
11 cur realm,
12 token0Path string,
13 token1Path string,
14 fee uint32,
15 sqrtPriceX96 string,
16) {
17 getImplementation().CreatePool(
18 0,
19 cur,
20 token0Path,
21 token1Path,
22 fee,
23 sqrtPriceX96,
24 )
25}
26
27// SetPoolCreationFee sets the pool creation fee.
28func SetPoolCreationFee(cur realm, fee int64) {
29 getImplementation().SetPoolCreationFee(0, cur, fee)
30}
31
32// IncreaseObservationCardinalityNext increases the observation cardinality for a pool.
33//
34// Parameters:
35// - token0Path: path of the first token
36// - token1Path: path of the second token
37// - fee: pool fee tier
38// - cardinalityNext: new observation cardinality limit
39func IncreaseObservationCardinalityNext(
40 cur realm,
41 token0Path string,
42 token1Path string,
43 fee uint32,
44 cardinalityNext uint16,
45) {
46 getImplementation().IncreaseObservationCardinalityNext(
47 0,
48 cur,
49 token0Path,
50 token1Path,
51 fee,
52 cardinalityNext,
53 )
54}
55
56// Mint adds liquidity to a position.
57//
58// Parameters:
59// - token0Path: path of the first token
60// - token1Path: path of the second token
61// - fee: pool fee tier
62// - tickLower: lower tick boundary
63// - tickUpper: upper tick boundary
64// - liquidityAmount: amount of liquidity to add
65// - positionCaller: caller address for the position
66//
67// Returns:
68// - string: amount of token0 added
69// - string: amount of token1 added
70func Mint(
71 cur realm,
72 token0Path string,
73 token1Path string,
74 fee uint32,
75 tickLower int32,
76 tickUpper int32,
77 liquidityAmount string,
78 positionCaller address,
79) (string, string) {
80 return getImplementation().Mint(
81 0,
82 cur,
83 token0Path,
84 token1Path,
85 fee,
86 tickLower,
87 tickUpper,
88 liquidityAmount,
89 positionCaller,
90 )
91}
92
93// Burn removes liquidity from a position.
94func Burn(
95 cur realm,
96 token0Path string,
97 token1Path string,
98 fee uint32,
99 tickLower int32,
100 tickUpper int32,
101 liquidityAmount string,
102 positionCaller address,
103) (string, string) {
104 return getImplementation().Burn(
105 0,
106 cur,
107 token0Path,
108 token1Path,
109 fee,
110 tickLower,
111 tickUpper,
112 liquidityAmount,
113 positionCaller,
114 )
115}
116
117// Collect transfers owed tokens from a position to recipient.
118func Collect(
119 cur realm,
120 token0Path string,
121 token1Path string,
122 fee uint32,
123 recipient address,
124 tickLower int32,
125 tickUpper int32,
126 amount0Requested string,
127 amount1Requested string,
128) (string, string) {
129 return getImplementation().Collect(
130 0,
131 cur,
132 token0Path,
133 token1Path,
134 fee,
135 recipient,
136 tickLower,
137 tickUpper,
138 amount0Requested,
139 amount1Requested,
140 )
141}
142
143// SetWithdrawalFee sets the withdrawal fee rate.
144//
145// Parameters:
146// - fee: withdrawal fee in basis points
147func SetWithdrawalFee(cur realm, fee uint64) {
148 getImplementation().SetWithdrawalFee(0, cur, fee)
149}
150
151// HandleWithdrawalFee processes withdrawal fees for a position.
152//
153// Parameters:
154// - token0Path: path of the first token
155// - amount0: amount of token0 to withdraw
156// - token1Path: path of the second token
157// - amount1: amount of token1 to withdraw
158// - positionCaller: caller address for the position
159//
160// Returns:
161// - string: withdrawal fee amount of token0
162// - string: withdrawal fee amount of token1
163// - string: net amount of token0 after fees
164// - string: net amount of token1 after fees
165func HandleWithdrawalFee(
166 cur realm,
167 token0Path string,
168 amount0 string,
169 token1Path string,
170 amount1 string,
171 positionCaller address,
172) (string, string, string, string) {
173 return getImplementation().HandleWithdrawalFee(
174 0,
175 cur,
176 token0Path,
177 amount0,
178 token1Path,
179 amount1,
180 positionCaller,
181 )
182}
183
184// Swap executes a token swap in the pool.
185//
186// Parameters:
187// - token0Path: path of the first token
188// - token1Path: path of the second token
189// - fee: pool fee tier
190// - recipient: recipient address for output tokens
191// - zeroForOne: true if swapping token0 for token1
192// - amountSpecified: amount to swap (positive for exact input, negative for exact output)
193// - sqrtPriceLimitX96: price limit for the swap
194// - payer: address that will pay for the swap
195// - swapCallback: callback function for token transfer, callbackMarker is used to identify the callback
196//
197// Returns:
198// - string: amount of token0 delta
199// - string: amount of token1 delta
200func Swap(
201 cur realm,
202 token0Path string,
203 token1Path string,
204 fee uint32,
205 recipient address,
206 zeroForOne bool,
207 amountSpecified string,
208 sqrtPriceLimitX96 string,
209 payer address,
210 swapCallback func(cur realm, amount0Delta, amount1Delta int64, callbackMarker *CallbackMarker) error,
211) (string, string) {
212 return getImplementation().Swap(
213 0,
214 cur,
215 token0Path,
216 token1Path,
217 fee,
218 recipient,
219 zeroForOne,
220 amountSpecified,
221 sqrtPriceLimitX96,
222 payer,
223 swapCallback,
224 )
225}
226
227// DrySwap simulates a swap without executing it, returning the expected output.
228//
229// This is a read-only operation that does not modify pool state.
230// Used by router for multi-hop swap simulations and by clients for price quotes.
231//
232// Parameters:
233// - token0Path: path of the first token
234// - token1Path: path of the second token
235// - fee: pool fee tier
236// - zeroForOne: true if swapping token0 for token1
237// - amountSpecified: amount to swap
238// - sqrtPriceLimitX96: price limit for the swap
239//
240// Returns:
241// - string: amount of token0 delta
242// - string: amount of token1 delta
243// - bool: swap success status
244func DrySwap(
245 token0Path string,
246 token1Path string,
247 fee uint32,
248 zeroForOne bool,
249 amountSpecified string,
250 sqrtPriceLimitX96 string,
251) (string, string, bool) {
252 return getImplementation().DrySwap(token0Path, token1Path, fee, zeroForOne, amountSpecified, sqrtPriceLimitX96)
253}
254
255// SetSwapEndHook sets the hook to be called at the end of a swap.
256func SetSwapEndHook(cur realm, hook func(cur realm, poolPath string) error) {
257 getImplementation().SetSwapEndHook(0, cur, hook)
258}
259
260// SetSwapStartHook sets the hook to be called at the start of a swap.
261func SetSwapStartHook(cur realm, hook func(cur realm, poolPath string, timestamp int64)) {
262 getImplementation().SetSwapStartHook(0, cur, hook)
263}
264
265// SetTickCrossHook sets the hook to be called when a tick is crossed during a swap.
266func SetTickCrossHook(cur realm, hook func(cur realm, poolPath string, tickId int32, zeroForOne bool, timestamp int64)) {
267 getImplementation().SetTickCrossHook(0, cur, hook)
268}
269
270// CollectProtocol collects protocol fees from a pool.
271//
272// Parameters:
273// - token0Path: path of the first token
274// - token1Path: path of the second token
275// - fee: pool fee tier
276// - recipient: recipient address for fees
277// - amount0Requested: amount of token0 to collect
278// - amount1Requested: amount of token1 to collect
279//
280// Returns:
281// - string: amount of token0 collected
282// - string: amount of token1 collected
283func CollectProtocol(
284 cur realm,
285 token0Path string,
286 token1Path string,
287 fee uint32,
288 recipient address,
289 amount0Requested string,
290 amount1Requested string,
291) (string, string) {
292 return getImplementation().CollectProtocol(
293 0,
294 cur,
295 token0Path,
296 token1Path,
297 fee,
298 recipient,
299 amount0Requested,
300 amount1Requested,
301 )
302}
303
304// SetFeeProtocol sets the protocol fee rates for a pool.
305//
306// Parameters:
307// - feeProtocol0: protocol fee rate for token0
308// - feeProtocol1: protocol fee rate for token1
309func SetFeeProtocol(cur realm, feeProtocol0, feeProtocol1 uint8) {
310 getImplementation().SetFeeProtocol(0, cur, feeProtocol0, feeProtocol1)
311}