Skip to content

Commit

Permalink
Merge pull request #358 from comdex-official/feature/dev
Browse files Browse the repository at this point in the history
Feature/dev
  • Loading branch information
dheerajkd30 authored Jul 21, 2022
2 parents 29263f8 + 46135c2 commit a2d03e0
Show file tree
Hide file tree
Showing 69 changed files with 10,292 additions and 1,991 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To verify latest testnet and main net version check
For further information on joining the testnet, head over to the
[Comdex Networks TestNet](https://github.com/comdex-official/networks/tree/main/testnet).

The explorer for this chain is hosted [TestNet Explorer](https://comets-test.comdex.one/)
The explorer for this chain is hosted [Meteor - TestNet Explorer](https://meteor-explorer.comdex.one)

## Main Net
For further information on joining the mainnet, head over to the
Expand Down
24 changes: 23 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package app
import (
"fmt"
icacontrollertypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/controller/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"net/http"

ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host"
Expand Down Expand Up @@ -631,6 +634,7 @@ func New(
&app.MarketKeeper,
&app.AuctionKeeper,
&app.EsmKeeper,
&app.LendKeeper,
)

app.AuctionKeeper = *auctionkeeper.NewKeeper(
Expand All @@ -647,6 +651,7 @@ func New(
&app.CollectorKeeper,
&app.TokenmintKeeper,
&app.EsmKeeper,
&app.LendKeeper,
)

app.CollectorKeeper = *collectorkeeper.NewKeeper(
Expand Down Expand Up @@ -1049,7 +1054,7 @@ func (a *App) GetSubspace(moduleName string) paramstypes.Subspace {

// RegisterAPIRoutes registers all application module routes with the provided
// API server.
func (a *App) RegisterAPIRoutes(server *api.Server, _ serverconfig.APIConfig) {
func (a *App) RegisterAPIRoutes(server *api.Server, apiConfig serverconfig.APIConfig) {
ctx := server.ClientCtx
rpc.RegisterRoutes(ctx, server.Router)
// Register legacy tx routes.
Expand All @@ -1062,6 +1067,23 @@ func (a *App) RegisterAPIRoutes(server *api.Server, _ serverconfig.APIConfig) {
// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterRESTRoutes(ctx, server.Router)
ModuleBasics.RegisterGRPCGatewayRoutes(ctx, server.GRPCGatewayRouter)

// register swagger API from root so that other applications can override easily
if apiConfig.Swagger {
RegisterSwaggerAPI(ctx, server.Router)
}
}

// RegisterSwaggerAPI registers swagger route with API Server.
func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) {
statikFS, err := fs.New()
if err != nil {
panic(err)
}

staticServer := http.FileServer(statikFS)
rtr.PathPrefix("/static/").Handler(http.StripPrefix("/static/", staticServer))
rtr.PathPrefix("/swagger/").Handler(staticServer)
}

// RegisterTxService implements the Application.RegisterTxService method.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require (

require (
github.com/golangci/golangci-lint v1.46.2
github.com/rakyll/statik v0.1.7
github.com/spf13/pflag v1.0.5
gopkg.in/yaml.v2 v2.4.0
mvdan.cc/gofumpt v0.3.1
Expand Down Expand Up @@ -200,7 +201,6 @@ require (
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
github.com/rakyll/statik v0.1.7 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rs/cors v1.8.2 // indirect
Expand Down
53 changes: 53 additions & 0 deletions proto/comdex/auction/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,50 @@ message QueryAuctionParamResponse {
[ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"auction_params\"" ];
}

message QueryDutchLendAuctionRequest {
uint64 app_id = 1;
uint64 auction_mapping_id = 2;
uint64 auction_id = 3;
bool history = 4;
}

message QueryDutchLendAuctionResponse {
DutchAuction auction = 1
[ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"auction\"" ];
}

message QueryDutchLendAuctionsRequest {
uint64 app_id = 1;
bool history = 2;
cosmos.base.query.v1beta1.PageRequest pagination = 3
[ (gogoproto.moretags) = "yaml:\"pagination\"" ];
}

message QueryDutchLendAuctionsResponse {
repeated DutchAuction auctions = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"auctions\""
];
cosmos.base.query.v1beta1.PageResponse pagination = 2
[ (gogoproto.moretags) = "yaml:\"pagination\"" ];
}

message QueryDutchLendBiddingsRequest {
string bidder = 1;
uint64 app_id = 2;
bool history = 3;
}

message QueryDutchLendBiddingsResponse {
string bidder = 1 [
(gogoproto.moretags) = "yaml:\"bidder\""
];
repeated DutchBiddings biddings = 2 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"biddings\""
];
}


service Query {
rpc QuerySurplusAuction(QuerySurplusAuctionRequest) returns (QuerySurplusAuctionResponse) {
Expand Down Expand Up @@ -241,4 +285,13 @@ service Query {
rpc QueryAuctionParams(QueryAuctionParamRequest) returns (QueryAuctionParamResponse) {
option (google.api.http).get = "/comdex/auction/v1beta1/auctionparams/{app_id}";
}
rpc QueryDutchLendAuction(QueryDutchLendAuctionRequest) returns (QueryDutchLendAuctionResponse) {
option (google.api.http).get = "/comdex/auction/v1beta1/dutchlendauction/{app_id}/{auction_mapping_id}/{auction_id}/{history}";
}
rpc QueryDutchLendAuctions(QueryDutchLendAuctionsRequest) returns (QueryDutchLendAuctionsResponse) {
option (google.api.http).get = "/comdex/auction/v1beta1/dutchlendauctions/{app_id}/{history}";
}
rpc QueryDutchLendBiddings(QueryDutchLendBiddingsRequest) returns (QueryDutchLendBiddingsResponse) {
option (google.api.http).get = "/comdex/auction/v1beta1/dutchlendbiddings/{bidder}/{app_id}/{history}";
}
}
63 changes: 39 additions & 24 deletions proto/comdex/auction/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,62 @@ import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/comdex-official/comdex/x/auction/types";
option (gogoproto.equal_all) = false;
option (gogoproto.equal_all) = false;
option (gogoproto.goproto_getters_all) = false;


message MsgPlaceSurplusBidRequest {
uint64 auction_id = 1;
string bidder = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
uint64 app_id =4;
uint64 auction_mapping_id =5;
uint64 auction_id = 1;
string bidder = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
uint64 app_id = 4;
uint64 auction_mapping_id = 5;
}

message MsgPlaceSurplusBidResponse {}

message MsgPlaceDebtBidRequest {
uint64 auction_id = 1;
string bidder = 2;
cosmos.base.v1beta1.Coin bid = 3 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin expectedUserToken = 4 [(gogoproto.nullable) = false];
uint64 app_id =5;
uint64 auction_mapping_id =6;
uint64 auction_id = 1;
string bidder = 2;
cosmos.base.v1beta1.Coin bid = 3 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin expectedUserToken = 4 [(gogoproto.nullable) = false];
uint64 app_id = 5;
uint64 auction_mapping_id = 6;
}

message MsgPlaceDebtBidResponse {}

message MsgPlaceDutchBidRequest {
uint64 auction_id = 1;
string bidder = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
string max= 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"max\""];
uint64 app_id =5;
uint64 auction_mapping_id =6;
uint64 auction_id = 1;
string bidder = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
string max = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"max\""];
uint64 app_id = 5;
uint64 auction_mapping_id = 6;
}

message MsgPlaceDutchBidResponse {}

message MsgPlaceDutchLendBidRequest {
uint64 auction_id = 1;
string bidder = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
string max = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"max\""];
uint64 app_id = 5;
uint64 auction_mapping_id = 6;
}

message MsgPlaceDutchLendBidResponse {}

service Msg {
rpc MsgPlaceSurplusBid(MsgPlaceSurplusBidRequest) returns (MsgPlaceSurplusBidResponse);
rpc MsgPlaceDebtBid(MsgPlaceDebtBidRequest) returns (MsgPlaceDebtBidResponse);
rpc MsgPlaceDutchBid(MsgPlaceDutchBidRequest) returns (MsgPlaceDutchBidResponse);
rpc MsgPlaceSurplusBid(MsgPlaceSurplusBidRequest) returns (MsgPlaceSurplusBidResponse);
rpc MsgPlaceDebtBid(MsgPlaceDebtBidRequest) returns (MsgPlaceDebtBidResponse);
rpc MsgPlaceDutchBid(MsgPlaceDutchBidRequest) returns (MsgPlaceDutchBidResponse);
rpc MsgPlaceDutchLendBid(MsgPlaceDutchLendBidRequest) returns (MsgPlaceDutchLendBidResponse);
}
25 changes: 24 additions & 1 deletion proto/comdex/lend/v1beta1/lend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ message LendAsset {
(gogoproto.moretags) = "yaml:\"reward_accumulated\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];

uint64 app_id = 10
[(gogoproto.customname) = "AppId", (gogoproto.moretags) = "yaml:\"app_id\""];
}

message BorrowAsset {
Expand Down Expand Up @@ -174,6 +175,9 @@ message Extended_Pair {
(gogoproto.customname) = "AssetOutPoolId",
(gogoproto.moretags) = "yaml:\"asset_out_pool_id\""
];

uint64 min_usd_value_left = 6 [
(gogoproto.moretags) = "yaml:\"min_usd_value_left\"" ];
}

message AssetToPairMapping{
Expand Down Expand Up @@ -408,4 +412,23 @@ message ModuleBalanceStats{
(gogoproto.moretags) = "yaml:\"balance\"",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
}

message BalanceStats{
uint64 asset_id = 1 [
(gogoproto.customname) = "AssetId",
(gogoproto.moretags) = "yaml:\"asset_id\""
];
string amount = 2 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"amount\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"
];
}

message DepositStats{
repeated BalanceStats balance_stats = 1[
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"balance_stats\""
];
}
61 changes: 61 additions & 0 deletions proto/comdex/lend/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,47 @@ message QueryModuleBalanceResponse {
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"module_balance\""];
}

message QueryDepositStatsRequest {}

message QueryDepositStatsResponse {
DepositStats DepositStats = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"deposit_stats\""];
}

message QueryUserDepositStatsRequest {}

message QueryUserDepositStatsResponse {
DepositStats UserDepositStats = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"user_deposit_stats\""];
}

message QueryReserveDepositStatsRequest {}

message QueryReserveDepositStatsResponse {
DepositStats ReserveDepositStats = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"reserve_deposit_stats\""];
}

message QueryBuyBackDepositStatsRequest {}

message QueryBuyBackDepositStatsResponse {
DepositStats BuyBackDepositStats = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"buy_back_deposit_stats\""];
}

message QueryBorrowStatsRequest {}

message QueryBorrowStatsResponse {
DepositStats BorrowStats = 1 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"borrow_stats\""];
}

service Query {
rpc QueryLends(QueryLendsRequest) returns (QueryLendsResponse) {
option (google.api.http).get = "/comdex/lend/v1beta1/lends";
Expand Down Expand Up @@ -303,5 +344,25 @@ service Query {
rpc QueryModuleBalance(QueryModuleBalanceRequest) returns (QueryModuleBalanceResponse) {
option (google.api.http).get = "/comdex/lend/v1beta1/module_balance/{pool_id}";
};

rpc QueryDepositStats(QueryDepositStatsRequest) returns (QueryDepositStatsResponse) {
option (google.api.http).get = "/comdex/lend/v1beta1/deposit_stats";
}

rpc QueryUserDepositStats(QueryUserDepositStatsRequest) returns (QueryUserDepositStatsResponse) {
option (google.api.http).get = "/comdex/lend/v1beta1/user_deposit_stats";
}

rpc QueryReserveDepositStats(QueryReserveDepositStatsRequest) returns (QueryReserveDepositStatsResponse) {
option (google.api.http).get = "/comdex/lend/v1beta1/reserve_deposit_stats";
}

rpc QueryBuyBackDepositStats(QueryBuyBackDepositStatsRequest) returns (QueryBuyBackDepositStatsResponse) {
option (google.api.http).get = "/comdex/lend/v1beta1/buy_back_deposit_stats";
}

rpc QueryBorrowStats(QueryBorrowStatsRequest) returns (QueryBorrowStatsResponse) {
option (google.api.http).get = "/comdex/lend/v1beta1/borrow_stats";
}
}

5 changes: 3 additions & 2 deletions proto/comdex/lend/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ message MsgLend {
uint64 asset_id = 2;
cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false];
uint64 pool_id = 4;
uint64 app_id = 5;
}

message MsgWithdraw {
Expand All @@ -62,7 +63,7 @@ message MsgBorrow {
string borrower = 1;
uint64 lend_id = 2;
uint64 pair_id = 3;
bool is_stable_borrow =4;
bool is_stable_borrow = 4;
cosmos.base.v1beta1.Coin amount_in = 5 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin amount_out = 6 [(gogoproto.nullable) = false];
}
Expand Down Expand Up @@ -93,7 +94,7 @@ message MsgCloseBorrow {

message MsgFundModuleAccounts {
string moduleName = 1;
uint64 assetId =2;
uint64 assetId = 2;
string lender = 3;
cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false];
}
Expand Down
Loading

0 comments on commit a2d03e0

Please sign in to comment.