SwapPriceWithChain<T, ChainIdentifier>
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:12
Chain-specific wrapper for swap pricing
Type Parameters
| Type Parameter |
|---|
T extends MultiChain |
ChainIdentifier extends ChainIds<T> |
Constructors
Constructor
new SwapPriceWithChain<T, ChainIdentifier>(swapPrice, chainIdentifier): SwapPriceWithChain<T, ChainIdentifier>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:18
Parameters
| Parameter | Type |
|---|---|
swapPrice | ISwapPrice<T> |
chainIdentifier | ChainIdentifier |
Returns
SwapPriceWithChain<T, ChainIdentifier>
Properties
chainIdentifier
chainIdentifier: ChainIdentifier;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:15
maxAllowedFeeDifferencePPM
maxAllowedFeeDifferencePPM: bigint;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:16
swapPrice
swapPrice: ISwapPrice<T>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:14
Methods
getBtcUsdValue()
getBtcUsdValue(
btcSats,
abortSignal?,
preFetchedUsdPrice?): Promise<number>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:152
Returns the USD value of the bitcoin amount
Parameters
| Parameter | Type | Description |
|---|---|---|
btcSats | bigint | Bitcoin amount in satoshis |
abortSignal? | AbortSignal | |
preFetchedUsdPrice? | number | An optional price pre-fetched with preFetchUsdPrice |
Returns
Promise<number>
getFromBtcSwapAmount()
getFromBtcSwapAmount(
fromAmount,
toToken,
abortSignal?,
preFetchedPrice?): Promise<bigint>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:104
Returns amount of toToken that is equivalent to fromAmount satoshis
Parameters
| Parameter | Type | Description |
|---|---|---|
fromAmount | bigint | Amount of satoshis |
toToken | string | Token address |
abortSignal? | AbortSignal | |
preFetchedPrice? | bigint | An optional price pre-fetched with preFetchPrice |
Returns
Promise<bigint>
Throws
when token is not found
getToBtcSwapAmount()
getToBtcSwapAmount(
fromAmount,
fromToken,
abortSignal?,
preFetchedPrice?): Promise<bigint>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:124
Returns amount of satoshis that are equivalent to fromAmount of fromToken
Parameters
| Parameter | Type | Description |
|---|---|---|
fromAmount | bigint | Amount of the token |
fromToken | string | Token address |
abortSignal? | AbortSignal | |
preFetchedPrice? | bigint | An optional price pre-fetched with preFetchPrice |
Returns
Promise<bigint>
Throws
when token is not found
getTokenUsdValue()
getTokenUsdValue(
tokenAmount,
tokenAddress,
abortSignal?,
preFetchedUsdPrice?): Promise<number>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:168
Returns the USD value of the smart chain token amount
Parameters
| Parameter | Type | Description |
|---|---|---|
tokenAmount | bigint | Amount of the token in base units |
tokenAddress | string | Token address |
abortSignal? | AbortSignal | |
preFetchedUsdPrice? | number | An optional price pre-fetched with preFetchUsdPrice |
Returns
Promise<number>
getUsdValue()
getUsdValue(
amount,
token,
abortSignal?,
preFetchedUsdPrice?): Promise<number>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:185
Returns the USD value of the token amount
Parameters
| Parameter | Type | Description |
|---|---|---|
amount | bigint | Amount in base units of the token |
token | Token<ChainIdentifier> | Token to fetch the usd price for |
abortSignal? | AbortSignal | |
preFetchedUsdPrice? | number | An optional price pre-fetched with preFetchUsdPrice |
Returns
Promise<number>
isValidAmountReceive()
isValidAmountReceive(
amountSats,
satsBaseFee,
feePPM,
receiveToken,
tokenAddress,
abortSignal?,
preFetchedPrice?): Promise<PriceInfoType>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:60
Checks whether the swap amounts are valid given the current market rate for a given pair
Parameters
| Parameter | Type | Description |
|---|---|---|
amountSats | bigint | Amount of sats (BTC) to be paid to the swap |
satsBaseFee | bigint | Base fee in sats (BTC) as reported by the intermediary |
feePPM | bigint | PPM fee rate as reported by the intermediary |
receiveToken | bigint | Amount of token to be received from the swap |
tokenAddress | string | Token address to be received |
abortSignal? | AbortSignal | Abort signal |
preFetchedPrice? | bigint | An optional price pre-fetched with preFetchPrice |
Returns
Promise<PriceInfoType>
isValidAmountSend()
isValidAmountSend(
amountSats,
satsBaseFee,
feePPM,
paidToken,
tokenAddress,
abortSignal?,
preFetchedPrice?): Promise<PriceInfoType>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:35
Checks whether the swap amounts are valid given the current market rate for a given pair
Parameters
| Parameter | Type | Description |
|---|---|---|
amountSats | bigint | Amount of sats (BTC) to be received from the swap |
satsBaseFee | bigint | Base fee in sats (BTC) as reported by the intermediary |
feePPM | bigint | PPM fee rate as reported by the intermediary |
paidToken | bigint | Amount of token to be paid to the swap |
tokenAddress | string | Token address to be paid |
abortSignal? | AbortSignal | Abort signal |
preFetchedPrice? | bigint | An optional price pre-fetched with preFetchPrice |
Returns
Promise<PriceInfoType>
preFetchPrice()
preFetchPrice(tokenAddress, abortSignal?): Promise<bigint>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:81
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
Parameters
| Parameter | Type | Description |
|---|---|---|
tokenAddress | string | Token address |
abortSignal? | AbortSignal | Abort signal |
Returns
Promise<bigint>
preFetchUsdPrice()
preFetchUsdPrice(abortSignal?): Promise<number>;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:91
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
| Parameter | Type | Description |
|---|---|---|
abortSignal? | AbortSignal |
Returns
Promise<number>
shouldIgnore()
shouldIgnore(tokenAddress): boolean;
Defined in: atomiq-sdk/src/prices/SwapPriceWithChain.ts:141
Returns whether the token should be ignored and pricing for it not calculated
Parameters
| Parameter | Type | Description |
|---|---|---|
tokenAddress | string | Token address |
Returns
boolean
Throws
if token is not found