Skip to main content

Middleware

Since the inception of Domination Finance, we've continued internally developing a “middleware” layer that enables building dApps in a Web3-native environment. It’s built on top of the foundational ethers.js library for EVM.

Compared to other ad-hoc solutions, it's written in a network-agnostic way which makes additional network deployments as easy as adding the new deployment addresses and their associated network. In the past, launching support for a new network took us roughly a week.

It features the following components:

Ethereum transaction management – tx-steps package

  • Allows for orchestrating complex chains of Ethereum transactions in a declarative way
  • Adding or removing transaction steps is declarative vs having to manually modifying direct contract calling code (e.g. GMX codebase, others)

Smart contract client support – eth package

  • Handles safely encoding and decoding between domain layer and Ethereum RPC layer
  • Low-level contract clients that interact with raw smart contracts
  • Prevents UI from directly calling smart contracts in error-prone ways (e.g. incorrectly decoding raw EVM values returned)

Wallet support - wallet package

  • Handles abstracting vendor wallet support and provides a uniform interface
  • Currently supports:
    • MetaMask on desktop and mobile

Realtime on-chain data sync – stores package

  • Uses a dependency graph to prevent duplicate refreshes of RPC data if used in multiple places in the UI
  • Allows the UI to directly link to live on-chain data without worrying about how to fetch it efficiently and keep it in sync (e.g. a user’s ERC20 balance)

Domain models – domain package

  • A comprehensive “vocabulary” for core EVM concepts shared by the entire application:
  • L1 and L2 mainnet and testnet networks
  • Framework for describing on-chain assets from ERC20s to native network tokens, and perpetual synths
  • Perpetual orders and positions
  • A “registry” for a central location to specify contract locations on-chain