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