-
Notifications
You must be signed in to change notification settings - Fork 1.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 'DefiLlama:master' into master
- Loading branch information
Showing
65 changed files
with
2,400 additions
and
605 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
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,77 @@ | ||
import { CHAIN } from "../../helpers/chains"; | ||
import { FetchOptions } from "../../adapters/types"; | ||
import {getUniqStartOfTodayTimestamp} from "../../helpers/getUniSubgraphVolume"; | ||
import { httpGet } from "../../utils/fetchURL"; | ||
|
||
|
||
const CHAINS: Array<CHAIN> = [ | ||
CHAIN.ETHEREUM, | ||
CHAIN.POLYGON, | ||
CHAIN.SOLANA, | ||
CHAIN.BSC, | ||
CHAIN.OPTIMISM, | ||
CHAIN.BASE, | ||
CHAIN.TON, | ||
CHAIN.TRON, | ||
CHAIN.BITCOIN, | ||
CHAIN.MANTA, | ||
CHAIN.LINEA, | ||
CHAIN.SUI, | ||
CHAIN.SCROLL, | ||
CHAIN.ARBITRUM, | ||
CHAIN.CORE, | ||
CHAIN.MERLIN, | ||
CHAIN.BLAST, | ||
CHAIN.APTOS | ||
]; | ||
|
||
|
||
|
||
|
||
interface IVolumeBridge { | ||
volume: string; | ||
date: string; | ||
} | ||
|
||
async function queryDataByApi(timestamp:string, path:string){ | ||
const historicalVolumeEndpoint = "https://new-swapopen.bitapi.vip/st"; | ||
let info = await httpGet(`${historicalVolumeEndpoint}${path}`); | ||
const data : IVolumeBridge[] = (info)?.data.list; | ||
return data | ||
} | ||
|
||
const fetch = async (_t: number, _b: any, options: FetchOptions) => { | ||
const dayTimestamp = getUniqStartOfTodayTimestamp(new Date(options.startOfDay * 1000)) | ||
const path = `/getOrderDayList?bridge=1&chain=${options.chain}×tamp=${dayTimestamp}` | ||
const data = await queryDataByApi(dayTimestamp.toString(), path) | ||
const dateString = new Date(dayTimestamp * 1000).toISOString().split("T")[0]; | ||
let dailyVolume = data.find(dayItem => dayItem.date === dateString)?.volume | ||
dailyVolume = dailyVolume || undefined; | ||
return { | ||
dailyBridgeVolume: dailyVolume, | ||
timestamp: options.endTimestamp, | ||
}; | ||
}; | ||
|
||
const adapter: any = { | ||
version: 1, // api supports other timestamps but if you try using current timestamps, it breaks, so sticking to v1 even though it should be able to support v2 | ||
adapter: { | ||
...CHAINS.map(chain => { | ||
return { | ||
|
||
[chain]: { | ||
fetch: fetch, | ||
start: '2024-01-01' | ||
} | ||
|
||
} | ||
}).reduce((acc, item) => { | ||
return { | ||
...acc, | ||
...item | ||
} | ||
}) | ||
}, | ||
}; | ||
|
||
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,65 @@ | ||
import { FetchOptions, SimpleAdapter } from '../../adapters/types'; | ||
import { httpGet } from '../../utils/fetchURL'; | ||
import { CHAIN } from '../../helpers/chains'; | ||
import { getUniqStartOfTodayTimestamp } from '../../helpers/getUniSubgraphVolume'; | ||
|
||
const chains: Record<string, string> = { | ||
[CHAIN.BITCOIN]: 'bitcoin', | ||
[CHAIN.ETHEREUM]: 'ethereum', | ||
[CHAIN.SUI]: 'sui', | ||
[CHAIN.TRON]: 'tron', | ||
[CHAIN.BASE]: 'base', | ||
[CHAIN.BSC]: 'bsc', | ||
[CHAIN.TARA]: 'tara', | ||
[CHAIN.AVAX]: 'avax', | ||
[CHAIN.LITECOIN]: 'litecoin', | ||
[CHAIN.ARBITRUM]: 'arbitrum', | ||
[CHAIN.NEAR]: 'near', | ||
[CHAIN.POLYGON]: 'polygon', | ||
[CHAIN.TON]: 'ton', | ||
[CHAIN.SOLANA]: 'solana', | ||
}; | ||
|
||
let data: any; | ||
const fetchVolume = async (_t: any, _b: any, options: FetchOptions) => { | ||
const unixTimestamp = getUniqStartOfTodayTimestamp( | ||
new Date(options.startOfDay * 1000) | ||
); | ||
if (!data) { | ||
data = await httpGet('https://api.teleswap.io/stats/volume', { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
} | ||
|
||
const chainVolume = data?.find( | ||
(item: any) => | ||
item.chain.toLowerCase() === chains[options.chain].toLowerCase() | ||
); | ||
|
||
return { | ||
dailyBridgeVolume: chainVolume?.dailyVolume || 0, | ||
totalBridgeVolume: chainVolume?.totalVolume || 0, | ||
timestamp: unixTimestamp, | ||
}; | ||
}; | ||
|
||
const adapter: SimpleAdapter = { | ||
adapter: { | ||
...Object.entries(chains).reduce((acc, chain) => { | ||
const [key, value] = chain; | ||
|
||
return { | ||
...acc, | ||
[key]: { | ||
fetch: fetchVolume, | ||
start: '2024-09-18', | ||
}, | ||
}; | ||
}, {}), | ||
}, | ||
version: 1, | ||
}; | ||
|
||
export default adapter; |
Oops, something went wrong.