Skip to main content

FromBTCWrapper<T>

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts:61

Legacy escrow (PrTLC) based swap for Bitcoin -> Smart chains, requires manual initiation of the swap escrow on the destination chain.

Extends

Type Parameters

Type Parameter
T extends ChainType

Implements

Constructors

Constructor

new FromBTCWrapper<T>(
chainIdentifier,
unifiedStorage,
unifiedChainEvents,
chain,
contract,
prices,
tokens,
swapDataDeserializer,
btcRelay,
synchronizer,
btcRpc,
options?,
events?): FromBTCWrapper<T>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts:115

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
pricesISwapPricePricing to use
tokensWrapperCtorTokens
swapDataDeserializer(data) => T["Data"]Deserializer for SwapData
btcRelayBtcRelay<any, T["TX"], any>
synchronizerRelaySynchronizer<any, T["TX"], any>Btc relay synchronizer
btcRpcBitcoinRpcWithAddressIndex<any>Bitcoin RPC which also supports getting transactions by txoHash
options?AllOptional<FromBTCWrapperOptions>
events?EventEmitter<{ swapState: [ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>]; }>Instance to use for emitting events

Returns

FromBTCWrapper<T>

Overrides

IFromBTCWrapper.constructor

Properties

chainIdentifier

readonly chainIdentifier: T["ChainId"];

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

Chain identifier string of this wrapper

Inherited from

IFromBTCWrapper.chainIdentifier


events

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

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

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

Inherited from

IFromBTCWrapper.events


TYPE

readonly TYPE: FROM_BTC = SwapType.FROM_BTC;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts:64

Swap type

Overrides

IEscrowSwapWrapper.TYPE

Methods

checkPastSwaps()

checkPastSwaps(pastSwaps?, noSave?): Promise<{
changedSwaps: FromBTCSwap<T>[];
removeSwaps: FromBTCSwap<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?FromBTCSwap<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: FromBTCSwap<T>[]; removeSwaps: FromBTCSwap<T>[]; }>

Inherited from

IFromBTCWrapper.checkPastSwaps


create()

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

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts:383

Returns a newly created legacy Bitcoin -> Smart chain swap using the PrTLC based escrow swap protocol, with the passed amount.

Parameters

ParameterTypeDescription
recipientstringSmart chain signer'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?FromBTCOptionsOptional additional quote options
additionalParams?Record<string, any>Optional additional parameters sent to the LP when creating the swap
abortSignal?AbortSignalAbort signal

Returns

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

IFromBTCWrapper.init


recoverFromSwapDataAndState()

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

Defined in: atomiq-sdk/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts:488

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<FromBTCSwap<T>>

Overrides

IFromBTCWrapper.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

IFromBTCWrapper.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?FromBTCSwap<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

IFromBTCWrapper.tick