Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update KyberPMM swaplimit type #118

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}