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

Feat/add exchange v2 support #263

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
"style",
],
"disabled-checks": [
"dupImport",
"hugeParam",
"singleCaseSwitch",
"unnamedResult",
]
}
},
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ copy-chain-types:
rm -rf chain/auction/types/*test.go rm -rf chain/auction/types/*gw.go
cp ../injective-core/injective-chain/modules/exchange/types/*.go chain/exchange/types
rm -rf chain/exchange/types/*test.go rm -rf chain/exchange/types/*gw.go
cp ../injective-core/injective-chain/modules/exchange/types/v2/*.go chain/exchange/types/v2
rm -rf chain/exchange/types/v2/*test.go rm -rf chain/exchange/types/v2/*gw.go
cp ../injective-core/injective-chain/modules/insurance/types/*.go chain/insurance/types
rm -rf chain/insurance/types/*test.go rm -rf chain/insurance/types/*gw.go
cp ../injective-core/injective-chain/modules/ocr/types/*.go chain/ocr/types
Expand All @@ -59,6 +61,8 @@ copy-chain-types:
rm -rf chain/wasmx/types/*test.go rm -rf chain/wasmx/types/*gw.go
cp ../injective-core/injective-chain/stream/types/*.go chain/stream/types
rm -rf chain/stream/types/*test.go rm -rf chain/stream/types/*gw.go
cp ../injective-core/injective-chain/stream/types/v2/*.go chain/stream/types/v2
rm -rf chain/stream/types/v2/*test.go rm -rf chain/stream/types/v2/*gw.go
cp ../injective-core/injective-chain/types/*.go chain/types
rm -rf chain/types/*test.go rm -rf chain/types/*gw.go

Expand All @@ -67,6 +71,7 @@ copy-chain-types:
@echo "👉 Replace injective-core/injective-chain/codec/types with sdk-go/chain/codec/types"
@echo "👉 Replace injective-core/injective-chain/types with sdk-go/chain/types"
@echo "👉 Replace injective-core/injective-chain/crypto with sdk-go/chain/crypto"
@echo "👉 Replace injective-core/injective-chain/stream/types with sdk-go/chain/stream/types"

tests:
go test -race ./client/... ./ethereum/...
Expand Down
164 changes: 107 additions & 57 deletions chain/auction/types/auction.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions chain/auction/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ var (
DefaultAuctionPeriod int64 = 60 * 60 * 24 * 7
// DefaultMinNextBidIncrementRate represents default min increment rate 0.25%
DefaultMinNextBidIncrementRate = math.LegacyNewDecWithPrec(25, 4)
// DefaultInjBasketMaxCap represents default inj basket max cap
DefaultInjBasketMaxCap = math.NewIntWithDecimal(10_000, 18)
)

// Parameter keys
var (
KeyAuctionPeriod = []byte("AuctionPeriod")
KeyMinNextBidIncrementRate = []byte("MinNextBidIncrementRate")
KeyInjBasketMaxCap = []byte("InjBasketMaxCap")
)

// ParamKeyTable returns the parameter key table.
Expand All @@ -32,10 +35,12 @@ func ParamKeyTable() paramtypes.KeyTable {
func NewParams(
auctionPeriod int64,
minNextBidIncrementRate math.LegacyDec,
injBasketMaxCap math.Int,
) Params {
return Params{
AuctionPeriod: auctionPeriod,
MinNextBidIncrementRate: minNextBidIncrementRate,
InjBasketMaxCap: injBasketMaxCap,
}
}

Expand All @@ -44,6 +49,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyAuctionPeriod, &p.AuctionPeriod, validateAuctionPeriodDuration),
paramtypes.NewParamSetPair(KeyMinNextBidIncrementRate, &p.MinNextBidIncrementRate, validateMinNextBidIncrementRate),
paramtypes.NewParamSetPair(KeyInjBasketMaxCap, &p.InjBasketMaxCap, validateInjBasketMaxCap),
}
}

Expand All @@ -52,6 +58,7 @@ func DefaultParams() Params {
return Params{
AuctionPeriod: DefaultAuctionPeriod,
MinNextBidIncrementRate: DefaultMinNextBidIncrementRate,
InjBasketMaxCap: DefaultInjBasketMaxCap,
}
}

Expand All @@ -65,6 +72,10 @@ func (p Params) Validate() error {
return err
}

if err := validateInjBasketMaxCap(p.InjBasketMaxCap); err != nil {
return err
}

return nil
}

Expand Down Expand Up @@ -101,3 +112,18 @@ func validateMinNextBidIncrementRate(i interface{}) error {

return nil
}

func validateInjBasketMaxCap(i interface{}) error {
v, ok := i.(math.Int)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}

if v.IsNil() {
return fmt.Errorf("InjBasketMaxCap cannot be nil")
}
if v.IsNegative() {
return fmt.Errorf("InjBasketMaxCap cannot be negative")
}
return nil
}
Loading
Loading