Skip to main content

SwapperWithSigner<T, ChainIdentifier>

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:40

Chain and signer-specific wrapper for automatic signer injection into swap methods

Type Parameters​

Type Parameter
T extends MultiChain
ChainIdentifier extends ChainIds<T>

Constructors​

Constructor​

new SwapperWithSigner<T, ChainIdentifier>(swapper, signer): SwapperWithSigner<T, ChainIdentifier>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:87

Parameters​

ParameterType
swapperSwapperWithChain<T, ChainIdentifier>
signerT[ChainIdentifier]["Signer"]

Returns​

SwapperWithSigner<T, ChainIdentifier>

Properties​

chainIdentifier​

readonly chainIdentifier: ChainIdentifier;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:51

Smart chain identifier of this swapper with chain and signer

Accessors​

intermediaryDiscovery​

Get Signature​

get intermediaryDiscovery(): IntermediaryDiscovery;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:62

Intermediary discovery instance

Returns​

IntermediaryDiscovery


prices​

Get Signature​

get prices(): SwapPriceWithChain<T, ChainIdentifier>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:56

Pricing API used by the SDK

Returns​

SwapPriceWithChain<T, ChainIdentifier>


SwapTypeInfo​

Get Signature​

get SwapTypeInfo(): Record<SwapType, {
requiresInputWallet: boolean;
requiresOutputWallet: boolean;
supportsGasDrop: boolean;
}>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:83

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.

Returns​

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


Utils​

Get Signature​

get Utils(): SwapperUtils<T>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:68

Miscellaneous utility functions

Returns​

SwapperUtils<T>

Methods​

_syncSwaps()​

_syncSwaps(): Promise<void>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:412

Synchronizes swaps from chain, this is usually ran when SDK is initialized, deletes expired quotes

Returns​

Promise<void>


create()​

create(
srcToken,
dstToken,
amount,
exactIn,
addressLnurlLightningInvoice): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:353

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.

Parameters​

ParameterTypeDescription
srcTokenSCToken<ChainIdentifier>Source token of the swap, user pays this token
dstTokenBtcToken<true>Destination token of the swap, user receives this token
amountundefinedAmount of the swap
exactInfalseWhether the amount specified is an input amount (exactIn=true) or an output amount (exactIn=false)
addressLnurlLightningInvoicestringBitcoin on-chain address, lightning invoice, LNURL-pay to pay or LNURL-withdrawal to withdraw money from

Returns​

Promise<ToBTCLNSwap<T[ChainIdentifier]>>


createFromBTCLNSwap()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:227

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

Parameters​

ParameterTypeDescription
tokenAddressstringToken address to receive
amountbigintAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOut?booleanWhether to use a exact out instead of exact in
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap
options?FromBTCLNOptionsAdditional options for the swap

Returns​

Promise<SwapWithSigner<FromBTCLNSwap<T[ChainIdentifier]>>>


createFromBTCLNSwapNew()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:268

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

Parameters​

ParameterTypeDescription
tokenAddressstringToken address to receive
amountbigintAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOut?booleanWhether to use a exact out instead of exact in
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap
options?FromBTCLNAutoOptionsAdditional options for the swap

Returns​

Promise<SwapWithSigner<FromBTCLNAutoSwap<T[ChainIdentifier]>>>


createFromBTCLNSwapNewViaLNURL()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:290

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

Parameters​

ParameterTypeDescription
tokenAddressstringToken address to receive
lnurlstring | LNURLWithdrawLNURL-withdraw link to pull the funds from
amountbigintAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOut?booleanWhether to use a exact out instead of exact in
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap
options?FromBTCLNAutoOptionsAdditional options for the swap

Returns​

Promise<SwapWithSigner<FromBTCLNAutoSwap<T[ChainIdentifier]>>>


createFromBTCLNSwapViaLNURL()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:248

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

Parameters​

ParameterTypeDescription
tokenAddressstringToken address to receive
lnurlstring | LNURLWithdrawLNURL-withdraw link to pull the funds from
amountbigintAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOut?booleanWhether to use a exact out instead of exact in
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap

Returns​

Promise<SwapWithSigner<FromBTCLNSwap<T[ChainIdentifier]>>>


createFromBTCSwap()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:207

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

Parameters​

ParameterTypeDescription
tokenAddressstringToken address to receive
amountbigintAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOut?booleanWhether to use a exact out instead of exact in
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap
options?FromBTCOptionsAdditional options for the swap

Returns​

Promise<SwapWithSigner<FromBTCSwap<T[ChainIdentifier]>>>


createFromBTCSwapNew()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:187

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

Parameters​

ParameterTypeDescription
tokenAddressstringToken address to receive
amountbigintAmount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true)
exactOut?booleanWhether to use a exact out instead of exact in
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap
options?SpvFromBTCOptionsAdditional options for the swap

Returns​

Promise<SwapWithSigner<SpvFromBTCSwap<T[ChainIdentifier]>>>


createToBTCLNSwap()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:124

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

Parameters​

ParameterTypeDescription
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
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap
options?ToBTCLNOptions & objectAdditional options for the swap

Returns​

Promise<SwapWithSigner<ToBTCLNSwap<T[ChainIdentifier]>>>


createToBTCLNSwapViaInvoiceCreateService()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:166

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

Parameters​

ParameterTypeDescription
tokenAddressstringToken address to pay with
serviceLightningInvoiceCreateServiceInvoice create service object which facilitates the creation of fixed amount LN invoices
amountbigintAmount to send in token based units (if exactIn=true) or receive in satoshis (if exactIn=false)
exactIn?booleanWhether to do an exact in swap instead of exact out
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap
options?ToBTCLNOptionsAdditional options for the swap

Returns​

Promise<SwapWithSigner<ToBTCLNSwap<T[ChainIdentifier]>>>


createToBTCLNSwapViaLNURL()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:144

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

Parameters​

ParameterTypeDescription
tokenAddressstringToken address to pay with
lnurlPaystring | LNURLPayLNURL-pay link to use for the payment
amountbigintAmount to send in token based units (if exactIn=true) or receive in satoshis (if exactIn=false)
exactIn?booleanWhether to do an exact in swap instead of exact out
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap
options?ToBTCLNOptionsAdditional options for the swap

Returns​

Promise<SwapWithSigner<ToBTCLNSwap<T[ChainIdentifier]>>>


createToBTCSwap()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:103

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

Parameters​

ParameterTypeDescription
tokenAddressstringToken address to pay with
addressstringRecipient's bitcoin address
amountbigintAmount to send in token based units (if exactIn=true) or receive in satoshis (if exactIn=false)
exactIn?booleanWhether to use exact in instead of exact out
additionalParams?Record<string, any>Additional parameters sent to the LP when creating the swap
options?ToBTCOptionsAdditional options for the swap

Returns​

Promise<SwapWithSigner<ToBTCSwap<T[ChainIdentifier]>>>


createTrustedLNForGasSwap()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:309

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

Parameters​

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

Throws​

If no trusted intermediary specified


createTrustedOnchainForGasSwap()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:321

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

Parameters​

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

Throws​

If no trusted intermediary specified


getActionableSwaps()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:381

Returns swaps that are in-progress and are claimable for the specific chain, optionally also for a specific signer's address

Returns​

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


getAllSwaps()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:374

Returns swaps that are in-progress and are claimable for the specific chain, optionally also for a specific signer's address

Returns​

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


getRefundableSwaps()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:388

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

Returns​

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


getSwapById()​

getSwapById(id): Promise<ISwap<T[ChainIdentifier], SwapTypeDefinition<T[ChainIdentifier], ISwapWrapper<T[ChainIdentifier], any, ISwapWrapperOptions>, ISwap<T[ChainIdentifier], any, any>>, number>>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:395

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

Parameters​

ParameterType
idstring

Returns​

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


getSwapCounterTokens()​

getSwapCounterTokens(token, input): Token<ChainIdentifier>[];

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:507

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


getSwapLimits()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:496

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

Type Parameters​

Type Parameter
A extends Token<ChainIdentifier>
B extends Token<ChainIdentifier>

Parameters​

ParameterTypeDescription
srcTokenASource token
dstTokenBDestination token

Returns​

object

NameTypeDefined in
inputobjectatomiq-sdk/src/swapper/SwapperWithSigner.ts:497
input.max?TokenAmount<A>atomiq-sdk/src/swapper/SwapperWithSigner.ts:497
input.minTokenAmount<A>atomiq-sdk/src/swapper/SwapperWithSigner.ts:497
outputobjectatomiq-sdk/src/swapper/SwapperWithSigner.ts:498
output.max?TokenAmount<B>atomiq-sdk/src/swapper/SwapperWithSigner.ts:498
output.minTokenAmount<B>atomiq-sdk/src/swapper/SwapperWithSigner.ts:498

getSwapType()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:479

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

Parameters​

ParameterTypeDescription
srcTokenToken<ChainIdentifier>Source token
dstTokenToken<ChainIdentifier>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/SwapperWithSigner.ts:430

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

BtcToken<false>

Call Signature​

getToken(ticker): BtcToken<true>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:431

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

BtcToken<true>

Call Signature​

getToken(ticker): SCToken<ChainIdentifier>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:432

Parameters​
ParameterType
ticker`${ChainIdentifier}-${string}`
Returns​

SCToken<ChainIdentifier>

Call Signature​

getToken(tickerOrAddress): Token<ChainIdentifier>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:433

Parameters​
ParameterType
tickerOrAddressstring
Returns​

Token<ChainIdentifier>


getTypedSwapById()​

getTypedSwapById<S>(id, swapType): Promise<SwapTypeMapping<T[ChainIdentifier]>[S]>;

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:405

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

Type Parameters​

Type Parameter
S extends SwapType

Parameters​

ParameterTypeDescription
idstringAn ID of the swap (ISwap.getId)
swapTypeSType of the swap

Returns​

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


recoverSwaps()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:426

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.

Parameters​

ParameterTypeDescription
startBlockheight?numberOptional starting blockheight for swap data recovery, will only check swaps initiated after this blockheight

Returns​

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


supportsSwapType()​

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

Defined in: atomiq-sdk/src/swapper/SwapperWithSigner.ts:451

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

Type Parameters​

Type Parameter
Type extends SwapType

Parameters​

ParameterTypeDescription
swapTypeTypeSwap protocol type

Returns​

SupportsSwapType<T[ChainIdentifier], Type>