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

reward converter - remove cache context wrapper and add trade route callback #999

Merged
merged 2 commits into from
Nov 30, 2023

Conversation

sampocs
Copy link
Collaborator

@sampocs sampocs commented Nov 29, 2023

Callback Keys Context

Instead of passing the trade route to the callback data, we should just pass the keys and re-look it up in the callback itself.

Main reason is to avoid a case where we accidentally override an updated route with a stale value. I don't think we currently re-set a TradeRoute in any of our callbacks, but I could see us doing this in the future and not remembering this scenario. Additionally, it could cause us to use a stale price as follows:

Example sequence:
  1. Current price stored in route is 1.0
  2. Price query submitted
  3. Trade reward balance query submitted (with current route as callback)
  4. Price query returns, sets price in route to 1.2
  5. Reward balance query returns, submits the trade based on the 1.0 price instead of 1.2 

Removing Cache Wrapper Context

After discussing offline, we decided the cache context wrapper is no longer needed and that we can return errors instead.

The main reasons to use the wrapper are if:

  1. The query permanently takes up storage (query's are only deleted after a successful callback)
  2. You need some state changes in the query callback to persist (if an error is thrown, state is reverted)

The examples here have neither of these cases, so we can just throw an error. But we should test these cases in dockernet to be sure.

@sampocs sampocs merged commit 74cd8a2 into autoswap-revenue-tokens Nov 30, 2023
1 check passed
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.

1 participant