Skip to main content

ISwapPrice<T>

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:10

Abstract base class for swap pricing implementations

Type Parameters

Type ParameterDefault type
T extends MultiChainMultiChain

Constructors

Constructor

protected new ISwapPrice<T>(maxAllowedFeeDifferencePPM): ISwapPrice<T>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:14

Parameters

ParameterType
maxAllowedFeeDifferencePPMbigint

Returns

ISwapPrice<T>

Properties

maxAllowedFeeDifferencePPM

maxAllowedFeeDifferencePPM: bigint;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:12

Methods

getBtcUsdValue()

getBtcUsdValue(
btcSats,
abortSignal?,
preFetchedUsdPrice?): Promise<number>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:325

Returns the USD value of the bitcoin amount

Parameters

ParameterTypeDescription
btcSatsbigintBitcoin amount in satoshis
abortSignal?AbortSignal
preFetchedUsdPrice?numberAn optional price pre-fetched with preFetchUsdPrice

Returns

Promise<number>


getFromBtcSwapAmount()

getFromBtcSwapAmount<C>(
chainIdentifier,
fromAmount,
toToken,
abortSignal?,
preFetchedPrice?): Promise<bigint>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:261

Returns amount of toToken that is equivalent to fromAmount satoshis

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier string for the smart chain
fromAmountbigintAmount of satoshis
toTokenstringToken address
abortSignal?AbortSignal
preFetchedPrice?bigintAn optional price pre-fetched with preFetchPrice

Returns

Promise<bigint>

Throws

when token is not found


getToBtcSwapAmount()

getToBtcSwapAmount<C>(
chainIdentifier,
fromAmount,
fromToken,
abortSignal?,
preFetchedPrice?): Promise<bigint>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:288

Returns amount of satoshis that are equivalent to fromAmount of fromToken

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier string for the smart chain
fromAmountbigintAmount of the token
fromTokenstringToken address
abortSignal?AbortSignal
preFetchedPrice?bigintAn optional price pre-fetched with preFetchPrice

Returns

Promise<bigint>

Throws

when token is not found


getTokenUsdValue()

getTokenUsdValue<C>(
chainIdentifier,
tokenAmount,
tokenAddress,
abortSignal?,
preFetchedUsdPrice?): Promise<number>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:342

Returns the USD value of the smart chain token amount

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier string for the smart chain
tokenAmountbigintAmount of the token in base units
tokenAddressstringToken address
abortSignal?AbortSignal
preFetchedUsdPrice?numberAn optional price pre-fetched with preFetchUsdPrice

Returns

Promise<number>


getUsdValue()

getUsdValue<C>(
amount,
token,
abortSignal?,
preFetchedUsdPrice?): Promise<number>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:364

Returns the USD value of the token amount

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
amountbigintAmount in base units of the token
tokenToken<C>Token to fetch the usd price for
abortSignal?AbortSignal
preFetchedUsdPrice?numberAn optional price pre-fetched with preFetchUsdPrice

Returns

Promise<number>


isValidAmountReceive()

isValidAmountReceive<C>(
chainIdentifier,
amountSats,
satsBaseFee,
feePPM,
receiveToken,
tokenAddress,
abortSignal?,
preFetchedPrice?): Promise<PriceInfoType>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:189

Checks whether the swap amounts are valid given the current market rate for a given pair

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier of the smart chain
amountSatsbigintAmount of sats (BTC) to be paid to the swap
satsBaseFeebigintBase fee in sats (BTC) as reported by the intermediary
feePPMbigintPPM fee rate as reported by the intermediary
receiveTokenbigintAmount of token to be received from the swap
tokenAddressstringToken address to be received
abortSignal?AbortSignal
preFetchedPrice?bigintAn optional price pre-fetched with preFetchPrice

Returns

Promise<PriceInfoType>


isValidAmountSend()

isValidAmountSend<C>(
chainIdentifier,
amountSats,
satsBaseFee,
feePPM,
paidToken,
tokenAddress,
abortSignal?,
preFetchedPrice?): Promise<PriceInfoType>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:104

Checks whether the swap amounts are valid given the current market rate for a given pair

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier of the smart chain
amountSatsbigintAmount of sats (BTC) to be received from the swap
satsBaseFeebigintBase fee in sats (BTC) as reported by the intermediary
feePPMbigintPPM fee rate as reported by the intermediary
paidTokenbigintAmount of token to be paid to the swap
tokenAddressstringToken address to be paid
abortSignal?AbortSignal
preFetchedPrice?bigintAn optional price pre-fetched with preFetchPrice

Returns

Promise<PriceInfoType>


preFetchPrice()

preFetchPrice<C>(
chainIdentifier,
tokenAddress,
abortSignal?): Promise<bigint>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:237

Pre-fetches the pricing data for a given token, such that further calls to isValidAmountReceive or isValidAmountSend are quicker and don't need to wait for the price fetch

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier of the smart chain
tokenAddressstringToken address
abortSignal?AbortSignal

Returns

Promise<bigint>


preFetchUsdPrice()

preFetchUsdPrice(abortSignal?): Promise<number>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:247

Pre-fetches the Bitcoin USD price data, such that further calls to getBtcUsdValue, getTokenUsdValue or getUsdValue are quicker and don't need to wait for the price fetch

Parameters

ParameterTypeDescription
abortSignal?AbortSignal

Returns

Promise<number>


recomputePriceInfoReceive()

recomputePriceInfoReceive<C>(
chainIdentifier,
amountSats,
satsBaseFee,
feePPM,
receiveToken,
tokenAddress): PriceInfoType;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:154

Recomputes pricing info without fetching the current price

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier of the smart chain
amountSatsbigintAmount of sats (BTC) to be paid to the swap
satsBaseFeebigintBase fee in sats (BTC) as reported by the intermediary
feePPMbigintPPM fee rate as reported by the intermediary
receiveTokenbigintAmount of token to be received from the swap
tokenAddressstringToken address to be received

Returns

PriceInfoType


recomputePriceInfoSend()

recomputePriceInfoSend<C>(
chainIdentifier,
amountSats,
satsBaseFee,
feePPM,
paidToken,
tokenAddress): PriceInfoType;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:69

Recomputes pricing info without fetching the current price

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier of the smart chain
amountSatsbigintAmount of sats (BTC) to be received from the swap
satsBaseFeebigintBase fee in sats (BTC) as reported by the intermediary
feePPMbigintPPM fee rate as reported by the intermediary
paidTokenbigintAmount of token to be paid to the swap
tokenAddressstringToken address to be paid

Returns

PriceInfoType


shouldIgnore()

shouldIgnore<C>(chainIdentifier, tokenAddress): boolean;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:312

Returns whether the token should be ignored and pricing for it not calculated

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier string for the smart chain
tokenAddressstringToken address

Returns

boolean

Throws

if token is not found


getDecimals()

abstract protected getDecimals<C>(chainIdentifier, tokenAddress): number;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:25

Gets the decimal places for a given token, returns -1 if token should be ignored & null if token is not found

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier of the smart chain
tokenAddressstringToken address

Returns

number


getDecimalsThrowing()

protected getDecimalsThrowing<C>(chainIdentifier, tokenAddress): number;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:53

Gets the decimal places for a given token, returns -1 if token should be ignored & throws if token is not found

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier of the smart chain
tokenAddressstringToken address

Returns

number

Throws

When token is not known


getPrice()

abstract protected getPrice<C>(
chainIdentifier,
tokenAddress,
abortSignal?): Promise<bigint>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:35

Returns the price of the token in BTC uSats (microSats)

Type Parameters

Type Parameter
C extends string

Parameters

ParameterTypeDescription
chainIdentifierCChain identifier of the smart chain
tokenAddressstringToken address
abortSignal?AbortSignal

Returns

Promise<bigint>


getUsdPrice()

abstract protected getUsdPrice(abortSignal?): Promise<number>;

Defined in: atomiq-sdk/src/prices/abstract/ISwapPrice.ts:43

Returns the price of bitcoin in USD (sats/USD)

Parameters

ParameterTypeDescription
abortSignal?AbortSignal

Returns

Promise<number>