ToBTCWrapper<T>
Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts:54
Escrow based (PrTLC) swap for Smart chains -> Bitcoin
Extends
IToBTCWrapper<T,ToBTCDefinition<T>,ToBTCWrapperOptions>
Type Parameters
| Type Parameter |
|---|
T extends ChainType |
Constructors
Constructor
new ToBTCWrapper<T>(
chainIdentifier,
unifiedStorage,
unifiedChainEvents,
chain,
contract,
prices,
tokens,
swapDataDeserializer,
btcRpc,
options?,
events?): ToBTCWrapper<T>;
Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts:78
Parameters
| Parameter | Type | Description |
|---|---|---|
chainIdentifier | string | |
unifiedStorage | UnifiedSwapStorage<T> | Storage interface for the current environment |
unifiedChainEvents | UnifiedSwapEventListener<T> | Smart chain on-chain event listener |
chain | T["ChainInterface"] | |
contract | T["Contract"] | Chain specific swap contract |
prices | ISwapPrice | Swap pricing handler |
tokens | WrapperCtorTokens | |
swapDataDeserializer | (data) => T["Data"] | Deserializer for chain specific SwapData |
btcRpc | BitcoinRpc<any> | Bitcoin RPC api |
options? | AllOptional<ToBTCWrapperOptions> | |
events? | EventEmitter<{ swapState: [ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>]; }> | Instance to use for emitting events |
Returns
ToBTCWrapper<T>
Overrides
Properties
chainIdentifier
readonly chainIdentifier: T["ChainId"];
Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:142
Chain identifier string of this wrapper
Inherited from
events
readonly events: EventEmitter<{
swapState: [ToBTCSwap<T>];
}>;
Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:146
Event emitter emitting "swapState" event when swap's state changes
Inherited from
TYPE
readonly TYPE: TO_BTC = SwapType.TO_BTC;
Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts:55
Swap type
Overrides
Methods
checkPastSwaps()
checkPastSwaps(pastSwaps?, noSave?): Promise<{
changedSwaps: ToBTCSwap<T>[];
removeSwaps: ToBTCSwap<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
| Parameter | Type | Description |
|---|---|---|
pastSwaps? | ToBTCSwap<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: ToBTCSwap<T>[];
removeSwaps: ToBTCSwap<T>[];
}>
Inherited from
create()
create(
signer,
recipient,
amountData,
lps,
options?,
additionalParams?,
abortSignal?): object[];
Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts:210
Returns a newly created Smart chain -> Bitcoin swap using the PrTLC based escrow swap protocol, with the passed amount.
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Source chain signer address initiating the swap |
recipient | string | Recipient bitcoin on-chain address |
amountData | AmountData | Amount, token and exact input/output data for to swap |
lps | Intermediary[] | An array of intermediaries (LPs) to get the quotes from |
options? | ToBTCOptions | Optional additional quote options |
additionalParams? | Record<string, any> | Optional additional parameters sent to the LP when creating the swap |
abortSignal? | AbortSignal | Abort 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
| 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
recoverFromSwapDataAndState()
recoverFromSwapDataAndState(
init,
state,
lp?): Promise<ToBTCSwap<T>>;
Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts:327
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 |
lp? | Intermediary | Intermediary (LP) used as a counterparty for the swap |
Returns
Promise<ToBTCSwap<T>>
Overrides
IToBTCWrapper.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
tick()
tick(swaps?): Promise<void>;
Defined in: atomiq-sdk/src/swaps/ISwapWrapper.ts:396
Invokes ISwap._tick on all the known swaps
Parameters
| Parameter | Type | Description |
|---|---|---|
swaps? | ToBTCSwap<T>[] | Optional array of swaps to invoke _tick() on, otherwise all relevant swaps will be fetched from the persistent storage |
Returns
Promise<void>