Skip to content

Commit

Permalink
hotcross
Browse files Browse the repository at this point in the history
  • Loading branch information
waynebruce0x committed Nov 28, 2023
1 parent d93e9b6 commit 0630e3a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions projects/hotcross/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { sumTokens2 } = require("../helper/unwrapLPs");
const { fetchURL } = require("../helper/utils");

const chainKeys = {
ethereum: {
asset: "erc20",
chain: "eth",
},
bsc: {
asset: "bep20",
chain: "bsc",
},
};

function tvl(chain, get) {
return async (_t, _e, { [chain]: block }, { logArray }) => {
const assets = (await get).data;
const tokensAndOwners = assets.map((data) => [
data[chainKeys[chain].asset],
data[`${chainKeys[chain].chain}BridgeAddress`],
]);
return sumTokens2({ tokensAndOwners, block, chain, logArray });
};
}

const chainTypeExports = () => {
const get = fetchURL("https://api.hotcross.com/bridges");
return Object.keys(chainKeys).reduce(
(obj, chain) => ({ ...obj, [chain]: { tvl: tvl(chain, get) } }),
{}
);
};

module.exports = chainTypeExports();

0 comments on commit 0630e3a

Please sign in to comment.