+ {{- /* ALLOW EXTERNAL TRANSFERS */ -}}
+
+
+ {{- /* INTERNAL TRANSFERS ONLY */ -}}
+
diff --git a/client/webserver/site/src/js/mm.ts b/client/webserver/site/src/js/mm.ts
index a5b048239b..dc39980b41 100644
--- a/client/webserver/site/src/js/mm.ts
+++ b/client/webserver/site/src/js/mm.ts
@@ -8,9 +8,10 @@ import {
StartConfig,
OrderPlacement,
AutoRebalanceConfig,
- CEXNotification,
EpochReportNote,
- CEXProblemsNote
+ CEXProblemsNote,
+ UIConfig,
+ CEXNotification
} from './registry'
import {
MM,
@@ -760,7 +761,7 @@ class Bot extends BotMarket {
}
async start () {
- const { page, alloc, baseID, quoteID, host, cexName, cfg: { uiConfig: { cexRebalance } } } = this
+ const { page, alloc, baseID, quoteID, host, cexName, cfg: { uiConfig } } = this
Doc.hide(page.errMsg)
if (cexName && !app().mmStatus.cexes[cexName]?.connected) {
@@ -780,7 +781,8 @@ class Bot extends BotMarket {
host: host,
alloc: alloc
}
- if (cexName && cexRebalance) startConfig.autoRebalance = this.autoRebalanceSettings()
+
+ startConfig.autoRebalance = this.autoRebalanceSettings(uiConfig)
try {
app().log('mm', 'starting mm bot', startConfig)
@@ -794,7 +796,7 @@ class Bot extends BotMarket {
this.hideAllocationDialog()
}
- autoRebalanceSettings (): AutoRebalanceConfig {
+ minTransferAmounts (): [number, number] {
const {
proj: { bProj, qProj, alloc }, baseFeeID, quoteFeeID, cfg: { uiConfig: { baseConfig, quoteConfig } },
baseID, quoteID, cexName, mktID
@@ -819,7 +821,22 @@ class Bot extends BotMarket {
const minBaseTransfer = Math.round(minB + baseConfig.transferFactor * (maxB - minB))
const [minQ, maxQ] = [mkt.quoteMinWithdraw, Math.max(mkt.quoteMinWithdraw * 2, maxQuote)]
const minQuoteTransfer = Math.round(minQ + quoteConfig.transferFactor * (maxQ - minQ))
- return { minBaseTransfer, minQuoteTransfer }
+ return [minBaseTransfer, minQuoteTransfer]
+ }
+
+ autoRebalanceSettings (uiCfg: UIConfig) : AutoRebalanceConfig | undefined {
+ if (!uiCfg.cexRebalance && !uiCfg.internalTransfers) return
+ const cfg : AutoRebalanceConfig = {
+ minBaseTransfer: 0,
+ minQuoteTransfer: 0,
+ internalOnly: !uiCfg.cexRebalance
+ }
+ if (uiCfg.cexRebalance) {
+ const [minBaseTransfer, minQuoteTransfer] = this.minTransferAmounts()
+ cfg.minBaseTransfer = minBaseTransfer
+ cfg.minQuoteTransfer = minQuoteTransfer
+ }
+ return cfg
}
reconfigure () {
diff --git a/client/webserver/site/src/js/mmsettings.ts b/client/webserver/site/src/js/mmsettings.ts
index 0a5e0f44e5..c921d3603a 100644
--- a/client/webserver/site/src/js/mmsettings.ts
+++ b/client/webserver/site/src/js/mmsettings.ts
@@ -179,6 +179,7 @@ interface ConfigState {
driftTolerance: number
orderPersistence: number // epochs
cexRebalance: boolean
+ internalTransfers: boolean
disabled: boolean
buyPlacements: OrderPlacement[]
sellPlacements: OrderPlacement[]
@@ -295,6 +296,8 @@ export default class MarketMakerSettingsPage extends BasePage {
Doc.bind(page.marketHeader, 'click', () => { this.showMarketSelectForm() })
Doc.bind(page.marketFilterInput, 'input', () => { this.sortMarketRows() })
Doc.bind(page.cexRebalanceCheckbox, 'change', () => { this.autoRebalanceChanged() })
+ Doc.bind(page.internalOnlyRadio, 'change', () => { this.internalOnlyChanged() })
+ Doc.bind(page.externalTransfersRadio, 'change', () => { this.externalTransfersChanged() })
Doc.bind(page.switchToAdvanced, 'click', () => { this.showAdvancedConfig() })
Doc.bind(page.switchToQuickConfig, 'click', () => { this.switchToQuickConfig() })
Doc.bind(page.qcMatchBuffer, 'change', () => { this.matchBufferChanged() })
@@ -594,7 +597,7 @@ export default class MarketMakerSettingsPage extends BasePage {
}) as ConfigState
if (botCfg) {
- const { basicMarketMakingConfig: mmCfg, arbMarketMakingConfig: arbMMCfg, simpleArbConfig: arbCfg, uiConfig: { cexRebalance } } = botCfg
+ const { basicMarketMakingConfig: mmCfg, arbMarketMakingConfig: arbMMCfg, simpleArbConfig: arbCfg, uiConfig } = botCfg
this.creatingNewBot = false
// This is kinda sloppy, but we'll copy any relevant issues from the
// old config into the originalConfig.
@@ -605,7 +608,8 @@ export default class MarketMakerSettingsPage extends BasePage {
oldCfg.quoteConfig = Object.assign({}, defaultBotAssetConfig, botCfg.uiConfig.quoteConfig)
oldCfg.baseOptions = botCfg.baseWalletOptions || {}
oldCfg.quoteOptions = botCfg.quoteWalletOptions || {}
- oldCfg.cexRebalance = cexRebalance
+ oldCfg.cexRebalance = uiConfig.cexRebalance
+ oldCfg.internalTransfers = uiConfig.internalTransfers
if (mmCfg) {
oldCfg.buyPlacements = mmCfg.buyPlacements
@@ -651,6 +655,7 @@ export default class MarketMakerSettingsPage extends BasePage {
Doc.setVis(viewOnly, page.viewOnlyRunning)
Doc.setVis(cexName, page.cexRebalanceSettings)
+ if (!cexName) Doc.hide(page.externalTransfersSettings, page.internalOnlySettings)
if (cexName) setCexElements(document.body, cexName)
await this.fetchMarketReport()
@@ -1168,9 +1173,48 @@ export default class MarketMakerSettingsPage extends BasePage {
}
}
+ internalOnlyChanged () {
+ const checked = Boolean(this.page.internalOnlyRadio.checked)
+ this.page.externalTransfersRadio.checked = !checked
+ this.updatedConfig.cexRebalance = !checked
+ this.updatedConfig.internalTransfers = checked
+ this.updateAllocations()
+ }
+
+ externalTransfersChanged () {
+ const checked = Boolean(this.page.externalTransfersRadio.checked)
+ this.page.internalOnlyRadio.checked = !checked
+ this.updatedConfig.cexRebalance = checked
+ this.updatedConfig.internalTransfers = !checked
+ this.updateAllocations()
+ }
+
autoRebalanceChanged () {
const { page, updatedConfig: cfg } = this
- cfg.cexRebalance = page.cexRebalanceCheckbox?.checked ?? false
+ const checked = page.cexRebalanceCheckbox?.checked
+ Doc.setVis(checked, page.internalOnlySettings, page.externalTransfersSettings)
+ if (checked && !cfg.cexRebalance && !cfg.internalTransfers) {
+ // default to external transfers
+ cfg.cexRebalance = true
+ page.externalTransfersRadio.checked = true
+ page.internalOnlyRadio.checked = false
+ } else if (!checked) {
+ cfg.cexRebalance = false
+ cfg.internalTransfers = false
+ page.externalTransfersRadio.checked = false
+ page.internalOnlyRadio.checked = false
+ } else if (cfg.cexRebalance && cfg.internalTransfers) {
+ // should not happen.. set to default
+ cfg.internalTransfers = false
+ page.externalTransfersRadio.checked = true
+ page.internalOnlyRadio.checked = false
+ } else {
+ // set to current values. This case should only be called when the form
+ // is loaded.
+ page.externalTransfersRadio.checked = cfg.cexRebalance
+ page.internalOnlyRadio.checked = cfg.internalTransfers
+ }
+
this.updateAllocations()
}
@@ -1620,7 +1664,9 @@ export default class MarketMakerSettingsPage extends BasePage {
this.qcProfitSlider.setValue((profit - defaultProfit.minV) / defaultProfit.range)
if (cexName) {
- page.cexRebalanceCheckbox.checked = cfg.cexRebalance
+ page.cexRebalanceCheckbox.checked = cfg.cexRebalance || cfg.internalTransfers
+ page.internalOnlyRadio.checked = cfg.internalTransfers
+ page.externalTransfersRadio.checked = cfg.cexRebalance
this.autoRebalanceChanged()
}
@@ -1701,7 +1747,8 @@ export default class MarketMakerSettingsPage extends BasePage {
simpleArbLots: cfg.simpleArbLots,
baseConfig: cfg.baseConfig,
quoteConfig: cfg.quoteConfig,
- cexRebalance: cfg.cexRebalance
+ cexRebalance: cfg.cexRebalance,
+ internalTransfers: cfg.internalTransfers
},
baseWalletOptions: cfg.baseOptions,
quoteWalletOptions: cfg.quoteOptions
diff --git a/client/webserver/site/src/js/registry.ts b/client/webserver/site/src/js/registry.ts
index d4832abee4..d58ffa8d2d 100644
--- a/client/webserver/site/src/js/registry.ts
+++ b/client/webserver/site/src/js/registry.ts
@@ -759,6 +759,7 @@ export interface OrderPlacement {
export interface AutoRebalanceConfig {
minBaseTransfer: number
minQuoteTransfer: number
+ internalOnly: boolean
}
export interface BasicMarketMakingConfig {
@@ -809,6 +810,7 @@ export interface UIConfig {
quoteConfig: BotAssetConfig
simpleArbLots?: number
cexRebalance: boolean
+ internalTransfers: boolean
}
export interface StartConfig extends MarketWithHost {