Repository navigation
feat(escrow): linear vesting stream escrows - #1767
Merged
mikewheeleer merged 2 commits intoOct 25, 2026
Merged
Conversation
Contributor
|
hey @OkeA-dev 👋 this PR scans clean and CI is green, but it now has merge conflicts with |
# Conflicts: # contracts/escrow/src/lib.rs
Contributor
|
tidy work — thanks for this! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements issue #1697: streaming milestones that vest linearly and let the freelancer withdraw accrued pay.
Closes #1697
Summary
create_stream(client, freelancer, token, amount, start, end) -> u64: creates a one-milestone escrow and storesDataKey::Stream { start, end, withdrawn, stopped_at }. Requiresstart < endandend - start >= 3600, elseEscrowError::InvalidSchedule(appended at the end).vested(id) -> i128:amount * (min(now, stop_or_end) - start) / (end - start)clamped to[0, amount], computed overflow-safely.withdraw_vested(id): freelancer auth, requires escrowFundedand stream not stopped, requires fully funded; paysvested - withdrawn; when fully vested and withdrawn marks milestone released and escrowCompleted. Emits("stream_wd", id) -> amount.stop_stream(id): client auth, requiresFundedand not stopped, requires fully funded; setsstopped_at = now, pays vested-but-unwithdrawn to freelancer, refunds unvested remainder to client, marks statusCancelled. Emits("stream_st", id) -> (to_freelancer, to_client).release_milestoneandcancel_contractreturnInvalidStatuson stream escrows (streams use their own functions).get_stream(id).EscrowError::InvalidSchedule = 20appended at the end (no renumbering).Security checklist
withdraw_vestedcomputesvestedfrom time/stop and pays onlyvested - withdrawn; checks reject ifvested <= withdrawnor nothing to withdraw.stop_streampaysvested - withdrawnto the freelancer (and only refunds unvested remainder to the client). Vested amounts are not clawed back.WASM size
c970981):38,481bytes46,372bytes+7,891bytes (+20.5%) — under 128 KBFull
cargo testoutputDocs
README.mdupdated with new functions (create_stream,vested,withdraw_vested,stop_stream,get_stream) andInvalidScheduleerror.