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

mm: Account for mult split buffer when making MultiTrade #3156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
18 changes: 18 additions & 0 deletions client/mm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mm
import (
"encoding/json"
"fmt"
"strconv"
)

// MarketMakingConfig is the overall configuration of the market maker.
Expand Down Expand Up @@ -127,6 +128,23 @@ func (c *BotConfig) requiresCEX() bool {
return c.SimpleArbConfig != nil || c.ArbMarketMakerConfig != nil
}

// multiSplitBuffer returns the additional buffer to add to the order size
// when doing a multi-split. This only applies to the quote asset.
func (c *BotConfig) multiSplitBuffer() float64 {
if c.QuoteWalletOptions == nil {
return 0
}
multiSplitBuffer, ok := c.QuoteWalletOptions["multisplitbuffer"]
if !ok {
return 0
}
multiSplitBufferFloat, err := strconv.ParseFloat(multiSplitBuffer, 64)
if err != nil {
return 0
}
return multiSplitBufferFloat
}

// maxPlacements returns the max amount of placements this bot will place on
// either side of the market in an epoch.
func (c *BotConfig) maxPlacements() (buy, sell uint32) {
Expand Down
7 changes: 6 additions & 1 deletion client/mm/exchange_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,14 +1218,19 @@ func (u *unifiedExchangeAdaptor) multiTrade(

rateCausesSelfMatch := u.rateCausesSelfMatchFunc(sell)

multiSplitBuffer := u.botCfg().multiSplitBuffer()

fundingReq := func(rate, lots, counterTradeRate uint64) (dexReq map[uint32]uint64, cexReq uint64) {
qty := u.lotSize * lots
swapFees := fees.Swap * lots
if !sell {
qty = calc.BaseToQuote(rate, qty)
qty = uint64(math.Round(float64(qty) * (100 + multiSplitBuffer) / 100))
swapFees = uint64(math.Round(float64(swapFees) * (100 + multiSplitBuffer) / 100))
}
dexReq = make(map[uint32]uint64)
dexReq[fromID] += qty
dexReq[fromFeeID] += fees.Swap * lots
dexReq[fromFeeID] += swapFees
if u.isAccountLocker(fromID) {
dexReq[fromFeeID] += fees.Refund * lots
}
Expand Down
Loading
Loading