Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyaoy committed Dec 13, 2024
1 parent 769cc18 commit a11b8b6
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion protocol/app/ante/replay_protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (rpd ReplayProtectionDecorator) AnteHandle(
1,
[]gometrics.Label{metrics.GetLabelForIntValue(metrics.ExecMode, int(ctx.ExecMode()))},
)
return ctx, errorsmod.Wrapf(sdkerrors.ErrWrongSequence, err.Error())
return ctx, errorsmod.Wrap(sdkerrors.ErrWrongSequence, err.Error())
}
telemetry.IncrCounterWithLabels(
[]string{metrics.TimestampNonce, metrics.Valid, metrics.Count},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package price_function

import (
"fmt"

"github.com/dydxprotocol/v4-chain/protocol/daemons/pricefeed/client/types"
)

Expand Down Expand Up @@ -35,6 +36,6 @@ func (e *ExchangeErrorImpl) GetExchangeId() types.ExchangeId {
func NewExchangeError(exchangeId types.ExchangeId, msg string) ExchangeError {
return &ExchangeErrorImpl{
exchangeId: exchangeId,
err: fmt.Errorf(msg),
err: fmt.Errorf("%s", msg),
}
}
2 changes: 1 addition & 1 deletion protocol/x/clob/keeper/process_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ func (k Keeper) PersistMatchDeleveragingToState(
// negative TNC subaccount was seen.
if len(matchDeleveraging.GetFills()) == 0 {
if !shouldDeleverageAtBankruptcyPrice {
return errorsmod.Wrapf(
return errorsmod.Wrap(
types.ErrZeroFillDeleveragingForNonNegativeTncSubaccount,
fmt.Sprintf(
"PersistMatchDeleveragingToState: zero-fill deleveraging operation included for subaccount %+v"+
Expand Down
2 changes: 1 addition & 1 deletion protocol/x/delaymsg/keeper/delayed_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (k Keeper) ValidateMsg(msg sdk.Msg, signers [][]byte) error {
handler := k.router.Handler(msg)
// If the message type is not routable, return an error.
if handler == nil {
return errorsmod.Wrapf(
return errorsmod.Wrap(
types.ErrMsgIsUnroutable,
sdk.MsgTypeURL(msg),
)
Expand Down
10 changes: 5 additions & 5 deletions protocol/x/prices/keeper/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (k Keeper) CreateMarket(
// Stateful Validation
for _, market := range k.GetAllMarketParams(ctx) {
if market.Pair == marketParam.Pair {
return types.MarketParam{}, errorsmod.Wrapf(
return types.MarketParam{}, errorsmod.Wrap(
types.ErrMarketParamPairAlreadyExists,
marketParam.Pair,
)
Expand All @@ -51,23 +51,23 @@ func (k Keeper) CreateMarket(
// check that the market exists in market map
currencyPair, err := slinky.MarketPairToCurrencyPair(marketParam.Pair)
if err != nil {
return types.MarketParam{}, errorsmod.Wrapf(
return types.MarketParam{}, errorsmod.Wrap(
types.ErrMarketPairConversionFailed,
marketParam.Pair,
)
}
currencyPairStr := currencyPair.String()
marketMapDetails, err := k.MarketMapKeeper.GetMarket(ctx, currencyPairStr)
if err != nil {
return types.MarketParam{}, errorsmod.Wrapf(
return types.MarketParam{}, errorsmod.Wrap(
types.ErrTickerNotFoundInMarketMap,
currencyPairStr,
)
}

// Check that the exponent of market price is the negation of the decimals value in the market map
if marketPrice.Exponent != int32(marketMapDetails.Ticker.Decimals)*-1 {
return types.MarketParam{}, errorsmod.Wrapf(
return types.MarketParam{}, errorsmod.Wrap(
types.ErrInvalidMarketPriceExponent,
currencyPairStr,
)
Expand Down Expand Up @@ -130,7 +130,7 @@ func (k Keeper) GetExponent(ctx sdk.Context, ticker string) (int32, error) {

marketMapDetails, err := k.MarketMapKeeper.GetMarket(ctx, currencyPair.String())
if err != nil {
return 0, errorsmod.Wrapf(
return 0, errorsmod.Wrap(
types.ErrTickerNotFoundInMarketMap,
ticker,
)
Expand Down
6 changes: 3 additions & 3 deletions protocol/x/prices/keeper/market_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ func (k Keeper) ModifyMarketParam(
// Validate update is permitted.
for _, market := range k.GetAllMarketParams(ctx) {
if market.Pair == updatedMarketParam.Pair && market.Id != updatedMarketParam.Id {
return types.MarketParam{}, errorsmod.Wrapf(types.ErrMarketParamPairAlreadyExists, updatedMarketParam.Pair)
return types.MarketParam{}, errorsmod.Wrap(types.ErrMarketParamPairAlreadyExists, updatedMarketParam.Pair)
}
}

// Validate that modified market param has a corresponding ticker in MarketMap
cp, err := slinky.MarketPairToCurrencyPair(updatedMarketParam.Pair)
if err != nil {
return types.MarketParam{}, errorsmod.Wrapf(types.ErrMarketPairConversionFailed, updatedMarketParam.Pair)
return types.MarketParam{}, errorsmod.Wrap(types.ErrMarketPairConversionFailed, updatedMarketParam.Pair)
}
if _, err := k.MarketMapKeeper.GetMarket(ctx, cp.String()); err != nil {
return types.MarketParam{}, errorsmod.Wrapf(types.ErrTickerNotFoundInMarketMap, cp.String())
return types.MarketParam{}, errorsmod.Wrap(types.ErrTickerNotFoundInMarketMap, cp.String())
}

// Store the modified market param.
Expand Down
2 changes: 1 addition & 1 deletion protocol/x/prices/keeper/market_param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func TestModifyMarketParam_Errors(t *testing.T) {
minExchanges: uint32(1),
minPriceChangePpm: uint32(50),
exchangeConfigJson: validExchangeConfigJson,
expectedErr: errorsmod.Wrapf(
expectedErr: errorsmod.Wrap(
types.ErrTickerNotFoundInMarketMap,
invalidUpdateCurrencyPair.String(),
).Error(),
Expand Down
2 changes: 1 addition & 1 deletion protocol/x/vault/keeper/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (k Keeper) RefreshAllVaultOrders(ctx sdk.Context) {
vaultParams.QuotingParams = &defaultQuotingParams
}
vault := k.subaccountsKeeper.GetSubaccount(ctx, *vaultId.ToSubaccountId())
if vault.PerpetualPositions == nil || len(vault.PerpetualPositions) == 0 {
if len(vault.PerpetualPositions) == 0 {
if vault.GetUsdcPosition().Cmp(vaultParams.QuotingParams.ActivationThresholdQuoteQuantums.BigInt()) == -1 {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions protocol/x/vest/types/vest_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (entry VestEntry) Validate() error {
}

if err := sdk.ValidateDenom(entry.Denom); err != nil {
return errorsmod.Wrapf(ErrInvalidDenom, err.Error())
return errorsmod.Wrap(ErrInvalidDenom, err.Error())
}

if !entry.StartTime.Before(entry.EndTime) {
Expand All @@ -27,7 +27,7 @@ func (entry VestEntry) Validate() error {
}

if entry.EndTime.Location().String() != "UTC" {
return errorsmod.Wrapf(ErrInvalidTimeZone, "start_time must be in UTC")
return errorsmod.Wrapf(ErrInvalidTimeZone, "end_time must be in UTC")
}
return nil
}

0 comments on commit a11b8b6

Please sign in to comment.