Skip to main content

IEscrowSelfInitSwap<T, D, S>

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

Base class for escrow-based swaps (i.e. swaps utilizing PrTLC and HTLC primitives) where the user needs to initiate the escrow on the smart chain side

Extends

Extended by

Type Parameters

Type ParameterDefault type
T extends ChainTypeChainType
D extends IEscrowSelfInitSwapDefinition<T, IEscrowSwapWrapper<T, D>, IEscrowSelfInitSwap<T, D, S>>IEscrowSwapDefinition<T, IEscrowSwapWrapper<T, any>, IEscrowSelfInitSwap<T, any, any>>
S extends numbernumber

Constructors

Constructor

protected new IEscrowSelfInitSwap<T, D, S>(wrapper, obj): IEscrowSelfInitSwap<T, D, S>;

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

Parameters

ParameterType
wrapperD["Wrapper"]
objany

Returns

IEscrowSelfInitSwap<T, D, S>

Overrides

IEscrowSwap.constructor

Constructor

protected new IEscrowSelfInitSwap<T, D, S>(wrapper, swapInit): IEscrowSelfInitSwap<T, D, S>;

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

Parameters

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

Returns

IEscrowSelfInitSwap<T, D, S>

Overrides

IEscrowSwap.constructor

Properties

chainIdentifier

readonly chainIdentifier: T["ChainId"];

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

Smart chain identifier string corresponding to this swap

Inherited from

IEscrowSwap.chainIdentifier


createdAt

createdAt: number;

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

A UNIX milliseconds timestamps of when this swap was created

Inherited from

IEscrowSwap.createdAt


events

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

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

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

Inherited from

IEscrowSwap.events


exactIn

readonly exactIn: boolean;

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

Whether a swap is an exact input swap

Inherited from

IEscrowSwap.exactIn


url?

readonly optional url: string;

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

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

Inherited from

IEscrowSwap.url


TYPE

abstract protected readonly TYPE: SwapType;

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

Swap type

Inherited from

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

Overrides

IEscrowSwap._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>

Overrides

IEscrowSwap._verifyQuoteValid

commit()

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

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

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>


execute()

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

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

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

IEscrowSwap.execute


getClaimHash()

getClaimHash(): string;

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

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

Returns

string

Inherited from

IEscrowSwap.getClaimHash


getCurrentActions()

abstract getCurrentActions(): Promise<SwapExecutionAction<T>[]>;

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

Returns a state-dependent set of actions for the user to execute, or empty array if there is currently no action required from the user to execute.

Returns

Promise<SwapExecutionAction<T>[]>

Inherited from

IEscrowSwap.getCurrentActions


getDirection()

getDirection(): SwapDirection;

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

Returns the direction of the swap

Returns

SwapDirection

Inherited from

IEscrowSwap.getDirection


getEscrowClaimTxId()

getEscrowClaimTxId(): string;

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

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

Returns

string

Inherited from

IEscrowSwap.getEscrowClaimTxId


getEscrowHash()

getEscrowHash(): string;

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

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

Returns

string

Inherited from

IEscrowSwap.getEscrowHash


getEscrowInitTxId()

getEscrowInitTxId(): string;

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

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

Returns

string

Inherited from

IEscrowSwap.getEscrowInitTxId


getEscrowRefundTxId()

getEscrowRefundTxId(): string;

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

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

Returns

string

Inherited from

IEscrowSwap.getEscrowRefundTxId


getFee()

abstract getFee(): Fee;

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

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

Returns

Fee

Inherited from

IEscrowSwap.getFee


getFeeBreakdown()

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

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

Returns the breakdown of all the fees paid

Returns

FeeBreakdown<T["ChainId"]>

Inherited from

IEscrowSwap.getFeeBreakdown


getId()

getId(): string;

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

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

Returns

string

Inherited from

IEscrowSwap.getId


getInput()

abstract getInput(): TokenAmount;

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

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

Returns

TokenAmount

Inherited from

IEscrowSwap.getInput


getInputAddress()

abstract getInputAddress(): string;

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

Returns source address of the swap

Returns

string

Inherited from

IEscrowSwap.getInputAddress


getInputToken()

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

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

Returns the input token of the swap

Returns

Token<T["ChainId"]>

Inherited from

IEscrowSwap.getInputToken


getInputTxId()

abstract getInputTxId(): string;

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

Returns swap input transaction ID on the source chain

Returns

string

Inherited from

IEscrowSwap.getInputTxId


getInputWithoutFee()

abstract getInputWithoutFee(): TokenAmount;

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

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

Returns

TokenAmount

Inherited from

IEscrowSwap.getInputWithoutFee


getOutput()

abstract getOutput(): TokenAmount;

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

Returns output amount of the swap, user receives this much

Returns

TokenAmount

Inherited from

IEscrowSwap.getOutput


getOutputAddress()

abstract getOutputAddress(): string;

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

Returns destination address of the swap

Returns

string

Inherited from

IEscrowSwap.getOutputAddress


getOutputToken()

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

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

Returns the output token of the swap

Returns

Token<T["ChainId"]>

Inherited from

IEscrowSwap.getOutputToken


getOutputTxId()

abstract getOutputTxId(): string;

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

Returns swap output transaction ID on the destination chain

Returns

string

Inherited from

IEscrowSwap.getOutputTxId


getPriceInfo()

getPriceInfo(): object;

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

Returns pricing info about the swap

Returns

object

NameTypeDefined in
differencePercentagePPMatomiq-sdk/src/swaps/ISwap.ts:349
marketPrice?numberatomiq-sdk/src/swaps/ISwap.ts:347
swapPricenumberatomiq-sdk/src/swaps/ISwap.ts:348

Inherited from

IEscrowSwap.getPriceInfo


getQuoteExpiry()

getQuoteExpiry(): number;

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

Returns quote expiry in UNIX millis

Returns

number

Inherited from

IEscrowSwap.getQuoteExpiry


getSmartChainNetworkFee()

getSmartChainNetworkFee(): Promise<TokenAmount<T["ChainId"], 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<T["ChainId"], SCToken<T["ChainId"]>, true>>


getState()

getState(): S;

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

Returns the current state of the swap

Returns

S

Inherited from

IEscrowSwap.getState


getStateInfo()

getStateInfo(): SwapStateInfo<S>;

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

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

Returns

SwapStateInfo<S>

Inherited from

IEscrowSwap.getStateInfo


getType()

getType(): SwapType;

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

Returns the type of the swap

Returns

SwapType

Inherited from

IEscrowSwap.getType


hasEnoughForTxFees()

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

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

Checks if the initiator/sender has enough balance on the smart chain side to cover the transaction fee for processing the swap

Returns

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


hasValidPrice()

hasValidPrice(): boolean;

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

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

Returns

boolean

Inherited from

IEscrowSwap.hasValidPrice


isFailed()

abstract isFailed(): boolean;

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

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

Returns

boolean

Inherited from

IEscrowSwap.isFailed


isFinished()

abstract isFinished(): boolean;

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

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

Returns

boolean

Inherited from

IEscrowSwap.isFinished


isInitiated()

isInitiated(): boolean;

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

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

IEscrowSwap.isInitiated


isInProgress()

abstract isInProgress(): boolean;

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

Returns whether the swap is currently being processed

Returns

boolean

Inherited from

IEscrowSwap.isInProgress


isQuoteExpired()

abstract isQuoteExpired(): boolean;

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

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

Returns

boolean

Inherited from

IEscrowSwap.isQuoteExpired


isQuoteSoftExpired()

abstract isQuoteSoftExpired(): boolean;

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

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

IEscrowSwap.isQuoteSoftExpired


isSuccessful()

abstract isSuccessful(): boolean;

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

Returns whether the swap finished successful

Returns

boolean

Inherited from

IEscrowSwap.isSuccessful


refreshPriceData()

refreshPriceData(): Promise<void>;

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

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

Returns

Promise<void>

Inherited from

IEscrowSwap.refreshPriceData


requiresAction()

abstract requiresAction(): boolean;

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

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

Returns

boolean

Inherited from

IEscrowSwap.requiresAction


serialize()

serialize(): any;

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

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

Returns

any

Overrides

IEscrowSwap.serialize


txsCommit()

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

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

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"][]>


txsExecute()

abstract txsExecute(options?): Promise<SwapExecutionAction<T>[]>;

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

Returns a list of steps or transactions required to finish and settle the swap

Parameters

ParameterTypeDescription
options?anyAdditional options for executing the swap

Returns

Promise<SwapExecutionAction<T>[]>

Inherited from

IEscrowSwap.txsExecute


waitTillCommited()

abstract waitTillCommited(abortSignal?): Promise<void>;

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

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>