Skip to content

Commit 96dcf42

Browse files
authored
feat: add Valdora Finance (#17014)
1 parent 7b9f3ad commit 96dcf42

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

projects/valdora/index.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const { queryContract } = require('../helper/chain/cosmos');
2+
const { transformBalances } = require('../helper/portedTokens');
3+
4+
// Valdora Staker contract address (https://docs.valdora.finance/smart-contracts)
5+
const VALDORA_STAKER_CONTRACT = 'zig18nnde5tpn76xj3wm53n0tmuf3q06nruj3p6kdemcllzxqwzkpqzqk7ue55';
6+
7+
/**
8+
* Fetches the AUM from the Valdora Staker contract
9+
*
10+
* How it works:
11+
* 1. Query the contract with funds_raised: "How much funds have been under management?"
12+
* 2. The contract responds with funds_raised (amount of uzig under management)
13+
*
14+
* Returns the amount of uzig under management (or null if query fails)
15+
* Example: if 1000 uZIG are under management, returns 1000
16+
*/
17+
async function fetchAUM() {
18+
const { funds_raised } = await queryContract({
19+
contract: VALDORA_STAKER_CONTRACT,
20+
chain: 'zigchain',
21+
data: { funds_raised: {} },
22+
});
23+
24+
if (!funds_raised || funds_raised === '0') return null;
25+
26+
return funds_raised;
27+
}
28+
29+
30+
async function tvl(api) {
31+
try {
32+
const aum = await fetchAUM();
33+
const balances = api.getBalances();
34+
balances['zigchain:uzig'] = aum;
35+
return transformBalances('zigchain', balances);
36+
} catch (error) {
37+
console.error('Error calculating TVL:', error);
38+
throw error;
39+
}
40+
}
41+
42+
module.exports = {
43+
timetravel: false,
44+
misrepresentedTokens: false,
45+
methodology: 'TVL is calculated by fetching Valdora finance\'s AUM',
46+
zigchain: { tvl }
47+
};

0 commit comments

Comments
 (0)