Skip to content

[CT-23] Implement dividend streaming in assetsup/dividends.rs in opsce crate #822

@yusuftomilola

Description

@yusuftomilola

Problem

contracts/assetsup/src/dividends.rs implements lump-sum dividend distribution but does not support continuous streaming. Token holders must wait for periodic distributions rather than earning dividends proportionally per second.

Proposed Solution

Create contracts/opsce/src/dividend_stream.rs. Implement a streaming dividend mechanism where a pool of funds is distributed linearly over a defined period, and holders can claim their accrued share at any time.

Acceptance Criteria

  • start_dividend_stream(env, asset_id, total_amount, duration_seconds) initiates a stream (admin only)
  • calculate_claimable(env, asset_id, holder) returns tokens earned since last claim based on proportional share and elapsed time
  • claim_stream_dividends(env, asset_id) transfers accrued amount to caller and updates last-claim timestamp
  • end_dividend_stream(env, asset_id) stops the stream and returns unclaimed funds to admin
  • Emits stream_started, dividends_claimed, and stream_ended events
  • Unit tests cover: proportional share calculation, multiple claims, zero-balance holder, stream end

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions