Skip to main content

SpvFromBTCWrapper<T>

Defined in: atomiq-sdk/src/swaps/spv_swaps/SpvFromBTCWrapper.ts:63

New spv vault (UTXO-controlled vault) based swaps for Bitcoin -> Smart chain swaps not requiring any initiation on the destination chain, and with the added possibility for the user to receive a native token on the destination chain as part of the swap (a "gas drop" feature).

Extends

  • ISwapWrapper<T, SpvFromBTCTypeDefinition<T>, SpvFromBTCWrapperOptions>

Type Parameters

Type Parameter
T extends ChainType

Implements

Constructors

Constructor

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

Defined in: atomiq-sdk/src/swaps/spv_swaps/SpvFromBTCWrapper.ts:137

Parameters

ParameterTypeDescription
chainIdentifierstring
unifiedStorageUnifiedSwapStorage<T>Storage interface for the current environment
unifiedChainEventsUnifiedSwapEventListener<T>On-chain event listener
chainT["ChainInterface"]
contractT["SpvVaultContract"]Underlying contract handling the swaps
pricesISwapPricePricing to use
tokensWrapperCtorTokens
spvWithdrawalDataDeserializer(data) => T["SpvVaultWithdrawalData"]Deserializer for SpvVaultWithdrawalData
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<SpvFromBTCWrapperOptions>
events?EventEmitter<{ swapState: [ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>]; }>Instance to use for emitting events

Returns

SpvFromBTCWrapper<T>

Overrides

ISwapWrapper.constructor

Properties

chainIdentifier

readonly chainIdentifier: T["ChainId"];

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

Chain identifier string of this wrapper

Inherited from

ISwapWrapper.chainIdentifier


events

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

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

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

Inherited from

ISwapWrapper.events


TYPE

readonly TYPE: SPV_VAULT_FROM_BTC = SwapType.SPV_VAULT_FROM_BTC;

Defined in: atomiq-sdk/src/swaps/spv_swaps/SpvFromBTCWrapper.ts:66

Swap type

Overrides

ISwapWrapper.TYPE

Methods

checkPastSwaps()

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

Inherited from

ISwapWrapper.checkPastSwaps


create()

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

Defined in: atomiq-sdk/src/swaps/spv_swaps/SpvFromBTCWrapper.ts:540

Returns a newly created Bitcoin -> Smart chain swap using the SPV vault (UTXO-controlled vault) swap protocol, with the passed amount. Also allows specifying additional "gas drop" native token that the receipient receives on the destination chain in the options argument.

Parameters

ParameterTypeDescription
recipientstringRecipient address on the destination smart chain
amountDataAmountDataAmount, token and exact input/output data for to swap
lpsIntermediary[]An array of intermediaries (LPs) to get the quotes from
options?SpvFromBTCOptionsOptional additional quote options
additionalParams?Record<string, any>Optional additional parameters sent to the LP when creating the swap
abortSignal?AbortSignalAbort signal

Returns

object[]


getDummySwapPsbt()

getDummySwapPsbt(includeGasToken): Transaction;

Defined in: atomiq-sdk/src/swaps/spv_swaps/SpvFromBTCWrapper.ts:792

Returns a random dummy PSBT that can be used for fee estimation, the last output (the LP output) is omitted to allow for coinselection algorithm to determine maximum sendable amount there

Parameters

ParameterTypeDefault valueDescription
includeGasTokenbooleanfalseWhether to return the PSBT also with the gas token amount (increases the vSize by 8)

Returns

Transaction


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

ISwapWrapper.init


recoverFromState()

recoverFromState(
state,
vault?,
lp?): Promise<SpvFromBTCSwap<T>>;

Defined in: atomiq-sdk/src/swaps/spv_swaps/SpvFromBTCWrapper.ts:687

Recovers an SPV vault (UTXO-controlled vault) based swap from smart chain on-chain data

Parameters

ParameterTypeDescription
stateSpvWithdrawalFrontedState | SpvWithdrawalClaimedStateState of the spv vault withdrawal recovered from on-chain data
vault?SpvVaultData<SpvWithdrawalTransactionData>SPV vault processing the swap
lp?IntermediaryIntermediary (LP) used as a counterparty for the swap

Returns

Promise<SpvFromBTCSwap<T>>


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

ISwapWrapper.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?SpvFromBTCSwap<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

ISwapWrapper.tick