Skip to content

Commit f732e9f

Browse files
authored
Add Lotto Run (Aptos lottery protocol) (#18480)
2 parents bcf9af5 + 0845fc7 commit f732e9f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

projects/lotto-run/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const { function_view } = require("../helper/chain/aptos");
2+
3+
const MODULE = "lotto_run";
4+
const APT = "0x1::aptos_coin::AptosCoin";
5+
6+
const POOLS = [
7+
"0xc38c49cd3008de7e0f41aadd83155ba1e4e380694db1e48b1f13c404e2451f16",
8+
"0x2ee2377b4b358cdf272cb7f3e8d22525c9d42a7db64816605f10f12819421c37",
9+
"0x53d1c36ff2af28bf67df3b1b2d2229e6bdf307efd6cacacdff8b4e2c2e1aace8",
10+
"0x55a51900d3c7bf85347c260448f7e5ffca9f37bbe8157679dbcb274967fae421",
11+
];
12+
13+
async function tvl(api) {
14+
for (const pool of POOLS) {
15+
// pool_info returns [pool_size, label, current_round, total_draws]
16+
const poolInfo = await function_view({
17+
functionStr: `${pool}::${MODULE}::pool_info`,
18+
args: [pool],
19+
});
20+
const currentRound = poolInfo[2];
21+
22+
// round_state returns [status, sold, pool_size, pot]
23+
const roundState = await function_view({
24+
functionStr: `${pool}::${MODULE}::round_state`,
25+
args: [pool, currentRound],
26+
});
27+
const pot = roundState[3]; // in octas (1e8)
28+
29+
api.add(APT, pot);
30+
}
31+
}
32+
33+
module.exports = {
34+
timetravel: false,
35+
methodology:
36+
"TVL is the sum of APT locked in the active lottery round vaults across the 4 immutable Aptos pool contracts.",
37+
aptos: { tvl },
38+
};

0 commit comments

Comments
 (0)