Skip to content

Commit

Permalink
Merge pull request DefiLlama#1412 from web3world/web3world_dex_adapter
Browse files Browse the repository at this point in the history
feat: web3world dex adapter has been added
  • Loading branch information
dtmkeng authored Apr 16, 2024
2 parents c8fe28a + 3405ebd commit abf48c6
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions dexs/web3world/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import BigNumber from "bignumber.js";
import { FetchOptions, FetchV2, SimpleAdapter } from "../../adapters/types";
import { postURL } from "../../utils/fetchURL";

interface IWeb3WorldPoolsStats {
pools: Array<{
meta: {
currencies: string[];
currencyAddresses: string[];
poolAddress: string;
lpAddress: string;
pairType: string;
fee: string;
feeBeneficiary: string | null;
beneficiaryAddress: string | null;
};
tvl: string;
tvlChange: string;
volumesLocked: string[];
prices: string[];
lpLocked: string;
count24Transactions: number;
volume24h: string;
volume24hChange: string;
volume7d: string;
fee24h: string;
fee7d: string;
feeAllTime: string;
stableOneSwap: string[] | null;
}>;
}

const fetch: FetchV2 = async (options: FetchOptions) => {
const response: IWeb3WorldPoolsStats = await postURL(
"https://api.web3.world/v2/pools",
{
limit: 1000,
offset: 0,
ordering: "tvldescending",
whiteListUri: "https://static.web3.world/assets/manifest.json",
}
);
let dailyVolumeBN = new BigNumber(0);
let dailyFeesBN = new BigNumber(0);
let totalFeesBN = new BigNumber(0);
response.pools.forEach((pool) => {
dailyVolumeBN = dailyVolumeBN.plus(pool.volume24h);
dailyFeesBN = dailyFeesBN.plus(pool.fee24h);
totalFeesBN = totalFeesBN.plus(pool.feeAllTime);
});
return {
dailyVolume: dailyVolumeBN.toString(10),
dailyFees: dailyFeesBN.toString(10),
dailyUserFees: dailyFeesBN.toString(10),
totalFees: totalFeesBN.toString(10),
};
};
const adapter: SimpleAdapter = {
adapter: {
venom: {
fetch,
runAtCurrTime: true,
start: 1713139200, // 2024-04-15T00:00:00.000Z
},
},
version: 2,
};

export default adapter;

0 comments on commit abf48c6

Please sign in to comment.