> ## Documentation Index
> Fetch the complete documentation index at: https://creator-a1160a86.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# LBSwapService

The `LBSwapService` class provides methods for calculating swap amounts and fees. It is used internally by the `LiquidityBookServices` class, but can also be used as a standalone service.

## Constructor

### new LBSwapService

Creates a new instance of the `LBSwapService` class.

**Parameters**

**lbProgram** `Program\<Idl\>` *required*

The Liquidity Book program instance.

**connection** `Connection` *required*

The Solana connection object.

***

## Methods

### fromLbConfig

A static method to create a new instance of the `LBSwapService` class.

**Parameters**

**lbProgram** `Program\<Idl\>` *required*

The Liquidity Book program instance.

**connection** `Connection` *required*

The Solana connection object.

**Returns**

**Returns** `LBSwapService`

A new instance of `LBSwapService`.

### getBinArray

Retrieves the bin array for a given pair and bin array index.

**Parameters**

**params** `GetBinArrayParams` *required*

**properties**

**binArrayIndex** `number`

The index of the bin array.

**pair** `PublicKey`

The public key of the pair.

**payer** `PublicKey`

The public key of the payer.

**transaction** `Transaction`

The transaction to add the instruction to.

**Returns**

**Returns** `PublicKey`

The public key of the bin array.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.