Skip to content

Latest commit

 

History

History
304 lines (244 loc) · 9.25 KB

File metadata and controls

304 lines (244 loc) · 9.25 KB

Idle Pot Yield Delegation to Stellar Pools Implementation

Overview

The Idle Pot Yield Delegation feature transforms SoroSusu from a "0% Interest Loan" into a "Yield-Generating Savings Engine" by allowing groups to delegate idle funds to Stellar liquidity pools while waiting for the end of the month. This provides a clear financial advantage over traditional physical Susu groups and maximizes capital efficiency.

Key Features

1. Smart Yield Generation

  • Groups can delegate idle pot funds to Stellar liquidity pools during waiting periods
  • Supports multiple pool types: Stellar Liquidity Pools, Regulated Money Markets, Stable Yield Vaults
  • Automatic compounding with weekly frequency
  • Real-time yield tracking and distribution

2. Democratic Control

  • 75% quorum requirement for yield delegation approval (higher stakes than rollover)
  • 80% supermajority approval threshold
  • 24-hour voting period for quick decision-making
  • Only active members can participate in voting

3. Fair Distribution

  • 50/50 Split: Half of yield goes to current round's winner, half to Group Treasury
  • Group Treasury funds can be used for future rollover bonuses
  • Transparent distribution tracking with audit trail
  • Automatic distribution upon withdrawal or compounding

4. Risk Management

  • Maximum 80% of pot can be delegated (maintains liquidity buffer)
  • Minimum delegation amounts to prevent micro-transactions
  • Pool registry system for trusted yield sources
  • Emergency withdrawal capabilities

Implementation Details

Data Structures

YieldDelegation

pub struct YieldDelegation {
    pub circle_id: u64,
    pub delegation_amount: i128,
    pub pool_address: Address,
    pub pool_type: YieldPoolType,
    pub delegation_percentage: u32, // Percentage of pot to delegate
    pub created_timestamp: u64,
    pub status: YieldDelegationStatus,
    pub voting_deadline: u64,
    pub for_votes: u32,
    pub against_votes: u32,
    pub total_votes_cast: u32,
    pub start_time: Option<u64>,
    pub end_time: Option<u64>,
    pub total_yield_earned: i128,
    pub yield_distributed: i128,
    pub last_compound_time: u64,
}

YieldPoolType

pub enum YieldPoolType {
    StellarLiquidityPool,
    RegulatedMoneyMarket,
    StableYieldVault,
}

YieldDistribution

pub struct YieldDistribution {
    pub circle_id: u64,
    pub recipient_share: i128,
    pub treasury_share: i128,
    pub total_yield: i128,
    pub distribution_time: u64,
    pub round_number: u32,
}

Constants

const YIELD_VOTING_PERIOD: u64 = 86400; // 24 hours
const YIELD_QUORUM: u32 = 75; // 75% quorum (higher stakes)
const YIELD_MAJORITY: u32 = 80; // 80% supermajority
const MIN_DELEGATION_AMOUNT: i128 = 100_000_000; // Minimum 10 tokens
const MAX_DELEGATION_PERCENTAGE: u32 = 8000; // Maximum 80% of pot
const YIELD_DISTRIBUTION_RECIPIENT_BPS: u32 = 5000; // 50% to current round winner
const YIELD_DISTRIBUTION_TREASURY_BPS: u32 = 5000; // 50% to group treasury
const YIELD_COMPOUNDING_FREQUENCY: u64 = 604800; // Weekly compounding

Core Functions

propose_yield_delegation(env, user, circle_id, delegation_percentage, pool_address, pool_type)

  • Initiates yield delegation proposal
  • Validates delegation limits and member status
  • Proposer automatically votes "For"
  • Emits YIELD_DELEGATION_PROPOSED event

vote_yield_delegation(env, user, circle_id, vote_choice)

  • Democratic voting on yield delegation proposals
  • Prevents double voting
  • Auto-approves if quorum and majority thresholds met
  • Emits YIELD_DELEGATION_VOTE event

approve_yield_delegation(env, circle_id)

  • Executes approved yield delegation
  • Registers yield pool in registry
  • Transfers funds to selected pool
  • Emits YIELD_DELEGATION_APPROVED event

execute_yield_delegation(env, circle_id)

  • Manually executes delegation if needed
  • Supports manual execution workflows
  • Emits YIELD_DELEGATION_EXECUTED event

compound_yield(env, circle_id)

  • Compounds earned yield from pools
  • Weekly compounding frequency
  • Updates total yield tracking
  • Emits YIELD_COMPOUNDED event

withdraw_yield_delegation(env, circle_id)

  • Withdraws funds from yield pool
  • Final yield calculation and distribution
  • Emits YIELD_DELEGATION_WITHDRAWN event

distribute_yield_earnings(env, circle_id)

  • Implements 50/50 yield distribution
  • Transfers share to current round recipient
  • Adds share to group treasury
  • Emits YIELD_DISTRIBUTED event

Economic Impact

For Groups

  • Increased Returns: 5-15% APY on idle funds vs 0% traditional
  • Capital Efficiency: Funds work while waiting for payout
  • Competitive Advantage: Clear benefit over physical Susu groups
  • Treasury Growth: Builds reserves for future bonuses

For Members

  • Higher Effective Returns: Yield supplements regular Susu payouts
  • Risk-Managed: Conservative delegation limits protect principal
  • Transparent: Clear tracking of all yield activities
  • Democratic Control: Group decides on participation

For Protocol

  • Higher User Retention: Better returns keep groups engaged
  • Network Effects: Yield opportunities attract new users
  • Platform Revenue: Potential for yield pool partnerships
  • Competitive Moat: Unique feature vs traditional savings

Integration Flow

1. Cycle Completion

All Members Contribute → Round Finalized → Payout Scheduled

2. Yield Delegation Window

Round Finalized → Yield Delegation Proposed → Group Votes → Delegation Approved

3. Yield Generation Period

Funds Delegated → Yield Compounds Weekly → Group Tracks Earnings

4. Distribution & Withdrawal

Yield Withdrawn → 50/50 Split → Recipient Paid → Treasury Funded

Security Considerations

1. Access Control

  • Only active members can propose and vote
  • Circle creator/admin can execute delegations
  • Pool registry prevents unauthorized pool usage

2. Vote Integrity

  • One vote per member enforcement
  • Immutable vote recording
  • Quorum and majority thresholds

3. Risk Management

  • Maximum delegation percentage (80%) limits exposure
  • Minimum delegation amounts prevent spam
  • Emergency withdrawal capabilities

4. Audit Trail

  • Complete logging of all yield operations
  • Transparent distribution tracking
  • Event emissions for off-chain monitoring

Usage Examples

Basic Yield Delegation

// Group decides to delegate 50% of idle funds
client.propose_yield_delegation(
    &member,
    &circle_id,
    &5000, // 50%
    &pool_address,
    &YieldPoolType::StellarLiquidityPool
);

// Other members vote
client.vote_yield_delegation(&member2, &circle_id, &YieldVoteChoice::For);
client.vote_yield_delegation(&member3, &circle_id, &YieldVoteChoice::For);

// Execute delegation
client.approve_yield_delegation(&circle_id);

Yield Compounding

// Weekly compounding
client.compound_yield(&circle_id);

Withdrawal and Distribution

// Withdraw and distribute earnings
client.withdraw_yield_delegation(&circle_id);

Events

YIELD_DELEGATION_PROPOSED

(circle_id, proposer, delegation_amount, delegation_percentage, pool_address, voting_deadline)

YIELD_DELEGATION_VOTE

(circle_id, voter, vote_choice, for_votes, against_votes)

YIELD_DELEGATION_APPROVED

(circle_id, delegation_amount, pool_address)

YIELD_COMPOUNDED

(circle_id, yield_earned, total_yield_earned)

YIELD_DELEGATION_WITHDRAWN

(circle_id, total_withdrawn, total_yield_earned)

YIELD_DISTRIBUTED

(circle_id, recipient_share, treasury_share, total_yield)

Testing

Test Coverage

  • ✅ Successful yield delegation proposal and voting
  • ✅ Yield delegation rejection scenarios
  • ✅ Yield calculation and compounding
  • ✅ Withdrawal and distribution logic
  • ✅ Edge cases and error conditions
  • ✅ Integration with existing pot management

Test Files

  • test_yield_delegation_proposal_and_voting() - Complete success scenario
  • test_yield_delegation_rejection() - Failure case validation

Future Enhancements

1. Dynamic Yield Optimization

  • Auto-selection of highest APY pools
  • Risk-based pool recommendations
  • Yield aggregation across multiple pools

2. Advanced Distribution Options

  • Customizable split ratios
  • Performance-based distribution
  • Treasury investment strategies

3. Cross-Protocol Integration

  • Integration with major DeFi protocols
  • Automated yield farming strategies
  • LP token rewards support

4. Risk Management Tools

  • Yield volatility protection
  • Insurance options for delegated funds
  • Stop-loss mechanisms

Conclusion

The Idle Pot Yield Delegation feature represents a significant advancement for the SoroSusu protocol, transforming it from a simple rotating savings mechanism into a sophisticated yield-generating platform. By enabling groups to earn returns on idle funds while maintaining the core Susu values of community savings and mutual support, this feature provides a compelling competitive advantage over traditional savings groups and positions SoroSusu as a leader in decentralized finance innovation on the Stellar network.

The combination of democratic governance, risk management, and fair distribution ensures that the feature enhances user value while maintaining the security and transparency that users expect from the SoroSusu protocol.