Skip to content

Commit 49d05e3

Browse files
authored
fix: fix a tick iterator (#610)
1 parent 89672e3 commit 49d05e3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

contract/r/gnoswap/pool/pool_type.gno

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,23 @@ func (p *Pool) Ticks() string {
8181
return "[]"
8282
}
8383

84-
var result []string
85-
p.ticks.Iterate("", "", func(key string, value interface{}) bool {
86-
tick, err := strconv.ParseInt(key, 10, 32)
87-
if err != nil {
88-
return true
89-
}
90-
tickInfo := value.(TickInfo)
91-
result = append(result, ufmt.Sprintf(
84+
tickInfoStrings := []string{}
85+
86+
p.ticks.Iterate("", "", func(tickKey string, tickValue any) bool {
87+
tick, _ := strconv.Atoi(tickKey)
88+
tickInfo := tickValue.(TickInfo)
89+
90+
tickInfoStrings = append(tickInfoStrings, ufmt.Sprintf(
9291
`{"tick":%d,"feeGrowthOutside0X128":"%s","feeGrowthOutside1X128":"%s"}`,
9392
tick,
9493
tickInfo.feeGrowthOutside0X128.ToString(),
9594
tickInfo.feeGrowthOutside1X128.ToString(),
9695
))
97-
return true
96+
97+
return false
9898
})
9999

100-
return "[" + strings.Join(result, ",") + "]"
100+
return "[" + strings.Join(tickInfoStrings, ",") + "]"
101101
}
102102

103103
func (p *Pool) PoolPath() string {

0 commit comments

Comments
 (0)