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

Testdev demo branch merge to feature/dev #258

Merged
merged 34 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5c873ef
auction segregated
Jun 12, 2022
3743640
auction segregated
Jun 12, 2022
35c2122
extra decimal fix
Subham2804 Jun 12, 2022
89b62af
rewards data fixed
Subham2804 Jun 13, 2022
5c5d6f8
dutch auction
Jun 13, 2022
fb90a0d
rewards, vault changes
Jun 13, 2022
e2f871a
dutch auction
Jun 13, 2022
1733b07
dutch auction
Jun 13, 2022
b26270d
dutch auction
Jun 13, 2022
e375048
dutch auction
Jun 13, 2022
199c5b8
formula changed
Jun 13, 2022
f2109a9
formula changed
Jun 14, 2022
a11597e
formula changed
Jun 14, 2022
c71f5d7
formula changed
Jun 14, 2022
cfa428f
formula changed
Jun 14, 2022
d3fd9cc
formula changed
Jun 14, 2022
1d78763
debt,surplus changes
Jun 15, 2022
2571024
Merge pull request #249 from comdex-official/testdev_auction
cgsingh33 Jun 15, 2022
5b9b880
time check added
Jun 15, 2022
8ae1cd9
Merge pull request #250 from comdex-official/testdev_auction
cgsingh33 Jun 15, 2022
ddbf225
dutch changes
Jun 16, 2022
a5df786
lot size change
Jun 16, 2022
56dabca
Merge pull request #251 from comdex-official/testdev_auction
cgsingh33 Jun 16, 2022
d0f04e9
dutch auction, vault query added
Jun 16, 2022
d9d587a
debt minor change
Jun 17, 2022
b818978
ductch calc fixed
Jun 17, 2022
4f950e1
print removed
Jun 17, 2022
682ffe6
Merge pull request #252 from comdex-official/testdev_auction
cgsingh33 Jun 17, 2022
185c14c
restart fixed
Jun 17, 2022
1bbf977
Merge pull request #254 from comdex-official/testdev_auction
cgsingh33 Jun 17, 2022
9354e53
my position error resolved
Jun 20, 2022
6f568ea
Merge pull request #257 from comdex-official/testdev_auction
cgsingh33 Jun 20, 2022
5ed67df
comments removed
Jun 20, 2022
4ad97b9
Merge pull request #259 from comdex-official/testdev_auction
cgsingh33 Jun 20, 2022
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
2 changes: 2 additions & 0 deletions app/wasm/bindings/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type MsgSetCollectorLookupTable struct {
LockerSavingRate sdk.Dec `json:"locker_saving_rate"`
LotSize uint64 `json:"lot_size"`
BidFactor sdk.Dec `json:"bid_factor"`
DebtLotSize uint64 `json:"debt_lot_size"`
}

type MsgSetAuctionMappingForApp struct {
Expand Down Expand Up @@ -120,4 +121,5 @@ type MsgAddAuctionParams struct {
SurplusId uint64 `json:"surplus_id"`
DebtId uint64 `json:"debt_id"`
DutchId uint64 `json:"dutch_id"`
BidDurationSeconds uint64 `json:"bid_duration_seconds"`
}
4 changes: 2 additions & 2 deletions app/wasm/message_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (m *CustomMessenger) SetCollectorLookupTable(ctx sdk.Context, contractAddr

func MsgSetCollectorLookupTable(collectorKeeper collectorkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress,
a *bindings.MsgSetCollectorLookupTable) error {
err := collectorKeeper.WasmSetCollectorLookupTable(ctx, a.AppMappingId, a.CollectorAssetId, a.SecondaryAssetId, a.SurplusThreshold, a.DebtThreshold, a.LockerSavingRate, a.LotSize, a.BidFactor)
err := collectorKeeper.WasmSetCollectorLookupTable(ctx, a.AppMappingId, a.CollectorAssetId, a.SecondaryAssetId, a.SurplusThreshold, a.DebtThreshold, a.LockerSavingRate, a.LotSize, a.BidFactor, a.DebtLotSize)
if err != nil {
return err
}
Expand Down Expand Up @@ -345,7 +345,7 @@ func (m *CustomMessenger) AddAuctionParams(ctx sdk.Context, contractAddr sdk.Acc

func MsgAddAuctionParams(auctionKeeper auctionkeeper.Keeper, ctx sdk.Context, contractAddr sdk.AccAddress,
a *bindings.MsgAddAuctionParams) error {
err := auctionKeeper.AddAuctionParams(ctx, a.AppMappingId, a.AuctionDurationSeconds, a.Buffer, a.Cusp, a.Step, a.PriceFunctionType, a.SurplusId, a.DebtId, a.DutchId)
err := auctionKeeper.AddAuctionParams(ctx, a.AppMappingId, a.AuctionDurationSeconds, a.Buffer, a.Cusp, a.Step, a.PriceFunctionType, a.SurplusId, a.DebtId, a.DutchId, a.BidDurationSeconds)
if err != nil {
return err
}
Expand Down
58 changes: 38 additions & 20 deletions proto/comdex/auction/v1beta1/auction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ message SurplusAuction {
(gogoproto.moretags) = "yaml:\"auction_id\""
];

cosmos.base.v1beta1.Coin outflow_token = 2 [
cosmos.base.v1beta1.Coin sell_token = 2 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"outflow_token\"",
(gogoproto.moretags) = "yaml:\"sell_token\"",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
cosmos.base.v1beta1.Coin inflow_token = 3 [
cosmos.base.v1beta1.Coin buy_token = 3 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"inflow_token\"",
(gogoproto.moretags) = "yaml:\"buy_token\"",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
uint64 active_bidding_id = 4 [
Expand Down Expand Up @@ -72,6 +72,11 @@ message SurplusAuction {
uint64 asset_out_id = 15 [
(gogoproto.moretags) = "yaml:\"asset_out_id\""
];
google.protobuf.Timestamp bid_end_time = 16 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"bid_end_time\""
];
}

message DebtAuction {
Expand Down Expand Up @@ -136,6 +141,11 @@ message DebtAuction {
uint64 asset_out_id = 16 [
(gogoproto.moretags) = "yaml:\"asset_out_id\""
];
google.protobuf.Timestamp bid_end_time = 17 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"bid_end_time\""
];
}


Expand Down Expand Up @@ -163,68 +173,73 @@ message DutchAuction {
(gogoproto.moretags) = "yaml:\"inflow_token_current_amount\"",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
string outflow_token_initial_price = 6 [
cosmos.base.v1beta1.Coin to_burn_amount = 6 [
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"to_burn_amount\"",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin"
];
string outflow_token_initial_price = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"outflow_token_initial_price\""
];
string outflow_token_current_price = 7 [
string outflow_token_current_price = 8 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"outflow_token_current_price\""
];
string outflow_token_end_price = 8 [
string outflow_token_end_price = 9 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"outflow_token_end_price\""
];
string inflow_token_current_price = 9 [
string inflow_token_current_price = 10 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"inflow_token_current_price\""
];

google.protobuf.Timestamp end_time = 10 [
google.protobuf.Timestamp end_time = 11 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"end_time\""
];
uint64 auction_status = 11 [
uint64 auction_status = 12 [
(gogoproto.moretags) = "yaml:\"auction_status\""
];
google.protobuf.Timestamp start_time = 12 [
google.protobuf.Timestamp start_time = 13 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.moretags) = "yaml:\"start_time\""
];
repeated bidOwnerMapping bidding_ids = 13[
repeated bidOwnerMapping bidding_ids = 14[
(gogoproto.moretags) = "yaml:\"bidding_ids\""
];
uint64 auction_mapping_id = 14 [
uint64 auction_mapping_id = 15 [
(gogoproto.moretags) = "yaml:\"auction_mapping_id\""
];
uint64 app_id = 15 [
uint64 app_id = 16 [
(gogoproto.moretags) = "yaml:\"app_id\""
];
uint64 asset_in_id = 16 [
uint64 asset_in_id = 17 [
(gogoproto.moretags) = "yaml:\"asset_in_id\""
];
uint64 asset_out_id = 17 [
uint64 asset_out_id = 18 [
(gogoproto.moretags) = "yaml:\"asset_out_id\""
];
uint64 locked_vault_id = 18 [
uint64 locked_vault_id = 19 [
(gogoproto.moretags) = "yaml:\"locked_vault_id\""
];
string vault_owner = 19 [
string vault_owner = 20 [
(gogoproto.moretags) = "yaml:\"vault_owner\"",
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
];
string liquidation_penalty = 20 [
string liquidation_penalty = 21 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"liquidatin_penalty\""
];
bool is_locked_vault_amount_in_zero = 21 [
bool is_locked_vault_amount_in_zero = 22 [
(gogoproto.moretags) = "yaml:\"is_locked_vault_amount_in_zero\""
];
}
Expand Down Expand Up @@ -282,4 +297,7 @@ message AuctionParams{
uint64 dutch_id = 9 [
(gogoproto.moretags) = "yaml:\"dutch_id\""
];
uint64 bid_duration_seconds = 10 [
(gogoproto.moretags) = "yaml:\"bid_duration_seconds\""
];
}
2 changes: 2 additions & 0 deletions proto/comdex/collector/v1beta1/collector.proto
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ message CollectorLookupTable {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.moretags) = "yaml:\"bid_factor\""
];
uint64 debt_lot_size = 9 [
(gogoproto.moretags) = "yaml:\"debt_lot_size\""];
}

message CollectorLookup {
Expand Down
12 changes: 12 additions & 0 deletions proto/comdex/vault/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,24 @@ message QueryUserMyPositionByAppResponse {
];
}

message QueryUserExtendedPairTotalDataRequest {
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
}

message QueryUserExtendedPairTotalDataResponse {
UserVaultAssetMapping userTotalData = 1 [ (gogoproto.moretags) = "yaml:\"userTotalData\"" ];
dheerajkd30 marked this conversation as resolved.
Show resolved Hide resolved
}


service Query {
rpc QueryVault(QueryVaultRequest) returns (QueryVaultResponse) {
option (google.api.http).get = "/comdex/vault/v1beta1/vaults/{id}";
};

rpc QueryUserExtendedPairTotalData(QueryUserExtendedPairTotalDataRequest) returns (QueryUserExtendedPairTotalDataResponse) {
option (google.api.http).get = "/comdex/vault/v1beta1/user-extended-total-data/{owner}";
};

rpc QueryVaultInfo(QueryVaultInfoRequest) returns (QueryVaultInfoResponse) {
option (google.api.http).get = "/comdex/vault/v1beta1/vaultsInfo/{id}";
};
Expand Down
17 changes: 15 additions & 2 deletions x/auction/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@ import (

func BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock, k keeper.Keeper) {
//k.CreateNewAuctions(ctx)
err := k.CloseAndRestartAuctions(ctx)
if err != nil {
// err := k.CloseAndRestartAuctions(ctx)
// if err != nil {
// return
// }

err1 := k.SurplusActivator(ctx)
if err1 != nil {
return
}
err2 := k.DebtActivator(ctx)
if err2 != nil {
return
}
err3 := k.DutchActivator(ctx)
if err3 != nil {
return
}
}
3 changes: 2 additions & 1 deletion x/auction/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func txPlaceDebtBid() *cobra.Command {

func txPlaceDutchBid() *cobra.Command {
cmd := &cobra.Command{
Use: "bid-dutch [auction-id] [amount] [maxamountpercollateraltoken] [app-id] [auction-mapping-id]",
Use: "bid-dutch [auction-id] [amount] [maxamountpercollateraltoken] [app-id] [auction-mapping-id]",
Short: "Place a Dutch bid on an auction",
Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -131,6 +131,7 @@ func txPlaceDutchBid() *cobra.Command {
return fmt.Errorf("auction-id '%s' not a valid uint", args[0])
}


auctionMappingId, err := strconv.ParseUint(args[4], 10, 64)
if err != nil {
return fmt.Errorf("auction-id '%s' not a valid uint", args[0])
Expand Down
4 changes: 4 additions & 0 deletions x/auction/expected/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type LiquidationKeeper interface {
GetLockedVaults(ctx sdk.Context) (locked_vaults []liquidationtypes.LockedVault)
GetLockedVault(ctx sdk.Context, id uint64) (locked_vault liquidationtypes.LockedVault, found bool)
SetLockedVault(ctx sdk.Context, locked_vault liquidationtypes.LockedVault)
DeleteLockedVault(ctx sdk.Context, id uint64)
CreateLockedVaultHistory(ctx sdk.Context, lockedVault liquidationtypes.LockedVault) error
//UpdateAssetQuantitiesInLockedVault(ctx sdk.Context, collateral_auction auctiontypes.CollateralAuction, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) error
}

Expand All @@ -57,6 +59,7 @@ type VaultKeeper interface {
SetAppExtendedPairVaultMapping(ctx sdk.Context, appExtendedPairVaultData vaultttypes.AppExtendedPairVaultMapping) error
UpdateTokenMintedAmountLockerMapping(ctx sdk.Context, valutLookupData vaultttypes.AppExtendedPairVaultMapping, extendedPairId uint64, amount sdk.Int, changeType bool)
UpdateCollateralLockedAmountLockerMapping(ctx sdk.Context, valutLookupData vaultttypes.AppExtendedPairVaultMapping, extendedPairId uint64, amount sdk.Int, changeType bool)
UpdateUserVaultExtendedPairMapping(ctx sdk.Context, extendedPairId uint64, userAddress string, appMappingId uint64)
}

type CollectorKeeper interface {
Expand All @@ -71,6 +74,7 @@ type CollectorKeeper interface {
GetAmountFromCollector(ctx sdk.Context, appId, asset_id uint64, amount sdk.Int) (sdk.Int, error)
SetNetFeeCollectedData(ctx sdk.Context, app_id, asset_id uint64, fee sdk.Int) error
SetAuctionMappingForApp(ctx sdk.Context, records ...types.CollectorAuctionLookupTable) error
GetAllAuctionMappingForApp(ctx sdk.Context) (collectorAuctionLookupTable []types.CollectorAuctionLookupTable, found bool)
}

type TokenMintKeeper interface {
Expand Down
15 changes: 15 additions & 0 deletions x/auction/keeper/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,19 @@ func (k *Keeper) UpdateTokenMintedAmountLockerMapping(ctx sdk.Context, valutLook
}
func (k *Keeper) UpdateCollateralLockedAmountLockerMapping(ctx sdk.Context, valutLookupData vaultttypes.AppExtendedPairVaultMapping, extendedPairId uint64, amount sdk.Int, changeType bool) {
k.vault.UpdateCollateralLockedAmountLockerMapping(ctx, valutLookupData, extendedPairId, amount, changeType)
}

func (k *Keeper) GetAllAuctionMappingForApp(ctx sdk.Context) (collectorAuctionLookupTable []types.CollectorAuctionLookupTable, found bool) {
return k.collector.GetAllAuctionMappingForApp(ctx)
}
func (k *Keeper) DeleteLockedVault(ctx sdk.Context, id uint64){
k.liquidation.DeleteLockedVault(ctx, id)
}

func (k *Keeper) UpdateUserVaultExtendedPairMapping(ctx sdk.Context, extendedPairId uint64, userAddress string, appMappingId uint64) {
k.vault.UpdateUserVaultExtendedPairMapping(ctx, extendedPairId, userAddress, appMappingId)
}

func (k Keeper) CreateLockedVaultHistory(ctx sdk.Context, lockedVault liquidationtypes.LockedVault) error{
return k.liquidation.CreateLockedVaultHistory(ctx, lockedVault)
}
Loading