Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions content/docs/sdk/all-modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Swidge is the preferred interface for new protocol providers that can quote and
|--------|----------|-------------|---------------|
| [`wdk-protocol-swidge-orchestra`](https://www.npmjs.com/package/wdk-protocol-swidge-orchestra) | Flashnet Orchestra | Swidge provider for BTC and stablecoin routes returned by Orchestra. Treat the live [Orchestra route matrix](https://orchestration.flashnet.xyz/v1/orchestration/routes) as provider-level data and filter through package discovery before exposing routes. | [Docs](/sdk/swidge-modules/swidge-orchestra/) |
| [`@rhino.fi/wdk-protocol-swidge-rhinofi`](https://www.npmjs.com/package/@rhino.fi/wdk-protocol-swidge-rhinofi) | Rhino.fi | Swidge routes for Rhino.fi cross-chain swap and bridge operations | [Docs](/sdk/swidge-modules/swidge-rhinofi/) |
| [`@gobob/wdk-protocol-swidge-gateway`](https://www.npmjs.com/package/@gobob/wdk-protocol-swidge-gateway) | BOB Gateway | Native BTC swidge routes to and from tokens on EVM chains and Tron, settled on Bitcoin L1 with no wrapped-BTC intermediary | [Docs](/sdk/swidge-modules/swidge-gateway/) |

## Pricing Modules

Expand Down Expand Up @@ -96,3 +97,4 @@ Modules built by the WDK community. See the [Community Modules](/sdk/community-m
| [`@morpho-org/wdk-protocol-lending-morpho-evm`](https://www.npmjs.com/package/@morpho-org/wdk-protocol-lending-morpho-evm) | EVM | Morpho Vault V2 and Morpho Blue lending integration | [Docs](/sdk/lending-modules/lending-morpho-evm/) |
| [`wdk-protocol-swidge-orchestra`](https://github.com/flashnetxyz/wdk-protocol-swidge-orchestra) | Swidge | Flashnet Orchestra BTC and stablecoin route integration | [Docs](/sdk/swidge-modules/swidge-orchestra/) |
| [`@rhino.fi/wdk-protocol-swidge-rhinofi`](https://www.npmjs.com/package/@rhino.fi/wdk-protocol-swidge-rhinofi) | Rhino.fi | Swidge cross-chain route integration | [Docs](/sdk/swidge-modules/swidge-rhinofi/) |
| [`@gobob/wdk-protocol-swidge-gateway`](https://github.com/bob-collective/wdk-protocol-swidge-gateway) | Swidge | BOB Gateway native BTC route integration | [Docs](/sdk/swidge-modules/swidge-gateway/) |
1 change: 1 addition & 0 deletions content/docs/sdk/community-modules/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Tether and the WDK Team do not endorse or assume responsibility for their code,
| [@morpho-org/wdk-protocol-lending-morpho-evm](https://www.npmjs.com/package/@morpho-org/wdk-protocol-lending-morpho-evm) ([GitHub](https://github.com/morpho-org/sdks/tree/main/packages/wdk-protocol-lending-morpho-evm)) | Lending Module | Morpho EVM lending module for vault deposits, collateral supply, borrowing, repayment, and position reads | [Docs](/sdk/lending-modules/lending-morpho-evm/) | [Morpho Association](https://morpho.org/) |
| [wdk-protocol-swidge-orchestra](https://www.npmjs.com/package/wdk-protocol-swidge-orchestra) ([GitHub](https://github.com/flashnetxyz/wdk-protocol-swidge-orchestra)) | Swidge Module | Flashnet Orchestra Swidge provider for BTC and stablecoin routes returned by Orchestra | [Docs](/sdk/swidge-modules/swidge-orchestra/) | [Flashnet](https://github.com/flashnetxyz) |
| [@rhino.fi/wdk-protocol-swidge-rhinofi](https://www.npmjs.com/package/@rhino.fi/wdk-protocol-swidge-rhinofi) ([GitHub](https://github.com/rhinofi/wdk-protocol-swidge-rhinofi)) | Swidge Module | Rhino.fi cross-chain swap and bridge routes through the WDK swidge interface | [Docs](/sdk/swidge-modules/swidge-rhinofi/) | [Rhino.fi](https://rhino.fi/) |
| [@gobob/wdk-protocol-swidge-gateway](https://www.npmjs.com/package/@gobob/wdk-protocol-swidge-gateway) ([GitHub](https://github.com/bob-collective/wdk-protocol-swidge-gateway)) | Swidge Module | Native BTC swidge routes to and from tokens on EVM chains and Tron, settled on Bitcoin L1 with no wrapped-BTC intermediary and no custodian | [Docs](/sdk/swidge-modules/swidge-gateway/) | [BOB](https://gobob.xyz) |

---

Expand Down
5 changes: 5 additions & 0 deletions content/docs/sdk/swidge-modules/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Use the existing [swap modules](/sdk/swap-modules) and [bridge modules](/sdk/bri
| Module | Provider | Routes | Documentation |
|--------|----------|--------|---------------|
| [`wdk-protocol-swidge-orchestra`](https://www.npmjs.com/package/wdk-protocol-swidge-orchestra) ([GitHub](https://github.com/flashnetxyz/wdk-protocol-swidge-orchestra)) | Flashnet Orchestra | BTC and stablecoin routes returned by Orchestra. Treat the live [Orchestra route matrix](https://orchestration.flashnet.xyz/v1/orchestration/routes) as provider-level data and filter through runtime discovery before exposing routes. | [Docs](/sdk/swidge-modules/swidge-orchestra/) |
| [`@rhino.fi/wdk-protocol-swidge-rhinofi`](https://www.npmjs.com/package/@rhino.fi/wdk-protocol-swidge-rhinofi) ([GitHub](https://github.com/rhinofi/wdk-protocol-swidge-rhinofi)) | Rhino.fi | Cross-chain swap and bridge routes from EVM source accounts. | [Docs](/sdk/swidge-modules/swidge-rhinofi/) |
| [`@gobob/wdk-protocol-swidge-gateway`](https://www.npmjs.com/package/@gobob/wdk-protocol-swidge-gateway) ([GitHub](https://github.com/bob-collective/wdk-protocol-swidge-gateway)) | BOB Gateway | Native BTC routes to and from tokens on EVM chains and Tron. Real BTC on Bitcoin L1, with no wrapped-BTC intermediary and no custodian. | [Docs](/sdk/swidge-modules/swidge-gateway/) |

## Interface methods

Expand Down Expand Up @@ -209,6 +211,9 @@ Register and use protocol modules with WDK accounts
<Card title="Orchestra" href="/sdk/swidge-modules/swidge-orchestra">
Use the Flashnet Orchestra community Swidge provider
</Card>
<Card title="BOB Gateway" href="/sdk/swidge-modules/swidge-gateway">
Swidge native BTC to and from tokens on EVM chains and Tron
</Card>
<Card title="Swap Modules" href="/sdk/swap-modules">
Maintain existing standalone swap modules
</Card>
Expand Down
124 changes: 124 additions & 0 deletions content/docs/sdk/swidge-modules/swidge-gateway/configuration.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
title: BOB Gateway Swidge Configuration
description: Configuration options for @gobob/wdk-protocol-swidge-gateway.
docType: reference
schemaType: TechArticle
icon: Settings
---

`GatewaySwidge` works with no configuration beyond a source chain. The module ships a default API endpoint and a default attribution token, so a minimal setup is enough to quote and execute.

```javascript
import { GatewaySwidge } from '@gobob/wdk-protocol-swidge-gateway'

const gateway = new GatewaySwidge(account, {
fromChain: 'bitcoin'
})
```

## Constructor

```typescript
new GatewaySwidge(account?, config?)
```

| Parameter | Description |
|-----------|-------------|
| `account` | WDK wallet account for the source chain — a `@tetherto/wdk-wallet-btc` account for BTC sources, or a `@tetherto/wdk-wallet-evm` (or ERC-4337) account for token sources. Quoting and discovery work without a writable account. |
| `config` | Optional `GatewaySwidgeConfig`. Set `fromChain` here unless you pass it per call. |

## Configuration Options

| Option | Type | Description |
|--------|------|-------------|
| `fromChain` | `string` | Source chain identifier, for example `'bitcoin'`, `'ethereum'`, or `'base'`. Required unless supplied in the route options. |
| `slippage` | `number` | Default slippage tolerance as a decimal. Defaults to `0.03` (3%). Override per call in the route options. |
| `affiliates` | `Array<{ address: string, bps: number }>` | Affiliate fee entries, in basis points, credited to each address. Applies to BTC to EVM and EVM to BTC routes only. |
| `feeRate` | `number` | Bitcoin fee rate in sat/vByte for onramp transactions. Defaults to a gateway-supplied estimate. |
| `paymasterToken` | `string` | ERC-20 token used to pay gas on ERC-4337 accounts. |
| `bearerToken` | `string` | Gateway API bearer token. Defaults to BOB's shared attribution key — see [API access](#api-access). |
| `apiUrl` | `string` | Gateway API base URL override. |
| `http` | `object` | Injectable HTTP transport. Useful for tests and custom runtimes. |
| `client` | `GatewayClient` | A pre-built client instance. Overrides `apiUrl`, `bearerToken`, and `http`. |

## Source Chain

The module signs on the source chain, so `fromChain` decides which WDK account it needs. Create one `GatewaySwidge` instance per source chain.

```javascript
// BTC as the source: pass a WDK Bitcoin account.
const fromBtc = new GatewaySwidge(btcAccount, { fromChain: 'bitcoin' })

// A token as the source: pass a WDK EVM account.
const fromBase = new GatewaySwidge(evmAccount, { fromChain: 'base' })
```

## Slippage

Set a default in the constructor and override it for a single route when needed.

```javascript
const gateway = new GatewaySwidge(account, {
fromChain: 'bitcoin',
slippage: 0.01 // 1%
})

const quote = await gateway.quoteSwidge({
...options,
slippage: 0.005 // 0.5% for this route only
})
```

## Affiliate Fees

Charge a fee on BTC to EVM and EVM to BTC routes by crediting one or more addresses in basis points of the input amount. Affiliate fees are not supported on EVM-to-EVM routes.

```javascript
const gateway = new GatewaySwidge(account, {
fromChain: 'bitcoin',
affiliates: [{ address: '0xYourFeeRecipient...', bps: 25 }] // 0.25%
})
```

Affiliate fees appear in the quote's itemized `fees` array with type `affiliate`, so a UI can display them before the user confirms.

## API Access

Every request carries a bearer token. If you do not set one, the module sends BOB's shared `gateway-wdk` attribution key, which costs nothing extra and attributes the volume to BOB.

```javascript
// Uses BOB's default attribution key.
const gateway = new GatewaySwidge(account, { fromChain: 'bitcoin' })

// Uses your own key. Set this only if you have a direct API agreement with BOB.
const gateway = new GatewaySwidge(account, {
fromChain: 'bitcoin',
bearerToken: process.env.GATEWAY_API_KEY
})
```

<Callout type="info">
The Gateway API applies a **country blocklist** that includes the United States and the United Kingdom alongside sanctioned jurisdictions. Requests from a blocked country receive a `403`. See the [Gateway FAQ](https://docs.gobob.xyz/gateway/faq#are-any-regions-blocked-from-using-gateway) for the current list. CI that exercises live quotes must run from a non-blocked region.
</Callout>

## Bitcoin Fee Rate

Onramp transactions use a gateway-supplied fee estimate by default. Override it when your app already tracks mempool conditions.

```javascript
const gateway = new GatewaySwidge(btcAccount, {
fromChain: 'bitcoin',
feeRate: 12 // sat/vByte
})
```

## ERC-4337 Accounts

Pass `paymasterToken` to pay gas in an ERC-20 when the source account is an ERC-4337 smart account from `@tetherto/wdk-wallet-evm-erc-4337`.

```javascript
const gateway = new GatewaySwidge(smartAccount, {
fromChain: 'base',
paymasterToken: '0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2' // USDT on Base
})
```
72 changes: 72 additions & 0 deletions content/docs/sdk/swidge-modules/swidge-gateway/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: BOB Gateway Swidge Overview
description: Overview of the @gobob/wdk-protocol-swidge-gateway module for native BTC swap and bridge routes.
docType: explanation
schemaType: TechArticle
---

The BOB Gateway Swidge module lets WDK accounts quote and execute **native Bitcoin** swap and bridge routes through [BOB Gateway](https://gobob.xyz) using the shared `SwidgeProtocol` interface.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to add the standard community-module warning used by the community index and Orchestra overview? This module is listed as community-maintained, so the overview should make that distinction clear.


Use this module when an app needs to move real BTC in or out of tokens on EVM chains and Tron. Bitcoin is spent and received on Bitcoin L1 — there is no wrapped-BTC intermediary and no custodian, and keys never leave the WDK account.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we describe the observable mechanics here instead of using “real BTC”, “no custodian”, and “keys never leave”? “Native BTC on Bitcoin L1, signed through the WDK account, with settlement handled by Gateway” feels closer to the neutral style used elsewhere in the docs.


## Features

- **Unified route interface**: Implements `quoteSwidge()`, `swidge()`, `getSwidgeStatus()`, `getSupportedChains()`, and `getSupportedTokens()`.
- **Native BTC routes**: Swaps native BTC to and from USDT, USDC, ETH, wBTC, cbBTC, and XAUT across Ethereum, Base, Arbitrum, and BSC.
- **BTC to Tron**: Sends BTC and receives USDT (or other supported tokens) on Tron.
- **EVM to EVM**: Same-chain swaps and cross-chain bridges through the inherited `swap()` and `bridge()` methods.
- **Non-custodial**: Signing is delegated to the WDK account. The module never touches private keys.
- **Affiliate fees**: Optional per-address basis-point fees on BTC to EVM and EVM to BTC routes.
- **Approval pre-flight**: `getRequiredApproval()` reports the exact ERC-20 approval an offramp needs before execution.
- **Multi-runtime**: Runs on Node.js, Bare (`bare.js`), and React Native.
- **Typed errors**: Exposes `GatewaySwidgeError` with stable `ERR` codes for HTTP, validation, unsupported route, and approval failures.

## Supported Routes

Call `getSupportedChains()` and `getSupportedTokens()` at runtime — BOB Gateway controls the live route set and adds chains and tokens over time.

| Route | Source support | Notes |
|-------|----------------|-------|
| BTC to EVM (onramp) | Supported | Spends native BTC from a `@tetherto/wdk-wallet-btc` account. Supports affiliate fees. |
| EVM to BTC (offramp) | Supported | Spends an ERC-20 from a `@tetherto/wdk-wallet-evm` account. Requires an approval first. Supports affiliate fees. |
| BTC to Tron | Supported | Tron is a **destination only**. Tron as a source is not supported; see the [Tron source tracking issue](https://github.com/tetherto/wdk-wallet-tron/issues/48). |
| EVM to EVM | Supported | Use the inherited `swap()` and `bridge()` methods. Affiliate fees do not apply to this route. |
| Solana | Not yet available | Planned. |

## Execution Model

The route direction determines which chain the module signs on.

**Onramp (BTC to a token).** `swidge()` builds and signs a Bitcoin transaction through the WDK BTC account, then hands it to the gateway. **The gateway broadcasts the Bitcoin transaction — the module does not.** The call resolves once the transaction is registered; the destination tokens settle asynchronously.

**Offramp (a token to BTC).** `swidge()` submits the source-chain EVM transaction after the required ERC-20 approval is in place. It resolves once that transaction is broadcast, and BTC settles on Bitcoin L1 asynchronously.

In both directions, use `getSwidgeStatus(result.id)` to track the route to completion.

<Callout type="warn">
`swidge()` spends real funds and can submit a Bitcoin or EVM transaction. Show the quote, fee breakdown, recipient, source token, destination token, and destination chain, and ask for explicit user confirmation before calling it.
</Callout>

<Callout type="info">
The Gateway API applies a **country blocklist** that includes the United States and the United Kingdom alongside sanctioned jurisdictions. Requests from a blocked country receive a `403`. See the [Gateway FAQ](https://docs.gobob.xyz/gateway/faq#are-any-regions-blocked-from-using-gateway) for the current list, and account for it in both production deployments and CI.
</Callout>

## Next Steps

<Cards>
<Card title="Configuration" href="/sdk/swidge-modules/swidge-gateway/configuration">
Configure the source chain, slippage, affiliate fees, BTC fee rate, and API access.
</Card>
<Card title="Usage" href="/sdk/swidge-modules/swidge-gateway/usage">
Install the package, register the module, quote a route, approve, execute, and poll status.
</Card>
<Card title="API Reference" href="/sdk/swidge-modules/swidge-gateway/api-reference">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to include api-reference.mdx before keeping this card and the matching sidebar entry? The route is missing from the PR, so the link check currently fails.

Review constructor options, methods, route options, status mapping, and error codes.
</Card>
</Cards>

---

## Need Help?

<SupportCards />
Loading