-
Notifications
You must be signed in to change notification settings - Fork 208
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
phase 2: auto-trade reward token revenue via routes in params #955
Conversation
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
open |
Co-authored-by: sampocs <sam@stridelabs.co> Co-authored-by: sampocs <sam.pochyly@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautifully done once again!!
One larger open question - should we handle the case where the price query fails? Would be a bit messy to keep track of how recent it is, but I'd be worried of the case where we just keeping using a stale value.
Feels like our options are:
- Include no staleness check
- Include a staleness check (would require additional state to track when the price was last updated)
- Update the price to indicate if the query failed (e.g. set it to zero/nil)
…1021) Co-authored-by: ethan <ethan@stridelabs.co>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢!
…de into autoswap-revenue-tokens
This PR is the logic for phase 2 of the community pools where foreign ibc denoms can be treated as revenue.
Tech Spec and Diagrams
https://docs.google.com/document/d/1U9ah95DABkg_ofSGgkDnhzr4wyJdHCCBExCKCX-t_WM/edit
https://app.excalidraw.com/l/9UFOCMAZLAI/2ErXWeealJE
Phase 2: Automatically convert revenue of foreign "reward" denom to host denom
There are 4 logical steps kicked off by epochly triggered ICQs:
The first and last ICQs here are done on a stride epoch cadence, because the swap is limited by a max swap size to prevent slippage, the swaps can happen in smaller more frequent triggers so the middle ICQ is done on an hourly cadence.
Also for safety, a min acceptable output amount is computed using the last known swap price. There is an independent hourly ICQ to get this "spot price" for the pool (which is a ratio of input to output denom in that pool) and this value is persisted to the TradeConfig type inside the TradeRoute information on the keeper state. Swaps use whatever value is found (which could be up to 1 hour out of date) when computing the minimum expected output for the swap. If a swap fails, the tokens just remain in the trade ICA and will be attempted again on the next epochly call to the swap action.
There are governance gated transactions to create, delete, and update the TradeRoute data stored on the keeper state. The most common expected use case is to update which pool the TradeRoute uses to do the swap or to change the max swap size.
Testing