Repository navigation
docs(contracts): document RepoDvP margin and maturity semantics in AUDIT_NOTES (#204) - #1274
Merged
DevTobis merged 3 commits intoNov 26, 2026
Conversation
…functions instead of line numbers, note DevTobis#203 now asserted
Owner
|
Thanks @Anambraboi-1! You documented the RepoDvP margin and maturity semantics in AUDIT_NOTES for #204:
Each item gives its consequence and links its issue. I merged |
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.
Closes #204
Adds a Margin and maturity semantics list to the RepoDvP section of
contracts/AUDIT_NOTES.md. Each item gives the behaviour, the code reference and what it means for consumers or lenders. Each also links to its tracking issue where one exists.Behaviours documented
margin_call_amountis a value shortfall, not a unit count. It is in post-haircut USDC base units (lib.rs:1067-1071). The item gives the formula that converts it to RWA units. It also notes that a partialtop_upleaves the figure stale (RepoDvp.top_up leaves margin_call_amount stale after a partial top-up #847) and that its exact value is not yet asserted in tests (Assert the exact margin_call_amount computed by RepoDvp.call_margin #203).maturity_at.lib.rs:523caps accrual at maturity, so margin,default_closeandunwindall use the same figure. There is no late interest. (RepoDvp margin exposure keeps accruing after maturity but unwind charges only to maturity #218)default_at_maturity, notdefault_close.default_closeneeds an open margin call (lib.rs:1152-1154).default_at_maturitycan act only aftermaturity_at + maturity_grace. (Add a maturity default path to RepoDvp for a borrower who does not repay at leg 2 #26)Okprice. There is no last-good fallback (lib.rs:1163-1164,lib.rs:1239-1242), so the lender carries the price risk until the halt clears. Tests for these refusals are tracked in Test RepoDvp.default_close authorisation and precondition failures #237.The "Cash legs are not escrowed" bullet now also covers the borrower-side allowance overwrite. Every
accept_and_settlereplaces the borrower's allowance, which is why the contract approves the runningBorrowerDuesum. The bullet links #843.Note on the issue text
Two facts in the issue are out of date on
main:evaluate_marginis now capped at maturity (RepoDvp margin exposure keeps accruing after maturity but unwind charges only to maturity #218).default_at_maturity, Add a maturity default path to RepoDvp for a borrower who does not repay at leg 2 #26).The notes describe the code as it is now and say what changed.
Finding while writing this
default_at_maturitydoes not callrelease_borrower_due, butunwindanddefault_closedo. As a result, a trade defaulted at maturity stays in the borrower'sBorrowerDuesum, and every later settle approves more than the borrower owes. The notes record this. A code fix is out of scope for this docs PR.Docs only. No code changes, so the WASM hash is unchanged.