Skip to content

Commit

Permalink
fix: make Gen_market set initial perp versions (#1677)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmatt authored Nov 27, 2023
1 parent b102818 commit 2d59c9d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1606](https://github.com/NibiruChain/nibiru/pull/1606) - fix(perp): emit `MarketUpdatedEvent` in the absence of index price
* [#1649](https://github.com/NibiruChain/nibiru/pull/1649) - fix(ledger): fix ledger for newer macos versions
* [#1655](https://github.com/NibiruChain/nibiru/pull/1655) - fix(inflation): inflate NIBI correctly to strategic treasury account
* [#1677](https://github.com/NibiruChain/nibiru/pull/1677) - fix(perp): make Gen_market set initial perp versions

## [v0.21.10]

Expand Down
10 changes: 10 additions & 0 deletions x/perp/v2/client/cli/gen_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ func AddMarketGenesisCmd(defaultNodeHome string) *cobra.Command {
perpGenState.Markets = append(perpGenState.Markets, market)
perpGenState.Amms = append(perpGenState.Amms, amm)

var marketsLastVersion []types.GenesisMarketLastVersion
for _, market := range perpGenState.Markets {
marketsLastVersion = append(marketsLastVersion, types.GenesisMarketLastVersion{
Pair: market.Pair,
Version: market.Version,
})
}

perpGenState.MarketLastVersions = marketsLastVersion

perpGenStateBz, err := clientCtx.Codec.MarshalJSON(perpGenState)
if err != nil {
return fmt.Errorf("failed to marshal market genesis state: %w", err)
Expand Down
1 change: 1 addition & 0 deletions x/perp/v2/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func DefaultGenesis() *GenesisState {
Amms: []AMM{},
Positions: []GenesisPosition{},
ReserveSnapshots: []ReserveSnapshot{},
CollateralDenom: TestingCollateralDenomNUSD,
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/perp/v2/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestDefaultGenesis(t *testing.T) {
require.Empty(t, genesis.Amms)
require.Empty(t, genesis.Positions)
require.Empty(t, genesis.ReserveSnapshots)
require.Empty(t, genesis.CollateralDenom)
require.NotNil(t, genesis.CollateralDenom)
}

func TestGenesisValidate(t *testing.T) {
Expand Down

0 comments on commit 2d59c9d

Please sign in to comment.