Skip to content

Commit 8ad0e9c

Browse files
authored
Add Riddle on xrplevm chain (DefiLlama#15347)
1 parent 7f41d6c commit 8ad0e9c

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

projects/riddle/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const { getLogs } = require("../helper/cache/getLogs");
2+
3+
module.exports = {
4+
xrplevm: {
5+
tvl: async (api) => {
6+
// const xrp = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
7+
const wxrp = "0x7C21a90E3eCD3215d16c3BBe76a491f8f792d4Bf";
8+
const factory = "0x4e127808535795C58045e546c4b1554ae4aeF3cD";
9+
const fromBlock = 1;
10+
const pairs = await getPairs(api, factory, fromBlock);
11+
12+
const reserves = await api.multiCall({
13+
abi: "function getReserves() view returns (uint256, uint256, uint256)",
14+
calls: pairs,
15+
});
16+
17+
reserves.forEach(reserve => {
18+
const _reserve1 = reserve[2];
19+
api.add(wxrp, _reserve1);
20+
});
21+
}
22+
}
23+
};
24+
25+
async function getPairs(api, factory, fromBlock) {
26+
const logs = await getLogs({
27+
api,
28+
target: factory,
29+
eventAbi:
30+
"event PairCreated(address indexed tokenA, address indexed tokenB, address pair, uint)",
31+
onlyArgs: true,
32+
fromBlock,
33+
topics: [
34+
"0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9",
35+
],
36+
});
37+
return logs.map((i) => i.pair);
38+
}

0 commit comments

Comments
 (0)