mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
Correct json field tags in pricefeed, auction (#301)
* fix: genesis param json tags * chore: linting * fix: missing tags in collateral * fix: genesis auctions tag
This commit is contained in:
commit
a9c92439c6
@ -8,10 +8,10 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
)
|
||||
|
||||
// distantFuture is a very large time value to use as initial the ending time for auctions.
|
||||
// DistantFuture is a very large time value to use as initial the ending time for auctions.
|
||||
// It is not set to the max time supported. This can cause problems with time comparisons, see https://stackoverflow.com/a/32620397.
|
||||
// Also amino panics when encoding times ≥ the start of year 10000.
|
||||
var DistantFuture time.Time = time.Date(9000, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
var DistantFuture = time.Date(9000, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
// Auction is an interface for handling common actions on auctions.
|
||||
type Auction interface {
|
||||
@ -57,6 +57,7 @@ func (a BaseAuction) GetBid() sdk.Coin { return a.Bid }
|
||||
// GetEndTime is a getter for auction end time.
|
||||
func (a BaseAuction) GetEndTime() time.Time { return a.EndTime }
|
||||
|
||||
// Validate verifies that the auction end time is before max end time
|
||||
func (a BaseAuction) Validate() error {
|
||||
if a.EndTime.After(a.MaxEndTime) {
|
||||
return fmt.Errorf("MaxEndTime < EndTime (%s < %s)", a.MaxEndTime, a.EndTime)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package types
|
||||
|
||||
// Events for auction module
|
||||
const (
|
||||
EventTypeAuctionStart = "auction_start"
|
||||
EventTypeAuctionBid = "auction_bid"
|
||||
|
@ -20,8 +20,8 @@ type GenesisAuctions []GenesisAuction
|
||||
// GenesisState is auction state that must be provided at chain genesis.
|
||||
type GenesisState struct {
|
||||
NextAuctionID uint64 `json:"next_auction_id" yaml:"next_auction_id"`
|
||||
Params Params `json:"auction_params" yaml:"auction_params"`
|
||||
Auctions GenesisAuctions `json:"genesis_auctions" yaml:"genesis_auctions"`
|
||||
Params Params `json:"params" yaml:"params"`
|
||||
Auctions GenesisAuctions `json:"auctions" yaml:"auctions"`
|
||||
}
|
||||
|
||||
// NewGenesisState returns a new genesis state object for auctions module.
|
||||
@ -50,7 +50,7 @@ func (gs GenesisState) IsEmpty() bool {
|
||||
return gs.Equal(GenesisState{})
|
||||
}
|
||||
|
||||
// ValidateGenesis validates genesis inputs. It returns error if validation of any input fails.
|
||||
// Validate validates genesis inputs. It returns error if validation of any input fails.
|
||||
func (gs GenesisState) Validate() error {
|
||||
if err := gs.Params.Validate(); err != nil {
|
||||
return err
|
||||
|
@ -20,9 +20,11 @@ const (
|
||||
// DefaultParamspace default name for parameter store
|
||||
DefaultParamspace = ModuleName
|
||||
|
||||
// QuerierRoute route used for abci queries
|
||||
QuerierRoute = ModuleName
|
||||
)
|
||||
|
||||
// Key prefixes
|
||||
var (
|
||||
AuctionKeyPrefix = []byte{0x00} // prefix for keys that store auctions
|
||||
AuctionByTimeKeyPrefix = []byte{0x01} // prefix for keys that are part of the auctionsByTime index
|
||||
@ -30,10 +32,12 @@ var (
|
||||
NextAuctionIDKey = []byte{0x02} // key for the next auction id
|
||||
)
|
||||
|
||||
// GetAuctionKey returns the bytes of an auction key
|
||||
func GetAuctionKey(auctionID uint64) []byte {
|
||||
return Uint64ToBytes(auctionID)
|
||||
}
|
||||
|
||||
// GetAuctionByTimeKey returns the key for iterating auctions by time
|
||||
func GetAuctionByTimeKey(endTime time.Time, auctionID uint64) []byte {
|
||||
return append(sdk.FormatTimeBytes(endTime), Uint64ToBytes(auctionID)...)
|
||||
}
|
||||
|
@ -54,11 +54,10 @@ func ParamKeyTable() subspace.KeyTable {
|
||||
}
|
||||
|
||||
// ParamSetPairs implements the ParamSet interface and returns all the key/value pairs.
|
||||
// nolint
|
||||
func (p *Params) ParamSetPairs() subspace.ParamSetPairs {
|
||||
return subspace.ParamSetPairs{
|
||||
{KeyAuctionBidDuration, &p.BidDuration},
|
||||
{KeyAuctionDuration, &p.MaxAuctionDuration},
|
||||
{Key: KeyAuctionBidDuration, Value: &p.BidDuration},
|
||||
{Key: KeyAuctionDuration, Value: &p.MaxAuctionDuration},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ func (n QueryResAuctions) String() string {
|
||||
|
||||
// QueryAllAuctionParams is the params for an auctions query
|
||||
type QueryAllAuctionParams struct {
|
||||
Page int `json"page:" yaml:"page"`
|
||||
Limit int `json"limit:" yaml:"limit"`
|
||||
Page int `json:"page" yaml:"page"`
|
||||
Limit int `json:"limit" yaml:"limit"`
|
||||
}
|
||||
|
||||
// NewQueryAllAuctionParams creates a new QueryAllAuctionParams
|
||||
|
@ -73,12 +73,12 @@ func DefaultParams() Params {
|
||||
|
||||
// CollateralParam governance parameters for each collateral type within the cdp module
|
||||
type CollateralParam struct {
|
||||
Denom string `json:"denom" yaml:"denom"` // Coin name of collateral type
|
||||
LiquidationRatio sdk.Dec `json:"liquidation_ratio" yaml:"liquidation_ratio"` // The ratio (Collateral (priced in stable coin) / Debt) under which a CDP will be liquidated
|
||||
DebtLimit sdk.Coins `json:"debt_limit" yaml:"debt_limit"` // Maximum amount of debt allowed to be drawn from this collateral type
|
||||
StabilityFee sdk.Dec `json:"stability_fee" yaml:"stability_fee"` // per second stability fee for loans opened using this collateral
|
||||
AuctionSize sdk.Int // Max amount of collateral to sell off in any one auction.
|
||||
LiquidationPenalty sdk.Dec // percentage penalty (between [0, 1]) applied to a cdp if it is liquidated
|
||||
Denom string `json:"denom" yaml:"denom"` // Coin name of collateral type
|
||||
LiquidationRatio sdk.Dec `json:"liquidation_ratio" yaml:"liquidation_ratio"` // The ratio (Collateral (priced in stable coin) / Debt) under which a CDP will be liquidated
|
||||
DebtLimit sdk.Coins `json:"debt_limit" yaml:"debt_limit"` // Maximum amount of debt allowed to be drawn from this collateral type
|
||||
StabilityFee sdk.Dec `json:"stability_fee" yaml:"stability_fee"` // per second stability fee for loans opened using this collateral
|
||||
AuctionSize sdk.Int `json:"auction_size" yaml:"auction_size"` // Max amount of collateral to sell off in any one auction.
|
||||
LiquidationPenalty sdk.Dec `json:"liquidation_penalty" yaml:"liquidation_penalty"` // percentage penalty (between [0, 1]) applied to a cdp if it is liquidated
|
||||
Prefix byte `json:"prefix" yaml:"prefix"`
|
||||
MarketID string `json:"market_id" yaml:"market_id"` // marketID for fetching price of the asset from the pricefeed
|
||||
ConversionFactor sdk.Int `json:"conversion_factor" yaml:"conversion_factor"` // factor for converting internal units to one base unit of collateral
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
// GenesisState - pricefeed state that must be provided at genesis
|
||||
type GenesisState struct {
|
||||
Params Params `json:"asset_params" yaml:"asset_params"`
|
||||
Params Params `json:"params" yaml:"params"`
|
||||
PostedPrices []PostedPrice `json:"posted_prices" yaml:"posted_prices"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user