Skip to content

Commit 525e337

Browse files
committed
Less sensitive error handling for failed swap
1 parent dcaba17 commit 525e337

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

x/protorev/keeper/protorev.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (k Keeper) GetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch str
171171
func (k Keeper) GetPoolForDenomPairNoOrder(ctx sdk.Context, tokenA, tokenB string) (uint64, error) {
172172
poolId, err := k.GetPoolForDenomPair(ctx, tokenA, tokenB)
173173
if err != nil {
174-
if errors.Is(err, types.NoPoolForDenomPairError{BaseDenom: tokenA, MatchDenom: tokenB}) {
174+
if errors.Is(err, types.NoPoolForDenomPairError{}) {
175175
// Attempt changing base and match denoms.
176176
poolId, err = k.GetPoolForDenomPair(ctx, tokenB, tokenA)
177177
if err != nil {

x/protorev/types/errors.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ func (e NoPoolForDenomPairError) Error() string {
1414
return fmt.Sprintf("highest liquidity pool between base %s and match denom %s not found", e.BaseDenom, e.MatchDenom)
1515
}
1616

17+
// Is implements error matching for errors.Is to match any NoPoolForDenomPairError regardless of field values
18+
func (e NoPoolForDenomPairError) Is(target error) bool {
19+
_, ok := target.(NoPoolForDenomPairError)
20+
return ok
21+
}
22+
1723
var ErrRouteDoubleContainsPool = errors.New("cannot be trading on the same pool twice")

0 commit comments

Comments
 (0)