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

refactor(perp): Moves types, keeper, and cli from vpool to perp/amm #1 #1267

Merged
merged 4 commits into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Breaking

* [#1267](https://github.com/NibiruChain/nibiru/pull/1267) - refactor(perp)!: (1/2) Moves types, keeper, and cli from vpool to perp/amm
* [#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
Expand Down
10 changes: 5 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ import (
oraclekeeper "github.com/NibiruChain/nibiru/x/oracle/keeper"
oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
"github.com/NibiruChain/nibiru/x/perp"
perpammcli "github.com/NibiruChain/nibiru/x/perp/amm/cli"
vpoolkeeper "github.com/NibiruChain/nibiru/x/perp/amm/keeper"
vpooltypes "github.com/NibiruChain/nibiru/x/perp/amm/types"
perpkeeper "github.com/NibiruChain/nibiru/x/perp/keeper"
perptypes "github.com/NibiruChain/nibiru/x/perp/types"
"github.com/NibiruChain/nibiru/x/spot"
Expand All @@ -125,9 +128,6 @@ import (
"github.com/NibiruChain/nibiru/x/util"
utiltypes "github.com/NibiruChain/nibiru/x/util/types"
"github.com/NibiruChain/nibiru/x/vpool"
vpoolcli "github.com/NibiruChain/nibiru/x/vpool/client/cli"
vpoolkeeper "github.com/NibiruChain/nibiru/x/vpool/keeper"
vpooltypes "github.com/NibiruChain/nibiru/x/vpool/types"
)

const (
Expand Down Expand Up @@ -162,8 +162,8 @@ var (
distrclient.ProposalHandler,
upgradeclient.ProposalHandler,
upgradeclient.CancelProposalHandler,
vpoolcli.CreatePoolProposalHandler,
vpoolcli.EditPoolConfigProposalHandler,
perpammcli.CreatePoolProposalHandler,
perpammcli.EditPoolConfigProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
ibcclientclient.UpgradeProposalHandler,
),
Expand Down
4 changes: 2 additions & 2 deletions cmd/nibid/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
dbm "github.com/tendermint/tm-db"

"github.com/NibiruChain/nibiru/app"
vpoolcli "github.com/NibiruChain/nibiru/x/vpool/client/cli"
perpammcli "github.com/NibiruChain/nibiru/x/perp/amm/cli"
)

// NewRootCmd creates a new root command for nibid. It is called once in the
Expand Down Expand Up @@ -144,7 +144,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
genutilcli.GenTxCmd(app.ModuleBasics, encodingConfig.TxConfig, banktypes.GenesisBalancesIterator{}, app.DefaultNodeHome),
genutilcli.ValidateGenesisCmd(app.ModuleBasics),
AddGenesisAccountCmd(app.DefaultNodeHome),
vpoolcli.AddVpoolGenesisCmd(app.DefaultNodeHome),
perpammcli.AddVpoolGenesisCmd(app.DefaultNodeHome),
tmcli.NewCompletionCmd(rootCmd, true),
testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}),
AddGenesisWasmMsgCmd(app.DefaultNodeHome),
Expand Down
12 changes: 6 additions & 6 deletions proto/vpool/v1/event.proto → proto/perp/amm/v1/event.proto
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
syntax = "proto3";

package nibiru.vpool.v1;
package nibiru.perp.amm.v1;

import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/NibiruChain/nibiru/x/vpool/types";
option go_package = "github.com/NibiruChain/nibiru/x/perp/amm/types";

message ReserveSnapshotSavedEvent {
string pair = 1 [
Expand Down Expand Up @@ -40,22 +40,22 @@ message ReserveSnapshotSavedEvent {
];
}

// A swap on the vpool represented by 'pair'.
// A swap on the perp.amm represented by 'pair'.
// Amounts are negative or positive base on the perspective of the pool, i.e.
// a negative quote means the trader has gained quote and the vpool lost quote.
// a negative quote means the trader has gained quote and the perp.amm lost quote.
message SwapOnVpoolEvent {
string pair = 1 [
(gogoproto.customtype) = "github.com/NibiruChain/nibiru/x/common/asset.Pair",
(gogoproto.nullable) = false
];

// delta in the quote reserves of the vpool
// delta in the quote reserves of the perp.amm
string quote_amount = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// delta in the base reserves of the vpool
// delta in the base reserves of the perp.amm
string base_amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
Expand Down
12 changes: 12 additions & 0 deletions proto/perp/amm/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
syntax = "proto3";
package nibiru.perp.amm.v1;

import "gogoproto/gogo.proto";
import "perp/amm/v1/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/perp/amm/types";

// GenesisState defines the perp.amm module's genesis state.
message GenesisState {
repeated Vpool vpools = 1 [(gogoproto.nullable) = false];
}
12 changes: 7 additions & 5 deletions proto/vpool/v1/gov.proto → proto/perp/amm/v1/gov.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
syntax = "proto3";

package nibiru.vpool.v1;
package nibiru.perp.amm.v1;

import "gogoproto/gogo.proto";
import "vpool/v1/state.proto";
import "perp/amm/v1/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/vpool/types";
option go_package = "github.com/NibiruChain/nibiru/x/perp/amm/types";

message CreatePoolProposal {
string title = 1;
Expand All @@ -17,12 +17,14 @@ message CreatePoolProposal {
(gogoproto.nullable) = false
];

// quote_asset_reserve is the amount of quote asset the pool will be initialized with.
// quote_asset_reserve is the amount of quote asset the pool will be
// initialized with.
string quote_asset_reserve = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// base_asset_reserve is the amount of base asset the pool will be initialized with.
// base_asset_reserve is the amount of base asset the pool will be
// initialized with.
string base_asset_reserve = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
Expand Down
12 changes: 6 additions & 6 deletions proto/vpool/v1/query.proto → proto/perp/amm/v1/query.proto
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
syntax = "proto3";

package nibiru.vpool.v1;
package nibiru.perp.amm.v1;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "vpool/v1/state.proto";
import "perp/amm/v1/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/vpool/types";
option go_package = "github.com/NibiruChain/nibiru/x/perp/amm/types";

// Query defines the gRPC querier service.
service Query {

// Queries the reserve assets in a given pool, identified by a token pair.
rpc ReserveAssets(QueryReserveAssetsRequest) returns (QueryReserveAssetsResponse) {
option (google.api.http).get = "/nibiru/vpool/reserve_assets";
option (google.api.http).get = "/nibiru/perp/amm/reserve_assets";
}

// Queries all virtual pools.
rpc AllPools(QueryAllPoolsRequest) returns (QueryAllPoolsResponse) {
option (google.api.http).get = "/nibiru/vpool/all_pools";
option (google.api.http).get = "/nibiru/perp/amm/all_pools";
}

// Queries prices
rpc BaseAssetPrice(QueryBaseAssetPriceRequest) returns (QueryBaseAssetPriceResponse) {
option (google.api.http).get = "/nibiru/vpool/base_asset_price";
option (google.api.http).get = "/nibiru/perp/amm/base_asset_price";
}

}
Expand Down
6 changes: 3 additions & 3 deletions proto/vpool/v1/state.proto → proto/perp/amm/v1/state.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
syntax = "proto3";

package nibiru.vpool.v1;
package nibiru.perp.amm.v1;

option go_package = "github.com/NibiruChain/nibiru/x/vpool/types";
option go_package = "github.com/NibiruChain/nibiru/x/perp/amm/types";

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
Expand Down Expand Up @@ -115,7 +115,7 @@ message CurrentTWAP {
string price = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
}

// a snapshot of the vpool's reserves at a given point in time
// a snapshot of the perp.amm's reserves at a given point in time
message ReserveSnapshot {
string pair = 5 [
(gogoproto.customtype) = "github.com/NibiruChain/nibiru/x/common/asset.Pair",
Expand Down
4 changes: 2 additions & 2 deletions proto/perp/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ message PositionLiquidatedEvent {
// owner of the position.
string trader_address = 2;

// margin * leverage * vPrice. 'notional' is the virtual size times the virtual price on 'vpool'.
// margin * leverage * vPrice. 'notional' is the virtual size times the virtual price on 'perp.amm'.
string exchanged_quote_amount = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
Expand Down Expand Up @@ -197,7 +197,7 @@ message PositionSettledEvent {
// Owner of the position.
string trader_address = 2;

// Settled coin as dictated by the settlement price of the vpool.
// Settled coin as dictated by the settlement price of the perp.amm.
repeated cosmos.base.v1beta1.Coin settled_coins = 3 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"settled_coins\"",
Expand Down
4 changes: 2 additions & 2 deletions proto/util/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ syntax = "proto3";

package nibiru.util.v1;

import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "cosmos/base/v1beta1/coin.proto";
import "vpool/v1/state.proto";
import "perp/amm/v1/state.proto";

option go_package = "github.com/NibiruChain/nibiru/x/util/types";

Expand Down
12 changes: 0 additions & 12 deletions proto/vpool/v1/genesis.proto

This file was deleted.

8 changes: 4 additions & 4 deletions x/common/testutil/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"github.com/NibiruChain/nibiru/x/common/asset"
oraclecli "github.com/NibiruChain/nibiru/x/oracle/client/cli"
oracletypes "github.com/NibiruChain/nibiru/x/oracle/types"
perpammcli "github.com/NibiruChain/nibiru/x/perp/amm/cli"
vpooltypes "github.com/NibiruChain/nibiru/x/perp/amm/types"
perpcli "github.com/NibiruChain/nibiru/x/perp/client/cli"
perptypes "github.com/NibiruChain/nibiru/x/perp/types"
vpoolcli "github.com/NibiruChain/nibiru/x/vpool/client/cli"
vpooltypes "github.com/NibiruChain/nibiru/x/vpool/types"
)

// ExecQueryOption defines a type which customizes a CLI query operation.
Expand Down Expand Up @@ -77,7 +77,7 @@ func ExecQuery(clientCtx client.Context, cmd *cobra.Command, args []string, resu
func QueryVpoolReserveAssets(clientCtx client.Context, pair asset.Pair,
) (*vpooltypes.QueryReserveAssetsResponse, error) {
var queryResp vpooltypes.QueryReserveAssetsResponse
if err := ExecQuery(clientCtx, vpoolcli.CmdGetVpoolReserveAssets(), []string{pair.String()}, &queryResp); err != nil {
if err := ExecQuery(clientCtx, perpammcli.CmdGetVpoolReserveAssets(), []string{pair.String()}, &queryResp); err != nil {
return nil, err
}
return &queryResp, nil
Expand All @@ -93,7 +93,7 @@ func QueryOracleExchangeRate(clientCtx client.Context, pair asset.Pair) (*oracle

func QueryBaseAssetPrice(clientCtx client.Context, pair asset.Pair, direction string, amount string) (*vpooltypes.QueryBaseAssetPriceResponse, error) {
var queryResp vpooltypes.QueryBaseAssetPriceResponse
if err := ExecQuery(clientCtx, vpoolcli.CmdGetBaseAssetPrice(), []string{pair.String(), direction, amount}, &queryResp); err != nil {
if err := ExecQuery(clientCtx, perpammcli.CmdGetBaseAssetPrice(), []string{pair.String(), direction, amount}, &queryResp); err != nil {
return nil, err
}
return &queryResp, nil
Expand Down
2 changes: 1 addition & 1 deletion x/common/testutil/mock/perp_interfaces.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading