DeFiCh / ain

DeFi Blockchain - enabling decentralized finance on Bitcoin
https://defichain.com
MIT License
399 stars 118 forks source link

History for Vault Withdraw not correct on tiny amounts #2803

Open marcelkb opened 7 months ago

marcelkb commented 7 months ago

Summary

If the amount is really small like 9.3e-07 the withdrawn amount and the info from the history does not match

{"method": "withdrawfromvault", "params": ["591882453d1c682bbc1aaaddaf5b0b3801416e1089386b99581c28f28dbb5bfc", "dTGeTGkayryJFi1tc6ERNnsL7eo4G5CbaZ", "9.3e-07@DUSD", [{"txid": "37153751df5f721636b38af31948978042cae635298f61561c3f1ef792550f37", "vout": 1, "amount": 0.19847125}]], "jsonrpc": "2.0"}

9.3e-07@DUSD vs. 0.00012317 DUSD

{"method": "listaccounthistory", "params": ["dTGeTGkayryJFi1tc6ERNnsL7eo4G5CbaZ", {"depth": 240, "no_rewards": true, "txtype": "J"}], "jsonrpc": "2.0"} and looking for txid in history

returns 0.00012317@DUSD as amount

image

Defiscan Block Explorer shows correct amount https://defiscan.live/transactions/37153751df5f721636b38af31948978042cae635298f61561c3f1ef792550f37

Steps to Reproduce

Take small DUSD loan and look in the history

Environment

Bushstar commented 7 months ago

Please use listvaulthistory to get the correct information about vault withdrawals. listaccounthistory is not able to track all changes that occur in vault TXs. In listvaulthistory what you are seeing is the owner reward calculations for the destination address of the withdrawal. To be able to use the vault index make sure that vaultindex=1 is specified in your defi.conf file. You will need to either reindex, perform a clean sync or use the snapshots which already have the vault index present.