Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: count rings as sonic TVL #13206

Merged
merged 6 commits into from
Jan 27, 2025
Merged

Conversation

0xtekgrinder
Copy link
Contributor

Count rings total volume locked as rings

@llamabutler
Copy link

Error while running adapter at projects/rings:

SyntaxError: Identifier 'ADDRESSES' has already been declared
Truncated error stack:

    at /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:127:12
    at Object.<anonymous> (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:265:3)
Error saving cache: Error: ENOENT: no such file or directory, open '/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/@defillama/sdk/build/util/local_cache/zlib-1.0/BlockCache.json'

@llamabutler
Copy link

The adapter at projects/rings exports TVL:

sonic                     14.98 M

total                    14.98 M 

@0xpeluche 0xpeluche self-assigned this Jan 23, 2025
@0xpeluche
Copy link
Contributor

Hi, thanks for the PR! Correct me if I’m wrong, but you tried to include the staking part of the protocol in the TVL, right? In that case, it’s better to include this in the staking section rather than the TVL. It’s also preferable to keep the code as it was previously. Currently, we count in the TVL the collateral on the Ethereum vaults, even if the CDP minting happens on Sonic via LayerZero. In general, we always prioritize counting the collateral in the TVL rather than using the token supply for TVL, as this ensures that the assets are properly backed

@0xpeluche
Copy link
Contributor

If I didn't misunderstand your intentions, the adapter might look more like this instead :

const ADDRESSES = require('../helper/coreAssets.json')
const { sumTokensExport } = require("../helper/unwrapLPs");
const { stakings } = require("../helper/staking");

module.exports = {
  methodology: 'TVL counts the tokens deposited in the boring vaults.',
  start: 1733726867
}

const CONFIG = {
  ethereum: {
    vaults: [
      '0xd3DCe716f3eF535C5Ff8d041c1A41C3bd89b97aE',
      '0x3bcE5CB273F0F148010BbEa2470e7b5df84C7812',
    ],
    supportedAssets: [
      ADDRESSES.ethereum.USDC,                         // USDC
      ADDRESSES.ethereum.USDT,                         // USDT
      ADDRESSES.ethereum.DAI,                          // DAI
      ADDRESSES.ethereum.SDAI,                         // SDAI
      ADDRESSES.ethereum.sUSDS,                        // SUSDS
      ADDRESSES.ethereum.WETH,                         // WETH
      ADDRESSES.ethereum.WSTETH,                       // WSTETH
      ADDRESSES.ethereum.WEETH,                        // WEETH
      '0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f', // GHO
      '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c', // AAVEUSDC
      '0x23878914EFE38d27C4D67Ab83ed1b93A74D4086a', // AAVEUSDT
      '0x1a88Df1cFe15Af22B3c4c783D4e6F7F9e0C1885d', // STKGHO
      '0xdC035D45d973E3EC169d2276DDab16f1e407384F', // USDS
      '0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8', // AAVEWETH
      '0xd63070114470f685b75B74D60EEc7c1113d33a3D'  // USDO MORPHO
    ]
  },
  sonic: {
    vaults: [
      '0xd3DCe716f3eF535C5Ff8d041c1A41C3bd89b97aE',
      '0x3bcE5CB273F0F148010BbEa2470e7b5df84C7812'
    ],
    supportedAssets: [
      ADDRESSES.sonic.USDC_e,                          // USDC
      '0x50c42dEAcD8Fc9773493ED674b675bE577f2634b', // WETH
    ],
    stakingVaults: [
      '0x4d85ba8c3918359c78ed09581e5bc7578ba932ba',   // stkscUSD
      '0x455d5f11Fea33A8fa9D3e285930b478B6bF85265'    // stkscETH   
    ],
    stakingSupportedAssets: [
      '0xd3DCe716f3eF535C5Ff8d041c1A41C3bd89b97aE',   // scUSD
      '0x3bce5cb273f0f148010bbea2470e7b5df84c7812',   // scETH
    ]
  },
}

Object.keys(CONFIG).forEach((chain) => {
  const {  vaults, supportedAssets,  stakingVaults = [], stakingSupportedAssets = [] } = CONFIG[chain]
  module.exports[chain] = { 
    tvl: sumTokensExport({ owners: vaults, tokens: supportedAssets }),
    staking: stakings(stakingVaults, stakingSupportedAssets),
  };
});

image

@0xtekgrinder
Copy link
Contributor Author

@0xpeluche The idea wasn't really to count the staking but instead of having the whole TVL as counted on sonic instead of majority on ethereum as minting usually happens on sonic but we bridge afterwards the collaterals.

If you wish to not count the totalSupply, could I refactor the adaptor to use the price of all the collaterals but only end up adding up as sonic chain ?

@0xpeluche
Copy link
Contributor

I'm sorry, we can't do that. Even though I understand that most of the minting happens on Sonic, the collaterals are still on Ethereum. Therefore, the TVL is mostly on Ethereum because we don't count the minted CDP token but the tokens backing them

@llamabutler
Copy link

The adapter at projects/rings exports TVL:

ethereum                  15.98 M
sonic-staking             6.02 M
staking                   6.02 M
sonic                     2.45 M
ethereum-staking          0

total                    18.44 M 

@llamabutler
Copy link

The adapter at projects/rings exports TVL:

ethereum                  15.98 M
sonic-staking             6.02 M
staking                   6.02 M
sonic                     3.30 M
ethereum-staking          0

total                    19.29 M 

@0xtekgrinder
Copy link
Contributor Author

0xtekgrinder commented Jan 24, 2025

Understood @0xpeluche , updated the PR to add staking + missing collaterals. The only problem I have is that the staking vaults aren't meant to only hold scUSD / scETH but also yield bearings assets such as silo lending, beets LP ... (currently it only holds beets LP and scUSD)

@0xpeluche 0xpeluche merged commit a610cd0 into DefiLlama:main Jan 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants