-
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.
Merge branch 'master' into frax-amo1
- Loading branch information
Showing
80 changed files
with
2,028 additions
and
295 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
Empty file.
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,130 @@ | ||
import { httpGet } from "../../utils/fetchURL"; | ||
import { ChainBlocks, FetchOptions, SimpleAdapter } from "../../adapters/types"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
|
||
const chainToId: Record<string, number> = { | ||
[CHAIN.ETHEREUM]: 1, | ||
[CHAIN.ARBITRUM]: 42161, | ||
[CHAIN.AVAX]: 43114, | ||
[CHAIN.BSC]: 56, | ||
[CHAIN.FANTOM]: 250, | ||
[CHAIN.OPTIMISM]: 10, | ||
[CHAIN.POLYGON]: 137, | ||
[CHAIN.LINEA]: 59144, | ||
[CHAIN.SCROLL]: 534352, | ||
[CHAIN.ERA]: 324, | ||
[CHAIN.CRONOS]: 25, | ||
[CHAIN.MANTA]: 169, | ||
}; | ||
|
||
|
||
const url = "https://api.aperture.finance/getMetricsBreakDownSinceInception" | ||
|
||
interface VolumeInfo { | ||
chainId: number; | ||
tve: number; | ||
txCount: number; | ||
} | ||
|
||
interface VolumeResponse { | ||
dailyVolume: VolumeInfo[]; | ||
totalVolume: VolumeInfo[]; | ||
} | ||
|
||
const fetch = async (timestamp: number, _: ChainBlocks, options: FetchOptions) => { | ||
const chainId = chainToId[options.chain] | ||
if (!chainId) { | ||
return { | ||
dailyVolume: 0, | ||
totalVolume: 0, | ||
timestamp: timestamp, | ||
} | ||
} | ||
const fetchUrl = `${url}?chainid=${chainId}×tamp=${timestamp}` | ||
const data: VolumeResponse = (await httpGet(fetchUrl, { timeout: 100000 })); | ||
|
||
if (data) { | ||
let dailyVolume :number = 0 | ||
let totalVolume :number = 0 | ||
if (data.dailyVolume) { | ||
data.dailyVolume.forEach(r => { | ||
if (r.chainId == chainId) { | ||
dailyVolume = r.tve | ||
} | ||
}) | ||
} | ||
|
||
if (data.totalVolume) { | ||
data.totalVolume.forEach(r => { | ||
if (r.chainId == chainId) { | ||
totalVolume = r.tve | ||
} | ||
}) | ||
} | ||
|
||
return { | ||
dailyVolume: dailyVolume, | ||
totalVolume: totalVolume, | ||
timestamp: timestamp | ||
} | ||
} else { | ||
//console.log("no data") | ||
return { | ||
dailyVolume: 0, | ||
totalVolume: 0, | ||
timestamp: timestamp, | ||
} | ||
} | ||
} | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.ETHEREUM]: { | ||
fetch: fetch, | ||
runAtCurrTime: false, | ||
start: 1689657695, | ||
}, | ||
[CHAIN.ARBITRUM]: { | ||
fetch: fetch, | ||
runAtCurrTime: false, | ||
start: 1689014691, | ||
}, | ||
[CHAIN.AVAX]: { | ||
fetch: fetch, | ||
runAtCurrTime: false, | ||
start: 1696671295, | ||
}, | ||
[CHAIN.BASE]: { | ||
fetch: fetch, | ||
runAtCurrTime: false, | ||
start: 1697229723, | ||
}, | ||
[CHAIN.BSC]: { | ||
fetch: fetch, | ||
runAtCurrTime: false, | ||
start: 1696963675, | ||
}, | ||
[CHAIN.OPTIMISM]: { | ||
fetch: fetch, | ||
runAtCurrTime: false, | ||
start: 1696888429, | ||
}, | ||
[CHAIN.POLYGON]: { | ||
fetch: fetch, | ||
runAtCurrTime: false, | ||
start: 1696888519, | ||
}, | ||
[CHAIN.MANTA]: { | ||
fetch: fetch, | ||
runAtCurrTime: false, | ||
start: 1695079629, | ||
}, | ||
[CHAIN.SCROLL]: { | ||
fetch: fetch, | ||
runAtCurrTime: false, | ||
start: 1702694992, | ||
} | ||
} | ||
}; | ||
|
||
export default adapter |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { request } from "graphql-request"; | ||
import { SimpleAdapter } from "../../adapters/types"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
import { getUniqStartOfTodayTimestamp } from "../../helpers/getUniSubgraphVolume"; | ||
|
||
const API_URL = 'https://statistic-api.ashperp.trade/graphql'; | ||
|
||
interface IVolume { | ||
volume: string; | ||
timestamp: number; | ||
} | ||
|
||
const VolumeQuery = ` | ||
query GetAllPairStatisticsToday { | ||
pairs { | ||
getAllPairStatistics { | ||
volume | ||
timestamp | ||
} | ||
} | ||
} | ||
` | ||
|
||
const fetch = async (timestamp: number) => { | ||
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(timestamp * 1000)) + 86400; | ||
const results: IVolume[] = (await request(API_URL, VolumeQuery)).pairs.getAllPairStatistics; | ||
let dailyVolume = results.filter((volumeInfo)=>{ | ||
return volumeInfo.timestamp === dayTimestamp; | ||
}) | ||
return { | ||
dailyVolume: dailyVolume ? `${dailyVolume[0].volume}` : undefined, | ||
timestamp: dayTimestamp, | ||
}; | ||
} | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.ELROND]: { | ||
fetch: fetch, | ||
runAtCurrTime: true, | ||
start: 1707782400 | ||
}, | ||
}, | ||
}; | ||
|
||
export default adapter; |
Oops, something went wrong.