Under The Hood: SkyPools’ Technical Upgrades & Smart Contracts

Swingby Protocol
5 min readOct 21, 2021

Kicking off Swingby’s Article Series, we started with our multi-chain and trustless vision of the world. Following that, we shared how our latest product — SkyPools helps Bitcoin traverse across chains & interact with smart contracts, opening up a new world of possibilities.

Today, we’d like to go deeper into what our team does best — the technical workings behind our products. That’s right, we will be going under the hood and sharing more about the technical upgrades that make SkyPools possible.

For the technical folks and diagram geeks, you’ll be in for a ride!

Technical Overview: What goes into the SkyPools update?

🎯 Main Objective: Enable Smart Contract Interactions

For the SkyPools update, the team’s main objective is to enable smart contract interactions to empower Swaps over SkyPools. This means that Metanodes will be able to sign transactions that invoke smart-contract functions once a consensus is formed.

Initially, the first application of this upgrade is to enable any-to-any coin swaps over the Ethereum network, but you can imagine a world where Bitcoin can be directly used with all DeFi applications in the future.

The Development team’s effort is heavily focused here, which we’ll share more in the second part of this article.

🎲 Side Quest: Improve user experience & security

As a sidequest, we also aim to improve the user experience and security for bridges made on SkyBridge. Users will see faster transactions and a more seamless user experience from these updates. These technical upgrades are as follows:

CMP & FROST Integration

CMP (ECDSA) and FROST (EdDSA & Taproot) vastly improve the performance of the underlying cryptography that powers Skybridge. This implementation helps us:

  • Reduce the number of signing rounds required to form a consensus massively
  • Reduce the amount of processing overhead
  • Add support for parallel processing, significantly speeding up signing rounds.

This upgrade creates a better user experience through faster transactions and reduces the complexity of Metanode processing for Metanode operators.

Implementation of BIP32

Bitcoin Improvement Proposal 32 enables Skybridge to create unique Bitcoin deposit addresses for each swap. This helps us identify & handle your swaps uniquely without needing you to send in Bitcoin with long-running decimals currently.

As a user, sending exactly how much you want without running decimals will greatly improve your user experience. For Metanodes, the new identification method under BIP32 also reduces the complexity of Metanode operations.

This sums up the objectives in the SkyPools update from a technical point of view. With that, we’d like to dive deeper into the main focus of the SkyPools Update — the Smart Contracts & Transaction Flows enabling Swaps over SkyPools.

Under the Hood: Smart Contracts & Transaction Flows

The Skypools update allows the existing Skybridge to enable Bitcoin holders to participate more directly in existing decentralized finance protocols that were not possible before. Two major flows make up the primary features of Skypools.

Flow 1: Swapping native BTC to ERC-20 tokens

This flow first converts native BTC to wrapped BTC tokens (BTCt) on the applicable EVM network (WBTC on Ethereum), before executing the swap to ERC-20 tokens.

On the SkyPools UI, we make a GET request and a PUT request to ParaSwap v5 to request full transactional data for the swap. From here, the user is required to initiate the swap on the UI to begin the following process.

When user initiates the swap, the first part of the flow involves converting native BTC to BTCt (i.e. WBTC)

  1. User initiates the swap request to wBTC and deposits BTC. This request includes the user’s Ethereum wallet address to allow the receipt of tokens
  2. Metanodes execute the cross-chain conversion from native BTC to WBTC.

Once the nodes have executed the cross-chain conversion to WBTC, the next step is to execute the swap from WBTC to ERC-20 token.

  1. SkPools allocates the WBTC tokens in a balance for the user’s wallet address.
  2. User decides whether to continue with the ERC-20 token swap or withdraw WBTC
  3. Once User clicks ‘Swap’, this calls the external function on our smart contract to execute the swap using data from the API PUT response.
  4. Swap is completed & token is sent to the user.

Flow 2: Swapping ERC-20 tokens into native BTC

The second flow works in the opposite direction from the first, allowing users to deposit ERC-20 tokens to the contract and swap it to native BTC in 1 transaction. There are 2 steps in this flow as well, to first swap the ERC-20 tokens to WBTC and then do the swap from WBTC to n active BTC.

In the first part, the user needs to swap the ERC-20 tokens to WBTC. First, we get the pricing data from ParaSwap V5 by doing a PUT and GET request. With this data, we display it in the SkyPools UI for the user to initiate the swap.

When the user initiates the swap from ERC-20 to wBTC,

  1. User first deposits ERC-20 token to the SkyPools smart contract
  2. User executes ParaSwap swap to WBTC. At this stage, the SkyPools smart contract records the pending cross-chain transaction & other associated information for the bridge later on.

After the swap is successful, we begin the second step of the process.

  1. Once the swap is successful, the SkyBridge picks up the transaction to start the swap
  2. A SwapTokensToBTC event is emitted to Metanodes to execute the swap.
  3. Once consensus is achieved, SkyBridge Metanodes send native BTC to the receiving wallet address.

In the event of a failed Skypools transaction, such as with an invalid receiving native BTC address, the user will be refunded with BTCt (WBTC on Ethereum)

With that, we hope that we’ve managed to share more about the technical upgrades going into the SkyPools update, as well as how the smart contract and transactional flows work in a SkyPools swap.

While enabling smart contract interactions sounds simple in theory, we have realised that the devil is in the details where the edge cases needs to be accounted for carefully. This should give you a good idea as to why we are taking some time in preparing for our launch.

That said, we are still on track for a Q4 testnet launch and will keep you posted on any technical updates!

For the technical folks, what do you think?

We’d love to know if you have any thoughts and feedback. Join us in our Discord to discuss more!

--

--

Swingby Protocol

The fastest protocol for cross-chain swaps, allowing DeFi users to move assets between blockchains without the need for a trusted party. https://swingby.network