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