Skip to content

Commit

Permalink
client/mm: Tracking of CEX balances
Browse files Browse the repository at this point in the history
Tracking of CEX balances for each bot is implemented in a similar fashion
to tracking bot balances on the DEX. A `wrappedCEX` is created for each
bot which behaves as if the entire balance of the CEX is the amount that
is allocated for each bot.
  • Loading branch information
martonp committed Oct 13, 2023
1 parent a78e484 commit 1cffa5b
Show file tree
Hide file tree
Showing 5 changed files with 2,185 additions and 563 deletions.
29 changes: 22 additions & 7 deletions client/mm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,31 @@ type CEXConfig struct {
APISecret string `json:"apiSecret"`
}

// BotCEXCfg is the specifies the CEX that a bot uses and the initial balances
// that should be allocated to the bot on that CEX.
type BotCEXCfg struct {
Name string `json:"name"`
BaseBalanceType BalanceType `json:"baseBalanceType"`
BaseBalance uint64 `json:"baseBalance"`
QuoteBalanceType BalanceType `json:"quoteBalanceType"`
QuoteBalance uint64 `json:"quoteBalance"`
}

// BotConfig is the configuration for a market making bot.
// The balance fields are the initial amounts that will be reserved to use for
// this bot. As the bot trades, the amounts reserved for it will be updated.
type BotConfig struct {
Host string `json:"host"`
BaseAsset uint32 `json:"baseAsset"`
QuoteAsset uint32 `json:"quoteAsset"`

BaseBalanceType BalanceType `json:"baseBalanceType"`
BaseBalance uint64 `json:"baseBalance"`

Host string `json:"host"`
BaseAsset uint32 `json:"baseAsset"`
QuoteAsset uint32 `json:"quoteAsset"`
BaseBalanceType BalanceType `json:"baseBalanceType"`
BaseBalance uint64 `json:"baseBalance"`
QuoteBalanceType BalanceType `json:"quoteBalanceType"`
QuoteBalance uint64 `json:"quoteBalance"`

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

// Only one of the following configs should be set
BasicMMConfig *BasicMarketMakingConfig `json:"basicMarketMakingConfig,omitempty"`
SimpleArbConfig *SimpleArbConfig `json:"simpleArbConfig,omitempty"`
Expand All @@ -63,6 +74,10 @@ func (c *BotConfig) requiresPriceOracle() bool {
return false
}

func (c *BotConfig) requiresCEX() bool {
return c.SimpleArbConfig != nil || c.MMWithCEXConfig != nil
}

func dexMarketID(host string, base, quote uint32) string {
return fmt.Sprintf("%s-%d-%d", host, base, quote)
}
Loading

0 comments on commit 1cffa5b

Please sign in to comment.