Skip to main content

IToBTCSwap<T, D>

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:118

Base class for escrow-based Smart chain -> Bitcoin (on-chain & lightning) swaps

Extends​

Extended by​

Type Parameters​

Type ParameterDefault type
T extends ChainTypeChainType
D extends IToBTCDefinition<T, IToBTCWrapper<T, D>, IToBTCSwap<T, D>>IToBTCDefinition<T, IToBTCWrapper<T, any>, IToBTCSwap<T, any>>

Implements​

Constructors​

Constructor​

protected new IToBTCSwap<T, D>(wrapper, serializedObject): IToBTCSwap<T, D>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:149

Parameters​

ParameterType
wrapperD["Wrapper"]
serializedObjectany

Returns​

IToBTCSwap<T, D>

Overrides​

IEscrowSelfInitSwap.constructor

Constructor​

protected new IToBTCSwap<T, D>(wrapper, init): IToBTCSwap<T, D>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:150

Parameters​

ParameterType
wrapperD["Wrapper"]
initIToBTCSwapInit<T["Data"]>

Returns​

IToBTCSwap<T, D>

Overrides​

IEscrowSelfInitSwap.constructor

Properties​

chainIdentifier​

readonly chainIdentifier: T["ChainId"];

Defined in: atomiq-sdk/src/swaps/ISwap.ts:168

Smart chain identifier string corresponding to this swap

Implementation of​

IRefundableSwap.chainIdentifier

Inherited from​

IEscrowSelfInitSwap.chainIdentifier


createdAt​

createdAt: number;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:176

A UNIX milliseconds timestamps of when this swap was created

Implementation of​

IRefundableSwap.createdAt

Inherited from​

IEscrowSelfInitSwap.createdAt


events​

readonly events: EventEmitter<{
swapState: [D["Swap"]];
}>;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:160

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

Implementation of​

IRefundableSwap.events

Inherited from​

IEscrowSelfInitSwap.events


exactIn​

readonly exactIn: boolean;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:172

Whether a swap is an exact input swap

Implementation of​

IRefundableSwap.exactIn

Inherited from​

IEscrowSelfInitSwap.exactIn


url?​

readonly optional url: string;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:164

URL of the intermediary (LP) used for this swap, already has the swap service specific path appended

Implementation of​

IRefundableSwap.url

Inherited from​

IEscrowSelfInitSwap.url


TYPE​

abstract protected readonly TYPE: SwapType;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:62

Swap type

Implementation of​

IRefundableSwap.TYPE

Inherited from​

IEscrowSelfInitSwap.TYPE

Methods​

_verifyQuoteDefinitelyExpired()​

_verifyQuoteDefinitelyExpired(): Promise<boolean>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts:178

Checks if the swap's quote is expired for good (i.e. the swap strictly cannot be committed on-chain anymore)

Returns​

Promise<boolean>

Implementation of​

IRefundableSwap._verifyQuoteDefinitelyExpired

Inherited from​

IEscrowSelfInitSwap._verifyQuoteDefinitelyExpired


_verifyQuoteValid()​

_verifyQuoteValid(): Promise<boolean>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts:189

Checks if the swap's quote is still valid

Returns​

Promise<boolean>

Implementation of​

IRefundableSwap._verifyQuoteValid

Inherited from​

IEscrowSelfInitSwap._verifyQuoteValid


commit()​

commit(
_signer,
abortSignal?,
skipChecks?,
onBeforeTxSent?): Promise<string>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:823

Initiates (commits) the escrow on the smart chain side

Parameters​

ParameterTypeDescription
_signerT["Signer"] | T["NativeSigner"]Signer to sign the transactions with, must be the same as used in the initialization
abortSignal?AbortSignalAbort signal
skipChecks?booleanSkip checks like making sure init signature is still valid and swap wasn't commited yet (this is handled on swap creation, if you commit right after quoting, you can use skipChecks=true)
onBeforeTxSent?(txId) => voidCallback called before the transactions are broadcasted

Returns​

Promise<string>

Overrides​

IEscrowSelfInitSwap.commit


execute()​

execute(
signer,
callbacks?,
options?): Promise<boolean>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:505

Executes the swap with the provided smart chain wallet/signer

Parameters​

ParameterTypeDescription
signerT["Signer"] | T["NativeSigner"]Smart chain wallet/signer to use to sign the transaction on the source chain
callbacks?{ onSourceTransactionConfirmed?: (sourceTxId) => void; onSourceTransactionSent?: (sourceTxId) => void; onSwapSettled?: (destinationTxId) => void; }Callbacks to track the progress of the swap
callbacks.onSourceTransactionConfirmed?(sourceTxId) => void-
callbacks.onSourceTransactionSent?(sourceTxId) => void-
callbacks.onSwapSettled?(destinationTxId) => void-
options?{ abortSignal?: AbortSignal; maxWaitTillSwapProcessedSeconds?: number; paymentCheckIntervalSeconds?: number; }Optional options for the swap like feeRate, AbortSignal, and timeouts/intervals
options.abortSignal?AbortSignal-
options.maxWaitTillSwapProcessedSeconds?number-
options.paymentCheckIntervalSeconds?number-

Returns​

Promise<boolean>

Whether the swap was successfully processed by the LP, in case false is returned the user can refund their funds back on the source chain by calling refund

Implementation of​

IRefundableSwap.execute

Overrides​

IEscrowSelfInitSwap.execute


getClaimHash()​

getClaimHash(): string;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwap.ts:130

Returns the claim data hash specifying the claim path of the escrow - i.e. hash passed to the claim handler

Returns​

string

Inherited from​

IEscrowSelfInitSwap.getClaimHash


getDirection()​

getDirection(): SwapDirection;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:560

Returns the direction of the swap

Returns​

SwapDirection

Implementation of​

IRefundableSwap.getDirection

Inherited from​

IEscrowSelfInitSwap.getDirection


getEscrowClaimTxId()​

getEscrowClaimTxId(): string;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwap.ts:151

Returns the smart chain transaction ID of the tx that claimed (settled) the escrow

Returns​

string

Inherited from​

IEscrowSelfInitSwap.getEscrowClaimTxId


getEscrowHash()​

getEscrowHash(): string;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwap.ts:123

Returns the escrow hash - i.e. hash of the escrow data

Returns​

string

Inherited from​

IEscrowSelfInitSwap.getEscrowHash


getEscrowInitTxId()​

getEscrowInitTxId(): string;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwap.ts:144

Returns the smart chain transaction ID of the tx that initiated the escrow

Returns​

string

Inherited from​

IEscrowSelfInitSwap.getEscrowInitTxId


getEscrowRefundTxId()​

getEscrowRefundTxId(): string;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwap.ts:158

Returns the smart chain transaction ID of the tx that refunded the escrow

Returns​

string

Inherited from​

IEscrowSelfInitSwap.getEscrowRefundTxId


getExecutionAction()​

getExecutionAction(options?): Promise<
| SwapExecutionActionWait<"LP">
| SwapExecutionActionSignSmartChainTx<T>>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:746

Returns a current state-dependent action for the user to execute, or undefined if there is no more action required for this swap - this means that the swap is probably finished (either expired, failed or settled).

Parameters​

ParameterTypeDescription
options?{ refundSmartChainSigner?: string | T["Signer"] | T["NativeSigner"]; skipChecks?: boolean; }Optional options argument for the additional action context (i.e. passing bitcoin wallet info to get funded PSBTs or passing the externally-generated swap secret), see the actual type in the respective swap classes
options.refundSmartChainSigner?string | T["Signer"] | T["NativeSigner"]Optional smart chain signer to use when creating refunds transactions
options.skipChecks?booleanSkip checks like making sure init signature is still valid and swap wasn't commited yet (this is handled on swap creation, if you commit right after quoting, you can use skipChecks=true)

Returns​

Promise< | SwapExecutionActionWait<"LP"> | SwapExecutionActionSignSmartChainTx<T>>

Implementation of​

IRefundableSwap.getExecutionAction

Overrides​

IEscrowSelfInitSwap.getExecutionAction


getExecutionStatus()​

getExecutionStatus(options?): Promise<{
currentAction: | SwapExecutionActionWait<"LP">
| SwapExecutionActionSignSmartChainTx<T>;
stateInfo: SwapStateInfo<ToBTCSwapState>;
steps: [SwapExecutionStepPayment<T["ChainId"]>, SwapExecutionStepSettlement<"BITCOIN" | "LIGHTNING", "soft_settled">, SwapExecutionStepRefund<T["ChainId"]>];
}>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:761

Returns the current action and the full execution steps for a given swap. Prefer this to calling getExecutionSteps and getExecutionAction separately - if called sequentially they might return the respective steps/actions in different states if you hit the state transition boundary.

Parameters​

ParameterTypeDescription
options?{ refundSmartChainSigner?: string | T["Signer"] | T["NativeSigner"]; skipBuildingAction?: boolean; skipChecks?: boolean; }Optional options argument for the additional execution status context, see the actual type in the respective swap classes
options.refundSmartChainSigner?string | T["Signer"] | T["NativeSigner"]-
options.skipBuildingAction?boolean-
options.skipChecks?boolean-

Returns​

Promise<{ currentAction: | SwapExecutionActionWait<"LP"> | SwapExecutionActionSignSmartChainTx<T>; stateInfo: SwapStateInfo<ToBTCSwapState>; steps: [SwapExecutionStepPayment<T["ChainId"]>, SwapExecutionStepSettlement<"BITCOIN" | "LIGHTNING", "soft_settled">, SwapExecutionStepRefund<T["ChainId"]>]; }>

Implementation of​

IRefundableSwap.getExecutionStatus

Overrides​

IEscrowSelfInitSwap.getExecutionStatus


getExecutionSteps()​

getExecutionSteps(): Promise<[SwapExecutionStepPayment<T["ChainId"]>, SwapExecutionStepSettlement<"BITCOIN" | "LIGHTNING", "soft_settled">, SwapExecutionStepRefund<T["ChainId"]>]>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:788

Returns a list of execution steps the user has to go through for a given swap, to see the possible execution steps check out SwapExecutionStep.

Returns​

Promise<[SwapExecutionStepPayment<T["ChainId"]>, SwapExecutionStepSettlement<"BITCOIN" | "LIGHTNING", "soft_settled">, SwapExecutionStepRefund<T["ChainId"]>]>

Implementation of​

IRefundableSwap.getExecutionSteps

Overrides​

IEscrowSelfInitSwap.getExecutionSteps


getExpiry()​

getExpiry(): number;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:321

Returns the time (in UNIX milliseconds) at which the swap expires and the user is able to unilaterally refund it with the refund or txsRefund function.

Returns​

number


getFee()​

getFee(): Fee<T["ChainId"], SCToken<T["ChainId"]>, BtcToken>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:388

Returns total fee for the swap, the fee is represented in source currency & destination currency, but is paid only once

Returns​

Fee<T["ChainId"], SCToken<T["ChainId"]>, BtcToken>

Implementation of​

IRefundableSwap.getFee

Overrides​

IEscrowSelfInitSwap.getFee


getFeeBreakdown()​

getFeeBreakdown(): [{
fee: Fee<T["ChainId"], SCToken<T["ChainId"]>, BtcToken>;
type: SWAP;
}, {
fee: Fee<T["ChainId"], SCToken<T["ChainId"]>, BtcToken>;
type: NETWORK_OUTPUT;
}];

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:407

Returns the breakdown of all the fees paid

Returns​

[{ fee: Fee<T["ChainId"], SCToken<T["ChainId"]>, BtcToken>; type: SWAP; }, { fee: Fee<T["ChainId"], SCToken<T["ChainId"]>, BtcToken>; type: NETWORK_OUTPUT; }]

Implementation of​

IRefundableSwap.getFeeBreakdown

Overrides​

IEscrowSelfInitSwap.getFeeBreakdown


getId()​

getId(): string;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSwap.ts:137

Returns the ID of the swap, as used in the storage

Returns​

string

Implementation of​

IRefundableSwap.getId

Inherited from​

IEscrowSelfInitSwap.getId


getInput()​

getInput(): TokenAmount<SCToken<T["ChainId"]>, true>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:433

Returns input amount of the swap, user needs to pay this much

Returns​

TokenAmount<SCToken<T["ChainId"]>, true>

Implementation of​

IRefundableSwap.getInput

Overrides​

IEscrowSelfInitSwap.getInput


getInputAddress()​

getInputAddress(): string;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:250

Returns source address of the swap

Returns​

string

Implementation of​

IRefundableSwap.getInputAddress

Overrides​

IEscrowSelfInitSwap.getInputAddress


getInputToken()​

getInputToken(): SCToken<T["ChainId"]>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:426

Returns the input token of the swap

Returns​

SCToken<T["ChainId"]>

Implementation of​

IRefundableSwap.getInputToken

Overrides​

IEscrowSelfInitSwap.getInputToken


getInputTxId()​

getInputTxId(): string;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:257

Returns swap input transaction ID on the source chain

Returns​

string

Implementation of​

IRefundableSwap.getInputTxId

Overrides​

IEscrowSelfInitSwap.getInputTxId


getInputWithoutFee()​

getInputWithoutFee(): TokenAmount<SCToken<T["ChainId"]>, true>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:443

Returns input amount of the swap without the fees (swap fee, network fee)

Returns​

TokenAmount<SCToken<T["ChainId"]>, true>

Implementation of​

IRefundableSwap.getInputWithoutFee

Overrides​

IEscrowSelfInitSwap.getInputWithoutFee


getOutput()​

abstract getOutput(): TokenAmount;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:638

Returns output amount of the swap, user receives this much

Returns​

TokenAmount

Implementation of​

IRefundableSwap.getOutput

Inherited from​

IEscrowSelfInitSwap.getOutput


getOutputAddress()​

abstract getOutputAddress(): string;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:480

Returns destination address of the swap

Returns​

string

Implementation of​

IRefundableSwap.getOutputAddress

Inherited from​

IEscrowSelfInitSwap.getOutputAddress


getOutputToken()​

abstract getOutputToken(): Token<T["ChainId"]>;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:643

Returns the output token of the swap

Returns​

Token<T["ChainId"]>

Implementation of​

IRefundableSwap.getOutputToken

Inherited from​

IEscrowSelfInitSwap.getOutputToken


getOutputTxId()​

abstract getOutputTxId(): string;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:490

Returns swap output transaction ID on the destination chain

Returns​

string

Implementation of​

IRefundableSwap.getOutputTxId

Inherited from​

IEscrowSelfInitSwap.getOutputTxId


getPriceInfo()​

getPriceInfo(): object;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:388

Returns pricing info about the swap

Returns​

object

NameTypeDefined in
differencePercentagePPMatomiq-sdk/src/swaps/ISwap.ts:391
marketPrice?numberatomiq-sdk/src/swaps/ISwap.ts:389
swapPricenumberatomiq-sdk/src/swaps/ISwap.ts:390

Implementation of​

IRefundableSwap.getPriceInfo

Inherited from​

IEscrowSelfInitSwap.getPriceInfo


getQuoteExpiry()​

getQuoteExpiry(): number;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:546

Returns quote expiry in UNIX millis

Returns​

number

Implementation of​

IRefundableSwap.getQuoteExpiry

Inherited from​

IEscrowSelfInitSwap.getQuoteExpiry


getRefundNetworkFee()​

getRefundNetworkFee(): Promise<TokenAmount<SCToken<T["ChainId"]>, true>>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:1041

Get the estimated smart chain transaction fee of the refund transaction

Returns​

Promise<TokenAmount<SCToken<T["ChainId"]>, true>>


getSmartChainNetworkFee()​

getSmartChainNetworkFee(): Promise<TokenAmount<SCToken<T["ChainId"]>, true>>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts:115

Returns the transaction fee paid on the smart chain side to initiate the escrow

Returns​

Promise<TokenAmount<SCToken<T["ChainId"]>, true>>

Inherited from​

IEscrowSelfInitSwap.getSmartChainNetworkFee


getState()​

getState(): ToBTCSwapState;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:567

Returns the current state of the swap

Returns​

ToBTCSwapState

Implementation of​

IRefundableSwap.getState

Inherited from​

IEscrowSelfInitSwap.getState


getStateInfo()​

getStateInfo(): SwapStateInfo<ToBTCSwapState>;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:574

Returns the current state of the swap along with the human-readable description of the state

Returns​

SwapStateInfo<ToBTCSwapState>

Implementation of​

IRefundableSwap.getStateInfo

Inherited from​

IEscrowSelfInitSwap.getStateInfo


getType()​

getType(): SwapType;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:553

Returns the type of the swap

Returns​

SwapType

Implementation of​

IRefundableSwap.getType

Inherited from​

IEscrowSelfInitSwap.getType


hasEnoughBalance()​

hasEnoughBalance(): Promise<{
balance: TokenAmount<SCToken<T["ChainId"]>, true>;
enoughBalance: boolean;
required: TokenAmount<SCToken<T["ChainId"]>, true>;
}>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:453

Checks if the initiator/sender on the source chain has enough balance to go through with the swap

Returns​

Promise<{ balance: TokenAmount<SCToken<T["ChainId"]>, true>; enoughBalance: boolean; required: TokenAmount<SCToken<T["ChainId"]>, true>; }>


hasEnoughForTxFees()​

hasEnoughForTxFees(): Promise<{
balance: TokenAmount<SCToken<T["ChainId"]>, true>;
enoughBalance: boolean;
required: TokenAmount<SCToken<T["ChainId"]>, true>;
}>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:475

Checks if the initiator/sender on the source chain has enough native token balance to cover the transaction fee of initiating the swap

Returns​

Promise<{ balance: TokenAmount<SCToken<T["ChainId"]>, true>; enoughBalance: boolean; required: TokenAmount<SCToken<T["ChainId"]>, true>; }>

Overrides​

IEscrowSelfInitSwap.hasEnoughForTxFees


hasValidPrice()​

hasValidPrice(): boolean;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:380

Checks if the pricing for the swap is valid, according to max allowed price difference set in the ISwapPrice

Returns​

boolean

Implementation of​

IRefundableSwap.hasValidPrice

Inherited from​

IEscrowSelfInitSwap.hasValidPrice


isFailed()​

isFailed(): boolean;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:306

Returns whether the swap failed (e.g. was refunded)

Returns​

boolean

Implementation of​

IRefundableSwap.isFailed

Overrides​

IEscrowSelfInitSwap.isFailed


isFinished()​

isFinished(): boolean;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:271

Returns whether the swap is finished and in its terminal state (this can mean successful, refunded or failed)

Returns​

boolean

Implementation of​

IRefundableSwap.isFinished

Overrides​

IEscrowSelfInitSwap.isFinished


isInitiated()​

isInitiated(): boolean;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:539

Whether a swap was initialized, a swap is considered initialized on first interaction with it, i.e. calling commit() on a Smart chain -> Bitcoin swaps, calling waitForPayment() or similar on the other direction. Not initiated swaps are not saved to the persistent storage by default (see SwapperOptions.saveUninitializedSwaps)

Returns​

boolean

Implementation of​

IRefundableSwap.isInitiated

Inherited from​

IEscrowSelfInitSwap.isInitiated


isInProgress()​

isInProgress(): boolean;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:313

Returns whether the swap is currently being processed

Returns​

boolean

Implementation of​

IRefundableSwap.isInProgress

Overrides​

IEscrowSelfInitSwap.isInProgress


isQuoteExpired()​

isQuoteExpired(): boolean;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:285

Checks whether the swap's quote has definitely expired and cannot be committed anymore, we can remove such swap

Returns​

boolean

Implementation of​

IRefundableSwap.isQuoteExpired

Overrides​

IEscrowSelfInitSwap.isQuoteExpired


isQuoteSoftExpired()​

isQuoteSoftExpired(): boolean;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:292

Checks whether the swap's quote is soft expired (this means there is not enough time buffer for it to commit, but it still can happen)

Returns​

boolean

Implementation of​

IRefundableSwap.isQuoteSoftExpired

Overrides​

IEscrowSelfInitSwap.isQuoteSoftExpired


isRefundable()​

isRefundable(): boolean;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:278

Checks whether a swap is currently refundable

Returns​

boolean

Implementation of​

IRefundableSwap.isRefundable


isSuccessful()​

isSuccessful(): boolean;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:299

Returns whether the swap finished successful

Returns​

boolean

Implementation of​

IRefundableSwap.isSuccessful

Overrides​

IEscrowSelfInitSwap.isSuccessful


refreshPriceData()​

refreshPriceData(): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:336

Re-fetches & revalidates the price data based on the current market prices

Returns​

Promise<void>

Implementation of​

IRefundableSwap.refreshPriceData

Inherited from​

IEscrowSelfInitSwap.refreshPriceData


refund()​

refund(_signer, abortSignal?): Promise<string>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:1096

Refunds the swap if the swap is in refundable state, you can check so with isRefundable

Parameters​

ParameterTypeDescription
_signerT["Signer"] | T["NativeSigner"]Signer to sign the transactions with, must be the same as used in the initialization
abortSignal?AbortSignalAbort signal

Returns​

Promise<string>

Implementation of​

IRefundableSwap.refund


requiresAction()​

requiresAction(): boolean;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:264

Checks whether there is some action required from the user for this swap - can mean either refundable or claimable

Returns​

boolean

Implementation of​

IRefundableSwap.requiresAction

Overrides​

IEscrowSelfInitSwap.requiresAction


serialize()​

serialize(): any;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:1159

Serializes the swap to a JSON stringifiable representation (i.e. no bigints, buffers etc.)

Returns​

any

Implementation of​

IRefundableSwap.serialize

Overrides​

IEscrowSelfInitSwap.serialize


txsCommit()​

txsCommit(skipChecks?): Promise<T["TX"][]>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:804

Returns transactions for initiating (committing) the escrow on the smart chain side. After sending the transactions manually be sure to call the waitTillCommited function to wait till the initiation transaction is observed, processed by the SDK and state of the swap properly updated.

Parameters​

ParameterTypeDescription
skipChecks?booleanSkip checks like making sure init signature is still valid and swap wasn't commited yet (this is handled on swap creation, if you commit right after quoting, you can use skipChecks=true)

Returns​

Promise<T["TX"][]>

Overrides​

IEscrowSelfInitSwap.txsCommit


txsRefund()​

txsRefund(_signer?): Promise<T["TX"][]>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:1057

Returns transactions for refunding the swap if the swap is in refundable state, you can check so with isRefundable. After sending the transaction manually be sure to call the waitTillRefunded function to wait till the refund transaction is observed, processed by the SDK and state of the swap properly updated.

Parameters​

ParameterTypeDescription
_signer?string | T["Signer"] | T["NativeSigner"]Address of the signer to create the refund transactions for

Returns​

Promise<T["TX"][]>

Implementation of​

IRefundableSwap.txsRefund


waitForPayment()​

waitForPayment(
maxWaitTimeSeconds?,
checkIntervalSeconds?,
abortSignal?): Promise<boolean>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:974

A blocking promise resolving when swap was concluded by the intermediary (LP), rejecting in case of failure

Parameters​

ParameterTypeDescription
maxWaitTimeSeconds?numberMaximum time in seconds to wait for the swap to be settled, an error is thrown if the swap is taking too long to claim
checkIntervalSeconds?numberHow often to poll the intermediary for answer
abortSignal?AbortSignalAbort signal

Returns​

Promise<boolean>

true if swap was successful, false if swap failed and we can refund

Throws​

If a swap is determined expired by the intermediary, but it is actually still valid

Throws​

If the swap should be cooperatively refundable but the intermediary returned invalid refund signature

Throws​

When swap expires or if the swap has invalid state (must be ToBTCSwapState.COMMITED)


waitTillCommited()​

waitTillCommited(abortSignal?): Promise<void>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:848

Waits till a swap is initiated (committed) on-chain, should be called after sending the commit transactions (txsCommit) manually to wait till the SDK processes the escrow initialization and updates the swap state accordingly

Parameters​

ParameterTypeDescription
abortSignal?AbortSignalAbortSignal

Returns​

Promise<void>

Overrides​

IEscrowSelfInitSwap.waitTillCommited


waitTillRefunded()​

waitTillRefunded(abortSignal?): Promise<void>;

Defined in: atomiq-sdk/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts:1114

Waits till a swap is refunded, should be called after sending the refund transactions manually to wait till the SDK processes the refund and updates the swap state accordingly

Parameters​

ParameterTypeDescription
abortSignal?AbortSignalAbortSignal

Returns​

Promise<void>

Implementation of​

IRefundableSwap.waitTillRefunded