-
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.
* Mantis daily/total volume dimensions adapter * minor fix --------- Co-authored-by: g1nt0ki <[email protected]>
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Chain } from "@defillama/sdk/build/general"; | ||
import { Adapter, ChainBlocks, FetchOptions, FetchResult, ProtocolType } from "../../adapters/types"; | ||
import { CHAIN } from '../../helpers/chains'; | ||
import fetchURL from "../../utils/fetchURL" | ||
|
||
const MANTIS_INDEXER_API = `https://mantis-indexer.composable-shared-artifacts.composablenodes.tech`; | ||
const MANTIS_VOLUME_API = `${MANTIS_INDEXER_API}/api/domain/getvolume`; | ||
|
||
|
||
function removeInvalidKeys(obj: any) { | ||
Object.keys(obj).forEach(key => { | ||
if (key.includes("…")) { | ||
console.log("Removing key", key); | ||
delete obj[key]; | ||
} | ||
}); | ||
} | ||
|
||
const fetch = async (timestamp: number, _: ChainBlocks, options: FetchOptions): Promise<FetchResult> => { | ||
const chain = options.chain | ||
const urlDaily = `${MANTIS_VOLUME_API}?timestamp=${options.toTimestamp}&chain=${chain == CHAIN.ETHEREUM ? 1 : 2}&period=1&solved_only=true`; | ||
const urlTotal = `${MANTIS_VOLUME_API}?timestamp=${options.toTimestamp}&chain=${chain == CHAIN.ETHEREUM ? 1 : 2}&period=0&solved_only=true`; | ||
|
||
const volumeDaily = (await fetchURL(urlDaily)).assets; | ||
const volumeTotal = (await fetchURL(urlTotal)).assets; | ||
|
||
removeInvalidKeys(volumeDaily); | ||
removeInvalidKeys(volumeTotal); | ||
|
||
const dailyVolume = options.createBalances(); | ||
const totalVolume = options.createBalances(); | ||
dailyVolume.addBalances(volumeDaily); | ||
totalVolume.addBalances(volumeTotal); | ||
|
||
|
||
return { | ||
dailyVolume, | ||
totalVolume, | ||
timestamp | ||
}; | ||
}; | ||
|
||
export default { | ||
adapter: { | ||
[CHAIN.SOLANA]: { | ||
fetch, | ||
start: 1732993200, | ||
meta: { | ||
methodology: "Sum of all executed intents with Solana as input or output", | ||
}, | ||
}, | ||
[CHAIN.ETHEREUM]: { | ||
fetch, | ||
start: 1732993200, | ||
meta: { | ||
methodology: "Sum of all executed intents with Ethereum as input or output", | ||
}, | ||
} | ||
}, | ||
} as Adapter; |