event_info.gno
1.18 Kb · 42 lines
1package pool
2
3import (
4 "gno.land/p/gnoswap/utils"
5
6 pl "gno.land/r/gnoswap/pool"
7)
8
9type tickEventInfo struct {
10 tickID int32
11 tickInfo pl.TickInfo
12}
13
14// Collect tick info for event
15// format key is:
16// - t: tick
17// - lg: liquidity gross
18// - ln: liquidity net
19// - fg0: fee growth outside 0
20// - fg1: fee growth outside 1
21// - tco: tick cumulative outside
22// - spl: seconds per liquidity outside x128
23// - so: seconds outside
24// - i: initialized
25func (t *tickEventInfo) ToString() string {
26 return "{\"t\":" + utils.FormatInt(t.tickID) +
27 ",\"lg\":\"" + t.tickInfo.LiquidityGross() + "\"" +
28 ",\"ln\":\"" + t.tickInfo.LiquidityNet() + "\"" +
29 ",\"fg0\":\"" + t.tickInfo.FeeGrowthOutside0X128() + "\"" +
30 ",\"fg1\":\"" + t.tickInfo.FeeGrowthOutside1X128() + "\"" +
31 ",\"tco\":\"" + utils.FormatInt(t.tickInfo.TickCumulativeOutside()) + "\"" +
32 ",\"spl\":\"" + t.tickInfo.SecondsPerLiquidityOutsideX128() + "\"" +
33 ",\"so\":\"" + utils.FormatUint(t.tickInfo.SecondsOutside()) + "\"" +
34 ",\"i\":\"" + utils.FormatBool(t.tickInfo.Initialized()) + "\"}"
35}
36
37func NewTickEventInfo(tickID int32, tickInfo pl.TickInfo) *tickEventInfo {
38 return &tickEventInfo{
39 tickID: tickID,
40 tickInfo: tickInfo,
41 }
42}