Skip to content

Commit

Permalink
Merge branch 'realu/collateral-queries' into mat/collateral-queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine committed Nov 16, 2023
2 parents c9e9c41 + 5c98a89 commit ab2dd3c
Show file tree
Hide file tree
Showing 64 changed files with 1,469 additions and 989 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/changelog-deps.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
name: "Automatically update changelog with dependabot"
on:
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
changelog-update:
runs-on: ubuntu-latest

if: contains(github.event.pull_request.labels.*.name, 'dependabot')
# TODO: feat: try to use author of the commit(s) to see if it's dependabot
# ${{ any(contains(commit.author.username, 'dependabot') for commit in github.event.commits) }}
steps:
# TODO: feat: try to use author of the commit(s) to see if it's dependabot
# instead of using labels. Labels work fine for now.
# ${{ any(contains(commit.author.username, 'dependabot') for commit in github.event.commits) }}

steps:
- uses: actions/checkout@v4
with:
# Token with permissions for pushing commits and editting GH issues
token: ${{ secrets.NIBIRU_PM }}
# to avoid checking out the repo in a detached state
ref: ${{ github.head_ref }}
# Helps keep your repository up-to-date when Dependabot updates your dependencies.
# This step updates adds a line to the "## Unreleased" section
- uses: dangoslen/dependabot-changelog-helper@v3
with:
activationLabel: 'dependabot'
changelogPath: './CHANGELOG.md'
activationLabel: "dependabot"
changelogPath: "./CHANGELOG.md"

- uses: stefanzweifel/git-auto-commit-action@v5
with:
Expand Down
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.27.2
# - uses: bufbuild/buf-setup-action@v1.28.1
# - 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.27.2
- uses: bufbuild/buf-setup-action@v1.28.1
with:
github_token: ${{ github.token }}
- uses: bufbuild/buf-breaking-action@v1
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### 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.2 ([#1624](https://github.com/NibiruChain/nibiru/pull/1624), [#1641](https://github.com/NibiruChain/nibiru/pull/1641), [#1654](https://github.com/NibiruChain/nibiru/pull/1654))
- Bump `bufbuild/buf-setup-action` from 1.26.1 to 1.28.1 ([#1624](https://github.com/NibiruChain/nibiru/pull/1624), [#1641](https://github.com/NibiruChain/nibiru/pull/1641), [#1654](https://github.com/NibiruChain/nibiru/pull/1654), [#1671](https://github.com/NibiruChain/nibiru/pull/1671), [#1673](https://github.com/NibiruChain/nibiru/pull/1673))
- Bump `stefanzweifel/git-auto-commit-action` from 4 to 5 ([#1625](https://github.com/NibiruChain/nibiru/pull/1625))
- Bump `github.com/CosmWasm/wasmvm` from 1.4.0 to 1.5.0 ([#1629](https://github.com/NibiruChain/nibiru/pull/1629), [#1657](https://github.com/NibiruChain/nibiru/pull/1657))
- Bump `google.golang.org/grpc` from 1.58.2 to 1.59.0 ([#1633](https://github.com/NibiruChain/nibiru/pull/1633), [#1643](https://github.com/NibiruChain/nibiru/pull/1643))
Expand All @@ -82,6 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bump `github.com/cosmos/ibc-go/v7` from 7.3.0 to 7.3.1 ([#1647](https://github.com/NibiruChain/nibiru/pull/1647))
- Bump `github.com/CosmWasm/wasmd` from 0.40.2 to 0.43.0 ([#1660](https://github.com/NibiruChain/nibiru/pull/1660))
- Bump `github.com/CosmWasm/wasmd` from 0.43.0 to 0.44.0 ([#1666](https://github.com/NibiruChain/nibiru/pull/1666))
- Bump `github.com/spf13/cobra` from 1.7.0 to 1.8.0 ([#1664](https://github.com/NibiruChain/nibiru/pull/1664))

### Bug Fixes

Expand Down Expand Up @@ -787,4 +788,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.
9 changes: 5 additions & 4 deletions app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,14 @@ func (app *NibiruApp) InitKeepers(
appCodec, keys[epochstypes.StoreKey],
)

app.SudoKeeper = keeper.NewKeeper(
appCodec, keys[sudotypes.StoreKey],
)

app.PerpKeeperV2 = perpkeeper.NewKeeper(
appCodec, keys[perptypes.StoreKey],
app.AccountKeeper, app.BankKeeper, app.OracleKeeper, app.EpochsKeeper,
)

app.SudoKeeper = keeper.NewKeeper(
appCodec, keys[sudotypes.StoreKey],
app.SudoKeeper,
)

app.InflationKeeper = inflationkeeper.NewKeeper(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/prometheus/client_golang v1.17.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.1
github.com/spf13/cobra v1.7.0
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
Expand Down
6 changes: 3 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ github.com/cosmos/rosetta-sdk-go v0.10.0 h1:E5RhTruuoA7KTIXUcMicL76cffyeoyvNybzU
github.com/cosmos/rosetta-sdk-go v0.10.0/go.mod h1:SImAZkb96YbwvoRkzSMQB6noNJXFgWl/ENIznEoYQI4=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJFxv2Li8=
github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
Expand Down Expand Up @@ -1094,8 +1094,8 @@ github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA=
github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
Expand Down
12 changes: 5 additions & 7 deletions proto/nibiru/perp/v2/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@ message GenesisState {
[ (gogoproto.nullable) = false ];

uint64 dnr_epoch = 6;

message TraderVolume {
string trader = 1;
uint64 epoch = 2;
string volume = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];

}

// For testing purpose, we allow the collateral to be set at genesis
string collateral_creator = 11;
string collateral_subdenom = 12;

// For testing purposes, we allow the collateral to be set at genesis
string collateral_denom = 11;

repeated TraderVolume trader_volumes = 7 [ (gogoproto.nullable) = false ];

Expand Down Expand Up @@ -86,4 +84,4 @@ message GenesisPosition {
uint64 version = 2;

Position position = 3 [ (gogoproto.nullable) = false ];
}
}
38 changes: 30 additions & 8 deletions proto/nibiru/perp/v2/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ option go_package = "github.com/NibiruChain/nibiru/x/perp/v2/types";

// Query defines the gRPC querier service.
service Query {
// QueryPosition: Query one position on the given market for a user
rpc QueryPosition(QueryPositionRequest) returns (QueryPositionResponse) {
option (google.api.http).get = "/nibiru/perp/v2/position";
}

// QueryPositions: Query all positions for a user
rpc QueryPositions(QueryPositionsRequest) returns (QueryPositionsResponse) {
option (google.api.http).get = "/nibiru/perp/v2/positions";
}
Expand All @@ -26,35 +28,46 @@ service Query {
option (google.api.http).get = "/nibiru/perp/v2/position_store";
}

// Queries the reserve assets in a given pool, identified by a token pair.
// Queries the module accounts for x/perp
rpc ModuleAccounts(QueryModuleAccountsRequest)
returns (QueryModuleAccountsResponse) {
option (google.api.http).get = "/nibiru/perp/v2/module_accounts";
}

// QueryMarkets: Query all markets
rpc QueryMarkets(QueryMarketsRequest) returns (QueryMarketsResponse) {
option (google.api.http).get = "/nibiru/perp/v2/markets";
}

rpc QueryCollateral(QueryCollateralRequest) returns (QueryCollateralResponse) {
// QueryCollateral: Queries info about the collateral
rpc QueryCollateral(QueryCollateralRequest)
returns (QueryCollateralResponse) {
option (google.api.http).get = "/nibiru/perp/v2/collateral";
}
}

// ---------------------------------------- Positions

// QueryPositionsRequest: Request type for the
// "nibiru.perp.v2.Query/Positions" gRPC service method
message QueryPositionsRequest { string trader = 1; }

// QueryPositionsResponse: Response type for the
// "nibiru.perp.v2.Query/Positions" gRPC service method
message QueryPositionsResponse {
repeated nibiru.perp.v2.QueryPositionResponse positions = 1
[ (gogoproto.nullable) = false ];
}

// QueryPositionStoreRequest: Request type for the
// "nibiru.perp.v2.Query/PositionStore" gRPC service method
message QueryPositionStoreRequest {
// pagination defines a paginated request
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

// QueryPositionStoreResponse: Response type for the
// "nibiru.perp.v2.Query/PositionStore" gRPC service method
message QueryPositionStoreResponse {
// Position responses: collection of all stored positions (with pagination)
repeated nibiru.perp.v2.Position positions = 1
Expand All @@ -66,8 +79,8 @@ message QueryPositionStoreResponse {

// ---------------------------------------- Position

// QueryPositionRequest is the request type for the position of the x/perp
// module account.
// QueryPositionRequest: Request type for the
// "nibiru.perp.v2.Query/Position" gRPC service method
message QueryPositionRequest {
string pair = 1 [
(gogoproto.customtype) =
Expand All @@ -78,6 +91,8 @@ message QueryPositionRequest {
string trader = 2;
}

// QueryPositionResponse: Response type for the
// "nibiru.perp.v2.Query/Position" gRPC service method
message QueryPositionResponse {
// The position as it exists in the blockchain state
nibiru.perp.v2.Position position = 1 [ (gogoproto.nullable) = false ];
Expand All @@ -104,8 +119,12 @@ message QueryPositionResponse {

// ---------------------------------------- QueryModuleAccounts

// QueryModuleAccountsRequest: Request type for the
// "nibiru.perp.v2.Query/ModuleAccounts" gRPC service method
message QueryModuleAccountsRequest {}

// QueryModuleAccountsResponse: Response type for the
// "nibiru.perp.v2.Query/ModuleAccounts" gRPC service method
message QueryModuleAccountsResponse {
repeated nibiru.perp.v2.AccountWithBalance accounts = 1
[ (gogoproto.nullable) = false ];
Expand Down Expand Up @@ -133,9 +152,12 @@ message QueryMarketsResponse {
[ (gogoproto.nullable) = false ];
}

// ---------------------------------------- QueryCollateral

// QueryCollateralRequest: Request type for the
// "nibiru.perp.v2.Query/Collateral" gRPC service method
message QueryCollateralRequest {}

message QueryCollateralResponse {
string collateral_creator= 1;
string collateral_subdenom= 2;
}
// QueryCollateralRequest: Response type for the
// "nibiru.perp.v2.Query/Collateral" gRPC service method
message QueryCollateralResponse { string collateral_denom = 1; }
14 changes: 14 additions & 0 deletions proto/nibiru/perp/v2/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ service Msg {

rpc DonateToEcosystemFund(MsgDonateToEcosystemFund)
returns (MsgDonateToEcosystemFundResponse) {}

rpc ChangeCollateralDenom(MsgChangeCollateralDenom)
returns (MsgChangeCollateralDenomResponse) {}
}

// -------------------------- Settle Position --------------------------
Expand Down Expand Up @@ -328,3 +331,14 @@ message MsgDonateToEcosystemFund {
}

message MsgDonateToEcosystemFundResponse {}

// ----------------------- MsgChangeCollateralDenom -----------------------

// MsgChangeCollateralDenom: Changes the collateral denom for the module.
// [Admin] Only callable by sudoers.
message MsgChangeCollateralDenom {
string sender = 1;
string new_denom = 2;
}

message MsgChangeCollateralDenomResponse {}
5 changes: 0 additions & 5 deletions wasmbinding/bindings/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ type SetMarketEnabled struct {
Enabled bool `json:"enabled"`
}

type UpdateCollateral struct {
Denom string `json:"denom"`
ContractAddress string `json:"contract_address"`
}

type CreateMarket struct {
Pair string `json:"pair"`
PegMult sdk.Dec `json:"peg_mult,omitempty"`
Expand Down
10 changes: 0 additions & 10 deletions wasmbinding/exec_perp.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,6 @@ func (exec *ExecutorPerp) SetMarketEnabled(
return exec.PerpV2.Admin.CloseMarket(ctx, pair)
}

func (exec *ExecutorPerp) UpdateCollateral(
cwMsg *bindings.UpdateCollateral, ctx sdk.Context,
) (err error) {
if cwMsg == nil {
return wasmvmtypes.InvalidRequest{Err: "null msg"}
}

return exec.PerpV2.Admin.UpdateCollateral(ctx, cwMsg.Denom, cwMsg.ContractAddress)
}

func (exec *ExecutorPerp) CreateMarket(
cwMsg *bindings.CreateMarket, ctx sdk.Context,
) (err error) {
Expand Down
Loading

0 comments on commit ab2dd3c

Please sign in to comment.