Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit fce7d7a

Browse files
authored
[xaqua-vaults-treasury] Add xaqua-vaults-treasury strategy (#1780)
* Add xaqua-vaults-treasury strategy * Add xaqua-vaults-treasury strategy * Add xaqua-vaults-treasury strategy * refactor: remove manual chunking, use multicall batching * refactor: remove manual chunking, use multicall batching
1 parent 115ca7a commit fce7d7a

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

src/strategies/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ import * as trancheStakingLP from './tranche-staking-lp';
128128
import * as masterchefPoolBalance from './masterchef-pool-balance';
129129
import * as masterchefPoolBalancePrice from './masterchef-pool-balance-price';
130130
import * as api from './api';
131+
import * as xaqua from './xaqua-vaults-treasury';
131132
import * as apiPost from './api-post';
132133
import * as apiV2 from './api-v2';
133134
import * as xseen from './xseen';
@@ -500,6 +501,7 @@ const strategies = {
500501
'erc20-balance-of-saevo': erc20BalanceOfSaevo,
501502
livepeer,
502503
'spooky-lp-sonic': spookyLpSonic,
504+
'xaqua-vaults-treasury': xaqua,
503505
'delegatexyz-erc721-balance-of': delegatexyzErc721BalanceOf,
504506
'giveth-balances-supply-weighted': givethBalancesSupplyWeighted,
505507
'giveth-gnosis-balance-supply-weighted-v3':
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
{
3+
"name": "Custom vault + treasury strategy",
4+
"strategy": {
5+
"name": "xaqua-vaults-treasury",
6+
"params": {
7+
"vault1": "0x8f0d1a8d2f2f0d9b297e6d4d7cd234ab638df51f",
8+
"vault2": "0x589fad2960b93efdfc0f86fcb5606cf625d8f755",
9+
"treasury": "0x46b6d5732d1b86f4fac7572efb675afbaba8164b",
10+
"decimals": 18
11+
}
12+
},
13+
"network": "146",
14+
"addresses": [
15+
"0x76E9EB9e6EA511A56D5625014c8a1708Bea49419",
16+
"0xbA3dc81872F61Ca7f80F1f1786F0dd316F68DA99",
17+
"0xFcD804207271E0cbFcf363891F4DF4Af2DBDc12B"
18+
],
19+
"snapshot": 38921180
20+
}
21+
]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { formatUnits } from '@ethersproject/units';
2+
import { multicall } from '../../utils';
3+
4+
export const author = 'pepperati224';
5+
export const version = '0.1.0';
6+
7+
export async function strategy(
8+
space,
9+
network,
10+
provider,
11+
addresses,
12+
options,
13+
snapshot
14+
) {
15+
const blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
16+
17+
const abi = [
18+
'function balanceOf(address) view returns (uint256)',
19+
'function usersAllocation(address) view returns (uint256)'
20+
];
21+
22+
const callData: [any, string, [any]][] = [];
23+
24+
// Prepare multicall input
25+
for (const address of addresses) {
26+
callData.push([options.vault1, 'balanceOf', [address]]);
27+
callData.push([options.vault2, 'balanceOf', [address]]);
28+
callData.push([options.treasury, 'usersAllocation', [address]]);
29+
}
30+
31+
const response: any[] = await multicall(network, provider, abi, callData, {
32+
blockTag
33+
});
34+
// Aggregate scores
35+
const scores: Record<string, number> = {};
36+
37+
for (let i = 0; i < addresses.length; i++) {
38+
const address = addresses[i];
39+
const vault1Res = response[i * 3];
40+
const vault2Res = response[i * 3 + 1];
41+
const treasuryRes = response[i * 3 + 2];
42+
43+
const vault1Bal = vault1Res?.[0] ?? 0;
44+
const vault2Bal = vault2Res?.[0] ?? 0;
45+
const treasuryBal = treasuryRes?.[0] ?? 0;
46+
47+
const total = BigInt(vault1Bal) + BigInt(vault2Bal) + BigInt(treasuryBal);
48+
49+
scores[address] = parseFloat(
50+
formatUnits(total.toString(), options.decimals)
51+
);
52+
}
53+
54+
return scores;
55+
}

0 commit comments

Comments
 (0)