Better socialising of losses#220
Closed
naddison36 wants to merge 7 commits into
Closed
Conversation
Collaborator
Author
|
Closing in preference for #223 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
withdrawsQueuedandwithdrawsClaimedwith a singlereservedWithdrawLiquidityvalue. This value represents the maximum amount of liquidity assets that must remain reserved for outstanding withdrawal requests.Changes
withdrawsQueued/withdrawsClaimedwithreservedWithdrawLiquidity.requestRedeemincreasesreservedWithdrawLiquidityby the request-time asset amount.claimRedeemdecreasesreservedWithdrawLiquiditybyrequest.assets, even if the actual loss-adjusted payout is lower.withdrawsQueuedSharesandwithdrawsClaimedShares.claimable()to return the cumulative claimable share frontier instead of liquidity assets.claimRedeemto checkrequest.queued <= claimable()._availableAssets()so it only returns available assets._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:
reservedWithdrawLiquidityis asset-denominated and protects liquidity for outstanding withdrawal requests.withdrawsQueuedSharesandwithdrawsClaimedSharesare 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.