Skip to content

Better socialising of losses#220

Closed
naddison36 wants to merge 7 commits into
clement/model-a-loss-sharingfrom
nicka/model-a-loss-sharing
Closed

Better socialising of losses#220
naddison36 wants to merge 7 commits into
clement/model-a-loss-sharingfrom
nicka/model-a-loss-sharing

Conversation

@naddison36
Copy link
Copy Markdown
Collaborator

@naddison36 naddison36 commented May 11, 2026

Summary

This PR improves the Model A loss-sharing implementation by simplifying withdrawal queue accounting and making claimability share-denominated.

The main change is replacing the asset-side cumulative counters withdrawsQueued and withdrawsClaimed with a single reservedWithdrawLiquidity value. This value represents the maximum amount of liquidity assets that must remain reserved for outstanding withdrawal requests.

Changes

  • Replaced withdrawsQueued / withdrawsClaimed with reservedWithdrawLiquidity.
  • requestRedeem increases reservedWithdrawLiquidity by the request-time asset amount.
  • claimRedeem decreases reservedWithdrawLiquidity by request.assets, even if the actual loss-adjusted payout is lower.
  • Kept FIFO queue accounting share-denominated via withdrawsQueuedShares and withdrawsClaimedShares.
  • Changed claimable() to return the cumulative claimable share frontier instead of liquidity assets.
  • Updated claimRedeem to check request.queued <= claimable().
  • Simplified _availableAssets() so it only returns available assets.
  • Moved withdrawal reservation handling into the specific functions that need it, especially _allocate.

Claimability Semantics

claimable() now returns a cumulative share amount:

withdrawsClaimedShares + convertToShares(claimableLiquidity)

This means a UI can determine whether a request is claimable with:

request.queued <= claimable()

assuming the request is not already claimed and its claim delay has elapsed.

Accounting Model

This keeps the two accounting domains separate:

  • reservedWithdrawLiquidity is asset-denominated and protects liquidity for outstanding withdrawal requests.
  • withdrawsQueuedShares and withdrawsClaimedShares are share-denominated and define FIFO queue position.

This makes the pro-rata loss-sharing model easier to reason about while preserving the claim-time payout cap:

min(request.assets, convertToAssets(request.shares))

Notes

This PR changes the public meaning of claimable() from asset liquidity to a share-denominated queue frontier.

@naddison36 naddison36 changed the title Nicka/model a loss sharing Better socialising of losses May 12, 2026
@naddison36 naddison36 marked this pull request as ready for review May 14, 2026 03:45
@naddison36
Copy link
Copy Markdown
Collaborator Author

Closing in preference for #223

@naddison36 naddison36 closed this May 14, 2026
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.

1 participant