Skip to content
Draft
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions defi/src/api2/cron-task/appMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as sdk from "@defillama/sdk";

// import { pullDevMetricsData } from "./githubMetrics";
import { chainNameToIdMap, extraSections } from "../../utils/normalizeChain";
import protocols from "../../protocols/data";
import protocols, { _InternalProtocolMetadataMap } from "../../protocols/data";
import parentProtocols from "../../protocols/parentProtocols";
import { bridgeCategoriesSet } from "../../utils/excludeProtocols";
import { IChainMetadata, IProtocolMetadata } from "./types";
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function storeAppMetadata() {
// await pullRaisesDataIfMissing(); // not needed anymore as raises data is always updated before this line is invoked
// await pullDevMetricsData(); // we no longer use this data
await _storeAppMetadata();

} catch (e) {
console.log("Error in storeAppMetadata: ", e);
console.error(e);
Expand Down Expand Up @@ -206,7 +206,9 @@ async function _storeAppMetadata() {
continue;
}
const slugName: string = slug(protocol.name);
const hasTvl = protocol.tvl != null && protocolInfo.module != null && protocolInfo.module !== "dummy.js" ? true : false
let { hasTvl } = _InternalProtocolMetadataMap[protocol.id] || {};

hasTvl = protocol.tvl != null && hasTvl
const hasBorrowed = protocol.currentChainTvls?.borrowed != null ? true : false
finalProtocols[protocol.defillamaId] = {
name: slugName,
Expand Down
5 changes: 2 additions & 3 deletions defi/src/api2/utils/craftProtocolV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ export async function craftProtocolV2({
skipFeMiniTransform = false,
}: CraftProtocolV2Options) {
const { misrepresentedTokens = false, ...restProtocolData } = protocolData as any
const { hallmarks } = _InternalProtocolMetadataMap[protocolData.id] || {};
const { hallmarks, hasTvl } = _InternalProtocolMetadataMap[protocolData.id] || {};

// protocol module is set to dummy.js if we are not tracking tvl of a given protocol
const isDummyProtocol = protocolData.module === "dummy.js";
const isDummyProtocol = !hasTvl

const debug_t0 = performance.now(); // start the timer
let protocolCache: any = {}
Expand Down
2 changes: 1 addition & 1 deletion defi/src/cli/fillLast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const main = async () => {
4,
false,
true,
protocol.module !== "dummy.js",
!!protocol.module,
undefined,
{ overwriteExistingData: true }
);
Expand Down
6 changes: 4 additions & 2 deletions defi/src/cli/protocolStats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as fs from "fs";
import protocols, { Protocol } from "../protocols/data";
import protocols, { _InternalProtocolMetadataMap, Protocol } from "../protocols/data";
import { PromisePool } from '@supercharge/promise-pool'
import * as sdk from '@defillama/sdk'
import { hourlyTvl, getLastRecord } from "../utils/getLastRecord";
Expand All @@ -21,7 +21,9 @@ async function cacheProtocolData() {
.process(async (protocol: any) => {
const startTime = +Date.now()
const adapterModule = importAdapter(protocol)
if (protocol.module === 'dummy.js' || protocol.rugged || adapterModule.deadFrom) {
let { hasTvl } = _InternalProtocolMetadataMap[protocol.id] || {};

if (!hasTvl || protocol.rugged || adapterModule.deadFrom) {
i++
protocol.skipped = true
res.push(protocol)
Expand Down
8 changes: 5 additions & 3 deletions defi/src/getProtocols.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import protocols, { Protocol } from "./protocols/data";
import protocols, { _InternalProtocolMetadataMap, Protocol } from "./protocols/data";
import { getLastRecord, hourlyTvl, hourlyUsdTokensTvl } from "./utils/getLastRecord";
import sluggify from "./utils/sluggify";
import {
Expand Down Expand Up @@ -377,7 +377,9 @@ export async function craftProtocolsResponseInternal(
includeTokenBreakdowns ? getLastHourlyTokensUsd(protocol) : {},
]);

if (!lastHourlyRecord && protocol.module !== "dummy.js") {
const { hasTvl } = _InternalProtocolMetadataMap[protocol.id] || {};

if (!lastHourlyRecord && hasTvl) {
return null;
}

Expand All @@ -387,7 +389,7 @@ export async function craftProtocolsResponseInternal(
const chainTvls: ITvlsByChain = {};
const chains: string[] = [];

if (protocol.module !== "dummy.js" && lastHourlyRecord) {
if (hasTvl && lastHourlyRecord) {
Object.entries(lastHourlyRecord).forEach(([chain, chainTvl]) => {
if (nonChains.includes(chain)) {
return;
Expand Down
3 changes: 1 addition & 2 deletions defi/src/protocols/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test("Github: track only orgs", async () => {

test("projects have a single chain or each chain has an adapter", async () => {
for (const protocol of protocols) {
if (protocol.module === 'dummy.js') continue;
if (!protocol.module) continue;
const module = await importAdapterDynamic(protocol)
const chains = protocol.module.includes("volumes/") ? Object.keys(module) : protocol.chains.map((chain) => normalizeChain(chain));
if (chains.length > 1) {
Expand Down Expand Up @@ -326,7 +326,6 @@ test("no module repeated", async () => {
const ids = [];
for (const protocol of protocols) {
const script = protocol.module
if (script === 'dummy.js') continue; // dummy.js is an exception
if (script === 'anyhedge/index.js') continue; // anyhedge/index.js is an exception, used as short hand for skipping tvl update
expect(ids).not.toContain(script);
ids.push(script);
Expand Down
2 changes: 1 addition & 1 deletion defi/src/protocols/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function setProtocolMetadata(protocol: Protocol) {
slugTagSet,
isDoublecounted,
isDead: !!module.deadFrom,
hasTvl: protocol.module !== 'dummy.js',
hasTvl: !!(protocol.module && protocol.module !== 'dummy.js'),
misrepresentedTokens: !!module.misrepresentedTokens,
methodology: module.methodology,
hallmarks: module.hallmarks,
Expand Down
2 changes: 0 additions & 2 deletions defi/src/protocols/data1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2074,7 +2074,6 @@ const data: Protocol[] = [
cmcId: null, //"3513",
category: "Chain",
chains: ["Fantom"],
module: "dummy.js",
twitter: "FantomFDN",
},
{
Expand Down Expand Up @@ -4282,7 +4281,6 @@ const data: Protocol[] = [
category: "Chain",
chains: ["Stacks"],
// module: "stacks/index.js",
module: "dummy.js",
twitter: "Stacks",
github: ["stacks-network"],
},
Expand Down
Loading