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

Create SCHEMA_AMM (with vault) #48

Merged
merged 8 commits into from
Dec 20, 2024
Merged

Create SCHEMA_AMM (with vault) #48

merged 8 commits into from
Dec 20, 2024

Conversation

lylprg
Copy link
Contributor

@lylprg lylprg commented Dec 17, 2024

No description provided.

| pair_index | The index of the token in the smart contract (one row for each pair). | number |
| pair_address | The contract address of the pair. | string |
| pair_symbol | The symbol of the pair. | string |
| pair_liquidity | The liquidity available for trading for the pair (24h rolling average, in tokens). | string |
Copy link
Contributor

Choose a reason for hiding this comment

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

eg if this is a BTC/USD pair, will it be :
base index 0
quote index 1

pair_liquidity - liquidity available for each token?

for other verticals, we just use the amount on the daily / hourly snapshot (00:59:59 or 23:59:59), and we date_trunc the timestamp . probably easier if they are doing it on sql?

Copy link
Contributor

Choose a reason for hiding this comment

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

datatype for pair_liquidity and pair_liquidity_usd is wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah liquidity for each

Comment on lines 25 to 28
| liquidation_fees_usd | The total liquidation fees accrued for each pair (24h rolling average, in USD). | number |
| funding_rate | The funding rate for each pair at the time of the snapshot, as a percentage. | number |
| open_fees_usd | The total open fees accrued for each pair (24h rolling average, in USD). | number |
| close_fees_usd | The total close fees accrued for each pair (24h rolling average, in USD). | number |
Copy link
Contributor

@0xroll 0xroll Dec 17, 2024

Choose a reason for hiding this comment

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

whats the difference between this and the same columns in the vault schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here's my thinking, if we are tracking a few pairs and not all of them in the vault, we might end up underestimating the total

Copy link
Contributor Author

Choose a reason for hiding this comment

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

vault_fees are toal fees accrued by the protocol.
those fees can only be calculated at the pair level
in the vault, it's usd values, not fees.

Copy link
Contributor

Choose a reason for hiding this comment

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

ideally we want to get all token amount and usd amount as optional. in case if token price is missing we can still use our internal price table

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, sounds fair.

Comment on lines 61 to 62
| tvl | Total Value Locked at snapshot, in tokens (one entry for each token in the vault). | number |
| tvl_usd | Total Value Locked at snapshot (TOTAL of all tokens, in USD). | number |
Copy link
Contributor

Choose a reason for hiding this comment

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

tvl - is this the token amount ? if so maybe lets name it token_amount and token_amount_usd?

also token_address is missing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find token_amount rather confusing compared to tvl.
I don't think we need any token_address at the vault level, just the vault address, don't we?

Copy link
Contributor

Choose a reason for hiding this comment

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

using sudo as an example here

their SLP is one vault, so shouldnt there be token address to identify the correct asset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed, i'll add it.

| amount_useful_usd | The amount of liquid tokens supplied in USD. | number |
| liquidated_amount | The amount of tokens liquidated from the LP (when the taker has positive PnL if a position is closed), decimal normalized. | number |
| liquidated_amount_usd | The amount liquidated, in USD. | number |
| total_lp_fees_usd | Total fees generated for the LP at the time of snapshot (in USD). | number |
Copy link
Contributor

Choose a reason for hiding this comment

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

total_lp_fees_usd - is this the amount of fee that is earned by the individual LP provider?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it's in the LP snapshot, so for each LP

Copy link
Contributor

Choose a reason for hiding this comment

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

this field seems difficult to calculate here, but we can leave it here and wait for team's feedback

@lylprg lylprg merged commit 67efc67 into main Dec 20, 2024
1 check passed
@lylprg lylprg deleted the lylprg-patch-1 branch December 20, 2024 13:53
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.

2 participants