Skip to content

Commit

Permalink
Merge pull request DefiLlama#1259 from DefiLlama/docs
Browse files Browse the repository at this point in the history
Docs Work
  • Loading branch information
waynebruce0x authored Mar 6, 2024
2 parents a46529d + 9a57798 commit e924265
Show file tree
Hide file tree
Showing 110 changed files with 524 additions and 372 deletions.
2 changes: 1 addition & 1 deletion adapters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export type BaseAdapter = {
start: IStartTimestamp | number
fetch: Fetch|FetchV2;
runAtCurrTime?: boolean;
customBackfill?: Fetch;
customBackfill?: Fetch|FetchV2;
meta?: {
methodology?: string | IJSON<string>
hallmarks?: [number, string][]
Expand Down
2 changes: 1 addition & 1 deletion cli/testAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const passedFile = path.resolve(process.cwd(), `./${adapterType}/${process.argv[
const adapterVersion = module.version
let timestamp = endCleanDayTimestamp
if (adapterVersion === 2) {
timestamp = process.argv[4] ? +process.argv[4] : getTimestamp30MinutesAgo()
timestamp = (process.argv[4] ? +process.argv[4] : getTimestamp30MinutesAgo()) - 86400 // 1 day;
}
console.info(`${upperCaseFirst(adapterType)} for ${formatTimestampAsDate(String(getUniqStartOfTodayTimestamp(new Date(timestamp * 1000))))}`)
console.info(`_______________________________________\n`)
Expand Down
1 change: 1 addition & 0 deletions dexs/3xcalibur/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ARBITRUM]: {
fetch: graphs(CHAIN.ARBITRUM),
Expand Down
1 change: 1 addition & 0 deletions dexs/ArbitrumExchange/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const startTimeV3:TStartTime = {
[CHAIN.ARBITRUM]: 1683590400,
}
const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v2: {
[CHAIN.ARBITRUM]: {
Expand Down
44 changes: 22 additions & 22 deletions dexs/DerpDEX/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ import { CHAIN } from "../../helpers/chains";
import { getGraphDimensions } from "../../helpers/getUniSubgraph";

const endpoints = {
[CHAIN.ERA]: "https://api.studio.thegraph.com/query/49147/derpdex-v3-amm/v0.0.10",
[CHAIN.BASE]: "https://api.thegraph.com/subgraphs/name/geckocoding/derpdex-amm-base",
[CHAIN.OP_BNB]: "https://opbnb.subgraph.derpdex.com/subgraphs/name/geckocoding/derpdex-opbnb"
[CHAIN.ERA]:
"https://api.studio.thegraph.com/query/49147/derpdex-v3-amm/v0.0.10",
[CHAIN.BASE]:
"https://api.thegraph.com/subgraphs/name/geckocoding/derpdex-amm-base",
[CHAIN.OP_BNB]:
"https://opbnb.subgraph.derpdex.com/subgraphs/name/geckocoding/derpdex-opbnb",
};
const v3StartTimes = {
[CHAIN.ERA]: 1688515200,
[CHAIN.BASE]: 1692296100,
[CHAIN.OP_BNB]: 1695275237,
};

const v3Graphs = getGraphDimensions({
Expand All @@ -17,7 +25,7 @@ const v3Graphs = getGraphDimensions({
dailyVolume: {
factory: "uniswapDayData",
field: "volumeUSD",
dateField: "date"
dateField: "date",
},
dailyFees: {
factory: "uniswapDayData",
Expand All @@ -29,25 +37,17 @@ const v3Graphs = getGraphDimensions({
HoldersRevenue: 0,
UserFees: 100, // User fees are 0% of collected fees
SupplySideRevenue: 100, // 100% of fees are going to LPs
Revenue: 0 // Revenue is 0% of collected fees
}
Revenue: 0, // Revenue is 0% of collected fees
},
});

const adapter: Adapter = {
adapter: {
[CHAIN.ERA]: {
fetch: v3Graphs(CHAIN.ERA),
start: 1688515200
},
[CHAIN.BASE]: {
fetch: v3Graphs(CHAIN.BASE),
start: 1692296100
},
[CHAIN.OP_BNB]: {
fetch: v3Graphs(CHAIN.OP_BNB),
start: 1695275237
}
}
};
const adapter: Adapter = { adapter: {}, version: 2 };

Object.keys(endpoints).map((chain: string) => {
adapter.adapter[chain] = {
fetch: v3Graphs(chain),
start: v3StartTimes[chain],
};
});

export default adapter;
40 changes: 16 additions & 24 deletions dexs/SmarDex/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ const graphRequestHeaders:IMap = {
[CHAIN.POLYGON]: defaultHeaders,
};

const startTimes = {
[CHAIN.ARBITRUM]: 1689582249,
[CHAIN.BASE]: 1691491872,
[CHAIN.BSC]: 1689581494,
[CHAIN.ETHEREUM]: 1678404995,
[CHAIN.POLYGON]: 1689582144,
}

/**
* @note We are using this method that allow us to use http headers
* The method `getGraphDimensions` try returns daily fees and total fees
Expand All @@ -58,29 +66,13 @@ const graphs = getGraphDimensions({
},
});

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.ETHEREUM]: {
fetch: graphs(CHAIN.ETHEREUM),
start: 1678404995, // birthBlock timestamp
},
[CHAIN.BSC]: {
fetch: graphs(CHAIN.BSC),
start: 1689581494,
},
[CHAIN.POLYGON]: {
fetch: graphs(CHAIN.POLYGON),
start: 1689582144,
},
[CHAIN.ARBITRUM]: {
fetch: graphs(CHAIN.ARBITRUM),
start: 1689582249,
},
[CHAIN.BASE]: {
fetch: graphs(CHAIN.BASE),
start: 1691491872,
},
},
};
const adapter: SimpleAdapter = { adapter: {}, version: 2 }

Object.keys(graphUrls).map((chain: string) => {
adapter.adapter[chain] = {
fetch: graphs(chain),
start: startTimes[chain]
}
})

export default adapter;
1 change: 1 addition & 0 deletions dexs/agni-fi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const v3Graphs = getGraphDimensions({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.MANTLE]: {
fetch: v3Graphs(CHAIN.MANTLE),
Expand Down
1 change: 1 addition & 0 deletions dexs/archly-finance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const graphFetch = getGraphDimensions({
});

const adapter: Adapter = {
version: 2,
adapter: {
[CHAIN.TELOS]: {
fetch: graphFetch(CHAIN.TELOS),
Expand Down
1 change: 1 addition & 0 deletions dexs/ascent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const graphsV3 = getChainVolume({


const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v2: {
[CHAIN.EON]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/auragi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ARBITRUM]: {
fetch: graphs(CHAIN.ARBITRUM),
Expand Down
8 changes: 4 additions & 4 deletions dexs/balancer/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chain } from "@defillama/sdk/build/general";
import request, { gql } from "graphql-request";
import { BaseAdapter, BreakdownAdapter, ChainEndpoints, FetchResultVolume } from "../../adapters/types";
import { BaseAdapter, BreakdownAdapter, ChainEndpoints, FetchResultV2, FetchResultVolume, FetchV2 } from "../../adapters/types";
import { CHAIN } from "../../helpers/chains";
import customBackfill from "../../helpers/customBackfill";
import { getStartTimestamp } from "../../helpers/getStartTimestamp";
Expand Down Expand Up @@ -37,8 +37,8 @@ interface IPoolSnapshot {


const v2Graphs = (chain: Chain) => {
return async (timestamp: number): Promise<FetchResultVolume> => {
const startTimestamp = getTimestampAtStartOfDayUTC(timestamp)
return async ({ endTimestamp }): Promise<FetchResultV2> => {
const startTimestamp = getTimestampAtStartOfDayUTC(endTimestamp)
const fromTimestamp = startTimestamp - 60 * 60 * 24
const toTimestamp = startTimestamp
const graphQuery = gql
Expand All @@ -62,7 +62,6 @@ const v2Graphs = (chain: Chain) => {

return {
dailyVolume: `${dailyVolume}`,
timestamp,
};
};
};
Expand All @@ -76,6 +75,7 @@ const v1graphs = getChainVolume({
});

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v1: {
[CHAIN.ETHEREUM]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/baseswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const startTimeV3 = {
};

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v2: Object.keys(v2Endpoints).reduce((acc, chain) => {
return {
Expand Down
1 change: 1 addition & 0 deletions dexs/beamswap-v3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const methodologyv3 = {
};

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v3: {
[CHAIN.MOONBEAN]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/beamswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const methodologyStable = {
};

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
classic: {
[CHAIN.MOONBEAN]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/butterxyz/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const dimensions = getGraphDimensions({
});

export default {
version: 2,
adapter: {
[CHAIN.MANTLE]: {
fetch: dimensions(CHAIN.MANTLE),
Expand Down
1 change: 1 addition & 0 deletions dexs/carthage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const v3Graphs = getChainVolume({
});

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v3: {
[CANDLE]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/champagneswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[DISABLED_ADAPTER_KEY]: disabledAdapter,
[BSC]: {
Expand Down
1 change: 1 addition & 0 deletions dexs/cherryswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.OKEXCHAIN]: {
fetch: graphs(CHAIN.OKEXCHAIN),
Expand Down
1 change: 1 addition & 0 deletions dexs/clipper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const graphs = getChainVolume({


const adapter: SimpleAdapter = {
version: 2,
adapter: Object.keys(endpoints).reduce((acc, chain: any) => {
return {
...acc,
Expand Down
1 change: 1 addition & 0 deletions dexs/crescent-swap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.ARBITRUM]: {
fetch: graphs(CHAIN.ARBITRUM),
Expand Down
1 change: 1 addition & 0 deletions dexs/cryptoswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const graphs = getChainVolume({
});

const adapter: SimpleAdapter = {
version: 2,
adapter: {
[CHAIN.BSC]: {
fetch: graphs(CHAIN.BSC),
Expand Down
1 change: 1 addition & 0 deletions dexs/dackieswap-v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const methodology = {
};

const adapter: SimpleAdapter = {
version: 2,
adapter: Object.keys(endpoints).reduce((acc, chain) => {
return {
...acc,
Expand Down
30 changes: 11 additions & 19 deletions dexs/dackieswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const v3Endpoint = {
[CHAIN.OPTIMISM]:
"https://api.studio.thegraph.com/query/50473/v3-optimism/version/latest",
[CHAIN.ARBITRUM]:
"https://api.studio.thegraph.com/query/50473/v3-arbitrum/version/latest",
"https://api.studio.thegraph.com/query/50473/v3-arbitrum/version/latest",
};

const VOLUME_USD = "volumeUSD";
Expand All @@ -23,12 +23,12 @@ const v3Graph = getGraphDimensions({
factory: "pancakeDayData",
field: VOLUME_USD,
},
totalFees:{
totalFees: {
factory: "factories",
},
dailyFees: {
factory: "pancakeDayData",
field: "feesUSD"
field: "feesUSD",
},
});

Expand All @@ -38,21 +38,13 @@ const v3StartTimes = {
[CHAIN.ARBITRUM]: 1707885300,
} as IJSON<number>;

const adapter: SimpleAdapter = {
adapter: {
[CHAIN.BASE]: {
fetch: v3Graph(CHAIN.BASE),
start: async () => v3StartTimes[CHAIN.BASE]
},
[CHAIN.OPTIMISM]: {
fetch: v3Graph(CHAIN.OPTIMISM),
start: async () => v3StartTimes[CHAIN.OPTIMISM]
},
[CHAIN.ARBITRUM]: {
fetch: v3Graph(CHAIN.ARBITRUM),
start: async () => v3StartTimes[CHAIN.ARBITRUM]
},
},
};
const adapter: SimpleAdapter = { adapter: {}, version: 2 };

Object.keys(v3StartTimes).map((chain: string) => {
adapter.adapter[chain] = {
fetch: v3Graph(chain),
start: v3StartTimes[chain],
};
});

export default adapter;
1 change: 1 addition & 0 deletions dexs/doveswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const startTimeV3:TStartTime = {

}
const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v3: Object.keys(v3Endpoints).reduce((acc, chain) => {
acc[chain] = {
Expand Down
10 changes: 2 additions & 8 deletions dexs/dragonswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const v3Graph = getGraphDimensions({
});

const adapter: BreakdownAdapter = {
version: 2,
breakdown: {
v2: Object.keys(endpoints).reduce((acc, chain) => {
acc[chain] = {
Expand All @@ -86,14 +87,7 @@ const adapter: BreakdownAdapter = {
}, {} as BaseAdapter),
v3: Object.keys(v3Endpoint).reduce((acc, chain) => {
acc[chain] = {
fetch: async (timestamp: number) => {
const v3stats = await v3Graph(chain)(timestamp, {})
return {
...v3stats,
timestamp
}

},
fetch: v3Graph(chain),
start: v3StartTimes[chain],
}
return acc
Expand Down
Loading

0 comments on commit e924265

Please sign in to comment.