mirror of
https://github.com/alexgo-io/DefiLlama-Adapters.git
synced 2026-01-12 08:34:23 +08:00
Add st supra tvl adapter (#16853)
Co-authored-by: prajwalghate <prajwalghate18@gmail.com>
This commit is contained in:
@@ -1,30 +1,32 @@
|
||||
const sdk = require("@defillama/sdk");
|
||||
const {
|
||||
invokeViewFunction,
|
||||
} = require("../helper/chain/supra");
|
||||
const { invokeViewFunction } = require("../helper/chain/supra");
|
||||
|
||||
const { transformBalances } = require("../helper/portedTokens");
|
||||
const coreTokensAll = require("../helper/coreAssets.json");
|
||||
|
||||
const CDP_GET_TOTAL_STATS_FUNCTION_TYPE =
|
||||
"0x9176f70f125199a3e3d5549ce795a8e906eed75901d535ded623802f15ae3637::cdp_multi::get_total_stats";
|
||||
|
||||
|
||||
const SUPRA_ADDR = "0x1::supra_coin::SupraCoin";
|
||||
const STSUPRA_ADDR =
|
||||
"0x81846514536430ea934c7270f86cf5b067e2a2faef0e91379b4f284e91c7f53c::vault_core::VaultShare";
|
||||
|
||||
const calculateSolidoTVL = async (api) => {
|
||||
const chain = api.chain;
|
||||
const coreTokens = Object.values(coreTokensAll[chain] ?? {});
|
||||
let balances = {};
|
||||
|
||||
// For each supported collateral type, get total stats
|
||||
for (const coinType of coreTokens) {
|
||||
const [totalCollateral, totalDebt] = await invokeViewFunction(
|
||||
CDP_GET_TOTAL_STATS_FUNCTION_TYPE,
|
||||
[coinType],
|
||||
[]
|
||||
);
|
||||
|
||||
if (totalCollateral > 0) {
|
||||
sdk.util.sumSingleBalance(balances, coinType, totalCollateral);
|
||||
}
|
||||
}
|
||||
// Fetch native SUPRA collateral
|
||||
const [SUPRA_TVL] = await invokeViewFunction(
|
||||
CDP_GET_TOTAL_STATS_FUNCTION_TYPE,
|
||||
[SUPRA_ADDR],
|
||||
[]
|
||||
);
|
||||
balances[SUPRA_ADDR] = BigInt(SUPRA_TVL);
|
||||
|
||||
const [stSUPRA_TVL] = await invokeViewFunction(
|
||||
CDP_GET_TOTAL_STATS_FUNCTION_TYPE,
|
||||
[STSUPRA_ADDR],
|
||||
[]
|
||||
);
|
||||
balances[STSUPRA_ADDR] = BigInt(stSUPRA_TVL);
|
||||
|
||||
return transformBalances(chain, balances);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user