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

feat: add market version to allow disabling markets #1559

Merged
merged 21 commits into from
Sep 19, 2023

Conversation

jgimeno
Copy link
Contributor

@jgimeno jgimeno commented Aug 28, 2023

@codecov
Copy link

codecov bot commented Aug 28, 2023

Codecov Report

Merging #1559 (c08dd53) into master (0f2169e) will increase coverage by 0.01%.
Report is 7 commits behind head on master.
The diff coverage is 90.15%.

❗ Current head c08dd53 differs from pull request most recent head 9cebdee. Consider uploading reports for the commit 9cebdee to get more accurate results

@@            Coverage Diff             @@
##           master    #1559      +/-   ##
==========================================
+ Coverage   70.77%   70.78%   +0.01%     
==========================================
  Files         180      180              
  Lines       14786    14827      +41     
==========================================
+ Hits        10465    10496      +31     
- Misses       3645     3651       +6     
- Partials      676      680       +4     
Files Changed Coverage
x/common/asset/pair.go ø
x/epochs/types/identifier.go ø
x/perp/v2/keeper/calc.go ø
x/perp/v2/module/abci.go 28.57%
x/perp/v2/keeper/grpc_query.go 77.77%
x/perp/v2/keeper/amm.go 78.57%
x/perp/v2/keeper/admin.go 100.00%
x/perp/v2/keeper/clearing_house.go 100.00%
x/perp/v2/keeper/hooks.go 100.00%
x/perp/v2/keeper/keeper.go 100.00%
... and 10 more

Copy link
Contributor

@matthiasmatt matthiasmatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Sonarcloud would be blocking this PR because of duplicated code in the pb.go file??

@@ -22,6 +22,7 @@ func AddPerpV2Genesis(gen app.GenesisState) app.GenesisState {
asset.Registry.Pair(denoms.BTC, denoms.NUSD): {
Market: perpv2types.Market{
Pair: asset.NewPair(denoms.BTC, denoms.NUSD),
Version: 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want to start with 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the one given that 0 is the typical default value in proto

@jgimeno jgimeno changed the title feature: add market version to allow disabling markets feat: add market version to allow disabling markets Sep 8, 2023
@jgimeno jgimeno marked this pull request as ready for review September 8, 2023 20:19
@jgimeno jgimeno requested a review from a team as a code owner September 8, 2023 20:19
Copy link
Member

@Unique-Divine Unique-Divine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review up to module/abci.go. Will continue going through the rest after I wake up in the morning

x/perp/v2/keeper/admin.go Outdated Show resolved Hide resolved
x/perp/v2/keeper/amm.go Outdated Show resolved Hide resolved
@@ -17,7 +17,8 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochN
}

func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, _ uint64) {
for _, market := range k.Markets.Iterate(ctx, collections.Range[asset.Pair]{}).Values() {
for _, market := range k.Markets.Iterate(ctx, collections.Range[collections.Pair[asset.Pair, uint64]]{}).Values() {
// TODO (reviewer): this needs to be fixed for only enabled markets
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you could use if market.Version != market.LastVersion { continue } here if we grab the MarketLastVersion state

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is not needed given we already know if it is disabled

@sonarcloud
Copy link

sonarcloud bot commented Sep 18, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 17 Code Smells

No Coverage information No Coverage information
20.8% 20.8% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@Unique-Divine Unique-Divine merged commit cdf86c5 into master Sep 19, 2023
15 of 16 checks passed
@Unique-Divine Unique-Divine deleted the feature/market-version branch September 19, 2023 01:42
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.

refactor(perp)!: Identify market with multi-part key [pair + version]
3 participants