Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protorev smarter logic and more testing (#4181)
* Add generalized tests Added: - 4 pool mainnet route test - 2 pool mainnet route test - Non-osmo/atom denom test * Add stableswap doomsday test - Currently panics due to solveCFMMBinarySearchMulti in stableswap calculation * Add tests for pool point limits - Tests that the per tx limit works properly - Tests that the per block limit works properly * Add pre-check before binary search - Adds a pre-check before the binary search that tells us if we need to run the binary search at all - Reduces overall computation/time by avoiding binary searching profit amounts over routes without any profit opportunity * Add denom to make test pass - Added "test/3" denom to test non-osmo/atom denoms in previous PR - didn't notice it broke one test that expected us to only have 2 denoms, so adding "test/3" here so everything passes * Implement minimum change to have smarter binary search bounds - This implements a way for us to have a binary search bound that can increase in size to account for large trades above the default range - I believe this is the minimum-amount-of-new-code approach, but may not be the optimal approach (what this method avoids is having to save the amount in or amount out of the original swap, and then backtracking/converting that amount to the base denom for an arb, and creating bounds off of that) * Switch range increasing logic - Doubling isn't the wanted behavior (only wanted if lower bound is 1), just increasing bound by the same range size is wanted (so adding MaxInputAmount achieves this) * Add logic to extend search bounds when finding optimal amount in - Increases max iterations to 17 to allow for situation when we need to increase the upper bound - Add new ExtendedMaxInputAmount variable for us to use as this new max bound range - Replace bound changing logic from iteratively changing the range to immediately giving our max range * Move range extension into it's own helper function * basic benchmark testing for posthandler and epoch hook * Add SwapAmountOut Test * Add extended range test - Tests binary search range extension logic works properly * Add panic catching test - This currently fails, this is on purpose so we don't merge the PR and think we are good until this passes and the panics are handled properly * dynamic step size * pool points only incremented if profitable * adding sanity checks for pool point calcs, nits * Update doomsday testing accounting for refund system - Makes pool 41 reserves to have an arb opportunity in the doomsday routes - Changes tx limit and block limit specifically for doomsday testing * Return nil for no profit opportunity * adding E2E, removing atom as a base denom, more testing for post handler * find max profit test fix * nit * backporting version tag to 14.x * comment update for protorev admin account --------- Co-authored-by: David Terpay <[email protected]>
- Loading branch information