Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protorev: Use hooks instead of message parsing to trigger backruns (#…
…5045) * Add input and output - Follows gamm module patterns such as 1) naming convention and 2) providing tokens (sdk.Coins) even though it's currently expected to be a single token in or out (sdk.Coin). * Update modules that use hook * Create new kvstore and methods for swpsToBackrun - With new hook based logic, need to persist the swaps to the posthandler. Doing so via storing in kvstored * Connect protorev to cfmm and cl hooks * Implement CFMMHook logic in protorev * Update comments, restrict join/exit pool logic to single denom in/out * Remove old placeholder print * Change init function to reset * add input and output coins in protorev cl hook * add necessary poolmanager expected keepers * add hook logic for cl pools and refactor * implement new hook-based logic in the posthandler * no-op unused hooks * Remove ResetSwapToBackrun, only use DeleteSwapsToBackrun * Add swap tests for hooks - Also creates a position in the cl pool defined in setupPools * Add join/exit pool hook tests - Limit len(coins) = 1 due to an exit pool message giving all denoms as exitdenoms (and potentially future behavior of other modules) * Add pool creation hook test * Add pool creation tests, handle CL pools differently due to 0 liquidity creation * Update ExtractSwappedPools to no longer need tx * Update TestExtractSwappedPools for new hook-based logic * Delete swaps without using user gas * Update TestAnteHandle with new hook-based logic * Update expected liquidity value for CL pool - CL pool now is created with pre-defined default values, so I remove sending coins to the pool in keeper_test.go - Updates the expected value in epoch_hook_test to match the output of the default PrepareConcentratedPoolWithCoinsAndFullRangePosition coins output * Add changelog entry * Remove unused messages in TestAnteHandle Since we now have hook-based logic, can remove msgs from inputs into TestAnteHandle() * Remove no longer used functions * Check len on all hooks to avoid unintended behavior * lint * Move all mul logic into same fn in hook logic afterpoolCreated, add panic catching to function * Separate getCoins logic into separate function * fix lint * return sdk.Coins{} instead of nil * remove unused import * Remove unnecessary code * clarify comment Co-authored-by: Sishir Giri <[email protected]> * use NewCoins instead of Coins Co-authored-by: Sishir Giri <[email protected]> * Revert "use NewCoins instead of Coins" This reverts commit 6c744ac. * add inline comment for why no return in err * use SetupTest instead of custom logic * Restructure protorev hook updating to only process pools with coins - Previously, protorev was triggered by AfterConcentratedPoolCreated, but this had an issue where the pool is created without any liquidity, returning empty coins object when getting total liquidity - Instead, this commit makes AfterConcentratedPoolCreated a no-op and moves the core logic into AfterInitialPoolPositionCreated, so that we know we have coins - This allows us to not handle this case in any custom manner and can expect there to be coins - Added more test cases to ensure this works as expected * Use denoms first, then coins in pool updating - Does all logic it can just using denoms first, and only gets coins object if necessary * remove comment * use poolmanager to get liquidity to avoid issues with CL - Previously used gamm to get liquidity which would have error'd, so uses poolmanager instead - Separate specific logic into own function for re-use and testing * Add CL first, then balancer (and vice-versa) pool creation tests * v16 version bump * implement ok checking pattern for map check * fix typo * Use expectPass bool in test * reuse k.storeSwap in join/exit logic * Add direct unit test for StoreSwap helper method * Add direct unit test for GetComparablePoolLiquidity helper method * Add direct unit test for StoreJoinExitPoolSwaps helper method * Remove old function * Add direct unit test for CompareAndStorePool helper method * Actually test CompareAndStorePool * export AfterPoolCreatedWithCoins * Clarify why the test calls DeleteAllPoolsForBaseDenom * Move panic catching into GetComparablePoolLiquidity - Panic catching was previously in CompareAndStorePool because that function did the multiplication. - Since then, the multiplication logic that this panic catches overflows on has been separated into it's own function GetComparablePoolLiquidity - This commit moves the panic catching logic to GetComparablePoolLiquidity * Add int overflow panic catching test * Revert "Add int overflow panic catching test" This reverts commit ed66bce. * Add int overflow panic catch test - try 2 * Add custom error message * Add overflow catching logical branch tests for CompareAndStorePool * Add non-gamm pool error test for StoreJoinExitPoolSwaps() * Use s.SetupTest() and give testAcc pool shares * Add clarifying comment about gas meter * Add comment explaining the base denoms check -> CompareAndStorePool logic --------- Co-authored-by: Sishir Giri <[email protected]>
- Loading branch information