From 6b5db6d21814a0776ffdfb31ec26518d58cc9b5b Mon Sep 17 00:00:00 2001 From: somer Date: Wed, 19 Jun 2024 17:20:11 +0800 Subject: [PATCH 1/3] add solayer adapter --- projects/solayer/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 projects/solayer/index.js diff --git a/projects/solayer/index.js b/projects/solayer/index.js new file mode 100644 index 000000000000..6bc918de6987 --- /dev/null +++ b/projects/solayer/index.js @@ -0,0 +1,16 @@ +const utils = require('../helper/utils'); +const totlaTvlEndpoint = "https://app-staging.solayer.org/api/total_tvl" + +async function tvl() { + const totalTvl = await utils.fetchURL(totlaTvlEndpoint) + const totalTvlValue = parseFloat(totalTvl.data); + return totalTvlValue +} + +module.exports = { + timetravel: false, + solana:{ + fetch: tvl + }, + methodology: 'TVL consists of deposits made to the protocol', +} From 5478fcae78e3b6258cb3e3899b3e08b81cc91462 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 21 Jun 2024 00:55:38 -0700 Subject: [PATCH 2/3] refactor: Update solayer index.js for TVL calculation and methodology --- projects/solayer/index.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/projects/solayer/index.js b/projects/solayer/index.js index 6bc918de6987..9657dd695238 100644 --- a/projects/solayer/index.js +++ b/projects/solayer/index.js @@ -1,16 +1,28 @@ -const utils = require('../helper/utils'); -const totlaTvlEndpoint = "https://app-staging.solayer.org/api/total_tvl" +const { sumTokens2, getConnection } = require("../helper/solana"); +const { PublicKey } = require("@solana/web3.js"); async function tvl() { - const totalTvl = await utils.fetchURL(totlaTvlEndpoint) - const totalTvlValue = parseFloat(totalTvl.data); - return totalTvlValue + const connection = getConnection(); + const [account, lst] = await Promise.all([ + connection.getAccountInfo(new PublicKey('po1osKDWYF9oiVEGmzKA4eTs8eMveFRMox3bUKazGN2')), + sumTokens2({ + tokensAndOwners: [ + ['J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn', 'GgTE2exWZ36Q82FoVgEEzEHYCfsbGjm3P6zRfx3hLUv4'], + ['mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So', 'E9LmYVKU5oyjWs9Zmzv9ji8NkzhJxJQbUEH3FWDKZt8D'], + ['bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1', '2DRZbbse5b5souvMQkifpS8CRBsDeLt6a9xDqqVJvmdw'], + ['5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm', 'GF8jvNGY44tnCfhnzdoSUBpgfog9YnLc6BRBCnt8j9do'] + ], + }) + ]); + + return { + solana: Number(account.data.readBigUint64LE(258)) / 1e9, + ...lst + }; } module.exports = { timetravel: false, - solana:{ - fetch: tvl - }, - methodology: 'TVL consists of deposits made to the protocol', -} + methodology: "TVL is calculated by summing all re-staked assets.", + solana: { tvl }, +}; From 95c6cd7f38d6071c37676a177ece8782ba603dcd Mon Sep 17 00:00:00 2001 From: Joshua Sum Date: Thu, 15 Aug 2024 16:30:27 -0700 Subject: [PATCH 3/3] update: add in hubSOL and hSOL for TVL calculations --- projects/solayer/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/solayer/index.js b/projects/solayer/index.js index 9657dd695238..93a68c5879e0 100644 --- a/projects/solayer/index.js +++ b/projects/solayer/index.js @@ -10,7 +10,9 @@ async function tvl() { ['J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn', 'GgTE2exWZ36Q82FoVgEEzEHYCfsbGjm3P6zRfx3hLUv4'], ['mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So', 'E9LmYVKU5oyjWs9Zmzv9ji8NkzhJxJQbUEH3FWDKZt8D'], ['bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1', '2DRZbbse5b5souvMQkifpS8CRBsDeLt6a9xDqqVJvmdw'], - ['5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm', 'GF8jvNGY44tnCfhnzdoSUBpgfog9YnLc6BRBCnt8j9do'] + ['5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm', 'GF8jvNGY44tnCfhnzdoSUBpgfog9YnLc6BRBCnt8j9do'], + ['HUBsveNpjo5pWqNkH57QzxjQASdTVXcSK7bVKTSZtcSX', '49EXLuCxc2ArgFfpJBeuci6DgULxMzrETAHpAGvsFBf1'], + ['Gwa3a4VJbAyorLhn6TEeWLbQ4tWyup4E6oL3WjAga7tx', '2DriEN733SMxEzqDBVSGwev7KwcdHPXVy65sw9u5mR14'] ], }) ]);