1+ // Zealous Swap (Kasplex) — Pools adapter for DefiLlama yield-server
2+ // Pulls per-pool TVL (USD) and APR directly from our public API.
3+ //
4+ // Endpoint used: https://kasplex.zealousswap.com/v1/pools
5+ // Notes:
6+ // - We use `apr` from our API as `apyBase` (already annualized %).
7+ // - If `apr` is missing, we fall back to fee APR from volume * feeRate.
8+ // - We include `apyReward` only if our API reports a positive `farmApr`.
9+ // - Only emit pools with `hasUSDValues === true` and tvl > 10000 to avoid noise.
10+
11+ const axios = require ( "axios" ) ;
12+
13+ const CHAIN = "kasplex" ;
14+ const API = "https://kasplex.zealousswap.com/v1/pools" ;
15+
16+ function toNumber ( x ) {
17+ if ( x === null || x === undefined ) return 0 ;
18+ const n = Number ( x ) ;
19+ return Number . isFinite ( n ) ? n : 0 ;
20+ }
21+
22+ function poolSymbol ( p ) {
23+ const s0 = p . token0 ?. symbol || "T0" ;
24+ const s1 = p . token1 ?. symbol || "T1" ;
25+ return `${ s0 } -${ s1 } ` ;
26+ }
27+
28+ function calcFeeAPR ( volumeUSD , tvlUsd , feeRate ) {
29+ const vol = toNumber ( volumeUSD ) ;
30+ const tvl = toNumber ( tvlUsd ) ;
31+ const fee = toNumber ( feeRate ) ;
32+ if ( tvl <= 0 || vol <= 0 || fee <= 0 ) return 0 ;
33+ return ( vol * fee / tvl ) * 365 * 100 ;
34+ }
35+
36+ async function apy ( ) {
37+ const { data } = await axios . get ( API ) ;
38+ const poolsObj = data ?. pools || { } ;
39+
40+ const results = [ ] ;
41+
42+ for ( const [ address , p ] of Object . entries ( poolsObj ) ) {
43+
44+ if ( ! p ?. hasUSDValues ) continue ;
45+ const tvlUsd = toNumber ( p . tvl ) ;
46+ if ( ! ( tvlUsd > 0 ) ) continue ;
47+
48+ let apyBase = toNumber ( p . apr ) ;
49+
50+ if ( ! ( apyBase > 0 ) ) {
51+ const feeRate = p . regularFeeRate ?? p . discountedFeeRate ?? 0.003 ;
52+ apyBase = calcFeeAPR ( p . volumeUSD , tvlUsd , feeRate ) ;
53+ }
54+
55+ const apyReward = toNumber ( p . farmApr ) > 0 ? toNumber ( p . farmApr ) : null ;
56+
57+ results . push ( {
58+ pool : `${ address } -${ CHAIN } ` ,
59+ chain : CHAIN ,
60+ project : "zealousswap" ,
61+ symbol : poolSymbol ( p ) ,
62+ tvlUsd,
63+ apyBase,
64+ apyReward,
65+ rewardTokens : p . hasActiveFarm
66+ ? [ "0xb7a95035618354D9ADFC49Eca49F38586B624040" ]
67+ : [ ] ,
68+ underlyingTokens : [ p . token0 ?. address , p . token1 ?. address ] . filter ( Boolean ) ,
69+ url : "https://app.zealousswap.com/liquidity" ,
70+ poolMeta : "Zealous Swap spot pool" ,
71+ volumeUsd1d : toNumber ( p . volumeUSD ) ,
72+ } ) ;
73+ }
74+
75+ return results . filter ( x => Number . isFinite ( x . tvlUsd ) && x . tvlUsd >= 10000 ) ;
76+ }
77+
78+ module . exports = {
79+ timetravel : false ,
80+ apy,
81+ } ;
0 commit comments