Liquorice
  • Intro
    • What is Liquorice
    • General flow
  • For market makers
    • Guide for PMMs
    • Basic Market Making API
    • Lending pools intro
      • Using lending pools via RFQ API
      • Onchain interactions with lending pools
  • For solvers
    • Guide for Solvers
    • WebSocket API
    • REST API
    • Settlement
      • Bebop JAM
      • CoW Protocol
  • For Liquidity Providers
    • Guide for LPs
  • LINKS
    • 🔗website
    • 👩‍💻github
    • 🐦twitter
    • Discord
    • Past audits
    • Smart contracts
Powered by GitBook
On this page
  • 1. Providing JamSettlement address in the RFQ
  • 2. Calling JamSettlement.settle function
  • 2.1 Solver data argument
  • 2.2. Jam Interactions argument
  • 2.3 Rest arguments
  1. For solvers
  2. Settlement

Bebop JAM

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

PreviousSettlementNextCoW Protocol

Last updated 4 months ago

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 in both trader and effectiveTrader fields of the RFQ message.

2. Calling function

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 .

Solidity example

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

  • baseToken

  • baseTokenAmount

  • tx

Reference

Approval

Quote interactions

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

Solidity example

address public constant LIQUORICE_BALANCE_MANAGER = <liquorice-balance-manager>;

struct Transaction {
  address to;
  bytes data;
}

// RFQ Quote level payload sample returned from the Liquorice API
struct LiquoriceRFQQuoteLevel {
  address baseToken;
  uint256 baseTokenAmount;
  Transaction tx;
}

function getJamInteractions(LiquoriceRFQQuoteLevel calldata quoteLevel) public returns (JamInteraction.Data[] memory interactions) {
  // Types can be found in https://github.com/bebop-dex/bebop-jam-contracts

  JamInteraction.Data[] memory interactions = new JamInteraction.Data[](2);

  // JamSettlement gives approval to LIQUORICE_BALANCE_MANAGER
  JamInteraction.Data memory approval = JamInteraction.Data(
    true,
    quoteLevel.baseToken,
    0,
    abi.encodeWithSelector(IERC20.approve.selector, LIQUORICE_BALANCE_MANAGER, quoteLevel.baseTokenAmount)
  );
  interactions[0] = approval;
  // And executes LiquoriceSettlement calldata   
  interactions[1] = 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.

When performing the trade, must have a baseToken approval given by the JamSettlement contract.

Liquorice Balance Manager contract
address of the JamSettlement smart contract
JamSettlement.settle
address of the JamSettlement contract
REST API Quote
REST API RFQ
WS API RFQ
WS API Quote