-
Notifications
You must be signed in to change notification settings - Fork 610
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
feat: scaling factors validation in create stableswap pool, small refactor and unit tests #1459
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1459 +/- ##
==========================================
- Coverage 19.82% 19.64% -0.19%
==========================================
Files 202 230 +28
Lines 27685 31617 +3932
==========================================
+ Hits 5489 6211 +722
- Misses 21175 24281 +3106
- Partials 1021 1125 +104
Continue to review full report at Codecov.
|
…sis into roman/scaling-factors2
|
||
func ValidatePoolAssets(poolAssets []PoolAsset) error { | ||
// validation for pool initial liquidity | ||
// TODO: expand this check to accommodate multi-asset pools for stableswap |
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.
this was copied over, what are the plans for this?
@@ -154,7 +139,9 @@ func (pa *Pool) SwapOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDe | |||
return sdk.Coin{}, err | |||
} | |||
|
|||
pa.updatePoolLiquidityForSwap(tokenIn, sdk.NewCoins(tokenOut)) | |||
if err := pa.updatePoolLiquidityForSwap(tokenIn, sdk.NewCoins(tokenOut)); err != nil { | |||
panic(err) |
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.
this was changed to make it more testable in unit tests
// Returns a pool asset, and its index. If err != nil, then the index will be valid. | ||
// CONTRACT: pool must be created with NewStableSwapPool so that the pool assets are sorted | ||
// by denom. Otherwise, the behavior is undefined. | ||
func (pa Pool) getPoolAssetAndIndex(denom string) (int, PoolAsset, error) { |
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.
this can be later generalized with balancer
I think the non-pool asset design was better tbh, and Balancer is what needs changing in the future |
Why do you think so? I find it more brittle to rely on the order of 2 separate slices to be in sync. If 2 slices need to maintain the same order, they should be grouped and merged into one. Otherwise, a small update to the ordering of one of the slices in the future can bring them out of sync and might cause problems when debugging. Additionally, while setting up unit tests, I found this abstraction to be easier to configure and assert on its results. These were the 2 primary motivators for this change Please let me know what you think |
[ (gogoproto.moretags) = "yaml:\"token\"", (gogoproto.nullable) = false ]; | ||
// used for normalizing values for calculation amognst assets with different | ||
// precisions | ||
string scalingFactor = 2 [ |
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.
string scalingFactor = 2 [ | |
string scaling_factor = 2 [ |
(gogoproto.moretags) = "yaml:\"stableswap_scaling_factor\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
repeated osmosis.gamm.stableswap.v1beta1.PoolAsset poolAssets = 6 |
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.
repeated osmosis.gamm.stableswap.v1beta1.PoolAsset poolAssets = 6 | |
repeated osmosis.gamm.stableswap.v1beta1.PoolAsset pool_assets = 6 |
@ValarDragon any updates on this? |
Since this PR is starting to have blockers on it, we should decide direction for this on call |
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! |
Stale bot is indeed doing its work! Nice :) |
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! |
Closes: #1392
What is the purpose of the change
Implemented scaling factors for
CreateStableswapPool
,NewStableswapPool
, along withValidateBasic
validation.Refactored to make it more testable and align the design closer to balancer.
All changed logic is covered by unit tests.
Brief Changelog
Testing and Verifying
This change introduces a scaling factors to CreateSta
includes a minor refactor to introduce
PoolAssets
in stableswap pool to make the design more aligned with the balancer and more testable.This change added tests and can be verified as follows:
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? no