Skip to content

Commit 8dbe7fa

Browse files
authored
fix broken subgraphs (DefiLlama#3946)
1 parent 5d6698c commit 8dbe7fa

12 files changed

Lines changed: 82 additions & 134 deletions

File tree

dexs/beamswap-stable-amm.ts

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11

2-
import adapter from './beamswap'
3-
const { breakdown, ...rest } = adapter
2+
import { FetchOptions, FetchResultV2, SimpleAdapter } from '../adapters/types'
3+
import { CHAIN } from '../helpers/chains'
44

5-
export default {
6-
...rest,
7-
adapter: breakdown['stable-amm'],
8-
}
5+
const pools = {
6+
'0xe3f59ab3c37c33b6368cdf4f8ac79644011e402c': {
7+
tokens: ['0x931715FEE2d06333043d11F658C8CE934aC61D0c', '0xCa01a1D0993565291051daFF390892518ACfAD3A', '0xFFFFFFfFea09FB06d082fd1275CD48b191cbCD1d'],
8+
},
9+
'0x09a793cca9d98b14350f2a767eb5736aa6b6f921': {
10+
tokens: ['0x8f552a71EFE5eeFc207Bf75485b356A0b3f01eC9', '0x8e70cD5B4Ff3f62659049e74b6649c6603A0E594', '0xc234A67a4F840E61adE794be47de455361b52413'],
11+
},
12+
}
13+
14+
const fetch = async (options: FetchOptions): Promise<FetchResultV2> => {
15+
const dailyVolume = options.createBalances()
16+
17+
for (const [poolAddress, poolConfig] of Object.entries(pools)) {
18+
const events = await options.getLogs({
19+
eventAbi: 'event TokenSwap(address indexed buyer, uint256 tokensSold, uint256 tokensBought, uint128 soldId, uint128 boughtId)',
20+
target: poolAddress,
21+
});
22+
for (const event of events) {
23+
dailyVolume.add(poolConfig.tokens[Number(event.soldId)], event.tokensSold)
24+
}
25+
}
26+
27+
return { dailyVolume }
28+
}
29+
30+
const adapter: SimpleAdapter = {
31+
version: 2,
32+
chains: [CHAIN.MOONBEAM],
33+
fetch: fetch,
34+
}
35+
36+
export default adapter;

dexs/carbonswap/index.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
import { SimpleAdapter } from "../../adapters/types";
22
import { CHAIN } from "../../helpers/chains";
3-
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
4-
5-
const endpoints = {
6-
[CHAIN.ENERGYWEB]: "https://ewc-subgraph-production.carbonswap.exchange/subgraphs/name/carbonswap/uniswapv2",
7-
};
8-
9-
const fetch = univ2Adapter({
10-
endpoints,
11-
});
3+
import { getUniV2LogAdapter } from "../../helpers/uniswap";
124

135
const adapter: SimpleAdapter = {
14-
version: 1,
15-
fetch,
16-
chains: Object.keys(endpoints),
6+
version: 2,
7+
fetch: getUniV2LogAdapter({ factory: '0x17854c8d5a41d5A89B275386E24B2F38FD0AfbDd' }),
8+
chains: [CHAIN.ENERGYWEB],
179
start: 1618446893,
1810
}
1911

dexs/cone/index.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
import * as sdk from "@defillama/sdk";
21
import { CHAIN } from "../../helpers/chains";
3-
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
42
import { SimpleAdapter } from "../../adapters/types";
5-
6-
const endpoints = {
7-
[CHAIN.BSC]: sdk.graph.modifyEndpoint('CeXrZ218JFm5S7iD6sGusqSSQgyFM6wuYoUk7iVygq1c'),
8-
};
9-
10-
const fetch = univ2Adapter({
11-
endpoints,
12-
});
3+
import { getUniV2LogAdapter } from "../../helpers/uniswap";
134

145
const adapter: SimpleAdapter = {
15-
version: 1,
16-
fetch,
17-
chains: Object.keys(endpoints),
6+
version: 2,
7+
fetch: getUniV2LogAdapter({ factory: '0x0EFc2D2D054383462F2cD72eA2526Ef7687E1016' }),
8+
chains: [CHAIN.BSC],
189
start: 1626677527
1910
}
2011

dexs/honeyswap/index.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
import { CHAIN } from "../../helpers/chains";
2-
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
2+
import { getUniV2LogAdapter } from "../../helpers/uniswap";
33
import { SimpleAdapter } from "../../adapters/types";
44

5-
const fetch = univ2Adapter({
6-
endpoints: {
7-
[CHAIN.POLYGON]: " https://api.thegraph.com/subgraphs/name/1hive/honeyswap-polygon",
8-
[CHAIN.XDAI]: "https://api.thegraph.com/subgraphs/name/1hive/honeyswap-xdai"
9-
},
10-
factoriesName: "honeyswapFactories",
11-
dayData: "honeyswapDayData",
12-
});
13-
145
const adapter: SimpleAdapter = {
15-
version: 1,
6+
version: 2,
167
adapter: {
17-
[CHAIN.POLYGON]: { fetch, start: 1622173831 },
18-
[CHAIN.XDAI]: { fetch, start: 1599191431 },
8+
[CHAIN.POLYGON]: { fetch: getUniV2LogAdapter({ factory: '0x03daa61d8007443a6584e3d8f85105096543c19c' }), start: 1622173831 },
9+
[CHAIN.XDAI]: { fetch: getUniV2LogAdapter({ factory: '0xa818b4f111ccac7aa31d0bcc0806d64f2e0737d7' }), start: 1599191431 },
1910
},
2011
}
2112

dexs/hyperjump/index.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
import * as sdk from "@defillama/sdk";
2-
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
1+
import { getUniV2LogAdapter } from "../../helpers/uniswap";
32
import { CHAIN } from "../../helpers/chains";
43
import { SimpleAdapter } from "../../adapters/types";
54

6-
const fetch = univ2Adapter({
7-
endpoints: {
8-
[CHAIN.BSC]: sdk.graph.modifyEndpoint('5fWfhux2ZJbU33j7Z1sn6m4vj7N7vapTj9hBKeZ5uyaU'),
9-
},
10-
factoriesName: "thugswapFactories",
11-
dayData: "thugswapDayData",
12-
});
13-
145
const adapter: SimpleAdapter = {
15-
version: 1,
6+
version: 2,
167
adapter: {
17-
[CHAIN.BSC]: { fetch, start: 1605139200 },
8+
[CHAIN.BSC]: { fetch: getUniV2LogAdapter({ factory: '0xac653ce27e04c6ac565fd87f18128ad33ca03ba2' }), start: '2020-11-10' },
9+
[CHAIN.FANTOM]: { fetch: getUniV2LogAdapter({ factory: '0x991152411A7B5A14A8CF0cDDE8439435328070dF' }), start: '2021-04-19' },
10+
[CHAIN.METIS]: { fetch: getUniV2LogAdapter({ factory: '0xAA1504c878B158906B78A471fD6bDbf328688aeB' }), start: '2022-05-04' },
1811
},
1912
}
2013

dexs/kaidex/index.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
import { CHAIN } from "../../helpers/chains";
2-
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
32
import { SimpleAdapter } from "../../adapters/types";
4-
5-
const fetch = univ2Adapter({
6-
endpoints: {
7-
[CHAIN.KARDIA]: "https://ex-graph-v3.kardiachain.io/subgraphs/name/kaidex-v3/exchange2"
8-
},
9-
factoriesName: "factories",
10-
dayData: "dayData",
11-
totalVolume: "volumeUSD",
12-
dailyVolume: "volumeUSD"
13-
});
3+
import { getUniV2LogAdapter } from "../../helpers/uniswap";
144

155
const adapter: SimpleAdapter = {
16-
version: 1,
6+
version: 2,
177
adapter: {
18-
[CHAIN.KARDIA]: { fetch },
8+
[CHAIN.KARDIA]: { fetch: getUniV2LogAdapter({ factory: '0x64203f29f4d6a7e199b6f6afbe65f1fa914c7c4e' }) },
199
},
2010
}
2111

dexs/padswap/index.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
import * as sdk from "@defillama/sdk";
21
import { CHAIN } from "../../helpers/chains";
3-
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
2+
import { getUniV2LogAdapter } from "../../helpers/uniswap";
43
import { SimpleAdapter } from "../../adapters/types";
54

6-
const fetch = univ2Adapter({
7-
endpoints: {
8-
[CHAIN.BSC]: sdk.graph.modifyEndpoint('85ZjqMyuYVWcWWW7Ei8ptMyVRhwYwxGBHo83TmNJkw2U'),
9-
[CHAIN.MOONBEAM]: sdk.graph.modifyEndpoint('HZrJDqzqR12BBUfmxaaPNbnSB9JunWzdzkpQaGYSHNcv'),
10-
},
11-
});
12-
135
const adapter: SimpleAdapter = {
14-
version: 1,
6+
version: 2,
157
adapter: {
16-
[CHAIN.BSC]: { fetch, start: 1620518400 },
17-
[CHAIN.MOONRIVER]: { fetch: async () => ({ dailyVolume: 0 }), start: 1635638400 },
18-
[CHAIN.MOONBEAM]: { fetch, start: 1642032000 },
8+
[CHAIN.BSC]: { fetch: getUniV2LogAdapter({ factory: '0xB836017ACf10b8A7c6c6C9e99eFE0f5B0250FC45' }), start: 1620518400 },
9+
[CHAIN.MOONRIVER]: { fetch: getUniV2LogAdapter({ factory: '0x760d2Bdb232027aB3b1594405077F9a1b91C04c1' }), start: 1635638400 },
10+
[CHAIN.MOONBEAM]: { fetch: getUniV2LogAdapter({ factory: '0x663a07a2648296f1A3C02EE86A126fE1407888E5' }), start: 1642032000 },
1911
},
2012
}
2113

dexs/pegasys/index.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import { CHAIN } from "../../helpers/chains";
2-
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
32
import { SimpleAdapter } from "../../adapters/types";
4-
5-
const fetch = univ2Adapter({
6-
endpoints: {
7-
[CHAIN.SYSCOIN]: "https://graph.pegasys.finance/subgraphs/name/pollum-io/pegasys"
8-
},
9-
factoriesName: "pegasysFactories",
10-
dayData: "pegasysDayData",
11-
});
3+
import { getUniV2LogAdapter } from "../../helpers/uniswap";
124

135
const adapter: SimpleAdapter = {
14-
fetch,
6+
version: 2,
7+
fetch: getUniV2LogAdapter({ factory: '0x7Bbbb6abaD521dE677aBe089C85b29e3b2021496' }),
158
chains: [CHAIN.SYSCOIN],
169
}
1710

dexs/pinkswap/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
import * as sdk from "@defillama/sdk";
21
import { CHAIN } from "../../helpers/chains";
3-
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
42
import { SimpleAdapter } from "../../adapters/types";
5-
6-
const fetch = univ2Adapter({
7-
endpoints: {
8-
[CHAIN.BSC]: sdk.graph.modifyEndpoint('CwTzDabgebYMipjh9gqP4Kyrbi3HGQSabBuR4ngorXUt')
9-
},
10-
});
3+
import { getUniV2LogAdapter } from "../../helpers/uniswap";
114

125
const adapter: SimpleAdapter = {
13-
fetch,
6+
version: 2,
7+
fetch: getUniV2LogAdapter({ factory: '0x7D2Ce25C28334E40f37b2A068ec8d5a59F11Ea54' }),
148
chains: [CHAIN.BSC],
159
}
1610

dexs/polycat/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
import * as sdk from "@defillama/sdk";
21
import { CHAIN } from "../../helpers/chains";
3-
import { univ2Adapter } from "../../helpers/getUniSubgraphVolume";
42
import { SimpleAdapter } from "../../adapters/types";
5-
6-
const fetch = univ2Adapter({
7-
endpoints: {
8-
[CHAIN.POLYGON]: sdk.graph.modifyEndpoint('9xwmkrJTk5s5e8QoBnQG1yTN8seLwzLWwACaqTgq2U9x')
9-
},
10-
});
3+
import { getUniV2LogAdapter } from "../../helpers/uniswap";
114

125
const adapter: SimpleAdapter = {
13-
fetch,
6+
version: 2,
7+
fetch: getUniV2LogAdapter({ factory: '0x477Ce834Ae6b7aB003cCe4BC4d8697763FF456FA' }),
148
chains: [CHAIN.POLYGON],
159
}
1610

0 commit comments

Comments
 (0)