> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cow.bleu.builders/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Flash loan infrastructure for CoW Protocol solvers to execute settlements with borrowed liquidity

export const InlineResource = ({value, copyValue, href, chain, explorerHref, explorerType = "address", explorerSuffix = "", showCopy = true, showExplorer = false, openInNewTab}) => {
  const explorerBases = {
    arbitrum: "https://arbiscan.io",
    arbitrum_one: "https://arbiscan.io",
    avalanche: "https://snowscan.xyz",
    base: "https://basescan.org",
    bnb: "https://bscscan.com",
    ethereum: "https://etherscan.io",
    gnosis: "https://gnosisscan.io",
    ink: "https://explorer.inkonchain.com",
    linea: "https://lineascan.build",
    mainnet: "https://etherscan.io",
    optimism: "https://optimistic.etherscan.io",
    plasma: "https://plasmascan.to",
    polygon: "https://polygonscan.com",
    sepolia: "https://sepolia.etherscan.io",
    xdai: "https://gnosisscan.io"
  };
  const isExternalUrl = (candidate = "") => (/^https?:\/\//i).test(candidate);
  const isHexAddress = (candidate = "") => (/^0x[a-fA-F0-9]{40}$/).test(candidate);
  const normalizeUrl = (candidate = "") => {
    if (!candidate) {
      return "";
    }
    if (candidate.startsWith("/") || candidate.startsWith("#") || isExternalUrl(candidate)) {
      return candidate;
    }
    return `https://${candidate}`;
  };
  const compactUrl = (candidate = "") => {
    const withoutProtocol = candidate.replace(/^https?:\/\//i, "");
    if (withoutProtocol.length <= 40) {
      return withoutProtocol;
    }
    const [host, ...segments] = withoutProtocol.split("/");
    if (!segments.length) {
      return `${withoutProtocol.slice(0, 20)}...${withoutProtocol.slice(-12)}`;
    }
    const tail = segments.length >= 2 ? `${segments[segments.length - 2]}/${segments[segments.length - 1]}` : segments[segments.length - 1];
    return `${host}/.../${tail}`;
  };
  const resolvedExplorerHref = (() => {
    if (explorerHref) {
      return explorerHref;
    }
    if (!chain || !value) {
      return "";
    }
    const base = explorerBases[chain];
    if (!base) {
      return "";
    }
    return `${base}/${explorerType}/${value}${explorerSuffix}`;
  })();
  const resolvedHref = normalizeUrl(href || "");
  const primaryHref = resolvedHref || (showExplorer ? resolvedExplorerHref : "");
  const primaryTarget = openInNewTab ?? (primaryHref ? isExternalUrl(primaryHref) : false);
  const shouldCompactValue = isExternalUrl(value || "") || isExternalUrl(primaryHref);
  const displayValue = shouldCompactValue ? compactUrl(value) : value;
  const contentClassName = ["inline-resource__value", shouldCompactValue ? "inline-resource__value--compact" : "", isHexAddress(value || "") ? "inline-resource__value--address" : ""].filter(Boolean).join(" ");
  const setButtonState = (button, state, label) => {
    if (!button) {
      return;
    }
    button.dataset.state = state;
    button.setAttribute("aria-label", label);
    button.title = label;
    if (button.__copyTimer) {
      window.clearTimeout(button.__copyTimer);
      button.__copyTimer = null;
    }
    if (state === "idle") {
      return;
    }
    button.__copyTimer = window.setTimeout(() => {
      button.dataset.state = "idle";
      button.setAttribute("aria-label", "Copy value");
      button.title = "Copy value";
    }, 1200);
  };
  const fallbackCopy = text => {
    if (typeof document === "undefined") {
      return false;
    }
    const input = document.createElement("textarea");
    input.value = text;
    input.setAttribute("readonly", "");
    input.style.left = "-9999px";
    input.style.position = "absolute";
    document.body.appendChild(input);
    input.select();
    let copied = false;
    try {
      copied = document.execCommand("copy");
    } catch {
      copied = false;
    }
    document.body.removeChild(input);
    return copied;
  };
  const copyText = async (text, button) => {
    if (!text) {
      setButtonState(button, "copied", "Nothing to copy");
      return;
    }
    try {
      if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
        await navigator.clipboard.writeText(text);
        setButtonState(button, "copied", "Copied");
        return;
      }
    } catch {}
    const copied = fallbackCopy(text);
    setButtonState(button, copied ? "copied" : "idle", copied ? "Copied" : "Copy failed");
  };
  const content = <code className={contentClassName} title={value}>
      {displayValue}
    </code>;
  return <span className="inline-resource">
      {primaryHref ? <a className="inline-resource__link" href={primaryHref} rel={primaryTarget ? "noreferrer noopener" : undefined} target={primaryTarget ? "_blank" : undefined} title={value}>
          {content}
        </a> : content}

      {showCopy || showExplorer && resolvedExplorerHref && resolvedExplorerHref !== primaryHref ? <span className="inline-resource__actions">
          {showCopy ? <button aria-label="Copy value" className="inline-resource__action" data-state="idle" onClick={event => copyText(copyValue || value, event.currentTarget)} title="Copy value" type="button">
              <span className="inline-resource__icon inline-resource__icon--copy">
                <CopyIcon />
              </span>
              <span className="inline-resource__icon inline-resource__icon--check">
                <CheckIcon />
              </span>
            </button> : null}

          {showExplorer && resolvedExplorerHref && resolvedExplorerHref !== primaryHref ? <a aria-label="Open in explorer" className="inline-resource__action" href={resolvedExplorerHref} rel="noreferrer noopener" target="_blank" title="Open in explorer">
              <span className="inline-resource__icon">
                <ExternalLinkIcon />
              </span>
            </a> : null}
        </span> : null}
    </span>;
};

The Flash Loan Router is a smart contract infrastructure that enables CoW Protocol solvers to execute settlements using funds from one or more flash loan providers. It acts as a proxy solver for CoW Protocol, allowing registered solvers to borrow assets, execute trades, and repay loans within a single atomic transaction.

## What is Flash Loan Router?

Flash Loan Router is a permissionless smart contract system deployed on multiple EVM networks that provides:

* **Multi-source flash loans**: Borrow from multiple lenders (Aave, Maker, etc.) in a single settlement
* **CoW Protocol integration**: Seamlessly execute settlements with borrowed liquidity
* **Modular architecture**: Support for any flash loan provider through adapter contracts
* **Atomic execution**: All operations succeed or fail together, ensuring safety

## Who is it for?

This infrastructure is designed specifically for **CoW Protocol solvers** who need access to liquidity beyond their own capital to:

* Execute large settlements that require substantial upfront capital
* Optimize settlement strategies by accessing external liquidity sources
* Reduce capital requirements while maintaining competitive solver operations
* Execute complex multi-step trading strategies within settlements

<Note>
  Only registered CoW Protocol solvers can call the Flash Loan Router. Authentication is managed through the same contract that handles solver authentication for the CoW Protocol settlement contract.
</Note>

## Key benefits

<CardGroup cols={2}>
  <Card title="Capital efficiency" icon="chart-line">
    Execute settlements without needing to maintain large capital reserves
  </Card>

  <Card title="Multi-lender support" icon="building-columns">
    Access liquidity from Aave, Maker, and any ERC-3156 compatible lender
  </Card>

  <Card title="Deterministic deployment" icon="fingerprint">
    Same contract addresses across all supported networks using CREATE2
  </Card>

  <Card title="Security model" icon="shield-halved">
    Solvers maintain full control of settlement execution with protected call flow
  </Card>
</CardGroup>

## Deployed contracts

All contracts are deployed deterministically with CREATE2 and share the same addresses across supported networks:

* `FlashLoanRouter`: <InlineResource value="0x9da8B48441583a2b93e2eF8213aAD0EC0b392C69" chain="ethereum" showExplorer />
* `AaveBorrower`: <InlineResource value="0x7d9C4DeE56933151Bc5C909cfe09DEf0d315CB4A" chain="ethereum" showExplorer />
* `ERC3156Borrower`: <InlineResource value="0x47d71b4B3336AB2729436186C216955F3C27cD04" chain="ethereum" showExplorer />

<Info>
  The Flash Loan Router was introduced as part of CoW Protocol through [CIP 66](https://snapshot.box/#/s:cow.eth/proposal/0x6f3d88347bcc8de87ecded2442c090d8eb1d3ef99eca75a831ee220ff5705f00).
</Info>

## Supported networks

CoW Protocol is deployed on the following networks:

| Network           | Chain ID | Type      |
| ----------------- | -------- | --------- |
| Ethereum          | 1        | Mainnet   |
| Gnosis Chain      | 100      | Mainnet   |
| Arbitrum One      | 42161    | Layer 2   |
| Base              | 8453     | Layer 2   |
| Polygon           | 137      | Sidechain |
| Avalanche C-Chain | 43114    | Sidechain |
| BNB Smart Chain   | 56       | Sidechain |
| Optimism          | 10       | Layer 2   |
| Linea             | 59144    | Layer 2   |
| Plasma            | 9745     | Layer 2   |
| Ink               | 57073    | Layer 2   |
| Sepolia           | 11155111 | Testnet   |

See the [networks.json](https://github.com/cowprotocol/flash-loan-router/blob/main/networks.json) file for complete deployment details.

## How it works

The execution flow follows these steps:

1. **Solver initiates**: A registered solver calls `flashLoanAndSettle()` with loan parameters and settlement data
2. **Flash loans requested**: The router requests loans sequentially from each specified lender through borrower adapters
3. **Funds received**: Each borrower receives loaned assets and calls back the router
4. **Settlement executed**: Once all loans are obtained, the router executes the CoW Protocol settlement
5. **Loans repaid**: The settlement transfers assets back to borrowers and approves lenders to pull repayment
6. **Verification**: Lenders verify repayment, completing the atomic transaction

<Warning>
  If any step fails (loan unavailable, settlement reverts, insufficient repayment), the entire transaction reverts. This ensures solvers never end up with unpayable debt.
</Warning>

## Next steps

<CardGroup cols={2}>
  <Card title="System architecture" icon="sitemap" href="/flash-loan-router/architecture">
    Understand the technical design and component interactions
  </Card>

  <Card title="Getting started" icon="rocket" href="/flash-loan-router/getting-started/quickstart">
    Learn how to integrate Flash Loan Router into your solver
  </Card>

  <Card title="Contract Reference" icon="code" href="/flash-loan-router/contracts/flash-loan-router">
    Explore contract interfaces and function signatures
  </Card>

  <Card title="Deployment guide" icon="server" href="/flash-loan-router/operations/deployment-guide">
    Deploy contracts to new networks
  </Card>
</CardGroup>
