Skip to content

[ETHEREUM-CONTRACTS] distinguish between unsettled and claimable balance in pools#2084

Merged
hellwolf merged 12 commits intodevfrom
2025-06-fix-claimable
Jul 18, 2025
Merged

[ETHEREUM-CONTRACTS] distinguish between unsettled and claimable balance in pools#2084
hellwolf merged 12 commits intodevfrom
2025-06-fix-claimable

Conversation

@d10r
Copy link
Collaborator

@d10r d10r commented Jun 26, 2025

What & Why

getClaimable should return the amount which will be added to the balance if calling claimAll. This is currently not the case, because the implementation mixes up the concepts of claimable amount and unsettled amount.

The point of the claiming concept is to allow pool members to fetch tokens allocated to them even when they are not connected to that pool. If the pool is connected, there's nothing to be claimed - the connected status could conceptually also be seen as being continuous auto-claiming.

If getClaimable returns a non-zero number, a call of claimAll is expected to add that amount to the user balance.
With the current implementation that is true only for unconnected pools.

How

The inconsistency is solved by making getClaimable always return 0 for connected pools.
This is achieved by having distinct logic for internal settlement and for claiming.

@d10r d10r requested a review from hellwolf as a code owner June 26, 2025 14:53
@github-actions
Copy link

github-actions bot commented Jun 26, 2025

Changelog Reminder

Reminder to update the CHANGELOG.md for any of the modified packages in this PR.

  • CHANGELOG.md modified
  • Double check before merge

@hellwolf hellwolf marked this pull request as draft June 30, 2025 10:35
@hellwolf
Copy link
Contributor

what prompted this issue? I prefer this be done after #2086 refactoring.

@d10r
Copy link
Collaborator Author

d10r commented Jun 30, 2025

what prompted this issue? I prefer this be done after #2086 refactoring.

Surprising behaviour when working on tests in the context of autoconnect (not yet pushed). And yes, should be after #2086 then.

@hellwolf
Copy link
Contributor

hellwolf commented Jul 4, 2025

UnsettledValue shouldn't be "leaked" as such.

I will reject this one for now.

I will continue from #2086, where we can touch this topic, too.

@d10r
Copy link
Collaborator Author

d10r commented Jul 15, 2025

this is now based on #2086

@d10r d10r reopened this Jul 15, 2025
@d10r d10r marked this pull request as ready for review July 16, 2025 15:46
@d10r
Copy link
Collaborator Author

d10r commented Jul 16, 2025

UnsettledValue shouldn't be "leaked" as such.

Note that it's not part of the interface. The PR doesn't change the public interface, it just fixes the behaviour of getClaimable and getClaimableNow. getUnsettledValue is conceptually private, but has public visibility because the GDA needs it too.


function _claimAll(address memberAddr, uint32 time) internal returns (int256 amount) {
amount = getClaimable(memberAddr, time);
function _settle(address memberAddr, int256 amount) internal {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have to reject this impelemtation, for design reason:

This function is effectful and has no constraint on what "amount" can be provided to it. Because of this, now as a code reader, you will have to worry if all the call sites of this function provided this "amount" correctly. The more robust design is to avoid such possibility, keep reasoning of correctness local.

In this case, it is quite easy to do, I will do a change in the following commmit.

Copy link
Contributor

@hellwolf hellwolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkout the updated _settle, then we can merge.

Signed-off-by: pavedroad <qcqs@outlook.com>
@hellwolf hellwolf merged commit 7d56c30 into dev Jul 18, 2025
22 checks passed
@hellwolf hellwolf deleted the 2025-06-fix-claimable branch July 18, 2025 07:34
@github-actions
Copy link

XKCD Comic Relif

Link: https://xkcd.com/2084
https://xkcd.com/2084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants