Skip to main content

SwapperWithSigner<T, ChainIdentifier>

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

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

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

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

Intermediary discovery instance

Returns

IntermediaryDiscovery


prices

Get Signature

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

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

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

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

Miscellaneous utility functions

Returns

SwapperUtils<T>

Methods

_syncSwaps()

_syncSwaps(): Promise<void>;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


getSwapLimits()

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

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

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

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

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

getToken(tickerOrAddress): Token<ChainIdentifier>;

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

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


getTypedSwapById()

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

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

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

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

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>