Swapper<T>
Defined in: atomiq-sdk/src/swapper/Swapper.ts:229
Core orchestrator for all atomiq swap operations
Extends
EventEmitter<{lpsAdded: [Intermediary[]];lpsRemoved: [Intermediary[]];swapLimitsChanged: [];swapState: [ISwap]; }>
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 transactionrequiresOutputWallet: Whether a swap requires a connected wallet on the output chain able to sign arbitrary transactionssupportsGasDrop: 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
| Parameter | Type | Description |
|---|---|---|
chainId? | C | Optional chain identifier to only run swap sync for a single smart chain |
signer? | string | Optional 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
| Parameter | Type | Description |
|---|---|---|
signer | string | Smartchain (Solana, Starknet, etc.) address of the user |
srcToken | Token<C> | Source token of the swap, user pays this token |
dstToken | Token<C> | Destination token of the swap, user receives this token |
amount | bigint | Amount of the swap |
exactIn | boolean | Whether the amount specified is an input amount (exactIn=true) or an output amount (exactIn=false) |
addressLnurlLightningInvoice? | | string | LNURLPay | LNURLWithdraw | Bitcoin 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
chainIdentifier | ChainIdentifier | undefined | Chain identifier string of the destination smart chain |
recipient | string | undefined | Recipient address on the destination chain |
tokenAddress | string | undefined | Token address to receive |
amount | bigint | undefined | Amount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true) |
exactOut | boolean | false | Whether to use a exact out instead of exact in |
additionalParams | Record<string, any> | ... | Additional parameters sent to the LP when creating the swap |
options? | FromBTCLNOptions | undefined | Additional 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
chainIdentifier | ChainIdentifier | undefined | Chain identifier string of the destination smart chain |
recipient | string | undefined | Recipient address on the destination chain |
tokenAddress | string | undefined | Token address to receive |
amount | bigint | undefined | Amount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true) |
exactOut | boolean | false | Whether to use a exact out instead of exact in |
additionalParams | Record<string, any> | ... | Additional parameters sent to the LP when creating the swap |
options? | FromBTCLNAutoOptions | undefined | Additional 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
chainIdentifier | ChainIdentifier | undefined | Chain identifier string of the destination smart chain |
recipient | string | undefined | Recipient address on the destination chain |
tokenAddress | string | undefined | Token address to receive |
lnurl | string | LNURLWithdraw | undefined | LNURL-withdraw link to pull the funds from |
amount | bigint | undefined | Amount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true) |
exactOut | boolean | false | Whether to use a exact out instead of exact in |
additionalParams | Record<string, any> | ... | Additional parameters sent to the LP when creating the swap |
options? | FromBTCLNAutoOptions | undefined | Additional 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
chainIdentifier | ChainIdentifier | undefined | Chain identifier string of the destination smart chain |
recipient | string | undefined | Recipient address on the destination chain |
tokenAddress | string | undefined | Token address to receive |
lnurl | string | LNURLWithdraw | undefined | LNURL-withdraw link to pull the funds from |
amount | bigint | undefined | Amount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true) |
exactOut | boolean | false | Whether to use a exact out instead of exact in |
additionalParams | Record<string, any> | ... | Additional parameters sent to the LP when creating the swap |
options? | FromBTCLNOptions | undefined | Additional 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
chainIdentifier | ChainIdentifier | undefined | Chain identifier string of the destination smart chain |
recipient | string | undefined | Recipient address on the destination chain |
tokenAddress | string | undefined | Token address to receive |
amount | bigint | undefined | Amount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true) |
exactOut | boolean | false | Whether to use a exact out instead of exact in |
additionalParams | Record<string, any> | ... | Additional parameters sent to the LP when creating the swap |
options? | FromBTCOptions | undefined | Additional 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
chainIdentifier | ChainIdentifier | undefined | Chain identifier string of the destination smart chain |
recipient | string | undefined | Recipient address on the destination chain |
tokenAddress | string | undefined | Token address to receive |
amount | bigint | undefined | Amount to send in satoshis (if exactOut=false) or receive in token based units (if exactOut=true) |
exactOut | boolean | false | Whether to use a exact out instead of exact in |
additionalParams | Record<string, any> | ... | Additional parameters sent to the LP when creating the swap |
options? | SpvFromBTCOptions | undefined | Additional 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
| Parameter | Type | Description |
|---|---|---|
chainIdentifier | ChainIdentifier | Chain identifier string of the source smart chain |
signer | string | Signer's address on the source chain |
tokenAddress | string | Token address to pay with |
paymentRequest | string | BOLT11 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 | Additional 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
chainIdentifier | ChainIdentifier | undefined | Chain identifier string of the source smart chain |
signer | string | undefined | Signer's address on the source chain |
tokenAddress | string | undefined | Token address to pay with |
service | LightningInvoiceCreateService | undefined | Invoice create service object which facilitates the creation of fixed amount LN invoices |
amount | bigint | undefined | Amount to send in token based units (if exactIn=true) or receive in satoshis (if exactIn=false) |
exactIn | boolean | false | Whether 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? | ToBTCLNOptions | undefined | Additional 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
chainIdentifier | ChainIdentifier | undefined | Chain identifier string of the source smart chain |
signer | string | undefined | Signer's address on the source chain |
tokenAddress | string | undefined | Token address to pay with |
lnurlPay | string | LNURLPay | undefined | LNURL-pay link to use for the payment |
amount | bigint | undefined | Amount to send in token based units (if exactIn=true) or receive in satoshis (if exactIn=false) |
exactIn | boolean | false | Whether 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? | ToBTCLNOptions & object | undefined | Additional 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
| Parameter | Type | Default value | Description |
|---|---|---|---|
chainIdentifier | ChainIdentifier | undefined | Chain identifier string of the source smart chain |
signer | string | undefined | Signer's address on the source chain |
tokenAddress | string | undefined | Token address to pay with |
address | string | undefined | Recipient's bitcoin address |
amount | bigint | undefined | Amount to send in token based units (if exactIn=true) or receive in satoshis (if exactIn=false) |
exactIn | boolean | false | Whether to use exact in instead of exact out |
additionalParams | Record<string, any> | ... | Additional parameters sent to the LP when creating the swap |
options? | ToBTCOptions | undefined | Additional 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
| Parameter | Type | Description |
|---|---|---|
chainIdentifier | C | Chain identifier string of the destination smart chain |
recipient | string | Recipient address on the destination chain |
amount | bigint | Amount of native token to receive, in base units |
trustedIntermediaryOrUrl? | string | Intermediary | URL 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
| Parameter | Type | Description |
|---|---|---|
chainIdentifier | C | Chain identifier string of the destination smart chain |
recipient | string | Recipient address on the destination chain |
amount | bigint | Amount of native token to receive, in base units |
refundAddress? | string | Bitcoin refund address, in case the swap fails the funds are refunded here |
trustedIntermediaryOrUrl? | string | Intermediary | URL 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
| Parameter | Type |
|---|---|
chainId | C |
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
| Parameter | Type |
|---|---|
chainId | C |
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
| Parameter | Type |
|---|---|
chainId | C |
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
| Parameter | Type |
|---|---|
chainId | C |
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
| Parameter | Type | Description |
|---|---|---|
input | boolean | Whether 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
| Parameter | Type |
|---|---|
id | string |
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
| Parameter | Type |
|---|---|
id | string |
chainId | C |
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
| Parameter | Type |
|---|---|
token | Token |
input | boolean |
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
| Parameter | Type | Description |
|---|---|---|
srcToken | A | Source token |
dstToken | B | Destination token |
Returns
object
| Name | Type | Defined in |
|---|---|---|
input | object | atomiq-sdk/src/swapper/Swapper.ts:2140 |
input.max? | TokenAmount<string, A> | atomiq-sdk/src/swapper/Swapper.ts:2140 |
input.min | TokenAmount<string, A> | atomiq-sdk/src/swapper/Swapper.ts:2140 |
output | object | atomiq-sdk/src/swapper/Swapper.ts:2141 |
output.max? | TokenAmount<string, B> | atomiq-sdk/src/swapper/Swapper.ts:2141 |
output.min | TokenAmount<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
| Parameter | Type | Description |
|---|---|---|
srcToken | Token<C> | Source token |
dstToken | Token<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
| Parameter | Type | Description |
|---|---|---|
tickerOrAddress | string | 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 |
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
| Parameter | Type | Description |
|---|---|---|
id | string | An ID of the swap (ISwap.getId) |
chainId | C | Chain identifier of the smart chain where the swap was initiated |
swapType | S | Type of the swap |
signer? | string | An 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
| Parameter | Type | Description |
|---|---|---|
chainId | C | Smart chain identifier string to recover the swaps from |
signer | string | Signer address to recover the swaps for |
startBlockheight? | number | Optional 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
| Parameter | Type | Description |
|---|---|---|
chainId | ChainIdentifier | Smart chain identifier string |
swapType | Type | Swap 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
| Parameter | Type | Description |
|---|---|---|
srcToken | string | Token<C> | Source token of the swap, user pays this token |
dstToken | string | Token<C> | Destination token of the swap, user receives this token |
amount | string | bigint | Amount of the swap either in base units as {bigint} or in human readable format (with decimals) as {string} |
exactIn | boolean | SwapAmountType | Whether the amount specified is an input amount (exactIn=true) or an output amount (exactIn=false) |
src | string | LNURLWithdraw | Source wallet/lnurl-withdraw of the swap |
dst | | string | LNURLPay | LightningInvoiceCreateService | Destination smart chain address, bitcoin on-chain address, lightning invoice, LNURL-pay |
options? | | ToBTCOptions | SpvFromBTCOptions | FromBTCOptions | FromBTCLNOptions | FromBTCLNAutoOptions | ToBTCLNOptions & object | Options 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
| Parameter | Type | Description |
|---|---|---|
chainId? | C | Optional, to only delete swaps for this smart chain |
signer? | string | Optional, 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
| Parameter | Type | Description |
|---|---|---|
chainIdentifier | ChainIdentifier | Smart chain identifier for the created child swapper instance |
Returns
SwapperWithChain<T, ChainIdentifier>