Skip to content

Commit 70cf9de

Browse files
cosi10a1g1nt0ki
andauthored
Add ILoop project (DefiLlama#12923)
Co-authored-by: g1nt0ki <[email protected]>
1 parent 22db430 commit 70cf9de

File tree

2 files changed

+196
-0
lines changed

2 files changed

+196
-0
lines changed

projects/iloop/iloop_sc_mainnet.json

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
{
2+
"address": "3i8rGP3ex8cjs7YYWrQeE4nWizuaStsVNUXpRGtMbs3H",
3+
"metadata": {
4+
"name": "iloop_sc",
5+
"version": "0.1.0",
6+
"spec": "0.1.0",
7+
"description": "Created with Anchor"
8+
},
9+
"instructions": [],
10+
"accounts": [
11+
{
12+
"name": "Reserve",
13+
"discriminator": [
14+
43,
15+
242,
16+
204,
17+
202,
18+
26,
19+
247,
20+
59,
21+
127
22+
]
23+
}
24+
],
25+
"events": [],
26+
"errors": [],
27+
"types": [
28+
{
29+
"name": "Reserve",
30+
"serialization": "bytemuck",
31+
"repr": {
32+
"kind": "c"
33+
},
34+
"type": {
35+
"kind": "struct",
36+
"fields": [
37+
{
38+
"name": "lending_market",
39+
"type": "pubkey"
40+
},
41+
{
42+
"name": "liquidity_mint",
43+
"type": "pubkey"
44+
},
45+
{
46+
"name": "liquidity_supply",
47+
"type": "pubkey"
48+
},
49+
{
50+
"name": "liquidity_supply_amount",
51+
"type": "u64"
52+
},
53+
{
54+
"name": "liquidity_price",
55+
"type": "u64"
56+
},
57+
{
58+
"name": "liquidity_price_account",
59+
"type": "pubkey"
60+
},
61+
{
62+
"name": "liquidity_price_max_age_price_seconds",
63+
"type": "u64"
64+
},
65+
{
66+
"name": "liquidity_price_updated_at",
67+
"type": "u64"
68+
},
69+
{
70+
"name": "collateral_mint",
71+
"type": "pubkey"
72+
},
73+
{
74+
"name": "collateral_supply",
75+
"type": "pubkey"
76+
},
77+
{
78+
"name": "collateral_supply_amount",
79+
"type": "u64"
80+
},
81+
{
82+
"name": "borrow_rate",
83+
"type": "u64"
84+
},
85+
{
86+
"name": "deposit_rate",
87+
"type": "u64"
88+
},
89+
{
90+
"name": "borrow_enabled",
91+
"type": "u64"
92+
},
93+
{
94+
"name": "borrowed_amount",
95+
"type": "u64"
96+
},
97+
{
98+
"name": "borrowed_collateral_amount",
99+
"type": "u64"
100+
},
101+
{
102+
"name": "max_withdraw_per_day",
103+
"type": "u64"
104+
},
105+
{
106+
"name": "withdrew_today",
107+
"type": "u64"
108+
},
109+
{
110+
"name": "last_withdrew_at",
111+
"type": "i64"
112+
},
113+
{
114+
"name": "margin_rate",
115+
"type": "u64"
116+
},
117+
{
118+
"name": "optimal_utilization_rate_1",
119+
"type": "u64"
120+
},
121+
{
122+
"name": "optimal_utilization_rate_2",
123+
"type": "u64"
124+
},
125+
{
126+
"name": "max_borrow_rate",
127+
"type": "u64"
128+
},
129+
{
130+
"name": "reserve_factor",
131+
"type": "u64"
132+
},
133+
{
134+
"name": "max_multiply",
135+
"type": "u64"
136+
},
137+
{
138+
"name": "max_supply",
139+
"type": "u64"
140+
},
141+
{
142+
"name": "liquidation_threshold",
143+
"type": "u64"
144+
},
145+
{
146+
"name": "liquidation_penalty",
147+
"type": "u64"
148+
},
149+
{
150+
"name": "flash_loan_enabled",
151+
"type": "u64"
152+
},
153+
{
154+
"name": "utilization_cap",
155+
"type": "u64"
156+
},
157+
{
158+
"name": "apy",
159+
"type": "u64"
160+
},
161+
{
162+
"name": "updated_at",
163+
"type": "i64"
164+
}
165+
]
166+
}
167+
}
168+
]
169+
}

projects/iloop/index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { Program, } = require('@coral-xyz/anchor');
2+
const iloopIdl = require('./iloop_sc_mainnet.json');
3+
const { sumTokens2, getProvider } = require("../helper/solana");
4+
5+
async function tvl() {
6+
const provider = getProvider();
7+
const iloopProgram = new Program(iloopIdl, provider);
8+
const reserves = await iloopProgram.account.reserve.all();
9+
const tokenAccounts = reserves.map(({ account }) => account.liquiditySupply.toBase58());
10+
return sumTokens2({ tokenAccounts })
11+
}
12+
async function borrowed(api) {
13+
const provider = getProvider();
14+
const iloopProgram = new Program(iloopIdl, provider);
15+
const reserves = await iloopProgram.account.reserve.all();
16+
for (const { account } of reserves) {
17+
api.add(account.liquidityMint.toBase58(), account.borrowedAmount)
18+
}
19+
}
20+
21+
module.exports = {
22+
timetravel: false,
23+
solana: {
24+
tvl, borrowed,
25+
},
26+
methodology: 'TVL consists of deposits made to the protocol, borrowed tokens are not counted.',
27+
};

0 commit comments

Comments
 (0)