-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
382 changed files
with
1,590 additions
and
1,209 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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { CHAIN } from "../../helpers/chains"; | ||
import { FetchOptions } from "../../adapters/types"; | ||
import axios from "axios"; | ||
|
||
const sentioApiKey = '3taTsrTS3cZq4tcKkKVSajWSJxkjZmcet'; //Read Only | ||
|
||
const fetchDailyVolume = async ({ fromTimestamp, toTimestamp, startOfDay }: FetchOptions) => { | ||
const url = 'https://app.sentio.xyz/api/v1/analytics/navi/dex-aggregator/sql/execute'; | ||
const res = await axios(url, { | ||
method: 'POST', | ||
headers: { | ||
'api-key': sentioApiKey, | ||
'Content-Type': 'application/json' | ||
}, | ||
data: JSON.stringify({ | ||
sqlQuery: { | ||
sql: `SELECT SUM(GREATEST(amount_in_usd, amount_out_usd)) AS usdValue | ||
FROM \'swapEvent\' | ||
WHERE timestamp >= ${fromTimestamp} AND timestamp <= ${toTimestamp};` | ||
}, | ||
version: 15 | ||
}) | ||
}).then(response => response.data); | ||
|
||
return { | ||
dailyVolume: res.result.rows[0].usdValue, | ||
} | ||
}; | ||
|
||
//NAVI Aggregator Volume | ||
const navi_aggregator: any = { | ||
version: 2, | ||
adapter: { | ||
[CHAIN.SUI]: { | ||
fetch: fetchDailyVolume, | ||
start: 1728111600, | ||
}, | ||
}, | ||
}; | ||
|
||
export default navi_aggregator; |
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,89 +1,48 @@ | ||
import { GraphQLClient, gql } from "graphql-request"; | ||
|
||
import { CHAIN } from "../../helpers/chains"; | ||
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; | ||
import { FetchOptions } from "../../adapters/types"; | ||
import { getEnv } from "../../helpers/env"; | ||
import axios from "axios"; | ||
|
||
type TChain = { | ||
[key: string]: string; | ||
[key: string]: number; | ||
}; | ||
const CHAINS: TChain = { | ||
[CHAIN.ARBITRUM]: "Arbitrum", | ||
[CHAIN.AVAX]: "Avalanche", | ||
[CHAIN.BASE]: "Base", | ||
[CHAIN.BSC]: "BSC", | ||
[CHAIN.CELO]: "Celo", | ||
[CHAIN.ETHEREUM]: "Ethereum", | ||
[CHAIN.FANTOM]: "Fantom", | ||
[CHAIN.OPTIMISM]: "Optimism", | ||
[CHAIN.POLYGON]: "Polygon", | ||
}; | ||
|
||
const graphQLClient = new GraphQLClient("https://api.0x.org/data/v0"); | ||
const getGQLClient = () => { | ||
graphQLClient.setHeader("0x-api-key", getEnv("AGGREGATOR_0X_API_KEY")); | ||
|
||
return graphQLClient; | ||
[CHAIN.ARBITRUM]: 42161, | ||
[CHAIN.AVAX]: 43114, | ||
[CHAIN.BASE]: 8453, | ||
[CHAIN.BSC]: 56, | ||
[CHAIN.ETHEREUM]: 1, | ||
[CHAIN.OPTIMISM]: 10, | ||
[CHAIN.POLYGON]: 137, | ||
[CHAIN.BLAST]: 81457, | ||
[CHAIN.LINEA]: 59144, | ||
[CHAIN.SCROLL]: 534352, | ||
[CHAIN.MANTLE]: 5000, | ||
[CHAIN.MODE]: 34443, | ||
}; | ||
|
||
const getVolumeByChain = async (chain: string) => { | ||
const client = getGQLClient(); | ||
const req = gql` | ||
query Query_root { | ||
aggTransactionsDailyRouter( | ||
order_by: [{ timestamp: desc, chainName: null }] | ||
where: { chainName: { _eq: ${chain} } } | ||
) { | ||
chainName | ||
timestamp | ||
transactions | ||
volumeUSD | ||
} | ||
const fetch = async (_a, _b, options: FetchOptions) => { | ||
const data = await axios.get(`https://api.0x.org/stats/volume/daily?timestamp=${options.startOfDay}&chainId=${CHAINS[options.chain]}`, { | ||
headers: { | ||
"0x-api-key": getEnv("AGGREGATOR_0X_API_KEY") | ||
} | ||
`; | ||
|
||
const data = (await client.request(req))["aggTransactionsDailyRouter"]; | ||
return data; | ||
}; | ||
|
||
const fetch = async (options: FetchOptions) => { | ||
const unixTimestamp = getUniqStartOfTodayTimestamp( | ||
new Date(options.endTimestamp * 1000) | ||
); | ||
try { | ||
const data = await getVolumeByChain(options.chain); | ||
const strDate = new Date(unixTimestamp * 1000).toISOString().split("T")[0]; | ||
const dayData = data.find( | ||
({ timestamp }: { timestamp: string }) => | ||
timestamp.split("T")[0] === strDate | ||
); | ||
return { | ||
dailyVolume: dayData?.volumeUSD, | ||
timestamp: unixTimestamp, | ||
}; | ||
} catch (e) { | ||
console.error(e); | ||
return { | ||
dailyVolume: "0", | ||
timestamp: unixTimestamp, | ||
}; | ||
}) | ||
return { | ||
dailyVolume: data.data.data.volume | ||
} | ||
}; | ||
|
||
const adapter: any = { | ||
version: 1, | ||
adapter: { | ||
...Object.values(CHAINS).reduce((acc, chain) => { | ||
return { | ||
...acc, | ||
[chain]: { | ||
fetch: fetch, | ||
start: 1652745600, | ||
}, | ||
}; | ||
}, {}), | ||
}, | ||
adapter: Object.keys(CHAINS).reduce((acc, chain) => { | ||
return { | ||
...acc, | ||
[chain]: { | ||
fetch: fetch, | ||
start: 1652745600, | ||
}, | ||
}; | ||
}, {}), | ||
}; | ||
|
||
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
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
Oops, something went wrong.