gnosis / dex-telegram

dFusion bot
MIT License
12 stars 9 forks source link

MIssing Orders on Batch Order Placement #144

Open bh2smith opened 4 years ago

bh2smith commented 4 years ago

The following transaction placing 40 orders on the dfusion exchange (Buy WETH for DAI and Buy DAI for WETH) in a single "batch" transaction using a multi-send contract only lead to ~19 notifications in the telegram channel.

https://rinkeby.etherscan.io/tx/0x6cb26f6b5feab2ab6185820b5049bbecafe4d013c04ff498de44e70e462da629

The transaction details can be viewed in slightly less cryptic terms on tenderly

https://dashboard.tenderly.dev/tx/rinkeby/0x6cb26f6b5feab2ab6185820b5049bbecafe4d013c04ff498de44e70e462da629

but to summarize (from the logs of the script), these are the following calls to placeValidFromOrders on BatchExchange.sol

Safe 0 - 0x0f41B6BaF8202512e62CCc9866D27032D9DCFcD1:
  Buy  WETH with DAI at 222.4
  Sell WETH for  DAI at 227.96
Safe 1 - 0x1d8A3D8d21466d36DDCa5432FD8b5d95956023B5:
  Buy  WETH with DAI at 227.96
  Sell WETH for  DAI at 233.52
Safe 2 - 0x97f87462cC8738E1AFf8656A0C1D499e28d17E3b:
  Buy  WETH with DAI at 233.52
  Sell WETH for  DAI at 239.07999999999998
Safe 3 - 0xF3b3609BEb25CB725377AaF06eBf50ff856F5C64:
  Buy  WETH with DAI at 239.07999999999998
  Sell WETH for  DAI at 244.64
Safe 4 - 0x5e95f9a4f4Ed1323Dd489bDfd10bdd718e4d4720:
  Buy  WETH with DAI at 244.64
  Sell WETH for  DAI at 250.2
Safe 5 - 0x194d09D906846aeF3402c5eab775bF8e6d6A9556:
  Buy  WETH with DAI at 250.2
  Sell WETH for  DAI at 255.76
Safe 6 - 0xe635149d28302891377168964f873728175E8976:
  Buy  WETH with DAI at 255.76
  Sell WETH for  DAI at 261.32
Safe 7 - 0x8beF6f835628688bDaC3Db28030769F5BCd37240:
  Buy  WETH with DAI at 261.32
  Sell WETH for  DAI at 266.88
Safe 8 - 0xFEFC78e2363dCD8f9699F9336b14B292B29cf98e:
  Buy  WETH with DAI at 266.88
  Sell WETH for  DAI at 272.44
Safe 9 - 0x8932112aEB83C7f7AebE9c83Beb62BCe5ad83275:
  Buy  WETH with DAI at 272.44
  Sell WETH for  DAI at 278
Safe 10 - 0x90FeeD152232eD3fe0dAe28f2BE3651e38208E60:
  Buy  WETH with DAI at 278
  Sell WETH for  DAI at 283.56
Safe 11 - 0xE6f636BD71e42F8D4EB17F47b216E945E0C156aE:
  Buy  WETH with DAI at 283.56
  Sell WETH for  DAI at 289.12
Safe 12 - 0x5961D9411e6722BD299a5C36a7A5CDD3fc5Ec35E:
  Buy  WETH with DAI at 289.12
  Sell WETH for  DAI at 294.67999999999995
Safe 13 - 0x52863CB34be1bE58B199281a6623D259BB670950:
  Buy  WETH with DAI at 294.67999999999995
  Sell WETH for  DAI at 300.24
Safe 14 - 0x88580dd3dF04Eb9418D9ECC694FBc95786189cFE:
  Buy  WETH with DAI at 300.24
  Sell WETH for  DAI at 305.79999999999995
Safe 15 - 0x185076bcba4aBD58F8d07C7276B7194Ec124Ea55:
  Buy  WETH with DAI at 305.79999999999995
  Sell WETH for  DAI at 311.35999999999996
Safe 16 - 0x3A8CE5F3186C0E116d412c80D1e56b9778182a1A:
  Buy  WETH with DAI at 311.35999999999996
  Sell WETH for  DAI at 316.91999999999996
Safe 17 - 0x0703B45ca5172016aF1f9fdF43f80bDc9088b542:
  Buy  WETH with DAI at 316.91999999999996
  Sell WETH for  DAI at 322.47999999999996
Safe 18 - 0xBd7982cE05fe5484448b775E2FD017203Cd9aE90:
  Buy  WETH with DAI at 322.47999999999996
  Sell WETH for  DAI at 328.03999999999996
Safe 19 - 0x5F1D32eFF4E25c4FD8C57d8cf3F8251eFB82bEC2:
  Buy  WETH with DAI at 328.03999999999996
  Sell WETH for  DAI at 333.59999999999997

The Rinkeby Telegram responded with the following messages at 9:08 and 9:09 am (Berlin Time) on Wed. 19 Feb.

Sell DAI for WETH

  - Price:  1 DAI = 0.00399683133513686904 WETH
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/WETH-DAI?sell=10&buy=2496.978021630287537584

Sell WETH for DAI

  - Price:  1 WETH = 255.75675740822802796191 DAI
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/DAI-WETH?sell=10&buy=0.039021451871437162

Sell DAI for WETH

  - Price:  1 DAI = 0.00390996511737847321 WETH
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/WETH-DAI?sell=10&buy=2552.452438934115721438

Sell WETH for DAI

  - Price:  1 WETH = 261.31981985600148359088 DAI
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/DAI-WETH?sell=10&buy=0.038190750343771901

Sell DAI for WETH

  - Price:  1 DAI = 0.00382672849135990996 WETH
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/WETH-DAI?sell=10&buy=2607.971802162894804914

Sell WETH for DAI

  - Price:  1 WETH = 266.87837870408045955842 DAI
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/DAI-WETH?sell=10&buy=0.037395311109357432

Sell DAI for WETH

  - Price:  1 DAI = 0.00374702516125825975 WETH
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/WETH-DAI?sell=10&buy=2663.446219466722989859

Sell WETH for DAI

  - Price:  1 WETH = 272.43693755222654460341 DAI
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/DAI-WETH?sell=10&buy=0.036632330731903121

Sell DAI for WETH

  - Price:  1 DAI = 0.0036705742216335793 WETH
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/WETH-DAI?sell=10&buy=2718.920636771220915246

Sell WETH for DAI

  - Price:  1 WETH = 278.00000000000000011386 DAI
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/DAI-WETH?sell=10&buy=0.035899280575539568

Sell DAI for WETH

  - Price:  1 DAI = 0.00359712230215827338 WETH
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/WETH-DAI?sell=10&buy=2774.440000000000000998

Sell WETH for DAI

  - Price:  1 WETH = 283.55855884807897634917 DAI
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/DAI-WETH?sell=10&buy=0.035195551989481454

Sell DAI for WETH

  - Price:  1 DAI = 0.00352660841577970482 WETH
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/WETH-DAI?sell=10&buy=2829.914417303828184916

Sell WETH for DAI

  - Price:  1 WETH = 289.11711769622506118503 DAI
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/DAI-WETH?sell=10&buy=0.034518883141626956

Sell DAI for WETH

  - Price:  1 DAI = 0.00345880592601472514 WETH
  - Tradable: Today at 8:15 AM GMT, in 7 minutes
  - Expires: Valid until cancelled

Fill the order here: https://dex.dev.gnosisdev.com/trade/WETH-DAI?sell=10&buy=2885.388834608326112095

Only 7 WETH for DAI and 8 DAI for WETH

anxolin commented 4 years ago

You broke it! :) Too many requests. I think we need to throttle the calls to Telegram. Also re-attempt logics.

Good call!

https://logs.gnosisdev.com/app/kibana#/discover/396dc300-d2e1-11e9-a183-49227c1c91a0?_g=(refreshInterval:(pause:!t,value:0),time:(from:'2020-02-19T08:08:00.000Z',mode:absolute,to:'2020-02-19T08:11:00.000Z'))&_a=(columns:!(log),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:'7ea8a550-5471-11e9-98b4-3b011d27ba56',key:kubernetes.labels.app,negate:!f,params:(query:dev-dex-telegram-bot,type:phrase),type:phrase,value:dev-dex-telegram-bot),query:(match:(kubernetes.labels.app:(query:dev-dex-telegram-bot,type:phrase))))),index:'7ea8a550-5471-11e9-98b4-3b011d27ba56',interval:auto,query:(language:lucene,query:''),sort:!('@timestamp',desc))

anxolin commented 4 years ago

Created 3 feature requests to address this situations better

alfetopito commented 4 years ago

Addressed by Dima. Requests are now pooled into less messages and spaced out.