-
Notifications
You must be signed in to change notification settings - Fork 119
mm: Multi-hop Arbs #3267
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
base: master
Are you sure you want to change the base?
mm: Multi-hop Arbs #3267
Conversation
Has conflicts now. |
aa2155b
to
113613b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass. Will take a few passes to understand. Unsure how well I can test but will try.
client/mm/libxc/orderbook_test.go
Outdated
ob.update([]*obEntry{ | ||
{qty: 30, rate: 4000}, | ||
{qty: 30, rate: 5000}, | ||
{qty: 80, rate: 400}, | ||
{qty: 10, rate: 3000}, | ||
}, []*obEntry{ | ||
{qty: 30, rate: 4000}, | ||
{qty: 30, rate: 5000}, | ||
{qty: 80, rate: 400}, | ||
{qty: 10, rate: 3000}, | ||
}) | ||
bids := []*obEntry{ | ||
{qty: 30, rate: 4000e8}, | ||
{qty: 30, rate: 5000e8}, | ||
{qty: 80, rate: 400e8}, | ||
{qty: 10, rate: 3000e8}, | ||
} | ||
asks := []*obEntry{ | ||
{qty: 30, rate: 4000e8}, | ||
{qty: 30, rate: 5000e8}, | ||
{qty: 80, rate: 400e8}, | ||
{qty: 10, rate: 3000e8}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were all the quantities zero for quote? I think it's more natural to increase the base qty, as they would be atoms. The rates weren't that far off from what you might have, but are now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I've changed it.
} else if sell { | ||
baseQtyStr, err = getBaseQtyStr() | ||
} else { | ||
quoteQtyStr, err = getQuoteQtyStr() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this case, qty is already quote asset, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for market buys you pass the quote qty.
@@ -1018,7 +1094,26 @@ func (c *coinbase) VWAP(baseID, quoteID uint32, sell bool, qty uint64) (vwap, ex | |||
return 0, 0, false, fmt.Errorf("no book found for %s", productID) | |||
} | |||
|
|||
return book.vwap(sell, qty) | |||
return book.vwap(!sell, qty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this wrong? The arg is bids
so to get sells then you want asks, I guess... This was a bug then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this was a bug.
client/mm/mm_arb_market_maker.go
Outdated
} | ||
} | ||
|
||
// multiHopRate returns the aggregate rate that can be achieved by completing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// multiHopRate returns the aggregate rate that can be achieved by completing | |
// multiHopRateAndTrades returns the aggregate rate that can be achieved by completing |
Adds features required for multi-hop arbs. - Market Trades are now supported. - Inverse VWAP, the same as VWAP but using the quote asset, is now supported. - A ValidateTrade function is also added, to be able to determine prior to placing an order if the order parameters are valid. - The Binance NOTIONAL and MIN_NOTIONAL filters are taken into account when determining the validity of trade parameters.
Adds the ability to perform multi-hop arbitrage trades using the arb market maker bot. If the exact market that exist on the DEX does not exist on the CEX, but there exist two markets each involving the base and quote assets of the DEX market and sharing the same third asset, then the bot will perform arbitrage trades by using both of these markets. For example, if there is a DCR-BTC market on the DEX, the bot can be configured to do multi-hop arbs on DCR-USDT and a BTC-USDT markets. Then if a sell order is matched on a DEX, the bot will sell BTC on the BTC-USDT market and buy DCR on the DCR-USDT market, and vice-versa for buys. Since two arb trades are being done, the chance of unfilled arb trades becomes higher. In order to avoid the possibility of funds being stuck in the intermediate asset, market trades are used rather than limit trades.
Closes #3120