Skip to content

Commit

Permalink
alex: turn on chain (#11265)
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Aug 14, 2024
1 parent ad3396b commit 4664b24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 31 deletions.
1 change: 0 additions & 1 deletion projects/alexlab/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { call } = require('../helper/chain/stacks-api')
const { getCache, setCache } = require('../helper/cache')
const { transformDexBalances } = require('../helper/portedTokens')
const { sleep } = require('../helper/utils')
const sdk = require('@defillama/sdk')

Expand Down
35 changes: 5 additions & 30 deletions projects/alexlab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,16 @@ const { get } = require('../helper/http')
// https://stacks-node-api.blockstack.org/extended/v1/address/SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.alex-vault/balances
const ALEX_API = "https://api.alexlab.co/v1";

async function fetch() {
const url = `${ALEX_API}/pool_token_stats`;
const alexStatsResponse = await get(url)

const valueLockedMap = {};
let totalValueLocked = 0;
for (const pool of alexStatsResponse) {
let poolValue = 0;
const poolToken = pool.pool_token;

if (poolToken == "age000-governance-token") {
poolValue = pool.price * pool.reserved_balance;
} else {
poolValue = pool.price * pool.total_supply;
}
totalValueLocked += poolValue;
valueLockedMap[poolToken] = poolValue;
}

return { tether: totalValueLocked };
}

async function staking() {
const url = `${ALEX_API}/stats/tvl`;
const alexResponse = await get(url)
return { tether: alexResponse.reserve_pool_value };
}
const { getExports } = require('../helper/heroku-api')

// node test.js projects/alexlab/index.js
module.exports = {
misrepresentedTokens: true,
timetravel: false,
stacks: {
tvl: fetch,
staking,
},
methodology: "Alex Lab TVL is sum of tokens locked in ALEX platform.",
};
...getExports("alexlab", ['stacks']),
}

module.exports.stacks.staking = staking

0 comments on commit 4664b24

Please sign in to comment.