Skip to content

Commit ce2f424

Browse files
Hourglass adaptor (DefiLlama#11956)
Co-authored-by: g1nt0ki <[email protected]>
1 parent dbff19c commit ce2f424

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

projects/hourglass/index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const ADDRESSES = require('../helper/coreAssets.json')
2+
const { getLogs2 } = require('../helper/cache/getLogs')
3+
4+
const ethereum_pitchfxs = '0x11ebe21e9d7bf541a18e1e3ac94939018ce88f0b';
5+
6+
const config = {
7+
ethereum: { factory: '0x679619FA685a18782a86dD5850124A75E83daD8F', fromBlock: 19877998 },
8+
mantle: { factory: '0x624bd5ba06A856C4D5f60c8Ba29eeE1f684Ddf05', fromBlock: 65870976 },
9+
}
10+
11+
module.exports = {
12+
methodology: 'TVL accounts for all assets deposited into our boosted vaults. It also includes the amount of FXS time-locked and minted as pitchFXS.',
13+
};
14+
15+
16+
Object.keys(config).forEach(chain => {
17+
const { factory, fromBlock, } = config[chain]
18+
module.exports[chain] = {
19+
tvl: async (api) => {
20+
if (chain === 'ethereum')
21+
await computePitchfxsTvl(api)
22+
const logs = await getLogs2({
23+
api,
24+
factory,
25+
eventAbi: 'event NewMaturityCreated (uint256 deploymentIndex, address depositor, address[] receipts)',
26+
fromBlock,
27+
})
28+
29+
const vaults = logs.map(log => log.depositor)
30+
const tokens = await api.multiCall({ abi: 'address:getUnderlying', calls: vaults })
31+
return api.sumTokens({ tokensAndOwners2: [tokens, vaults] })
32+
}
33+
}
34+
})
35+
36+
const computePitchfxsTvl = async (api) => {
37+
const balance = await api.call({
38+
target: ethereum_pitchfxs,
39+
params: [],
40+
abi: 'erc20:totalSupply',
41+
});
42+
43+
api.addToken(ADDRESSES.ethereum.FXS, balance);
44+
}

0 commit comments

Comments
 (0)