CYS3-06: Policies Can Be Backed By Unswappable Collateral - #106
Merged
Merged
Conversation
dB2510
approved these changes
May 9, 2026
Comment on lines
+52
to
+54
| address public override claimManager; | ||
| mapping(bytes32 routeKey => uint256 lockedUntil) private _routeLockedUntil; | ||
| mapping(address target => uint256 lockedUntil) private _targetLockedUntil; |
Member
There was a problem hiding this comment.
these change will not collide with the existing storage variables, right?
Contributor
Author
There was a problem hiding this comment.
Yes, we will just extend the storage, not replace it.
| * `payoutToken` (via `ClaimManager.validateAndLockCollateralRoutes`), locks those routes | ||
| * until `maturityTime`, and returns the aggregate USD value of all staked collateral. | ||
| */ | ||
| function _validateRoutesAndComputeStake( |
Member
There was a problem hiding this comment.
why you moved total stake calculation inside this function?
Contributor
Author
There was a problem hiding this comment.
The stake computation was moved inside precisely to enforce the invariant from the audit: collateral should only count toward backing if it can actually be used for settlement. If the stake loop lived separately in bindPolicy(), we would have a logical gap where totalStakeUSD gets computed unconditionally for all tokens, but route validation could revert later.
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.
Note
High Risk
High risk because it changes core policy-binding invariants and introduces time-based route/target locks in
Swapper, which can block admin reconfiguration and affect claim settlement if mis-wired or misconfigured.Overview
Fixes CYS3-06 by adding bind-time validation that every non-payout collateral token has a working
Swapperquote route to the policypayoutToken, and by locking those routes until policy maturity so they can’t be disabled or pointed at a new target while policies are active.PolicyManager.bindPolicynow callsClaimManager.validateAndLockCollateralRoutesbefore counting collateral toward the USD backing check;SwapperaddsclaimManagerwiring plus route/target lock tracking and enforces the locks insetSwapRouteandsetSwapTargetWhitelist. Wiring/scripts, docs, and unit/fork tests are updated to requireSwapper.setClaimManager(claimManager)and to cover the new revert/lock behaviors.Reviewed by Cursor Bugbot for commit 521a538. Bugbot is set up for automated code reviews on this repo. Configure here.