Skip to content

Commit e7b7d37

Browse files
author
Maxim
committed
Updated chain module exchange types
1 parent f167199 commit e7b7d37

27 files changed

+13616
-21006
lines changed

chain/client/contract_discover.go

Lines changed: 0 additions & 75 deletions
This file was deleted.

chain/exchange/types/codec.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/cosmos/cosmos-sdk/codec"
55
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
66
sdk "github.com/cosmos/cosmos-sdk/types"
7+
"github.com/cosmos/cosmos-sdk/types/msgservice"
78
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
89
)
910

@@ -16,26 +17,33 @@ var (
1617
ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
1718
)
1819

19-
// RegisterCodec registers concrete types on the Amino codec
20+
// RegisterInterfaces registers concrete types on the Amino codec
2021
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
2122
registry.RegisterImplementations(
2223
(*sdk.Msg)(nil),
23-
&MsgInitExchange{},
24-
&MsgRegisterDerivativeMarket{},
25-
&MsgSuspendDerivativeMarket{},
26-
&MsgResumeDerivativeMarket{},
27-
&MsgCreateDerivativeOrder{},
28-
&MsgSoftCancelDerivativeOrder{},
29-
&MsgRegisterSpotMarket{},
30-
&MsgSuspendSpotMarket{},
31-
&MsgResumeSpotMarket{},
32-
&MsgCreateSpotOrder{},
33-
&MsgExecuteDerivativeTakeOrder{},
34-
&MsgExecuteTECTransaction{},
24+
&MsgDeposit{},
25+
&MsgWithdraw{},
26+
&MsgInstantSpotMarketLaunch{},
27+
&MsgCreateSpotLimitOrder{},
28+
&MsgCreateSpotMarketOrder{},
29+
&MsgCancelSpotOrder{},
30+
&MsgCreateDerivativeLimitOrder{},
31+
&MsgCreateDerivativeMarketOrder{},
32+
&MsgCancelDerivativeOrder{},
33+
&MsgSubaccountTransfer{},
34+
&MsgExternalTransfer{},
3535
)
3636

3737
registry.RegisterImplementations(
3838
(*govtypes.Content)(nil),
39-
&RegisterExchangeProposal{},
39+
&SpotMarketParamUpdateProposal{},
40+
&SpotMarketLaunchProposal{},
41+
&SpotMarketStatusSetProposal{},
42+
&PerpetualMarketLaunchProposal{},
43+
&ExpiryFuturesMarketLaunchProposal{},
44+
&DerivativeMarketParamUpdateProposal{},
45+
&DerivativeMarketStatusSetProposal{},
4046
)
47+
48+
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
4149
}

chain/exchange/types/coin.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package types
2+
3+
import (
4+
sdk "github.com/cosmos/cosmos-sdk/types"
5+
)
6+
7+
const (
8+
// INJ defines the default coin denomination used in Ethermint in:
9+
//
10+
// - Staking parameters: denomination used as stake in the dPoS chain
11+
// - Mint parameters: denomination minted due to fee distribution rewards
12+
// - Governance parameters: denomination used for spam prevention in proposal deposits
13+
// - Crisis parameters: constant fee denomination used for spam prevention to check broken invariant
14+
// - EVM parameters: denomination used for running EVM state transitions in Ethermint.
15+
InjectiveCoin string = "inj"
16+
17+
// BaseDenomUnit defines the base denomination unit for Photons.
18+
// 1 photon = 1x10^{BaseDenomUnit} inj
19+
BaseDenomUnit = 18
20+
)
21+
22+
// NewInjectiveCoin is a utility function that returns an "inj" coin with the given sdk.Int amount.
23+
// The function will panic if the provided amount is negative.
24+
func NewInjectiveCoin(amount sdk.Int) sdk.Coin {
25+
return sdk.NewCoin(InjectiveCoin, amount)
26+
}
27+
28+
// NewInjectiveDecCoin is a utility function that returns an "inj" decimal coin with the given sdk.Int amount.
29+
// The function will panic if the provided amount is negative.
30+
func NewInjectiveDecCoin(amount sdk.Int) sdk.DecCoin {
31+
return sdk.NewDecCoin(InjectiveCoin, amount)
32+
}
33+
34+
// NewInjectiveCoinInt64 is a utility function that returns an "inj" coin with the given int64 amount.
35+
// The function will panic if the provided amount is negative.
36+
func NewInjectiveCoinInt64(amount int64) sdk.Coin {
37+
return sdk.NewInt64Coin(InjectiveCoin, amount)
38+
}

chain/exchange/types/errors.go

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
var (
88
ErrOrderInvalid = sdkerrors.Register(ModuleName, 1, "failed to validate order")
99
ErrOrderNotFound = sdkerrors.Register(ModuleName, 2, "no active order found for the hash")
10-
ErrPairSuspended = sdkerrors.Register(ModuleName, 3, "trade pair suspended")
11-
ErrPairNotFound = sdkerrors.Register(ModuleName, 4, "trade pair not found")
12-
ErrSpotMarketExists = sdkerrors.Register(ModuleName, 5, "trade pair exists")
13-
ErrPairMismatch = sdkerrors.Register(ModuleName, 6, "trade pair mismatch")
10+
ErrSpotMarketSuspended = sdkerrors.Register(ModuleName, 3, "spot market suspended")
11+
ErrSpotMarketNotFound = sdkerrors.Register(ModuleName, 4, "spot market not found")
12+
ErrSpotMarketExists = sdkerrors.Register(ModuleName, 5, "spot market exists")
13+
ErrSpotMarketMismatch = sdkerrors.Register(ModuleName, 6, "spot market mismatch")
1414
ErrBadField = sdkerrors.Register(ModuleName, 7, "struct field error")
1515
ErrMarketNotFound = sdkerrors.Register(ModuleName, 8, "derivative market not found")
1616
ErrMarketInvalid = sdkerrors.Register(ModuleName, 9, "failed to validate derivative market")
@@ -21,7 +21,7 @@ var (
2121
ErrOverLeveragedOrder = sdkerrors.Register(ModuleName, 14, "cannot add overlevered order")
2222
ErrSubaccountNotFound = sdkerrors.Register(ModuleName, 15, "subaccount not found")
2323
ErrOrderAlreadyExists = sdkerrors.Register(ModuleName, 16, "order already exists")
24-
ErrInsufficientMargin = sdkerrors.Register(ModuleName, 17, "subaccount has insufficient margin")
24+
ErrInsufficientDeposit = sdkerrors.Register(ModuleName, 17, "subaccount has insufficient margin")
2525
ErrMarketExpired = sdkerrors.Register(ModuleName, 18, "market has already expired")
2626
ErrOrderExpired = sdkerrors.Register(ModuleName, 19, "order has already expired")
2727
ErrInsufficientOrderQuantity = sdkerrors.Register(ModuleName, 20, "order quantity invalid")
@@ -34,6 +34,21 @@ var (
3434
ErrReplayTecTransaction = sdkerrors.Register(ModuleName, 27, "cannot replay TEC transaction")
3535
ErrOrderAlreadyArchived = sdkerrors.Register(ModuleName, 28, "order already in archive store")
3636
ErrAddressNotContract = sdkerrors.Register(ModuleName, 29, "address is not a smart contract")
37-
ErrExchangeAlreadySet = sdkerrors.Register(ModuleName, 30, "Exchange address already set")
38-
ErrBadExchangeAddress = sdkerrors.Register(ModuleName, 31, "Bad exchange address")
37+
ErrOrderIDInvalid = sdkerrors.Register(ModuleName, 30, "order id is not valid")
38+
ErrBadSubaccountID = sdkerrors.Register(ModuleName, 31, "subaccount id is not valid")
39+
ErrInvalidTicker = sdkerrors.Register(ModuleName, 32, "invalid ticker")
40+
ErrInvalidBaseDenom = sdkerrors.Register(ModuleName, 33, "invalid base denom")
41+
ErrInvalidQuoteDenom = sdkerrors.Register(ModuleName, 34, "invalid quote denom")
42+
ErrOrderDoesntExist = sdkerrors.Register(ModuleName, 35, "order doesnt exist")
43+
44+
ErrDepositDoesntExist = sdkerrors.Register(ModuleName, 37, "deposit doesnt exist")
45+
ErrOrderbookDoesntExist = sdkerrors.Register(ModuleName, 38, "spot limit orderbook doesnt exist")
46+
ErrOrderbookFillInvalid = sdkerrors.Register(ModuleName, 39, "spot limit orderbook fill invalid")
47+
ErrPerpetualMarketExists = sdkerrors.Register(ModuleName, 40, "perpetual market exists")
48+
ErrExpiryFuturesMarketExists = sdkerrors.Register(ModuleName, 41, "expiry futures market exists")
49+
ErrExpiryFuturesMarketExpired = sdkerrors.Register(ModuleName, 42, "expiry futures market expired")
50+
ErrNoLiquidity = sdkerrors.Register(ModuleName, 43, "no liquidity on the orderbook!")
51+
ErrSlippageExceedsWorstPrice = sdkerrors.Register(ModuleName, 44, "Orderbook liquidity cannot satisfy current worst price")
52+
ErrInsufficientOrderMargin = sdkerrors.Register(ModuleName, 45, "Order has insufficient margin")
53+
ErrDerivativeMarketNotFound = sdkerrors.Register(ModuleName, 46, "Derivative market not found")
3954
)

chain/exchange/types/events.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const (
1717
AttributeKeyTradePairHash = "trade_pair_hash"
1818
AttributeKeySignedOrder = "signed_order"
1919
AttributeKeyFilledAmount = "filled_amount"
20-
AttributeKeyUnfilledAmount = "unfilled_amount"
20+
AttributeKeyFillableAmount = "fillable_amount"
2121
AttributeKeyWasActiveOrder = "was_active_order"
2222
AttributeKeyPrice = "price"
2323
AttributeKeyTicker = "ticker"

0 commit comments

Comments
 (0)