Skip to content

Commit

Permalink
Update KyberPMM swaplimit type (#118)
Browse files Browse the repository at this point in the history
* Update KyberPMM swaplimit type

* Fix lint
  • Loading branch information
chrisngyn authored Feb 7, 2025
1 parent de1a9fa commit a4bbf69
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
9 changes: 6 additions & 3 deletions pkg/hashset/hashset.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package hashset

import "golang.org/x/exp/maps"
import (
"maps"
"slices"
)

type HashSet[K comparable] struct {
m map[K]struct{}
Expand Down Expand Up @@ -31,9 +34,9 @@ func (h *HashSet[K]) Size() int {
}

func (h *HashSet[K]) Clear() {
maps.Clear(h.m)
clear(h.m)
}

func (h *HashSet[K]) Keys() []K {
return maps.Keys(h.m)
return slices.Collect(maps.Keys(h.m))
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package fusionorder
import (
"errors"
"math"
"slices"

"github.com/ethereum/go-ethereum/common"
"golang.org/x/exp/slices"
)

var (
Expand Down
16 changes: 11 additions & 5 deletions pkg/poolsimulators/poolsimulators.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,24 @@ func PoolSimulatorFromPool(pool ksent.Pool, chainID uint) (pkgpool.IPoolSimulato
func newSwapLimit(dex string, limit map[string]*big.Int) pkgpool.SwapLimit {
switch dex {
case pooltypes.PoolTypes.Synthetix,
pooltypes.PoolTypes.LimitOrder,
pooltypes.PoolTypes.NativeV1,
pooltypes.PoolTypes.Dexalot,
pooltypes.PoolTypes.RingSwap,
pooltypes.PoolTypes.MxTrading,
pooltypes.PoolTypes.LO1inch:
pooltypes.PoolTypes.LO1inch,
pooltypes.PoolTypes.KyberPMM:
return swaplimit.NewInventory(dex, limit)

case pooltypes.PoolTypes.LimitOrder:
return swaplimit.NewInventoryWithAllowedSenders(
dex,
limit,
// here just for usecase of kyberswap only, there are some client have priority private limit orders.
"",
)

case pooltypes.PoolTypes.Bebop:
return swaplimit.NewSingleSwapLimit(dex)

case pooltypes.PoolTypes.KyberPMM:
return swaplimit.NewSwappedInventory(dex, limit)
}

return nil
Expand Down
4 changes: 1 addition & 3 deletions x/syncmap/syncmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package syncmap

import (
"sync"

"golang.org/x/exp/maps"
)

type SyncMap[K comparable, V any] struct {
Expand Down Expand Up @@ -83,5 +81,5 @@ func (m *SyncMap[K, V]) Clears() {
m.rw.Lock()
defer m.rw.Unlock()

maps.Clear(m.data)
clear(m.data)
}

0 comments on commit a4bbf69

Please sign in to comment.