Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JVault #11269

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions projects/jvault/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { sumTokensExport } = require("../helper/chain/ton");
const sdk = require("@defillama/sdk");
const ADDRESSES = require("../helper/coreAssets.json");
const { fetchURL } = require('../helper/utils');

async function getTvl(api) {
const balances = {};

// API is used to get all vaults and their TVLs to avoid scan of all blockchain for matching vaults
// also Jettons values are converted to TON using DEXs prices
const response = await fetchURL("https://jvault.xyz/staking/stake?type=json")
for (const pool of response.data.pools) {
sdk.util.sumSingleBalance(balances, ADDRESSES.ton.TON, pool.ton_tvl * 1e9, api.chain)
}
return balances;
}


module.exports = {
methodology: 'Counts balances of all tokens based on DEXs prices in all vaults.',
timetravel: false,
ton: {
tvl: (api) => getTvl(api)
}
}
Loading