Skip to content

Investment Module (Strategies, Participations)

Overview

The Investment Module manages the investment marketplace of the IWM Platform, allowing users to participate in various investment strategies. It handles strategy configuration, multi-step participation wizards, investment lifecycle management, portfolio tracking, and returns distribution. The module integrates with the MLM Module for referral attribution and commission calculation.

Responsibilities

  • Investment strategy management
  • Strategy categorization and discovery
  • Multi-step participation wizard
  • Investment lifecycle tracking
  • Portfolio aggregation and reporting
  • Returns calculation and distribution
  • Early withdrawal handling
  • Referral attribution for investments

Domain Entities

Strategy

Investment strategy definition.

FieldTypeDescription
idUUIDStrategy identifier
category_idUUIDCategory reference
nameVARCHAR(200)Strategy name
codeVARCHAR(50)Unique strategy code
slugVARCHAR(200)URL-friendly identifier
short_descriptionVARCHAR(500)Brief description
descriptionTEXTFull description
termsTEXTLegal terms and conditions
risk_levelENUMLOW, MEDIUM, HIGH, VERY_HIGH
min_amountDECIMALMinimum investment
max_amountDECIMALMaximum investment (optional)
duration_monthsINTInvestment term
expected_return_minDECIMALMinimum expected return %
expected_return_maxDECIMALMaximum expected return %
image_urlVARCHAR(500)Strategy image
documents_urlsJSONBRelated documents
statusENUMStrategy status
participants_countINTActive participants
total_investedDECIMALTotal amount invested
published_atTIMESTAMPPublication date

StrategyCategory

Category for organizing strategies.

FieldTypeDescription
idUUIDCategory identifier
nameVARCHAR(100)Category name
slugVARCHAR(100)URL-friendly identifier
descriptionTEXTCategory description
parent_idUUIDParent category
sort_orderINTDisplay order
is_activeBOOLEANActive status

ParticipationStep

Wizard step configuration for a strategy.

FieldTypeDescription
idUUIDStep identifier
strategy_idUUIDStrategy reference
step_numberINTStep order
titleVARCHAR(200)Step title
descriptionTEXTStep instructions
step_typeENUMStep type
configJSONBStep configuration
is_requiredBOOLEANRequired flag

Participation

User's investment participation.

FieldTypeDescription
idUUIDParticipation identifier
user_idUUIDInvestor reference
strategy_idUUIDStrategy reference
current_stepINTCurrent wizard step
step_dataJSONBCollected wizard data
amountDECIMALInvestment amount
currencyVARCHAR(3)Currency code
statusENUMParticipation status
referring_partner_idUUIDMLM attribution
started_atTIMESTAMPWizard start time
submitted_atTIMESTAMPSubmission time
approved_atTIMESTAMPApproval time
completed_atTIMESTAMPCompletion time

Portfolio

User's active investment portfolio entry.

FieldTypeDescription
idUUIDPortfolio entry identifier
user_idUUIDInvestor reference
participation_idUUIDSource participation
strategy_idUUIDStrategy reference
invested_amountDECIMALOriginal investment
current_valueDECIMALCurrent value
total_returnsDECIMALAccumulated returns
currencyVARCHAR(3)Currency code
statusENUMPortfolio status
start_dateDATEInvestment start
maturity_dateDATEExpected maturity
last_updated_atTIMESTAMPLast value update

Strategy Types and Configuration

Risk Levels

Risk LevelExpected ReturnVolatilitySuitable For
LOW5-8% annualLowConservative investors
MEDIUM8-15% annualModerateBalanced portfolios
HIGH15-25% annualHighGrowth seekers
VERY_HIGH25%+ annualVery HighRisk-tolerant investors

Strategy Status Flow

Strategy Configuration Example

json
{
  "name": "Growth Portfolio 2024",
  "code": "GROWTH_2024",
  "risk_level": "HIGH",
  "min_amount": 50000,
  "max_amount": 5000000,
  "duration_months": 12,
  "expected_return_min": 15.0,
  "expected_return_max": 25.0,
  "terms": "Investment terms and conditions...",
  "documents_urls": [
    {"type": "prospectus", "url": "/docs/growth-2024-prospectus.pdf"},
    {"type": "risk_disclosure", "url": "/docs/risk-disclosure.pdf"}
  ]
}

Participation Wizard

Multi-Step Process

The participation wizard guides users through the investment process:

Step Types

TypeDescriptionConfiguration
INFORead-only information displaycontent, acknowledgement
FORMData collection formfields, validation rules
DOCUMENT_UPLOADFile upload requirementdocument_types, max_size
KYC_CHECKKYC verification gaterequired_level
PAYMENTPayment processingpayment_methods
CONFIRMATIONFinal review and submitsummary_fields

Step Configuration Examples

INFO Step:

json
{
  "step_type": "INFO",
  "config": {
    "content": "Strategy overview and risk disclosure...",
    "acknowledgement_required": true,
    "acknowledgement_text": "I have read and understood the risks"
  }
}

FORM Step:

json
{
  "step_type": "FORM",
  "config": {
    "fields": [
      {
        "name": "investment_amount",
        "type": "number",
        "label": "Investment Amount",
        "min": 50000,
        "max": 5000000,
        "required": true
      },
      {
        "name": "investment_goal",
        "type": "select",
        "label": "Investment Goal",
        "options": ["retirement", "education", "wealth_growth"],
        "required": true
      }
    ]
  }
}

KYC_CHECK Step:

json
{
  "step_type": "KYC_CHECK",
  "config": {
    "required_level": "STANDARD",
    "allow_skip": false,
    "redirect_to_kyc": true
  }
}

Validation at Each Step


Investment Lifecycle

Participation Status Flow

Status Definitions

StatusDescription
IN_PROGRESSUser completing wizard steps
PENDING_APPROVALSubmitted, awaiting approval
ACTIVEInvestment is active
COMPLETEDInvestment matured successfully
WITHDRAWNEarly withdrawal processed
CANCELLEDUser cancelled before activation
REJECTEDAdmin rejected application

Portfolio Status Flow


Portfolio Aggregation

Portfolio Calculations

Portfolio Metrics

MetricCalculation
Total InvestedSum of all invested_amount
Current ValueSum of all current_value
Total ReturnsSum of all total_returns
ROI(Current Value - Total Invested) / Total Invested * 100
Active InvestmentsCount where status = ACTIVE

Portfolio by Strategy

sql
SELECT
    s.name as strategy_name,
    COUNT(*) as investments,
    SUM(p.invested_amount) as total_invested,
    SUM(p.current_value) as current_value,
    SUM(p.total_returns) as returns
FROM portfolios p
JOIN strategies s ON p.strategy_id = s.id
WHERE p.user_id = :userId
GROUP BY s.id, s.name;

Returns Distribution

Distribution Flow

Return Calculation Methods

MethodDescriptionUse Case
FixedFixed percentage per periodConservative strategies
VariableBased on market performanceGrowth strategies
TieredDifferent rates based on amountLarge investor incentives
CompoundReturns reinvestedLong-term strategies

Returns Distribution Schedule

FrequencyDescription
MonthlyReturns calculated and distributed monthly
QuarterlyEvery 3 months
At MaturitySingle distribution at end of term
ContinuousDaily accrual, monthly distribution

Returns Crediting

Returns can be credited to:

  1. User Balance - Available for withdrawal or reinvestment
  2. Reinvestment - Automatically added to portfolio
  3. MLM Balance - If user is also a partner

Early Withdrawal

Withdrawal Rules

Withdrawal TimingPenaltyConditions
0-3 months10% of returnsFull principal returned
3-6 months5% of returnsFull principal returned
6-12 months2% of returnsFull principal returned
After maturityNo penaltyFull value available

Early Withdrawal Flow

Penalty Calculation

typescript
function calculateWithdrawalAmount(
  portfolio: Portfolio,
  currentDate: Date
): WithdrawalResult {
  const monthsInvested = differenceInMonths(currentDate, portfolio.start_date);

  let penaltyRate = 0;
  if (monthsInvested < 3) penaltyRate = 0.10;
  else if (monthsInvested < 6) penaltyRate = 0.05;
  else if (monthsInvested < 12) penaltyRate = 0.02;

  const returns = portfolio.current_value - portfolio.invested_amount;
  const penalty = returns * penaltyRate;
  const finalAmount = portfolio.current_value - penalty;

  return {
    invested_amount: portfolio.invested_amount,
    returns: returns,
    penalty: penalty,
    final_amount: finalAmount
  };
}

Events Published

EventTriggerPayload
StrategyCreatedNew strategy createdstrategyId, code, name
StrategyPublishedStrategy goes livestrategyId, publishedAt
StrategyStatusChangedStatus transitionstrategyId, fromStatus, toStatus
ParticipationStartedUser begins wizardparticipationId, userId, strategyId
ParticipationStepCompletedWizard step doneparticipationId, stepNumber, stepData
ParticipationSubmittedWizard completedparticipationId, userId, amount
ParticipationApprovedAdmin approvesparticipationId, approvedBy
ParticipationRejectedAdmin rejectsparticipationId, reason
ParticipationActivatedInvestment activeparticipationId, portfolioId
ParticipationCancelledUser cancelsparticipationId, reason
InvestmentMaturedTerm completedportfolioId, finalValue
ReturnsDistributedReturns creditedportfolioId, amount, period
WithdrawalRequestedUser requests withdrawalportfolioId, amount
WithdrawalCompletedWithdrawal processedportfolioId, amount, penalty
PortfolioValueUpdatedValue recalculatedportfolioId, previousValue, newValue

Events Consumed

EventSourceHandler
ReferralAttributedMLMStore referral on participation
PaymentReceivedCommerceActivate participation
PaymentFailedCommerceCancel participation
KycApprovedCoreUnblock KYC-gated participations

Business Rules and Invariants

Strategy Rules

  1. Minimum amount must be positive
  2. Maximum amount must be greater than minimum (if set)
  3. Expected return max must be >= min
  4. Duration must be positive (if set)
  5. Only ACTIVE strategies accept new participations

Participation Rules

  1. User cannot have multiple IN_PROGRESS participations for same strategy
  2. Amount must be within strategy min/max bounds
  3. All required steps must be completed before submission
  4. KYC level must meet strategy requirements
  5. Payment must be received for activation

Portfolio Rules

  1. Current value cannot be negative
  2. Invested amount is immutable after creation
  3. Returns are credited to total_returns
  4. Status must follow defined state machine
  5. Maturity date is calculated from start_date + duration

Returns Rules

  1. Returns calculated based on strategy configuration
  2. Early withdrawal penalties apply as defined
  3. Returns credited to user balance or reinvested
  4. MLM commissions triggered on activation (not returns)

Integration Points

Provides to Other Modules

InterfaceConsumersPurpose
IInvestmentServiceMLMGet investment details for commission
IPortfolioServiceCoreUser portfolio summary

Consumes from Other Modules

InterfaceProviderPurpose
IUserLookupServiceCoreGet investor details
IKycStatusServiceCoreCheck KYC level for participation
IAttributionServiceMLMGet referral partner for investment
IPaymentServiceCommerceProcess investment payments