Skip to content

Commit

Permalink
Merge branch 'master' into realu/goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine authored Oct 10, 2023
2 parents 2fc1f03 + 7cc73b4 commit 66c6a97
Show file tree
Hide file tree
Showing 75 changed files with 9,557 additions and 787 deletions.
112 changes: 97 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

* [#1596](https://github.com/NibiruChain/nibiru/pull/1596) - epic(tokenfactory):
State transitions, collections, genesis import and export, and app wiring
* [#1607](https://github.com/NibiruChain/nibiru/pull/1607) - Token factory
transaction messages for CreateDenom, ChangeAdmin, and UpdateModuleParams
* [#1620](https://github.com/NibiruChain/nibiru/pull/1620) - Token factory
transaction messages for Mint and Burn
* [#1596](https://github.com/NibiruChain/nibiru/pull/1596) - epic(tokenfactory): State transitions, collections, genesis import and export, and app wiring
* [#1607](https://github.com/NibiruChain/nibiru/pull/1607) - Token factory transaction messages for CreateDenom, ChangeAdmin, and UpdateModuleParams
* [#1620](https://github.com/NibiruChain/nibiru/pull/1620) - Token factory transaction messages for Mint and Burn
* [#1573](https://github.com/NibiruChain/nibiru/pull/1573) - feat(perp): Close markets and compute settlement price

### State Machine Breaking

* [#1609](https://github.com/NibiruChain/nibiru/pull/1609) - refactor(app)!: Remove x/stablecoin module.
* [#1613](https://github.com/NibiruChain/nibiru/pull/1613) - feat(app)!: enforce min commission by changing default and genesis validation
* [#1615](https://github.com/NibiruChain/nibiru/pull/1613) - feat(ante)!: Ante
handler to add a maximum commission rate of 25% for validators.
* [#1616](https://github.com/NibiruChain/nibiru/pull/1616) - fix(app)!:
Add custom wasm snapshotter for proper state exports
* [#1617](https://github.com/NibiruChain/nibiru/pull/1617) - fix(app)!:
non-nil snapshot manager is not guarantted in testapp
* [#1615](https://github.com/NibiruChain/nibiru/pull/1613) - feat(ante)!: Ante handler to add a maximum commission rate of 25% for validators.
* [#1616](https://github.com/NibiruChain/nibiru/pull/1616) - fix(app)!: Add custom wasm snapshotter for proper state exports
* [#1617](https://github.com/NibiruChain/nibiru/pull/1617) - fix(app)!: non-nil snapshot manager is not guaranteed in testapp

### Improvements

* [#1610](https://github.com/NibiruChain/nibiru/pull/1610) - refactor(app):
Simplify app.go with less redundant imports using struct embedding.
* [#1610](https://github.com/NibiruChain/nibiru/pull/1610) - refactor(app): Simplify app.go with less redundant imports using struct embedding.
* [#1614](https://github.com/NibiruChain/nibiru/pull/1614) - refactor(proto): Use explicit namespacing on proto imports for #1608
* [#1630](https://github.com/NibiruChain/nibiru/pull/1630) - refactor(wasm): clean up wasmbinding/ folder structure
* [#1631](https://github.com/NibiruChain/nibiru/pull/1631) - fix(.goreleaser.yml): Load version for wasmvm dynamically.
Expand Down Expand Up @@ -93,7 +87,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1559](https://github.com/NibiruChain/nibiru/pull/1559) - feat: add versions to markets to allow to disable them
* [#1585](https://github.com/NibiruChain/nibiru/pull/1585) - feat: include flag versioned in query markets to allow to query disabled markets
* [#1594](https://github.com/NibiruChain/nibiru/pull/1594) - feat: add user discounts

* [#1463](https://github.com/NibiruChain/nibiru/pull/1463) - feat(oracle): add genesis pricefeeder delegation
* [#1479](https://github.com/NibiruChain/nibiru/pull/1479) - feat(perp): implement `PartialClose`
* [#1498](https://github.com/NibiruChain/nibiru/pull/1498) - feat: add cli to change root sudo command
* [#1501](https://github.com/NibiruChain/nibiru/pull/1501) - feat(localnet.sh): (1) Make it possible to run while offline. (2) Implement --no-build option to use the script with the current `nibid` installed.
* [#1501](https://github.com/NibiruChain/nibiru/pull/1501) - feat(proto): add Python buf generation logic for py-sdk
* [#1503](https://github.com/NibiruChain/nibiru/pull/1503) - feat(wasm): add Oracle Exchange Rate query for wasm
* [#1543](https://github.com/NibiruChain/nibiru/pull/1543) - epic(devgas): devgas module for incentivizing smart contract
*
### Improvements

* [#1466](https://github.com/NibiruChain/nibiru/pull/1466) - refactor(perp): `PositionLiquidatedEvent`
Expand All @@ -116,6 +117,87 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1555](https://github.com/NibiruChain/nibiru/pull/1555) - feat(devgas): Convert legacy ABCI events to typed proto events
* [#1558](https://github.com/NibiruChain/nibiru/pull/1558) - feat(perp): paginated query to read the position store
* [#1554](https://github.com/NibiruChain/nibiru/pull/1554) - refactor: runs gofumpt formatter, which has nice conventions: go install mvdan.cc/gofumpt@latest

### Bug Fixes

* [#1459](https://github.com/NibiruChain/nibiru/pull/1459) - fix(spot): wire `x/spot` msgService into app router
* [#1467](https://github.com/NibiruChain/nibiru/pull/1467) - fix(oracle): make `calcTwap` safer
* [#1464](https://github.com/NibiruChain/nibiru/pull/1464) - fix(gov): wire legacy proposal handlers
* [#1565](https://github.com/NibiruChain/nibiru/pull/1565) - fix(oracle)!: Count vote omission as abstain for less slashing + more stability

### State Machine Breaking

* [#1473](https://github.com/NibiruChain/nibiru/pull/1473) - refactor(perp)!: rename `OpenPosition` to `MarketOrder`
* [#1477](https://github.com/NibiruChain/nibiru/pull/1477) - refactor(oracle)!: Move away from deprecated events to typed events in x/oracle

### Dependencies

- Bump `robinraju/release-downloader` from 1.6 to 1.8 (#1326)
- Bump `pozetroninc/github-action-get-latest-release` from 0.6.0 to 0.7.0 (#1325)
- Bump `technote-space/get-diff-action` from 4 to 6 (#1327)
- Bump `actions/setup-go` from 3 to 4 (#1324)
- Bump `github.com/docker/distribution` from 2.8.1+incompatible to 2.8.2+incompatible (#1339)
- Bump `github.com/CosmWasm/wasmvm` from 1.2.1 to 1.3.0 (#1354, #1507)
- Bump `github.com/spf13/cast` from 1.5.0 to 1.5.1 (#1358)
- Bump `github.com/stretchr/testify` from 1.8.2 to 1.8.4 (#1384, #1435)
- Bump `cosmossdk.io/math` from 1.0.0-beta.6 to 1.1.2 (#1394, [#1547](https://github.com/NibiruChain/nibiru/pull/1547))
- Bump `google.golang.org/grpc` from 1.53.0 to 1.57.0 (#1395, #1437, #1443, #1497, [#1525](https://github.com/NibiruChain/nibiru/pull/1525))
- Bump `github.com/gin-gonic/gin` from 1.8.1 to 1.9.1 (#1409)
- Bump `github.com/spf13/viper` from 1.15.0 to 1.16.0 (#1436)
- Bump `github.com/prometheus/client_golang` from 1.15.1 to 1.16.0 (#1431)
- Bump `github.com/cosmos/ibc-go/v7` from 7.1.0 to 7.3.0 (#1445, [#1562](https://github.com/NibiruChain/nibiru/pull/1562))
- Bump `bufbuild/buf-setup-action` from 1.21.0 to 1.26.1 (#1449, #1469, #1505, #1510, [#1537](https://github.com/NibiruChain/nibiru/pull/1537), [#1540](https://github.com/NibiruChain/nibiru/pull/1540), [#1544](https://github.com/NibiruChain/nibiru/pull/1544))
- Bump `google.golang.org/protobuf` from 1.30.0 to 1.31.0 (#1450)
- Bump `cosmossdk.io/errors` from 1.0.0-beta.7 to 1.0.0 (#1499)
- Bump `github.com/holiman/uint256` from 1.2.2 to 1.2.3 (#1504)
- Bump `actions/checkout` from 3 to 4 ([#1563](https://github.com/NibiruChain/nibiru/pull/1563))

### Breaking

* [#1380](https://github.com/NibiruChain/nibiru/pull/1380) - feat(wasm): Add CreateMarket admin call for the controller contract
* [#1359](https://github.com/NibiruChain/nibiru/pull/1359) - feat(perp): Add InsuranceFundWithdraw admin call with corresponding smart contract
* [#1356](https://github.com/NibiruChain/nibiru/pull/1356) - build: Regress wasmvm (v1.1.1), tendermint (v0.34.24), and Cosmos-SDK (v0.45.14) dependencies
* [#1346](https://github.com/NibiruChain/nibiru/pull/1346) - build: Upgrade wasmvm (v1.2.1), tendermint (v0.34.26), and Cosmos-SDK (v0.45.14) dependencies
* [#1317](https://github.com/NibiruChain/nibiru/pull/1317) - feat(sudo): Implement and test CLI commands for tx and queries.
* [#1307](https://github.com/NibiruChain/nibiru/pull/1307) - feat(sudo): Create the x/sudo module + integration tests
* [#1299](https://github.com/NibiruChain/nibiru/pull/1299) - feat(wasm): Add peg shift bindings
* [#1292](https://github.com/NibiruChain/nibiru/pull/1292) - feat(wasm): Add module bindings for execute calls in x/perp: OpenPosition, ClosePosition, AddMargin, RemoveMargin.
* [#1287](https://github.com/NibiruChain/nibiru/pull/1287) - feat(wasm): Add module bindings for custom queries in x/perp: Reserves, AllMarkets, BasePrice, PremiumFraction, Metrics, PerpParams, PerpModuleAccounts
* [#1282](https://github.com/NibiruChain/nibiru/pull/1282) - feat(inflation)!: add inflation module
* [#1270](https://github.com/NibiruChain/nibiru/pull/1270) - refactor(proto)!: lint protos and standardize versioning
* [#1271](https://github.com/NibiruChain/nibiru/pull/1271) - refactor(perp)!: vpool → perp/amm #2 | imports and renames
* [#1269](https://github.com/NibiruChain/nibiru/pull/1269) - refactor(perp)!: merge x/util with x/perp
* [#1267](https://github.com/NibiruChain/nibiru/pull/1267) - refactor(perp)!: vpool → perp/amm #1 | Moves types, keeper, and cli
* [#1243](https://github.com/NibiruChain/nibiru/pull/1243) - feat(vpool): sqrt of liquidity depth tracked on pool
* [#1220](https://github.com/NibiruChain/nibiru/pull/1220) - feat: reduce gas fees when posting price
* [#1229](https://github.com/NibiruChain/nibiru/pull/1229) - feat: upgrade ibc to v4.2.0 and wasm v0.30.0
* [#1254](https://github.com/NibiruChain/nibiru/pull/1254) - feat: add bias field into vpool
* [#1255](https://github.com/NibiruChain/nibiru/pull/1255) - feat: add peg multiplier field into vpool, which for now defaults to 1
* [#1281](https://github.com/NibiruChain/nibiru/pull/1281) - feat: add peg multiplier to the pricing logic
* [#1291](https://github.com/NibiruChain/nibiru/pull/1291) - refactor(perp)!: add perp v2 state protos
* [#1296](https://github.com/NibiruChain/nibiru/pull/1296) - refactor(perp)!: update perp v2 state protos
* [#1298](https://github.com/NibiruChain/nibiru/pull/1298) - refactor(perp)!: remove `MaxOracleSpreadRatio` from Perpv2
* [#1302](https://github.com/NibiruChain/nibiru/pull/1302) - refactor(oracle)!: price snapshot start time inclusive
* [#1301](https://github.com/NibiruChain/nibiru/pull/1301) - fix(epochs)!: correct epoch start time
* [#1304](https://github.com/NibiruChain/nibiru/pull/1304) - feat: db backend - rocksdb
* [#1305](https://github.com/NibiruChain/nibiru/pull/1305) - refactor(perp!): Remove unnecessary protos
* [#1312](https://github.com/NibiruChain/nibiru/pull/1312) - feat(wasm): wire depth shift handler to the wasm router
* [#1306](https://github.com/NibiruChain/nibiru/pull/1306) - feat(perp): complete perp v2 types
* [#1309](https://github.com/NibiruChain/nibiru/pull/1309) - feat: minimum swap amount set to $1
* [#1336](https://github.com/NibiruChain/nibiru/pull/1336) - feat: move oracle params out of params subspace and onto the keeper
* [#1315](https://github.com/NibiruChain/nibiru/pull/1315) - feat: oracle rewards distribution every week
* [#1342](https://github.com/NibiruChain/nibiru/pull/1342) - feat(perp): market not enabled can only be used to close out existing positions
* [#1367](https://github.com/NibiruChain/nibiru/pull/1367) - feat: wire enable market to wasm
* [#1382](https://github.com/NibiruChain/nibiru/pull/1382) - refactor(perp)!: remove `perpv1`
* [#1385](https://github.com/NibiruChain/nibiru/pull/1385) - test(perp): add clearing house negative tests
* [#1388](https://github.com/NibiruChain/nibiru/pull/1388) - refactor(perp)!: idempotent position changed event
* [#1387](https://github.com/NibiruChain/nibiru/pull/1387) - feat: upgrade to Cosmos SDK v0.46.10
* [#1413](https://github.com/NibiruChain/nibiru/pull/1413) - fix(perp): provide descriptive errors when all liquidations fail in MultiLiquidate
* [#1427](https://github.com/NibiruChain/nibiru/pull/1427) - refactor(perp)!: PositionChangedEvent `MarginToUser`
* [#1407](https://github.com/NibiruChain/nibiru/pull/1407) - feat!: upgrade to Cosmos SDK v0.47.3

### Improvements

* [#1574](https://github.com/NibiruChain/nibiru/pull/1574) - chore(goreleaser): update wasmvm to v1.4.0
* [#1463](https://github.com/NibiruChain/nibiru/pull/1463) - feat(oracle): add genesis pricefeeder delegation
* [#1466](https://github.com/NibiruChain/nibiru/pull/1466) - refactor(perp): `PositionLiquidatedEvent`
Expand Down
2 changes: 1 addition & 1 deletion contrib/make/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

.PHONY: lint
lint:
docker run -v $(CURDIR):/code --rm -w /code golangci/golangci-lint:v1.52.2-alpine golangci-lint run --timeout 10m
docker run -v $(CURDIR):/code --rm -w /code golangci/golangci-lint:v1.52.2-alpine golangci-lint run --timeout 30m
15 changes: 13 additions & 2 deletions proto/nibiru/perp/v2/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ message GenesisState {

repeated nibiru.perp.v2.AMM amms = 3 [ (gogoproto.nullable) = false ];

repeated nibiru.perp.v2.Position positions = 4
[ (gogoproto.nullable) = false ];
repeated GenesisPosition positions = 4 [ (gogoproto.nullable) = false ];

repeated nibiru.perp.v2.ReserveSnapshot reserve_snapshots = 5
[ (gogoproto.nullable) = false ];
Expand Down Expand Up @@ -71,3 +70,15 @@ message GenesisMarketLastVersion {

uint64 version = 2;
}

message GenesisPosition {
string pair = 1 [
(gogoproto.customtype) =
"github.com/NibiruChain/nibiru/x/common/asset.Pair",
(gogoproto.nullable) = false
];

uint64 version = 2;

Position position = 3 [ (gogoproto.nullable) = false ];
}
7 changes: 7 additions & 0 deletions proto/nibiru/perp/v2/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ message AMM {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// The settlement price if the AMM is settled.
string settlement_price = 9 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.stdduration) = true,
(gogoproto.nullable) = false
];
}

message Position {
Expand Down
2 changes: 1 addition & 1 deletion wasmbinding/bindings/marshalling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s *TestSuiteBindingJsonTypes) TestToAppMarket() {
ammMarket.Market,
ammMarket.Amm,
"index price",
ammMarket.Amm.MarkPrice().String(),
ammMarket.Amm.InstMarkPrice().String(),
dummyBlockHeight,
)

Expand Down
2 changes: 1 addition & 1 deletion wasmbinding/bindings/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func NewMarket(appMarket perpv2types.Market, appAmm perpv2types.AMM, indexPrice,
MaintenanceMarginRatio: appMarket.MaintenanceMarginRatio,
MaxLeverage: appMarket.MaxLeverage,
},
MarkPrice: appAmm.MarkPrice(),
MarkPrice: appAmm.InstMarkPrice(),
IndexPrice: indexPrice,
TwapMark: twapMark,
BlockNumber: sdk.NewInt(blockNumber),
Expand Down
3 changes: 2 additions & 1 deletion wasmbinding/exec_perp.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func (exec *ExecutorPerp) InsuranceFundWithdraw(
)
}

// TODO: rename to CloseMarket
func (exec *ExecutorPerp) SetMarketEnabled(
cwMsg *bindings.SetMarketEnabled, ctx sdk.Context,
) (err error) {
Expand All @@ -201,7 +202,7 @@ func (exec *ExecutorPerp) SetMarketEnabled(
return err
}

return exec.PerpV2.ChangeMarketEnabledParameter(ctx, pair, cwMsg.Enabled)
return exec.PerpV2.CloseMarket(ctx, pair)
}

func (exec *ExecutorPerp) CreateMarket(
Expand Down
5 changes: 1 addition & 4 deletions wasmbinding/exec_perp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

sdkmath "cosmossdk.io/math"
"github.com/NibiruChain/collections"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -114,9 +113,7 @@ func (s *TestSuitePerpExecutor) DoMarketOrderTest(pair asset.Pair) error {
}

// Verify position exists with PerpKeeper
_, err = s.exec.PerpV2.Positions.Get(
s.ctx, collections.Join(pair, s.contractPerp),
)
_, err = s.exec.PerpV2.GetPosition(s.ctx, pair, 1, s.contractPerp)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion wasmbinding/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (perpExt *PerpQuerier) AllMarkets(
MaintenanceMarginRatio: pbMarket.Market.MaintenanceMarginRatio,
MaxLeverage: pbMarket.Market.MaxLeverage,
},
MarkPrice: pbMarket.Amm.MarkPrice(),
MarkPrice: pbMarket.Amm.InstMarkPrice(),
BlockNumber: sdk.NewInt(ctx.BlockHeight()),
}
}
Expand Down
2 changes: 1 addition & 1 deletion wasmbinding/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (s *TestSuiteQuerier) TestQueryAllMarkets() {
s.Assert().EqualValues(marketAmm.Amm.TotalLong, cwMarket.TotalLong)
s.Assert().EqualValues(marketAmm.Amm.TotalShort, cwMarket.TotalShort)
s.Assert().EqualValues(marketAmm.Amm.PriceMultiplier.String(), cwMarket.PegMult.String())
s.Assert().EqualValues(marketAmm.Amm.MarkPrice().String(), cwMarket.MarkPrice.String())
s.Assert().EqualValues(marketAmm.Amm.InstMarkPrice().String(), cwMarket.MarkPrice.String())
s.Assert().EqualValues(s.ctx.BlockHeight(), cwMarket.BlockNumber.Int64())
}
}
Expand Down
4 changes: 2 additions & 2 deletions x/common/testutil/genesis/perp_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func AddPerpV2Genesis(gen app.GenesisState) app.GenesisState {
Markets: marketsv2,
MarketLastVersions: marketLastVersions,
Amms: ammsv2,
Positions: []perpv2types.Position{},
Positions: []perpv2types.GenesisPosition{},
ReserveSnapshots: []perpv2types.ReserveSnapshot{},
}

Expand Down Expand Up @@ -226,7 +226,7 @@ func PerpV2Genesis() *perpv2types.GenesisState {
TotalShort: sdk.ZeroDec(),
},
},
Positions: []perpv2types.Position{},
Positions: []perpv2types.GenesisPosition{},
ReserveSnapshots: []perpv2types.ReserveSnapshot{},
}
}
1 change: 1 addition & 0 deletions x/common/testutil/mock/perp_amm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func TestAMMDefault() *types.AMM {
PriceMultiplier: sdk.OneDec(),
TotalLong: sdk.ZeroDec(),
TotalShort: sdk.ZeroDec(),
SettlementPrice: sdk.ZeroDec(),
}
}

Expand Down
Loading

0 comments on commit 66c6a97

Please sign in to comment.