Skip to content

Commit d3b77ed

Browse files
author
Your Name
committed
app-win
1 parent fd18e44 commit d3b77ed

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

app-win.zip

-319 Bytes
Binary file not shown.

app.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ console.log(data)
4747
for (var c in data.data){
4848
prices[c] = data.data[c].eth
4949
}
50-
prices['compound-dai'] = prices['compound-sai'] / 1.045310179747434
5150
console.log(prices)
5251
}
5352
catch (err){
@@ -123,7 +122,7 @@ bal = bal * prices[coinGeckoNames[tok]]
123122
var payload = {
124123
"swap": {
125124
"sourceAsset": tradeTokens[thetoken],
126-
"destinationAsset": 'DAI',// token['address'],
125+
"destinationAsset": token['address'],
127126
"sourceAmount": Math.floor(tradePercent * winBalDec),
128127
"maxMarketSlippagePercent": "50",
129128
"maxExecutionSlippagePercent": "10"
@@ -154,14 +153,14 @@ bal = bal * prices[coinGeckoNames[tok]]
154153
var tokWin = {}
155154
var arbWinR2s = {}
156155
var arbPots = {}
157-
tokWin[sym] = ""
158-
arbPots[sym] = []
159-
arbWins[sym] = -1000
160-
arbWinR2s[sym] = [];
156+
tokWin[token['symbol']] = ""
157+
arbPots[token['symbol']] = []
158+
arbWins[token['symbol']] = -1000
159+
arbWinR2s[token['symbol']] = [];
161160
for (var tok in tradeTokens){
162161
var payload2 = {
163162
"swap": {
164-
"sourceAsset": 'DAI',//token['address'],
163+
"sourceAsset": token['address'],
165164
"destinationAsset": tradeTokens[tok],
166165
"sourceAmount": total,
167166
"maxMarketSlippagePercent": "50",
@@ -189,8 +188,8 @@ bal = bal * prices[coinGeckoNames[tok]]
189188

190189

191190

192-
if (syms[sym] == undefined) {
193-
syms[sym] = 0
191+
if (syms[token['symbol']] == undefined) {
192+
syms[token['symbol']] = 0
194193
}
195194
var fee
196195
var fee2
@@ -220,22 +219,23 @@ bal = bal * prices[coinGeckoNames[tok]]
220219

221220
var arbpotential = 100 * ((parseFloat(tx1price2) / parseFloat(tx1price) - 1))
222221
//console.log('arb potential: ' + arbpotential)
223-
arbPots[sym].push(arbpotential)
224-
//console.log(arbPots[sym])
225-
if (arbpotential > arbWins[sym]){
226-
tokWin[sym] = tradeTokens[tok]
227-
arbWins[sym] = arbpotential
228-
arbWinR2s[sym] = r2
222+
arbPots[token['symbol']].push(arbpotential)
223+
//console.log(arbPots[token['symbol']])
224+
if (arbpotential > arbWins[token['symbol']]){
225+
tokWin[token['symbol']] = tradeTokens[tok]
226+
arbWins[token['symbol']] = arbpotential
227+
arbWinR2s[token['symbol']] = r2
229228

230229
}
231230
}
232231
}
233232
}
234-
if (arbWins[sym] != -1000){
235-
console.log('arbWin: ' + sym + ': ' + arbWins[sym] + ', tok: ' + tokWin[sym])
233+
console.log(arbWins)
234+
if (arbWins[token['symbol']] != -1000){
235+
console.log('arbWin: ' + sym + ': ' + arbWins[token['symbol']] + ', tok: ' + tokWin[token['symbol']])
236236
}
237-
if (arbWins[sym] > biggest) {
238-
biggest = arbWins[sym]
237+
if (arbWins[token['symbol']] > biggest) {
238+
biggest = arbWins[token['symbol']]
239239
}
240240
if (!doable.includes(sym)){
241241
doable.push(sym)
@@ -245,16 +245,16 @@ bal = bal * prices[coinGeckoNames[tok]]
245245

246246
console.log('tradeable length: ' + (doable.length))
247247
arb = false
248-
if (arbWins[sym] > 0.05) {
249-
console.log(arbWins[sym])
248+
if (arbWins[token['symbol']] > 0.05) {
249+
console.log(arbWins[token['symbol']])
250250
console.log(tx1price2)
251251
console.log(tx1price)
252252
arb = true
253253
}
254-
if (syms[sym] == undefined) {
255-
syms[sym] = 0
254+
if (syms[token['symbol']] == undefined) {
255+
syms[token['symbol']] = 0
256256
}
257-
if (arbWins[sym] < 0.05 && sym[syms] > 0) {
257+
if (arbWins[token['symbol']] < 0.05 && sym[syms] > 0) {
258258
try {
259259
ignore.splice(ignore.indexOf(sym), 1)
260260

@@ -264,19 +264,19 @@ bal = bal * prices[coinGeckoNames[tok]]
264264
}
265265

266266
}
267-
if (arbWins[sym] > 0.05 && syms[sym] == 0) {
267+
if (arbWins[token['symbol']] > 0.05 && syms[token['symbol']] == 0) {
268268
ignore.push(sym)
269269

270270

271271
console.log('length ignore ' + ((ignore.length)))
272272
}
273-
if ((arbWins[sym] > 0.05 && syms[sym] != 0 && !ignore.includes(sym))){// || first && arbWins[sym] > -1.5) {
273+
if ((arbWins[token['symbol']] > 0.05 && syms[token['symbol']] != 0 && !ignore.includes(sym))){// || first && arbWins[token['symbol']] > -1.5) {
274274
first = false
275275
console.log('arb! ' + sym)
276276
fs.writeFile("./arbs.json", JSON.stringify({
277277
'platform': 'totle',
278278
'symbol': sym,
279-
'arb': arbWins[sym]
279+
'arb': arbWins[token['symbol']]
280280
}) + '\n', function(err) {
281281
if (err) {
282282
return console.log(err);
@@ -285,7 +285,7 @@ bal = bal * prices[coinGeckoNames[tok]]
285285
});
286286

287287
var tx1 = (r['response']['transactions'])
288-
var tx = (arbWinR2s[sym]['response']['transactions'])
288+
var tx = (arbWinR2s[token['symbol']]['response']['transactions'])
289289
var abc = 0
290290
for (var t in tx1){
291291
setTimeout(async function(){
@@ -324,9 +324,9 @@ abc++
324324

325325

326326
}
327-
syms[sym] = syms[sym] + 1
327+
syms[token['symbol']] = syms[token['symbol']] + 1
328328

329-
console.log('occurences of symbol: ' + syms[sym])
329+
console.log('occurences of symbol: ' + syms[token['symbol']])
330330
}
331331
} else {
332332
if (r2['response']['message'] != undefined){
@@ -342,6 +342,7 @@ abc++
342342
}
343343

344344
} else {
345+
if (r2['response'] != undefined){
345346
if (r2['response']['message'].indexOf('is not tradable') != -1) {
346347
blacklist.push(token['symbol'])
347348

@@ -350,6 +351,7 @@ abc++
350351
thelength--
351352
console.log(r2)
352353
}
354+
}
353355
}
354356

355357

0 commit comments

Comments
 (0)