Dealing with refunds of maximum amount #322
Replies: 4 comments 4 replies
-
Huh — this is an interesting case where end-to-end product integration uncovered a UX issue that would have been difficult to spot otherwise. Solution 1 seems the most straightforward. Let's go with that. There might be cases where users want to refund a particular amount for accounting reasons, e.g., they made a big deposit accidentally and wish to receive a portion back. Also, having two discrete functions |
Beta Was this translation helpful? Give feedback.
-
my vote is for |
Beta Was this translation helpful? Give feedback.
-
Closing as per a majority vote |
Beta Was this translation helpful? Give feedback.
-
Solution 2 would be the one that's the least prone to errors. Its downside, as mentioned on slack is the user-facing form UX (we'd present the user with a percentage slider rather than an actual amount input). PRBs point re. accounting reasons and Mircea's take re. consistency with our other forms is what makes me wonder if it's the best choice... It covers all the bad cases execution-wise, but doesn't offer the best UX. Solution 1 is an easy win. I think most cases will be of people wanting to "rage quit" a.k.a. void + withdraw + refund, which requires Solution 3 is a nice mix between not-reverting and having a |
Beta Was this translation helpful? Give feedback.
-
Context
@razgraf pointed out in the Slack that refund would very likely revert if it's called with the
refundableAmountOf
. TherefundableAmountOf
returns the maximum amount that a user can withdraw, and by the time transaction is mined in the block, this amount would have already exceeded the maximum amount that can be refunded at the block timestamp (due to streaming). This makes it impossible for a user to withdraw the max amount until dealing with a paused stream.batch
can also not be used in this case since there is no way to enter the returned value of one function as the input parameter of another. We will think about improvingbatch
in the future release. But for now three simple solutions have been discussed on Slack to resolve this.Solutions
Solution 1
Implement
refundMax
that implicitly calculates the max refundable amount.Solution 2
Replace
amount
input with apercentage
inrefund
function. So if 50% is provided as input, a refund of 50% of the max refundable will be processed.Solution 3
The
refund
can be modified to allowmaxAmount
instead ofamount
to signal how much maximum the user wants to refund. So, in cases where the maximum refundable amount goes down by the time the tx is included in a block, the function would still make a refund but with the max amount at that time.These two solutions have been discussed on the Slack. Feel free to share more ideas. cc @sablier-labs/engineers
Beta Was this translation helpful? Give feedback.
All reactions