Skip to content

Commit

Permalink
Fix: don't rebalance if desired amount less than min
Browse files Browse the repository at this point in the history
  • Loading branch information
dwasse committed Mar 13, 2024
1 parent 112197b commit 43436e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 4 additions & 2 deletions services/rfq/relayer/inventory/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,12 @@ func getRebalance(span trace.Span, cfg relconfig.Config, tokens map[int]map[comm
return nil, nil
}

// clip the rebalance amount by the configured min
// filter the rebalance amount by the configured min
minAmount := cfg.GetMinRebalanceAmount(maxTokenData.ChainID, maxTokenData.Addr)
if amount.Cmp(minAmount) < 0 {
amount = minAmount
// no need to rebalance
//nolint:nilnil
return nil, nil
}

// clip the rebalance amount by the configured max
Expand Down
7 changes: 1 addition & 6 deletions services/rfq/relayer/inventory/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,7 @@ func (i *InventoryTestSuite) TestGetRebalance() {
cfgWithMax := getConfig("10", "1000000000")
rebalance, err = inventory.GetRebalance(cfgWithMax, tokens, origin, usdcDataOrigin.Addr)
i.NoError(err)
expected = &inventory.RebalanceData{
OriginMetadata: &usdcDataOrigin,
DestMetadata: &usdcDataDest,
Amount: big.NewInt(1e7),
}
i.Equal(expected, rebalance)
i.Nil(rebalance)

// Set max rebalance amount
cfgWithMax = getConfig("0", "1.1")
Expand Down

0 comments on commit 43436e3

Please sign in to comment.