Onchain.DEX.Router.Pool (onchain v0.7.0)

Copy Markdown View Source

A single DEX liquidity pool descriptor consumed by Onchain.DEX.Router.

Two protocols are supported:

  • :uniswap_v2 — constant-product pools. Output is computed analytically in pure Elixir from :reserve0/:reserve1 (no RPC needed for the math). Fetch reserves once via getReserves() and populate the struct.
  • :uniswap_v3 — concentrated-liquidity pools. Output is obtained from the on-chain QuoterV2 contract via eth_call (exact tick-crossing simulation); :reserve0/:reserve1 are ignored.

:fee_bps is the pool fee in true basis points (30 = 0.30%). For v3 it is converted to the uint24 fee tier the quoter expects (fee_bps * 100, so 30 bps → 3000).

Summary

Types

t()

@type t() :: %Onchain.DEX.Router.Pool{
  address: String.t() | binary(),
  fee_bps: non_neg_integer(),
  protocol: :uniswap_v2 | :uniswap_v3,
  reserve0: non_neg_integer() | nil,
  reserve1: non_neg_integer() | nil,
  token0: String.t() | binary(),
  token1: String.t() | binary()
}