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

[Lake] Calculate df and stake revenues for silver predictions table #746

Closed
4 tasks done
KatunaNorbert opened this issue Mar 6, 2024 · 2 comments
Closed
4 tasks done
Assignees
Labels

Comments

@KatunaNorbert
Copy link
Member

KatunaNorbert commented Mar 6, 2024

Target of this ticket is to discuss and determin how to calculate the data farming and stake revenues for a slot.

The requirement is found in #618 but because this could be a higher complexity task and might require other tables decided to get it out into a separate issue and write down all the requirement here:

  • make sure all the subscriptions related data is fetched
  • add a list of addresses used by df to purchase the subscriptions
  • create a method that can filter a table based on df/non df addresses and returns the specific table
  • create a method that calculates the revenue for each contract+user+slot. For this we also need to read from pdr_slots table to get all the stakes from the specific slot.
@KatunaNorbert KatunaNorbert added the Type: Enhancement New feature or request label Mar 6, 2024
@KatunaNorbert KatunaNorbert self-assigned this Mar 6, 2024
@KatunaNorbert
Copy link
Member Author

KatunaNorbert commented Mar 6, 2024

- As a first step we could filter out subscription based revenue from the stake revenue:
This is easy to do and doesn't require any extra data, just subtract the staked amount from the revenue

- In the second step we could further split the subscription based revenue into data farming and user purchase:
In this step we need to query the subscription purchases from the subgraph and filter them based on address so we know how much is coming from data farming and how much from other users.

After knowing how much OCEAN tokens are coming for each inflow, calculate the slot revenues

How payout is calculated:

`
uint256 amt_perepoch_start = amount / numepoch_starts

uint256 swe = trueValues[epoch_start]
? roundSumStakesUp[epoch_start]
: roundSumStakes[epoch_start] - roundSumStakesUp[epoch_start];

if(swe > 0) {
uint256 revenue = amt_perepoch_start;
payout_amt = predobj.stake * (roundSumStakes[epoch_start] + revenue) / swe;
}else{
payout_amt=0
}
`

@trentmc trentmc changed the title Calculate df and stake revenues for silver predictions table [Lake] Calculate df and stake revenues for silver predictions table Mar 12, 2024
@idiom-bytes
Copy link
Member

This is performing slowly.
Calculating revenue & updating needs to lookback to get info.
Let's review and improve the query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants