gnosis / dx-services

🇳🇱✖️DutchX Services, Bots and CLI
http://dutchx.readthedocs.io/en/latest/
MIT License
29 stars 13 forks source link

`BuyLiquidityBot` cannot buy partially if it doesn't have enough funds #9

Open ghost opened 6 years ago

ghost commented 6 years ago
2018-08-29T18:15:05.304Z INFO-dx-service:services:LiquidityService-MKR-DAI The auction has 0 % of the buy volume bought. So we need to buy an extra 100 %
2018-08-29T18:15:06.329Z INFO-dx-service:services:LiquidityService-MKR-DAI Posting a buy order for 1621806.140323919 DAI ($2854611.240162635)
2018-08-29T18:15:06.604Z ERROR-dx-service:bots:BuyLiquidityBot-MKR-DAI There was an error buy ensuring liquidity with the account 0xc32cac63823b556e6ebf61bb74149f08bf1aab34: AssertionError [ERR_ASSERTION]: The user 0xc32cac63823b556e6ebf61bb74149f08bf1aab34 has just 999887.154789074167978419 DAI (required 1621806.14032391898952026834 DAI)
{ AssertionError [ERR_ASSERTION]: The user 0xc32cac63823b556e6ebf61bb74149f08bf1aab34 has just 999887.154789074167978419 DAI (required 1621806.14032391898952026834 DAI)
    at AuctionRepoImpl._assertBalanceAux (/usr/src/app/src/repositories/AuctionRepo/AuctionRepoImpl.js:1036:5)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  generatedMessage: false,
  name: 'AssertionError [ERR_ASSERTION]',
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '==' }
2018-08-29T18:15:06.605Z ERROR-dx-service:error Uncought promise rejection: AssertionError [ERR_ASSERTION]: The user 0xc32cac63823b556e6ebf61bb74149f08bf1aab34 has just 999887.154789074167978419 DAI (required 1621806.14032391898952026834 DAI)
{ AssertionError [ERR_ASSERTION]: The user 0xc32cac63823b556e6ebf61bb74149f08bf1aab34 has just 999887.154789074167978419 DAI (required 1621806.14032391898952026834 DAI)
    at AuctionRepoImpl._assertBalanceAux (/usr/src/app/src/repositories/AuctionRepo/AuctionRepoImpl.js:1036:5)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
  generatedMessage: false,
  name: 'AssertionError [ERR_ASSERTION]',
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '==' }

I'm not saying it's a bug, just a thing to consider. If the bot needs 1,621,806.xx DAI but it only has 999,887.xx DAI available, maybe it should do a buy with what it has instead of just raising an exception and letting the price fall further down...?

anxolin commented 6 years ago

This one was done on purpose.

Maybe we can add a parameter in the configuration of the buyBot, so we decide if he does partial postBuyOrders or not.

We will add it to our tasks and prioritize it with the others.