Skip to main content

Swapper<T>

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

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:287

Intermediary discovery instance


prices

readonly prices: ISwapPrice<T>;

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

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:2127

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:291

Miscellaneous utility functions

Methods

_syncSwaps()

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

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

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:1391

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:1145

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:1236

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:1281

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:1190

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:1102

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:1059

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:913

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:1012

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:963

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:861

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:1325

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:1344

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:1557

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:1561

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:1533

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:1537

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:1630

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:1634

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


getRefundableSwaps()

Call Signature

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

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

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:1598

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:2042

Returns an array of all the supported smart chains

Returns

ChainIds<T>[]


getSupportedTokens()

getSupportedTokens(input): Token[];

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

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

Parameters

ParameterTypeDescription
inputbooleanWhether 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:1668

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:1672

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:2278

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

Returns

Token[]


getSwapLimits()

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

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

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:2140
input.max?TokenAmount<string, A>atomiq-sdk/src/swapper/Swapper.ts:2140
input.minTokenAmount<string, A>atomiq-sdk/src/swapper/Swapper.ts:2140
outputobjectatomiq-sdk/src/swapper/Swapper.ts:2141
output.max?TokenAmount<string, B>atomiq-sdk/src/swapper/Swapper.ts:2141
output.minTokenAmount<string, B>atomiq-sdk/src/swapper/Swapper.ts:2141

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:2081

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()

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

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

Returns the Token object for a given token

Parameters

ParameterTypeDescription
tickerOrAddressstringToken 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

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:1726

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:639

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

Returns

Promise<void>


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:1855

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:658

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:2052

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:1447

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


wipeStorage()

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

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

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:2034

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>