Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using max_taker_vol values to initiate trade sometimes results in "req funds larger than available" #733

Closed
smk762 opened this issue Oct 17, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@smk762
Copy link

smk762 commented Oct 17, 2020

In some cases, using the values returned from max_taker_vol to submit a trade returns "req amount is larger than balance.

Issue first encountered during AtomicDEX-Desktop testing, then checked using CLI directly with mm2 to confirm. Console output below -

curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"version\"}"

{"result":"2.0.2422_mm2_31d1803b0_Linux_Debug","datetime":"2020-09-25T12:40:25+07:00"}

curl --url "http://127.0.0.1:7783" --data "{\"method\":\"max_taker_vol\",\"coin\":\"ZEC\",\"userpass\":\"$userpass\",\"mm2\":1}"

{"result":{"numer":"824933907","denom":"15560000000"}}

curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"sell\",\"base\":\"ZEC\",\"rel\":\"KMD\",\"volume\":{\"numer\":\"824933907\",\"denom\":\"15560000000\"},\"price\":"\"2000\""}"

{"error":"rpc:339] lp_ordermatch:1249] taker_swap:1443] The total required ZEC amount 0.05331631793059125964010282776349614395886889460154241645244215938303341902313624678663239074550128535 is larger than available 0.05328455, balance: 0.05328455, locked by swaps: 0"}```

curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"get_trade_fee\",\"coin\":\"ZEC\"}"

{"result":{"coin":"ZEC","amount":"0.0001","amount_fraction":{"numer":"1","denom":"10000"},"amount_rat":[[1,[1]],[1,[10000]]]}}

I've seen this with ZEC and BCH.

With BCH, after doing a swap that was half of total, doing a subsequent trade with the remainder was successful.
I've left the account with ZEC relating to the issue as is, and can provide the seed for testing if required.

@artemii235
Copy link
Member

Thanks for report! Checking now.

@artemii235 artemii235 self-assigned this Oct 23, 2020
@artemii235 artemii235 added the bug Something isn't working label Oct 23, 2020
@artemii235
Copy link
Member

artemii235 commented Oct 23, 2020

The problem is max_taker_vol does not take the 0.0001 min dexfee threshold into account so it returns larger number that can be actually used. I'm going to fix this now.

@smk762
Copy link
Author

smk762 commented Oct 26, 2020

Results of latest test on fix_max_taker_vol branch:

curl --url "http://127.0.0.1:7783" --data "{"userpass":"$userpass","method":"version"}"
{"result":"31d1803b0","datetime":"2020-10-23T20:35:23+07:00"}

curl --url "http://127.0.0.1:7783" --data "{"method":"max_taker_vol","coin":"ZEC","userpass":"$userpass","mm2":1}"
{"result":{"numer":"1059691","denom":"20000000"}}

curl --url "http://127.0.0.1:7783" --data "{"userpass":"$userpass","method":"sell","base":"ZEC","rel":"KMD","volume":{"numer":"1059691","denom":"20000000"},"price":""2000""}"

{"result":{"base":"ZEC","rel":"KMD","base_amount":"0.05298455","base_amount_rat":[[1,[1059691]],[1,[20000000]]],"rel_amount":"105.9691","rel_amount_rat":[[1,[1059691]],[1,[10000]]],"action":"Sell","uuid":"88952618-c189-4a79-8002-057e79ae1721","method":"request","sender_pubkey":"f394a5c245230e9d2ee3d3fef89b2398e91621f008b6ba9256aaf98fd55c5d46","dest_pub_key":"0000000000000000000000000000000000000000000000000000000000000000","match_by":{"type":"Any"},"conf_settings":{"base_confs":3,"base_nota":false,"rel_confs":2,"rel_nota":true},"order_type":{"type":"GoodTillCancelled"}}}

curl --url "http://127.0.0.1:7783" --data "{"userpass":"$userpass","method":"get_trade_fee","coin":"ZEC"}"
{"result":{"coin":"ZEC","amount":"0.0001","amount_fraction":{"numer":"1","denom":"10000"},"amount_rat":[[1,[1]],[1,[10000]]]}}

artemii235 added a commit that referenced this issue Nov 20, 2020
… (#734)

* Fix max_taker_vol. Take min dex fee and KMD discount into account.
#733

* Fix comment about expected volume equation.
@artemii235
Copy link
Member

@smk762 Could you please confirm that it works fine now?

@smk762
Copy link
Author

smk762 commented Feb 14, 2021

Tested a few times, did not encounter the "required {coin} amount {amount} is larger than available {balance}" error.
Appears to be operating as intended, thanks!

@smk762 smk762 closed this as completed Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants