If you're not a developer or experienced Bitcoiner you might be wondering, what is a Bitcoin script?

If you come from the Ethereum ecosystem, it's basically Bitcoin's version of a smart contract although much more primitive.

If you don't come from the Ethereum ecosystem, it's basically a way to lock your Bitcoin in a way that it can only be unlocked if certain conditions are met.

What are some examples of Bitcoin scripts?

A commonly used Bitcoin script is a multisig. For example a 2 of 3 multisig wallet, where you lock Bitcoin, and require signatures from 2 of the 3 parties to unlock that Bitcoin.

Another example is a Hashed Time-Locked Contract (HTLC). In this script, you lock your Bitcoin, and it can either be claimed by someone else by revealing a "Secret", or you can refund after a certain amount of time has passed. This is useful for Atomic Swaps (exchanging assets across blockchains trustlessly) and Lightning Network (for routing payments).

What does an Atomic Loans Bitcoin Script look like?

For Atomic Loans, we use a script that can be unlocked in a few different conditions.

  1. Unlock by Borrower in the case of repayment
  2. Claim by Liquidator in the case that the loan defaults or goes below the minimum-collateralization ratio
  3. Seizure by Lender after an elapsed time in the case that liquidation fails
  4. Refund by Borrower after an elapsed time in the case that something else goes wrong

As you can see, no one party can steal the Bitcoin collateral or unlock the Bitcoin, unless a specific condition is met.

You can read more about this process in our System Overview.

Why do I send to two different bitcoin addresses when locking my collateral?

In order to account for all possible scenarios, and account for an edge case where liquidation fails, the Lender is able to seize a percentage of the collateral to recover losses. However they can only do this after a certain amount of time has elapsed (typically a week after the Borrower has defaulted on a loan).

This is why we call the first address the refundable collateral, and the second address the seizable collateral.

The refundable collateral can be refunded to the Borrower if all else fails.

The seizable collateral can be seized by the Lender if all else fails.

Why would a liquidation ever fail?

The simple answer is it shouldn't.

The complicated answer is that in the case of default or if a loan goes below the minimum-collateralization ratio, a Liquidator can buy the Bitcoin at a 7% discount.

When a Liquidator liquidates a loan, they lock their stablecoin funds into the Loans contract, and then the Bitcoin collateral is moved to a "Atomic Swap" like Bitcoin script escrow. The Liquidator can then claim the Bitcoin.

However if they choose not to claim the Bitcoin during the 4 hour window (aka the timeout), then it is considered a "failed" liquidation.

Two more liquidations can occur after this (three total) before liquidating the loan is considered failed.

We don't expect this to ever happen (because who wouldn't want to buy Bitcoin at a 7% discount 😎), but if it does, then the Lender can seize a percentage of the collateral, and the rest will be refunded to the Borrower.

Check our our system overview to learn more about the liquidation system.

And if you're interested in buying Bitcoin at a 7% discount and becoming a liquidator reach out to us on telegram @Atomic_Loans.