auradefi 0.1.1
PyPI GitHub

auradefi

Open-source, multi-tenant crypto data aggregator. It takes the tenancy model from Vezgo, the DeFi position depth from DeBank and the transaction decomposition from Zerion, then emits Plaid's wire format, so crypto lands in the same downstream schema as bank and exchange data.

It is a library first and a service second. A Python host imports auradefi directly and pays no serialisation or network cost. The HTTP API is a thin shell over the same importable core.

Status: alpha, and 0.1.1 is the release to use. Every planned capability is implemented. The suite is 3,247 tests green offline on a fresh clone with no API keys, all twelve notebooks execute clean, and every example under examples/ runs against the published wheel.

Do not use 0.1.0. A separate adversarial review of it found nineteen verified defects, of which five were security and four were silent data loss. None of them failed a test. docs/internal/RELEASE_0.1.1.md is the full accounting. 0.1.1 fixes all nineteen and deliberately breaks one id derivation, so read Upgrading in CHANGELOG.md before you move library-ingested data across.

Alpha means the gaps in What is not there are real; read that section before you budget work against this. STATUS.md carries the live gate state, and docs/internal/SPEC.md is the design contract.

Documentation site → carries the examples, the twelve executable notebooks and the full reference, rendered with every example's real output.

Install

pip install auradefi                # core; httpx is the only dependency
pip install 'auradefi[sql]'         # + the SQLModel ledger backend
pip install 'auradefi[api]'         # + the FastAPI HTTP surface

From a clone (if your system python has no pip, scripts/bootstrap.sh handles it):

git clone https://github.com/auracarehq/auradefi
cd auradefi && bash scripts/bootstrap.sh
.venv/bin/pytest                           # the whole suite, offline, no keys
.venv/bin/python examples/quickstart.py    # every capability, end to end
bash scripts/run_examples.sh               # all eleven examples

Examples

examples/ holds one file per question. Each one is self-contained, reads nothing from this repository, and runs offline without API keys. Each asserts its own output, and CI executes all of them, so a stale example fails the build.

Example What it answers
quickstart.py the whole library in one file; start here
01_holdings_for_an_address.py a priced portfolio, exactly, with unpriced assets named
02_embed_in_your_backend.py your ports, your tick, your database, and restart resume
03_write_a_source_adapter.py point it at your own chain data (two methods)
04_persist_to_your_database.py host-owned DDL, a resumable cursor feed, a reorg
05_serve_the_http_api.py Plaid's envelope over HTTP, and batch partial success
06_isolate_two_tenants.py one deployment, many customers, attacked four ways
07_read_defi_positions.py an LP and a loan that still add up to net worth
08_report_cost_basis_and_pnl.py FIFO/LIFO/HIFO/ACB, any instant, Plaid tax_lots[]
09_deliver_signed_webhooks.py signing, the pinned retry schedule, replay
10_scan_bitcoin_and_solana.py an xpub that never leaves the process, and Token-2022

examples/README.md annotates the index, and the documentation site renders every example with its real output.

Using it

As a library, where the host owns storage, transport, prices and the tick:

from auradefi import Auradefi

auradefi = Auradefi(
    ledger=SqlModelLedger(session_factory=my_session_factory),  # your database
    source=MySource(),        # your transport: .balances() + .fetch_txlist()
    prices=MyPrices(),        # your price feed: .usd_prices()
)
user = auradefi.user("opaque-host-user-id")   # get-or-create, id is derived
user.connect_address("eip155:1", "0x…")       # validated now, not on a later tick
report = auradefi.sync(budget=5)              # budgeted, resumable, self-throttling
holdings, metrics = auradefi.holdings(), auradefi.scalar_metrics()

As a service, where create_app takes ports you already built:

from auradefi.api.app import create_app
from auradefi.api.deps import Deps

app = create_app(Deps(tenancy=, keys=, ledger=, webhooks=, clock=))
# POST /auth/token, POST /connections, GET /crypto/sync  (Plaid's envelope)
# GET /coverage, POST /webhooks/endpoints, POST /webhooks/…/replay

docs/books/ walks both surfaces executably and offline.

What works today

Coverage is published as data (rule #10). Every row below has an executable notebook under docs/books/ that runs offline and asserts its own outputs, plus a gate test under tests/.

Capability Limits, and what proves it
Quantity/Money: exact at 10^77, four-field wire form, raw always a JSON string, strict wire grammar 02_money
CAIP-2/CAIP-19 parse + canonicalize, deterministic ast_… ids, both-ways asset registry 5 seed chains (Ethereum, Polygon, Base, Bitcoin, Solana); 03_assets_chains
Asset groups (decimals-equality law, single fallback) + additive spam scoring (score + numbers, caller threshold) 03_assets_chains
Ledger port: idempotent upsert, cursor sync with has_more paging, reorg as removed + re-added, resurrection, tenant isolation memory and SQLModel backends; 04_ledger
Cassette replay harness (CassetteMissError offline guarantee) 01_foundation
Style gates: size, structure, placement, layering (tests/style) no allowlist
EVM balances to holdings, exact-Decimal USD totals, unpriced assets named Etherscan V2 source + DefiLlama prices; 05_holdings
Tenancy: org/project/end-user, scoped adk_ keys, authEndpoint JWT mint, three-window quota, audit log the isolation gate actively tries to leak; 06_tenancy
Rich transactions: parts[]/acts[], fees as siblings carrying borne_by, derived type, ledger bridge, reorg + resurrection EVM only, one act per transaction; 07_transactions
DeFi positions: adapter protocol, drill-down, group totals + health factor, signed synthetic-Holdings projection Uniswap v2/v3, Aave v3, Lido/Rocket Pool; fixture-driven, see below; 08_positions
Embedding: from auradefi import Auradefi, host-owned session, budgeted two-phase sync, 26-metric scalar projection chain-scoped connection ids, restart resume enumerated from the state port, one connection's failure contained to its own row (0.1.1 #18/#21/#24/#26); 09_embedding, 02_embed_in_your_backend.py
Bitcoin: pure-Python BIP32 xpub derivation, gap-20 scan, confirmed-only UTXO balances p2wpkh + Esplora only; the extended key never reaches HTTP; 10_bitcoin_solana
Solana: SPL + Token-2022 balances, ScaledUiAmount carried both ways, signature history balances only, no decode; 10_bitcoin_solana
HTTP API: Plaid /crypto/sync envelope, connections, /coverage generated as data, nine quota headers, batch holdings 12_http_api
Webhooks: HMAC-SHA256 signed, durable over a pinned retry schedule, dead letter + replay 12_http_api
Accounting: lot ledger, FIFO/LIFO/HIFO/ACB, realised + unrealised PnL, arbitrary-date PnL, Plaid tax_lots 50,000-event gate; 11_accounting

What is not there

Rule #10 applies to the absences too.

The rules the code lives by

Docker

docker compose run --rm test    # full offline suite in a network-less container
docker compose run --rm demo    # quickstart against the installed wheel

Docs

auradefi.info is built from this repository, with every example executed at build time and every signature generated from the code.

Start here:

Also in the repository:

Licence

Apache-2.0. See LICENSE.