proxy.gno
7.38 Kb · 308 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// - swapCallback: callback function for token transfer, callbackMarker is used to identify the callback
195//
196// Returns:
197// - string: amount of token0 delta
198// - string: amount of token1 delta
199func Swap(
200 cur realm,
201 token0Path string,
202 token1Path string,
203 fee uint32,
204 recipient address,
205 zeroForOne bool,
206 amountSpecified string,
207 sqrtPriceLimitX96 string,
208 swapCallback func(cur realm, amount0Delta, amount1Delta int64, callbackMarker *CallbackMarker) error,
209) (string, string) {
210 return getImplementation().Swap(
211 0,
212 cur,
213 token0Path,
214 token1Path,
215 fee,
216 recipient,
217 zeroForOne,
218 amountSpecified,
219 sqrtPriceLimitX96,
220 swapCallback,
221 )
222}
223
224// DrySwap simulates a swap without executing it, returning the expected output.
225//
226// This is a read-only operation that does not modify pool state.
227// Used by router for multi-hop swap simulations and by clients for price quotes.
228//
229// Parameters:
230// - token0Path: path of the first token
231// - token1Path: path of the second token
232// - fee: pool fee tier
233// - zeroForOne: true if swapping token0 for token1
234// - amountSpecified: amount to swap
235// - sqrtPriceLimitX96: price limit for the swap
236//
237// Returns:
238// - string: amount of token0 delta
239// - string: amount of token1 delta
240// - bool: swap success status
241func DrySwap(
242 token0Path string,
243 token1Path string,
244 fee uint32,
245 zeroForOne bool,
246 amountSpecified string,
247 sqrtPriceLimitX96 string,
248) (string, string, bool) {
249 return getImplementation().DrySwap(token0Path, token1Path, fee, zeroForOne, amountSpecified, sqrtPriceLimitX96)
250}
251
252// SetSwapEndHook sets the hook to be called at the end of a swap.
253func SetSwapEndHook(cur realm, hook func(cur realm, poolPath string) error) {
254 getImplementation().SetSwapEndHook(0, cur, hook)
255}
256
257// SetSwapStartHook sets the hook to be called at the start of a swap.
258func SetSwapStartHook(cur realm, hook func(cur realm, poolPath string, timestamp int64)) {
259 getImplementation().SetSwapStartHook(0, cur, hook)
260}
261
262// SetTickCrossHook sets the hook to be called when a tick is crossed during a swap.
263func SetTickCrossHook(cur realm, hook func(cur realm, poolPath string, tickId int32, zeroForOne bool, timestamp int64)) {
264 getImplementation().SetTickCrossHook(0, cur, hook)
265}
266
267// CollectProtocol collects protocol fees from a pool.
268//
269// Parameters:
270// - token0Path: path of the first token
271// - token1Path: path of the second token
272// - fee: pool fee tier
273// - recipient: recipient address for fees
274// - amount0Requested: amount of token0 to collect
275// - amount1Requested: amount of token1 to collect
276//
277// Returns:
278// - string: amount of token0 collected
279// - string: amount of token1 collected
280func CollectProtocol(
281 cur realm,
282 token0Path string,
283 token1Path string,
284 fee uint32,
285 recipient address,
286 amount0Requested string,
287 amount1Requested string,
288) (string, string) {
289 return getImplementation().CollectProtocol(
290 0,
291 cur,
292 token0Path,
293 token1Path,
294 fee,
295 recipient,
296 amount0Requested,
297 amount1Requested,
298 )
299}
300
301// SetFeeProtocol sets the protocol fee rates for a pool.
302//
303// Parameters:
304// - feeProtocol0: protocol fee rate for token0
305// - feeProtocol1: protocol fee rate for token1
306func SetFeeProtocol(cur realm, feeProtocol0, feeProtocol1 uint8) {
307 getImplementation().SetFeeProtocol(0, cur, feeProtocol0, feeProtocol1)
308}