Skip to main content

OnchainForGasWrapper<T>

Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasWrapper.ts:27

Trusted swap for Bitcoin -> Smart chains, to be used for minor amounts to get gas tokens on the destination chain, which is only needed for Solana, which still uses legacy swaps

Extends

  • ISwapWrapper<T, OnchainForGasSwapTypeDefinition<T>, OnchainForGasWrapperOptions>

Type Parameters

Type Parameter
T extends ChainType

Constructors

Constructor

new OnchainForGasWrapper<T>(
chainIdentifier,
unifiedStorage,
unifiedChainEvents,
chain,
prices,
tokens,
btcRpc,
options,
events?): OnchainForGasWrapper<T>;

Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasWrapper.ts:63

Parameters

ParameterTypeDescription
chainIdentifierstring
unifiedStorageUnifiedSwapStorage<T>Storage interface for the current environment
unifiedChainEventsUnifiedSwapEventListener<T>On-chain event listener
chainT["ChainInterface"]
pricesISwapPricePricing to use
tokensWrapperCtorTokens
btcRpcBitcoinRpcWithAddressIndex<any>Bitcoin RPC which also supports getting transactions by txoHash
optionsOnchainForGasWrapperOptions
events?EventEmitter<{ swapState: [ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>]; }>Instance to use for emitting events

Returns

OnchainForGasWrapper<T>

Overrides

ISwapWrapper.constructor

Properties

chainIdentifier

readonly chainIdentifier: T["ChainId"];

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

Chain identifier string of this wrapper

Inherited from

ISwapWrapper.chainIdentifier


events

readonly events: EventEmitter<{
swapState: [OnchainForGasSwap<T>];
}>;

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

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

Inherited from

ISwapWrapper.events


TYPE

readonly TYPE: TRUSTED_FROM_BTC = SwapType.TRUSTED_FROM_BTC;

Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasWrapper.ts:28

Swap type

Overrides

ISwapWrapper.TYPE

Methods

checkPastSwaps()

checkPastSwaps(pastSwaps?, noSave?): Promise<{
changedSwaps: OnchainForGasSwap<T>[];
removeSwaps: OnchainForGasSwap<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

ParameterTypeDescription
pastSwaps?OnchainForGasSwap<T>[]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: OnchainForGasSwap<T>[]; removeSwaps: OnchainForGasSwap<T>[]; }>

Inherited from

ISwapWrapper.checkPastSwaps


create()

create(
recipient,
amount,
lpOrUrl,
refundAddress?): Promise<OnchainForGasSwap<T>>;

Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasWrapper.ts:87

Returns a newly created trusted Bitcoin on-chain -> Smart chain swap, receiving the specified amount of native token on the destination chain.

Parameters

ParameterTypeDescription
recipientstringAddress of the recipient on the smart chain destination chain
amountbigintAmount of native token to receive in base units
lpOrUrlstring | IntermediaryIntermediary (LP) to use for the swap
refundAddress?stringBitcoin address to receive refund on in case the intermediary (LP) cannot execute the swap

Returns

Promise<OnchainForGasSwap<T>>


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>

Inherited from

ISwapWrapper.init


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

ISwapWrapper.stop


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

Returns

Promise<void>

Inherited from

ISwapWrapper.tick