Skip to content

Commit

Permalink
Merge branch 'master' into tip/dnr/rebates
Browse files Browse the repository at this point in the history
# Conflicts:
#	proto/nibiru/perp/v2/genesis.proto
  • Loading branch information
godismercilex committed Oct 9, 2023
2 parents ce819bb + 40f8e71 commit dfeefb9
Show file tree
Hide file tree
Showing 68 changed files with 8,039 additions and 565 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
activationLabel: 'dependabot'
changelogPath: './CHANGELOG.md'

- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Updated changelog - dependabot"
4 changes: 2 additions & 2 deletions .github/workflows/proto-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# timeout-minutes: 5
# steps:
# - uses: actions/checkout@v4
# - uses: bufbuild/buf-setup-action@v1.26.1
# - uses: bufbuild/buf-setup-action@v1.27.0
# - uses: bufbuild/buf-lint-action@v1
# with:
# input: "proto"
Expand All @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.26.1
- uses: bufbuild/buf-setup-action@v1.27.0
with:
github_token: ${{ github.token }}
- uses: bufbuild/buf-breaking-action@v1
Expand Down
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#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

### 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

### 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

### Dependencies
- Bump `github.com/prometheus/client_golang` from 1.16.0 to 1.17.0 ([#1605](https://github.com/NibiruChain/nibiru/pull/1605))
- Bump `bufbuild/buf-setup-action` from 1.26.1 to 1.27.0 ([#1624](https://github.com/NibiruChain/nibiru/pull/1624))
- Bump `stefanzweifel/git-auto-commit-action` from 4 to 5 ([#1625](https://github.com/NibiruChain/nibiru/pull/1625))

### Bug Fixes

* [#1606](https://github.com/NibiruChain/nibiru/pull/1606) - fix(perp): emit `MarketUpdatedEvent` in the absence of index price

## [v0.21.10]

Expand Down Expand Up @@ -668,4 +685,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Testing

* [#695](https://github.com/NibiruChain/nibiru/pull/695) Add `OpenPosition` integration tests.
* [#692](https://github.com/NibiruChain/nibiru/pull/692) Add test coverage for Perp MsgServer methods.
* [#692](https://github.com/NibiruChain/nibiru/pull/692) Add test coverage for Perp MsgServer methods.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Nibiru Chain <!-- omit in toc -->
# Nibiru Chain

[![Go Reference](https://pkg.go.dev/badge/github.com/NibiruChain/nibiru.svg)](https://pkg.go.dev/github.com/NibiruChain/nibiru)
[![Nibiru Test workflow][badge-go-linter]][workflow-go-linter]
Expand All @@ -10,30 +10,29 @@

## Components of Nibiru

- **CosmWasm Smart Contracts**: Rust-based, [WebAssembly (WASM) smart contracts](https://book.cosmwasm.com/) built for the Cosmos Ecosystem.
- **CosmWasm Smart Contracts**: Rust-based, WebAssembly (WASM) smart contracts built for the Cosmos Ecosystem. See our [CosmWasm sandbox monorepo (cw-nibiru)](https://github.com/NibiruChain/cw-nibiru/tree/main) for the protocol's core smart contracts.
- **Nibi-Perps**: A perpetual futures exchange where users can take leveraged exposure and trade on a plethora of assets — completely on-chain, completely non-custodially, and with minimal gas fees.
- **Oracle Module**: Nibiru accurately prices assets using a native, system of decentralized oracles, and communicates with other Cosmos layer-1 chains using the Inter-Blockchain Communication (IBC) (opens new window)protocol.
- **Nibi-Swap**: An automated market maker protocol for multichain assets. This application gives users access to swaps, pools, and bonded liquidity gauges.
- **NUSD Stablecoin**: Nibiru powers a two-token economic model, where NIBI is the staking and utility token for the protocol and NUSD is a capital-efficient, partially collateralized stablecoin for the protocol.

## Modules

| Module | Description |
| --- | --- |
| [common][code-x-common] | Holds helper and utility functions to be utilized by other `x/` modules. |
| [epochs][code-x-epochs] | Often in the SDK, we would like to run certain code every-so often. The purpose of `epochs` module is to allow other modules to set that they would like to be signaled once every period. So another module can specify it wants to execute code once a week, starting at UTC-time = x. `epochs` creates a generalized epoch interface to other modules so that they can easily be signalled upon such events. |
| [inflation][code-x-inflation] | Implements the [tokenomics](https://nibiru.fi/docs/learn/tokenomics.html) for Nibiru. |
| [oracle][code-x-oracle] | Handles the posting of an up-to-date and accurate feed of exchange rates from the validators. |
| [perp][code-x-perp] | Powers the Nibi-Perps exchange. This module enables traders to open long and short leveraged positions and houses all of the PnL calculation and liquidation logic. |
| [spot][code-x-spot] | Responsible for creating, joining, and exiting liquidity pools. It also allows users to swap between two assets in an existing pool. It's a fully functional AMM. |
| [stablecoin][code-x-stablecoin] | Responsible for handling mint and redeem transactions with NUSD. |
| [wasm][code-x-wasm] | Implements the execution environment for [WebAssembly (WASM) smart contracts](https://book.cosmwasm.com/). |

[code-x-common]: https://github.com/NibiruChain/nibiru/tree/master/x/common
[code-x-epochs]: https://github.com/NibiruChain/nibiru/tree/master/x/epochs
[code-x-inflation]: https://github.com/NibiruChain/nibiru/tree/master/x/inflation
[code-x-oracle]: https://github.com/NibiruChain/nibiru/tree/master/x/oracle
[code-x-perp]: https://github.com/NibiruChain/nibiru/tree/master/x/perp
[code-x-spot]: https://github.com/NibiruChain/nibiru/tree/master/x/spot
[code-x-stablecoin]: https://github.com/NibiruChain/nibiru/tree/master/x/stablecoin
[code-x-wasm]: https://github.com/NibiruChain/nibiru/tree/master/x/wasm

Nibiru is built with the [Cosmos-SDK][cosmos-sdk-repo] on [Tendermint Core](https://tendermint.com/core/) consensus, accurately prices assets using a system of decentralized oracles, and communicates with other Cosmos layer-1 chains using the [Inter-Blockchain Communication (IBC)](https://github.com/cosmos/ibc) protocol.
Expand All @@ -55,7 +54,7 @@ If you have questions or concerns, feel free to connect with a developer or comm
<p style="display: flex; gap: 24px; justify-content: center; text-align:center">
<a href="https://discord.gg/nibiruchain"><img src="https://img.shields.io/badge/Discord-7289DA?&logo=discord&logoColor=white" alt="Discord" height="22"/></a>
<a href="https://twitter.com/NibiruChain"><img src="https://img.shields.io/badge/Twitter-1DA1F2?&logo=twitter&logoColor=white" alt="Tweet" height="22"/></a>
<a href="example.com"><img src="https://img.shields.io/badge/Telegram-2CA5E0?&logo=telegram&logoColor=white" alt="Telegram" height="22"/></a>
<a href="https://t.me/nibiruhackathon"><img src="https://img.shields.io/badge/Telegram-2CA5E0?&logo=telegram&logoColor=white" alt="Telegram" height="22"/></a>
</p>

----
Expand Down
11 changes: 11 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,17 @@ func NewNibiruApp(
app.SetAnteHandler(anteHandler)
app.SetEndBlocker(app.EndBlocker)

if snapshotManager := app.SnapshotManager(); snapshotManager != nil {
if err = snapshotManager.RegisterExtensions(
wasmkeeper.NewWasmSnapshotter(
app.CommitMultiStore(),
&app.WasmKeeper,
),
); err != nil {
panic("failed to add wasm snapshot extension.")
}
}

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
Expand Down
6 changes: 3 additions & 3 deletions app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (app *NibiruApp) InitKeepers(
appCodec,
keys[banktypes.StoreKey],
app.AccountKeeper,
blockedAddresses(),
BlockedAddresses(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.stakingKeeper = stakingkeeper.NewKeeper(
Expand Down Expand Up @@ -679,8 +679,8 @@ func orderedModuleNames() []string {
}
}

// blockedAddresses returns all the app's blocked account addresses.
func blockedAddresses() map[string]bool {
// BlockedAddresses returns all the app's blocked account addresses.
func BlockedAddresses() map[string]bool {
modAccAddrs := make(map[string]bool)
for acc := range maccPerms {
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
Expand Down
4 changes: 2 additions & 2 deletions contrib/make/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ test-coverage:
go test ./... $(PACKAGES_NOSIMULATION) -short \
-coverprofile=coverage.txt \
-covermode=atomic \
-race | grep -v "no test" | grep -v "no statement"
-race

# NOTE: Using the verbose flag breaks the coverage reporting in CI.
# Used for CI by Codecov
Expand All @@ -18,7 +18,7 @@ test-coverage-integration:
go test ./... \
-coverprofile=coverage.txt \
-covermode=atomic \
-race | grep -v "no test" | grep -v "no statement"
-race

# Require Python3
.PHONY: test-create-test-cases
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
cosmossdk.io/math v1.1.2
github.com/CosmWasm/wasmd v0.40.2
github.com/CosmWasm/wasmvm v1.4.0
github.com/MakeNowJust/heredoc/v2 v2.0.1
github.com/NibiruChain/collections v0.3.0
github.com/armon/go-metrics v0.4.1
github.com/cometbft/cometbft v0.37.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/MakeNowJust/heredoc/v2 v2.0.1 h1:rlCHh70XXXv7toz95ajQWOWQnN4WNLt0TdpZYIR/J6A=
github.com/MakeNowJust/heredoc/v2 v2.0.1/go.mod h1:6/2Abh5s+hc3g9nbWLe9ObDIOhaRrqsyY9MWy+4JdRM=
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
github.com/NibiruChain/collections v0.3.0 h1:DB2RPzzgcHk35lRXuJ1cPOezweAZ6/c/Guq3bAo4W6w=
github.com/NibiruChain/collections v0.3.0/go.mod h1:tKTlBL+Cs1oJnS4tT9MIaFWr7BWsUXrc7KPzP1LxRBo=
Expand Down
5 changes: 3 additions & 2 deletions proto/nibiru/devgas/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ option go_package = "github.com/NibiruChain/nibiru/x/devgas/v1/types";
// GenesisState defines the module's genesis state.
message GenesisState {
// params are the feeshare module parameters
ModuleParams params = 1 [ (gogoproto.nullable) = false ];
nibiru.devgas.v1.ModuleParams params = 1 [ (gogoproto.nullable) = false ];
// FeeShare is a slice of active registered contracts for fee distribution
repeated FeeShare fee_share = 2 [ (gogoproto.nullable) = false ];
repeated nibiru.devgas.v1.FeeShare fee_share = 2
[ (gogoproto.nullable) = false ];
}

// ModuleParams defines the params for the devgas module
Expand Down
10 changes: 6 additions & 4 deletions proto/nibiru/devgas/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ message QueryFeeSharesRequest {
// method.
message QueryFeeSharesResponse {
// FeeShare is the slice of all stored Reveneue for the deployer
repeated FeeShare feeshare = 1 [ (gogoproto.nullable) = false ];
repeated nibiru.devgas.v1.FeeShare feeshare = 1
[ (gogoproto.nullable) = false ];
}

// QueryFeeShareRequest is the request type for the Query/FeeShare RPC method.
Expand All @@ -70,7 +71,7 @@ message QueryFeeShareRequest {
// QueryFeeShareResponse is the response type for the Query/FeeShare RPC method.
message QueryFeeShareResponse {
// FeeShare is a stored Reveneue for the queried contract
FeeShare feeshare = 1 [ (gogoproto.nullable) = false ];
nibiru.devgas.v1.FeeShare feeshare = 1 [ (gogoproto.nullable) = false ];
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
Expand All @@ -79,7 +80,7 @@ message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params is the returned FeeShare parameter
ModuleParams params = 1 [ (gogoproto.nullable) = false ];
nibiru.devgas.v1.ModuleParams params = 1 [ (gogoproto.nullable) = false ];
}

// QueryFeeSharesByWithdrawerRequest is the request type for the
Expand All @@ -92,5 +93,6 @@ message QueryFeeSharesByWithdrawerRequest {
// QueryFeeSharesByWithdrawerResponse is the response type for the
// Query/FeeSharesByWithdrawer RPC method.
message QueryFeeSharesByWithdrawerResponse {
repeated FeeShare feeshare = 1 [ (gogoproto.nullable) = false ];
repeated nibiru.devgas.v1.FeeShare feeshare = 1
[ (gogoproto.nullable) = false ];
}
3 changes: 2 additions & 1 deletion proto/nibiru/epochs/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ option go_package = "github.com/NibiruChain/nibiru/x/epochs/types";

// GenesisState defines the epochs module's genesis state.
message GenesisState {
repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ];
repeated nibiru.epochs.v1.EpochInfo epochs = 1
[ (gogoproto.nullable) = false ];
}
5 changes: 3 additions & 2 deletions proto/nibiru/epochs/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ service Query {

message QueryEpochsInfoRequest {}
message QueryEpochsInfoResponse {
repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ];
repeated nibiru.epochs.v1.EpochInfo epochs = 1
[ (gogoproto.nullable) = false ];
}

message QueryCurrentEpochRequest { string identifier = 1; }
message QueryCurrentEpochResponse { uint64 current_epoch = 1; }
message QueryCurrentEpochResponse { uint64 current_epoch = 1; }
2 changes: 1 addition & 1 deletion proto/nibiru/inflation/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
nibiru.inflation.v1.Params params = 1 [ (gogoproto.nullable) = false ];
}
2 changes: 1 addition & 1 deletion proto/nibiru/oracle/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ message EventAggregateVote {
// transaction messages on behalf of the voting validator.
string feeder = 2;

repeated ExchangeRateTuple prices = 3 [
repeated nibiru.oracle.v1.ExchangeRateTuple prices = 3 [
(gogoproto.castrepeated) = "ExchangeRateTuples",
(gogoproto.nullable) = false
];
Expand Down
18 changes: 10 additions & 8 deletions proto/nibiru/oracle/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ option go_package = "github.com/NibiruChain/nibiru/x/oracle/types";

// GenesisState defines the oracle module's genesis state.
message GenesisState {
Params params = 1 [ (gogoproto.nullable) = false ];
repeated FeederDelegation feeder_delegations = 2
nibiru.oracle.v1.Params params = 1 [ (gogoproto.nullable) = false ];
repeated nibiru.oracle.v1.FeederDelegation feeder_delegations = 2
[ (gogoproto.nullable) = false ];
repeated ExchangeRateTuple exchange_rates = 3 [
repeated nibiru.oracle.v1.ExchangeRateTuple exchange_rates = 3 [
(gogoproto.castrepeated) = "ExchangeRateTuples",
(gogoproto.nullable) = false
];
repeated MissCounter miss_counters = 4 [ (gogoproto.nullable) = false ];
repeated AggregateExchangeRatePrevote aggregate_exchange_rate_prevotes = 5
[ (gogoproto.nullable) = false ];
repeated AggregateExchangeRateVote aggregate_exchange_rate_votes = 6
repeated nibiru.oracle.v1.MissCounter miss_counters = 4
[ (gogoproto.nullable) = false ];
repeated nibiru.oracle.v1.AggregateExchangeRatePrevote
aggregate_exchange_rate_prevotes = 5 [ (gogoproto.nullable) = false ];
repeated nibiru.oracle.v1.AggregateExchangeRateVote
aggregate_exchange_rate_votes = 6 [ (gogoproto.nullable) = false ];
repeated string pairs = 7 [
(gogoproto.customtype) =
"github.com/NibiruChain/nibiru/x/common/asset.Pair",
(gogoproto.nullable) = false
];
repeated Rewards rewards = 8 [ (gogoproto.nullable) = false ];
repeated nibiru.oracle.v1.Rewards rewards = 8
[ (gogoproto.nullable) = false ];
}

// FeederDelegation is the address for where oracle feeder authority are
Expand Down
15 changes: 8 additions & 7 deletions proto/nibiru/oracle/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ message QueryExchangeRatesRequest {}
message QueryExchangeRatesResponse {
// exchange_rates defines a list of the exchange rate for all whitelisted
// pairs.
repeated ExchangeRateTuple exchange_rates = 1 [
repeated nibiru.oracle.v1.ExchangeRateTuple exchange_rates = 1 [
(gogoproto.castrepeated) = "ExchangeRateTuples",
(gogoproto.nullable) = false
];
Expand Down Expand Up @@ -204,7 +204,7 @@ message QueryAggregatePrevoteRequest {
message QueryAggregatePrevoteResponse {
// aggregate_prevote defines oracle aggregate prevote submitted by a validator
// in the current vote period
AggregateExchangeRatePrevote aggregate_prevote = 1
nibiru.oracle.v1.AggregateExchangeRatePrevote aggregate_prevote = 1
[ (gogoproto.nullable) = false ];
;
}
Expand All @@ -218,7 +218,7 @@ message QueryAggregatePrevotesRequest {}
message QueryAggregatePrevotesResponse {
// aggregate_prevotes defines all oracle aggregate prevotes submitted in the
// current vote period
repeated AggregateExchangeRatePrevote aggregate_prevotes = 1
repeated nibiru.oracle.v1.AggregateExchangeRatePrevote aggregate_prevotes = 1
[ (gogoproto.nullable) = false ];
}

Expand All @@ -237,7 +237,8 @@ message QueryAggregateVoteRequest {
message QueryAggregateVoteResponse {
// aggregate_vote defines oracle aggregate vote submitted by a validator in
// the current vote period
AggregateExchangeRateVote aggregate_vote = 1 [ (gogoproto.nullable) = false ];
nibiru.oracle.v1.AggregateExchangeRateVote aggregate_vote = 1
[ (gogoproto.nullable) = false ];
}

// QueryAggregateVotesRequest is the request type for the Query/AggregateVotes
Expand All @@ -249,7 +250,7 @@ message QueryAggregateVotesRequest {}
message QueryAggregateVotesResponse {
// aggregate_votes defines all oracle aggregate votes submitted in the current
// vote period
repeated AggregateExchangeRateVote aggregate_votes = 1
repeated nibiru.oracle.v1.AggregateExchangeRateVote aggregate_votes = 1
[ (gogoproto.nullable) = false ];
}

Expand All @@ -259,5 +260,5 @@ message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
}
nibiru.oracle.v1.Params params = 1 [ (gogoproto.nullable) = false ];
}
2 changes: 1 addition & 1 deletion proto/nibiru/oracle/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ message MsgDelegateFeedConsent {

// MsgDelegateFeedConsentResponse defines the Msg/DelegateFeedConsent response
// type.
message MsgDelegateFeedConsentResponse {}
message MsgDelegateFeedConsentResponse {}
Loading

0 comments on commit dfeefb9

Please sign in to comment.