Bundle Format

A FastLane bundle consists of two transactions:

  1. The opportunity-creating transaction.

  2. The searcher’s own transaction, which calls the submitFlashBid function on the FastLane Auction Handler contract.

The transactions must be presented in that specific order and there must be exactly two transactions in the bundle. The transactions must be hexadecimal encoded (see Relay JSON-RPC API for more information)

Example:

// Check next doc page of `submitFlashBid` 
// for ethers implementation instead

const Web3 = require('web3');

var web3 = new Web3("https://matic-mainnet.infura.io/v3/some_random_hash_provider"); 

const PRIVATE_KEY = "0xsomePrivateKey";

  const oppTxHash = "0xb1fe7a7b31de3d4c703725898fd190672791fb6dd4a48496ac7efa563ef6eec9";
  const oppTxSigned = "0xf82392...29302932"; // Yours to gather from hash.

const functionCall = {
    "inputs": [
      {
        "internalType": "uint256",
        "name": "_bidAmount",
        "type": "uint256"
      },
      {
        "internalType": "bytes32",
        "name": "_oppTxHash",
        "type": "bytes32"
      },
      {
        "internalType": "address",
        "name": "_searcherToAddress",
        "type": "address"
      },
      {
        "internalType": "bytes",
        "name": "_searcherCallData",
        "type": "bytes"
      }
    ],
    "name": "submitFlashBid",
    "outputs": [],
    "stateMutability": "payable",
    "type": "function"
  };

  const bidAmount = 100000;
  const searcherContract = "0xeA26974363EC1dBc132C99cF9A29273B17254aE3";

  // Assuming we intend to use _searcherCallDataBytes
  // when received on our searcher contract `fastLaneCall(` callback
  // to then trigger searcherContract.myMethod(uint256,string);
  
  // See: Searcher Call Data section of the docs for more informations
  const searcherCallDataBytes = web3.eth.abi.encodeFunctionCall({
    name: 'myMethod',
    type: 'function',
    inputs: [{
        type: 'uint256',
        name: 'myNumber'
    },{
        type: 'string',
        name: 'myString'
    }]
}, ['2345675643', 'Hello!%']);

  const dataField = web3.eth.abi.encodeFunctionCall(functionCall, [
    bidAmount,
    oppTxHash,
    searcherContract,
    searcherCallDataBytes
  ])

// Gas must match
const transaction = {
    'to': '0xf5df545113dee4df10f8149090aa737ddc05070a', // Auction Handler Beta
    'value': 1000000000000000000, // 1 ETH
    'gas': 1337, // Yours to handle, must match oppTx gas
    'gasLimit': 1337
    'nonce': 12,
    'data': dataField
   };

async function main() {
    const signedTx = await web3.eth.accounts.signTransaction(transaction, PRIVATE_KEY);
    console.log(signedTx.rawTransaction); // 0xf901b20c8502e155e78c8275309431b98d14007bdee637298086988a0bbd...1baddd8f2f8f940fc5d387832a1
    const bundle = [
        oppTxSigned
        signedTx.rawTransaction,
    ]
   return bundle;
}
main();

More details in

submitFlashBid

Full Example

Last updated