Current section
Files
Jump to
Current section
Files
mix.exs
defmodule Bourse.MixProject do
use Mix.Project
@version "0.1.0"
@source_url "https://github.com/ZenHive/bourse"
@runtime_manifest "priv/specs/json/runtime_support.json"
@runtime_venues @runtime_manifest |> File.read!() |> :json.decode() |> Map.fetch!("venues")
def project do
[
app: :bourse,
version: @version,
elixir: "~> 1.18",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
deps: deps(),
aliases: aliases(),
description: "Elixir client for ten provider-authored cryptocurrency exchange integrations.",
package: package(),
source_url: @source_url,
homepage_url: @source_url,
dialyzer: dialyzer(),
docs: docs()
]
end
defp docs do
[
main: "readme",
extras: ["README.md", "CHANGELOG.md", "CONTRIBUTING.md"],
source_url_pattern: "#{@source_url}/blob/main/%{path}#L%{line}",
description: "Unified and raw REST APIs for ten complete provider-authored exchange integrations.",
# Docs mirror the package: only `ccxt.build_lighter_signer` ships, so the
# repo-internal tasks must not appear on hexdocs as tasks consumers can run.
# `filter_modules` is a KEEP predicate — true documents the module.
filter_modules: &__MODULE__.document_module?/2,
groups_for_modules: [
Exchanges: ~r/^Elixir\.Bourse\.[A-Z][a-zA-Z0-9]+$/,
Signing: ~r/^Elixir\.Bourse\.Signing\./,
WebSocket: ~r/^Elixir\.Bourse\.WS\./,
"Core API": [
Bourse,
Bourse.Exchange,
Bourse.Registry,
Bourse.Spec,
Bourse.Unified,
Bourse.UnifiedMethod,
Bourse.Symbol,
Bourse.Parser,
Bourse.Dispatch,
Bourse.HTTP,
Bourse.Credentials,
Bourse.Error,
Bourse.MCP,
Bourse.Multi,
Bourse.Exchanges
]
]
]
end
@doc """
ExDoc `:filter_modules` predicate — true keeps the module in the docs.
Drops the repo-internal `mix ccxt.*` tooling that `package/0` deliberately
leaves out of the tarball, so hexdocs never advertises a task a consumer
cannot run. `ccxt.build_lighter_signer` ships and stays documented.
"""
@spec document_module?(module(), map()) :: boolean()
def document_module?(module, _metadata) do
name = inspect(module)
not String.starts_with?(name, "Mix.Tasks.Ccxt.") or
name == "Mix.Tasks.Ccxt.BuildLighterSigner"
end
defp package do
runtime_specs =
Enum.map(@runtime_venues, &"priv/specs/json/output/authored/#{&1}.json")
[
licenses: ["MIT"],
links: %{"GitHub" => @source_url},
# `lib/mix/tasks` is repo-internal authoring/audit tooling: every task but
# the Lighter build reads paths that are deliberately unpackaged
# (`test/fixtures`, `roadmap/`, `CLAUDE.md`, the CCXT reference corpus), so
# shipping them would put `mix help` entries in consumer projects that fail
# on a missing file. `ccxt.build_lighter_signer` is the one consumer-facing
# task — README documents it as the prerequisite for private Lighter calls.
files:
~w(lib/bourse lib/bourse.ex lib/mix/tasks/ccxt.build_lighter_signer.ex) ++
~w(native/lighter_signer mix.exs README.md LICENSE) ++
[@runtime_manifest | runtime_specs]
]
end
defp dialyzer do
[
plt_add_apps: [:mix]
]
end
def cli do
[
preferred_envs: [
"test.json": :test,
"dialyzer.json": :dev,
"ccxt.oracle_gate": :test
]
]
end
def application do
[
mod: {Bourse.Application, []},
extra_applications: [:logger]
]
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
defp deps do
[
# Dev/test tooling
{:ex_unit_json, "~> 0.6", only: [:dev, :test], runtime: false},
{:dialyzer_json, "~> 0.2.1", only: [:dev, :test], runtime: false},
{:styler, "~> 1.12.2", only: [:dev, :test], runtime: false},
{:credo, "~> 1.7.19", only: [:dev, :test], runtime: false},
{:sobelow, "~> 0.14.1", only: [:dev, :test], runtime: false},
# CVE tripwire: `mix deps.audit` checks mix.lock against the advisory DB
# (hex.audit only catches retired packages). Wired into precommit.full + ci.
{:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.4.7", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.40.3", only: :dev, runtime: false},
{:doctor, "~> 0.23.0", only: [:dev, :test], runtime: false},
# Tidewave for Claude Code MCP integration (non-Phoenix needs bandit)
{:tidewave, "~> 0.8.0", only: :dev},
{:bandit, "~> 1.12.0", only: :dev},
# Code analysis tools
{:ex_dna, "~> 1.5.3", only: [:dev, :test], runtime: false},
# reach 2.8.1 pins ex_ast ~> 0.12.0; override verified against mix reach.check
{:ex_ast, "~> 0.13.0", only: [:dev, :test], runtime: false, override: true},
{:ex_slop, "~> 0.4.2", only: [:dev, :test], runtime: false},
{:reach, "~> 2.8.1", only: [:dev, :test], runtime: false},
# reach references Boxart.Render.* unconditionally; boxart is
# `optional: true` in reach's hex manifest, so we pull it in here.
{:boxart, "~> 0.3.3", only: [:dev, :test], runtime: false},
# Plug.Conn for Req.Test stubs with custom status codes (also needed by tidewave in :dev)
{:plug, "~> 1.20", only: [:dev, :test]},
# Runtime dependencies
# decimal — arbitrary-precision decimal for money-exact response normalization
# (Bourse `Precise.stringMul`/`stringDiv` parity: e.g. trade cost = amount × price
# without float drift). Previously only transitively present via dev/test `doctor`.
{:decimal, "~> 3.1"},
{:jason, "~> 1.4.5"},
{:req, "~> 0.6.1 or ~> 0.7.0"},
{:fuse, "~> 2.5.0"},
{:telemetry, "~> 1.4.2"},
# Self-describing APIs — emit_api/3 (for-comprehension api declarations,
# used in lib/bourse.ex) ships in descripex 0.11.0; vendor fork retired.
{:descripex, "~> 0.12.0"},
# Custom DEX signing (hyperliquid + derive): EIP-712 / msgpack / secp256k1.
# msgpax — canonical MessagePack for Hyperliquid action hashing.
# ex_keccak — Keccak-256 NIF (EIP-712 struct/domain hashing).
# ex_secp256k1 — RFC-6979 deterministic ECDSA with recovery id (signature r/s/v).
{:msgpax, "~> 2.4"},
{:ex_keccak, "~> 0.7.8"},
{:ex_secp256k1, "~> 0.8.0"},
# WebSocket client (Gun-based, 5-function API + Deribit heartbeat + reconnection)
{:zen_websocket, "~> 0.6.0"}
]
end
defp aliases do
[
tidewave: [
"run --no-halt -e 'Agent.start(fn -> Bandit.start_link(plug: Tidewave, port: 4003) end)'"
],
precommit: [
"format --check-formatted",
"compile --warnings-as-errors",
# TODO(Task N) markers are first-class here — don't fail credo on them.
"credo --strict --ignore TagTODO,TagFIXME",
"doctor --raise",
# Hash-based `.sobelow-skips` (this repo's hook ignores inline comments).
"sobelow --skip",
# `preferred_envs` (cli/0) is ignored for alias steps — set MIX_ENV
# explicitly so test.json runs in :test (a bare alias step inherits the
# alias's env, not :test). `cmd env VAR=val ...` so the assignment reaches
# the subprocess env, not System.cmd's executable slot. test.json excludes
# most integration tags by default; this is the offline unit + signing gate.
"cmd env MIX_ENV=test mix test.json --quiet --exclude integration"
],
# Dispatch-scale reviewer hint (the registered harness `check_command`).
# `precommit` (offline unit + signing gate) plus the clone + architecture/smell
# analyzers a cold reviewer worktree would otherwise never run (they're only
# host-PostToolUse-hook-run locally). No dialyzer (a cold harness worktree
# cold-builds the PLT for minutes → `review_stuck`). AGENTS.md freshness is
# in-tree (`ccxt.agents_md --check`, task 471) so every reviewer grades against
# current rules without an operator marketplace checkout.
"check.dispatch": [
"precommit",
# Binary reality gate over recordings, accepted requests, and recorded
# errors. The committed exact-set baseline rejects lost provenance.
"cmd env MIX_ENV=test mix ccxt.oracle_gate",
"ccxt.check_lighter_signer",
# Fast filesystem parse of CLAUDE.md mechanical claims (task 487). Safe
# on cold reviewer worktrees — no PLT, no network, no suite.
"ccxt.claude_check",
# AGENTS.md freshness (task 471): re-renders CLAUDE.md + pinned includes
# and fails on drift. Repo-owned — no marketplace path, no $HOME fallback.
"ccxt.agents_md --check",
"ex_dna --max-clones 0",
# `--strict` fails the gate on smell findings — no baseline/suppression;
# findings are fixed, not grandfathered. Reach derives architecture
# sources from the active Mix environment, while `--path` pins smell
# sources; pin both so callers always grade lib/.
"cmd env MIX_ENV=dev mix reach.check --arch --smells --strict --path lib"
],
# GHSA-w4f7-4cxr-rv3c pairs cowboy + gun; its gun rows carry cowboy's
# numbers ("first patched 2.16.0" — gun has no 2.16.x), so mix_audit
# flags gun 2.5.0 although gun's own vulnerable range is < 2.4.0.
# Verified against the advisory 2026-07-30; drop when the DB row is fixed.
"deps.audit": "deps.audit --ignore-advisory-ids GHSA-w4f7-4cxr-rv3c",
# Local pre-PR / post-merge-audit gate — adds dialyzer. SPLIT out because a
# cold harness worktree cold-builds the PLT (minutes) → `review_stuck`.
# `--cover` is omitted everywhere here (`:cover` instruments every loaded
# beam, multi-GB spike on cold trees); run coverage explicitly via
# `mix test.json --cover` per the critical-rules gate.
"precommit.full": ["precommit", "deps.audit", "dialyzer.json --quiet"],
# Comprehensive pre-PR / CI gate: the dispatch gate + dialyzer + changelog.
# AGENTS.md freshness and CLAUDE.md mechanical claims already run inside
# check.dispatch (`ccxt.agents_md --check`, `ccxt.claude_check`).
ci: [
"check.dispatch",
"deps.audit",
"dialyzer.json --quiet",
"ccxt.changelog_check"
]
]
end
end