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

Update Royco TVL to include corrected calculations for Recipe and Vau… #12925

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

githubotoro
Copy link
Contributor

…lt Markets

NOTE

Please enable "Allow edits by maintainers" while putting up the PR.


  • If you would like to add a volume adapter please submit the PR here.
  • If you would like to add a liquidations adapter, please refer to this readme document for details.
  1. Once your adapter has been merged, it takes time to show on the UI. If more than 24 hours have passed, please let us know in Discord.
  2. Sorry, We no longer accept fetch adapter for new projects, we prefer the tvl to computed from blockchain data, if you have trouble with creating a the adapter, please hop onto our discord, we are happy to assist you.
  3. Please fill the form below only if the PR is for listing a new protocol else it can be ignored/replaced with reason/details about the PR
  4. For updating listing info It is a different repo, you can find your listing in this file: https://github.com/DefiLlama/defillama-server/blob/master/defi/src/protocols/data2.ts, you can edit it there and put up a PR
  5. Do not edit/push package-lock.json file as part of your changes, we use lockfileVersion 2, and most use v1 and using that messes up our CI
  6. No need to go to our discord and announce that you've created a PR, we monitor all PRs and will review it asap

Name (to be shown on DefiLlama):
Twitter Link:
List of audit links if any:
Website Link:
Logo (High resolution, will be shown with rounded borders):
Current TVL:
Treasury Addresses (if the protocol has treasury)
Chain:
Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed): (https://api.coingecko.com/api/v3/coins/list)
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed): (https://api.coinmarketcap.com/data-api/v3/map/all?listing_status=active,inactive,untracked&start=1&limit=10000)
Short Description (to be shown on DefiLlama):
Token address and ticker if any:
Category (full list at https://defillama.com/categories) *Please choose only one:
Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.):
Implementation Details: Briefly describe how the oracle is integrated into your project:
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
forkedFrom (Does your project originate from another project):
methodology (what is being counted as tvl, how is tvl being calculated):
Github org/user (Optional, if your code is open source, we can track activity):

@llamabutler
Copy link

The adapter at projects/royco exports TVL:

ethereum                  2.43 M
arbitrum                  213.86 k
base                      23.93 k

total                    2.67 M 

);

if (currTimestampInSeconds.isLessThan(endTimestampInSeconds)) {
api.add(incentiveTokenId, incentiveTokenAmount);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we read balances from the chain using an rpc instead? propietary apis are fine for reading config data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not possible to read balances directly from chain data because of following limitations:

  1. For Vault Markets:
  • The wrapped vault is a wrapper around another ERC4626 vault and therefore, wrapped vault itself holds no assets
  • The previously committed version of royco TVL was counting balances of issued vault tokens of Wrapped Vault, rather than the assets deposited by the wrapped vault into the underlying ERC4626 vault -- this was making significant amount of TVL being excluded in summation
  1. For Recipe Markets:
  • The assets are deposited & withdrawn by the weiroll script (this is an arbitrary sequence of transactions which will differ for each market, like swap into some other token, then deposit half in one contract, rest in another, etc.) -- so we can't deterministically find the token address and it's token amount
  • The amount deposited and received is not being stored on-chain, and is only emitted as an event -- these events are then indexed by subgraph, to calculate what amount is currently present inside the market
  • The events are interdependent on one another, for example: in order to find out how much an LP deposited into the market, first we need to find the event that LP filled -> this gives the address of weiroll wallet (this wallet is generated uniquely every time an LP fills a position) -> then we need to find the offer id which was filled -> based on offer id, we need to find the IP event that had made the offer, this gives us the corresponding market id -> based on market id, we need to find the Market Creation event, this gives us the input asset that was deposited -> finally, this gives us liquidity of one one position of an LP -> Now, we need to find all positions of all LPs inside all markets -> therefore, this requires a cumulative calculation, rather than on-demand -- so we are doing them in subgraph.

Moreover, the entire code of subgraph is open-source and can be referenced in this repo: https://github.com/roycoprotocol/royco-subgraphs-template

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @githubotoro

For vault markets, noticed that we are not pricing some of the erc4626 tokens, we will fix it.

For Recipe markets, you dont hold user funds right? they do some action and you rewards wallets later right? if this is the case, we cant count it as your tvl.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @g1nt0ki --

Re: Vault markets - got it, sounds good.
Re: Recipe markets - it's the same as an Aave deposit in that a user has custody, but it's being held within the protocol. The user are fractured into independent Weiroll wallets to protect their main wallet from malicious scripts and also enforce a timelock. The assets doing the action within the protocol are inside the Weiroll wallet. Does that make sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jbhav24 hmm, maybe I am confusing this with a different project that computes rewards off chain.

But the tokens dont end up in weiroll wallets right (btw, are they smart contract)? for example, this statestone vault is part of recipe market right? https://app.stakestone.io/u/vault/detail/bera but the tokens remain in the vault arm?

@waynebruce0x waynebruce0x self-assigned this Dec 31, 2024
@llamabutler
Copy link

The adapter at projects/royco exports TVL:

ethereum                  2.49 M
arbitrum                  254.65 k
base                      24.27 k

total                    2.77 M 

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.

5 participants