# ISwapPrice\<T>

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:10](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L10)

Abstract base class for swap pricing implementations

## Type Parameters

| Type Parameter             | Default type |
| -------------------------- | ------------ |
| `T` *extends* `MultiChain` | `MultiChain` |

## Constructors

### Constructor

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

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

#### Parameters

| Parameter                    | Type     |
| ---------------------------- | -------- |
| `maxAllowedFeeDifferencePPM` | `bigint` |

#### Returns

`ISwapPrice`<`T`>

## Properties

### maxAllowedFeeDifferencePPM

```
maxAllowedFeeDifferencePPM: bigint;
```

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

## Methods

### getBtcUsdValue()

```
getBtcUsdValue(

   btcSats, 

   abortSignal?, 

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:338](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L338)

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

   chainIdentifier, 

   fromAmount, 

   toToken, 

   abortSignal?, 

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:274](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L274)

Returns amount of `toToken` that is equivalent to `fromAmount` satoshis

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter          | Type          | Description                                                        |
| ------------------ | ------------- | ------------------------------------------------------------------ |
| `chainIdentifier`  | `C`           | Chain identifier string for the smart chain                        |
| `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<C>(

   chainIdentifier, 

   fromAmount, 

   fromToken, 

   abortSignal?, 

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:301](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L301)

Returns amount of satoshis that are equivalent to `fromAmount` of `fromToken`

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter          | Type          | Description                                                        |
| ------------------ | ------------- | ------------------------------------------------------------------ |
| `chainIdentifier`  | `C`           | Chain identifier string for the smart chain                        |
| `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<C>(

   chainIdentifier, 

   tokenAmount, 

   tokenAddress, 

   abortSignal?, 

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:355](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L355)

Returns the USD value of the smart chain token amount

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter             | Type          | Description                                                              |
| --------------------- | ------------- | ------------------------------------------------------------------------ |
| `chainIdentifier`     | `C`           | Chain identifier string for the smart chain                              |
| `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<C>(

   amount, 

   token, 

   abortSignal?, 

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:377](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L377)

Returns the USD value of the token amount

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### 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)<`C`> | Token to fetch the usd price for                                         |
| `abortSignal?`        | `AbortSignal`                                                                                       |                                                                          |
| `preFetchedUsdPrice?` | `number`                                                                                            | An optional price pre-fetched with [preFetchUsdPrice](#prefetchusdprice) |

#### Returns

`Promise`<`number`>

***

### isValidAmountReceive()

```
isValidAmountReceive<C>(

   chainIdentifier, 

   amountSats, 

   satsBaseFee, 

   feePPM, 

   receiveToken, 

   tokenAddress, 

   abortSignal?, 

   preFetchedPrice?, 

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:195](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L195)

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

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter          | Type          | Description                                                        |
| ------------------ | ------------- | ------------------------------------------------------------------ |
| `chainIdentifier`  | `C`           | Chain identifier of the smart chain                                |
| `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` |                                                                    |
| `preFetchedPrice?` | `bigint`      | An optional price pre-fetched with [preFetchPrice](#prefetchprice) |
| `realSwapFeeSats?` | `bigint`      |                                                                    |

#### Returns

`Promise`<`PriceInfoType`>

***

### isValidAmountSend()

```
isValidAmountSend<C>(

   chainIdentifier, 

   amountSats, 

   satsBaseFee, 

   feePPM, 

   paidToken, 

   tokenAddress, 

   abortSignal?, 

   preFetchedPrice?, 

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:105](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L105)

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

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter          | Type          | Description                                                        |
| ------------------ | ------------- | ------------------------------------------------------------------ |
| `chainIdentifier`  | `C`           | Chain identifier of the smart chain                                |
| `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` |                                                                    |
| `preFetchedPrice?` | `bigint`      | An optional price pre-fetched with [preFetchPrice](#prefetchprice) |
| `realSwapFeeSats?` | `bigint`      |                                                                    |

#### Returns

`Promise`<`PriceInfoType`>

***

### preFetchPrice()

```
preFetchPrice<C>(

   chainIdentifier, 

   tokenAddress, 

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:250](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L250)

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

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter         | Type          | Description                         |
| ----------------- | ------------- | ----------------------------------- |
| `chainIdentifier` | `C`           | Chain identifier of the smart chain |
| `tokenAddress`    | `string`      | Token address                       |
| `abortSignal?`    | `AbortSignal` |                                     |

#### Returns

`Promise`<`bigint`>

***

### preFetchUsdPrice()

```
preFetchUsdPrice(abortSignal?): Promise<number>;
```

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:260](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L260)

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

***

### recomputePriceInfoReceive()

```
recomputePriceInfoReceive<C>(

   chainIdentifier, 

   amountSats, 

   satsBaseFee, 

   feePPM, 

   receiveToken, 

   tokenAddress): PriceInfoType;
```

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:159](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L159)

Recomputes pricing info without fetching the current price

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter         | Type     | Description                                            |
| ----------------- | -------- | ------------------------------------------------------ |
| `chainIdentifier` | `C`      | Chain identifier of the smart chain                    |
| `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                           |

#### Returns

`PriceInfoType`

***

### recomputePriceInfoSend()

```
recomputePriceInfoSend<C>(

   chainIdentifier, 

   amountSats, 

   satsBaseFee, 

   feePPM, 

   paidToken, 

   tokenAddress): PriceInfoType;
```

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:69](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L69)

Recomputes pricing info without fetching the current price

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter         | Type     | Description                                            |
| ----------------- | -------- | ------------------------------------------------------ |
| `chainIdentifier` | `C`      | Chain identifier of the smart chain                    |
| `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                               |

#### Returns

`PriceInfoType`

***

### shouldIgnore()

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:325](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L325)

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

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter         | Type     | Description                                 |
| ----------------- | -------- | ------------------------------------------- |
| `chainIdentifier` | `C`      | Chain identifier string for the smart chain |
| `tokenAddress`    | `string` | Token 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](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L25)

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

| Parameter         | Type     | Description                         |
| ----------------- | -------- | ----------------------------------- |
| `chainIdentifier` | `C`      | Chain identifier of the smart chain |
| `tokenAddress`    | `string` | Token address                       |

#### Returns

`number`

***

### getDecimalsThrowing()

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:53](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L53)

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

| Parameter         | Type     | Description                         |
| ----------------- | -------- | ----------------------------------- |
| `chainIdentifier` | `C`      | Chain identifier of the smart chain |
| `tokenAddress`    | `string` | Token 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](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L35)

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

#### Type Parameters

| Type Parameter         |
| ---------------------- |
| `C` *extends* `string` |

#### Parameters

| Parameter         | Type          | Description                         |
| ----------------- | ------------- | ----------------------------------- |
| `chainIdentifier` | `C`           | Chain identifier of the smart chain |
| `tokenAddress`    | `string`      | Token address                       |
| `abortSignal?`    | `AbortSignal` |                                     |

#### Returns

`Promise`<`bigint`>

***

### getUsdPrice()

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

Defined in: [atomiq-sdk/src/prices/abstract/ISwapPrice.ts:43](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/prices/abstract/ISwapPrice.ts#L43)

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

#### Parameters

| Parameter      | Type          | Description |
| -------------- | ------------- | ----------- |
| `abortSignal?` | `AbortSignal` |             |

#### Returns

`Promise`<`number`>
