Skip to content

Commit

Permalink
Merge branch 'main' into dong/fix-getprice-err
Browse files Browse the repository at this point in the history
  • Loading branch information
DongLieu committed Nov 12, 2024
2 parents 521a65d + e41f5cb commit bf63087
Show file tree
Hide file tree
Showing 17 changed files with 222 additions and 216 deletions.
2 changes: 1 addition & 1 deletion proto/reserve/psm/v1/psm.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ message StablecoinInfo {
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
string sym_bol = 7;
string symbol = 7;
}
4 changes: 2 additions & 2 deletions proto/reserve/psm/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ message MsgAddStableCoin {
(gogoproto.nullable) = false
];
int64 oracle_script = 6;
string sym_bol = 7;
string symbol = 7;
}

message MsgAddStableCoinResponse {}
Expand Down Expand Up @@ -102,7 +102,7 @@ message MsgUpdatesStableCoin {
];

int64 oracle_script = 6;
string sym_bol = 7;
string symbol = 7;
}

message MsgUpdatesStableCoinResponse {}
Expand Down
4 changes: 2 additions & 2 deletions proto/reserve/vaults/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ message MsgUpdatesCollateral {
option (cosmos.msg.v1.signer) = "authority";

string collateral_denom = 1;
string collateral_sym_bol = 2;
string collateral_symbol = 2;

string min_collateral_ratio = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
Expand Down Expand Up @@ -181,7 +181,7 @@ message MsgUpdatesCollateral {
int64 collateral_oracle_script = 9;

string authority = 10 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
string sym_bol = 11;
string symbol = 11;
string mint_denom = 12;
int64 mint_oracle_script = 13;
}
Expand Down
2 changes: 1 addition & 1 deletion x/psm/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (k Keeper) BeginBlocker(ctx context.Context) error {

func (k Keeper) UpdatesStablecoinEpoch(ctx context.Context) error {
updatePrice := func(info types.StablecoinInfo) bool {
price := k.OracleKeeper.GetPrice(ctx, info.SymBol, types.SymBolUSD)
price := k.OracleKeeper.GetPrice(ctx, info.Symbol, types.SymBolUSD)
if price == nil || price.IsNil() {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion x/psm/keeper/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s *KeeperTestSuite) TestUpdatesStablecoinEpoch() {
s.Run(t.name, func() {
sc := types.GetMsgStablecoin(&types.MsgAddStableCoin{
Denom: usdt,
SymBol: usdt,
Symbol: usdt,
LimitTotal: limitUSDT,
FeeIn: t.feeIn,
FeeOut: t.feeOut,
Expand Down
2 changes: 1 addition & 1 deletion x/psm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (k msgServer) AddStableCoinProposal(ctx context.Context, msg *types.MsgAddS
return &types.MsgAddStableCoinResponse{}, err
}

err = k.keeper.OracleKeeper.AddNewSymbolToBandOracleRequest(ctx, msg.SymBol, msg.OracleScript)
err = k.keeper.OracleKeeper.AddNewSymbolToBandOracleRequest(ctx, msg.Symbol, msg.OracleScript)
if err != nil {
return &types.MsgAddStableCoinResponse{}, err
}
Expand Down
6 changes: 3 additions & 3 deletions x/psm/keeper/proposals_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (s *KeeperTestSuite) TestAddStableCoinProposal() {
proAdd := types.MsgAddStableCoin{
Denom: usdt,
LimitTotal: limitUSDT,
SymBol: usdt,
Symbol: usdt,
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
FeeIn: math.LegacyMustNewDecFromStr("0.001"),
FeeOut: math.LegacyMustNewDecFromStr("0.001"),
Expand All @@ -35,7 +35,7 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() {
proAdd := types.MsgAddStableCoin{
Denom: usdt,
LimitTotal: limitUSDT,
SymBol: usdt,
Symbol: usdt,
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
FeeIn: math.LegacyMustNewDecFromStr("0.001"),
FeeOut: math.LegacyMustNewDecFromStr("0.001"),
Expand All @@ -59,7 +59,7 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() {
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
FeeIn: math.LegacyMustNewDecFromStr("0.001"),
FeeOut: math.LegacyMustNewDecFromStr("0.001"),
SymBol: usdt,
Symbol: usdt,
OracleScript: 44,
}

Expand Down
6 changes: 3 additions & 3 deletions x/psm/keeper/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (k Keeper) SwapToOnomyStableToken(ctx context.Context, accAddress sdk.AccAd
}

// check balance user and calculate amount of coins received
receiveAmountnomUSD, fee_in, err := k.calculateSwapToOnomyStableToken(ctx, offerCoin, stablecoin.SymBol)
receiveAmountnomUSD, fee_in, err := k.calculateSwapToOnomyStableToken(ctx, offerCoin, stablecoin.Symbol)
if err != nil {
return err
}
Expand Down Expand Up @@ -151,9 +151,9 @@ func (k Keeper) PayFeesIn(ctx context.Context, amount math.Int, denom string) (m

// SwapToStablecoin return receiveAmount, fee, error
func (k Keeper) calculateSwapToStablecoin(ctx context.Context, amount math.Int, sc types.StablecoinInfo) (math.Int, sdk.DecCoin, error) {
multiplier := k.OracleKeeper.GetPrice(ctx, sc.SymBol, types.SymBolUSD)
multiplier := k.OracleKeeper.GetPrice(ctx, sc.Symbol, types.SymBolUSD)
if multiplier == nil || multiplier.IsNil() {
return math.Int{}, sdk.DecCoin{}, errors.Wrapf(oracletypes.ErrInvalidOracle, "can not get price with base %s quote %s", sc.SymBol, types.ReserveStableCoinDenom)
return math.Int{}, sdk.DecCoin{}, errors.Wrapf(oracletypes.ErrInvalidOracle, "can not get price with base %s quote %s", sc.Symbol, types.ReserveStableCoinDenom)
}
amountStablecoin := amount.ToLegacyDec().Quo(*multiplier)

Expand Down
8 changes: 4 additions & 4 deletions x/psm/keeper/swap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (s *KeeperTestSuite) TestSwapToOnomyStableToken() {
_, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Denom: usdt,
SymBol: usdt,
Symbol: usdt,
LimitTotal: limitUSDT,
FeeIn: math.LegacyMustNewDecFromStr("0.001"),
FeeOut: math.LegacyMustNewDecFromStr("0.001"),
Expand All @@ -55,7 +55,7 @@ func (s *KeeperTestSuite) TestSwapToOnomyStableToken() {
_, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Denom: usdc,
SymBol: usdc,
Symbol: usdc,
LimitTotal: limitUSDC,
FeeIn: math.LegacyMustNewDecFromStr("0.001"),
FeeOut: math.LegacyMustNewDecFromStr("0.001"),
Expand Down Expand Up @@ -115,7 +115,7 @@ func (s *KeeperTestSuite) TestSwapToOtherStablecoin() {
_, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Denom: usdt,
SymBol: usdt,
Symbol: usdt,
LimitTotal: limitUSDT,
FeeIn: math.LegacyMustNewDecFromStr("0.001"),
FeeOut: math.LegacyMustNewDecFromStr("0.001"),
Expand All @@ -138,7 +138,7 @@ func (s *KeeperTestSuite) TestSwapToOtherStablecoin() {
_, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{
Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Denom: usdc,
SymBol: usdc,
Symbol: usdc,
LimitTotal: limitUSDC,
FeeIn: math.LegacyMustNewDecFromStr("0.001"),
FeeOut: math.LegacyMustNewDecFromStr("0.001"),
Expand Down
4 changes: 2 additions & 2 deletions x/psm/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (msg MsgAddStableCoin) ValidateBasic() error {
return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty denom")
}

if msg.SymBol == "" {
if msg.Symbol == "" {
return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty symbol")
}

Expand Down Expand Up @@ -122,7 +122,7 @@ func (msg MsgUpdatesStableCoin) ValidateBasic() error {
return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty denom")
}

if msg.SymBol == "" {
if msg.Symbol == "" {
return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty symbol")
}

Expand Down
4 changes: 2 additions & 2 deletions x/psm/types/psm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func GetMsgStablecoin(msg getStablecoinFromMsg) StablecoinInfo {
FeeOut: msg.GetFeeOut(),
TotalStablecoinLock: math.ZeroInt(),
FeeMaxStablecoin: msg.GetFeeIn().Add(msg.GetFeeOut()),
SymBol: msg.GetSymBol(),
Symbol: msg.GetSymbol(),
}
}

Expand All @@ -21,5 +21,5 @@ type getStablecoinFromMsg interface {
GetLimitTotal() math.Int
GetFeeIn() math.LegacyDec
GetFeeOut() math.LegacyDec
GetSymBol() string
GetSymbol() string
}
74 changes: 37 additions & 37 deletions x/psm/types/psm.pb.go

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

Loading

0 comments on commit bf63087

Please sign in to comment.