The technology under the hood
Zest Protocol runs on smart contracts that are secured by the Bitcoin blockchain. These are Clarity smart contracts on Stacks, a Bitcoin L2.
Clarity smart contracts on Stacks can interact with Bitcoin by reading Bitcoin-state directly from the Bitcoin blockchain without requiring an intermediary (such as a server). Additionally, Bitcoin and Stacks blocks are produced at the same time allowing for unique cross-chain functionality. Stacks is our secret sauce.
To hold BTC in escrow in Zest liquidity pools or as collateral, we leverage the Stacks layer’s unique architecture that enables trustless wrapping of BTC into a tokenised version of BTC that can be moved on the Stacks network. When a user sends BTC to Zest Protocol through the Zest Protocol UI, the BTC gets wrapped to a tokenised version of BTC on the Stacks layer (sBTC). Subsequently, the sBTC programmatically ends up in the Zest pool contracts. When a user withdraws BTC from Zest Protocol, Zest Protocol facilitates a programmatic unwrapping from sBTC to BTC. The withdrawing user receives native BTC directly into their Bitcoin wallet. For the first time, users can interact with a lending app while only using BTC.
Stacks’ unique ability to read Bitcoin state in combination with synchronised block production between the Bitcoin blockchain and Stacks layer enables the wrapping from BTC to sBTC and back to happen programmatically without reliance on a third party.

While sBTC sits in a Zest pool, the equivalent amount of BTC is held in a threshold-signature script on the Bitcoin blockchain controlled by Stacks consensus. For security purposes, the BTC can only be moved out of the threshold-signature script every 150 Stacks/Bitcoin blocks, which is when the Stacks layer reaches Bitcoin finality and Stacks blocks can no longer be altered without changing Bitcoin history in a deep reorg. Every 150 Bitcoin/Stacks blocks, Stacks blocks become secured by the entire hash power of the Bitcoin network.
Let’s dive into each of the steps block-by-block to see how we leverage the Stacks layer’s unique network architecture to enable on-chain Bitcoin lending.
- Zest Protocol fetches the Bitcoin address for the sBTC threshold-signature script and presents this Bitcoin address in to the LP.
- A threshold signature is a signature whose private key is distributed over multiple addresses. For the sBTC threshold-signature script, the private key is held by an open network of Stackers - who lock up STX as part of Stacks consensus.
- Depositing user sends BTC to the sBTC threshold-signature script on the Bitcoin blockchain.

- Stacks consensus trustlessly confirms the depositing user’s Bitcoin transaction thanks to the unique ability of Stacks nodes to read Bitcoin state.
- In the same block, sBTC is minted to the Zest Protocol BTC pool as a claim on the BTC in the threshold-signature script.
- A tokenised receipt is minted to the Deposited user’s wallet address as a claim on deposited BTC (they will use this receipt to get their BTC back during withdrawal).

- A withdrawing user seeks to drawdown BTC funds. They specify a BTC address for drawdown on the Stacks layer and prove that they own a claim to the pool.

- Zest Protocol BTC pool moves sBTC to the threshold-signature script.

- Stacks consensus produces signature to release BTC from the threshold-signature script to the withdrawing user.
- The sBTC gets burnt.
- For security purposes, the BTC can only be moved out of the threshold-signature script every 150 Stacks/Bitcoin blocks (~24 hours), which is when the Stacks layer reaches Bitcoin finality and Stacks blocks can no longer be altered without changing Bitcoin history in a deep reorg. As a result, every 150 Bitcoin/Stacks blocks Stacks history becomes secured by the entire hash power of Bitcoin.

Wrapped BTC yield products require the user to wrap BTC before participating in on-chain activity. The BTC is held by a custodian or network of nodes acting as custodians of the BTC for the full duration of yield bearing activity, which introduces risk.
These wrapped BTC products charge basis point fees for (un)wrapping BTC. Wrapping BTC into wBTC or tBTC costs ~15bps (0.15%). A lending protocol operating with wrapped BTC thus requires users to pay (un)wrapping fees before/after interacting with the protocol. In many cases, this can make interactions with lending protocols uneconomical. For example, if I want to lend out my idle BTC for 2 months at 5% APR I'm set to earn 0.83% over these two months. If I also have to wrap BTC before interacting with the protocol and unwrap it afterwards, I'm set to earn just ~0.5% (2x 0.15% (un)wrapping fee). That in combination with the fact that wrapped Bitcoin products can be volatile and sometimes depeg would unlikely make this yield bearing activity worth it for me as a user.
Zest Protocol reduces risk because users only interact with native BTC and loans are denominated in native BTC. Because Zest Protocol users Stacks under the hood, the protocol doesn't incur wrapping fees for moving BTC on and off the Stacks layer.
No. There is currently no blockchain or Bitcoin layer in operation that has the technical design to facilitate trustless and programmatic movement of BTC. Bitcoin lending pools on other chains would require users to wrap BTC before interacting with the protocol and unwrap BTC after interacting with the protocol, resulting in fees, friction and risks.
This is the best place to learn about Stacks’ trustless tokenised BTC asset and Bitcoin finality: sBTC: Enabling Bitcoin Write
To learn about building decentralised applications that leverage sBTC under the hood, have a look at our contract docs (see sidebar).
The Stacks layer requires a hard fork before sBTC is introduced. This consensus upgrade is currently scheduled for Q4 2023.
Before the hard fork, Zest Protocol will use trustless atomic swaps between BTC and xBTC (a wrapped version of BTC on the Stacks layer) to allow users to add BTC to Zest pools. Read more about the unique security features of the Zest Protocol design that features trustless atomic swaps below: