📊
Tx History API [Beta]
  • Introduction
  • Quick Start
  • Reference
    • API Reference
      • App
      • Chain
      • Fill
      • Liquidity Source
      • Transaction
  • Tips
Powered by GitBook
On this page
  1. Reference
  2. API Reference

Fill

A fill is a transfer made to a single liquidity source (AMM pool, Off-chain MM, or limit order) inside a transaction. A transaction can have one or more fills.

query Fills {
  fills(limit: 2, offset: 100, order_by: {timestamp: desc}, where: {chainName: {_eq: "Ethereum"}}) {
    affiliate
    app
    blockNumber
    chainName
    feeRecipient
    isDirect
    isRfq
    liquiditySource
    logIndex
    maker
    makerAmount
    makerToken
    makerTokenPriceUSD
    makerTokenSymbol
    makerVolumeUSD
    nativeOrderHash
    nativeOrderType
    protocolVersion
    router
    taker
    takerAmount
    takerToken
    takerTokenPriceUSD
    takerTokenSymbol
    takerVolumeUSD
    timestamp
    transactionFrom
    transactionHash
    transactionTo
    volumeUSD
  }
}
{
  "data": {
    "fills": [
      {
        "affiliate": "0x86003b044f70dac0abc80ac8957305b6370893ed",
        "app": "Matcha",
        "blockNumber": 15252717,
        "chainName": "Ethereum",
        "feeRecipient": null,
        "isDirect": false,
        "isRfq": true,
        "liquiditySource": "0x RFQ",
        "logIndex": 571,
        "maker": "0x00000000ae347930bd1e7b0f35588b92280f9e75",
        "makerAmount": 42160.2697129934,
        "makerToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
        "makerTokenPriceUSD": 1.00002725170364,
        "makerTokenSymbol": "DAI",
        "makerVolumeUSD": 42161.4186521689,
        "nativeOrderHash": "0x8c4c19cf1fffbe5faf78a3630d5a81177d106b4417612bf542461c85f04cb20e",
        "nativeOrderType": "RFQ Order",
        "protocolVersion": "v4",
        "router": "0x API",
        "taker": "0xf4160bc6c49def9bd17fb9ff194e43ddd49ada3e",
        "takerAmount": 24.7080043880914,
        "takerToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "takerTokenPriceUSD": 1722.03233503279,
        "takerTokenSymbol": "WETH",
        "takerVolumeUSD": 42547.9824904254,
        "timestamp": "2022-07-31T21:42:40+00:00",
        "transactionFrom": "0xf4160bc6c49def9bd17fb9ff194e43ddd49ada3e",
        "transactionHash": "0x1dcf34d4be336f1a7dcdb29590bd5812e0e1734a3f03e284323906fbd1a1d8b2",
        "transactionTo": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
        "volumeUSD": 42161.4186521689
      },
      {
        "affiliate": "0x86003b044f70dac0abc80ac8957305b6370893ed",
        "app": "Matcha",
        "blockNumber": 15252635,
        "chainName": "Ethereum",
        "feeRecipient": null,
        "isDirect": false,
        "isRfq": true,
        "liquiditySource": "0x RFQ",
        "logIndex": 431,
        "maker": "0x00000000ae347930bd1e7b0f35588b92280f9e75",
        "makerAmount": 17.395665,
        "makerToken": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "makerTokenPriceUSD": 1722.03233503279,
        "makerTokenSymbol": "WETH",
        "makerVolumeUSD": 29955.8976193981,
        "nativeOrderHash": "0x463d7bd4d172e5613d01c5f31ad4093734aefff340136101901ebc797b31550e",
        "nativeOrderType": "RFQ Order",
        "protocolVersion": "v4",
        "router": "0x API",
        "taker": "0x9ee6f42531adac0bd443756f0120c6aeed354115",
        "takerAmount": 30000,
        "takerToken": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "takerTokenPriceUSD": 1.0003513255839,
        "takerTokenSymbol": "USDC",
        "takerVolumeUSD": 30010.5397675169,
        "timestamp": "2022-07-31T21:22:04+00:00",
        "transactionFrom": "0x9ee6f42531adac0bd443756f0120c6aeed354115",
        "transactionHash": "0x6a04ca86762fd1fe1f5bf1c0b976d8577a127c9a58c944861bd3b30c60f0503a",
        "transactionTo": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
        "volumeUSD": 30010.5397675169
      }
    ]
  }
}
async function fetchGraphQL(operationsDoc, operationName, variables) {
  const result = await fetch(
    "https://api.0x.org/data/v0",
    {
      method: "POST",
      headers: {
        '0x-api-key': 'USE_APY_KEY_HERE'
      },
      body: JSON.stringify({
        query: operationsDoc,
        variables: variables,
        operationName: operationName
      })
    }
  );

  return await result.json();
}

const operationsDoc = `
  query Chains {
    fills(limit: 2, offset: 100, order_by: {timestamp: desc}, where: {chainName: {_eq: "Ethereum"}, app: {_eq: "Matcha"}}) {
      affiliate
      app
      blockNumber
      chainName
      feeRecipient
      isDirect
      isRfq
      liquiditySource
      logIndex
      maker
      makerAmount
      makerToken
      makerTokenPriceUSD
      makerTokenSymbol
      makerVolumeUSD
      nativeOrderHash
      nativeOrderType
      protocolVersion
      router
      taker
      takerAmount
      takerToken
      takerTokenPriceUSD
      takerTokenSymbol
      takerVolumeUSD
      timestamp
      transactionFrom
      transactionHash
      transactionTo
      volumeUSD
    }
  }
`;

function fetchChains() {
  return fetchGraphQL(
    operationsDoc,
    "Chains",
    {}
  );
}

async function startFetchChains() {
  const { errors, data } = await fetchChains();

  if (errors) {
    // handle those errors like a pro
    console.error(errors);
  }

  // do something great with this precious data
  console.log(data);
}

startFetchChains();
PreviousChainNextLiquidity Source

Last updated 2 years ago