Created
April 27, 2019 19:16
-
-
Save dionyziz/f065404a4f2a7f0e7851594a3f9ce58f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wallet | |
class Edge { | |
order: { | |
placed: false, | |
place: async function() { | |
... | |
this.placed = true | |
orderid = await cctx.placeOrder() | |
do { | |
status = await cctx.checkOrder(orderid) | |
} while (status != FILLED) | |
this.filled = true | |
} | |
} | |
} | |
c[0] = BTC, c[1] = XMR, c[2] = ETH | |
e[0] = Edge(c[0], c[1]) | |
e[1] = Edge(c[1], c[2]) | |
e[2] = Edge(c[2], c[0]) | |
t = Triangle(e) | |
orders = map _.order e | |
prices = map _.price e | |
volumes = map _.volume e | |
v[0] = t.maxTradeVolume() | |
v[i] = prices[i - 1] * volumes[i - i], i in [1, 2, 3] | |
function exploit() { | |
finished = all map _.filled orders | |
function placeOrder(i) { | |
if (order.placed) { | |
return true | |
} | |
if (all $ map apply order[i].conditions) { | |
return order.place() | |
} | |
return false | |
} | |
async function ready() { | |
do { | |
promises = map placeOrder [0, 1, 2] | |
await Promise.race(promises) | |
} while (!finished()) | |
} | |
return ready() | |
} | |
order[0].conditions = [] | |
order[1].conditions = [() => order[0].filled, () => wallet[c[1]] >= v[1]] | |
order[2].conditions = [() => order[1].filled, () => wallet[c[2]] >= v[2]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment