Monorail is our DeFi order routing system used internally at Gambit Labs. It specializes in finding optimal routes across thousands of DeFi contracts to get the best rates when converting tokens. This product is in beta and we are continuing to open up more parts for broader use.

Documentation

hermes_searchRoute

JSON-RPC request that returns the optimal routes between tokenIn and tokenOut for a given amountIn. The maxSteps parameter allows you to control performance by reducing the search space. Anywhere between two and four steps tend to be a good range: the former targeting speed and latter for best rates. Keep in mind the longer the path the more gas it needs to execute. paths[0].cost (response) is the cost (in wei) to execute this route on the current block. Contact us to obtain a username and password.

curl --data '{
    "method": "hermes_searchRoute",
    "params": [{
      "tokenIn": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
      "tokenOut": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      "amountsIn": ["2500000000000000000"],
      "maxSteps": 4
    }],
    "id": 1,
    "jsonrpc": "2.0"
  }' \
  --user <username>:<password> \
  -H "Content-Type: application/json" \
  -X POST "https://monorail.gmbit.co/rpc"

Response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "blockNumber": 15980247,
    "blockHash": "0xd4da0d...",
    "paths": [
      {
        "steps": [
          {
            "tokenIn": "0xc02aaa...",
            "tokenOut": "0x6b1754...",
            "node": "0x60594a...",
            "amountIn": "2500000000000000000",
            "amountOut": "3143547285207114671266"
          },
          {
            "tokenIn": "0x6b1754...",
            "tokenOut": "0x419d0d...",
            "node": "0x75bff9...",
            "amountIn": "3143547285207114671266",
            "amountOut": "46062587863686"
          },
          ...
        ],
        "gasUsed": "188000",
        "cost": "2826996"
      }
    ],
    "metrics": {
      "timing": {
        "BlockArrivedAt": 1668573456938008,
        "SearchStartedAt": 1668573462044993,
        "SearchedAt": 1668573462116241
      }
    }
  }
}