Skip to content

Commit

Permalink
Merge pull request #4 from CronosLabsDev/feat/FUL-1792-cronos-zk-
Browse files Browse the repository at this point in the history
feat: add cronos zk evm fee and vol
  • Loading branch information
CronosLabsDev committed Aug 28, 2024
2 parents a91e6c1 + 128f5ed commit 8073100
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 42 deletions.
84 changes: 43 additions & 41 deletions dexs/fulcrom-finance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const endpoints: { [key: string]: string } = {
"https://graph.cronoslabs.com/subgraphs/name/fulcrom/stats-prod",
[CHAIN.ERA]:
"https://api.studio.thegraph.com/query/52869/stats-prod/version/latest",
[CHAIN.CRONOS_ZKEVM]: "https://api.goldsky.com/api/public/project_clwrfupe2elf301wlhnd7bvva/subgraphs/fulcrom-stats-mainnet/prod/gn"
};

const historicalDataSwap = gql`
Expand Down Expand Up @@ -39,51 +40,52 @@ interface IGraphResponse {

const getFetch =
(query: string) =>
(chain: string): Fetch =>
async (timestamp: number) => {
const dayTimestamp = getUniqStartOfTodayTimestamp(
new Date(timestamp * 1000)
);
const dailyData: IGraphResponse = await request(endpoints[chain], query, {
id: "daily:" + String(dayTimestamp),
period: "daily",
});
const totalData: IGraphResponse = await request(endpoints[chain], query, {
id: "total",
period: "total",
});
(chain: string): Fetch =>
async (timestamp: number) => {
const dayTimestamp = getUniqStartOfTodayTimestamp(
new Date(timestamp * 1000)
);
const dailyData: IGraphResponse = await request(endpoints[chain], query, {
id: "daily:" + String(dayTimestamp),
period: "daily",
});
const totalData: IGraphResponse = await request(endpoints[chain], query, {
id: "total",
period: "total",
});

return {
timestamp: dayTimestamp,
dailyVolume:
dailyData.volumeStats.length == 1
? String(
Number(
Object.values(dailyData.volumeStats[0]).reduce((sum, element) =>
String(Number(sum) + Number(element))
)
) *
return {
timestamp: dayTimestamp,
dailyVolume:
dailyData.volumeStats.length == 1
? String(
Number(
Object.values(dailyData.volumeStats[0]).reduce((sum, element) =>
String(Number(sum) + Number(element))
)
) *
10 ** -30
)
: undefined,
totalVolume:
totalData.volumeStats.length == 1
? String(
Number(
Object.values(totalData.volumeStats[0]).reduce((sum, element) =>
String(Number(sum) + Number(element))
)
) *
)
: undefined,
totalVolume:
totalData.volumeStats.length == 1
? String(
Number(
Object.values(totalData.volumeStats[0]).reduce((sum, element) =>
String(Number(sum) + Number(element))
)
) *
10 ** -30
)
: undefined,
};
};
)
: undefined,
};
};

const startTimestamps: { [chain: string]: number } = {
[CHAIN.CRONOS]: 1677470400,
[CHAIN.ERA]: 1696496400,
};
const startTimestamps: { [chain: string]: number } = {
[CHAIN.CRONOS]: 1677470400,
[CHAIN.ERA]: 1696496400,
[CHAIN.CRONOS_ZKEVM]: 1723698700,
};

const adapter: BreakdownAdapter = {
breakdown: {
Expand Down
8 changes: 8 additions & 0 deletions fees/fulcrom-finance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const endpoints = {
"https://graph.cronoslabs.com/subgraphs/name/fulcrom/stats-prod",
[CHAIN.ERA]:
"https://api.studio.thegraph.com/query/52869/stats-prod/version/latest",
[CHAIN.CRONOS_ZKEVM]: "https://api.goldsky.com/api/public/project_clwrfupe2elf301wlhnd7bvva/subgraphs/fulcrom-stats-mainnet/prod/gn"
};

const methodology = {
Expand Down Expand Up @@ -99,6 +100,13 @@ const adapter: Adapter = {
methodology,
},
},
[CHAIN.CRONOS_ZKEVM]: {
fetch: graphs(endpoints)(CHAIN.CRONOS_ZKEVM),
start: 1723698700,
meta: {
methodology,
},
},
},
};

Expand Down
3 changes: 2 additions & 1 deletion helpers/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export enum CHAIN {
ZKLINK = "zklink",
DEXALOT = "dexalot",
IMMUTABLEX = "immutablex",
CHAINFLIP = "chainflip"
CHAINFLIP = "chainflip",
CRONOS_ZKEVM = "cronos_zkevm",
}

// Don´t use
Expand Down

0 comments on commit 8073100

Please sign in to comment.