Skip to content

Commit a3e3bb1

Browse files
committed
Add GAIB protocol support for multiple chains with TVL calculation (DefiLlama#15515)
1 parent 817d6aa commit a3e3bb1

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

projects/gaib/index.js

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
const mainnetContracts = {
2+
ethereum: [
3+
{
4+
token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
5+
poolToken: '0xd5255Cc08EBAf6D54ac9448822a18d8A3da29A42' // AIDollarAlphaUSDC Pool
6+
},
7+
{
8+
token: '0xdAC17F958D2ee523a2206206994597C13D831ec7', // USDT
9+
poolToken: '0xDc45e7027A0489FE6C2E4A0735097d8E6952A340' // AIDollarAlphaUSDT Pool
10+
},
11+
{
12+
token: '0x66a1E37c9b0eAddca17d3662D6c05F4DECf3e110', // USR
13+
poolToken: '0x5D976F56343e33A6a4d6e26AF7d59358d1359dd4' // AIDollarAlphaUSR Pool
14+
},
15+
{
16+
token: '0xaD55aebc9b8c03FC43cd9f62260391c13c23e7c0', // CUSDO
17+
poolToken: '0x17D02bCA29BD9E8cF4A39B25C9C902e6bF00AA54' // AIDollarAlphaCUSDO Pool
18+
}
19+
],
20+
arbitrum: [
21+
{
22+
token: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // USDC
23+
poolToken: '0xd5255Cc08EBAf6D54ac9448822a18d8A3da29A42' // AIDollarAlphaUSDC Pool
24+
},
25+
{
26+
token: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9', // USDT
27+
poolToken: '0xDc45e7027A0489FE6C2E4A0735097d8E6952A340' // AIDollarAlphaUSDT Pool
28+
}
29+
],
30+
base: [
31+
{
32+
token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC
33+
poolToken: '0xd5255Cc08EBAf6D54ac9448822a18d8A3da29A42' // AIDollarAlphaUSDC Pool
34+
}
35+
],
36+
plume: [
37+
{
38+
token: '0xdddD73F5Df1F0DC31373357beAC77545dC5A6f3F', // PUSD
39+
poolToken: '0xd5255Cc08EBAf6D54ac9448822a18d8A3da29A42' // AIDaPUSD Pool
40+
}
41+
],
42+
sei: [
43+
{
44+
token: '0x3894085Ef7Ff0f0aeDf52E2A2704928d1Ec074F1', // USDC
45+
poolToken: '0xd5255Cc08EBAf6D54ac9448822a18d8A3da29A42' // AIDollarAlphaUSDC Pool
46+
},
47+
{
48+
token: '0x9151434b16b9763660705744891fA906F660EcC5', // USDT
49+
poolToken: '0xDc45e7027A0489FE6C2E4A0735097d8E6952A340' // AIDollarAlphaUSDT Pool
50+
}
51+
],
52+
// story: [
53+
// {
54+
// token: '0xF1815bd50389c46847f0Bda824eC8da914045D14', // USDC
55+
// poolToken: '0xd5255Cc08EBAf6D54ac9448822a18d8A3da29A42' // AIDollarAlphaUSDC Pool
56+
// }
57+
// ]
58+
};
59+
60+
const totalAssetsABI = {
61+
"inputs": [],
62+
"name": "totalAssets",
63+
"outputs": [
64+
{
65+
"internalType": "uint256",
66+
"name": "",
67+
"type": "uint256"
68+
}
69+
],
70+
"stateMutability": "view",
71+
"type": "function"
72+
};
73+
74+
async function tvl(api) {
75+
const chain = api.chain;
76+
77+
const poolsForChain = mainnetContracts[chain];
78+
79+
if (!poolsForChain || poolsForChain.length === 0) {
80+
console.warn(`No configured contract data for chain: ${chain}. Skipping TVL calculation.`);
81+
return {};
82+
}
83+
84+
const calls = poolsForChain.map(poolInfo => ({
85+
target: poolInfo.poolToken,
86+
}));
87+
88+
const totalAssetsAmounts = await api.multiCall({
89+
abi: totalAssetsABI,
90+
calls: calls,
91+
});
92+
93+
totalAssetsAmounts.forEach((amount, index) => {
94+
const underlyingToken = poolsForChain[index].token;
95+
api.add(underlyingToken, amount);
96+
});
97+
98+
return api.getBalances();
99+
}
100+
101+
module.exports = {
102+
methodology: 'Counts the total underlying assets (e.g., USDC, USDT, USR, CUSDO, PUSD) reported by GAIB protocol pool contracts using their `totalAssets()` function across supported mainnet chains.',
103+
start: 1715490671,
104+
timetravel: true,
105+
misrepresentedTokens: false,
106+
107+
ethereum: {
108+
tvl,
109+
},
110+
arbitrum: {
111+
tvl,
112+
},
113+
base: {
114+
tvl,
115+
},
116+
plume: {
117+
tvl,
118+
},
119+
sei: {
120+
tvl,
121+
},
122+
// story: {
123+
// tvl,
124+
// },
125+
};

0 commit comments

Comments
 (0)