mirror of
https://github.com/luxfi/graph.git
synced 2026-09-24 00:26:07 +00:00
exchange-api answered /v1/quote, and it was the last TypeScript service standing in front of this one. Its route search could try two intermediaries, WLUX and LUSD, because those are the two someone typed into a list — while the indexer beside it holds the whole pool graph. Searching the real graph finds what the list cannot: WLUX to LUSD pays 1221887840049623 through LBLAST against 611022579164403 direct, twice as much, on the same block. A quote is two questions and they have different authorities. Which pools could carry the trade is the index's to answer, and that is why the endpoint belongs here. What a pool actually pays is the pool's: a constant-product pair is its two reserves, and that arithmetic is in this file, exact, in integers; a concentrated pool is a walk across whatever ticks the trade crosses, and only its quoter holds the tick map. Doing the concentrated case here was tried and measured before it was rejected. Treating a pool as constant-liquidity around slot0 is exact while a trade stays inside the current tick and wrong the moment it does not — 15% high on CYRUS/LUSD, 44% on Z/LUSD, 89% on TRUMP/LUSD, every error in the direction of promising output the pool cannot pay. Those are the pools holding their liquidity away from spot, which is most of a thin book. Closing the gap needs the tick map; the tick map is not indexed, and event-sourcing it is exactly what valuation.go already declined to do for reserves. Constant-product pairs are quoted here for the first time. QuoterV2 is a V3 contract and never knew them, so the one pair on Lux mainnet has been invisible to the swap form; it prices at 987158034397061298 for a token in against its 100/100 reserves, read live. The store cannot tell a pair from a pool — handlePairCreated records feeTier 3000 whichever it is — so the pool is asked, once, and the answer kept for as long as the process runs. A pool that answers neither is left out rather than guessed at. Eleven of thirteen live probes reproduce exchange-api's amount exactly. The two that differ are the better routes. The response shape is exchange-api's, unchanged, down to the empty route that a missing quote returns as a 200 — the swap form reads that as "no price" and retries a 404. Co-authored-by: Hanzo Dev <[email protected]>
52 lines
2.1 KiB
AMPL
52 lines
2.1 KiB
AMPL
module github.com/luxfi/graph
|
|
|
|
go 1.26.5
|
|
|
|
require (
|
|
github.com/hanzoai/csqlite v0.1.2
|
|
github.com/hanzoai/replicate v0.6.0
|
|
github.com/luxfi/age v1.4.0
|
|
golang.org/x/crypto v0.54.0
|
|
gopkg.in/yaml.v3 v3.0.1
|
|
)
|
|
|
|
require (
|
|
filippo.io/hpke v0.4.0 // indirect
|
|
github.com/beorn7/perks v1.0.1 // indirect
|
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
|
github.com/google/go-cmp v0.6.0 // indirect
|
|
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect
|
|
github.com/google/uuid v1.6.1-0.20241114170450-2d3c2a9cc518 // indirect
|
|
github.com/hablullah/go-hijri v1.0.2 // indirect
|
|
github.com/hablullah/go-juliandays v1.0.0 // indirect
|
|
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
|
github.com/jalaali/go-jalaali v0.0.0-20210801064154-80525e88d958 // indirect
|
|
github.com/kr/text v0.2.0 // indirect
|
|
github.com/lmittmann/tint v1.1.3 // indirect
|
|
github.com/magefile/mage v1.14.0 // indirect
|
|
github.com/markusmobius/go-dateparser v1.2.4 // indirect
|
|
github.com/mattn/go-isatty v0.0.22 // indirect
|
|
github.com/mattn/go-sqlite3 v1.14.47 // indirect
|
|
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
|
github.com/ncruces/go-strftime v1.0.0 // indirect
|
|
github.com/pierrec/lz4/v4 v4.1.22 // indirect
|
|
github.com/prometheus/client_golang v1.17.0 // indirect
|
|
github.com/prometheus/client_model v0.5.0 // indirect
|
|
github.com/prometheus/common v0.45.0 // indirect
|
|
github.com/prometheus/procfs v0.12.0 // indirect
|
|
github.com/psanford/sqlite3vfs v0.0.0-20251127171934-4e34e03a991a // indirect
|
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
|
github.com/superfly/ltx v0.5.1 // indirect
|
|
github.com/tetratelabs/wazero v1.2.1 // indirect
|
|
github.com/wasilibs/go-re2 v1.3.0 // indirect
|
|
golang.org/x/sync v0.22.0 // indirect
|
|
golang.org/x/sys v0.47.0 // indirect
|
|
golang.org/x/text v0.40.0 // indirect
|
|
google.golang.org/protobuf v1.33.0 // indirect
|
|
modernc.org/libc v1.72.3 // indirect
|
|
modernc.org/mathutil v1.7.1 // indirect
|
|
modernc.org/memory v1.11.0 // indirect
|
|
modernc.org/sqlite v1.51.0 // indirect
|
|
)
|