Skip to content

Commit c1ab54d

Browse files
buchaoqung1nt0kiqwen-solvAn-Haijun
authored
Add Solana (DefiLlama#14297)
Co-authored-by: g1nt0ki <[email protected]> Co-authored-by: qwen-solv <[email protected]> Co-authored-by: hja <[email protected]>
1 parent 96c3d82 commit c1ab54d

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

projects/solv-protocol-funds/index.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { getConfig } = require("../helper/cache");
44
const { cachedGraphQuery } = require("../helper/cache");
55
const { sumTokens2, } = require("../helper/unwrapLPs");
66
const { getAmounts } = require("./iziswap");
7+
const { sumTokens2: sumTokens2Solana } = require('../helper/solana')
78

89
// The Graph
910
const graphUrlList = {
@@ -38,12 +39,13 @@ async function tvl(api) {
3839
await mux(api, address);
3940
await klp(api, address);
4041
await iziswap(api, address);
41-
await lendle(api, address);
42+
await derivativeToken(api, address);
4243
await vaultBalance(api, graphData);
4344
await otherDeposit(api, address);
4445
await ceffuBalance(api, address, graphData);
4546
await lpV3PositionsBalance(api, address);
4647
await aaveSupplyBalance(api, address);
48+
await solanaTvl(api, address);
4749

4850
(solvTokens[api.chain] ?? []).forEach(token => {
4951
api.removeTokenBalance(token)
@@ -225,15 +227,15 @@ async function concrete(slots, api) {
225227
return concretes;
226228
}
227229

228-
async function lendle(api, address) {
229-
if (!address[api.chain] || !address[api.chain]["lendle"]) {
230+
async function derivativeToken(api, address) {
231+
if (!address[api.chain] || !address[api.chain]["derivativeData"]) {
230232
return;
231233
}
232-
let lendleData = address[api.chain]["lendle"];
234+
let derivativeTokenData = address[api.chain]["derivativeData"];
233235

234-
const balance = await api.call({ abi: abi.balanceOf, target: lendleData.aToken, params: lendleData.account.user });
236+
const balance = await api.call({ abi: abi.balanceOf, target: derivativeTokenData.derivativeToken, params: derivativeTokenData.account.userAddress });
235237

236-
api.add(lendleData.account.ethAddress, balance)
238+
api.add(derivativeTokenData.account.underlyingToken, balance)
237239
}
238240

239241
async function vaultBalance(api, graphData) {
@@ -401,7 +403,6 @@ async function aaveSupplyBalance(api, address) {
401403
params: [index[1]]
402404
})));
403405
}
404-
405406
const balances = await api.multiCall({
406407
abi: abi.balanceOf,
407408
calls: allCalls,
@@ -414,6 +415,14 @@ async function aaveSupplyBalance(api, address) {
414415
}
415416
}
416417

418+
async function solanaTvl(api, address) {
419+
if (api.chain !== 'solana' || !address[api.chain]) return;
420+
421+
const tokenAccounts = address[api.chain];
422+
423+
return sumTokens2Solana({ tokenAccounts });
424+
}
425+
417426
async function getGraphData(timestamp, chain, api) {
418427
let rwaSlot = (await getConfig('solv-protocol/slots', slotListUrl));
419428

@@ -445,7 +454,7 @@ async function getGraphData(timestamp, chain, api) {
445454

446455

447456
// node test.js projects/solv-protocol-funds
448-
['ethereum', 'bsc', 'polygon', 'arbitrum', 'mantle', 'merlin'].forEach(chain => {
457+
['ethereum', 'bsc', 'polygon', 'arbitrum', 'mantle', 'merlin', 'solana'].forEach(chain => {
449458
module.exports[chain] = {
450459
tvl
451460
}

0 commit comments

Comments
 (0)