Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,13 @@ impl StellarStreamContract {
let min_end = if now > stream.start_time {
now
} else {
stream.start_time + 1
stream.start_time
};
if min_end < stream.end_time {
stream.end_time = min_end;
// Adjust total_amount to match the vested amount at cancel time
// This ensures that the vested calculation remains correct after truncation
stream.total_amount = vested;
}

if sender_refund > 0 {
Expand Down Expand Up @@ -256,7 +259,7 @@ fn vested_amount(stream: &Stream, at_time: u64) -> i128 {
let total_duration = stream.end_time - stream.start_time;

if total_duration == 0 {
return stream.total_amount;
return 0;
}

stream.total_amount * (elapsed as i128) / (total_duration as i128)
Expand Down
Loading
Loading