Difficulty : High
Type : Advanced Feature
Summary
Implement clawback allowing sender to reclaim withdrawn tokens with receiver or governance approval.
Current Behaviour
Withdrawn tokens cannot be reclaimed.
Expected Behaviour
Sender can request clawback. Requires receiver approval OR governance multi-sig. Clawed tokens returned to sender.
Suggested Implementation
#[ contracttype]
pub struct ClawbackRequest {
pub stream_id : u64 ,
pub amount : i128 ,
pub reason : String ,
pub approved_by_receiver : bool ,
pub approvals : Vec < Address > ,
pub required_approvals : u32 ,
}
pub fn request_clawback (
env : Env ,
stream_id : u64 ,
sender : Address ,
amount : i128 ,
reason : String ,
) -> Result < u64 , Error >
pub fn approve_clawback (
env : Env ,
clawback_id : u64 ,
approver : Address ,
) -> Result < ( ) , Error >
pub fn execute_clawback (
env : Env ,
clawback_id : u64 ,
) -> Result < ( ) , Error >
Files or Areas Likely Affected
contracts/Contract-V1/src/lib.rs (clawback functions)
contracts/Contract-V1/src/types.rs (ClawbackRequest)
contracts/Contract-V1/src/storage.rs (clawback keys)
contracts/Contract-V1/src/errors.rs (clawback errors)
contracts/Contract-V1/src/test.rs
Acceptance Criteria
ClawbackRequest struct defined
request_clawback function implemented
approve_clawback function implemented
execute_clawback function implemented
request requires sender authentication
Receiver can approve own clawback
Governance multi-sig can approve
Amount validated (≤ withdrawn_amount)
Transfers tokens from receiver to sender
Includes reason field
Cannot execute without sufficient approvals
At least 12 tests: request, receiver approval, governance approval, execution, insufficient approvals, amount validation, multiple clawbacks, partial clawback, rejection, expired requests, events, balance updates
Clawback is opt-in at stream creation
Rustdoc explains clawback purpose and risks
Code compiles without warnings
Additional Notes
Clawback is controversial - should be opt-in. Useful for compliance and error correction but can be abused.
Difficulty: High
Type: Advanced Feature
Summary
Implement clawback allowing sender to reclaim withdrawn tokens with receiver or governance approval.
Current Behaviour
Withdrawn tokens cannot be reclaimed.
Expected Behaviour
Sender can request clawback. Requires receiver approval OR governance multi-sig. Clawed tokens returned to sender.
Suggested Implementation
Files or Areas Likely Affected
contracts/Contract-V1/src/lib.rs(clawback functions)contracts/Contract-V1/src/types.rs(ClawbackRequest)contracts/Contract-V1/src/storage.rs(clawback keys)contracts/Contract-V1/src/errors.rs(clawback errors)contracts/Contract-V1/src/test.rsAcceptance Criteria
request_clawbackfunction implementedapprove_clawbackfunction implementedexecute_clawbackfunction implementedAdditional Notes
Clawback is controversial - should be opt-in. Useful for compliance and error correction but can be abused.