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 the TVL Calculation for Joltify RWA Adapter #10628

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

briangarden
Copy link
Contributor

This PR aims to update Joltify RWA adapter.

@llamatester
Copy link

The adapter at projects/joltify-rwa exports TVL:

joltify                   25.38 k
joltify-borrowed          24.99 k
borrowed                  24.99 k

total                    25.38 k 

const [market, borrowed_denom] = pool.borrowed_amount.denom.split('-');
const market_id = `${market}:usd`;
const price = price_info.prices.find(price => price.market_id === market_id)?.price;
api.add(borrowed_denom, pool.borrowed_amount.amount * price);
Copy link
Member

Choose a reason for hiding this comment

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

this is already counted as part of borrowed

api.add(pool.usable_amount.denom, pool.usable_amount.amount);
api.add(pool.escrow_principal_amount.denom, pool.escrow_principal_amount.amount);
Copy link
Member

Choose a reason for hiding this comment

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

what is the difference between usable_amount and escrow_principal_amount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The escrow_principal_amount.amount indicates the principal repaid by the SPV and locked into the pool so that the investors can claim their investing assets from the pool once the due time reached.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to escrow_interest_amount, which indicates the repaid interest by the SPV.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The usable amount is the asset amount invested or put in the pool by users/investors for the SPV to borrow.
Basically, the escrow_principal and escrow_interest in the pool are from the SPV/borrower, the usable amount in the pool are from the users/investors.

api.add(pool.usable_amount.denom, pool.usable_amount.amount);
api.add(pool.escrow_principal_amount.denom, pool.escrow_principal_amount.amount);
api.add(pool.escrow_principal_amount.denom, pool.escrow_interest_amount);
Copy link
Member

Choose a reason for hiding this comment

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

we only count the amount locked in protocol as tvl, for example, the borrower might be insolvent and never pay back the loan, then this value will keep going up (this has already happened in a few hacked protocols)

@g1nt0ki g1nt0ki self-assigned this Jun 13, 2024
@g1nt0ki
Copy link
Member

g1nt0ki commented Jun 14, 2024

ah ,thanks for the details, will merge the and removed the borrowed amount counted towards tvl.

@g1nt0ki g1nt0ki merged commit 44879a3 into DefiLlama:main Jun 14, 2024
1 check failed
@briangarden
Copy link
Contributor Author

ah ,thanks for the details, will merge the and removed the borrowed amount counted towards tvl.

Hey, @g1nt0ki , we involve this borrowed amount in the TVL calculation due to the difference between traditional digital lending and RWA lending.

I understand the concept of RWA lending can be quite confusing. To help clarify, I've compared it to digital lending. Hopefully, this side-by-side comparison brings more clarity.
For digital lending, the process typically involves User A depositing 100 worth of tokens and User B depositing 100 worth of tokens into the protocol. Subsequently, User A borrows 80 tokens from User B's deposit. In this scenario, User A can withdraw the borrowed 80 tokens, taking them out of the protocol. Despite this withdrawal, the protocol still retains a Total Value Locked (TVL) of 120, calculated as the sum of User A's remaining 20 tokens and User B's 100 tokens**.

It's important to note that the TVL is not double-counted; it is calculated as 100 (User A's deposit) + 100 (User B's deposit) - 80 (User A's withdrawal) = 120, reflecting the accurate value locked within the protocol after User A's token withdrawal.

In the case of Real-World Asset (RWA) lending, a Special Purpose Vehicle (SPV) entity, let's call it 'C,' utilizes contracts collateralized by assets like bonds or other securities to borrow 100 dollars from User D. In this scenario, the SPV mints a 100 dollar Non-Fungible Token (NFT) backed by real-world assets, and User D deposits 100 worth of USDT/USDC into the protocol. Consequently, User D receives the 100 dollar NFT as proof of ownership, which remains within the protocol, while the SPV takes out the 100 USDT/USDC.

In this scenario, the protocol maintains a TVL of 100, calculated as the sum of the 100 dollar NFT and the 100 USDT/USDC initially deposited by User D, minus the 100 USDT/USDC withdrawn by the SPV. The TVL is not double-counted, as it accurately reflects the stablecoins taken out of the protocol, while the NFT representing the RWA remains locked within.

It's crucial to acknowledge that the collateral's value may fluctuate or even collapse over time, potentially decreasing the corresponding NFT's value. To address this, we will continuously assess and update the NFT's value based on the underlying collateral's performance. For example, in the event of a default, the NFT's value will be adjusted accordingly, reflecting the outcome of legal proceedings and the realization of the underlying RWA's value. Our protocol will dynamically update these valuations to ensure transparency and accurate representation of the locked assets.

@g1nt0ki
Copy link
Member

g1nt0ki commented Jun 19, 2024

hi @briangarden I understand your POV but we cant verify the NFT/off chain collateral value, this is why it is not included in tvl. We have done the same for other rwa lending protocols that we have listed.

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