Skip to main content

Swapper<T>

Defined in: atomiq-sdk/src/swapper/Swapper.ts:271

Core orchestrator for all atomiq swap operations

Extends

Type Parameters

Type Parameter
T extends MultiChain

Properties

intermediaryDiscovery

readonly intermediaryDiscovery: IntermediaryDiscovery;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:333

Intermediary discovery instance


lpApi

readonly lpApi: IntermediaryAPI;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:329

API for contacting LPs


prices

readonly prices: ISwapPrice<T>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:325

Pricing API used by the SDK


SwapTypeInfo

readonly SwapTypeInfo: Record<SwapType, {
requiresInputWallet: boolean;
requiresOutputWallet: boolean;
supportsGasDrop: boolean;
}>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2379

Helper information about various swap protocol and their features:

  • requiresInputWallet: Whether a swap requires a connected wallet on the input chain able to sign arbitrary transaction
  • requiresOutputWallet: Whether a swap requires a connected wallet on the output chain able to sign arbitrary transactions
  • supportsGasDrop: Whether a swap supports the "gas drop" feature, allowing to user to receive a small amount of native token as part of the swap when swapping to smart chains

Uses a Record type here, use the SwapProtocolInfo import for a literal readonly type, with pre-filled exact values in the type.


Utils

readonly Utils: SwapperUtils<T>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:337

Miscellaneous utility functions

Methods

_pollChainEvents()

_pollChainEvents<C>(chainId, lastEventCursorState?): Promise<any>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2039

When the swapper is initiated with the noEvents config this function allows you to manually poll for on-chain events. It returns an events cursor which you should save and pass to the next call to the poll() function.

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdCChain for which to poll the chain events listener for
lastEventCursorState?anyEvent cursor state returned from the last call to the poll() function

Returns

Promise<any>


_syncSwaps()

_syncSwaps<C>(chainId?, signer?): Promise<void>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2022

Synchronizes swaps from on-chain, this is ran automatically when SDK is initialized, hence should only be ran manually when dontCheckPastSwaps=true is passed in the swapper options, also deletes expired quotes

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainId?COptional chain identifier to only run swap sync for a single smart chain
signer?stringOptional signer to only run swap sync for swaps initiated by this signer

Returns

Promise<void>


create()

create<C>(
signer,
srcToken,
dstToken,
amount,
exactIn,
addressLnurlLightningInvoice?): Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1494

Creates a swap from srcToken to dstToken, of a specific token amount, either specifying input amount (exactIn=true) or output amount (exactIn=false), NOTE: For regular -> BTC-LN (lightning) swaps the passed amount is ignored and invoice's pre-set amount is used instead.

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
signerstringSmartchain (Solana, Starknet, etc.) address of the user
srcTokenToken<C>Source token of the swap, user pays this token
dstTokenToken<C>Destination token of the swap, user receives this token
amountbigintAmount of the swap
exactInbooleanWhether the amount specified is an input amount (exactIn=true) or an output amount (exactIn=false)
addressLnurlLightningInvoice?| string | LNURLPay | LNURLWithdrawBitcoin on-chain address, lightning invoice, LNURL-pay to pay or LNURL-withdrawal to withdraw money from

Returns

Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>>

Deprecated

Use swap instead


createFromBTCLNSwap()

createFromBTCLNSwap<ChainIdentifier>(
chainIdentifier,
recipient,
tokenAddress,
amount,
exactOut,
additionalParams,
options?): Promise<FromBTCLNSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1242

Creates LEGACY Bitcoin Lightning -> Smart chain (SwapType.FROM_BTCLN) swap

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDefault valueDescription
chainIdentifierChainIdentifierundefinedChain identifier string of the destination smart chain
recipientstringundefinedRecipient address on the destination chain
tokenAddressstringundefinedToken address to receive
amountbigintundefinedAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOutbooleanfalseWhether to use a exact out instead of exact in
additionalParamsRecord<string, any>...Additional parameters sent to the LP when creating the swap
options?FromBTCLNOptionsundefinedAdditional options for the swap

Returns

Promise<FromBTCLNSwap<T[ChainIdentifier]>>


createFromBTCLNSwapNew()

createFromBTCLNSwapNew<ChainIdentifier>(
chainIdentifier,
recipient,
tokenAddress,
amount,
exactOut,
additionalParams,
options?): Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1333

Creates Bitcoin Lightning -> Smart chain (SwapType.FROM_BTCLN_AUTO) swap

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDefault valueDescription
chainIdentifierChainIdentifierundefinedChain identifier string of the destination smart chain
recipientstringundefinedRecipient address on the destination chain
tokenAddressstringundefinedToken address to receive
amountbigintundefinedAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOutbooleanfalseWhether to use a exact out instead of exact in
additionalParamsRecord<string, any>...Additional parameters sent to the LP when creating the swap
options?FromBTCLNAutoOptionsundefinedAdditional options for the swap

Returns

Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>>


createFromBTCLNSwapNewViaLNURL()

createFromBTCLNSwapNewViaLNURL<ChainIdentifier>(
chainIdentifier,
recipient,
tokenAddress,
lnurl,
amount,
exactOut,
additionalParams,
options?): Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1379

Creates Bitcoin Lightning -> Smart chain (SwapType.FROM_BTCLN_AUTO) swap, withdrawing from an LNURL-withdraw link

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDefault valueDescription
chainIdentifierChainIdentifierundefinedChain identifier string of the destination smart chain
recipientstringundefinedRecipient address on the destination chain
tokenAddressstringundefinedToken address to receive
lnurlstring | LNURLWithdrawundefinedLNURL-withdraw link to pull the funds from
amountbigintundefinedAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOutbooleanfalseWhether to use a exact out instead of exact in
additionalParamsRecord<string, any>...Additional parameters sent to the LP when creating the swap
options?FromBTCLNAutoOptionsundefinedAdditional options for the swap

Returns

Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>>


createFromBTCLNSwapViaLNURL()

createFromBTCLNSwapViaLNURL<ChainIdentifier>(
chainIdentifier,
recipient,
tokenAddress,
lnurl,
amount,
exactOut,
additionalParams,
options?): Promise<FromBTCLNSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1287

Creates LEGACY Bitcoin Lightning -> Smart chain (SwapType.FROM_BTCLN) swap, withdrawing from an LNURL-withdraw link

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDefault valueDescription
chainIdentifierChainIdentifierundefinedChain identifier string of the destination smart chain
recipientstringundefinedRecipient address on the destination chain
tokenAddressstringundefinedToken address to receive
lnurlstring | LNURLWithdrawundefinedLNURL-withdraw link to pull the funds from
amountbigintundefinedAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOutbooleanfalseWhether to use a exact out instead of exact in
additionalParamsRecord<string, any>...Additional parameters sent to the LP when creating the swap
options?FromBTCLNOptionsundefinedAdditional options for the swap

Returns

Promise<FromBTCLNSwap<T[ChainIdentifier]>>


createFromBTCSwap()

createFromBTCSwap<ChainIdentifier>(
chainIdentifier,
recipient,
tokenAddress,
amount,
exactOut,
additionalParams,
options?): Promise<FromBTCSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1199

Creates LEGACY Bitcoin -> Smart chain (SwapType.FROM_BTC) swap

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDefault valueDescription
chainIdentifierChainIdentifierundefinedChain identifier string of the destination smart chain
recipientstringundefinedRecipient address on the destination chain
tokenAddressstringundefinedToken address to receive
amountbigintundefinedAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOutbooleanfalseWhether to use a exact out instead of exact in
additionalParamsRecord<string, any>...Additional parameters sent to the LP when creating the swap
options?FromBTCOptionsundefinedAdditional options for the swap

Returns

Promise<FromBTCSwap<T[ChainIdentifier]>>


createFromBTCSwapNew()

createFromBTCSwapNew<ChainIdentifier>(
chainIdentifier,
recipient,
tokenAddress,
amount,
exactOut,
additionalParams,
options?): Promise<SpvFromBTCSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1155

Creates Bitcoin -> Smart chain (SwapType.SPV_VAULT_FROM_BTC) swap

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDefault valueDescription
chainIdentifierChainIdentifierundefinedChain identifier string of the destination smart chain
recipientstringundefinedRecipient address on the destination chain
tokenAddressstringundefinedToken address to receive
amountbigintundefinedAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOutbooleanfalseWhether to use a exact out instead of exact in
additionalParamsRecord<string, any>...Additional parameters sent to the LP when creating the swap
options?SpvFromBTCOptionsundefinedAdditional options for the swap

Returns

Promise<SpvFromBTCSwap<T[ChainIdentifier]>>


createToBTCLNSwap()

createToBTCLNSwap<ChainIdentifier>(
chainIdentifier,
signer,
tokenAddress,
paymentRequest,
additionalParams,
options?): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1015

Creates Smart chain -> Bitcoin Lightning (SwapType.TO_BTCLN) swap

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDescription
chainIdentifierChainIdentifierChain identifier string of the source smart chain
signerstringSigner's address on the source chain
tokenAddressstringToken address to pay with
paymentRequeststringBOLT11 lightning network invoice to be paid (needs to have a fixed amount), and the swap amount is taken from this fixed amount, hence only exact output swaps are supported
additionalParamsRecord<string, any>Additional parameters sent to the LP when creating the swap
options?ToBTCLNOptionsAdditional options for the swap

Returns

Promise<ToBTCLNSwap<T[ChainIdentifier]>>


createToBTCLNSwapViaInvoiceCreateService()

createToBTCLNSwapViaInvoiceCreateService<ChainIdentifier>(
chainIdentifier,
signer,
tokenAddress,
service,
amount,
exactIn,
additionalParams,
options?): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1110

Creates Smart chain -> Bitcoin Lightning (SwapType.TO_BTCLN) swap via LightningInvoiceCreateService

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDefault valueDescription
chainIdentifierChainIdentifierundefinedChain identifier string of the source smart chain
signerstringundefinedSigner's address on the source chain
tokenAddressstringundefinedToken address to pay with
serviceLightningInvoiceCreateServiceundefinedInvoice create service object which facilitates the creation of fixed amount LN invoices
amountbigintundefinedAmount to send in token based units (if exactIn=true) or receive in satoshis (if exactIn=false)
exactInbooleanfalseWhether to do an exact in swap instead of exact out
additionalParamsRecord<string, any>...Additional parameters sent to the LP when creating the swap
options?ToBTCLNOptionsundefinedAdditional options for the swap

Returns

Promise<ToBTCLNSwap<T[ChainIdentifier]>>


createToBTCLNSwapViaLNURL()

createToBTCLNSwapViaLNURL<ChainIdentifier>(
chainIdentifier,
signer,
tokenAddress,
lnurlPay,
amount,
exactIn,
additionalParams,
options?): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1063

Creates Smart chain -> Bitcoin Lightning (SwapType.TO_BTCLN) swap via LNURL-pay link

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDefault valueDescription
chainIdentifierChainIdentifierundefinedChain identifier string of the source smart chain
signerstringundefinedSigner's address on the source chain
tokenAddressstringundefinedToken address to pay with
lnurlPaystring | LNURLPayundefinedLNURL-pay link to use for the payment
amountbigintundefinedAmount to send in token based units (if exactIn=true) or receive in satoshis (if exactIn=false)
exactInbooleanfalseWhether to do an exact in swap instead of exact out
additionalParamsRecord<string, any>...Additional parameters sent to the LP when creating the swap
options?ToBTCLNOptions & objectundefinedAdditional options for the swap

Returns

Promise<ToBTCLNSwap<T[ChainIdentifier]>>


createToBTCSwap()

createToBTCSwap<ChainIdentifier>(
chainIdentifier,
signer,
tokenAddress,
address,
amount,
exactIn,
additionalParams,
options?): Promise<ToBTCSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:966

Creates Smart chain -> Bitcoin (SwapType.TO_BTC) swap

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDefault valueDescription
chainIdentifierChainIdentifierundefinedChain identifier string of the source smart chain
signerstringundefinedSigner's address on the source chain
tokenAddressstringundefinedToken address to pay with
addressstringundefinedRecipient's bitcoin address
amountbigintundefinedAmount to send in token based units (if exactIn=true) or receive in satoshis (if exactIn=false)
exactInbooleanfalseWhether to use exact in instead of exact out
additionalParamsRecord<string, any>...Additional parameters sent to the LP when creating the swap
options?ToBTCOptionsundefinedAdditional options for the swap

Returns

Promise<ToBTCSwap<T[ChainIdentifier]>>


createTrustedLNForGasSwap()

createTrustedLNForGasSwap<C>(
chainIdentifier,
recipient,
amount,
trustedIntermediaryOrUrl?): Promise<LnForGasSwap<T[C]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1424

Creates a trusted Bitcoin Lightning -> Smart chain (SwapType.TRUSTED_FROM_BTCLN) gas swap

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier string of the destination smart chain
recipientstringRecipient address on the destination chain
amountbigintAmount of native token to receive, in base units
trustedIntermediaryOrUrl?string | IntermediaryURL or Intermediary object of the trusted intermediary to use, otherwise uses default

Returns

Promise<LnForGasSwap<T[C]>>

Throws

If no trusted intermediary specified


createTrustedOnchainForGasSwap()

createTrustedOnchainForGasSwap<C>(
chainIdentifier,
recipient,
amount,
refundAddress?,
trustedIntermediaryOrUrl?): Promise<OnchainForGasSwap<T[C]>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1445

Creates a trusted Bitcoin -> Smart chain (SwapType.TRUSTED_FROM_BTC) gas swap

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier string of the destination smart chain
recipientstringRecipient address on the destination chain
amountbigintAmount of native token to receive, in base units
refundAddress?stringBitcoin refund address, in case the swap fails the funds are refunded here
trustedIntermediaryOrUrl?string | IntermediaryURL or Intermediary object of the trusted intermediary to use, otherwise uses default

Returns

Promise<OnchainForGasSwap<T[C]>>

Throws

If no trusted intermediary specified


getActionableSwaps()

Call Signature

getActionableSwaps(): Promise<ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1767

Returns all swaps where an action is required (either claim or refund)

Returns

Promise<ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>[]>

Call Signature

getActionableSwaps<C>(chainId, signer?): Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1771

Returns swaps where an action is required (either claim or refund) for the specific chain, and optionally also for a specific signer's address

Type Parameters
Type Parameter
C extends string
Parameters
ParameterType
chainIdC
signer?string
Returns

Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>[]>


getAllSwaps()

Call Signature

getAllSwaps(): Promise<ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1706

Returns all swaps

Returns

Promise<ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>[]>

Call Signature

getAllSwaps<C>(chainId, signer?): Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1710

Returns all swaps for the specific chain, and optionally also for a specific signer's address

Type Parameters
Type Parameter
C extends string
Parameters
ParameterType
chainIdC
signer?string
Returns

Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>[]>


getClaimableSwaps()

Call Signature

getClaimableSwaps(): Promise<IClaimableSwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, IClaimableSwap<ChainType, any, any>>, number>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1819

Returns all swaps that are manually claimable

Returns

Promise<IClaimableSwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, IClaimableSwap<ChainType, any, any>>, number>[]>

Call Signature

getClaimableSwaps<C>(chainId, signer?): Promise<IClaimableSwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, IClaimableSwap<T[C], any, any>>, number>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1823

Returns all swaps that are manually claimable for the specific chain, and optionally also for a specific signer's address

Type Parameters
Type Parameter
C extends string
Parameters
ParameterType
chainIdC
signer?string
Returns

Promise<IClaimableSwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, IClaimableSwap<T[C], any, any>>, number>[]>


getPendingSwaps()

Call Signature

getPendingSwaps(): Promise<ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1730

Returns all swaps which are pending (i.e. not in their final state yet)

Returns

Promise<ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>[]>

Call Signature

getPendingSwaps<C>(chainId, signer?): Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1734

Returns swaps which are pending (i.e. not in their final state yet) for the specific chain, and optionally also for a specific signer's address

Type Parameters
Type Parameter
C extends string
Parameters
ParameterType
chainIdC
signer?string
Returns

Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>[]>


getRefundableSwaps()

Call Signature

getRefundableSwaps(): Promise<IToBTCSwap<ChainType, IToBTCDefinition<ChainType, IToBTCWrapper<ChainType, any, ISwapWrapperOptions>, IToBTCSwap<ChainType, any>>>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1783

Returns all swaps that are refundable

Returns

Promise<IToBTCSwap<ChainType, IToBTCDefinition<ChainType, IToBTCWrapper<ChainType, any, ISwapWrapperOptions>, IToBTCSwap<ChainType, any>>>[]>

Call Signature

getRefundableSwaps<C>(chainId, signer?): Promise<IToBTCSwap<T[C], IToBTCDefinition<T[C], IToBTCWrapper<T[C], any, ISwapWrapperOptions>, IToBTCSwap<T[C], any>>>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1787

Returns swaps which are refundable for the specific chain, and optionally also for a specific signer's address

Type Parameters
Type Parameter
C extends string
Parameters
ParameterType
chainIdC
signer?string
Returns

Promise<IToBTCSwap<T[C], IToBTCDefinition<T[C], IToBTCWrapper<T[C], any, ISwapWrapperOptions>, IToBTCSwap<T[C], any>>>[]>


getSmartChains()

getSmartChains(): ChainIds<T>[];

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2294

Returns an array of all the supported smart chains

Returns

ChainIds<T>[]


getSupportedTokens()

getSupportedTokens(input): Token[];

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2427

Returns an array of supported tokens either on the input or on the output of a swap

Parameters

ParameterTypeDescription
inputboolean | SwapSideWhether to return input tokens or output tokens

Returns

Token[]


getSwapById()

Call Signature

getSwapById(id): Promise<ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1857

Returns swap with a specific id (identifier)

Parameters
ParameterType
idstring
Returns

Promise<ISwap<ChainType, SwapTypeDefinition<ChainType, ISwapWrapper<ChainType, any, ISwapWrapperOptions>, ISwap<ChainType, any, any>>, number>>

Call Signature

getSwapById<C>(
id,
chainId,
signer?): Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1861

Returns swap with a specific id (identifier) on a specific chain and optionally with a signer

Type Parameters
Type Parameter
C extends string
Parameters
ParameterType
idstring
chainIdC
signer?string
Returns

Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>>


getSwapCounterTokens()

getSwapCounterTokens(token, input): Token[];

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2530

Returns tokens that you can swap to (if input=true) from a given token, or tokens that you can swap from (if input=false) to a given token

Parameters

ParameterType
tokenToken
inputboolean | SwapSide

Returns

Token[]


getSwapLimits()

getSwapLimits<C, A, B>(srcToken, dstToken): object;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2391

Returns minimum/maximum limits for inputs and outputs for a swap between given tokens

Type Parameters

Type Parameter
C extends string
A extends Token<C>
B extends Token<C>

Parameters

ParameterTypeDescription
srcTokenASource token
dstTokenBDestination token

Returns

object

NameTypeDefined in
inputobjectatomiq-sdk/src/swapper/Swapper.ts:2392
input.max?TokenAmount<A>atomiq-sdk/src/swapper/Swapper.ts:2392
input.minTokenAmount<A>atomiq-sdk/src/swapper/Swapper.ts:2392
outputobjectatomiq-sdk/src/swapper/Swapper.ts:2393
output.max?TokenAmount<B>atomiq-sdk/src/swapper/Swapper.ts:2393
output.minTokenAmount<B>atomiq-sdk/src/swapper/Swapper.ts:2393

getSwapType()

getSwapType<C>(srcToken, dstToken):
| FROM_BTC
| FROM_BTCLN
| TO_BTC
| TO_BTCLN
| SPV_VAULT_FROM_BTC
| FROM_BTCLN_AUTO;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2333

Returns type of the swap based on input and output tokens specified

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
srcTokenToken<C>Source token
dstTokenToken<C>Destination token

Returns

| FROM_BTC | FROM_BTCLN | TO_BTC | TO_BTCLN | SPV_VAULT_FROM_BTC | FROM_BTCLN_AUTO


getToken()

Returns the Token object for a given token

Param

Token to return the object for, can use multiple formats:

  • a) token ticker, such as "BTC", "SOL", etc.
  • b) token ticker prefixed with smart chain identifier, such as "SOLANA-SOL", "SOLANA-USDC", etc.
  • c) token address

Call Signature

getToken(ticker): BtcToken<false>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2236

Parameters
ParameterType
ticker"BTC" | "BITCOIN-BTC"
Returns

BtcToken<false>

Call Signature

getToken(ticker): BtcToken<true>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2237

Parameters
ParameterType
ticker"BTCLN" | "BTC-LN" | "LIGHTNING-BTC"
Returns

BtcToken<true>

Call Signature

getToken<ChainIdentifier>(ticker): SCToken<ChainIdentifier>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2238

Type Parameters
Type Parameter
ChainIdentifier extends string
Parameters
ParameterType
ticker`${ChainIdentifier}-${string}`
Returns

SCToken<ChainIdentifier>

Call Signature

getToken(tickerOrAddress): Token<ChainIds<T>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2239

Parameters
ParameterType
tickerOrAddressstring
Returns

Token<ChainIds<T>>


getTypedSwapById()

getTypedSwapById<C, S>(
id,
chainId,
swapType,
signer?): Promise<SwapTypeMapping<T[C]>[S]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1915

Returns the swap with a proper return type, or undefined if not found or has wrong type

Type Parameters

Type Parameter
C extends string
S extends SwapType

Parameters

ParameterTypeDescription
idstringAn ID of the swap (ISwap.getId)
chainIdCChain identifier of the smart chain where the swap was initiated
swapTypeSType of the swap
signer?stringAn optional required smart chain signer address to fetch the swap for

Returns

Promise<SwapTypeMapping<T[C]>[S]>


init()

init(): Promise<void>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:735

Initializes the swap storage and loads existing swaps, needs to be called before any other action

Returns

Promise<void>


isInitialized()

isInitialized(): boolean;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:757

Whether the SDK is initialized (after init is called)

Returns

boolean


recoverSwaps()

recoverSwaps<C>(
chainId,
signer,
startBlockheight?): Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>[]>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2058

Recovers swaps from on-chain historical data.

Please note that the recovered swaps might not be complete (i.e. missing amounts or addresses), as some of the swap data is purely off-chain and can never be recovered purely from on-chain data. This functions tries to recover as much swap data as possible.

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdCSmart chain identifier string to recover the swaps from
signerstringSigner address to recover the swaps for
startBlockheight?numberOptional starting blockheight for swap data recovery, will only check swaps initiated after this blockheight

Returns

Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>[]>


stop()

stop(): Promise<void>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:764

Stops listening for onchain events and closes this Swapper instance

Returns

Promise<void>


supportsSwapType()

supportsSwapType<ChainIdentifier, Type>(chainId, swapType): SupportsSwapType<T[ChainIdentifier], Type>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2304

Returns whether the SDK supports a given swap type on a given chain based on currently known LPs

Type Parameters

Type Parameter
ChainIdentifier extends string
Type extends SwapType

Parameters

ParameterTypeDescription
chainIdChainIdentifierSmart chain identifier string
swapTypeTypeSwap protocol type

Returns

SupportsSwapType<T[ChainIdentifier], Type>


swap()

swap<C>(
srcToken,
dstToken,
amount,
exactIn,
src,
dst,
options?): Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1550

Creates a swap from srcToken to dstToken, of a specific token amount, either specifying input amount (if exactIn=true) or output amount (if exactIn=false), NOTE: For regular Smart chain -> BTC-LN (lightning) swaps the passed amount is ignored and invoice's pre-set amount is used instead, use LNURL-pay links for dynamic amounts

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
srcTokenstring | Token<C>Source token of the swap, user pays this token
dstTokenstring | Token<C>Destination token of the swap, user receives this token
amountstring | bigintAmount of the swap either in base units as {bigint} or in human readable format (with decimals) as {string}
exactInboolean | SwapAmountTypeWhether the amount specified is an input amount (exactIn=true) or an output amount (exactIn=false)
srcstring | LNURLWithdrawSource wallet/lnurl-withdraw of the swap
dst| string | LNURLPay | LightningInvoiceCreateServiceDestination smart chain address, bitcoin on-chain address, lightning invoice, LNURL-pay
options?| ToBTCOptions | SpvFromBTCOptions | FromBTCOptions | FromBTCLNOptions | FromBTCLNAutoOptions | ToBTCLNOptions & objectOptions for the swap

Returns

Promise<ISwap<T[C], SwapTypeDefinition<T[C], ISwapWrapper<T[C], any, ISwapWrapperOptions>, ISwap<T[C], any, any>>, number>>


sweepBitcoinWallet()

sweepBitcoinWallet<C>(
srcWallet,
_dstToken,
dstAddress,
options?): Promise<{
btcFeeRate: number;
swap: SpvFromBTCSwap<T[C]>;
utxos: BitcoinWalletUtxo[];
}>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1669

A helper function to sweep all the funds from a given wallet in a single swap, after getting the quote you can execute the swap by passing the returned feeRate and utxos to the SpvFromBTCSwap.execute, SpvFromBTCSwap.getFundedPsbt or SpvFromBTCSwap.sendBitcoinTransaction functions along with spendFully=true.

Type Parameters

Type Parameter
C extends string

Parameters

ParameterType
srcWallet| IBitcoinWallet | MinimalBitcoinWalletInterface
_dstTokenstring | SCToken<C>
dstAddressstring
options?SpvFromBTCOptions

Returns

Promise<{ btcFeeRate: number; swap: SpvFromBTCSwap<T[C]>; utxos: BitcoinWalletUtxo[]; }>

Example

Create the swap first using this function

const {swap, utxos, btcFeeRate} = await swapper.sweepBitcoinWallet(wallet, Tokens.CITREA.CBTC, dstAddress);

Then execute it using one of these execution paths - ensure that you supply the returned utxos, btcFeeRate params and also set spendFully to true!

a) Execute and pass the returned utxos and btcFeeRate:

await swap.execute(wallet, undefined, {feeRate: btcFeeRate, utxos: utxos, spendFully: true});

b) Get funded PSBT to sign externally:

const {psbt, psbtHex, psbtBase64, signInputs} = await swap.getFundedPsbt(wallet, btcFeeRate, undefined, utxos, true);
// Sign the psbt at the specified signInputs indices
const signedPsbt = ...;
// Then submit back to the SDK
await swap.submitPsbt(signedPsbt);

c) Only sign and send the signed PSBT with the provided wallet:

await swap.sendBitcoinTransaction(wallet, btcFeeRate, utxos, true);

wipeStorage()

wipeStorage<C>(chainId?, signer?): Promise<void>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:1990

Deletes the swaps from the persistent storage backend. Note that some data (like lightning network amounts and bolt11 invoices) are purely off-chain and can never be recovered later just from on-chain data!

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainId?COptional, to only delete swaps for this smart chain
signer?stringOptional, to only delete swaps for this smart chain signer (chainId param must be set to delete only signer's swaps)

Returns

Promise<void>


withChain()

withChain<ChainIdentifier>(chainIdentifier): SwapperWithChain<T, ChainIdentifier>;

Defined in: atomiq-sdk/src/swapper/Swapper.ts:2286

Creates a child swapper instance with a given smart chain

Type Parameters

Type Parameter
ChainIdentifier extends string

Parameters

ParameterTypeDescription
chainIdentifierChainIdentifierSmart chain identifier for the created child swapper instance

Returns

SwapperWithChain<T, ChainIdentifier>