Error run on LINK/UNI

3
open
renorzr
renorzr
Posted 4 months ago

Error run on LINK/UNI #9

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
Created 4 months ago

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 these posts, maybe are usefull haha to be honest im not sure (sorry Im out of time). post1 post2

renorzr
renorzr
Created 4 months ago

thanks @6eer. seems computeProfitMaximizingTrade doesn't consider reserves...

oussaki
oussaki
Created 2 weeks ago

computeProfitMaximizingTrade has an issue with the reserves it's returning the amount bigger than the liquidity .