6eer

6eer

Finishing my degree on computer science. I'm orienting my career in blockchain. FIAT? a worldwide scam.

Member Since 3 years ago

Argentina

Experience Points
30
follower
Lessons Completed
0
follow
Lessons Completed
2
stars
Best Reply Awards
1
repos

18 contributions in the last year

Pinned
⚡ Two bots written in JS that uses flashswaps and normal swaps to arbitrage Uniswap. Includes an automated demostration.
Activity
Jul
30
2 months ago
Activity icon
issue

6eer issue rileytestut/AltStore

6eer
6eer

Cant sign in altstore app

Hi,

I install the altstore 1.4.6 app on my iphone 6 iOS 12.5.4 (no jailbreak) from windows and works very well.

Now I'm trying to sign in with my apple ID and I can't, just keep loading and it never can goes through.

Its a known issue? I could not find any open/closed issue for this.

6eer

edit

PS:

First i created a new apple id, install itunes & icoud on windows, logged in with this new account & did the same with the iphone. Then i installed the altstore & tried to signed in with this new account and 'failed' so I rebooted the phone and tried again, 3 attemps with no success. So basically used this account to the whole proccess.

Then i tried using my personal account to loged in into altstore while the new account was on the iphone. No success again.

My last try was with my personal account in the iphone & in the altstore, but once again i was not able to sign in.

Activity icon
issue

6eer issue comment rileytestut/AltStore

6eer
6eer

Cant sign in altstore app

Hi,

I install the altstore 1.4.6 app on my iphone 6 iOS 12.5.4 (no jailbreak) from windows and works very well.

Now I'm trying to sign in with my apple ID and I can't, just keep loading and it never can goes through.

Its a known issue? I could not find any open/closed issue for this.

6eer

edit

PS:

First i created a new apple id, install itunes & icoud on windows, logged in with this new account & did the same with the iphone. Then i installed the altstore & tried to signed in with this new account and 'failed' so I rebooted the phone and tried again, 3 attemps with no success. So basically used this account to the whole proccess.

Then i tried using my personal account to loged in into altstore while the new account was on the iphone. No success again.

My last try was with my personal account in the iphone & in the altstore, but once again i was not able to sign in.

6eer
6eer

OK, solved. Read the faq and i found that i need to keep the sync with the altserver live.

Activity icon
issue

6eer issue rileytestut/AltStore

6eer
6eer

Cant sign in altstore app

Hi,

I install the altstore1.4.6 app on my iphone 6 iOS 12.5.4 (no jailbreak) from windows and works very well.

Now I'm trying to sign in with my apple ID and I can't, just keep loading and it never can goes through.

its a known issue? I cant find any open/closed issue for this.

6eer

Jul
27
2 months ago
Activity icon
issue

6eer issue comment 6eer/uniswap-sushiswap-arbitrage-bot

6eer
6eer

Question about sAmountIn

I'm a bit confused about the calculation of sAmountIn:

const sAmountIn = await sRouter.methods.getAmountIn(**amountIn**,sReserve1 ,sReserve0).call()

Output log:

Watermelon (WTM) {T0} | Pineapple (PNA) {T1} reserves

On Uniswap
WTM: 1000 | PNA: 500

On Sushiswap
WTM: 10000 | PNA: 100000

Swap's direction
PNA -> WTM

Uniswap's pool state
WTM excess/PNA shortage

On Uniswap
Mid price before swap: 2.00 WTM/PNA
Mid price after swap: 0.10 WTM/PNA
Swap 1738 PNA for 776 WTM
Trade price: 0.45 WTM/PNA (sell price)

Sushiswap price: 0.10 WTM/PNA (buy price)
Difference: 0.34 WTM/PNA
Total difference: 56.49445 ETH or 598.68 WTM

Gas needed: 0.36 M
Gas price: 20 gwei
Gas cost: 0.00720 ETH

Profit: 56.48725 ETH or 113855.24 DAI

My understanding is that the bot discovers and arbitrage opportunity where WTM is underpriced relative to PNA on Uniswap than it is on sushiswap (since on Uniswap, WTM is in excess and PNA is in shortage). So in order to exploit this, we would want to purchase WTM on Uniswap and sell PNA on Uniswap, hence we would be swapping amountIn PNA for amountOut WTM on uniswap.

Now that we have WTM, we would look to sell it on Sushiswap, so we would be sending in WTM and getting back PNA.

If so, why is it that sAmountIn is calculated from amountIn (this PNA amount going into Uniswap), and not amountOut (the WTM amount coming out of uniswap)?

6eer
6eer

Ah, ok! (I saw the edit). Yeah u are right with the normal bot u need to be holding the WTM, u only use sushiswap as oracle, as if the sushiprice was the market price (a VERY BAD assumption, here i suppose using a binance API to get the price reference would be a much better idea). So instead of

  1. Since we don't own any PNA, we must first borrow 'amountIn' PNA on Sushiswap, meaning we are taking PNA out of Sushiswap, so we must be sending 'sAmountIn' WTM on Sushiswap.

U use the PNA tokens that u owns (the account u use to send & sign the transaction must have enough PNA). I wrote it in the first paragraph of the What its included in this repo?

[...]The other uses normal swaps, this bot require you to be holding the tokens needed to do the trade but it contrast it cost less gas to execute.[...]

U dont borrow nothing!! u just make the arbitrage with your funds

Activity icon
issue

6eer issue comment 6eer/uniswap-sushiswap-arbitrage-bot

6eer
6eer

Question about sAmountIn

I'm a bit confused about the calculation of sAmountIn:

const sAmountIn = await sRouter.methods.getAmountIn(**amountIn**,sReserve1 ,sReserve0).call()

Output log:

Watermelon (WTM) {T0} | Pineapple (PNA) {T1} reserves

On Uniswap
WTM: 1000 | PNA: 500

On Sushiswap
WTM: 10000 | PNA: 100000

Swap's direction
PNA -> WTM

Uniswap's pool state
WTM excess/PNA shortage

On Uniswap
Mid price before swap: 2.00 WTM/PNA
Mid price after swap: 0.10 WTM/PNA
Swap 1738 PNA for 776 WTM
Trade price: 0.45 WTM/PNA (sell price)

Sushiswap price: 0.10 WTM/PNA (buy price)
Difference: 0.34 WTM/PNA
Total difference: 56.49445 ETH or 598.68 WTM

Gas needed: 0.36 M
Gas price: 20 gwei
Gas cost: 0.00720 ETH

Profit: 56.48725 ETH or 113855.24 DAI

My understanding is that the bot discovers and arbitrage opportunity where WTM is underpriced relative to PNA on Uniswap than it is on sushiswap (since on Uniswap, WTM is in excess and PNA is in shortage). So in order to exploit this, we would want to purchase WTM on Uniswap and sell PNA on Uniswap, hence we would be swapping amountIn PNA for amountOut WTM on uniswap.

Now that we have WTM, we would look to sell it on Sushiswap, so we would be sending in WTM and getting back PNA.

If so, why is it that sAmountIn is calculated from amountIn (this PNA amount going into Uniswap), and not amountOut (the WTM amount coming out of uniswap)?

6eer
6eer

hey rob,

My understanding is that the bot discovers and arbitrage opportunity where WTM is underpriced relative to PNA on Uniswap than it is on sushiswap (since on Uniswap, WTM is in excess and PNA is in shortage). So in order to exploit this, we would want to purchase WTM on Uniswap and sell PNA on Uniswap, hence we would be swapping amountIn PNA for amountOut WTM on uniswap. Now that we have WTM, we would look to sell it on Sushiswap, so we would be sending in WTM and getting back PNA.

It's all right.

If so, why is it that sAmountIn is calculated from amountIn (this PNA amount going into Uniswap), and not amountOut (the WTM amount coming out of uniswap)?

Its because you wanna know how much WTM u will need to payback on sushiswap given u borrow (amountIn) PNA on sushi, so one u know how much u need to repay to sushi, your profit will be the (amountOut) WTMs that u got from uniswap less the sAmountIn of WTM u need to payback the flashloan on sushi (payback for the PNA u borrowed)

I hope have been clear! (otherwise, let me know but i think u got it, after all u understand all the shitty computations i made haha, cheers!)

Jul
26
2 months ago
Activity icon
issue

6eer issue comment 6eer/uniswap-sushiswap-arbitrage-bot

6eer
6eer

Error run on LINK/UNI

Hi,

The demo works well, but when I tried with pair LINK/UNI, got error revert ds-math-sub-underflow (the output is pasted at the bottom).

Added console.log around computeProfitMaximizingTrade and getAmountIn, the amountIn looks weird.

Could you please take a look? Thanks.

btw, I tried with WETH/WBTC the amountIn seems good (no arbitrage opportunity as expected). Possibly a problem with liquidity?

This is my .env:

ADDR_ARBITRAGE_CONTRACT = '0x376eE0EcDD38d7cb6B23f5bC4392e16eB3F5f33b'
ADDR_DAI = '0x6b175474e89094c44da98b954eedeac495271d0f'
ADDR_ETH = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
ADDR_SFACTORY = '0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac'
ADDR_SROUTER = '0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'
ADDR_TOKEN0 = '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'
ADDR_TOKEN1 = '0x514910771af9ca656af840dff83e8264ecf986ca'
ADDR_UFACTORY = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'
ADDR_UROUTER = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'
ADDR_UTILS = '0x8c0bb5a63B6340a2522b02c49F6318db4d2B3099'
LOCAL_DEPLOYMENT = true
PRICE_TOKEN0 = 16.7
PRICE_TOKEN1 = 15.4
PRIVATE_KEY = '0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
PROJECT_ID = '3c40e9b697e547b4ae7e72dceb82ad11'
VALID_PERIOD = 5

This is the bot output:

Bot listening!

compute start 4466628919515992 4432234592178367 1283386482501355995913 1385617325034400988498
compute done result={"0":true,"1":"53451036616789987127","aToB":true,"amountIn":"53451036616789987127"}
getAmountIn amountIn=53451036616789987127 sReserve1=4432234592178367 sReserve0=4466628919515992
Error: Returned error: VM Exception while processing transaction: revert ds-math-sub-underflow
    at Object.ErrorResponse (/home/ubuntu/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-helpers/lib/errors.js:28:19)
    at Object.callback (/home/ubuntu/uniswap-sushiswap-arbitrage-bot/node_modules/web3-core-requestmanager/lib/index.js:303:36)
    at /home/ubuntu/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:114:45
    at Array.forEach (<anonymous>)
    at WebsocketProvider._onMessage (/home/ubuntu/uniswap-sushiswap-arbitrage-bot/node_modules/web3-providers-ws/lib/index.js:102:69)
    at W3CWebSocket._dispatchEvent [as dispatchEvent] (/home/ubuntu/uniswap-sushiswap-arbitrage-bot/node_modules/yaeti/lib/EventTarget.js:115:12)
    at W3CWebSocket.onMessage (/home/ubuntu/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:234:14)
    at WebSocketConnection.<anonymous> (/home/ubuntu/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/W3CWebSocket.js:205:19)
    at WebSocketConnection.emit (events.js:314:20)
    at WebSocketConnection.processFrame (/home/ubuntu/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:554:26)
    at /home/ubuntu/uniswap-sushiswap-arbitrage-bot/node_modules/websocket/lib/WebSocketConnection.js:323:40
    at processTicksAndRejections (internal/process/task_queues.js:79:11) {
  data: {
    '0xdff8a9c91157fece89320a187264de5b04ca625b887805fe1f49ce140eb6523d': {
      error: 'revert',
      program_counter: 15576,
      return: '0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001564732d6d6174682d7375622d756e646572666c6f770000000000000000000000',
      reason: 'ds-math-sub-underflow'
    },
    stack: 'c: VM Exception while processing transaction: revert ds-math-sub-underflow\n' +
      '    at Function.c.fromResults (/home/ubuntu/.nvm/versions/node/v12.22.1/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:192416)\n' +
      '    at /home/ubuntu/.nvm/versions/node/v12.22.1/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:42:50402',
    name: 'c'
  }
}
6eer
6eer

Hey im not sure whats happening but yeah there is an issue with the liquidity, you are trying to borrow 53 UNI on sushiswap UNI/LINK pair but looking at the reserves there are less than 1 UNI token in the pool (to be more accurate 0,0044 UNI) & i check the pool in sushiswap and basically its empty. This is not true in the case of uniswap.

Then I found this posts, maybe are usefull haha to be honest im not sure (sorry Im out of time). post1 post2