Skip to content

Pull Request: [Feature] Streaming-to-Staking Direct Pipeline (#53, #43)#74

Merged
JerryIdoko merged 2 commits intoGrant-Stream:mainfrom
JamesEjembi:feature/streaming-to-staking-53-43
Feb 25, 2026
Merged

Pull Request: [Feature] Streaming-to-Staking Direct Pipeline (#53, #43)#74
JerryIdoko merged 2 commits intoGrant-Stream:mainfrom
JamesEjembi:feature/streaming-to-staking-53-43

Conversation

@JamesEjembi
Copy link
Contributor

This PR introduces the "Direct Pipeline" feature, allowing grantees to automate their savings by redirecting streamed funds directly into a staking pool or a secondary secure address. This bypasses the need for manual withdrawals to a hot wallet, reducing gas costs and improving security for the user.

🎯 Key Changes
Data Structure Update: Added an optional redirect_address: Option

field to the Grant struct.

Logic Enhancement: Updated the withdraw() function to check for a redirect_address. If present, the unlocked funds are transferred directly to that target instead of the caller's address.

Permissioning: Ensured that only the grantee can set or update the redirect_address to prevent unauthorized diversion of funds.

💻 Implementation Snippet (Soroban/Rust)
The core logic shift in the withdrawal process:

Rust
pub fn withdraw(e: Env, grant_id: Symbol) {
let mut grant: Grant = e.storage().persistent().get(&grant_id).unwrap();
grant.grantee.require_auth();

let amount_to_withdraw = calculate_unlocked_amount(&e, &grant);

// Determine the recipient: redirect target or the grantee
let recipient = grant.redirect_address.unwrap_or(grant.grantee.clone());

// Execute transfer to the pipeline target
token::Client::new(&e, &grant.token).transfer(
    &e.current_contract_address(),
    &recipient,
    &amount_to_withdraw,
);

// Update internal state...

}
✅ Acceptance Criteria Checklist
[x] Grant Struct: Added redirect_address to the Grant definition.

[x] Withdraw Logic: The withdraw() function now respects the redirect target.

[x] State Management: Properly handles cases where no redirect is set (defaults to standard withdrawal).

[x] Security: Verified that redirection does not bypass require_auth() from the grantee.

🚀 How to Test
Initialize Grant: Create a grant with a redirect_address set to a mock staking contract.

Advance Ledger: Move the ledger time forward to unlock funds.

Withdraw: Call withdraw from the grantee's account.

Verify: Assert that the mock staking contract's balance increased, while the grantee's balance remained the same.

🔗 Linked Issues
Closes #43
Closes #53

@JerryIdoko JerryIdoko merged commit 939fd74 into Grant-Stream:main Feb 25, 2026
1 check failed
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.

#43 Issue 43: [Feature] "Streaming-to-Staking" Direct Pipeline #33 Issue 33: [Logic] Partial Grant Self-Termination

2 participants