Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

transaction fail, i cant understand profit #26

Open
sbrfarhadi opened this issue Jun 2, 2021 · 8 comments
Open

transaction fail, i cant understand profit #26

sbrfarhadi opened this issue Jun 2, 2021 · 8 comments

Comments

@sbrfarhadi
Copy link

sbrfarhadi commented Jun 2, 2021

I see a profit between the two pair
profit: 0.059353947220959595
'0x5010dA63eBD45D833258cca1FEFB7715c16708c2', '0x223740a259E461aBeE12D84A9FFF5Da69Ff071dD'

config
minimumProfit: 3, // in USD

I called the flashArbitrage manually
But the transaction went fail
Was the amount of profit small?
How is the loan amount obtained, can it be changed for max profit?

I use bsc network

code:


const tokens = await flashBot.getBaseTokens();
  console.log('Base tokens: ', tokens);

  const res = await flashBot.getProfit('0x5010dA63eBD45D833258cca1FEFB7715c16708c2', '0x223740a259E461aBeE12D84A9FFF5Da69Ff071dD');
  console.log(res);
  const [baseTokens] = getTokens(Network.BSC);
  const netProfit = await calcNetProfit(res.profit, res.baseToken, baseTokens);
  console.log('profit: ', netProfit);

  const lock = new AsyncLock({ timeout: 2000, maxPending: 20 });
  try {
    // lock to prevent tx nonce overlap
    await lock.acquire('flash-bot', async () => {
      const response = await flashBot.flashArbitrage('0x5010dA63eBD45D833258cca1FEFB7715c16708c2', '0x223740a259E461aBeE12D84A9FFF5Da69Ff071dD', {
        gasPrice: config.gasPrice,
        gasLimit: config.gasLimit,
      });
      const receipt = await response.wait(1);
      console.log(`Tx: ${receipt.transactionHash}`);
    });
  } catch (err) {
    if (err.message === 'Too much pending tasks' || err.message === 'async-lock timed out') {
      return;
    }
    console.log(err);
  }
}

result:

Error: transaction failed (transactionHash="0x233", transaction={"hash":"0x233","type":0,"accessList":null,"blockHash":null,"blockNumber":null,"transactionIndex":null,"confirmations":0,"from":"0x555","gasPrice":{"type":"BigNumber","hex":"0x04a817c800"},"gasLimit":{"type":"BigNumber","hex":"0x7530"},"to":"0x4xx","value":{"type":"BigNumber","hex":"0x00"},"nonce":87,"data":"0xba","r":"0x9d","s":"0x5b","v":148,"creates":null,"chainId":56}, receipt={"to":"0x4xx","from":"0x555","contractAddress":null,"transactionIndex":0,"gasUsed":{"type":"BigNumber","hex":"0x7530"},"logsBloom":"0x000000000000000000","blockHash":"0x1","transactionHash":"0x233","logs":[],"blockNumber":7939670,"confirmations":1,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x7530"},"status":0,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.2.0)
   at Logger.makeError (\node_modules\@ethersproject\logger\src.ts\index.ts:213:28)
   at Logger.throwError (\node_modules\@ethersproject\logger\src.ts\index.ts:225:20)
   at EthersProviderWrapper.<anonymous> (\node_modules\@ethersproject\providers\src.ts\base-provider.ts:1189:24)
   at step (\node_modules\@ethersproject\providers\lib\base-provider.js:48:23)
   at Object.next (\node_modules\@ethersproject\providers\lib\base-provider.js:29:53)
   at fulfilled (\node_modules\@ethersproject\providers\lib\base-provider.js:20:58) {
 reason: 'transaction failed',
 code: 'CALL_EXCEPTION',
 transactionHash: '0x233',
 transaction: {
   hash: '0x233',
   type: 0,
   accessList: null,
   blockHash: null,
   blockNumber: null,
   transactionIndex: null,
   confirmations: 0,
   from: '0x555',
   gasPrice: BigNumber { _hex: '0x04a817c800', _isBigNumber: true },
   gasLimit: BigNumber { _hex: '0x7530', _isBigNumber: true },
   to: '0x4xx',
   value: BigNumber { _hex: '0x00', _isBigNumber: true },
   nonce: 87,
   data: '0xbxxxx',
   r: '0x9xxx',
   s: '0x5xxx',
   v: 148,
   creates: null,
   chainId: 56,
   wait: [Function (anonymous)]
 },
 receipt: {
   to: '0x4xxxx',
   from: '0x555',
   contractAddress: null,
   transactionIndex: 0,
   gasUsed: BigNumber { _hex: '0x7530', _isBigNumber: true },
   logsBloom: '0x000000',
   blockHash: '0x1xxx',
   transactionHash: '0x233',
   logs: [],
   blockNumber: 
   confirmations: 1,
   cumulativeGasUsed: BigNumber { _hex: '0x7530', _isBigNumber: true },
   status: 0,
   byzantium: true
 }
}
@hallex321
Copy link

I'm not sure about this but it seems bot dont take liquidity provider fee into account, so if the "profit" is too small, the contrat will fail to do a real profit

@hallex321
Copy link

if anyone can confirm... if true, seems like its not that hard to implement the feature yourself in getprofit function in flashbot.sol

@sbrfarhadi
Copy link
Author

@hallex321
Thank you for your answer

@sbrfarhadi
Copy link
Author

Also
I see many opportunities
Is this profit displayed the ultimate profit that can be achieved?
Or does it mean that I can make a good profit with a very large loan (Like a flash loan)?

image

@paco0x
Copy link
Owner

paco0x commented Jun 2, 2021

There's a time gap between you found profitability and then actually sent a transaction. So it might not be profitable when the transaction actually got executed on the blockchain.

@sbrfarhadi
Copy link
Author

sbrfarhadi commented Jun 8, 2021

@paco0x
Coulde you please help me?

image

1 - Why there is always a difference between buying and selling

2- With these conditions why there is always profit

@ccoop1
Copy link

ccoop1 commented Sep 21, 2021

Did anyone utilize this bot and make a profit yet? Did you clean it up a bit first or run it out of the box. Thanks in advance!!

@alexhunterr
Copy link

Did anyone utilize this bot and make a profit yet? Did you clean it up a bit first or run it out of the box. Thanks in advance!!

did you find anything

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants