forked from DefiLlama/dimension-adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/tokenlon-rfqv2-l2-volume' of github.com:0xkeen/…
…dimension-adapters into feature/tokenlon-rfqv2-l2-volume
- Loading branch information
Showing
176 changed files
with
6,079 additions
and
1,464 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,44 @@ | ||
import { postURL } from '../../utils/fetchURL' | ||
import { FetchResult, SimpleAdapter } from '../../adapters/types' | ||
import { CHAIN } from '../../helpers/chains' | ||
|
||
const URL = 'https://leaderboard-production.rage.trade' | ||
const endpoint = '/api/stats/defillama' | ||
const arbitrumStartTimestamp = 1701302400 // 2023-11-30 00:00:00 | ||
const optimismStartTimestamp = 1701302400 // 2023-11-30 00:00:00 | ||
const ethereumStartTimestamp = 1710374400 // 2023-11-30 00:00:00 | ||
|
||
const fetch = | ||
(chain: string) => | ||
async (timestamp: number): Promise<FetchResult> => { | ||
const { dailyVolume: dailyVolumeE30, totalVolume: totalVolumeE30 } = | ||
await postURL(`${URL}${endpoint}`, { | ||
timestamp, | ||
chain, | ||
}) | ||
|
||
return { | ||
dailyVolume: dailyVolumeE30 ? dailyVolumeE30 / 1e30 : 0, | ||
totalVolume: totalVolumeE30 ? totalVolumeE30 / 1e30 : 0, | ||
timestamp, | ||
} | ||
} | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
[CHAIN.ARBITRUM]: { | ||
fetch: fetch(CHAIN.ARBITRUM), | ||
start: arbitrumStartTimestamp, | ||
}, | ||
[CHAIN.ETHEREUM]: { | ||
fetch: fetch(CHAIN.ETHEREUM), | ||
start: ethereumStartTimestamp, | ||
}, | ||
[CHAIN.OPTIMISM]: { | ||
fetch: fetch(CHAIN.OPTIMISM), | ||
start: optimismStartTimestamp, | ||
}, | ||
}, | ||
} | ||
|
||
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
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 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,36 @@ | ||
import fetchURL from "../../utils/fetchURL"; | ||
import { FetchResultV2, SimpleAdapter } from "../../adapters/types"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
|
||
const URL = 'https://app.bountive.fi'; | ||
const endpoint = '/api/metrics/volumes/'; | ||
const startTimestamp = 1709356735;// 02.03.2024 | ||
|
||
interface IAPIResponse { | ||
date: number; | ||
dailyVolume: string; | ||
totalVolume: string; | ||
} | ||
|
||
const fetch = async ({ endTimestamp, startTimestamp }): Promise<FetchResultV2> => { | ||
const { dailyVolume, totalVolume }: IAPIResponse = await fetchURL( | ||
`${URL}${endpoint}${startTimestamp * 1000}/${endTimestamp * 1000}`, | ||
); | ||
|
||
return { | ||
dailyVolume, | ||
totalVolume, | ||
}; | ||
}; | ||
|
||
const adapter: SimpleAdapter = { | ||
version: 2, | ||
adapter: { | ||
[CHAIN.STARKNET]: { | ||
fetch: fetch, | ||
start: startTimestamp, | ||
}, | ||
}, | ||
}; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import BigNumber from "bignumber.js"; | ||
import { CHAIN } from "../../helpers/chains"; | ||
import { httpGet } from "../../utils/fetchURL"; | ||
|
||
const fetchLogs = async (timestamp: number) => { | ||
const res = await httpGet(`https://api.etaswap.com/v1/statistics/volume/total?timestamp=${timestamp}`); | ||
return { | ||
dailyVolume: new BigNumber(res.volume_USD_24h).div(100).toFixed(2), | ||
totalVolume: new BigNumber(res.volume_USD_total).div(100).toFixed(2), | ||
dailyFees: new BigNumber(res.fee_USD_24h).div(100).toFixed(2), | ||
totalFees: new BigNumber(res.fee_USD_total).div(100).toFixed(2), | ||
timestamp: timestamp, | ||
}; | ||
}; | ||
|
||
const adapter: any = { | ||
adapter: { | ||
[CHAIN.HEDERA]: { | ||
fetch: fetchLogs, | ||
start: 1709395559, | ||
}, | ||
}, | ||
}; | ||
|
||
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
Oops, something went wrong.