Skip to content

Add create-tap-with-borrowed-liquidity convenience function#11

Merged
obycode merged 1 commit intoobycode:mainfrom
warmidris:feat/create-tap-with-borrowed-liquidity
Mar 8, 2026
Merged

Add create-tap-with-borrowed-liquidity convenience function#11
obycode merged 1 commit intoobycode:mainfrom
warmidris:feat/create-tap-with-borrowed-liquidity

Conversation

@warmidris
Copy link
Contributor

Summary

  • Adds create-tap-with-borrowed-liquidity to contracts/reservoir.clar, combining create-tap and borrow-liquidity into a single transaction
  • Adds two tests: happy path (verifies balances and expiry block) and error path (invalid signature)

Motivation

In the common setup flow for a new participant (e.g. a stackmail agent opening a mailbox), they need to:

  1. Open a tap by depositing funds for outgoing capacity
  2. Borrow liquidity from the reservoir for incoming capacity

Currently this requires two separate transactions. This convenience function combines them atomically, reducing the on-chain footprint and simplifying client-side setup code.

Parameters

Same as create-tap + borrow-liquidity combined:

  • stackflow / token / tap-amount / tap-nonce → forwarded to create-tap
  • borrow-amount / borrow-fee / my-balance / reservoir-balance / my-signature / reservoir-signature / borrow-nonce → forwarded to borrow-liquidity

Returns

(ok expire-block) — the burn block height when the borrowed liquidity expires (same as borrow-liquidity).

Test plan

  • Happy path: creates tap + borrows, verifies STX balances and return value
  • Invalid signature: passes wrong signing key, expects (err u125) (InvalidSignature)
  • Tests can't run locally (Node v18, clarinet-sdk requires v20) — CI should cover this

🤖 Generated with Claude Code

Combines create-tap and borrow-liquidity into a single transaction so
new participants can set up both their outgoing capacity (deposit) and
incoming capacity (borrowed liquidity) atomically, reducing the
on-chain footprint for the common mailbox setup case.

Also adds two tests covering the happy path and invalid-signature
error path for the new function.
Copy link
Owner

@obycode obycode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@obycode obycode merged commit fc16f51 into obycode:main Mar 8, 2026
1 check passed
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.

2 participants