Skip to main content

FromBTCLNAutoWrapper<T>

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts:65

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

Type Parameters

Type Parameter
T extends ChainType

Implements

Constructors

Constructor

new FromBTCLNAutoWrapper<T>(
chainIdentifier,
unifiedStorage,
unifiedChainEvents,
chain,
contract,
prices,
tokens,
swapDataDeserializer,
lnApi,
messenger,
options?,
events?): FromBTCLNAutoWrapper<T>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts:118

Parameters

ParameterTypeDescription
chainIdentifierstring
unifiedStorageUnifiedSwapStorage<T>Storage interface for the current environment
unifiedChainEventsUnifiedSwapEventListener<T>On-chain event listener
chainT["ChainInterface"]
contractT["Contract"]Underlying contract handling the swaps
pricesISwapPriceSwap pricing handler
tokensWrapperCtorTokens
swapDataDeserializer(data) => T["Data"]Deserializer for SwapData
lnApiLightningNetworkApi
messengerMessenger
options?AllOptional<FromBTCLNAutoWrapperOptions>
events?EventEmitter<{ swapState: [ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>]; }>Instance to use for emitting events

Returns

FromBTCLNAutoWrapper<T>

Overrides

IFromBTCLNWrapper.constructor

Properties

chainIdentifier

readonly chainIdentifier: T["ChainId"];

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:142

Chain identifier string of this wrapper

Inherited from

IFromBTCLNWrapper.chainIdentifier


events

readonly events: EventEmitter<{
swapState: [FromBTCLNAutoSwap<T>];
}>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:146

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

Inherited from

IFromBTCLNWrapper.events


TYPE

readonly TYPE: FROM_BTCLN_AUTO = SwapType.FROM_BTCLN_AUTO;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts:69

Swap type

Overrides

IEscrowSwapWrapper.TYPE

Methods

checkPastSwaps()

checkPastSwaps(pastSwaps?, noSave?): Promise<{
changedSwaps: FromBTCLNAutoSwap<T>[];
removeSwaps: FromBTCLNAutoSwap<T>[];
}>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:369

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

Parameters

ParameterTypeDescription
pastSwaps?FromBTCLNAutoSwap<T>[]Optional array of past swaps to check, otherwise all relevant swaps will be fetched from the persistent storage
noSave?booleanWhether to skip saving the swap changes in the persistent storage

Returns

Promise<{ changedSwaps: FromBTCLNAutoSwap<T>[]; removeSwaps: FromBTCLNAutoSwap<T>[]; }>

Inherited from

IFromBTCLNWrapper.checkPastSwaps


create()

create(
recipient,
amountData,
lps,
options?,
additionalParams?,
abortSignal?,
preFetches?): object[];

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts:309

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

ParameterTypeDescription
recipientstringRecipient's address on the destination chain
amountDataAmountDataAmount, token and exact input/output data for to swap
lpsIntermediary[]An array of intermediaries (LPs) to get the quotes from
options?FromBTCLNAutoOptionsOptional additional quote options
additionalParams?Record<string, any>Optional additional parameters sent to the LP when creating the swap
abortSignal?AbortSignalAbort signal
preFetches?{ claimerBountyPrefetch?: 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?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:485

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 is called on the swap.

Parameters

ParameterTypeDescription
recipientstringRecipient's address on the destination chain
lnurl| string | LNURLWithdrawParamsWithUrlLNURL-withdraw link to pull the funds from
amountDataAmountDataAmount, token and exact input/output data for to swap
lpsIntermediary[]An array of intermediaries (LPs) to get the quotes from
options?FromBTCLNAutoOptionsOptional additional quote options
additionalParams?Record<string, any>Optional additional parameters sent to the LP when creating the swap
abortSignal?AbortSignalAbort signal

Returns

Promise<object[]>


init()

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

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:314

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

Parameters

ParameterTypeDefault valueDescription
noTimersbooleanfalseWhether 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
noCheckPastSwapsbooleanfalseWhether 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.init


recoverFromSwapDataAndState()

recoverFromSwapDataAndState(
init,
state,
lp?): Promise<FromBTCLNAutoSwap<T>>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts:635

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

ParameterTypeDescription
init{ data: T["Data"]; getInitTxId: () => Promise<string>; getTxBlock: () => Promise<{ blockHeight: number; blockTime: number; }>; }Swap escrow initialization transaction and swap data
init.dataT["Data"]-
init.getInitTxId() => Promise<string>-
init.getTxBlock?() => Promise<{ blockHeight: number; blockTime: number; }>-
state?SwapCommitStateCurrent on-chain state of the swap
lp?IntermediaryIntermediary (LP) used as a counterparty for the swap

Returns

Promise<FromBTCLNAutoSwap<T>>

Overrides

IFromBTCLNWrapper.recoverFromSwapDataAndState


stop()

stop(): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:355

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

Returns

Promise<void>

Inherited from

IFromBTCLNWrapper.stop


tick()

tick(swaps?): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:396

Invokes ISwap._tick on all the known swaps

Parameters

ParameterTypeDescription
swaps?FromBTCLNAutoSwap<T>[]Optional array of swaps to invoke _tick() on, otherwise all relevant swaps will be fetched from the persistent storage

Returns

Promise<void>

Inherited from

IFromBTCLNWrapper.tick