Skip to content

Commit 84ca9e3

Browse files
authored
Fix: Sushi trident using new bentobox helper (DefiLlama#15381)
1 parent d335ea6 commit 84ca9e3

File tree

3 files changed

+39
-80
lines changed

3 files changed

+39
-80
lines changed

projects/sushiswap-bentobox/helper.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const sdk = require("@defillama/sdk");
2-
const { default: BigNumber } = require("bignumber.js");
32
const { request, gql } = require("graphql-request");
43

54
const CONFIG = {
@@ -214,4 +213,4 @@ async function fetchAllTokens(subgraph, query, block, type) {
214213
return allTokens;
215214
}
216215

217-
module.exports = { CONFIG, getTokens };
216+
module.exports = { CONFIG, getTokens, fetchAllTokens };

projects/sushiswap-trident/index.js

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
const { trident } = require("./trident.js");
1+
const sdk = require("@defillama/sdk");
2+
const { getTokens, fetchAllTokens } = require("../sushiswap-bentobox/helper.js");
3+
4+
const polygonOldRouter = sdk.graph.modifyEndpoint('5LBvcUQthQDZTMe6cyJ7DbeokFkYeVpYYBZruHPUjMG5')
25

36
const modulesToExport = {};
47
const trident_chains = [
@@ -12,12 +15,43 @@ const trident_chains = [
1215
"avax",
1316
];
1417

18+
const tridentQuery = `
19+
query get_tokens {
20+
tokens(
21+
first: 100
22+
orderBy: liquidityUSD
23+
orderDirection: desc
24+
where: { liquidityUSD_gt: 0 }
25+
) {
26+
id
27+
symbol
28+
liquidity
29+
}
30+
}
31+
`;
32+
33+
async function fetchAndAddTridentTokens(api, block, subgraph) {
34+
const tokens = subgraph
35+
? await fetchAllTokens(subgraph, tridentQuery, block, 'trident')
36+
: await getTokens(api, block, 'trident');
37+
38+
for (const { id, liquidity } of tokens) {
39+
api.add(id, liquidity);
40+
}
41+
}
42+
43+
const tvl = async (api) => {
44+
const block = await api.getBlock();
45+
await fetchAndAddTridentTokens(api, block);
46+
if (api.chain === 'polygon') await fetchAndAddTridentTokens(api, block, polygonOldRouter);
47+
}
48+
1549
trident_chains.forEach((chain) => {
16-
modulesToExport[chain] = {
17-
tvl: trident(chain),
18-
};
50+
modulesToExport[chain] = { tvl }
1951
});
2052

53+
module.exports.methodology = `TVL of Trident consist of tokens deployed into swapping pairs.`
54+
2155
module.exports = {
2256
...modulesToExport,
2357
};

projects/sushiswap-trident/trident.js

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)