mirror of
https://github.com/luxfi/dex.git
synced 2026-09-24 00:26:31 +00:00
Three things claimed to be this repo's trading API and no two agreed. pkg/trading carried its own Venue interface, its own V4/native/V2/V3 and broker venues, its own constant-product math and its own eth_call client — a copy of what pkg/gateway already had — and nothing mounted it: grep for the import outside that directory returns empty. api/openapi.yaml documented it anyway, so the one published contract in the repo described the one package no binary served. Meanwhile the binary answered at /v1/* and again at /trading/* in Uniswap's shapes: two contracts for one API, reachable by both names, free to drift. Deleted, both of them, rather than picked between and left beside. Everything answers under /v1/trade now. api.lux.cloud carries the chain at /v1/chain, the C-chain at the root and other services besides, so /v1/quote was a generic name claimed on a shared host; one prefix is one namespace with one owner, and the edge rule that publishes it collapses from a nine-clause allowlist to a prefix. Server.routes() is the surface written once, and TestTheDocumentIsTheSurface reads api/openapi.yaml and holds the two to each other in both directions. /v1/trade/venues is new. It is the question a screen asks before it asks anything else — which chains this deployment can price, and from what — grouped by chain, because a venue is a contract on a chain and the same name means a different pool on each. Without it a client learns a chain is unquotable by quoting on it and reading an error. The allowance is read rather than assumed. approval/check and permit2/check answered allowance 0 and needsApproval on every request, under a comment saying the gateway had no way to reach a chain; it has one per chain, one field away — the same endpoint the pool is quoted from. Measured against 96369: LUSD to the position manager reads 6000000000000000000000000, which is what eth_call returns for that pair, and the approve tx now rides along only when it is needed. Handed back beside "you already approved" it is a transaction somebody sends, and the user pays gas for a state change that changes nothing before every swap. Permit2 reads the expiration too, because a grant that has run out is not a grant. Nothing here invents a number any more. /v1/history/prices and /v1/history/tvl returned a random walk seeded from hardcoded base prices — LUX at 2.47, WBTC at 96420, 12.5M of TVL on a chain whose pools were seeded hours ago — and both were routed to the public internet, where a chart drawn from them is indistinguishable from a chart of the market. History belongs to the indexer, which reads the chain. /v1/tokens/search answered 501 on a TODO, a route lying about the surface in the other direction. Gone, with a test that keeps them gone. Co-authored-by: Hanzo Dev <[email protected]>