feat: list CL8Y DEX (dex.cl8y.com) on DeFiLlama (TVL + volume + fees) #631
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#631
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
List CL8Y DEX (
https://dex.cl8y.com) on DeFiLlama as a Terra Classic DEX: TVL, spot volume, and fees/revenue. Bundle the three Llama dashboards plus the indexer/docs work they require. This is not a CoinGecko/CMC listing ticket — those already have/cg/*and/cmc/*.Public pins (columbus-5)
https://dex.cl8y.comhttps://indexer.dex.cl8y.comterra1ejpgvv7g3hj0u6fpcnxhflqp84g0w3cnaskqkg5733ygwlmf963sfchseaterra(Terra Classic; same as Terraport / GarudaDeFi adapters)Current codebase
CL8Y already publishes self-hosted exchange listing APIs and an internal protocol dashboard. None of that is a DeFiLlama adapter.
What exists
GET /cg/pairs,/cg/tickers,/cg/orderbook,/cg/historical_tradesdocs/CG_CMC_COMPLIANCE.md,indexer/src/api/cg.rs)/cg/*. Tickers are a trailing 24h snapshot, not UTC calendar-daydailyVolume.GET /cmc/*indexer/src/api/cmc.rs)GET /api/v1/overviewtotal_liquidity_usd, trailing 24h/7d/30d volume + treasury fees (overview.rs, #550 / #569 / #586)GET /api/v1/protocol/fees?window=protocol_fees.rs)24h|7d|30donly. No?timestamp=calendar bucket.protocol_tvl.rssums factorypair_reserveswith P522-Q catalog + hub marks; omits book escrow, stale/same-asset/unpriced pairs (#569)api.add(denom|cw20, raw_amount)and price on their side. Our USD number is a QA cross-check, not the adapter output.swap_eventsrow per taker swap; do not addlimit_order_fills(docs/integrators-hybrid-volume.md, #216 / #189)Pairs { start_after, limit }andPool {}(dex-commonfactory + pair); pagination is required (#258)Known trap: CG
liquidity_in_usdis not TVLGET /cg/tickersfieldliquidity_in_usdis mislabeled 24hvolume_usd(see comment incg.rs). Protocol pool TVL isGET /api/v1/overviewtotal_liquidity_usd. A Llama adapter that copiesliquidity_in_usdwill publish volume as TVL. Forbidden.What does not exist
DefiLlama-Adaptersproject underprojects/cl8y-dex(or similar).dimension-adaptersfiles underdexs/orfees/.GET /api/v1/defillama/*surface.docs/listing playbook for Llama (CG/CMC only).Why this is needed
DeFiLlama is the default public TVL/volume/fees ledger for DEXes. Terra Classic already lists Terraport, GarudaDeFi, Loop, etc. Without adapters:
dex.cl8y.comis invisible on defillama.com/chain/terra-classic and the Dexs dashboard./protocolpage is first-party; Llama is the independent citation. Listing also forces us to publish a methodology that matches on-chain state (factory pools), not only indexer USD.CG/CMC endpoints do not substitute: Llama maintainers merge open-source adapters in their repos, not a hosted
/cg/tickersURL.Constraints and guardrails
Llama process (upstream, not this repo)
node test.js projects/<slug>/index.js.dexs/<slug>. Required dimension:dailyVolume. Guide: other dashboards. Test:pnpm test dexs <slug>.fees/<slug>. Required:dailyFees,dailyRevenue; includedailySupplySideRevenue(even if0) andbreakdownMethodology. Do not export deprecatedtotal*cumulatives.https://dex.cl8y.com, chainterra, category Dexs, logo via DefiLlama icons repo. Slug recommendation:cl8y-dex(avoid colliding with a future CL8Y token-only listing).TVL (on-chain only)
pairs,queryContractWithRetrieseach pair{ pool: {} },api.addnativedenom/ CW20contract_addrwith raw amounts (Terraport adapter).timetravel: false(live factory list cannot historical-query).errors.length > poolContracts.length / 2).start_after = last.asset_infosand a boundedlimit(factory default page is small; #258).total_liquidity_usd, hub marks, CGliquidity_in_usd).liquidity_token) — that double-counts pool assets.uluna/uusdbalances as locked wrap collateral. If included, methodology must say so; default omit unless Llama asks (DEX category is usually pools-only).COLUMBUS5_GEM_ADDRESSES.uluna/uusd. UST1, USTR, cLUNC, cUSTC, CL8Y, community-tax CW20s may be unpriced until CoinGecko/Llama have those contracts. UsemisrepresentedTokensonly with an explicit substitution table (e.g. cUSTC → USTC 1:1). Do not invent hub pegs inside the adapter. Related: token recognition #629./overview.total_liquidity_usdis OK (different pricers + one-sided 2× catalog vs Llama omit-unpriced). Document it; do not “fix” Llama TVL by posting our USD.Volume
options.startOfDay…+86400), not trailing 24h.SUM(swap_events.volume_usd)(or offer-side USD) once per swap row. Never addlimit_order_fills(#216 L10).GET /overview.total_volume_24h_usdasdailyVolume(window mismatch + includes gems unless filtered).Fees / revenue
CL8Y pair commission goes to pair
FEE_CONFIG.treasury(CMM), not to LPs.spread_amountis not a fee (protocol_fees.rsPFee / L7).dailyFeesswap_amm+book_take+limit_place(+ optional wrap/unwrap/ust1_* as labeled breakdowns)dailySupplySideRevenue0for billed commission (LPs earn via inventory / spread, not a transferred fee). Do not reclassifyspread_amountas SSR.dailyRevenue/dailyProtocolRevenuedailyFeesfor the DEX fee set (protocol keeps treasury commission)dailyHoldersRevenuebreakdownMethodologylabels must match every.add()label. Community-tax extra-debit is token tax, not protocol DEX fee.Indexer / Coolify
swap_eventsfull-table scan on the request path (same class as#281/#333/#577overview rollups).https://dex.cl8y.com; Llama adapters are server-side (CORS irrelevant).indexer/into root Docker to compile.RUN_MODE=prod, HTTPS only.Out of scope
Relevant files
This repo (implement / document)
indexer/src/api/overview.rs— trailing overview (do not reuse as Llama daily)indexer/src/api/cg.rs— do not treatliquidity_in_usdas TVLindexer/src/api/protocol_fees.rs+indexer/src/indexer/protocol_fees.rsindexer/src/indexer/protocol_tvl.rsindexer/src/indexer/volume_aggregator.rs+indexer/src/db/queries/volume.rsindexer/src/api/mod.rs— route tablesmartcontracts/packages/dex-common/src/factory.rs—Pairs/GetPairCountsmartcontracts/packages/dex-common/src/pair.rs—Pool {}smartcontracts/packages/dex-common/src/types.rs—PairInfo.contract_addrfrontend-dapp/src/utils/pairCatalogRank.ts—COLUMBUS5_GEM_ADDRESSESdocs/CG_CMC_COMPLIANCE.md,docs/integrators-hybrid-volume.md,docs/indexer-invariants.mddocs/runbooks/rotate-fee-treasury.md— factory + CMM pinsdocker/README.md— public indexer hostUpstream (PRs live there; keep copies or notes under
docs/+scripts/in this repo)DefiLlama-Adapters/projects/cl8y-dex/index.js(new)dimension-adapters/dexs/cl8y-dex/index.ts(new)dimension-adapters/fees/cl8y-dex/index.ts(new)dexs/garuda-defi(Terra Classic volume via their API)Recommended direction
1) TVL adapter (Llama-owned, on-chain)
New
projects/cl8y-dex/index.js:getAllPairs()loop:{ pairs: { limit: 30, start_after } }onchain: 'terra'until a short page.poolqueries (concurrency ~10) with retries.api.addeach asset; skip zero amounts.methodology,timetravel: false,terra: { tvl }.No indexer dependency for TVL.
2) Indexer UTC-day rollup + public read API
Add a calendar-day rollup (refresh on the existing volume/fee loop, not on GET):
date_utc(or unixstart_of_day):volume_usd,trade_count, fee USD byFeeSource,pricedvsunpricedflags.COLUMBUS5_GEM_ADDRESSES).swap_eventsonly (hybrid-safe).protocol_fee_events/ existing ingest (PFee / L7). Fail closed: activity + unpriced → JSONnullfor that dimension (same contract as overview USD), never silent"0"when trades exist.Public endpoints (names bikeshedable, keep under
/api/v1/):GET /api/v1/defillama/daily?timestamp=<unix_start_of_utc_day>{ date, volume_usd, fees: { swap_amm, book_take, limit_place, wrap, unwrap, ust1_mint, ust1_redeem }, methodology }400on non-day-aligned timestamp / future day;404if day not rolled yet;200with zeros only when the day is closed and idle.Dimension adapters
fetch(options)HTTP GET this URL (GarudaDeFi-style), withstart= first economic mainnet day (soft-launch / first non-gem swap — record the unix date in the adapter).3) Volume + fees adapters (Llama-owned)
dexs/cl8y-dex:dailyVolumefromvolume_usd;methodology.Volume;chains: [CHAIN.TERRA].fees/cl8y-dex: map sources →dailyFees/dailyRevenue/dailyProtocolRevenue; SSR0for commission; labeled wrap/window if included;breakdownMethodology.swap_amm+book_take+limit_place). Put wrap/window in the same adapter as extra labels or omit until a “CL8Y Wrap” listing. Default: include as labeled breakdowns so/protocoltreasury mix is not silently dropped.4) Docs + listing pack
docs/DEFILLAMA.md(or section indocs/integrators.md): methodology, endpoints, factory pin, gem exclude, hybrid volume, fee mapping, expected TVL drift vs/overview.docs/CG_CMC_COMPLIANCE.md(“not Llama”) anddocs/README.md.skills/AGENTS_DEFILLAMA.md+make verify-issue-NNNfor indexer tests.5) Submit and operate
https://defillama.com/protocol/cl8y-dex(or assigned slug) shows Terra Classic TVL + volume + fees.Acceptance criteria
node test.jsreturns a sane USD breakdown of pool tokens, not a single precomputed USD blob.Pairs+ pairPoolonly (plus documented optional wrap natives). No CG/CMC/overview USD.dailyVolumefor UTC days; numbers matchGET /api/v1/defillama/dailyand exclude gems, wrap, window, and fill double-counts.dailyFeesanddailyRevenuewithbreakdownMethodology; SSR is0(or documented non-zero only if a real LP transfer exists);spread_amountand community tax are not fees.400; missing day →404; idle closed day →"0"; unpriced-but-active →nullfor USD fields.#569.https://dex.cl8y.comis the website on the Llama protocol page after merge.make verify-issue-<iid>(or documented cargo/vitest set) is green for the indexer surface.Test plan (all paths)
Indexer (Postgres)
GET /api/v1/defillama/daily?timestamp=day0volume = economicswap_events.volume_usdonly (gem excluded; fills not added; wrap/window not in volume).limit_order_fills.commission_amount, not also swap-levelbook_commission_amount).volume_usdall null → volume fieldnull, not"0"."0"volume and fees.window=1;drop table/ negative / far-future →400.404.swap_events(cache or rollup-only EXPLAIN, same spirit asindexer_overview_global_stats).TVL adapter (fork +
node test.js)GetPairCount; each added balance is a pool reserve.$0).Pool {}(unit-style fixture if we vendor a tiny query helper in-repo for CI).Volume / fees adapters (
pnpm test dexs cl8y-dex,pnpm test fees cl8y-dex)startday both return dimensions.Volume,Fees,Revenue, …).breakdownMethodology.Cross-checks (columbus-5)
/api/v1/overview.total_liquidity_usd: same order of magnitude; document % gap (pricing)./overview.total_volume_24h_usd: must not be required to match (calendar vs trailing + gem filter).Docs / listing pack
COLUMBUS5_GEM_ADDRESSES.Test plan (attack, hack, abuse)
liquidity_in_usd(or ticker volume) as Llama TVLswap_events+limit_order_fillsindailyVolumespread_amount, burn tax, gas, hook fees, community-tax extra-debit asdailyFeesPool {}(and documented wrap natives).liquidity_tokenbalancessymbol=UST1on a gem contract)dailyVolume/defillama/*.timestamp400. No raw SQL interpolation.from=0&to=now)GetPairCountcross-check recommended; high pool-error rate fails the adapter.misrepresentedTokenspeg (UST1=$1, USTR=2.5×USTC) to juice TVL#569A7: Venus/CEX ticker is not a pool asset.CreatePairdust poolshttps://indexer.dex.cl8y.com(or documented host). No user-supplied URL./overview).Pool {}balanceOfof the pair (unless Llama later requires it). Do not add FoT delta math.Verification criteria
Issue is done when all of the following are true:
test.js/pnpm testlogs attached.make verify-issue-<iid>(indexer daily API + gem/hybrid/fee exclusions) passes on host Postgres (make setup-indexer-postgres).https://indexer.dex.cl8y.com/api/v1/defillama/daily?timestamp=<yesterday_utc>returns 200 and reconciles with a SQL check on prod-shaped data (or a redacted operator note).GetPairCountand a sample ofPool {}match the TVL adapter’s pair set / raw adds.dex.cl8y.com, non-zero or honestly-zero TVL, and volume/fees dimensions without using CGliquidity_in_usd.docs/README.mdlinks the playbook.Close is blocked if volume includes gems or fills, if TVL is sourced from the indexer USD fields, or if fees include
spread_amount/ token tax.Related
Addendum — UST1 / USTR follow-up (feat/631-ust1-ustr-llama)
Implemented on
feat/631-ust1-ustr-llama. Does not close this issue.ust1.peggedUSD, mechanism crypto-backed (ust1-window vs vFDUSD). Circulating = CW20 token_info.total_supply / 1e6. Price is hub / Llama — never $1. Product name unstablecoin.assets.ustr: DEX volume, pair fees, hub price. Not a second stablecoin. Not 2.5× USTC.cl8y-ust1issuer TVLGET /api/v1/defillama/dailynow includesassets.ust1andassets.ustr(O(1) fromdefillama_daily_assets). Invariants L631-10 (UST1 unstablecoin / no $1) and L631-11 (USTR reserve, not a stablecoin).In-repo adapter copy:
scripts/defillama/stablecoins/. Existing upstream: DefiLlama-Adapters#20676 (TVL), dimension-adapters#8987 (volume+fees, still draft until Coolify daily GET is live).marked as related to #216
marked as related to #189
marked as related to #569
marked as related to #586
marked as related to #562
marked as related to #548
marked as related to #550
marked as related to #629
mentioned in merge request !1143
In-repo surface for this listing is in !1143:
GET /api/v1/defillama/dailyUTC-day rollup (gem/hybrid/fee exclusions)scripts/defillama/docs/DEFILLAMA.md+skills/AGENTS_DEFILLAMA.mdmake verify-issue-631green (twice)Still needed before close: upstream DefiLlama-Adapters + dimension-adapters PRs, Coolify live daily check, and Llama UI after merge.
Upstream adapters filed
projects/cl8y-dexdexs/cl8y-dex+ feesfees/cl8y-dexThis-repo MR: https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/425
Still blocking close
GET /api/v1/defillama/daily.pnpm test dexs cl8y-dexandpnpm test fees cl8y-dexsucceed against yesterday UTC.https://defillama.com/protocol/cl8y-dex, Terra Classic,dex.cl8y.com).Notes
Addendum: UST1 on Stablecoins + USTR dimensions
Expanding #631 beyond the DEX adapters:
peggedassets-server,peggedUSD, crypto-backed via vFDUSD window). Circulating = CW20total_supply. Not a$1peg.GET /api/v1/defillama/dailyassets.ustr(volume, pair fees, hub price, circulating). Reserve token — not a second stablecoin.cl8y-ust1issuer TVL = vFDUSD in the window (separate from DEX TVL).Skipped: wrap-mapper wrapper listing, yields, emissions, treating USTR as USD-pegged.
Indexer + vendored adapters ship on !1143. Pegged-asset GitHub PR follows the same Coolify gate as volume/fees.
mentioned in commit
1ae62ca38f!1143 merged to
main(1ae62ca3) without waiting for CI.Merge problems (resolved):
631-feat-list-cl8y-dex-dex-cl8y-com-on-defillama-tvl-volume-fees-was reset to oldmainand had no DeFiLlama commits. Real work was onfeat/631-defillama(9f06e241+ wrap 1:1 follow-up). That tip was pushed onto the MR source before merge.20260825140000_*. DeFiLlama migration renamed to20260825150000_defillama_daily.sql. Localdex_indexer_testthat already applied the old20260825140000defillama checksum needs a DB recreate (VersionMismatch).Sanity: docs + gem lockstep +
cargo test --lib defillama+indexer_defillama5/5 + node adapter tests 9/9. L631-1–L631-9 covered bymake verify-issue-631except the script tail hiccup after integration (node tests re-run clean).Not merged (incomplete leftover in local stash
wip: incomplete #631 UST1/USTR daily assets + stablecoins adapter):defillama_daily_assetsGET fields +scripts/defillama/stablecoins/. Integration test failed: USTR-pair fees (0.08) were also attributed to UST1 (0.53vs expected0.45). Do not land until attribution is pair-leg-correct.Still operator (issue stays open):
GET https://indexer.dex.cl8y.com/api/v1/defillama/daily?timestamp=<00:00_utc>.scripts/defillama/(skill already links DefiLlama-Adapters#20676 and dimension-adapters#8987).dex.cl8y.com.mentioned in issue #638
marked as related to #638
Post-merge leftovers for the !1140/!1142/!1143/!1144/!1145 pass: #638.
UST1 / USTR follow-up (implemented on feat/631-ust1-ustr-llama)
Surfaces
ust1.peggedUSD, mechanism crypto-backed (ust1-window vs vFDUSD). Circulating = CW20 token_info.total_supply / 1e6. Price is hub / Llama — never $1. Product name unstablecoin.assets.ustr: DEX volume, pair fees, hub price. Not a second stablecoin. Not 2.5× USTC.cl8y-ust1issuer TVLIndexer
GET /api/v1/defillama/dailynow includesassets.ust1andassets.ustr(O(1) fromdefillama_daily_assets). Volume is UTC-day SUM(swap_events.volume_usd) on pairs whose either leg is that CW20 (gems still excluded; L10 once per swap). A UST1/USTR swap counts in both token volumes; headline DEX volume still once. UST1 fees include pair-linked PFee/L7 plusust1_mint/ust1_redeem.Invariants L631-10 (UST1 unstablecoin / no $1) and L631-11 (USTR reserve, not a stablecoin).
make verify-issue-631passes on this branch.Adapters
In-repo copies:
scripts/defillama/stablecoins/(peggedassetsust1). DEX TVL / volume / fees adapters are unchanged (UST1 circulating is not DEX TVL).Existing upstream: DefiLlama-Adapters#20676 (TVL), dimension-adapters#8987 (volume+fees, still draft until Coolify daily GET is live).
changed the description
peggedassets-server draft PR for UST1 unstablecoin: https://github.com/DefiLlama/peggedassets-server/pull/903
Circulating = CW20
token_info.total_supply/ 1e6.peggedUSD, crypto-backed, no $1 hardcode. dimension-adapters#8987 stays draft until Coolify daily GET is live.mentioned in merge request !1146
mentioned in merge request !1147
mentioned in issue #639
marked as related to #639
mentioned in commit
23f4224b1f!1147 merged to
mainMerged
!1147(feat/631-ust1-ustr-llama→main) without automerge and without waiting for CI. GitLab reportedcan_be_merged/ no conflicts (tip was one commit on currentmain).CI: pipeline
2788033808failed withci_quota_exceededon all jobs (not a code failure). Did not wait or retry.Sanity (
make verify-issue-631on the MR tip): 5/5liquidity_in_usdas TVLdefillama4/4indexer_defillama6/6 includingust1_ustr_asset_volume_fees_and_hub_price(UST1 volume 15, USTR volume 3, UST1 fees 0.45 = pair 0.40 + redeem 0.05, other-pair fee 1.00 not leaked, USTRpeg_typenull /categoryreserve)mapAsset+ circulatingtotal_supply / 1e6, never$1)Fee attribution: the earlier stash bug (USTR-pair fees counted on UST1,
0.53vs0.45) is addressed inrefresh_daily_assetsbytarget_pairs(pair legs must match the ticker CW20). Headline DEX volume still counts a UST1/USTR swap once.Not landed from local stash
wip: incomplete #631 UST1/USTR daily assets + stablecoins adapter: that stash is a stale subset of !1147 (docs + helper copies). Dropping it after this merge — do not re-apply.Test gap (non-blocking): integration does not seed a USTR-only pair +
swap_ammfee. Leak protection is covered by the unrelated pair1.00exclusion. Optional follow-up: add a USTR-only fee row expecting UST10.45/ USTR>0.Still operator (issue stays open):
GET /api/v1/defillama/daily?timestamp=<yesterday_utc>includesassets.ust1/assets.ustr(today’s live GET has noassetskey).token_info.total_supply/ 1e6 (no$1).dex.cl8y.com.Do not close #631 until Coolify assets + Llama UI criteria in the issue body are met.
mentioned in issue #640
mentioned in issue #641
mentioned in issue #646
mentioned in issue #652
mentioned in issue #667
mentioned in issue #668
mentioned in issue #677
mentioned in issue #682
mentioned in issue #683
mentioned in issue #685
mentioned in issue #687
marked as related to #687
mentioned in merge request !1187
mentioned in issue #688
mentioned in issue #689
mentioned in issue #692