flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Smart Contracts] Auto-Yield & DeFi Lending Pool Integration for Idle Streaming Deposits

Open blurbeast opened this issue 3 months ago • 10 comments

Overview & Background

In standard payment streams, unvested tokens sit idle inside the smart contract storage until accrued and withdrawn. For large payroll accounts and multi-month vesting schedules, substantial capital is locked without generating return. Integrating with Soroban-native DeFi lending markets (such as Blend Protocol or liquidity pools) allows the protocol to earn yield on deposited collateral, which can be split between the stream sender and the protocol treasury.


Detailed Problem Statement

  • Large locked deposits suffer from opportunity cost and inflationary decay over long vesting durations.
  • Protocols competing in the DeFi streaming landscape (such as Superfluid and Sablier) offer yield-bearing streaming.

Technical Specification & Architecture

1. Yield Strategy Interface

Define an abstract yield adapter interface in contracts/stream_contract/src/yield_strategy.rs:

pub trait YieldStrategy {
    fn deposit(env: &Env, token: &Address, amount: i128) -> Result<i128, StreamError>;
    fn withdraw(env: &Env, token: &Address, shares: i128) -> Result<i128, StreamError>;
    fn get_exchange_rate(env: &Env, token: &Address) -> i128;
}

2. Strategy Integration in Stream Contract

  1. Support an optional yield_enabled: bool flag on stream creation.
  2. When enabled, idle deposited tokens are routed to the verified yield pool adapter in exchange for interest-bearing pool tokens.
  3. Upon recipient withdrawal or sender cancellation, principal tokens are instantly redeemed with zero lockup friction.
  4. Yield accrued above principal is automatically distributed according to configured protocol parameters (e.g. 80% to stream sender, 20% to protocol treasury).

Target Files

  • contracts/stream_contract/src/yield_strategy.rs
  • contracts/stream_contract/src/types.rs
  • contracts/stream_contract/src/lib.rs
  • contracts/stream_contract/src/test.rs

Acceptance Criteria

  • [ ] Yield strategy deposits and redeems principal without impairing instant withdrawal availability.
  • [ ] Principal solvency is strictly guaranteed: stream recipient is always able to withdraw 100% of vested principal.
  • [ ] Protocol fee split on excess yield is correctly routed to treasury.
  • [ ] Unit and mock integration tests verify yield distribution and emergency redemption.

blurbeast avatar Aug 29 '26 22:08 blurbeast

Hello! I'd like to work on this issue.

Execution Plan for [Smart Contracts] Auto-Yield & DeFi Lending Pool Integration for Idle Streaming Deposits:

  • Smart Contract Architecture: Implement [Smart Contracts] Auto-Yield & DeFi Lending Pool Integration for Idle Streaming Deposits with explicit auth checks (require_auth), clean DataKey storage, and zero-overflow arithmetic.
  • Exhaustive Testing: Add unit tests asserting both happy-path states and unauthorized reverts with exact ContractError variants.
  • Green CI: Verify zero clippy warnings and 100% test coverage locally before opening the PR.

Why assign me?

  • Proven Proof-of-Work: #1 contributor on Mova Store (28 merged Web3 PRs) and official ElizaOS contributor.
  • Fast Turnaround: Dedicated to shipping a tested, production-grade PR within 12–24 hours.
  • Zero Maintainer Burden: Self-documenting code with green CI and tests included so you don't spend time debugging.

Looking forward to clearing this off your backlog—please assign to me!

Ranjeet2063 avatar Sep 06 '26 11:09 Ranjeet2063

@titilope12 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

Hello maintainer, i can fix this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @titilope12 to this issue.

titilope12 avatar Sep 28 '26 14:09 titilope12

@nazteeemba has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

Please assign me to this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @nazteeemba to this issue.

nazteeemba avatar Sep 30 '26 06:09 nazteeemba

@lawalajose has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

kindly assign boss

ℹ️ Repo Maintainers: To accept this application, review their application or assign @lawalajose to this issue.

lawalajose avatar Sep 30 '26 10:09 lawalajose

Congratulations, @lawalajose! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

🧑‍💻 @lawalajose: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Sep 30 '26 11:09 drips-wave[bot]

@AkpakaProsper has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello Maintainer, I can work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @AkpakaProsper to this issue.

AkpakaProsper avatar Oct 15 '26 13:10 AkpakaProsper

@MuhammadDG has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello Maintainer, I’ve gone through the issue details and am confident I can implement a clean, reliable solution. I’m ready to take ownership and submit a PR within 1–2 hours of assignment.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @MuhammadDG to this issue.

MuhammadDG avatar Oct 16 '26 22:10 MuhammadDG

@dollfins has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello maintainer, i would like to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @dollfins to this issue.

dollfins avatar Oct 16 '26 23:10 dollfins

Congratulations, @dollfins! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

🧑‍💻 @dollfins: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Oct 16 '26 23:10 drips-wave[bot]

This issue has been completed by @dollfins as part of the Stellar Wave Program's 10th Wave 🥳

😎 @dollfins: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Oct 18 '26 01:10 drips-wave[bot]