Skip to content
Closed
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
2 changes: 1 addition & 1 deletion defi/src/adaptors/cli/backfillUtilities/auto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./../setup.ts"
import "../setup.ts"
import { autoBackfill } from "./backfillFunction"

(async () => {
Expand Down
13 changes: 1 addition & 12 deletions defi/src/adaptors/cli/backfillUtilities/getBackfillEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ import { sumAllVolumes } from "../../utils/volumeCalcs"

const DAY_IN_MILISECONDS = 1000 * 60 * 60 * 24

const KEYS_TO_CHECK = {
[AdapterType.FEES]: 'df',
[AdapterType.DEXS]: 'dv',
[AdapterType.INCENTIVES]: 'ti',
[AdapterType.AGGREGATORS]: 'dv',
[AdapterType.DERIVATIVES]: 'dv',
[AdapterType.OPTIONS]: 'dv',
[AdapterType.PROTOCOLS]: 'dv'
}

export default async (adapter: string[], adaptorType: AdapterType, cliArguments: ICliArgs) => {
// comment dexs that you dont want to backfill
const DEXS_LIST: string[] = [
Expand Down Expand Up @@ -153,8 +143,7 @@ export default async (adapter: string[], adaptorType: AdapterType, cliArguments:
const dates: Date[] = []
if (cliArguments.onlyMissing) {
let volTimestamps = {} as IJSON<boolean>
for (const type of [KEYS_TO_CHECK[adaptorType]]) {
console.log("Checking missing days for data type -> ", type)
for (const type of Object.keys(adaptorsData.KEYS_TO_STORE).slice(0, 1)) {
let vols = (await getAdaptorRecord(adapterData.id, type as AdaptorRecordType, adapterData.protocolType, "ALL"))
if (!(vols instanceof Array)) throw new Error("Incorrect volumes found")
vols = vols.map(removeEventTimestampAttribute)
Expand Down
25 changes: 7 additions & 18 deletions defi/src/adaptors/cli/checkNonEnabledDexs.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
import config from "../data/dexs/config";
import path from "path";
import getDirectories from "../utils/getDirectories";
import config from "../../adaptors/data/fees/config";
import config_new from "../data/fees/config";

const enabledDEXs = Object.entries(config).reduce((acc, [dex, enabled]) => {
if (enabled) acc.push(dex)
return acc
}, [] as string[])
const moduleKeys_old = Object.keys(config)
const modules_new = Object.keys(config_new)

// const adaptersList = Object.keys(adapters)
const adaptersList = getDirectories(path.resolve('../../DefiLlama-Adapters/volumes/adapters'))
// console.log(adaptersList)

// console.log("Adapters enabled")
// console.log("_______________________")
// enabledDEXs.forEach(enabledDex => console.log(enabledDex))
// console.log("\n")
console.log("Adapters NOT enabled")
adaptersList.forEach(adapter => {
if (!enabledDEXs.includes(adapter))
console.log("Adapters NOT included")
moduleKeys_old.forEach(adapter => {
if (!modules_new.includes(adapter))
console.log(adapter)
})
2 changes: 1 addition & 1 deletion defi/src/adaptors/cli/others/fixTimestamps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./../setup.ts"
import "../setup.ts"
import { removeAdaptorRecord, AdaptorRecordType, getAdaptorRecord, storeAdaptorRecord, AdaptorRecord, removeAdaptorRecordQuery } from "../../db-utils/adaptor-record"
import { ProtocolType } from "@defillama/dimension-adapters/adapters/types"
import getDataPoints from "../../utils/getDataPoints"
Expand Down
2 changes: 1 addition & 1 deletion defi/src/adaptors/cli/others/getCSV.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./../setup.ts"
import "../setup.ts"
import { getAdaptorRecord, AdaptorRecordType, AdaptorRecord } from "../../db-utils/adaptor-record"
import loadAdaptorsData from "../../data"
import { AdapterType, ProtocolType } from "@defillama/dimension-adapters/adapters/types"
Expand Down
2 changes: 1 addition & 1 deletion defi/src/adaptors/cli/others/removeAdaptorData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./../setup.ts"
import "../setup.ts"
import { removeAdaptorRecord, AdaptorRecordType } from "../../db-utils/adaptor-record"
import { ProtocolType } from "@defillama/dimension-adapters/adapters/types"

Expand Down
8 changes: 7 additions & 1 deletion defi/src/adaptors/cli/runGetOverview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ const event = {
// console.log(rr.protocols.filter(name=>name.name.toLowerCase().includes("uniswap") || name.name.toLowerCase().includes("pancakeswap")))
// console.log(rr.protocols[0])
console.log(rr.totalDataChart.length)
console.log(rr.protocols.length)
console.log(rr.protocols.filter(d=>d.module==='uniswap').map(d=>[
d.displayName,
`7d-> ${d.total7d}`,
`14d-> ${d.total14dto7d}`,
`30d-> ${d.total30d}`,
`60d-> ${d.total60dto30d}`,
]))
const runTime = (endTime - startTime) / 1000
const runTimeDescription = runTime > 30 ? '🐢' : '🐇'
console.log(`\nCurrent run ${runTimeDescription} (s): ${runTime}`)
Expand Down
11 changes: 5 additions & 6 deletions defi/src/adaptors/cli/runGetProtocolSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ import { performance } from "perf_hooks";
const start = performance.now()
const r = await handler({
pathParameters: {
name: "aave",
type: "fees"
name: "pancakeswap",
type: "dexs"
},
/* queryStringParameters: {
dataType: "dailyRevenue"
} */
} as unknown as AWSLambda.APIGatewayEvent)
const end = performance.now()
const d = JSON.parse(r.body) as Partial<IHandlerBodyResponse>
//console.log(d.totalDataChartBreakdown?.find(r=>+r[0]===Date.UTC(2022, 10, 23)/1000))
delete d['totalDataChart']
delete d['totalDataChartBreakdown']
console.log(d)
console.log(JSON.stringify(d.totalDataChartBreakdown?.slice(-5), null, 2))
console.log(d.totalDataChart?.slice(0, 5))
console.log(d.childProtocols)
console.log((end - start) / 1000)
//console.log(JSON.stringify(d, null, 2))
})()
145 changes: 145 additions & 0 deletions defi/src/adaptors/data/aggregators/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Protocol adaptor list is complete AGGREGATORS 1`] = `
Array [
Object {
"address": null,
"audit_links": Array [
"https://github.com/vantagepointreports/releases/blob/main/VPQ-20220418%20-%20Deflex%20-%20Smart%20Contract%20Audit%20of%20Deflex%20Protocol_Public_V1.1.pdf",
],
"audit_note": null,
"audits": "2",
"category": "Dexes",
"chain": "Algorand",
"chains": Array [
"algorand",
],
"cmcId": null,
"config": Object {
"enabled": true,
"id": "2420",
},
"description": "Deflex is an exchange infrastructure for best-in-class DeFi trading, leveraging Algorand's renowned efficiency by optimizing and combining liquidity of existing DEXs.",
"disabled": false,
"displayName": "Deflex",
"enabled": true,
"forkedFrom": Array [],
"gecko_id": null,
"id": "2420",
"listedAt": 1673354892,
"logo": "https://icons.llama.fi/deflex.png",
"methodology": Object {
"Fees": "Swap fees paid by users",
"HoldersRevenue": "Money going to governance token holders",
"ProtocolRevenue": "Percentage of swap fees going to treasury",
"Revenue": "Percentage of swap fees going to treasury and/or token holders",
"SupplySideRevenue": "Liquidity providers revenue",
"UserFees": "Swap fees paid by users",
},
"methodologyURL": "https://github.com/DefiLlama/dimension-adapters/blob/master/aggregators/deflex",
"module": "deflex",
"name": "Deflex",
"oracles": Array [],
"protocolType": undefined,
"symbol": "-",
"twitter": "deflexfi",
"url": "https://deflex.fi",
},
Object {
"address": null,
"audit_links": Array [
"https://github.com/BUIDLHub/dexible-contracts/blob/master/Audit%20Report%20-%20Dexible%20%5B16%20August%202021%5D.pdf",
],
"audit_note": null,
"audits": "1",
"category": "Dexes",
"chain": "Ethereum",
"chains": Array [
"ethereum",
"arbitrum",
"avax",
"bsc",
"fantom",
"optimism",
"polygon",
],
"cmcId": null,
"config": Object {
"enabled": true,
"id": "2249",
"protocolsData": Object {
"Dexible_v2": Object {
"displayName": "Dexible V2",
"enabled": true,
"id": "2249",
},
},
"startFrom": 1630022400,
},
"description": " DeFi's execution management system. Dexible is a DEX aggregator that also provides algo and automated order types normally only seen in CeFi.",
"disabled": false,
"displayName": "Dexible V2",
"enabled": true,
"forkedFrom": Array [],
"gecko_id": null,
"id": "2249",
"listedAt": 1667558693,
"logo": "https://icons.llama.fi/dexible.png",
"methodology": Object {
"Fees": "Swap fees paid by users",
"HoldersRevenue": "Money going to governance token holders",
"ProtocolRevenue": "Percentage of swap fees going to treasury",
"Revenue": "Percentage of swap fees going to treasury and/or token holders",
"SupplySideRevenue": "Liquidity providers revenue",
"UserFees": "Swap fees paid by users",
},
"methodologyURL": "https://github.com/DefiLlama/dimension-adapters/blob/master/aggregators/dexible",
"module": "dexible",
"name": "Dexible V2",
"protocolType": undefined,
"symbol": "-",
"twitter": "DexibleApp",
"url": "https://dexible.io",
"versionKey": "Dexible_v2",
},
Object {
"address": null,
"audit_note": null,
"audits": "0",
"category": "Dexes",
"chain": "Solana",
"chains": Array [
"solana",
],
"cmcId": null,
"config": Object {
"enabled": true,
"id": "2141",
},
"description": "The best swap aggregator & infrastructure for Solana - powering best price, token selection and UX for all users and devs",
"disabled": false,
"displayName": "Jupiter Aggregator",
"enabled": true,
"forkedFrom": Array [],
"gecko_id": null,
"id": "2141",
"listedAt": 1664608359,
"logo": "https://icons.llama.fi/jupiter-aggregator.png",
"methodology": Object {
"Fees": "Swap fees paid by users",
"HoldersRevenue": "Money going to governance token holders",
"ProtocolRevenue": "Percentage of swap fees going to treasury",
"Revenue": "Percentage of swap fees going to treasury and/or token holders",
"SupplySideRevenue": "Liquidity providers revenue",
"UserFees": "Swap fees paid by users",
},
"methodologyURL": "https://github.com/DefiLlama/dimension-adapters/blob/master/aggregators/jupiter-aggregator",
"module": "jupiter-aggregator",
"name": "Jupiter Aggregator",
"protocolType": undefined,
"symbol": "-",
"twitter": "JupiterExchange",
"url": "https://jup.ag/",
},
]
`;
18 changes: 14 additions & 4 deletions defi/src/adaptors/data/aggregators/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@ import { AdaptorsConfig } from "../types"

export default {
"jupiter-aggregator": {
enabled: true
"enabled": true,
"id": "2141"
},
"dexible": {
enabled: true,
startFrom: 1630022400
"enabled": true,
"startFrom": 1630022400,
"id": "2249",
protocolsData: {
Dexible_v2: {
"id": "2249",
enabled: true,
displayName: "Dexible V2"
}
}
},
"deflex": {
enabled: true,
"enabled": true,
"id": "2420"
}
} as AdaptorsConfig
33 changes: 33 additions & 0 deletions defi/src/adaptors/data/aggregators/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { AdapterType } from '@defillama/dimension-adapters/adapters/types';
//import { writeFile } from 'fs';
//import { config } from './protocols';
import data from '../index'
//import { IJSON } from './types';

describe("Protocol adaptor list is complete", () => {
it("AGGREGATORS", () => {
const d = data(AdapterType.AGGREGATORS).default
expect(d).toMatchSnapshot()
});
});


/* const formatted = Object.entries(config).reduce((acc, [module, config]) => {
const findd = d.find(sm => sm.module === module)?.id
if (!findd) throw new Error(`not found! ${module}`)
acc[module] = {
...config,
id: findd
}
return acc
}, {} as IJSON<any>)
writeFile(`./src/adaptors/data/${type}/new_config.ts`, `
export default
${JSON.stringify(formatted, null, 2)}

`, err => {
if (err) {
console.error(err);
}
// file written successfully
}); */
4 changes: 2 additions & 2 deletions defi/src/adaptors/data/aggregators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export const KEYS_TO_STORE = {

export { default as config } from "./config";

export { default as dex_imports } from "../../../utils/imports/dexs_adapters"
export { default as aggregators_imports } from "../../../utils/imports/aggregators_adapters"

export default generateProtocolAdaptorsList(aggregators_imports, config)
4 changes: 2 additions & 2 deletions defi/src/adaptors/data/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const configs = {
export const getConfigByType = (type: string, module: string) => configs[type]?.[module]

export const getAvailableMetricsByModule = (modulePath: string) => Object.entries(configs).reduce((acc, [metric, map]) => {
const [module] = modulePath.split("/")[0].split(/[/.-]+/)
const isMetricEnabled = map?.[module.toLocaleLowerCase()]?.enabled
const [module] = modulePath.split("/")[0].split(/[/.]+/)
const isMetricEnabled = map?.[module]?.enabled
if (isMetricEnabled === true)
acc[metric] = isMetricEnabled
return acc
Expand Down
Loading