Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sunspirit99 committed Dec 19, 2024
1 parent c6a0a72 commit a99a676
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 55 deletions.
22 changes: 17 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module github.com/KyberNetwork/kyberswap-dex-lib

go 1.22.8

toolchain go1.22.9
go 1.23.1

require (
github.com/KyberNetwork/blockchain-toolkit v0.8.2-0.20241123202223-0b77d465adc4
github.com/KyberNetwork/elastic-go-sdk/v2 v2.0.2
github.com/KyberNetwork/ethrpc v0.7.3
github.com/KyberNetwork/iZiSwap-SDK-go v1.1.0
github.com/KyberNetwork/int256 v0.1.4
github.com/KyberNetwork/kutils v0.3.8
github.com/KyberNetwork/logger v0.2.1
github.com/KyberNetwork/msgpack/v5 v5.4.2
github.com/KyberNetwork/pancake-v3-sdk v0.2.0
Expand All @@ -18,7 +17,7 @@ require (
github.com/daoleno/uniswapv3-sdk v0.4.0
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set/v2 v2.6.0
github.com/dgraph-io/ristretto v0.1.1
github.com/dgraph-io/ristretto v0.2.0
github.com/ethereum/go-ethereum v1.14.12
github.com/go-resty/resty/v2 v2.14.0
github.com/goccy/go-json v0.10.3
Expand All @@ -41,8 +40,13 @@ require (

require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/aws/smithy-go v1.15.0 // indirect
github.com/bits-and-blooms/bitset v1.14.3 // indirect
github.com/bytedance/sonic v1.12.1 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/consensys/bavard v0.1.15 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
Expand All @@ -53,28 +57,36 @@ require (
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/golang/glog v1.1.2 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/matryer/is v1.4.1 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/arch v0.9.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/tools v0.25.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
64 changes: 52 additions & 12 deletions go.sum

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pkg/liquidity-source/algebra/integral/pool_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"

"github.com/KyberNetwork/blockchain-toolkit/integer"
"github.com/KyberNetwork/kutils"
"github.com/KyberNetwork/logger"
"github.com/goccy/go-json"
"github.com/machinebox/graphql"
Expand Down Expand Up @@ -147,8 +148,8 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
return nil, metadataBytes, err
}

createdAtTimestamp, ok := new(big.Int).SetString(p.CreatedAtTimestamp, 10)
if !ok {
createdAtTimestamp, err := kutils.Atoi[int64](p.CreatedAtTimestamp)
if err != nil {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v", p.CreatedAtTimestamp, p.ID)
}

Expand All @@ -158,7 +159,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
AmplifiedTvl: 0,
Exchange: d.config.DexID,
Type: DexType,
Timestamp: createdAtTimestamp.Int64(),
Timestamp: createdAtTimestamp,
Reserves: reserves,
Tokens: tokens,
StaticExtra: string(staticExtra),
Expand Down
10 changes: 5 additions & 5 deletions pkg/liquidity-source/algebra/v1/pool_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/big"
"strconv"

"github.com/KyberNetwork/kutils"
"github.com/KyberNetwork/logger"
"github.com/goccy/go-json"
"github.com/machinebox/graphql"
Expand Down Expand Up @@ -137,10 +138,9 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
reserves = append(reserves, zeroString)
}

createdAtTimestamp, ok := new(big.Int).SetString(p.CreatedAtTimestamp, 10)
if !ok {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v",
p.CreatedAtTimestamp, p.ID)
createdAtTimestamp, err := kutils.Atoi[int64](p.CreatedAtTimestamp)
if err != nil {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v", p.CreatedAtTimestamp, p.ID)
}

var newPool = entity.Pool{
Expand All @@ -149,7 +149,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
AmplifiedTvl: 0,
Exchange: d.config.DexID,
Type: DexTypeAlgebraV1,
Timestamp: createdAtTimestamp.Int64(),
Timestamp: createdAtTimestamp,
Reserves: reserves,
Tokens: tokens,
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/source/nuriv2/pools_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/KyberNetwork/blockchain-toolkit/integer"
"github.com/KyberNetwork/ethrpc"
"github.com/KyberNetwork/kutils"
"github.com/KyberNetwork/logger"
"github.com/goccy/go-json"
"github.com/machinebox/graphql"
Expand Down Expand Up @@ -140,10 +141,9 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
reserves = append(reserves, zeroString)
}

createdAtTimestamp, ok := new(big.Int).SetString(p.CreatedAtTimestamp, 10)
if !ok {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v",
p.CreatedAtTimestamp, p.ID)
createdAtTimestamp, err := kutils.Atoi[int64](p.CreatedAtTimestamp)
if err != nil {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v", p.CreatedAtTimestamp, p.ID)
}

var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64)
Expand All @@ -157,7 +157,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
SwapFee: swapFee,
Exchange: d.config.DexID,
Type: DexType,
Timestamp: createdAtTimestamp.Int64(),
Timestamp: createdAtTimestamp,
Reserves: reserves,
Tokens: tokens,
Extra: string(extraBytes),
Expand Down
10 changes: 5 additions & 5 deletions pkg/source/pancakev3/pools_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/KyberNetwork/blockchain-toolkit/integer"
"github.com/KyberNetwork/ethrpc"
"github.com/KyberNetwork/kutils"
"github.com/KyberNetwork/logger"
"github.com/goccy/go-json"
"github.com/machinebox/graphql"
Expand Down Expand Up @@ -149,10 +150,9 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte

var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64)

createdAtTimestamp, ok := new(big.Int).SetString(p.CreatedAtTimestamp, 10)
if !ok {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v",
p.CreatedAtTimestamp, p.ID)
createdAtTimestamp, err := kutils.Atoi[int64](p.CreatedAtTimestamp)
if err != nil {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v", p.CreatedAtTimestamp, p.ID)
}

extraBytes, _ := json.Marshal(extraField)
Expand All @@ -164,7 +164,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
SwapFee: swapFee,
Exchange: d.config.DexID,
Type: DexTypePancakeV3,
Timestamp: createdAtTimestamp.Int64(),
Timestamp: createdAtTimestamp,
Reserves: reserves,
Tokens: tokens,
Extra: string(extraBytes),
Expand Down
10 changes: 5 additions & 5 deletions pkg/source/ramsesv2/pools_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/KyberNetwork/blockchain-toolkit/integer"
"github.com/KyberNetwork/ethrpc"
"github.com/KyberNetwork/kutils"
"github.com/KyberNetwork/logger"
"github.com/goccy/go-json"
"github.com/machinebox/graphql"
Expand Down Expand Up @@ -142,10 +143,9 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte

var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64)

createdAtTimestamp, ok := new(big.Int).SetString(p.CreatedAtTimestamp, 10)
if !ok {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v",
p.CreatedAtTimestamp, p.ID)
createdAtTimestamp, err := kutils.Atoi[int64](p.CreatedAtTimestamp)
if err != nil {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v", p.CreatedAtTimestamp, p.ID)
}

extraBytes, _ := json.Marshal(extraField)
Expand All @@ -157,7 +157,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
SwapFee: swapFee,
Exchange: d.config.DexID,
Type: DexTypeRamsesV2,
Timestamp: createdAtTimestamp.Int64(),
Timestamp: createdAtTimestamp,
Reserves: reserves,
Tokens: tokens,
Extra: string(extraBytes),
Expand Down
10 changes: 5 additions & 5 deletions pkg/source/slipstream/pools_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/KyberNetwork/blockchain-toolkit/integer"
"github.com/KyberNetwork/ethrpc"
"github.com/KyberNetwork/kutils"
"github.com/KyberNetwork/logger"
"github.com/goccy/go-json"
"github.com/machinebox/graphql"
Expand Down Expand Up @@ -148,10 +149,9 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
reserves = append(reserves, zeroString)
}

createdAtTimestamp, ok := new(big.Int).SetString(p.CreatedAtTimestamp, 10)
if !ok {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v",
p.CreatedAtTimestamp, p.ID)
createdAtTimestamp, err := kutils.Atoi[int64](p.CreatedAtTimestamp)
if err != nil {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v", p.CreatedAtTimestamp, p.ID)
}

extraBytes, _ := json.Marshal(extraField)
Expand All @@ -163,7 +163,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
SwapFee: 0,
Exchange: d.config.DexID,
Type: DexType,
Timestamp: createdAtTimestamp.Int64(),
Timestamp: createdAtTimestamp,
Reserves: reserves,
Tokens: tokens,
Extra: string(extraBytes),
Expand Down
10 changes: 5 additions & 5 deletions pkg/source/solidly-v3/pools_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/KyberNetwork/blockchain-toolkit/integer"
"github.com/KyberNetwork/ethrpc"
"github.com/KyberNetwork/kutils"
"github.com/KyberNetwork/logger"
"github.com/goccy/go-json"
"github.com/machinebox/graphql"
Expand Down Expand Up @@ -142,10 +143,9 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte

var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64)

createdAtTimestamp, ok := new(big.Int).SetString(p.CreatedAtTimestamp, 10)
if !ok {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v",
p.CreatedAtTimestamp, p.ID)
createdAtTimestamp, err := kutils.Atoi[int64](p.CreatedAtTimestamp)
if err != nil {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v", p.CreatedAtTimestamp, p.ID)
}

extraBytes, _ := json.Marshal(extraField)
Expand All @@ -157,7 +157,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
SwapFee: swapFee,
Exchange: d.config.DexID,
Type: DexTypeSolidlyV3,
Timestamp: createdAtTimestamp.Int64(),
Timestamp: createdAtTimestamp,
Reserves: reserves,
Tokens: tokens,
Extra: string(extraBytes),
Expand Down
10 changes: 5 additions & 5 deletions pkg/source/uniswapv3/pools_list_updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/KyberNetwork/blockchain-toolkit/integer"
"github.com/KyberNetwork/ethrpc"
"github.com/KyberNetwork/kutils"
"github.com/KyberNetwork/logger"
"github.com/goccy/go-json"
"github.com/machinebox/graphql"
Expand Down Expand Up @@ -149,10 +150,9 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte

var swapFee, _ = strconv.ParseFloat(p.FeeTier, 64)

createdAtTimestamp, ok := new(big.Int).SetString(p.CreatedAtTimestamp, 10)
if !ok {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v",
p.CreatedAtTimestamp, p.ID)
createdAtTimestamp, err := kutils.Atoi[int64](p.CreatedAtTimestamp)
if err != nil {
return nil, metadataBytes, fmt.Errorf("invalid CreatedAtTimestamp: %v, pool: %v", p.CreatedAtTimestamp, p.ID)
}

extraBytes, _ := json.Marshal(extraField)
Expand All @@ -164,7 +164,7 @@ func (d *PoolsListUpdater) GetNewPools(ctx context.Context, metadataBytes []byte
SwapFee: swapFee,
Exchange: d.config.DexID,
Type: DexTypeUniswapV3,
Timestamp: createdAtTimestamp.Int64(),
Timestamp: createdAtTimestamp,
Reserves: reserves,
Tokens: tokens,
Extra: string(extraBytes),
Expand Down

0 comments on commit a99a676

Please sign in to comment.