Skip to content

Commit

Permalink
client/mm: Move shared logic from bots to unifiedExchangeAdaptor
Browse files Browse the repository at this point in the history
Some logic including grouping trades by placement, tracking fiat rates,
and tracking order fees were shared between strategies. These are moved
to the unifiedExchangeAdaptor.
  • Loading branch information
martonp committed Feb 20, 2024
1 parent aed1270 commit 2a107f8
Show file tree
Hide file tree
Showing 18 changed files with 4,195 additions and 5,952 deletions.
43 changes: 24 additions & 19 deletions client/mm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,28 @@ type CEXConfig struct {
APISecret string `json:"apiSecret"`
}

// BotCEXCfg specifies the CEX that a bot uses and the initial balances
// that should be allocated to the bot on that CEX.
// AutoRebalanceConfig determines how the bot will automatically rebalance its
// assets between the CEX and DEX. If the base or quote asset dips below the
// minimum amount, a transfer will take place, but only if both balances can be
// brought above the minimum amount and the transfer amount would be above the
// minimum transfer amount.
type AutoRebalanceConfig struct {
MinBaseAmt uint64 `json:"minBaseAmt"`
MinBaseTransfer uint64 `json:"minBaseTransfer"`
MinQuoteAmt uint64 `json:"minQuoteAmt"`
MinQuoteTransfer uint64 `json:"minQuoteTransfer"`
}

// BotCEXCfg specifies the CEX that a bot uses, the initial balances
// that should be allocated to the bot on that CEX, and the configuration
// for automatically rebalancing between the CEX and DEX.
type BotCEXCfg struct {
Name string `json:"name"`
BaseBalanceType BalanceType `json:"baseBalanceType"`
BaseBalance uint64 `json:"baseBalance"`
QuoteBalanceType BalanceType `json:"quoteBalanceType"`
QuoteBalance uint64 `json:"quoteBalance"`
Name string `json:"name"`
BaseBalanceType BalanceType `json:"baseBalanceType"`
BaseBalance uint64 `json:"baseBalance"`
QuoteBalanceType BalanceType `json:"quoteBalanceType"`
QuoteBalance uint64 `json:"quoteBalance"`
AutoRebalance *AutoRebalanceConfig `json:"autoRebalance"`
}

// BotConfig is the configuration for a market making bot.
Expand All @@ -66,6 +80,9 @@ type BotConfig struct {
QuoteFeeAssetBalanceType BalanceType `json:"quoteFeeAssetBalanceType"`
QuoteFeeAssetBalance uint64 `json:"quoteFeeAssetBalance"`

BaseWalletOptions map[string]string `json:"baseWalletOptions"`
QuoteWalletOptions map[string]string `json:"quoteWalletOptions"`

// Only applicable for arb bots.
CEXCfg *BotCEXCfg `json:"cexCfg"`

Expand All @@ -91,15 +108,3 @@ func (c *BotConfig) requiresCEX() bool {
func dexMarketID(host string, base, quote uint32) string {
return fmt.Sprintf("%s-%d-%d", host, base, quote)
}

// AutoRebalanceConfig determines how the bot will automatically rebalance its
// assets between the CEX and DEX. If the base or quote asset dips below the
// minimum amount, a transfer will take place, but only if both balances can be
// brought above the minimum amount and the transfer amount would be above the
// minimum transfer amount.
type AutoRebalanceConfig struct {
MinBaseAmt uint64 `json:"minBaseAmt"`
MinBaseTransfer uint64 `json:"minBaseTransfer"`
MinQuoteAmt uint64 `json:"minQuoteAmt"`
MinQuoteTransfer uint64 `json:"minQuoteTransfer"`
}
Loading

0 comments on commit 2a107f8

Please sign in to comment.