Skip to main content

ISwapWrapper<T, D, O>

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

Base abstract class for swap handler implementations

Extended by

Type Parameters

Type ParameterDefault type
T extends ChainType-
D extends SwapTypeDefinition<T, ISwapWrapper<T, D>, ISwap<T, D>>-
O extends ISwapWrapperOptionsISwapWrapperOptions

Constructors

Constructor

new ISwapWrapper<T, D, O>(
chainIdentifier,
unifiedStorage,
unifiedChainEvents,
chain,
prices,
tokens,
options,
events?): ISwapWrapper<T, D, O>;

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

Parameters

ParameterType
chainIdentifierT["ChainId"]
unifiedStorageUnifiedSwapStorage<T>
unifiedChainEventsUnifiedSwapEventListener<T>
chainT["ChainInterface"]
pricesISwapPrice
tokensWrapperCtorTokens
optionsO
events?EventEmitter<{ swapState: [ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>]; }>

Returns

ISwapWrapper<T, D, O>

Properties

chainIdentifier

readonly chainIdentifier: T["ChainId"];

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

Chain identifier string of this wrapper


events

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

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

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


TYPE

abstract readonly TYPE: SwapType;

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

Swap type

Methods

checkPastSwaps()

checkPastSwaps(pastSwaps?, noSave?): Promise<{
changedSwaps: D["Swap"][];
removeSwaps: D["Swap"][];
}>;

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?D["Swap"][]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: D["Swap"][]; removeSwaps: D["Swap"][]; }>


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>


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>


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?D["Swap"][]Optional array of swaps to invoke _tick() on, otherwise all relevant swaps will be fetched from the persistent storage

Returns

Promise<void>