Skip to content

Commit

Permalink
add json marshaler example
Browse files Browse the repository at this point in the history
  • Loading branch information
linhbkhn95 committed Jul 22, 2024
1 parent 05f782d commit 468431a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions example/jsonmarshal/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package main

import (
"fmt"

"github.com/linhbkhn95/int256"
)

type PoolState struct {
Price *int256.Int
Tick int64
}

func main() {
state1 := &PoolState{
Price: fromString("100000000000000000000000"),
Tick: 1000,
}
state2 := &PoolState{
Price: fromString("-100000000000000000000000"),
Tick: 1000,
}

fmt.Println("state1", state1)
fmt.Println("state2", state2)

}

func fromString(str string) *int256.Int {
i, _ := new(int256.Int).SetString(str)
return i
}

0 comments on commit 468431a

Please sign in to comment.