-
Notifications
You must be signed in to change notification settings - Fork 951
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1915 from DefiLlama/kibana-fixes
Kibana fixes
- Loading branch information
Showing
13 changed files
with
59 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,30 @@ | ||
import * as sdk from "@defillama/sdk"; | ||
import request, { gql } from "graphql-request"; | ||
import { FetchResultVolume, SimpleAdapter } from "../../adapters/types"; | ||
import { SimpleAdapter } from "../../adapters/types"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
import BigNumber from "bignumber.js"; | ||
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; | ||
|
||
const ONE_DAY_IN_SECONDS = 60 * 60 * 24 | ||
|
||
const endpoint = sdk.graph.modifyEndpoint('3E7EJF1zWHD3LHTKV5L6dspCno2ghxZ3WYe9MN7QVnEE') | ||
|
||
const query = gql` | ||
query stats($from: String!, $to: String!) { | ||
dailyHistories(where: {timestamp_gte: $from, timestamp_lte: $to, accountSource: "0x1c03B6480a4efC2d4123ba90d7857f0e1878B780"}){ | ||
timestamp | ||
platformFee | ||
accountSource | ||
tradeVolume | ||
} | ||
totalHistories(where: {accountSource: "0x1c03B6480a4efC2d4123ba90d7857f0e1878B780"}) { | ||
timestamp | ||
platformFee | ||
accountSource | ||
tradeVolume | ||
} | ||
} | ||
` | ||
|
||
|
||
interface IGraphResponse { | ||
dailyHistories: Array<{ | ||
tiemstamp: string, | ||
platformFee: string, | ||
accountSource: string, | ||
tradeVolume: string | ||
}> | ||
totalHistories: Array<{ | ||
tiemstamp: string, | ||
platformFee: string, | ||
accountSource: string, | ||
tradeVolume: BigNumber | ||
}> | ||
} | ||
|
||
const toString = (x: BigNumber) => { | ||
if (x.isEqualTo(0)) return undefined | ||
return x.toString() | ||
} | ||
|
||
const fetchVolume = async (timestamp: number): Promise<FetchResultVolume> => { | ||
const response: IGraphResponse = await request(endpoint, query, { | ||
from: String(timestamp - ONE_DAY_IN_SECONDS), | ||
to: String(timestamp) | ||
}) | ||
|
||
|
||
let dailyVolume = new BigNumber(0); | ||
response.dailyHistories.forEach(data => { | ||
dailyVolume = dailyVolume.plus(new BigNumber(data.tradeVolume)) | ||
}); | ||
|
||
let totalVolume = new BigNumber(0); | ||
response.totalHistories.forEach(data => { | ||
totalVolume = totalVolume.plus(new BigNumber(data.tradeVolume)) | ||
}); | ||
|
||
dailyVolume = dailyVolume.dividedBy(new BigNumber(1e18)) | ||
totalVolume = totalVolume.dividedBy(new BigNumber(1e18)) | ||
|
||
const _dailyVolume = toString(dailyVolume) | ||
const _totalVolume = toString(totalVolume) | ||
|
||
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date((timestamp * 1000))) | ||
|
||
return { | ||
timestamp: dayTimestamp, | ||
dailyVolume: _dailyVolume, | ||
totalVolume: _totalVolume, | ||
} | ||
|
||
} | ||
import { getGraphDimensions2 } from "../../helpers/getUniSubgraph"; | ||
|
||
const fetch = getGraphDimensions2({ | ||
graphUrls: { | ||
[CHAIN.BASE]: sdk.graph.modifyEndpoint( | ||
"3E7EJF1zWHD3LHTKV5L6dspCno2ghxZ3WYe9MN7QVnEE", | ||
), | ||
}, | ||
totalVolume: { | ||
factory: "factories", | ||
}, | ||
totalFees: { | ||
factory: "factories", | ||
}, | ||
}); | ||
|
||
const adapter: SimpleAdapter = { | ||
version: 2, | ||
adapter: { | ||
[CHAIN.BASE]: { | ||
fetch: fetchVolume, | ||
start: 1704009000 | ||
} | ||
} | ||
} | ||
fetch: fetch(CHAIN.BASE), | ||
start: 1704009000, | ||
}, | ||
}, | ||
}; | ||
|
||
export default adapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import * as sdk from "@defillama/sdk"; | ||
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume"; | ||
import { univ2Adapter2 } from "../../helpers/getUniSubgraphVolume"; | ||
|
||
export default univ2Adapter({ | ||
"avax": sdk.graph.modifyEndpoint('CPXTDcwh6tVP88QvFWW7pdvZJsCN4hSnfMmYeF1sxCLq') | ||
}, { | ||
export default univ2Adapter2( | ||
{ | ||
avax: sdk.graph.modifyEndpoint( | ||
"CPXTDcwh6tVP88QvFWW7pdvZJsCN4hSnfMmYeF1sxCLq", | ||
), | ||
}, | ||
{ | ||
factoriesName: "pangolinFactories", | ||
dayData: "pangolinDayData", | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume"; | ||
import { univ2Adapter2 } from "../../helpers/getUniSubgraphVolume"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
|
||
const endpoints = { | ||
[CHAIN.ERA]: "https://api.studio.thegraph.com/query/30365/syncswap-graph/1.4.0", | ||
[CHAIN.ERA]: | ||
"https://api.studio.thegraph.com/query/30365/syncswap-graph/1.4.0", | ||
}; | ||
|
||
const adapter = univ2Adapter(endpoints, { | ||
const adapter = univ2Adapter2(endpoints, { | ||
factoriesName: "syncSwapFactories", | ||
dayData: "dayData", | ||
dailyVolume: "dailyVolumeUSD", | ||
totalVolume: "totalVolumeUSD", | ||
dailyVolumeTimestampField: "date", | ||
}); | ||
|
||
adapter.adapter.era.start = 1679529600 | ||
adapter.adapter.era.start = 1679529600; | ||
|
||
export default adapter | ||
export default adapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters