feat: implement multi-asset collateral support#111
Merged
Smartdevs17 merged 7 commits intoSmartdevs17:mainfrom Mar 24, 2026
Merged
feat: implement multi-asset collateral support#111Smartdevs17 merged 7 commits intoSmartdevs17:mainfrom
Smartdevs17 merged 7 commits intoSmartdevs17:mainfrom
Conversation
- Add UserAssetCollateral(user, asset) and UserAssetList(user) storage keys to DepositDataKey - Add record_asset_deposit and record_asset_withdrawal helpers in deposit.rs - Update deposit_collateral to track per-asset balances alongside aggregate balance - Update withdraw_collateral to update per-asset records on each withdrawal - Add multi_collateral.rs module with get_user_asset_collateral, get_user_asset_list, calculate_total_collateral_value (oracle-priced, collateral-factor weighted), and has_multi_asset_collateral helpers - Update borrow.rs health factor check to use oracle-priced total for multi-asset users - Update liquidate.rs to use per-asset collateral records and oracle-priced total for check - Expose get_user_asset_collateral, get_user_asset_list, get_user_total_collateral_value on HelloContract in lib.rs - Add comprehensive multi_collateral_test.rs covering per-asset tracking, asset list management, withdrawal updates, total collateral value calculation, and borrow health - Maintain full backward compatibility: aggregate CollateralBalance always updated - Guard token transfer calls with #[cfg(not(test))] in deposit.rs and withdraw.rs
|
@olathedev is attempting to deploy a commit to the smartdevs17's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@olathedev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Owner
|
fix conflicts |
…collateral - Resolved lib.rs conflict: kept both treasury (Smartdevs17#101) and multi-asset collateral (Smartdevs17#86) sections - Fixed auto-merge duplicate enum variants in oracle.rs (PrimaryOracle, FallbackFeed) - Fixed auto-merge duplicate enum variant in storage.rs (MultisigAdmins) - Fixed duplicate imports in multisig.rs (GovernanceError, Proposal types) - Added missing imports in governance.rs (ProposalCreatedEvent, ProposalExecutedEvent, ProposalFailedEvent, MIN_TIMELOCK_DELAY, risk_params, risk_management, interest_rate)
….com/olathedev/stellarlend into feat/issue-86-multi-asset-collateral
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
Closes #86
UserAssetCollateral(user, asset)andUserAssetList(user)storage keys to track each asset independently alongside the existing aggregateCollateralBalancemulti_collateral.rswithget_user_asset_collateral,get_user_asset_list,calculate_total_collateral_value(oracle-priced, collateral-factor weighted), andhas_multi_asset_collateralborrow.rsandliquidate.rsnow branch onhas_multi_asset_collateral— multi-asset users get oracle-priced total collateral value; legacy single-asset users retain existing aggregate pathCollateralBalance(user)is always maintained so existing single-asset users are unaffectedget_user_asset_collateral,get_user_asset_list,get_user_total_collateral_valueexposed onHelloContractTest plan
multi_collateral_test.rscovering: per-asset deposit/withdrawal tracking, asset list deduplication and cleanup, total collateral value with collateral factors, borrow health factor with multi-asset collateral, user isolationcargo test