getter.gno
10.55 Kb · 284 lines
1package pool
2
3// GetPoolCount returns the total number of pools.
4func GetPoolCount() int {
5 return getImplementation().GetPoolCount()
6}
7
8// GetPoolPaths returns a paginated list of pool paths.
9func GetPoolPaths(offset, count int) []string {
10 return cloneStringSlice(getImplementation().GetPoolPaths(offset, count))
11}
12
13// ExistsPoolPath checks if a pool exists at the given path.
14func ExistsPoolPath(poolPath string) bool {
15 return getImplementation().ExistsPoolPath(poolPath)
16}
17
18// GetBalances returns the balances of the pool.
19func GetBalances(poolPath string) (int64, int64) {
20 return getImplementation().GetBalanceToken0(poolPath), getImplementation().GetBalanceToken1(poolPath)
21}
22
23// GetBalanceToken0 returns the balance of token0 in the pool.
24func GetBalanceToken0(poolPath string) int64 {
25 return getImplementation().GetBalanceToken0(poolPath)
26}
27
28// GetBalanceToken1 returns the balance of token1 in the pool.
29func GetBalanceToken1(poolPath string) int64 {
30 return getImplementation().GetBalanceToken1(poolPath)
31}
32
33// GetFee returns the fee tier of the pool.
34func GetFee(poolPath string) uint32 {
35 return getImplementation().GetFee(poolPath)
36}
37
38// GetFeeAmountTickSpacings returns all fee tier to tick spacing mappings.
39func GetFeeAmountTickSpacings() map[uint32]int32 {
40 return cloneFeeAmountTickSpacings(getImplementation().GetFeeAmountTickSpacings())
41}
42
43// GetFeeAmountTickSpacing returns the tick spacing for a given fee tier.
44func GetFeeAmountTickSpacing(fee uint32) (spacing int32) {
45 return getImplementation().GetFeeAmountTickSpacing(fee)
46}
47
48// GetFeeGrowthGlobal0X128 returns the global fee growth for token0.
49func GetFeeGrowthGlobal0X128(poolPath string) string {
50 return getImplementation().GetFeeGrowthGlobal0X128(poolPath).ToString()
51}
52
53// GetFeeGrowthGlobal1X128 returns the global fee growth for token1.
54func GetFeeGrowthGlobal1X128(poolPath string) string {
55 return getImplementation().GetFeeGrowthGlobal1X128(poolPath).ToString()
56}
57
58// GetFeeGrowthGlobalX128 returns the global fee growth for both tokens.
59func GetFeeGrowthGlobalX128(poolPath string) (string, string) {
60 fg0, fg1 := getImplementation().GetFeeGrowthGlobalX128(poolPath)
61 return fg0.ToString(), fg1.ToString()
62}
63
64// GetLiquidity returns the current liquidity in the pool.
65func GetLiquidity(poolPath string) string {
66 return getImplementation().GetLiquidity(poolPath).ToString()
67}
68
69// GetObservation returns observation data for calculating time-weighted averages.
70func GetObservation(poolPath string, secondsAgo int64) (tickCumulative int64, liquidityCumulative, secondsPerLiquidityCumulativeX128 string, blockTimestamp int64) {
71 return getImplementation().GetObservation(poolPath, secondsAgo)
72}
73
74// GetPoolCreationFee returns the current pool creation fee.
75func GetPoolCreationFee() int64 {
76 return getImplementation().GetPoolCreationFee()
77}
78
79// GetPositionFeeGrowthInside0LastX128 returns the last recorded fee growth inside for token0.
80func GetPositionFeeGrowthInside0LastX128(poolPath, key string) string {
81 return getImplementation().GetPositionFeeGrowthInside0LastX128(poolPath, key)
82}
83
84// GetPositionFeeGrowthInside1LastX128 returns the last recorded fee growth inside for token1.
85func GetPositionFeeGrowthInside1LastX128(poolPath, key string) string {
86 return getImplementation().GetPositionFeeGrowthInside1LastX128(poolPath, key)
87}
88
89// GetPositionFeeGrowthInsideLastX128 returns the last recorded fee growth inside for both tokens.
90func GetPositionFeeGrowthInsideLastX128(poolPath, key string) (string, string) {
91 return getImplementation().GetPositionFeeGrowthInsideLastX128(poolPath, key)
92}
93
94// GetPoolPositionCount returns the number of positions in a pool.
95func GetPoolPositionCount(poolPath string) int {
96 return getImplementation().GetPoolPositionCount(poolPath)
97}
98
99// GetPoolPositionKeys returns a paginated list of position keys in a pool.
100func GetPoolPositionKeys(poolPath string, offset, count int) []string {
101 return cloneStringSlice(getImplementation().GetPoolPositionKeys(poolPath, offset, count))
102}
103
104// GetPositionLiquidity returns the liquidity of a position.
105func GetPositionLiquidity(poolPath, key string) string {
106 return getImplementation().GetPositionLiquidity(poolPath, key)
107}
108
109// GetPositionTokensOwed0 returns the amount of token0 owed to a position.
110func GetPositionTokensOwed0(poolPath, key string) int64 {
111 return getImplementation().GetPositionTokensOwed0(poolPath, key)
112}
113
114// GetPositionTokensOwed1 returns the amount of token1 owed to a position.
115func GetPositionTokensOwed1(poolPath, key string) int64 {
116 return getImplementation().GetPositionTokensOwed1(poolPath, key)
117}
118
119// GetPositionTokensOwedInfos returns the amount of tokens owed for both tokens.
120func GetPositionTokensOwed(poolPath, key string) (int64, int64) {
121 return getImplementation().GetPositionTokensOwed0(poolPath, key), getImplementation().GetPositionTokensOwed1(poolPath, key)
122}
123
124// GetProtocolFeesToken0 returns accumulated protocol fees for token0.
125func GetProtocolFeesToken0(poolPath string) int64 {
126 return getImplementation().GetProtocolFeesToken0(poolPath)
127}
128
129// GetProtocolFeesToken1 returns accumulated protocol fees for token1.
130func GetProtocolFeesToken1(poolPath string) int64 {
131 return getImplementation().GetProtocolFeesToken1(poolPath)
132}
133
134// GetProtocolFeesTokens returns the accumulated protocol fees for both tokens.
135func GetProtocolFeesTokens(poolPath string) (int64, int64) {
136 return getImplementation().GetProtocolFeesToken0(poolPath), getImplementation().GetProtocolFeesToken1(poolPath)
137}
138
139// GetSlot0FeeProtocol returns the protocol fee rate from slot0.
140func GetSlot0FeeProtocol(poolPath string) uint8 {
141 return getImplementation().GetSlot0FeeProtocol(poolPath)
142}
143
144// GetSlot0SqrtPriceX96 returns the current sqrt price from slot0.
145func GetSlot0SqrtPriceX96(poolPath string) string {
146 return getImplementation().GetSlot0SqrtPriceX96(poolPath).ToString()
147}
148
149// GetSlot0Tick returns the current tick from slot0.
150func GetSlot0Tick(poolPath string) int32 {
151 return getImplementation().GetSlot0Tick(poolPath)
152}
153
154// GetSlot0Unlocked returns the locked status from slot0.
155func GetSlot0Unlocked(poolPath string) bool {
156 return getImplementation().GetSlot0Unlocked(poolPath)
157}
158
159// GetTickCumulativeOutside returns the tick cumulative value outside a tick.
160func GetTickCumulativeOutside(poolPath string, tick int32) int64 {
161 return getImplementation().GetTickCumulativeOutside(poolPath, tick)
162}
163
164// GetTickFeeGrowthOutside0X128 returns fee growth outside for token0 at a tick.
165func GetTickFeeGrowthOutside0X128(poolPath string, tick int32) string {
166 return getImplementation().GetTickFeeGrowthOutside0X128(poolPath, tick)
167}
168
169// GetTickFeeGrowthOutside1X128 returns fee growth outside for token1 at a tick.
170func GetTickFeeGrowthOutside1X128(poolPath string, tick int32) string {
171 return getImplementation().GetTickFeeGrowthOutside1X128(poolPath, tick)
172}
173
174// GetTickFeeGrowthOutsideX128 returns fee growth outside for both tokens at a tick.
175func GetTickFeeGrowthOutsideX128(poolPath string, tick int32) (string, string) {
176 return getImplementation().GetTickFeeGrowthOutsideX128(poolPath, tick)
177}
178
179// GetTickInitialized returns whether a tick is initialized.
180func GetTickInitialized(poolPath string, tick int32) bool {
181 return getImplementation().GetTickInitialized(poolPath, tick)
182}
183
184// GetInitializedTicksInRange returns initialized ticks within the given range.
185func GetInitializedTicksInRange(poolPath string, tickLower, tickUpper int32) []int32 {
186 return cloneInt32Slice(getImplementation().GetInitializedTicksInRange(poolPath, tickLower, tickUpper))
187}
188
189// GetTickLiquidityGross returns the total liquidity that references a tick.
190func GetTickLiquidityGross(poolPath string, tick int32) string {
191 return getImplementation().GetTickLiquidityGross(poolPath, tick)
192}
193
194// GetTickLiquidityNet returns the net liquidity change at a tick.
195func GetTickLiquidityNet(poolPath string, tick int32) string {
196 return getImplementation().GetTickLiquidityNet(poolPath, tick)
197}
198
199// GetTickSecondsOutside returns seconds spent outside a tick.
200func GetTickSecondsOutside(poolPath string, tick int32) uint32 {
201 return getImplementation().GetTickSecondsOutside(poolPath, tick)
202}
203
204// GetTickSecondsPerLiquidityOutsideX128 returns seconds per liquidity outside a tick.
205func GetTickSecondsPerLiquidityOutsideX128(poolPath string, tick int32) string {
206 return getImplementation().GetTickSecondsPerLiquidityOutsideX128(poolPath, tick)
207}
208
209// GetTickSpacing returns the tick spacing of the pool.
210func GetTickSpacing(poolPath string) int32 {
211 return getImplementation().GetTickSpacing(poolPath)
212}
213
214// GetToken0Path returns the path of token0 in the pool.
215func GetToken0Path(poolPath string) string {
216 return getImplementation().GetToken0Path(poolPath)
217}
218
219// GetToken1Path returns the path of token1 in the pool.
220func GetToken1Path(poolPath string) string {
221 return getImplementation().GetToken1Path(poolPath)
222}
223
224// GetWithdrawalFee returns the current withdrawal fee rate.
225func GetWithdrawalFee() uint64 {
226 return getImplementation().GetWithdrawalFee()
227}
228
229// GetTWAP returns the time-weighted average price for a pool.
230// Returns arithmetic mean tick and harmonic mean liquidity over the time period.
231func GetTWAP(poolPath string, secondsAgo uint32) (int32, string, error) {
232 tick, liquidity, err := getImplementation().GetTWAP(poolPath, secondsAgo)
233 if err != nil {
234 return 0, "", err
235 }
236 return tick, liquidity.ToString(), nil
237}
238
239// Structure getters
240
241// GetPool returns a copy of the pool for the given token pair and fee tier.
242func GetPool(token0Path, token1Path string, fee uint32) (*Pool, error) {
243 pool, err := getImplementation().GetPool(token0Path, token1Path, fee)
244 if err != nil {
245 return nil, err
246 }
247
248 return clonePool(pool), nil
249}
250
251// GetTickInfo returns the tick info for a given tick.
252func GetTickInfo(poolPath string, tick int32) (TickInfo, error) {
253 tickInfo, err := getImplementation().GetTickInfo(poolPath, tick)
254 if err != nil {
255 return TickInfo{}, err
256 }
257
258 return tickInfo.Clone(), nil
259}
260
261// GetTickBitmaps returns the tick bitmap for a given word position.
262func GetTickBitmaps(poolPath string, wordPos int16) (string, error) {
263 return getImplementation().GetTickBitmaps(poolPath, wordPos)
264}
265
266// GetPosition returns the position info for a given key.
267func GetPosition(poolPath, key string) (PositionInfo, error) {
268 positionInfo, err := getImplementation().GetPosition(poolPath, key)
269 if err != nil {
270 return PositionInfo{}, err
271 }
272
273 return clonePositionInfo(positionInfo), nil
274}
275
276// GetObservationState returns the observation state for a given pool path.
277func GetObservationState(poolPath string) (*ObservationState, error) {
278 observationState, err := getImplementation().GetObservationState(poolPath)
279 if err != nil {
280 return nil, err
281 }
282
283 return cloneObservationState(observationState), nil
284}