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

Add query to track liquidity provider rewards #2992

Open
Tracked by #4624
georgemc98 opened this issue Oct 13, 2022 · 8 comments
Open
Tracked by #4624

Add query to track liquidity provider rewards #2992

georgemc98 opened this issue Oct 13, 2022 · 8 comments
Assignees

Comments

@georgemc98
Copy link
Contributor

Background

To protect against the Cream exploit we need a way to only compound those rewards that come from liquidity mining rewards and not those that might be donated by an attacker. We currently don’t know how to do this and I assume it will require an upgrade in Osmosis to add this query. We’re not sure what the best way to write such a query would be and it would be great if someone from Osmosis can help with this as we are not very familiar with the liquidity mining rewards logic.

https://mudit.blog/cream-hack-analysis/

Suggested Design

Add an RPC endpoint that returns the amount of liquidity pool rewards have been sent to an address since a given timestamp or block.

@mattverse
Copy link
Member

mattverse commented Oct 13, 2022

IMO,a query that takes in address and timestamp as response, and returns amount of rewards given during timestamp is not adequate to have it as a chain query.

First reason, we don't keep state on rewards by "timestamps", there wouldn't be a way to do this as of rn.

Second reason, we track rewards for each "lock", not each account in the incentives module.

An approach you might want to try out is using the query RewardsEst, combined with different lock queries

@georgemc98
Copy link
Contributor Author

georgemc98 commented Oct 13, 2022

RewardsEst may be useful, but we need to know the historical rewards for a lockup. Is there a total amount of rewards per lock we could query?

@mattverse
Copy link
Member

Would it be possible to store that within the contract, not the state machine? I'm not sure if storing an unused state(within state machine) is preferred

@georgemc98
Copy link
Contributor Author

Would it be possible to store that within the contract, not the state machine? I'm not sure if storing an unused state(within state machine) is preferred

We can't store the correct amount of rewards in our contract, because we don't know the correct amount of rewards to begin with.

@mattverse
Copy link
Member

Would it be possible to store that within the contract, not the state machine? I'm not sure if storing an unused state(within state machine) is preferred

We can't store the correct amount of rewards in our contract, because we don't know the correct amount of rewards to begin with.

Because of the difference caused by the estimate reward and the actual reward?

@georgemc98
Copy link
Contributor Author

Would it be possible to store that within the contract, not the state machine? I'm not sure if storing an unused state(within state machine) is preferred

We can't store the correct amount of rewards in our contract, because we don't know the correct amount of rewards to begin with.

Because of the difference caused by the estimate reward and the actual reward?

Yes, exactly. What information is stored? Are the total rewards distributed saved?

@pacmanifold
Copy link

@mattverse any update on this?

@shapeshed
Copy link

shapeshed commented Aug 5, 2023

I'm also looking for a similar query to get rewards distributed to an address by lock id and epoch. My use case is autocompounding rewards after a distribution.

Afaik the only way to do this now with the available apis is to use the rewards estimate endpoint before the epoch ends, store this and hope it is accurate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Triage 🔍
Development

No branches or pull requests

6 participants