-
Notifications
You must be signed in to change notification settings - Fork 1
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
Vault/allow multiple currency #76
Changes from 14 commits
0118e0e
06c7be0
7f62acd
4536c35
7ce2dc8
d981cba
9b77243
245e106
b3b0f50
c8713de
1ee268b
4ce4b30
bd16083
13f43de
7df5199
8391e3d
1e740ff
b8a84b4
32d9fdb
eba4c8f
abd2daa
17404ce
fb8ec9e
175dcf7
2c6e0f9
474bc3c
97faecd
63b0f5c
3c0516d
799bfa1
d82580e
117aaf0
da16681
fc5d3e4
b690dd9
765d1a9
16835b5
d19c303
10140e7
cc1924a
7156e46
41e3d7f
efff475
b49d729
b048910
4f09b4e
04cd748
1eb130a
ed66585
86bd072
d89cee4
02856bd
038f33b
8029fcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ message Params { | |
(gogoproto.nullable) = false | ||
]; | ||
|
||
string mint_denom = 2; | ||
repeated string allowed_mint_denom = 2; | ||
|
||
google.protobuf.Duration charging_period = 3 [ | ||
(gogoproto.stdduration) = true, | ||
|
@@ -33,42 +33,44 @@ message Params { | |
|
||
// VaultParams defines the parameters for each collateral vault type. | ||
message VaultMamagerParams { | ||
string min_collateral_ratio = 1 [ | ||
string mint_denom = 1; | ||
|
||
string min_collateral_ratio = 2 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.nullable) = false | ||
]; | ||
|
||
string liquidation_ratio = 2 [ | ||
string liquidation_ratio = 3 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.nullable) = false | ||
]; | ||
|
||
string max_debt = 3 [ | ||
string max_debt = 4 [ | ||
(cosmos_proto.scalar) = "cosmos.Int", | ||
(gogoproto.customtype) = "cosmossdk.io/math.Int", | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.nullable) = false | ||
]; | ||
|
||
string stability_fee = 4 [ | ||
string stability_fee = 5 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.nullable) = false | ||
]; | ||
|
||
string liquidation_penalty = 5 [ | ||
string liquidation_penalty = 6 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(amino.dont_omitempty) = true, | ||
(gogoproto.nullable) = false | ||
]; | ||
|
||
string minting_fee = 6 [ | ||
string minting_fee = 7 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(amino.dont_omitempty) = true, | ||
|
@@ -142,7 +144,9 @@ message VaultLiquidationStatus { | |
} | ||
|
||
message Liquidation { | ||
string denom = 1; | ||
string debt_denom = 1; | ||
|
||
string mint_denom = 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should rename. Lets say debt and mint denom is same |
||
|
||
repeated Vault liquidating_vaults = 3; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ import ( | |
"cosmossdk.io/math" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/onomyprotocol/reserve/x/auction/types" | ||
vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" | ||
) | ||
|
||
// return aution, is create, error | ||
|
@@ -17,8 +16,12 @@ func (k Keeper) GetNewAuction(ctx context.Context, | |
item, targetGoal sdk.Coin, | ||
vaultId uint64, | ||
) (*types.Auction, bool, error) { | ||
vault, err := k.vaultKeeper.GetVault(ctx, vaultId) | ||
if err != nil { | ||
return nil, true, err | ||
} | ||
var newAuction *types.Auction | ||
err := k.Auctions.Walk(ctx, nil, func(key uint64, value types.Auction) (stop bool, err error) { | ||
err = k.Auctions.Walk(ctx, nil, func(key uint64, value types.Auction) (stop bool, err error) { | ||
if value.VaultId == vaultId { | ||
newAuction = &value | ||
return true, nil | ||
|
@@ -31,7 +34,8 @@ func (k Keeper) GetNewAuction(ctx context.Context, | |
if newAuction != nil { | ||
return newAuction, false, nil | ||
} | ||
newAuction, err = k.NewAuction(ctx, startTime, initialPrice, item, targetGoal, vaultId) | ||
newAuction, err = k.NewAuction(ctx, startTime, initialPrice, item, targetGoal, vaultId, vault.Debt.Denom) | ||
|
||
if err != nil { | ||
return newAuction, true, err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if err != nil so the auction should not be created. Let check the bool return |
||
} | ||
|
@@ -43,6 +47,7 @@ func (k Keeper) NewAuction(ctx context.Context, | |
initialPrice math.LegacyDec, | ||
item, targetGoal sdk.Coin, | ||
vaultId uint64, | ||
mintDenom string, | ||
) (*types.Auction, error) { | ||
auctionId, err := k.AuctionIdSeq.Next(ctx) | ||
if err != nil { | ||
|
@@ -58,7 +63,7 @@ func (k Keeper) NewAuction(ctx context.Context, | |
LastDiscountTime: startTime, | ||
Status: types.AuctionStatus_AUCTION_STATUS_ACTIVE, | ||
TargetGoal: targetGoal, | ||
TokenRaised: sdk.NewCoin(vaultstypes.DefaultMintDenom, math.ZeroInt()), | ||
TokenRaised: sdk.NewCoin(mintDenom, math.ZeroInt()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
VaultId: vaultId, | ||
}, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be collateral_denom I think