Skip to content

Commit a51b01e

Browse files
tivtrong1nt0ki
andauthored
add-AggreLend-tvl-adapter (#16115)
Co-authored-by: g1nt0ki <[email protected]>
1 parent 0e446a8 commit a51b01e

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

projects/AggreLend/idl.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"version": "0.1.0",
3+
"name": "aggrelend",
4+
"instructions": [],
5+
"accounts": [
6+
{
7+
"name": "PoolVault",
8+
"type": {
9+
"kind": "struct",
10+
"fields": [
11+
{"name": "vault", "type": "publicKey"},
12+
{"name": "tokenMint", "type": "publicKey"},
13+
{"name": "depositTokens", "type": "u64"},
14+
{"name": "scaledShares", "type": "u128"},
15+
{"name": "lastAccruedTime", "type": "i64"},
16+
{"name": "cumulativeYieldIndex", "type": "u128"},
17+
{"name": "hasMarket", "type": {"array": ["bool", 45]}},
18+
{"name": "rewards", "type": "u64"},
19+
{"name": "boost", "type": "bool"},
20+
{"name": "bump", "type": "u8"}
21+
]
22+
}
23+
}
24+
],
25+
"events": [],
26+
"errors": [],
27+
"types": []
28+
}

projects/AggreLend/index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { getProvider } = require('../helper/solana')
2+
const { Program } = require('@project-serum/anchor')
3+
const idl = require('./idl.json')
4+
5+
const PROGRAM_ID = 'AGGREbma2Gi9unS1mPptAcG4HmkMTLNmqcunYaSSf46b'
6+
7+
const tvl = async (api) => {
8+
const provider = getProvider()
9+
const program = new Program(idl, PROGRAM_ID, provider)
10+
11+
const vaults = await program.account.poolVault.all()
12+
13+
for (const { account: pool } of vaults)
14+
api.add(pool.tokenMint.toBase58(), pool.depositTokens.toString())
15+
}
16+
17+
module.exports = {
18+
methodology: 'Sum of all assets deposited into the AggreLend protocol for yield aggregation.',
19+
doublecounted: true,
20+
timetravel: false,
21+
solana: { tvl },
22+
}

utils/formatIdl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ idl.errors = []
1010

1111
const whitelistedTypes = new Set()
1212
const typeMap = {}
13-
idl.types.forEach(t => typeMap[t.name] = t)
13+
idl.types?.forEach(t => typeMap[t.name] = t)
1414
const whitelistedTypeMap = {}
1515
const accountMap = {}
1616
idl.accounts.forEach(a => accountMap[a.name] = a)

0 commit comments

Comments
 (0)