Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

getter.gno

27.26 Kb · 701 lines
  1package pool
  2
  3import (
  4	rotree "gno.land/p/nt/bptree/rotree/v0"
  5)
  6
  7// GetPools returns a read-only view of every pool, keyed by pool path.
  8// Reading an entry yields a clone, so the view cannot mutate realm state.
  9// Returns:
 10//   - *rotree.ReadOnlyTree: Read-only tree keyed by canonical pool path; each
 11//     entry is cloned before it is exposed.
 12func GetPools() *rotree.ReadOnlyTree {
 13	return getImplementation().GetPools()
 14}
 15
 16// ExistsPoolPath checks if a pool exists at the given path.
 17// Parameters:
 18//   - poolPath: Canonical pool path identifying the pool to check.
 19//
 20// Returns:
 21//   - bool: True when a pool is registered at poolPath; false otherwise.
 22func ExistsPoolPath(poolPath string) bool {
 23	return getImplementation().ExistsPoolPath(poolPath)
 24}
 25
 26// GetBalances returns the balances of the pool.
 27// Parameters:
 28//   - poolPath: Canonical pool path identifying the pool whose balances are read.
 29//
 30// Returns:
 31//   - int64: Current token0 balance held by the pool, in token base units.
 32//   - int64: Current token1 balance held by the pool, in token base units.
 33//   - error: Non-nil when poolPath does not identify an existing pool.
 34func GetBalances(poolPath string) (int64, int64, error) {
 35	bal0, err := getImplementation().GetBalanceToken0(poolPath)
 36	if err != nil {
 37		return 0, 0, err
 38	}
 39	bal1, err := getImplementation().GetBalanceToken1(poolPath)
 40	if err != nil {
 41		return 0, 0, err
 42	}
 43	return bal0, bal1, nil
 44}
 45
 46// GetBalanceToken0 returns the balance of token0 in the pool.
 47// Parameters:
 48//   - poolPath: Canonical pool path identifying the pool to query.
 49//
 50// Returns:
 51//   - int64: Current token0 balance held by the pool, in token base units.
 52//   - error: Non-nil when poolPath does not identify an existing pool.
 53func GetBalanceToken0(poolPath string) (int64, error) {
 54	return getImplementation().GetBalanceToken0(poolPath)
 55}
 56
 57// GetBalanceToken1 returns the balance of token1 in the pool.
 58// Parameters:
 59//   - poolPath: Canonical pool path identifying the pool to query.
 60//
 61// Returns:
 62//   - int64: Current token1 balance held by the pool, in token base units.
 63//   - error: Non-nil when poolPath does not identify an existing pool.
 64func GetBalanceToken1(poolPath string) (int64, error) {
 65	return getImplementation().GetBalanceToken1(poolPath)
 66}
 67
 68// GetFee returns the fee tier of the pool.
 69// Parameters:
 70//   - poolPath: Canonical pool path identifying the pool whose fee tier is read.
 71//
 72// Returns:
 73//   - uint32: Configured fee tier for the pool.
 74//   - error: Non-nil when poolPath does not identify an existing pool.
 75func GetFee(poolPath string) (uint32, error) {
 76	return getImplementation().GetFee(poolPath)
 77}
 78
 79// GetFeeAmountTickSpacings returns all fee tier to tick spacing mappings.
 80// Returns:
 81//   - map[uint32]int32: Copy of the configured fee-tier-to-tick-spacing mapping.
 82func GetFeeAmountTickSpacings() map[uint32]int32 {
 83	return cloneFeeAmountTickSpacings(getImplementation().GetFeeAmountTickSpacings())
 84}
 85
 86// GetFeeAmountTickSpacing returns the tick spacing for a given fee tier.
 87// Parameters:
 88//   - fee: Fee tier whose supported tick spacing is requested.
 89//
 90// Returns:
 91//   - spacing: Tick spacing configured for fee.
 92//   - err: Non-nil when fee is not one of the supported fee tiers.
 93func GetFeeAmountTickSpacing(fee uint32) (spacing int32, err error) {
 94	return getImplementation().GetFeeAmountTickSpacing(fee)
 95}
 96
 97// GetFeeGrowthGlobal0X128 returns the global fee growth for token0.
 98// Parameters:
 99//   - poolPath: Canonical pool path identifying the pool to query.
100//
101// Returns:
102//   - string: Token0 global fee growth, serialized as a base-10 X128 accumulator.
103//   - error: Non-nil when poolPath does not identify an existing pool.
104func GetFeeGrowthGlobal0X128(poolPath string) (string, error) {
105	feeGrowth, err := getImplementation().GetFeeGrowthGlobal0X128(poolPath)
106	if err != nil {
107		return "", err
108	}
109	return feeGrowth.ToString(), nil
110}
111
112// GetFeeGrowthGlobal1X128 returns the global fee growth for token1.
113// Parameters:
114//   - poolPath: Canonical pool path identifying the pool to query.
115//
116// Returns:
117//   - string: Token1 global fee growth, serialized as a base-10 X128 accumulator.
118//   - error: Non-nil when poolPath does not identify an existing pool.
119func GetFeeGrowthGlobal1X128(poolPath string) (string, error) {
120	feeGrowth, err := getImplementation().GetFeeGrowthGlobal1X128(poolPath)
121	if err != nil {
122		return "", err
123	}
124	return feeGrowth.ToString(), nil
125}
126
127// GetFeeGrowthGlobalX128 returns the global fee growth for both tokens.
128// Parameters:
129//   - poolPath: Canonical pool path identifying the pool to query.
130//
131// Returns:
132//   - string: Token0 global fee growth, serialized as a base-10 X128 accumulator.
133//   - string: Token1 global fee growth, serialized as a base-10 X128 accumulator.
134//   - error: Non-nil when poolPath does not identify an existing pool.
135func GetFeeGrowthGlobalX128(poolPath string) (string, string, error) {
136	fg0, fg1, err := getImplementation().GetFeeGrowthGlobalX128(poolPath)
137	if err != nil {
138		return "", "", err
139	}
140	return fg0.ToString(), fg1.ToString(), nil
141}
142
143// GetLiquidity returns the current liquidity in the pool.
144// Parameters:
145//   - poolPath: Canonical pool path identifying the pool whose liquidity is read.
146//
147// Returns:
148//   - string: Current pool liquidity, serialized as a base-10 unsigned integer.
149//   - error: Non-nil when poolPath does not identify an existing pool.
150func GetLiquidity(poolPath string) (string, error) {
151	liquidity, err := getImplementation().GetLiquidity(poolPath)
152	if err != nil {
153		return "", err
154	}
155	return liquidity.ToString(), nil
156}
157
158// GetPoolCreationFee returns the current pool creation fee.
159// Returns:
160//   - int64: Pool creation fee charged when a new pool is created, in configured
161//     native-token base units.
162func GetPoolCreationFee() int64 {
163	return getImplementation().GetPoolCreationFee()
164}
165
166// GetPositionFeeGrowthInside0LastX128 returns the last recorded fee growth inside for token0.
167// Parameters:
168//   - poolPath: Canonical pool path identifying the pool containing the position.
169//   - key: Position key identifying the position within the pool.
170//
171// Returns:
172//   - string: Position's last token0 fee-growth-inside accumulator, serialized
173//     as a base-10 X128 value.
174//   - error: Non-nil when the pool or position key cannot be found.
175func GetPositionFeeGrowthInside0LastX128(poolPath, key string) (string, error) {
176	return getImplementation().GetPositionFeeGrowthInside0LastX128(poolPath, key)
177}
178
179// GetPositionFeeGrowthInside1LastX128 returns the last recorded fee growth inside for token1.
180// Parameters:
181//   - poolPath: Canonical pool path identifying the pool containing the position.
182//   - key: Position key identifying the position within the pool.
183//
184// Returns:
185//   - string: Position's last token1 fee-growth-inside accumulator, serialized
186//     as a base-10 X128 value.
187//   - error: Non-nil when the pool or position key cannot be found.
188func GetPositionFeeGrowthInside1LastX128(poolPath, key string) (string, error) {
189	return getImplementation().GetPositionFeeGrowthInside1LastX128(poolPath, key)
190}
191
192// GetPositionFeeGrowthInsideLastX128 returns the last recorded fee growth inside for both tokens.
193// Parameters:
194//   - poolPath: Canonical pool path identifying the pool containing the position.
195//   - key: Position key identifying the position within the pool.
196//
197// Returns:
198//   - string: Position's last token0 fee-growth-inside accumulator, serialized
199//     as a base-10 X128 value.
200//   - string: Position's last token1 fee-growth-inside accumulator, serialized
201//     as a base-10 X128 value.
202//   - error: Non-nil when the pool or position key cannot be found.
203func GetPositionFeeGrowthInsideLastX128(poolPath, key string) (string, string, error) {
204	return getImplementation().GetPositionFeeGrowthInsideLastX128(poolPath, key)
205}
206
207// GetPoolPositions returns a read-only view of a pool's positions, keyed by
208// position key. nil is returned when the pool does not exist.
209// Parameters:
210//   - poolPath: Canonical pool path identifying the pool whose positions are read.
211//
212// Returns:
213//   - *rotree.ReadOnlyTree: Read-only tree keyed by position key; nil when the
214//     pool does not exist.
215func GetPoolPositions(poolPath string) *rotree.ReadOnlyTree {
216	return getImplementation().GetPoolPositions(poolPath)
217}
218
219// GetPositionLiquidity returns the liquidity of a position.
220// Parameters:
221//   - poolPath: Canonical pool path identifying the pool containing the position.
222//   - key: Position key identifying the position within the pool.
223//
224// Returns:
225//   - string: Position liquidity, serialized as a base-10 unsigned integer.
226//   - error: Non-nil when the pool or position key cannot be found.
227func GetPositionLiquidity(poolPath, key string) (string, error) {
228	return getImplementation().GetPositionLiquidity(poolPath, key)
229}
230
231// GetPositionTokensOwed0 returns the amount of token0 owed to a position.
232// Parameters:
233//   - poolPath: Canonical pool path identifying the pool containing the position.
234//   - key: Position key identifying the position within the pool.
235//
236// Returns:
237//   - int64: Amount of token0 owed to the position, in token base units.
238//   - error: Non-nil when the pool or position key cannot be found.
239func GetPositionTokensOwed0(poolPath, key string) (int64, error) {
240	return getImplementation().GetPositionTokensOwed0(poolPath, key)
241}
242
243// GetPositionTokensOwed1 returns the amount of token1 owed to a position.
244// Parameters:
245//   - poolPath: Canonical pool path identifying the pool containing the position.
246//   - key: Position key identifying the position within the pool.
247//
248// Returns:
249//   - int64: Amount of token1 owed to the position, in token base units.
250//   - error: Non-nil when the pool or position key cannot be found.
251func GetPositionTokensOwed1(poolPath, key string) (int64, error) {
252	return getImplementation().GetPositionTokensOwed1(poolPath, key)
253}
254
255// GetPositionTokensOwedInfos returns the amount of tokens owed for both tokens.
256// Parameters:
257//   - poolPath: Canonical pool path identifying the pool containing the position.
258//   - key: Position key identifying the position within the pool.
259//
260// Returns:
261//   - int64: Amount of token0 owed to the position, in token base units.
262//   - int64: Amount of token1 owed to the position, in token base units.
263//   - error: Non-nil when the pool or position key cannot be found.
264func GetPositionTokensOwed(poolPath, key string) (int64, int64, error) {
265	tokensOwed0, err := getImplementation().GetPositionTokensOwed0(poolPath, key)
266	if err != nil {
267		return 0, 0, err
268	}
269	tokensOwed1, err := getImplementation().GetPositionTokensOwed1(poolPath, key)
270	if err != nil {
271		return 0, 0, err
272	}
273	return tokensOwed0, tokensOwed1, nil
274}
275
276// GetProtocolFeesToken0 returns accumulated protocol fees for token0.
277// Parameters:
278//   - poolPath: Canonical pool path identifying the pool whose fees are read.
279//
280// Returns:
281//   - int64: Accumulated protocol fee for token0, in token base units.
282//   - error: Non-nil when poolPath does not identify an existing pool.
283func GetProtocolFeesToken0(poolPath string) (int64, error) {
284	return getImplementation().GetProtocolFeesToken0(poolPath)
285}
286
287// GetProtocolFeesToken1 returns accumulated protocol fees for token1.
288// Parameters:
289//   - poolPath: Canonical pool path identifying the pool whose fees are read.
290//
291// Returns:
292//   - int64: Accumulated protocol fee for token1, in token base units.
293//   - error: Non-nil when poolPath does not identify an existing pool.
294func GetProtocolFeesToken1(poolPath string) (int64, error) {
295	return getImplementation().GetProtocolFeesToken1(poolPath)
296}
297
298// GetProtocolFeesTokens returns the accumulated protocol fees for both tokens.
299// Parameters:
300//   - poolPath: Canonical pool path identifying the pool whose fees are read.
301//
302// Returns:
303//   - int64: Accumulated protocol fee for token0, in token base units.
304//   - int64: Accumulated protocol fee for token1, in token base units.
305//   - error: Non-nil when poolPath does not identify an existing pool.
306func GetProtocolFeesTokens(poolPath string) (int64, int64, error) {
307	fees0, err := getImplementation().GetProtocolFeesToken0(poolPath)
308	if err != nil {
309		return 0, 0, err
310	}
311	fees1, err := getImplementation().GetProtocolFeesToken1(poolPath)
312	if err != nil {
313		return 0, 0, err
314	}
315	return fees0, fees1, nil
316}
317
318// GetSlot0FeeProtocol returns the protocol fee rate from slot0.
319// Parameters:
320//   - poolPath: Canonical pool path identifying the pool to query.
321//
322// Returns:
323//   - uint8: Packed protocol-fee denominator configuration from slot0; token0
324//     occupies the low nibble and token1 the high nibble.
325//   - error: Non-nil when poolPath does not identify an existing pool.
326func GetSlot0FeeProtocol(poolPath string) (uint8, error) {
327	return getImplementation().GetSlot0FeeProtocol(poolPath)
328}
329
330// GetSlot0SqrtPriceX96 returns the current sqrt price from slot0.
331// Parameters:
332//   - poolPath: Canonical pool path identifying the pool to query.
333//
334// Returns:
335//   - string: Current square-root price in Q64.96 fixed-point form, serialized
336//     as a base-10 unsigned integer.
337//   - error: Non-nil when poolPath does not identify an existing pool.
338func GetSlot0SqrtPriceX96(poolPath string) (string, error) {
339	sqrtPriceX96, err := getImplementation().GetSlot0SqrtPriceX96(poolPath)
340	if err != nil {
341		return "", err
342	}
343	return sqrtPriceX96.ToString(), nil
344}
345
346// GetSlot0Tick returns the current tick from slot0.
347// Parameters:
348//   - poolPath: Canonical pool path identifying the pool to query.
349//
350// Returns:
351//   - int32: Current active tick index stored in slot0.
352//   - error: Non-nil when poolPath does not identify an existing pool.
353func GetSlot0Tick(poolPath string) (int32, error) {
354	return getImplementation().GetSlot0Tick(poolPath)
355}
356
357// GetSlot0Unlocked reports whether the pool is currently unlocked.
358// Parameters:
359//   - poolPath: Canonical pool path identifying the pool to query.
360//
361// Returns:
362//   - bool: True when the pool is not holding its reentrancy lock; false when
363//     the pool is currently locked.
364//   - error: Non-nil when poolPath does not identify an existing pool.
365func GetSlot0Unlocked(poolPath string) (bool, error) {
366	return getImplementation().GetSlot0Unlocked(poolPath)
367}
368
369// GetSlot0 returns a safe copy of the pool's slot0 (sqrt price, tick,
370// protocol fee, lock state, and oracle cursor/capacity metadata).
371// The clone happens here, at the proxy boundary, so every implementation
372// version can return its internal Slot0 by value without each one having to
373// remember to defend against callers mutating the shared sqrtPriceX96.
374// Parameters:
375//   - poolPath: Canonical pool path identifying the pool to query.
376//
377// Returns:
378//   - Slot0: Copy of the pool's slot0 state, including price, tick, protocol
379//     fee, lock, and observation metadata; panics if the pool is missing.
380func GetSlot0(poolPath string) Slot0 {
381	slot0 := getImplementation().GetSlot0(poolPath)
382	return slot0.Clone()
383}
384
385// GetObservationAt returns a safe copy of the observation stored at index.
386// An in-range but uninitialized slot returns the zero observation, matching
387// Uniswap V3's fixed observation-array getter.
388//
389// ref: uniswap v3 IUniswapV3PoolState.observations(uint256 index)
390// Parameters:
391//   - poolPath: Canonical pool path identifying the pool containing the observation.
392//   - index: Zero-based observation-array index; values at or above the fixed
393//     cardinality bound return an error.
394//
395// Returns:
396//   - Observation: Observation at index, or the zero observation when the slot
397//     is in range but has never been written.
398//   - error: Non-nil when the pool is missing or index is out of range.
399func GetObservationAt(poolPath string, index uint16) (Observation, error) {
400	observation, err := getImplementation().GetObservationAt(poolPath, index)
401	if err != nil {
402		return Observation{}, err
403	}
404
405	return observation, nil
406}
407
408// Observe returns the tick and seconds-per-liquidity cumulatives for each
409// requested lookback, matching Uniswap V3's observe(uint32[] secondsAgos).
410// Parameters:
411//   - poolPath: Canonical pool path whose oracle history is queried.
412//   - secondsAgos: Lookback intervals in seconds; one cumulative pair is returned
413//     for each value, in the same order.
414//
415// Returns:
416//   - []int64: Tick cumulative values corresponding to each requested lookback.
417//   - []string: Seconds-per-liquidity cumulative X128 values, serialized as
418//     base-10 strings, corresponding to each lookback.
419//   - error: Non-nil when pool or observation data cannot be read.
420func Observe(poolPath string, secondsAgos []uint32) ([]int64, []string, error) {
421	tickCumulatives, secondsPerLiquidityCumulativeX128s, err := getImplementation().Observe(
422		poolPath,
423		cloneUint32Slice(secondsAgos),
424	)
425	if err != nil {
426		return nil, nil, err
427	}
428
429	return cloneInt64Slice(tickCumulatives), cloneStringSlice(secondsPerLiquidityCumulativeX128s), nil
430}
431
432// SnapshotCumulativesInside returns the tick, seconds-per-liquidity, and
433// seconds cumulatives accrued while the pool price was inside
434// [tickLower, tickUpper). Both boundary ticks must be initialized.
435//
436// Snapshots are only comparable across an interval during which a position in
437// the range existed, matching Uniswap V3's snapshotCumulativesInside.
438// Parameters:
439//   - poolPath: Canonical pool path whose oracle snapshot is queried.
440//   - tickLower: Lower inclusive tick boundary of the position range.
441//   - tickUpper: Upper exclusive tick boundary of the position range; both
442//     boundary ticks must be initialized.
443//
444// Returns:
445//   - int64: Tick cumulative accrued while the price was inside the range.
446//   - string: Seconds-per-liquidity-inside X128 accumulator, serialized as a
447//     base-10 string.
448//   - uint32: Seconds accrued while the price was inside the range.
449//   - error: Non-nil when the pool, observations, or initialized boundaries are
450//     unavailable.
451func SnapshotCumulativesInside(
452	poolPath string,
453	tickLower int32,
454	tickUpper int32,
455) (int64, string, uint32, error) {
456	tickCumulativeInside, secondsPerLiquidityInsideX128, secondsInside, err := getImplementation().SnapshotCumulativesInside(
457		poolPath,
458		tickLower,
459		tickUpper,
460	)
461	if err != nil {
462		return 0, "", 0, err
463	}
464
465	return tickCumulativeInside, secondsPerLiquidityInsideX128.ToString(), secondsInside, nil
466}
467
468// GetTickCumulativeOutside returns the tick cumulative value outside a tick.
469// Parameters:
470//   - poolPath: Canonical pool path identifying the pool containing the tick.
471//   - tick: Tick index whose outside tick cumulative is requested.
472//
473// Returns:
474//   - int64: Tick cumulative recorded outside tick.
475//   - error: Non-nil when the pool or tick is not found.
476func GetTickCumulativeOutside(poolPath string, tick int32) (int64, error) {
477	return getImplementation().GetTickCumulativeOutside(poolPath, tick)
478}
479
480// GetTickFeeGrowthOutside0X128 returns fee growth outside for token0 at a tick.
481// Parameters:
482//   - poolPath: Canonical pool path identifying the pool containing the tick.
483//   - tick: Tick index whose outside fee growth is requested.
484//
485// Returns:
486//   - string: Token0 fee growth outside tick, serialized as a base-10 X128
487//     accumulator.
488//   - error: Non-nil when the pool or tick is not found.
489func GetTickFeeGrowthOutside0X128(poolPath string, tick int32) (string, error) {
490	return getImplementation().GetTickFeeGrowthOutside0X128(poolPath, tick)
491}
492
493// GetTickFeeGrowthOutside1X128 returns fee growth outside for token1 at a tick.
494// Parameters:
495//   - poolPath: Canonical pool path identifying the pool containing the tick.
496//   - tick: Tick index whose outside fee growth is requested.
497//
498// Returns:
499//   - string: Token1 fee growth outside tick, serialized as a base-10 X128
500//     accumulator.
501//   - error: Non-nil when the pool or tick is not found.
502func GetTickFeeGrowthOutside1X128(poolPath string, tick int32) (string, error) {
503	return getImplementation().GetTickFeeGrowthOutside1X128(poolPath, tick)
504}
505
506// GetTickFeeGrowthOutsideX128 returns fee growth outside for both tokens at a tick.
507// Parameters:
508//   - poolPath: Canonical pool path identifying the pool containing the tick.
509//   - tick: Tick index whose outside fee growth is requested.
510//
511// Returns:
512//   - string: Token0 fee growth outside tick, serialized as a base-10 X128
513//     accumulator.
514//   - string: Token1 fee growth outside tick, serialized as a base-10 X128
515//     accumulator.
516//   - error: Non-nil when the pool or tick is not found.
517func GetTickFeeGrowthOutsideX128(poolPath string, tick int32) (string, string, error) {
518	return getImplementation().GetTickFeeGrowthOutsideX128(poolPath, tick)
519}
520
521// GetTickInitialized returns whether a tick is initialized.
522// Parameters:
523//   - poolPath: Canonical pool path identifying the pool containing the tick.
524//   - tick: Tick index whose initialization flag is requested.
525//
526// Returns:
527//   - bool: True when the tick has initialized liquidity and outside accumulators.
528//   - error: Non-nil when the pool or tick is not found.
529func GetTickInitialized(poolPath string, tick int32) (bool, error) {
530	return getImplementation().GetTickInitialized(poolPath, tick)
531}
532
533// GetInitializedTicksInRange returns initialized ticks within the given range.
534// Parameters:
535//   - poolPath: Canonical pool path whose ticks are enumerated.
536//   - tickLower: Lower inclusive tick bound for enumeration.
537//   - tickUpper: Upper bound for enumeration; ticks are selected through the
538//     pool's range iterator.
539//
540// Returns:
541//   - []int32: Tick indices that are initialized in the requested range.
542//   - error: Non-nil when poolPath does not identify an existing pool.
543func GetInitializedTicksInRange(poolPath string, tickLower, tickUpper int32) ([]int32, error) {
544	ticks, err := getImplementation().GetInitializedTicksInRange(poolPath, tickLower, tickUpper)
545	if err != nil {
546		return nil, err
547	}
548	return cloneInt32Slice(ticks), nil
549}
550
551// GetTickLiquidityGross returns the total liquidity that references a tick.
552// Parameters:
553//   - poolPath: Canonical pool path identifying the pool containing the tick.
554//   - tick: Tick index whose gross liquidity is requested.
555//
556// Returns:
557//   - string: Gross liquidity referencing the tick, serialized as a base-10
558//     unsigned integer.
559//   - error: Non-nil when the pool or tick is not found.
560func GetTickLiquidityGross(poolPath string, tick int32) (string, error) {
561	return getImplementation().GetTickLiquidityGross(poolPath, tick)
562}
563
564// GetTickLiquidityNet returns the net liquidity change at a tick.
565// Parameters:
566//   - poolPath: Canonical pool path identifying the pool containing the tick.
567//   - tick: Tick index whose net liquidity change is requested.
568//
569// Returns:
570//   - string: Signed net liquidity change at the tick, serialized as a base-10
571//     integer.
572//   - error: Non-nil when the pool or tick is not found.
573func GetTickLiquidityNet(poolPath string, tick int32) (string, error) {
574	return getImplementation().GetTickLiquidityNet(poolPath, tick)
575}
576
577// GetTickSecondsOutside returns seconds spent outside a tick.
578// Parameters:
579//   - poolPath: Canonical pool path identifying the pool containing the tick.
580//   - tick: Tick index whose outside time is requested.
581//
582// Returns:
583//   - uint32: Seconds accumulated outside the tick.
584//   - error: Non-nil when the pool or tick is not found.
585func GetTickSecondsOutside(poolPath string, tick int32) (uint32, error) {
586	return getImplementation().GetTickSecondsOutside(poolPath, tick)
587}
588
589// GetTickSecondsPerLiquidityOutsideX128 returns seconds per liquidity outside a tick.
590// Parameters:
591//   - poolPath: Canonical pool path identifying the pool containing the tick.
592//   - tick: Tick index whose outside accumulator is requested.
593//
594// Returns:
595//   - string: Seconds-per-liquidity outside tick in X128 precision, serialized
596//     as a base-10 unsigned integer.
597//   - error: Non-nil when the pool or tick is not found.
598func GetTickSecondsPerLiquidityOutsideX128(poolPath string, tick int32) (string, error) {
599	return getImplementation().GetTickSecondsPerLiquidityOutsideX128(poolPath, tick)
600}
601
602// GetTickSpacing returns the tick spacing of the pool.
603// Parameters:
604//   - poolPath: Canonical pool path identifying the pool whose spacing is read.
605//
606// Returns:
607//   - int32: Tick spacing associated with the pool's fee tier.
608//   - error: Non-nil when poolPath does not identify an existing pool.
609func GetTickSpacing(poolPath string) (int32, error) {
610	return getImplementation().GetTickSpacing(poolPath)
611}
612
613// GetToken0Path returns the path of token0 in the pool.
614// Parameters:
615//   - poolPath: Canonical pool path identifying the pool to query.
616//
617// Returns:
618//   - string: Canonical token0 contract path stored by the pool.
619//   - error: Non-nil when poolPath does not identify an existing pool.
620func GetToken0Path(poolPath string) (string, error) {
621	return getImplementation().GetToken0Path(poolPath)
622}
623
624// GetToken1Path returns the path of token1 in the pool.
625// Parameters:
626//   - poolPath: Canonical pool path identifying the pool to query.
627//
628// Returns:
629//   - string: Canonical token1 contract path stored by the pool.
630//   - error: Non-nil when poolPath does not identify an existing pool.
631func GetToken1Path(poolPath string) (string, error) {
632	return getImplementation().GetToken1Path(poolPath)
633}
634
635// GetWithdrawalFee returns the current withdrawal fee rate.
636// Returns:
637//   - uint64: Withdrawal fee rate in basis points; zero means no withdrawal
638//     fee is charged.
639func GetWithdrawalFee() uint64 {
640	return getImplementation().GetWithdrawalFee()
641}
642
643// OracleConsult returns the arithmetic mean tick and harmonic mean liquidity
644// over a lookback, following Uniswap V3 OracleLibrary's consult convention.
645// Parameters:
646//   - poolPath: Canonical pool path whose oracle data is queried.
647//   - secondsAgo: Lookback duration in seconds used to compute the time-weighted
648//     values.
649//
650// Returns:
651//   - int32: Arithmetic mean tick over the requested lookback.
652//   - string: Harmonic mean liquidity over the lookback, serialized as a base-10
653//     unsigned integer.
654//   - error: Non-nil when the pool or required observation history is unavailable.
655func OracleConsult(poolPath string, secondsAgo uint32) (int32, string, error) {
656	tick, liquidity, err := getImplementation().OracleConsult(poolPath, secondsAgo)
657	if err != nil {
658		return 0, "", err
659	}
660	return tick, liquidity.ToString(), nil
661}
662
663// Structure getters
664
665// GetTickInfo returns the tick info for a given tick.
666// Parameters:
667//   - poolPath: Canonical pool path identifying the pool containing the tick.
668//   - tick: Tick index whose complete state is requested.
669//
670// Returns:
671//   - TickInfo: Safe copy of the requested tick's liquidity and oracle/fee
672//     accumulator fields.
673//   - error: Non-nil when the pool or tick is not found.
674func GetTickInfo(poolPath string, tick int32) (TickInfo, error) {
675	tickInfo, err := getImplementation().GetTickInfo(poolPath, tick)
676	if err != nil {
677		return TickInfo{}, err
678	}
679
680	return tickInfo.Clone(), nil
681}
682
683// GetTickBitmaps returns the tick bitmap for a given word position.
684// Parameters:
685//   - poolPath: Canonical pool path identifying the pool containing the bitmap.
686//   - wordPos: Signed bitmap word position to read.
687//
688// Returns:
689//   - string: Bitmap word serialized as a base-10 unsigned integer.
690//   - error: Non-nil when the pool or bitmap word is not found.
691func GetTickBitmaps(poolPath string, wordPos int16) (string, error) {
692	return getImplementation().GetTickBitmaps(poolPath, wordPos)
693}
694
695// GetPendingProtocolFees returns the pending protocol fee amount per token path.
696// Returns:
697//   - map[string]int64: Copy of pending protocol fees keyed by token contract path,
698//     with amounts in token base units.
699func GetPendingProtocolFees() map[string]int64 {
700	return cloneStringInt64Map(getImplementation().GetPendingProtocolFees())
701}