Router

The Fira Router is a diamond-like proxy that delegates user calls to specialized action facets via selector-to-facet mappings.

The router is the single entry point for all user-facing protocol operations. It uses a diamond-like proxy pattern where each function selector maps to an action facet contract via delegatecall.

circle-info

Since all facets share storage via delegatecall, RouterStorage uses ERC-7201 storage namespacing to avoid collisions.

FiraRouterV4

Extends OpenZeppelin's Proxy and overrides _implementation() to look up CoreStorage.selectorToFacet[msg.sig]. If no facet is registered, it reverts with INVALID_SELECTOR.

The constructor hard-wires the setSelectorToFacets and selectorToFacet selectors to the ActionStorageV4 facet, allowing the owner to configure all other mappings post-deployment.

Facet contracts

Shared base contracts

All facets inherit from ActionBase, which provides:

  • FW mint/redeem orchestration

  • BT/CT swap orchestration with limit order support

  • Flash-callback encoding/decoding via CallbackHelper

  • Delegation to ActionSimple when on-chain approximation suffices

Last updated