Skip to content

Commit a44d479

Browse files
jaimi-iog1nt0ki
andauthored
Add dexalot tvl adapter (DefiLlama#11318)
* add dexalot tvl adapter * refactor tvl via sumTokens2 for avax,arb+base to helper file * add adapter for dexalot bridge * minor refactor * minor refactor --------- Co-authored-by: g1nt0ki <[email protected]>
1 parent 9733fd8 commit a44d479

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

projects/dexalot-bridge/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { exportDexalotTVL } = require("../dexalot/helper");
2+
3+
module.exports = exportDexalotTVL("Portfolio")

projects/dexalot/helper.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const { sumTokens2 } = require('../helper/unwrapLPs')
2+
const { get } = require("../helper/http");
3+
4+
const dexalotTradingAPI = "https://api.dexalot.com/privapi/trading"
5+
6+
// [chain]: env
7+
const supportedChains = {
8+
"arbitrum": "production-multi-arb",
9+
"avax": "production-multi-avax",
10+
"base": "production-multi-base"
11+
}
12+
13+
function getTVL(env, contractName) {
14+
return async (api) => {
15+
const contract = await get(`${dexalotTradingAPI}/deployment?contracttype=${contractName}&env=${env}`)
16+
const allTokens = await get(`${dexalotTradingAPI}/tokens`)
17+
const tokens = allTokens.filter((t) => !t.isvirtual && t.env === env).map((t) => t.address)
18+
return sumTokens2({ api, owner: contract[0].address, tokens })
19+
}
20+
}
21+
22+
// Returns TVL for each supported chain (excludes Dexalot chain)
23+
function exportDexalotTVL(contractName) {
24+
const res = {}
25+
for (const [chain, env] of Object.entries(supportedChains)) {
26+
res[chain] = {tvl: getTVL(env, contractName)}
27+
}
28+
return res
29+
}
30+
31+
module.exports = {
32+
exportDexalotTVL
33+
}

projects/dexalot/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const { get } = require("../helper/http");
2+
const { exportDexalotTVL } = require("./helper");
3+
4+
const dexalotAPI = "https://api.dexalot.com"
5+
6+
async function getDexalotChainLockedOrders(_) {
7+
const lockedTokens = await get(`${dexalotAPI}/api/stats/orderstvl`)
8+
const res = {}
9+
for (const {coingecko_id, amount} of lockedTokens) {
10+
// Ignore counting tokens without coingecko_id
11+
if (coingecko_id == null) {
12+
continue
13+
}
14+
res[coingecko_id] = amount
15+
}
16+
return res
17+
}
18+
19+
module.exports = {
20+
methodology: "Dexalot TVL is comprised of the token balances locked in the MainnetRFQ (swap) contracts and the value locked in open orders on the Dexalot chain.",
21+
dexalot: {
22+
tvl: getDexalotChainLockedOrders,
23+
},
24+
...exportDexalotTVL("MainnetRFQ")
25+
}

projects/helper/chains.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"defichain_evm",
8282
"defiverse",
8383
"degen",
84+
"dexalot",
8485
"dexit",
8586
"dfs",
8687
"dfk",

0 commit comments

Comments
 (0)