Mirrored Liquidity/Arbitrage May 2019

dexbot(46)
Published in
#dexbot
Words
790
Reading
4 min
Listen
Play
7y

https://docs.google.com/document/d/1B6M0z0ha7nEHevGSPGiEp8P64gbq9bzCuH3tbPXq3Ag/edit?usp=sharing

CEX to DEX Mirrored-Arbitrage Feature Specifications
May 2019
Permie

Mirrored Arbitrage is similar to traditional arbitrage except that it involves one limit order and one market order. As opposed to traditional arbitrage which involves two market orders.

Traditional arbitrage lies hidden ready to pounce on an arbitrage opportunity that arises out of two limit orders being placed by other traders on two separate exchanges.

Mirrored Arbitrage instead analyses the orderbook of Exchange-1 (CEX), and places a limit order on Exchange-2 (DEX) that if filled would allow DEXBot to take an offer from Exchange-1 and realise a profit. DEXBot should read the orderbook of the CEX and predict/front-run arbitrage opportunities by placing limit orders on the DEX and only acting on the CEX if the DEX limit-order is filled.

DEXBot supports liquidity and trading activity on the BitShares DEX so the exchange where limit orders are placed will be the DEX and the exchange where market orders are taken will be a CEX.

The orderbook of the CEX will be dynamic and ever changing so the limit orders on the DEX will have to be placed/cancelled and replaced in response to the updated CEX orderbook - within a margin of error to reduce wasting fees on unnecessarily minute order changes.

DEXBot must be aware of the state of the CEX orderbook with minimal time-lag and updated as frequently as is possible.

DEXBot will constantly monitor the CEX’s orderbook information and use the data to place limit orders on the DEX at prices %offset to the CEX.

For example:

CEX BID PRICE (Best offer to buy BTC available on the CEX at a specific moment in time. Market orders ready to be taken by DEXBot if conditions are correct):
100,000BTS/BTC

CEX ASK PRICE
(Best offer to sell BTC available on the CEX at a specific moment in time. Offers ready to be taken by DEXBot if conditions are correct):
105,000BTS/BTC

User-defined profit %OFFSET:
1%

User-defined error margin:
10%

DEXBot DEX limit order to buy price:
99,009BTS/BTC

DEXBot DEX limit order to sell price:
106,050BTS/BTC

Illustrative Comment from tbone:
"I think even a conservative approach with this feature could yield amazing results for the DEX.

for example, right now if i wanted to buy 200k BTS on the DEX (BTS/OPEN.BTC market), i would have to go way up to 624 sats to get it, while on Binance alone i could get 300k up to just 408 sats.

so based on Binance liquidity alone, someone using this strategy could pretty conservatively put up on the DEX, say, a 50k BTS order on the bid at 425 sats, and perhaps another 100k BTS at let's say 440 sats. that alone would be a huge improvement for that market on the DEX, and that's a) being conservative, and b) using ONLY Binance liquidity.

So I feel very optimistic about the impact of this development on DEX liquidity."

Example Logic:

What market does the user want to trade in?
BTC/BTS

Does the USER have both assets on both the CEX and DEX?
IF YES, Proceed
IF NO, Stop the bot and await user manual action

What % of assets should be used per trade?
(Like relative orders)

What is the current highest bid on the CEX?
CEX.BID = 100,000BTS/BTC

What is the current lowest ask on the CEX?
CEX.ASK = 105,000BTS/BTC

What is the user-defined %offset?
%OFFSET = 1%

What is the user-defined error-margin?
%ERRORMARGIN = 10%
(If the price is within 10% of the %OFFSET, treat it as if = %OFFSET).

Has a limit order been placed on the DEX to sell?
If NO, place a limit order on the DEX to sell BTC at (CEX.ASK) * (%OFFSET)
If YES,
Check that the limit order is still equal to (CEX.ASK) * (%Offset)
If YES, do nothing - leave the limit order on the DEX book
If NO, cancel the limit order on the DEX and recalculate and re-place.

Has a limit order been placed on the DEX to buy?
If NO, place a limit order on the DEX to buy BTC at (CEX.BID) / (%OFFSET)
If YES,
Check that the limit order is still equal to (CEX.BID) / (%Offset)
If YES, do nothing - leave the limit order on the DEX book
If NO, cancel the limit order on the DEX and recalculate and re-place.

Has the limit order to sell on the DEX been filled?
If NO, do nothing.
If YES, immediately place an order on the CEX to buy, taking the corresponding offer
that results in profit.

Has the limit order to buy on the DEX been filled?
If NO, do nothing
If YES, immediately place an order on the CEX to sell, taking the corresponding offer
that results in profit.

Repeat ad finitum.

Mirrored Liquidity/Arbitrage May 2019 | Ecency