Skip to content

Commit

Permalink
Merge branch 'master' into feat/better-get-balance
Browse files Browse the repository at this point in the history
  • Loading branch information
slavastartsev authored Dec 14, 2024
2 parents 446a329 + 14c642f commit 67f3e3c
Show file tree
Hide file tree
Showing 21 changed files with 5,789 additions and 53 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,27 @@ Proof length is the number of headers needed before and after a retarget to upda

## Security (Light Relay)

Let's review the calculation given in the [Bitcoin Wiki](https://en.bitcoin.it/wiki/Difficulty) to compute the hashrate:
Let's review the calculation given in the [Bitcoin Wiki](https://en.bitcoin.it/wiki/Difficulty) to compute the hashrate:

```
hashrate = difficulty * 2**32 / 600 (60 * 10 = 10 minutes)
hashrate = ~157 (GH/s) = (22012.4941572 * 2**32 / 600) / 10**9 (example)
hashrate = ~595 (EH/s) (83148355189239.77 * 2**32 / 600) / 10**18 (current)
hashrate = ~743 (EH/s) = (103919634711492.2 * 2**32 / 600) / 10**18 (time of writing, Dec 2024)
```

The `LightRelay` requires that the proof is included at the *current* or *previous* difficulty so we can assume the attacker has 2016 * 2 blocks to brute-force a valid chain of `proofLength`.
This is possible since due to SPV assumptions we can not verify the transactions references by the block header are valid, only that sufficient PoW has accumulated on the chain.
The `LightRelay` requires that the proof is included at the _current_ or _previous_ difficulty so we can assume the attacker has 2016 \* 2 blocks to brute-force a valid chain of `proofLength`.
This is possible since, due to SPV assumptions, we can not verify the transactions references by the block header are valid, only that sufficient PoW has accumulated on the chain.

Let's assume the attacker can generate 6 blocks (with some invalid transactions) within two difficulty adjustment period, 2016 * 2 blocks (four weeks).
Let's assume the attacker can generate 6 blocks (with some invalid transactions) within two difficulty adjustment period, 2016 \* 2 blocks (four weeks).

```
hashrate * 6/(2016*2)
595 * 6/(2016*2) = 0.885 EH/s (~885712 TH/s)
743 (EH/s) * 6/(2016*2) = 1.105 EH/s (~1,105,654 TH/s)
```

So we need ~0.148% of the current hashrate to build six blocks in two weeks.
So we need ~0.142% of the current hashrate to build six blocks in two weeks.

If we estimate it would cost $11 per TH/s (excluding electricity and other setup costs) then the total cost of that hashrate would be $9,742,832.
If we estimate it would cost $11 per TH/s (excluding electricity and other setup costs) then the total cost of that hashrate would be $12,162,194.
This excludes the opportunity cost from actually mining on Bitcoin mainnet, receiving fees and block rewards.

Therefore, provided the value protected by the relay is less than $10m protocols secured by the relay are "economically safe".
Therefore, provided the value protected by the relay is less than $12m protocols secured by the relay are "economically safe".
13 changes: 7 additions & 6 deletions docs/docs/learn/builder-guides/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
sidebar_position: 2
---

# BOB Gateway
# Integrate BOB Gateway in Your App

## Overview

[BOB Gateway](https://docs.gobob.xyz/learn/guides/bitcoin-bridge/) is a Bitcoin intent bridge that unlocks Bitcoin liquidity by reducing the number of steps to onboard users, saving time and money. Users can go from **BTC** on Bitcoin to **staked BTC LSTs** with a single Bitcoin transaction.
[BOB Gateway](https://docs.gobob.xyz/learn/guides/bitcoin-bridge/) is a Bitcoin intent bridge that unlocks Bitcoin liquidity by reducing the number of steps to onboard users to your app, saving time and money. For example, users can go from **BTC** on Bitcoin to **staked BTC LSTs** with a single Bitcoin transaction.

Our SDK makes it possible for you to bring this UX directly into your app.

Expand All @@ -18,7 +16,10 @@ Our SDK makes it possible for you to bring this UX directly into your app.

1. Gateway finalizes the transaction. After trustlessly verifying the user's Bitcoin transaction with an on-chain [Light Client](/learn/builder-guides/relay.md), Gateway sends the LP's wrapped Bitcoin to the user's EVM address. If the user requested a Bitcoin LST/LRT, that token is minted using the LP's wrapped Bitcoin before it is sent to the user.

This SDK makes it possible to do steps 2, 3, and 4 in your application's front end.
This SDK exposes helper functions for steps 2, 3, and 4 to be used in your application's front end.
:::info Learn More
Discover the architecture of BOB Gateway and how it simplifies Bitcoin transactions by visiting our [BOB Gateway introduction page](../introduction/gateway).
:::

## Step-by-Step Integration Guide

Expand Down Expand Up @@ -80,7 +81,7 @@ The SDK will handle automatically when the `toToken` has a fungible ERC20 token,
```ts
const strategies = await gatewaySDK.getStrategies();
const strategy = strategies.find(
(contract) => contract.integration.name === "pell-wbtc",
(contract) => contract.integration.name === "pell-wbtc"
)!;
const quoteParamsStaking: GatewayQuoteParams = {
...quoteParams,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 67f3e3c

Please sign in to comment.