Skip to main content

IRefundableSwap<T, D, S>

Defined in: atomiq-sdk/src/swaps/IRefundableSwap.ts:21

Interface for swaps that can be refunded in case of failure

Extends

Type Parameters

Type ParameterDefault type
T extends ChainTypeChainType
D extends SwapTypeDefinition<T, ISwapWrapper<T, D>, IRefundableSwap<T, D, S>>SwapTypeDefinition<T, ISwapWrapper<T, any>, IRefundableSwap<T, any, any>>
S extends numbernumber

Properties

chainIdentifier

readonly chainIdentifier: T["ChainId"];

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

Smart chain identifier string corresponding to this swap

Inherited from

ISwap.chainIdentifier


createdAt

createdAt: number;

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

A UNIX milliseconds timestamps of when this swap was created

Inherited from

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

Inherited from

ISwap.events


exactIn

readonly exactIn: boolean;

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

Whether a swap is an exact input swap

Inherited from

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

Inherited from

ISwap.url


TYPE

abstract protected readonly TYPE: SwapType;

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

Swap type

Inherited from

ISwap.TYPE

Methods

execute()

abstract execute(...args): Promise<boolean>;

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

Executes the swap with the provided wallet, the exact arguments for this functions differ for various swap types. Check the execute() function signature in the respective swap class to see the required arguments.

Parameters

ParameterTypeDescription
...argsany[]Execution arguments, usually contains a source wallet object, callbacks and options, for exact syntax check the respective swap class.

Returns

Promise<boolean>

Whether a swap was successfully executed or not, if it wasn't the user can refund or claim manually

Inherited from

ISwap.execute


getDirection()

getDirection(): SwapDirection;

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

Returns the direction of the swap

Returns

SwapDirection

Inherited from

ISwap.getDirection


getExecutionAction()

abstract getExecutionAction(options?): Promise<SwapExecutionAction>;

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

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?anyOptional 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

Returns

Promise<SwapExecutionAction>

Inherited from

ISwap.getExecutionAction


getExecutionStatus()

abstract getExecutionStatus(options?): Promise<{
currentAction: SwapExecutionAction;
stateInfo: SwapStateInfo<S>;
steps: SwapExecutionStep[];
}>;

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

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?anyOptional options argument for the additional execution status context, see the actual type in the respective swap classes

Returns

Promise<{ currentAction: SwapExecutionAction; stateInfo: SwapStateInfo<S>; steps: SwapExecutionStep[]; }>

Inherited from

ISwap.getExecutionStatus


getExecutionSteps()

abstract getExecutionSteps(options?): Promise<SwapExecutionStep[]>;

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

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.

Parameters

ParameterTypeDescription
options?anyOptional options argument for the additional steps context (i.e. automatic settlement timeout), see the actual type in the respective swap classes

Returns

Promise<SwapExecutionStep[]>

Inherited from

ISwap.getExecutionSteps


getFee()

abstract getFee(): Fee;

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

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

Returns

Fee

Inherited from

ISwap.getFee


getFeeBreakdown()

abstract getFeeBreakdown(): FeeBreakdown<T["ChainId"]>;

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

Returns the breakdown of all the fees paid

Returns

FeeBreakdown<T["ChainId"]>

Inherited from

ISwap.getFeeBreakdown


getId()

abstract getId(): string;

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

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

Returns

string

Inherited from

ISwap.getId


getInput()

abstract getInput(): TokenAmount;

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

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

Returns

TokenAmount

Inherited from

ISwap.getInput


getInputAddress()

abstract getInputAddress(): string;

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

Returns source address of the swap

Returns

string

Inherited from

ISwap.getInputAddress


getInputToken()

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

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

Returns the input token of the swap

Returns

Token<T["ChainId"]>

Inherited from

ISwap.getInputToken


getInputTxId()

abstract getInputTxId(): string;

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

Returns swap input transaction ID on the source chain

Returns

string

Inherited from

ISwap.getInputTxId


getInputWithoutFee()

abstract getInputWithoutFee(): TokenAmount;

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

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

Returns

TokenAmount

Inherited from

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

Inherited from

ISwap.getOutput


getOutputAddress()

abstract getOutputAddress(): string;

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

Returns destination address of the swap

Returns

string

Inherited from

ISwap.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"]>

Inherited from

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

Inherited from

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

Inherited from

ISwap.getPriceInfo


getQuoteExpiry()

getQuoteExpiry(): number;

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

Returns quote expiry in UNIX millis

Returns

number

Inherited from

ISwap.getQuoteExpiry


getState()

getState(): S;

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

Returns the current state of the swap

Returns

S

Inherited from

ISwap.getState


getStateInfo()

getStateInfo(): SwapStateInfo<S>;

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<S>

Inherited from

ISwap.getStateInfo


getType()

getType(): SwapType;

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

Returns the type of the swap

Returns

SwapType

Inherited from

ISwap.getType


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

Inherited from

ISwap.hasValidPrice


isFailed()

abstract isFailed(): boolean;

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

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

Returns

boolean

Inherited from

ISwap.isFailed


isFinished()

abstract isFinished(): boolean;

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

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

Returns

boolean

Inherited from

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

Inherited from

ISwap.isInitiated


isInProgress()

abstract isInProgress(): boolean;

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

Returns whether the swap is currently being processed

Returns

boolean

Inherited from

ISwap.isInProgress


isQuoteExpired()

abstract isQuoteExpired(): boolean;

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

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

Returns

boolean

Inherited from

ISwap.isQuoteExpired


isQuoteSoftExpired()

abstract isQuoteSoftExpired(): boolean;

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

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

Inherited from

ISwap.isQuoteSoftExpired


isRefundable()

isRefundable(): boolean;

Defined in: atomiq-sdk/src/swaps/IRefundableSwap.ts:30

Checks whether a swap is currently refundable

Returns

boolean


isSuccessful()

abstract isSuccessful(): boolean;

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

Returns whether the swap finished successful

Returns

boolean

Inherited from

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

Inherited from

ISwap.refreshPriceData


refund()

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

Defined in: atomiq-sdk/src/swaps/IRefundableSwap.ts:48

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

Parameters

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

Returns

Promise<string>


requiresAction()

abstract requiresAction(): boolean;

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

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

Returns

boolean

Inherited from

ISwap.requiresAction


serialize()

serialize(): any;

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

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

Returns

any

Inherited from

ISwap.serialize


txsRefund()

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

Defined in: atomiq-sdk/src/swaps/IRefundableSwap.ts:40

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?stringAddress of the signer to create the refund transactions for

Returns

Promise<T["TX"][]>


waitTillRefunded()

waitTillRefunded(abortSignal?): Promise<void>;

Defined in: atomiq-sdk/src/swaps/IRefundableSwap.ts:56

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>