# FromBTCLNAutoWrapper\<T>

Defined in: [atomiq-sdk/src/swaps/escrow\_swaps/frombtc/ln\_auto/FromBTCLNAutoWrapper.ts:107](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts#L107)

New escrow based (HTLC) swaps for Bitcoin Lightning -> Smart chain swaps not requiring manual settlement on the destination by the user, and instead letting the LP initiate the escrow. Permissionless watchtower network handles the claiming of HTLC, with the swap secret broadcasted over Nostr. Also adds a possibility for the user to receive a native token on the destination chain as part of the swap (a "gas drop" feature).

## Extends

* [`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md)<`T`, `FromBTCLNAutoDefinition`<`T`>, `FromBTCLNAutoWrapperOptions`>

## Type Parameters

| Type Parameter                                                                                                       |
| -------------------------------------------------------------------------------------------------------------------- |
| `T` *extends* [`ChainType`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/ChainType.md) |

## Implements

* `IClaimableSwapWrapper`<[`FromBTCLNAutoSwap`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/FromBTCLNAutoSwap.md)<`T`>>

## Constructors

### Constructor

```
new FromBTCLNAutoWrapper<T>(

   chainIdentifier, 

   unifiedStorage, 

   unifiedChainEvents, 

   chain, 

   prices, 

   tokens, 

   versionedContracts, 

   lnApi, 

   messenger, 

   lpApi, 

   options?, 

events?): FromBTCLNAutoWrapper<T>;
```

Defined in: [atomiq-sdk/src/swaps/escrow\_swaps/frombtc/ln\_auto/FromBTCLNAutoWrapper.ts:160](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts#L160)

#### Parameters

| Parameter            | Type                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | Description                                   |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| `chainIdentifier`    | `string`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |                                               |
| `unifiedStorage`     | [`UnifiedSwapStorage`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/UnifiedSwapStorage.md)<`T`>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | Storage interface for the current environment |
| `unifiedChainEvents` | `UnifiedSwapEventListener`<`T`>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | On-chain event listener                       |
| `chain`              | `T`\[`"ChainInterface"`]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |                                               |
| `prices`             | [`ISwapPrice`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/ISwapPrice.md)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Swap pricing handler                          |
| `tokens`             | `WrapperCtorTokens`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                                               |
| `versionedContracts` | { \[`version`: `string`]: `object`; }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |                                               |
| `lnApi`              | [`LightningNetworkApi`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/interfaces/LightningNetworkApi.md)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |                                               |
| `messenger`          | [`Messenger`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/interfaces/Messenger.md)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |                                               |
| `lpApi`              | `IntermediaryAPI`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |                                               |
| `options?`           | `AllOptional`<`FromBTCLNAutoWrapperOptions`>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |                                               |
| `events?`            | `EventEmitter`<{ `swapState`: \[[`ISwap`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/ISwap.md)<[`ChainType`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/ChainType.md), `SwapTypeDefinition`<[`ChainType`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/ChainType.md), [`ISwapWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/ISwapWrapper.md)<[`ChainType`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/ChainType.md), `any`, `ISwapWrapperOptions`>, [`ISwap`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/ISwap.md)<[`ChainType`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/ChainType.md), `any`, `any`>>, `number`>]; }> | Instance to use for emitting events           |

#### Returns

`FromBTCLNAutoWrapper`<`T`>

#### Overrides

[`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md).[`constructor`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md#constructor)

## Properties

### \_versionedContracts

```
readonly _versionedContracts: object = {};
```

Defined in: [atomiq-sdk/src/swaps/escrow\_swaps/IEscrowSwapWrapper.ts:55](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts#L55)

#### Index Signature

```
[version: string]: object
```

#### Inherited from

[`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md).[`_versionedContracts`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md#_versionedcontracts)

***

### chainIdentifier

```
readonly chainIdentifier: T["ChainId"];
```

Defined in: [atomiq-sdk/src/swaps/ISwapWrapper.ts:164](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/ISwapWrapper.ts#L164)

Chain identifier string of this wrapper

#### Inherited from

[`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md).[`chainIdentifier`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md#chainidentifier)

***

### events

```
readonly events: EventEmitter<{

  swapState: [FromBTCLNAutoSwap<T>];

}>;
```

Defined in: [atomiq-sdk/src/swaps/ISwapWrapper.ts:168](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/ISwapWrapper.ts#L168)

Event emitter emitting `"swapState"` event when swap's state changes

#### Inherited from

[`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md).[`events`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md#events)

***

### TYPE

```
readonly TYPE: FROM_BTCLN_AUTO = SwapType.FROM_BTCLN_AUTO;
```

Defined in: [atomiq-sdk/src/swaps/escrow\_swaps/frombtc/ln\_auto/FromBTCLNAutoWrapper.ts:111](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts#L111)

Swap type

#### Overrides

[`IEscrowSwapWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IEscrowSwapWrapper.md).[`TYPE`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IEscrowSwapWrapper.md#type)

## Methods

### checkPastSwaps()

```
checkPastSwaps(pastSwaps?, noSave?): Promise<{

  changedSwaps: FromBTCLNAutoSwap<T>[];

  removeSwaps: FromBTCLNAutoSwap<T>[];

}>;
```

Defined in: [atomiq-sdk/src/swaps/ISwapWrapper.ts:424](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/ISwapWrapper.ts#L424)

Runs checks on all the known pending swaps, syncing their state from on-chain data

#### Parameters

| Parameter    | Type                                                                                                                      | Description                                                                                                     |
| ------------ | ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `pastSwaps?` | [`FromBTCLNAutoSwap`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/FromBTCLNAutoSwap.md)<`T`>\[] | Optional array of past swaps to check, otherwise all relevant swaps will be fetched from the persistent storage |
| `noSave?`    | `boolean`                                                                                                                 | Whether to skip saving the swap changes in the persistent storage                                               |

#### Returns

`Promise`<{ `changedSwaps`: [`FromBTCLNAutoSwap`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/FromBTCLNAutoSwap.md)<`T`>\[]; `removeSwaps`: [`FromBTCLNAutoSwap`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/FromBTCLNAutoSwap.md)<`T`>\[]; }>

#### Remarks

Doesn't work properly if you pass non-persisted swaps

#### Inherited from

[`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md).[`checkPastSwaps`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md#checkpastswaps)

***

### create()

```
create(

   recipient, 

   amountData, 

   lps, 

   options?, 

   additionalParams?, 

   abortSignal?, 

   preFetches?): object[];
```

Defined in: [atomiq-sdk/src/swaps/escrow\_swaps/frombtc/ln\_auto/FromBTCLNAutoWrapper.ts:358](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts#L358)

Returns a newly created Lightning -> Smart chain swap using the HTLC based escrow swap protocol, where watchtowers handle the automatic settlement of the swap on the destination chain. Also allows specifying additional "gas drop" native token that the receipient receives on the destination chain in the `options` argument. The user has to pay a bolt11 invoice on the input lightning network side.

#### Parameters

| Parameter                                  | Type                                                                                                                                                                                                                                      | Description                                                                       |
| ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `recipient`                                | `string`                                                                                                                                                                                                                                  | Recipient's address on the destination chain                                      |
| `amountData`                               | [`AmountData`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/AmountData.md)                                                                                                                                  | Amount, token and exact input/output data for to swap                             |
| `lps`                                      | [`Intermediary`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/Intermediary.md)\[]                                                                                                                                | An array of intermediaries (LPs) to get the quotes from                           |
| `options?`                                 | `FromBTCLNAutoOptions`                                                                                                                                                                                                                    | Optional additional quote options                                                 |
| `additionalParams?`                        | `Record`<`string`, `any`>                                                                                                                                                                                                                 | Optional additional parameters sent to the LP when creating the swap              |
| `abortSignal?`                             | `AbortSignal`                                                                                                                                                                                                                             | Abort signal                                                                      |
| `preFetches?`                              | { `claimerBountyPrefetch`: { \[`contractVersion`: `string`]: `Promise`<`bigint`>; }; `gasTokenPricePrefetchPromise?`: `Promise`<`bigint`>; `pricePrefetchPromise`: `Promise`<`bigint`>; `usdPricePrefetchPromise`: `Promise`<`number`>; } | Optional pre-fetches for speeding up the quoting process (mainly used internally) |
| `preFetches.claimerBountyPrefetch?`        | { \[`contractVersion`: `string`]: `Promise`<`bigint`>; }                                                                                                                                                                                  | -                                                                                 |
| `preFetches.gasTokenPricePrefetchPromise?` | `Promise`<`bigint`>                                                                                                                                                                                                                       | -                                                                                 |
| `preFetches.pricePrefetchPromise?`         | `Promise`<`bigint`>                                                                                                                                                                                                                       | -                                                                                 |
| `preFetches.usdPricePrefetchPromise?`      | `Promise`<`number`>                                                                                                                                                                                                                       | -                                                                                 |

#### Returns

`object`\[]

***

### createViaLNURL()

```
createViaLNURL(

   recipient, 

   lnurl, 

   amountData, 

   lps, 

   options?, 

   additionalParams?, 

abortSignal?): Promise<object[]>;
```

Defined in: [atomiq-sdk/src/swaps/escrow\_swaps/frombtc/ln\_auto/FromBTCLNAutoWrapper.ts:546](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts#L546)

Returns a newly created Lightning -> Smart chain swap using the HTLC based escrow swap protocol, where watchtowers handle the automatic settlement of the swap on the destination chain. Also allows specifying additional "gas drop" native token that the receipient receives on the destination chain in the `options` argument. The swap is created with an LNURL-withdraw link which will be used to pay the generated bolt11 invoice automatically when [FromBTCLNSwap.waitForPayment](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/FromBTCLNSwap.md#waitforpayment) is called on the swap.

#### Parameters

| Parameter           | Type                                                                                                                                                    | Description                                                          |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `recipient`         | `string`                                                                                                                                                | Recipient's address on the destination chain                         |
| `lnurl`             | \| `string` \| [`LNURLWithdrawParamsWithUrl`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/LNURLWithdrawParamsWithUrl.md) | LNURL-withdraw link to pull the funds from                           |
| `amountData`        | [`AmountData`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/AmountData.md)                                                | Amount, token and exact input/output data for to swap                |
| `lps`               | [`Intermediary`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/Intermediary.md)\[]                                              | An array of intermediaries (LPs) to get the quotes from              |
| `options?`          | `FromBTCLNAutoOptions`                                                                                                                                  | Optional additional quote options                                    |
| `additionalParams?` | `Record`<`string`, `any`>                                                                                                                               | Optional additional parameters sent to the LP when creating the swap |
| `abortSignal?`      | `AbortSignal`                                                                                                                                           | Abort signal                                                         |

#### Returns

`Promise`<`object`\[]>

***

### init()

```
init(noTimers, noCheckPastSwaps): Promise<void>;
```

Defined in: [atomiq-sdk/src/swaps/ISwapWrapper.ts:360](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/ISwapWrapper.ts#L360)

Initializes the swap wrapper, needs to be called before any other action can be taken

#### Parameters

| Parameter          | Type      | Default value | Description                                                                                                                                                                                  |
| ------------------ | --------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `noTimers`         | `boolean` | `false`       | Whether to skip scheduling a tick timer for the swaps, if the tick timer is not initiated the swap states depending on e.g. expiry can be out of sync with the actual expiration of the swap |
| `noCheckPastSwaps` | `boolean` | `false`       | Whether to skip checking past swaps on initialization (by default all pending swaps are re-checked on init, and their state is synchronized from the on-chain data)                          |

#### Returns

`Promise`<`void`>

#### Inherited from

[`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md).[`init`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md#init)

***

### recoverFromSwapDataAndState()

```
recoverFromSwapDataAndState(

   init, 

   state, 

   contractVersion, 

lp?): Promise<FromBTCLNAutoSwap<T>>;
```

Defined in: [atomiq-sdk/src/swaps/escrow\_swaps/frombtc/ln\_auto/FromBTCLNAutoWrapper.ts:703](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts#L703)

Recovers a swap from smart chain on-chain data, please note that not all values for the recovered swaps might be populated, as some data is purely off-chain and can never be recovered purely from on-chain data.

#### Parameters

| Parameter          | Type                                                                                                                                                      | Description                                           |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| `init`             | { `data`: `T`\[`"Data"`]; `getInitTxId`: () => `Promise`<`string`>; `getTxBlock`: () => `Promise`<{ `blockHeight`: `number`; `blockTime`: `number`; }>; } | Swap escrow initialization transaction and swap data  |
| `init.data`        | `T`\[`"Data"`]                                                                                                                                            | -                                                     |
| `init.getInitTxId` | () => `Promise`<`string`>                                                                                                                                 | -                                                     |
| `init.getTxBlock`  | () => `Promise`<{ `blockHeight`: `number`; `blockTime`: `number`; }>                                                                                      | -                                                     |
| `state?`           | `SwapCommitState`                                                                                                                                         | Current on-chain state of the swap                    |
| `contractVersion?` | `string`                                                                                                                                                  | -                                                     |
| `lp?`              | [`Intermediary`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/Intermediary.md)                                                   | Intermediary (LP) used as a counterparty for the swap |

#### Returns

`Promise`<[`FromBTCLNAutoSwap`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/FromBTCLNAutoSwap.md)<`T`>>

#### Overrides

[`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md).[`recoverFromSwapDataAndState`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md#recoverfromswapdataandstate)

***

### stop()

```
stop(): Promise<void>;
```

Defined in: [atomiq-sdk/src/swaps/ISwapWrapper.ts:401](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/ISwapWrapper.ts#L401)

Un-subscribes from event listeners on the smart chain, terminates the tick interval and stops this wrapper

#### Returns

`Promise`<`void`>

#### Inherited from

[`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md).[`stop`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md#stop)

***

### tick()

```
tick(swaps?, abortSignal?): Promise<void>;
```

Defined in: [atomiq-sdk/src/swaps/ISwapWrapper.ts:459](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/ISwapWrapper.ts#L459)

Invokes ISwap.\_tick on all the known swaps

#### Parameters

| Parameter      | Type                                                                                                                      | Description                                                                                                              |
| -------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `swaps?`       | [`FromBTCLNAutoSwap`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/FromBTCLNAutoSwap.md)<`T`>\[] | Optional array of swaps to invoke `_tick()` on, otherwise all relevant swaps will be fetched from the persistent storage |
| `abortSignal?` | `AbortSignal`                                                                                                             | Abort signal                                                                                                             |

#### Returns

`Promise`<`void`>

#### Inherited from

[`IFromBTCLNWrapper`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md).[`tick`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/IFromBTCLNWrapper.md#tick)
