# SwapPriceWithChain\<T, ChainIdentifier>

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:12](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L12)

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](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L18)

#### Parameters

| Parameter         | Type                                                                                                     |
| ----------------- | -------------------------------------------------------------------------------------------------------- |
| `swapPrice`       | [`ISwapPrice`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/classes/ISwapPrice.md)<`T`> |
| `chainIdentifier` | `ChainIdentifier`                                                                                        |

#### Returns

`SwapPriceWithChain`<`T`, `ChainIdentifier`>

## Properties

### chainIdentifier

```
chainIdentifier: ChainIdentifier;
```

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:15](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L15)

***

### maxAllowedFeeDifferencePPM

```
maxAllowedFeeDifferencePPM: bigint;
```

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:16](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L16)

***

### swapPrice

```
swapPrice: ISwapPrice<T>;
```

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:14](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L14)

## Methods

### getBtcUsdValue()

```
getBtcUsdValue(

   btcSats, 

   abortSignal?, 

preFetchedUsdPrice?): Promise<number>;
```

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:152](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L152)

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](#prefetchusdprice) |

#### Returns

`Promise`<`number`>

***

### getFromBtcSwapAmount()

```
getFromBtcSwapAmount(

   fromAmount, 

   toToken, 

   abortSignal?, 

preFetchedPrice?): Promise<bigint>;
```

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:104](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L104)

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](#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](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L124)

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](#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](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L168)

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](#prefetchusdprice) |

#### Returns

`Promise`<`number`>

***

### getUsdValue()

```
getUsdValue(

   amount, 

   token, 

   abortSignal?, 

preFetchedUsdPrice?): Promise<number>;
```

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:185](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L185)

Returns the USD value of the token amount

#### Parameters

| Parameter             | Type                                                                                                              | Description                                                              |
| --------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `amount`              | `bigint`                                                                                                          | Amount in base units of the token                                        |
| `token`               | [`Token`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/Token.md)<`ChainIdentifier`> | Token to fetch the usd price for                                         |
| `abortSignal?`        | `AbortSignal`                                                                                                     |                                                                          |
| `preFetchedUsdPrice?` | `number`                                                                                                          | An optional price pre-fetched with [preFetchUsdPrice](#prefetchusdprice) |

#### Returns

`Promise`<`number`>

***

### isValidAmountReceive()

```
isValidAmountReceive(

   amountSats, 

   satsBaseFee, 

   feePPM, 

   receiveToken, 

   tokenAddress, 

   abortSignal?, 

preFetchedPrice?): Promise<PriceInfoType>;
```

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:60](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L60)

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](#prefetchprice) |

#### Returns

`Promise`<`PriceInfoType`>

***

### isValidAmountSend()

```
isValidAmountSend(

   amountSats, 

   satsBaseFee, 

   feePPM, 

   paidToken, 

   tokenAddress, 

   abortSignal?, 

preFetchedPrice?): Promise<PriceInfoType>;
```

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:35](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L35)

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](#prefetchprice) |

#### Returns

`Promise`<`PriceInfoType`>

***

### preFetchPrice()

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

Defined in: [atomiq-sdk/src/prices/SwapPriceWithChain.ts:81](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L81)

Pre-fetches the pricing data for a given token, such that further calls to [isValidAmountReceive](#isvalidamountreceive) or [isValidAmountSend](#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](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L91)

Pre-fetches the Bitcoin USD price data, such that further calls to [getBtcUsdValue](#getbtcusdvalue), [getTokenUsdValue](#gettokenusdvalue) or [getUsdValue](#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](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/SwapPriceWithChain.ts#L141)

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
