Skip to content

Commit

Permalink
Add dexalot tvl adapter (#11318)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
jaimi-io and g1nt0ki authored Aug 16, 2024
1 parent 9733fd8 commit a44d479
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions projects/dexalot-bridge/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { exportDexalotTVL } = require("../dexalot/helper");

module.exports = exportDexalotTVL("Portfolio")
33 changes: 33 additions & 0 deletions projects/dexalot/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { sumTokens2 } = require('../helper/unwrapLPs')
const { get } = require("../helper/http");

const dexalotTradingAPI = "https://api.dexalot.com/privapi/trading"

// [chain]: env
const supportedChains = {
"arbitrum": "production-multi-arb",
"avax": "production-multi-avax",
"base": "production-multi-base"
}

function getTVL(env, contractName) {
return async (api) => {
const contract = await get(`${dexalotTradingAPI}/deployment?contracttype=${contractName}&env=${env}`)
const allTokens = await get(`${dexalotTradingAPI}/tokens`)
const tokens = allTokens.filter((t) => !t.isvirtual && t.env === env).map((t) => t.address)
return sumTokens2({ api, owner: contract[0].address, tokens })
}
}

// Returns TVL for each supported chain (excludes Dexalot chain)
function exportDexalotTVL(contractName) {
const res = {}
for (const [chain, env] of Object.entries(supportedChains)) {
res[chain] = {tvl: getTVL(env, contractName)}
}
return res
}

module.exports = {
exportDexalotTVL
}
25 changes: 25 additions & 0 deletions projects/dexalot/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { get } = require("../helper/http");
const { exportDexalotTVL } = require("./helper");

const dexalotAPI = "https://api.dexalot.com"

async function getDexalotChainLockedOrders(_) {
const lockedTokens = await get(`${dexalotAPI}/api/stats/orderstvl`)
const res = {}
for (const {coingecko_id, amount} of lockedTokens) {
// Ignore counting tokens without coingecko_id
if (coingecko_id == null) {
continue
}
res[coingecko_id] = amount
}
return res
}

module.exports = {
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.",
dexalot: {
tvl: getDexalotChainLockedOrders,
},
...exportDexalotTVL("MainnetRFQ")
}
1 change: 1 addition & 0 deletions projects/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"defichain_evm",
"defiverse",
"degen",
"dexalot",
"dexit",
"dfs",
"dfk",
Expand Down

0 comments on commit a44d479

Please sign in to comment.