KomodoPlatform / komodo-defi-framework

This is the official Komodo DeFi Framework repository
https://komodoplatform.com/en/docs/komodo-defi-framework/
103 stars 94 forks source link

add minvolume to setprice #473

Closed cipig closed 3 years ago

cipig commented 5 years ago

https://etherscan.io/tx/0x91ad987b51e9cf2838764150ab0c1d1b95ddef9e45f3d61bdd4548d5924332bb

value of transferred tokens: $1.33 txfee: $0.37 (with 21 gwei)

in order to avoid such swaps, it would be nice if setprice would support minvolume, so people can't start such swaps the only other solution to this is to set the margin to 50% and higher, or to remove all ERC20-orders from orderbook when gasprice > 5 gwei (currently > 20 gwei)

artemii235 commented 5 years ago

@cipig Hi, thanks for your report! Please ensure that you're setting gas_station_url on ETH/ERC20 enable: https://developers.atomicdex.io/basic-docs/atomicdex/atomicdex-api.html#enable, MM2 uses ETH node RPC API to get gas price by default. It usually results into higher fees.

The minvolume is easy to implement from MM2 side, but we will also need to handle this in GUI apps.

The gasprice limitation is much harder and error prone:

  1. 0.37$ is too much for 1$ trade but it will be fine for 1000$. So we should handle this at runtime, maybe relying on user-defined setting.
  2. What if gas price stays high for long time? We will have empty orderbooks then.
  3. Also I guess that order should be restored when gasprice becomes lower again, it requires extra effort.
cipig commented 5 years ago

gas_station is set, i use curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"enable\",\"coin\":\"USDC\",\"urls\":[\"http://eth1.cipig.net:8555\",\"http://eth2.cipig.net:8555\",\"http://eth3.cipig.net:8555\"],\"swap_contract_address\":\"0x8500AFc0bc5214728082163326C2FF0C73f4a871\",\"gas_station_url\":\"https://ethgasstation.info/json/ethgasAPI.json\",\"mm2\":1}" for all erc20 tokens

no need to implement the gas price limitation in mm2, i do this in my script the script cancels orders when gasprice > 20 gwei and puts them back online when gasprice < 20 gwei, simply because it is called every 30s and checks all this every time it is called

cipig commented 4 years ago

Could the fixed min trade amount of 0.00777 be replaced by the possibility to set a min amount in setprice call? That way, makers could decide to offer lower BTC amounts for trade in exchange for a higher margin and/or could set the min trade amount depending on the txfee at the moment of setprice call.

artemii235 commented 4 years ago

@cipig Sure, it can be added to API fast, but we will also need the GUI to handle it, e.g. display minimum amount on orderbook screen so users can understand if their supposed trading volume is too low for specific maker order. I will add min volume param on this week, but we will need some more time for adoption to use it widely.

BloodyNora commented 4 years ago

came here to say i'd like to see this included, as well. thank you

tolken1138 commented 4 years ago

Been waiting for this since mm1 days. I think this would be an excellent feature. As they say, lots of things are 'easy' but of course it comes down to priorities. I hope you guys find time to implement this easy addition soon! :D Would be most appreciated!

cipig commented 3 years ago

https://etherscan.io/tx/0x26cf66a44f38134433231cee3ba2a0e0beda5ab08903c2926cfbab9817b9e542 claiming the 5 USDC sent by the taker costs 2$ txfee we need this feature...

artemii235 commented 3 years ago

The feature is implemented and will be released along with major ordermatching protocol update prior to stress test v2.

cipig commented 3 years ago

tested min_volume on KMD/DOGE, basically to prevent takers from trying to sell < 777 DOGE (which results in dust error on taker fee send because dust on DOGE is 1 and taker fee is 1/777)

used {"userpass":"xxx","method":"setprice","base":"KMD","rel":"DOGE","price":186.50205043,"max":true,"min_volume":5} because 5 KMD is ~ 900 DOGE

orderbook entry looks like this

    {
      "coin": "KMD",
      "address": "RT9MpMyucqXiX8bZLimXBnrrn2ofmdGNKd",
      "price": "0.005359707887001604488584702264721628102771609784254799432430946257863851846988889632125536810386940659",
      "maxvolume": "10925.67863204",
      "min_volume": "5",
      "pubkey": "031bb83b58ec130e28e0a6d5d2acf2eb01b0d3f1670e021d47d31db8a858219da8",
      "age": 1607403034,
      "zcredits": 0,
      "uuid": "050d8a63-dc51-405a-9ba6-844c28b58664",
      "is_mine": true
    }

on taker side when trying to sell < 777 DOGE the order is not matched and turned into a maker order

cipig commented 3 years ago

works as expected, thanks a lot for implementing this closing the issue