-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add gov msg that sets vault quoting params (#2017)
(cherry picked from commit 27a4923)
- Loading branch information
Showing
13 changed files
with
822 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
protocol/x/vault/keeper/msg_server_set_vault_quoting_params.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
errorsmod "cosmossdk.io/errors" | ||
|
||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" | ||
"github.com/dydxprotocol/v4-chain/protocol/lib" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/vault/types" | ||
) | ||
|
||
// SetVaultQuotingParams sets the quoting parameters of a specific vault. | ||
func (k msgServer) SetVaultQuotingParams( | ||
goCtx context.Context, | ||
msg *types.MsgSetVaultQuotingParams, | ||
) (*types.MsgSetVaultQuotingParamsResponse, error) { | ||
// Check if authority is valid. | ||
if !k.HasAuthority(msg.Authority) { | ||
return nil, errorsmod.Wrapf( | ||
govtypes.ErrInvalidSigner, | ||
"invalid authority %s", | ||
msg.Authority, | ||
) | ||
} | ||
|
||
ctx := lib.UnwrapSDKContext(goCtx, types.ModuleName) | ||
|
||
// Validate quoting parameters. | ||
if err := msg.QuotingParams.Validate(); err != nil { | ||
return nil, err | ||
} | ||
|
||
// Set quoting parameters for specified vault. | ||
if err := k.Keeper.SetVaultQuotingParams(ctx, msg.VaultId, msg.QuotingParams); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &types.MsgSetVaultQuotingParamsResponse{}, nil | ||
} |
Oops, something went wrong.