Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add arbitrum address for Mangrove #11225

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions projects/mangrove/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const abi = require("./abi.json");
const { BigNumber } = require("bignumber.js");

const mgvReader = "0x26fD9643Baf1f8A44b752B28f0D90AEBd04AB3F8";
const mgvReaders = {
blast: "0x26fD9643Baf1f8A44b752B28f0D90AEBd04AB3F8",
arbitrum: "0x7E108d7C9CADb03E026075Bf242aC2353d0D1875",
};

const getOffers = async (api, { tkn0, tkn1, tickSpacing }) => {
const getOffers = async (api, mgvReader, { tkn0, tkn1, tickSpacing }) => {
let total = BigNumber(0);
let currentId = 0;
do {
Expand All @@ -25,26 +28,38 @@ const getOffers = async (api, { tkn0, tkn1, tickSpacing }) => {
return total;
};

async function getMangroveTVL(api) {
async function getMangroveTVL(api, mgvReader) {
const markets = await api.call({
target: mgvReader,
abi: abi.openMarkets,
});

for (const market of markets) {
const [tkn0, tkn1, tickSpacing] = market;
const tkn0TPV = await getOffers(api, { tkn0, tkn1, tickSpacing });
const tkn1TPV = await getOffers(api, { tkn0: tkn1, tkn1: tkn0, tickSpacing });
const tkn0TPV = await getOffers(api, mgvReader, {
tkn0,
tkn1,
tickSpacing,
});
const tkn1TPV = await getOffers(api, mgvReader, {
tkn0: tkn1,
tkn1: tkn0,
tickSpacing,
});

api.addTokens([tkn0, tkn1], [tkn0TPV, tkn1TPV]);
}
}

module.exports = {
blast: {
tvl: getMangroveTVL,
},
misrepresentedTokens: false,
methodology: "TVL is calculated by getting the total promised liquidity on the orderbook on a specific block.",
methodology:
"TVL is calculated by getting the total promised liquidity on the orderbook on a specific block.",
start: 1708992000,
};

for (const chain in mgvReaders) {
module.exports[chain] = {
tvl: (api) => getMangroveTVL(api, mgvReaders[chain]),
};
}
Loading