Technical architecture

How Does TerpLayer Achieve Decentralized Bitcoin AMM Trading?

How does TerpLayer achieve decentralized Bitcoin AMM trading? TerpLayer doesn't let BTC leave users' wallets. We complete the transactions between BTC and TPUSD on the Bitcoin network, and these transactions are realized based on the latest PSBT (Partially Signed Bitcoin Transaction) technology of Bitcoin. In a Bitcoin transaction, the delivery of BTC and TPUSD is achieved by swapping UTXO (Unspent Transaction Output) between inputs and outputs. Each Bitcoin transaction will be synchronized to the AMM Oracle contract deployed on Berachain through TerpLayer's state channels, and the AMM Oracle provides us with the trading price of BTC. Meanwhile, the transactions occurring on TerpLayer will also affect the price of the AMM. To ensure the accuracy of the price in the AMM, we determine the Bitcoin trading price by adopting the method of multiple quotations: 30% of the price weight comes from Chainlink, 30% from Pyth, and 30% from our liquidity pool. For example, the reason for introducing Curve is that considering that USDT has decoupled from the US dollar in history. By monitoring the exchange rate between USDT and other stablecoins, our AMM Oracle can timely judge risks and send out early warning signals to ensure that liquidity providers (LP) don't suffer losses.


How to Achieve Transactions between BTC and USDT on the Bitcoin Mainnet

TerpLayer has issued the first stablecoin TPUSD on the Bitcoin network based on the Runes protocol. The issuance and redemption mechanism of TPUSD is realized based on the TAS (improved cross-chain atomic swap) protocol standard. Through transaction association, it is ensured that the transactions on the Bitcoin chain and the EVM contract transactions will either succeed or fail simultaneously. We provide a decentralized trading gateway that allows users to exchange TPUSD at any time. So for the transactions occurring on the Bitcoin mainnet, there areUTXOs associated with BTC and TPUSD. From an architectural perspective, TerpLayer's BTCSwap can be understood in this way: The actual transactions of BTC occur on the Bitcoin mainnet, while the price formation and liquidity calculation of Bitcoin are carried out on Berachain. When users conduct transactions on BTCSwap, their actions will be submitted to the smart contract, and the contract will issue additional TERP tokens according to these transaction behaviors to reward users. TerpLayer will become the asset delivery protocol of Berachain on the Bitcoin chain. From the perspective of financial products, any wrapped tokens, such as WBTC, FBTC, etc., can be regarded as future options of Bitcoin. Users using these wrapped tokens conduct the delivery of ERC20 and BTC through third-party institutions, and this delivery method is usually called a cross-chain bridge. In the future, institutions can issue BTC options and choose to use the trading route of BTCSwap for the physical BTC delivery. For example, TerpLayer will cooperate with IVX on the expiration date option protocol on Berachain in the future. The product form of IVX is 24-hour option delivery. Suppose you buy a BTC option at a price of $60,000 at 0 o'clock. By 24 o'clock, the price of BTC has risen to $65,000. At this time, users can either choose to obtain a profit of $5,000 or use the trading route of BTCSwap to deliver the physical BTC. BTC and TerpLayer, a DEX project on Berachain. It expands the atomic swap innovation of UTXO to multiple chains. It is a DEX on the native BTC chain and operates services through a decentralized node network. The AMM Oracle is placed on Berachain and participates in Berachain's flywheel model. It is currently very popular on Berachain and has established cooperation with top validators and Bera project teams. There is a project on Berachain that focuses on BTC DeFi. Through the node network and cross-chain atomic swap technology, it introduces the real BTC trading business into the Berachain ecosystem. This project mainly focuses on BTC trading business, has a clear market demand, and realizes coordinated development with Berachain through a carefully designed economic model. It has already established a close cooperative relationship with top validators.

Last updated