fix(contracts): error on malformed DeFindex valuation, add vault zero-assets backstop - #590
Open
laurentketterle-hub wants to merge 1 commit into
Conversation
…-assets backstop DefindexAdapter::total_assets() is the denominator of the vault's share-pricing formula. On a malformed get_asset_amounts_per_shares response, amounts.get(0).unwrap_or(0) manufactured a valid-looking zero price, collapsing the denominator to OFFSET and letting any meaningful deposit mint a share count that dilutes every prior depositor. - defindex-adapter: total_assets() now panics with MalformedProtocolResponse when a held position cannot be valued, instead of returning zero. - vault: deposit() rejects with AdapterReportedNoAssets when shares are outstanding but the adapter reports zero/negative total assets, so no present or future adapter can drive the pricing denominator to zero. Closes drydocs#555 Signed-off-by: laurentketterle-hub <laurentketterle-hub@users.noreply.github.com>
|
@laurentketterle-hub is attempting to deploy a commit to the Collins' projects Team on Vercel. A member of the Team first needs to authorize it. |
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
DefindexAdapter::total_assets()is the denominator of the vault's share-pricing formula. On a malformedget_asset_amounts_per_sharesresponse,amounts.get(0).unwrap_or(0)manufactured a valid-looking zero price, collapsing the denominator toOFFSETand letting any meaningful deposit mint a share count that dilutes every prior depositor.total_assets()now fails with a newMalformedProtocolResponseerror when a held position cannot be valued, instead of silently returning zero. A genuinely empty position (shares <= 0) still returns zero, which is the truth.deposit()now rejects with a newAdapterReportedNoAssetserror when shares are outstanding but the adapter reports zero/negative total assets — a vault-side backstop that holds regardless of which adapter is active.Test plan
cargo fmt --all -- --checkpassescargo clippy --all-targets -- -D warningspassescargo testpasses (all 14 blend, 13 defindex, 44 vault tests green)cargo build --target wasm32-unknown-unknown --releasesucceedsCloses #555