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

Psm/decimal #126

Merged
merged 2 commits into from
Dec 31, 2024
Merged
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
5 changes: 5 additions & 0 deletions proto/reserve/psm/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ message MsgAddStableCoin {
];
int64 oracle_script = 6;
string symbol = 7;
uint64 stable_decimal = 8;
uint64 mint_decimal = 9;
}

message MsgAddStableCoinResponse {}
Expand Down Expand Up @@ -103,6 +105,9 @@ message MsgUpdatesStableCoin {

int64 oracle_script = 6;
string symbol = 7;

uint64 stable_decimal = 8;
uint64 mint_decimal = 9;
}

message MsgUpdatesStableCoinResponse {}
Expand Down
4 changes: 4 additions & 0 deletions x/psm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func (s MockOracleKeeper) GetPrice(ctx context.Context, denom1 string, denom2 st
return p, nil
}

func (s MockOracleKeeper) SetPairDecimalsRate(ctx context.Context, base, quote string, baseDecimals, quoteDecimals uint64) error {
return nil
}

func (s MockOracleKeeper) AddNewSymbolToBandOracleRequest(ctx context.Context, symbol string, oracleScriptId int64) error {
_, ok := s.prices[symbol]

Expand Down
10 changes: 10 additions & 0 deletions x/psm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func (k msgServer) AddStableCoinProposal(ctx context.Context, msg *types.MsgAddS
return &types.MsgAddStableCoinResponse{}, err
}

err = k.keeper.OracleKeeper.SetPairDecimalsRate(ctx, msg.Symbol, types.SymBolUSD, msg.StableDecimal, msg.MintDecimal)
if err != nil {
return &types.MsgAddStableCoinResponse{}, err
}

sdkCtx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventAddStablecoin,
Expand Down Expand Up @@ -136,6 +141,11 @@ func (k msgServer) UpdatesStableCoinProposal(ctx context.Context, msg *types.Msg
return &types.MsgUpdatesStableCoinResponse{}, err
}

err = k.keeper.OracleKeeper.SetPairDecimalsRate(ctx, msg.Symbol, types.SymBolUSD, msg.StableDecimal, msg.MintDecimal)
if err != nil {
return &types.MsgUpdatesStableCoinResponse{}, err
}

sdkCtx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventAddStablecoin,
Expand Down
1 change: 1 addition & 0 deletions x/psm/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ type ParamSubspace interface {
type OracleKeeper interface {
GetPrice(ctx context.Context, base, quote string) (math.LegacyDec, error)
AddNewSymbolToBandOracleRequest(ctx context.Context, symbol string, oracleScriptId int64) error
SetPairDecimalsRate(ctx context.Context, base, quote string, baseDecimals, quoteDecimals uint64) error
}
2 changes: 2 additions & 0 deletions x/psm/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ var (

_ govtypes.Content = &MsgAddStableCoin{}
_ govtypes.Content = &MsgUpdatesStableCoin{}

Msg_serviceDesc = _Msg_serviceDesc
)

const (
Expand Down
Loading
Loading