Skip to content

Commit

Permalink
re-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
albertchon committed Jun 25, 2022
1 parent 4c9cb0b commit 55778b8
Show file tree
Hide file tree
Showing 7 changed files with 810 additions and 256 deletions.
2 changes: 2 additions & 0 deletions chain/exchange/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&ExpiryFuturesMarketLaunchProposal{}, "exchange/ExpiryFuturesMarketLaunchProposal", nil)
cdc.RegisterConcrete(&DerivativeMarketParamUpdateProposal{}, "exchange/DerivativeMarketParamUpdateProposal", nil)
cdc.RegisterConcrete(&MarketForcedSettlementProposal{}, "exchange/MarketForcedSettlementProposal", nil)
cdc.RegisterConcrete(&UpdateDenomDecimalsProposal{}, "exchange/UpdateDenomDecimalsProposal", nil)
cdc.RegisterConcrete(&TradingRewardCampaignLaunchProposal{}, "exchange/TradingRewardCampaignLaunchProposal", nil)
cdc.RegisterConcrete(&TradingRewardCampaignUpdateProposal{}, "exchange/TradingRewardCampaignUpdateProposal", nil)
cdc.RegisterConcrete(&TradingRewardPendingPointsUpdateProposal{}, "exchange/TradingRewardPendingPointsUpdateProposal", nil)
Expand Down Expand Up @@ -113,6 +114,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
&ExpiryFuturesMarketLaunchProposal{},
&DerivativeMarketParamUpdateProposal{},
&MarketForcedSettlementProposal{},
&UpdateDenomDecimalsProposal{},
&TradingRewardCampaignLaunchProposal{},
&TradingRewardCampaignUpdateProposal{},
&TradingRewardPendingPointsUpdateProposal{},
Expand Down
1 change: 1 addition & 0 deletions chain/exchange/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ var (
ErrSenderIsNotAnAdmin = sdkerrors.Register(ModuleName, 74, "sender should be a market admin")
ErrMarketAlreadyScheduledToSettle = sdkerrors.Register(ModuleName, 75, "market is already scheduled to settle")
ErrGenericMarketNotFound = sdkerrors.Register(ModuleName, 76, "market not found")
ErrInvalidDenomDecimal = sdkerrors.Register(ModuleName, 77, "denom decimal cannot be below 1 or above max scale factor")
)
5 changes: 5 additions & 0 deletions chain/exchange/types/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (
SpotExchangeEnabledKey = []byte{0x07} // key for whether spot exchange is enabled
DerivativeExchangeEnabledKey = []byte{0x08} // key for whether derivative exchange is enabled
MarketHistoricalTradeRecordsPrefix = []byte{0x09} // prefix for each key to a market's historical trade records
DenomDecimalsPrefix = []byte{0x10} // prefix for denom decimals

SpotMarketsPrefix = []byte{0x11} // prefix for each key to a spot market by (isEnabled, marketID)
SpotLimitOrdersPrefix = []byte{0x12} // prefix for each key to a spot order, by (marketID, direction, price level, order hash)
Expand Down Expand Up @@ -413,3 +414,7 @@ func GetBinaryOptionsMarketSettlementTimestampKey(timestamp int64, marketID comm
func GetMarketHistoricalTradeRecordsKey(marketID common.Hash) []byte {
return append(MarketHistoricalTradeRecordsPrefix, marketID.Bytes()...)
}

func GetDenomDecimalsKey(denom string) []byte {
return append(DenomDecimalsPrefix, []byte(denom)...)
}
6 changes: 5 additions & 1 deletion chain/exchange/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func (msg MsgInstantBinaryOptionsMarketLaunch) ValidateBasic() error {
if err := ValidateFee(msg.TakerFeeRate); err != nil {
return err
}
if msg.ExpirationTimestamp > msg.SettlementTimestamp || msg.ExpirationTimestamp < 0 || msg.SettlementTimestamp < 0 {
if msg.ExpirationTimestamp >= msg.SettlementTimestamp || msg.ExpirationTimestamp < 0 || msg.SettlementTimestamp < 0 {
return ErrInvalidExpiry
}
if msg.Admin != "" {
Expand Down Expand Up @@ -1047,6 +1047,10 @@ func (msg *MsgCancelBinaryOptionsOrder) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{sender}
}

func (msg *MsgBatchCancelBinaryOptionsOrders) Route() string {
return RouterKey
}

// Type implements the sdk.Msg interface. It should return the action.
func (msg *MsgBatchCancelBinaryOptionsOrders) Type() string {
return "batchCancelBinaryOptionsOrders"
Expand Down
57 changes: 57 additions & 0 deletions chain/exchange/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
ProposalTypeExpiryFuturesMarketLaunch string = "ProposalTypeExpiryFuturesMarketLaunch"
ProposalTypeDerivativeMarketParamUpdate string = "ProposalTypeDerivativeMarketParamUpdate"
ProposalTypeMarketForcedSettlement string = "ProposalTypeMarketForcedSettlement"
ProposalUpdateDenomDecimals string = "ProposalUpdateDenomDecimals"
ProposalTypeTradingRewardCampaign string = "ProposalTypeTradingRewardCampaign"
ProposalTypeTradingRewardCampaignUpdate string = "ProposalTypeTradingRewardCampaignUpdateProposal"
ProposalTypeTradingRewardPointsUpdate string = "ProposalTypeTradingRewardPointsUpdateProposal"
Expand All @@ -47,6 +48,8 @@ func init() {
gov.RegisterProposalTypeCodec(&DerivativeMarketParamUpdateProposal{}, "injective/DerivativeMarketParamUpdateProposal")
gov.RegisterProposalType(ProposalTypeMarketForcedSettlement)
gov.RegisterProposalTypeCodec(&MarketForcedSettlementProposal{}, "injective/MarketForcedSettlementProposal")
gov.RegisterProposalType(ProposalUpdateDenomDecimals)
gov.RegisterProposalTypeCodec(&UpdateDenomDecimalsProposal{}, "injective/UpdateDenomDecimalsProposal")
gov.RegisterProposalType(ProposalTypeTradingRewardCampaign)
gov.RegisterProposalTypeCodec(&TradingRewardCampaignLaunchProposal{}, "injective/TradingRewardCampaignLaunchProposal")
gov.RegisterProposalType(ProposalTypeTradingRewardCampaignUpdate)
Expand Down Expand Up @@ -547,6 +550,60 @@ func (p *MarketForcedSettlementProposal) ValidateBasic() error {
return gov.ValidateAbstract(p)
}

// NewUpdateDenomDecimalsProposal returns new instance of UpdateDenomDecimalsProposal
func NewUpdateDenomDecimalsProposal(
title, description string,
denomDecimals []*DenomDecimals,
) *UpdateDenomDecimalsProposal {
return &UpdateDenomDecimalsProposal{
Title: title,
Description: description,
DenomDecimals: denomDecimals,
}
}

// Implements Proposal Interface
var _ gov.Content = &UpdateDenomDecimalsProposal{}

// GetTitle returns the title of this proposal
func (p *UpdateDenomDecimalsProposal) GetTitle() string {
return p.Title
}

// GetDescription returns the description of this proposal
func (p *UpdateDenomDecimalsProposal) GetDescription() string {
return p.Description
}

// ProposalRoute returns router key of this proposal.
func (p *UpdateDenomDecimalsProposal) ProposalRoute() string { return RouterKey }

// ProposalType returns proposal type of this proposal.
func (p *UpdateDenomDecimalsProposal) ProposalType() string {
return ProposalUpdateDenomDecimals
}

// ValidateBasic returns ValidateBasic result of this proposal.
func (p *UpdateDenomDecimalsProposal) ValidateBasic() error {
for _, d := range p.DenomDecimals {
if err := d.Validate(); err != nil {
return err
}
}
return gov.ValidateAbstract(p)
}

func (d *DenomDecimals) Validate() error {
if d.Denom == "" {
return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, d.Denom)
}

if d.Decimals <= 0 || d.Decimals > uint64(MaxOracleScaleFactor) {
return sdkerrors.Wrapf(ErrInvalidDenomDecimal, "invalid decimals passed: %d", d.Decimals)
}
return nil
}

func NewOracleParams(
oracleBase string,
oracleQuote string,
Expand Down
Loading

0 comments on commit 55778b8

Please sign in to comment.