Skip to content
Open
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
4 changes: 2 additions & 2 deletions protocol/lib/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"math"
"math/big"
"sort"
"slices"

"golang.org/x/exp/constraints"
)
Expand Down Expand Up @@ -182,7 +182,7 @@ func Median[V uint64 | uint32 | int64 | int32](input []V) (V, error) {

inputCopy := make([]V, l)
copy(inputCopy, input)
sort.Slice(inputCopy, func(i, j int) bool { return inputCopy[i] < inputCopy[j] })
slices.Sort(inputCopy)

midIdx := l / 2

Expand Down
6 changes: 2 additions & 4 deletions protocol/x/clob/keeper/grpc_query_leverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package keeper

import (
"context"
"sort"
"slices"

errorsmod "cosmossdk.io/errors"
"github.com/dydxprotocol/v4-chain/protocol/lib"
Expand Down Expand Up @@ -37,9 +37,7 @@ func (k Keeper) Leverage(
for perpetualId := range leverageMap {
keys = append(keys, perpetualId)
}
sort.Slice(keys, func(i, j int) bool {
return keys[i] < keys[j]
})
slices.Sort(keys)

clobPairLeverage := make([]*types.ClobPairLeverageInfo, 0, len(leverageMap))
for _, perpetualId := range keys {
Expand Down
3 changes: 2 additions & 1 deletion protocol/x/perpetuals/keeper/perpetual.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/big"
"math/rand"
"slices"
"sort"
"time"

Expand Down Expand Up @@ -615,7 +616,7 @@ func (k Keeper) GetRemoveSampleTailsFunc(

end := int64(len(premiums)) - topRemoval

sort.Slice(premiums, func(i, j int) bool { return premiums[i] < premiums[j] })
slices.Sort(premiums)

return premiums[bottomRemoval:end]
}
Expand Down
6 changes: 2 additions & 4 deletions protocol/x/prices/client/testutil/util.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package testutil

import (
"sort"
"slices"

"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types"
)
Expand All @@ -12,9 +12,7 @@ func GetTickersSortedByMarketId(marketToMarketConfig map[uint32]types.MarketConf
for marketId := range marketToMarketConfig {
marketIds = append(marketIds, marketId)
}
sort.Slice(marketIds, func(i, j int) bool {
return marketIds[i] < marketIds[j]
})
slices.Sort(marketIds)

// Get a list of tickers sorted by their corresponding `marketId`.
tickers := make([]string, 0, len(marketToMarketConfig))
Expand Down