Itheum / data-dex

DApp with suite of web3 tools to trade personal data on MultiversX
https://datadex.itheum.io
GNU General Public License v3.0
466 stars 6 forks source link

Error seen when performing early withdrawal in specific scenario #1289

Closed fuzzyduke closed 5 months ago

fuzzyduke commented 5 months ago

Bond amount: 10 ITHEUM

Penalty was set to 5% Maximum Slash: 50% Early withdrawal:35%

After penalty of 5% was applied, 9.5 ITHEUM remained After Slash of 50% was applied, 4.5 remained Early withdrawal of 35% threw an error below, when we still have 45% remaining. It should deduct and return 10% to the user.

https://devnet-explorer.multiversx.com/transactions/e8a346efc1cb30d5791c9dd390829631937e886b5da03890b23061522fd33d45

image image

bucurdavid commented 5 months ago

This fall more into this case: Image

Bond Value Compensation Value
bond amount 10 ITHEUM accumulated amount 0 ITHEUM
remaining amount 10 ITHEUM
After 5% and 50% Bond Value Compensation Value
bond amount 10 ITHEUM accumulated amount 5.5 ITHEUM
remaining amount 4.5 ITHEUM

If user tries to withdraw before unbond period(timestamp) 35% is added

After another 35% Bond Value Compensation Value
bond amount 10 ITHEUM accumulated amount 5.5 + 3.5(9) ITHEUM
remaining amount 4.5 - 3.5 (1.5) ITHEUM

But there is another check here: remaining amount (4.5) - penalty (3.5) > accumulated_amount (5.5), because this check is false the value it's "forfeit".

The user should be able to withdraw 1.5 after the unbond period has passed.

CC: @damienen @newbreedofgeek

damienen commented 5 months ago

Solved. Closing