Skip to content

Implement Core Portfolio Management Functionality for DynamoFi#1

Open
ola-usman wants to merge 6 commits intomainfrom
feat/implement
Open

Implement Core Portfolio Management Functionality for DynamoFi#1
ola-usman wants to merge 6 commits intomainfrom
feat/implement

Conversation

@ola-usman
Copy link
Copy Markdown
Owner

Summary:
This PR introduces the core functionality for the DynamoFi protocol smart contracts, enabling users to create, manage, and track self-custodial portfolios on the Stacks L2.

Key Changes:

Read-Only Functions

  • get-portfolio: Fetch portfolio metadata by ID.
  • get-portfolio-asset: Retrieve asset details by portfolio and index.
  • get-user-portfolios: List all portfolio IDs owned by a user.
  • calculate-rebalance-amounts: Determines if rebalancing is required.

Private Helpers

  • Validation: Token ID checks, percentage validation
  • Initialization: initialize-token-at-index, initialize-portfolio-asset, add-to-user-portfolios

Public Functions

  • create-portfolio: Creates a new portfolio with up to 10 token allocations (basis point-based).
  • rebalance-portfolio: Updates portfolio state post-rebalancing.
  • update-portfolio-allocation: Allows users to adjust target allocations.
  • initialize: Sets the protocol owner/admin.

Benefits:

  • Enables decentralized portfolio creation and management
  • Enforces allocation and token constraints
  • Establishes secure, owner-only mutation logic
  • Lays groundwork for future integration with automated rebalancing and token swaps

Developer Notes:

  • All functions written in Clarity
  • Compatible with Stacks-based frontends and wallets
  • Follows best practices for storage limits and error handling

ola-usman added 6 commits May 15, 2025 10:28
- Implemented get-portfolio, get-portfolio-asset, and get-user-portfolios read-only functions
- Enables efficient querying of portfolio and asset details by users
- Improves protocol transparency and user experience
- Implemented calculate-rebalance-amounts read-only function
- Added private functions for token ID and percentage validation
- Improves portfolio integrity and supports automated rebalancing logic
- Implemented add-to-user-portfolios to manage user portfolio lists
- Added initialize-portfolio-asset and initialize-token-at-index for asset setup
- Streamlines portfolio creation and asset allocation processes
- Adds create-portfolio to allow users to create portfolios with custom tokens and allocations
- Initializes up to 10 tokens per portfolio and validates input constraints
- Updates user portfolio list and increments portfolio counter
- Enhances protocol usability and onboarding for new portfolios
- Implemented rebalance-portfolio to update last rebalanced timestamp
- Added update-portfolio-allocation for dynamic asset allocation changes
- Introduced initialize for protocol ownership transfer
- Improves protocol flexibility, security, and portfolio management
- Provides detailed protocol overview, architecture, and smart contract logic
- Documents features, security, error handling, and roadmap
- Improves developer onboarding and project transparency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant