> For the complete documentation index, see [llms.txt](https://liquorice.gitbook.io/liquorice-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liquorice.gitbook.io/liquorice-docs/for-solvers/settlement/bebop-jam.md).

# Bebop JAM

The following guide explains how to use Liquorice together with Bebop JAM API

### 1. Providing JamSettlement address in the RFQ

From the perspective of Liquorice, trade is performed with the JamSettlement contract, not directly with the trader.

Therefore, a solver must first and foremost provide the [address of the JamSettlement smart contract ](https://docs.bebop.xyz/bebop/smart-contracts/jam-smart-contracts)in both `trader` and `effectiveTrader` fields of the RFQ message.&#x20;

* [REST API RFQ](https://liquorice.gitbook.io/liquorice-docs/for-solvers/settlement/pages/DZxOUYGmZTU7wNZBpgld#id-2.-rfq)
* [WS API RFQ](https://liquorice.gitbook.io/liquorice-docs/for-solvers/settlement/pages/8KNzbv9BjnFq0k00IvQ4#id-2.-sending-rfq)

### 2. Calling [JamSettlement.settle](https://github.com/bebop-dex/bebop-jam-contracts/blob/master/src/JamSettlement.sol#L46) function&#x20;

### 2.1 Solver data argument

During the settlement process, funds from the trader must first be transferred to the JamSettlement contract.

For this reason, `balanceRecipient` of the `ExecInfo.SolverData` has to be set to the [address of the JamSettlement contract](https://docs.bebop.xyz/bebop/smart-contracts/jam-smart-contracts).

#### Solidity example

```solidity
ExecInfo.SolverData memory solverData = ExecInfo.SolverData(<jam-settlement>, 10_000);
```

### 2.2. Jam Interactions argument

To assemble Jam Interactions, solver would need to use following fields from the Quote payload&#x20;

* `baseToken`
* `baseTokenAmount`
* `tx`

*Reference*

* [REST API Quote](/liquorice-docs/for-solvers/rest-api.md#response)
* [WS API Quote](https://liquorice.gitbook.io/liquorice-docs/for-solvers/settlement/pages/8KNzbv9BjnFq0k00IvQ4#id-3.-receiving-quote)

#### Approval

When performing the trade, [Liquorice Balance Manager contract](/liquorice-docs/links/smart-contracts.md) must have a `baseToken` approval given by the JamSettlement contract.

#### Quote interactions

The rest of the interactions must be assembled from the `interactions` and `market` fields.

#### Solidity example

```solidity
struct Transaction {
  address to;
  bytes data;
}

struct Allowance {
  address token;
  address spender;
  uint256 amount;
}

struct LiquoriceRFQQuoteLevel {
  address baseToken;
  uint256 baseTokenAmount;
  Transaction tx;
  Allowance[] allowances;
}

function getJamInteractions(LiquoriceRFQQuoteLevel calldata quoteLevel) public pure returns (JamInteraction.Data[] memory interactions) {
  uint256 allowancesLength = quoteLevel.allowances.length;
  interactions = new JamInteraction.Data[](allowancesLength + 1);

  for (uint256 i = 0; i < allowancesLength; i++) {
    interactions[i] = JamInteraction.Data(
      true,
      quoteLevel.allowances[i].token,
      0,
      abi.encodeWithSelector(IERC20.approve.selector, quoteLevel.allowances[i].spender, quoteLevel.allowances[i].amount)
    );
  }

  interactions[allowancesLength] = JamInteraction.Data(true, quoteLevel.tx.to, 0, quoteLevel.tx.data);

  return interactions;
}
```

### 2.3 Rest arguments

Remaining arguments such as `hooks`, `signature` and `order` provided as is.
