Skip to content

Commit

Permalink
Mantis Volume (#2221)
Browse files Browse the repository at this point in the history
* Mantis daily/total volume dimensions adapter

* minor fix

---------

Co-authored-by: g1nt0ki <[email protected]>
  • Loading branch information
godilov and g1nt0ki authored Dec 16, 2024
1 parent 25fa4dd commit bfe08cb
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions dexs/mantis/index.ts
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;

0 comments on commit bfe08cb

Please sign in to comment.