From 0118e0e68d60e44c1875330cd743147a47413b3d Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Fri, 1 Nov 2024 00:08:37 +0700 Subject: [PATCH 01/42] add bid denom check --- x/auction/keeper/keeper.go | 10 +--------- x/auction/keeper/msg_server.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 9fa13c3b..bc445b2f 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -118,15 +118,7 @@ func (k Keeper) DeleteAuction(ctx context.Context, auctionId uint64) error { // AddBidEntry adds new bid entry for the given auction id func (k Keeper) AddBidEntry(ctx context.Context, auctionId uint64, bidderAddr sdk.AccAddress, bid types.Bid) error { - has, err := k.Auctions.Has(ctx, auctionId) - if err != nil { - return err - } - if !has { - return fmt.Errorf("cannot bid for non-existing/expired auction with id: %v", auctionId) - } - - has = k.authKeeper.HasAccount(ctx, bidderAddr) + has := k.authKeeper.HasAccount(ctx, bidderAddr) if !has { return sdkerrors.ErrInvalidAddress.Wrapf("invalid proposer address %s: account does not exist", bid.Bidder) } diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index fa0f50da..ef09c990 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "cosmossdk.io/collections" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/onomyprotocol/reserve/x/auction/types" @@ -40,6 +41,26 @@ func (k msgServer) Bid(ctx context.Context, msg *types.MsgBid) (*types.MsgBidRes Response: "Failed to submit bid", }, err } + + // check bid denom to match vault debt denom + bidDenom := msg.Amount.Denom + auction, err := k.Auctions.Get(ctx, msg.AuctionId) + if err != nil { + if errorsmod.IsOf(err, collections.ErrNotFound) { + return nil, fmt.Errorf("cannot bid for non-existing/expired auction with id: %v", msg.AuctionId) + } + return nil, err + } + + vault, err := k.vaultKeeper.GetVault(ctx, auction.VaultId) + if err != nil { + return nil, err + } + + if vault.Debt.Denom != bidDenom { + return nil, fmt.Errorf("invalid bid amount denom, expected %s got %s", vault.Debt.Denom, bidDenom) + } + bidIdSeq, err := k.BidIdSeq.Get(ctx, msg.AuctionId) if err != nil { return nil, err From 06c7be0797bd49105db3a2c5f6eb076b53f888d4 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 1 Nov 2024 01:53:26 +0700 Subject: [PATCH 02/42] allow multiple stable coin denom --- .../reserve/x/vaults/types/params.pb.go | 2576 +++++++++++++++++ proto/reserve/vaults/params.proto | 16 +- x/auction/keeper/abci.go | 149 +- x/auction/keeper/auction.go | 13 +- x/auction/keeper/liquidate.go | 178 ++ x/auction/types/expected_keepers.go | 5 +- x/vaults/keeper/keeper.go | 4 + x/vaults/keeper/keeper_test.go | 2 +- x/vaults/keeper/vault.go | 17 +- x/vaults/keeper/vaults_test.go | 8 +- x/vaults/types/params.go | 11 +- x/vaults/types/params.pb.go | 268 +- 12 files changed, 2971 insertions(+), 276 deletions(-) create mode 100644 proto/github.com/onomyprotocol/reserve/x/vaults/types/params.pb.go create mode 100644 x/auction/keeper/liquidate.go diff --git a/proto/github.com/onomyprotocol/reserve/x/vaults/types/params.pb.go b/proto/github.com/onomyprotocol/reserve/x/vaults/types/params.pb.go new file mode 100644 index 00000000..0e266d35 --- /dev/null +++ b/proto/github.com/onomyprotocol/reserve/x/vaults/types/params.pb.go @@ -0,0 +1,2576 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: reserve/vaults/params.proto + +package types + +import ( + cosmossdk_io_math "cosmossdk.io/math" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// VaultStatus is the status of a vault. +type VaultStatus int32 + +const ( + // ACTIVE - vault is in use and can be changed + ACTIVE VaultStatus = 0 + // LIQUIDATING - vault is being liquidated by the vault manager, and cannot be + // changed by the user. If liquidation fails, vaults may remain in this state. + // An upgrade might be able to recover them. + LIQUIDATING VaultStatus = 1 + // TRANSFER - vault is able to be transferred (payments and debits frozen + // until it has a new owner) + TRANSFER VaultStatus = 2 + // CLOSED - vault was closed by the user and all assets have been paid out + CLOSED VaultStatus = 3 + // LIQUIDATED - vault was closed by the manager, with remaining assets paid to + // owner + LIQUIDATED VaultStatus = 4 +) + +var VaultStatus_name = map[int32]string{ + 0: "ACTIVE", + 1: "LIQUIDATING", + 2: "TRANSFER", + 3: "CLOSED", + 4: "LIQUIDATED", +} + +var VaultStatus_value = map[string]int32{ + "ACTIVE": 0, + "LIQUIDATING": 1, + "TRANSFER": 2, + "CLOSED": 3, + "LIQUIDATED": 4, +} + +func (x VaultStatus) String() string { + return proto.EnumName(VaultStatus_name, int32(x)) +} + +func (VaultStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_1f12ab0d072f9f7c, []int{0} +} + +// Params defines the parameters for the module. +type Params struct { + MinInitialDebt cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=min_initial_debt,json=minInitialDebt,proto3,customtype=cosmossdk.io/math.Int" json:"min_initial_debt"` + AllowedMintDenom []string `protobuf:"bytes,2,rep,name=allowed_mint_denom,json=allowedMintDenom,proto3" json:"allowed_mint_denom,omitempty"` + ChargingPeriod time.Duration `protobuf:"bytes,3,opt,name=charging_period,json=chargingPeriod,proto3,stdduration" json:"charging_period"` + LiquidatePeriod time.Duration `protobuf:"bytes,4,opt,name=liquidate_period,json=liquidatePeriod,proto3,stdduration" json:"liquidate_period"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_1f12ab0d072f9f7c, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetAllowedMintDenom() []string { + if m != nil { + return m.AllowedMintDenom + } + return nil +} + +func (m *Params) GetChargingPeriod() time.Duration { + if m != nil { + return m.ChargingPeriod + } + return 0 +} + +func (m *Params) GetLiquidatePeriod() time.Duration { + if m != nil { + return m.LiquidatePeriod + } + return 0 +} + +// VaultParams defines the parameters for each collateral vault type. +type VaultMamagerParams struct { + MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` + MinCollateralRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=min_collateral_ratio,json=minCollateralRatio,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_collateral_ratio"` + LiquidationRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=liquidation_ratio,json=liquidationRatio,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_ratio"` + MaxDebt cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=max_debt,json=maxDebt,proto3,customtype=cosmossdk.io/math.Int" json:"max_debt"` + StabilityFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=stability_fee,json=stabilityFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"stability_fee"` + LiquidationPenalty cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=liquidation_penalty,json=liquidationPenalty,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_penalty"` + MintingFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=minting_fee,json=mintingFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"minting_fee"` +} + +func (m *VaultMamagerParams) Reset() { *m = VaultMamagerParams{} } +func (m *VaultMamagerParams) String() string { return proto.CompactTextString(m) } +func (*VaultMamagerParams) ProtoMessage() {} +func (*VaultMamagerParams) Descriptor() ([]byte, []int) { + return fileDescriptor_1f12ab0d072f9f7c, []int{1} +} +func (m *VaultMamagerParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VaultMamagerParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VaultMamagerParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *VaultMamagerParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_VaultMamagerParams.Merge(m, src) +} +func (m *VaultMamagerParams) XXX_Size() int { + return m.Size() +} +func (m *VaultMamagerParams) XXX_DiscardUnknown() { + xxx_messageInfo_VaultMamagerParams.DiscardUnknown(m) +} + +var xxx_messageInfo_VaultMamagerParams proto.InternalMessageInfo + +func (m *VaultMamagerParams) GetMintDenom() string { + if m != nil { + return m.MintDenom + } + return "" +} + +// VaultMamager defines the manager of each collateral vault type. +type VaultMamager struct { + Params VaultMamagerParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + MintAvailable cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=mint_available,json=mintAvailable,proto3,customtype=cosmossdk.io/math.Int" json:"mint_available"` +} + +func (m *VaultMamager) Reset() { *m = VaultMamager{} } +func (m *VaultMamager) String() string { return proto.CompactTextString(m) } +func (*VaultMamager) ProtoMessage() {} +func (*VaultMamager) Descriptor() ([]byte, []int) { + return fileDescriptor_1f12ab0d072f9f7c, []int{2} +} +func (m *VaultMamager) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VaultMamager) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VaultMamager.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *VaultMamager) XXX_Merge(src proto.Message) { + xxx_messageInfo_VaultMamager.Merge(m, src) +} +func (m *VaultMamager) XXX_Size() int { + return m.Size() +} +func (m *VaultMamager) XXX_DiscardUnknown() { + xxx_messageInfo_VaultMamager.DiscardUnknown(m) +} + +var xxx_messageInfo_VaultMamager proto.InternalMessageInfo + +func (m *VaultMamager) GetParams() VaultMamagerParams { + if m != nil { + return m.Params + } + return VaultMamagerParams{} +} + +func (m *VaultMamager) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +type Vault struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + Debt types.Coin `protobuf:"bytes,3,opt,name=debt,proto3" json:"debt"` + CollateralLocked types.Coin `protobuf:"bytes,4,opt,name=collateral_locked,json=collateralLocked,proto3" json:"collateral_locked"` + Status VaultStatus `protobuf:"varint,5,opt,name=status,proto3,enum=reserve.vaults.VaultStatus" json:"status,omitempty"` + LiquidationPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=liquidation_price,json=liquidationPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_price"` + Address string `protobuf:"bytes,7,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *Vault) Reset() { *m = Vault{} } +func (m *Vault) String() string { return proto.CompactTextString(m) } +func (*Vault) ProtoMessage() {} +func (*Vault) Descriptor() ([]byte, []int) { + return fileDescriptor_1f12ab0d072f9f7c, []int{3} +} +func (m *Vault) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Vault) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Vault.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Vault) XXX_Merge(src proto.Message) { + xxx_messageInfo_Vault.Merge(m, src) +} +func (m *Vault) XXX_Size() int { + return m.Size() +} +func (m *Vault) XXX_DiscardUnknown() { + xxx_messageInfo_Vault.DiscardUnknown(m) +} + +var xxx_messageInfo_Vault proto.InternalMessageInfo + +func (m *Vault) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *Vault) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *Vault) GetDebt() types.Coin { + if m != nil { + return m.Debt + } + return types.Coin{} +} + +func (m *Vault) GetCollateralLocked() types.Coin { + if m != nil { + return m.CollateralLocked + } + return types.Coin{} +} + +func (m *Vault) GetStatus() VaultStatus { + if m != nil { + return m.Status + } + return ACTIVE +} + +func (m *Vault) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type VaultLiquidationStatus struct { + Sold types.Coin `protobuf:"bytes,4,opt,name=sold,proto3" json:"sold"` + RemainCollateral types.Coin `protobuf:"bytes,5,opt,name=remain_collateral,json=remainCollateral,proto3" json:"remain_collateral"` +} + +func (m *VaultLiquidationStatus) Reset() { *m = VaultLiquidationStatus{} } +func (m *VaultLiquidationStatus) String() string { return proto.CompactTextString(m) } +func (*VaultLiquidationStatus) ProtoMessage() {} +func (*VaultLiquidationStatus) Descriptor() ([]byte, []int) { + return fileDescriptor_1f12ab0d072f9f7c, []int{4} +} +func (m *VaultLiquidationStatus) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *VaultLiquidationStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_VaultLiquidationStatus.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *VaultLiquidationStatus) XXX_Merge(src proto.Message) { + xxx_messageInfo_VaultLiquidationStatus.Merge(m, src) +} +func (m *VaultLiquidationStatus) XXX_Size() int { + return m.Size() +} +func (m *VaultLiquidationStatus) XXX_DiscardUnknown() { + xxx_messageInfo_VaultLiquidationStatus.DiscardUnknown(m) +} + +var xxx_messageInfo_VaultLiquidationStatus proto.InternalMessageInfo + +func (m *VaultLiquidationStatus) GetSold() types.Coin { + if m != nil { + return m.Sold + } + return types.Coin{} +} + +func (m *VaultLiquidationStatus) GetRemainCollateral() types.Coin { + if m != nil { + return m.RemainCollateral + } + return types.Coin{} +} + +type Liquidation struct { + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + LiquidatingVaults []*Vault `protobuf:"bytes,3,rep,name=liquidating_vaults,json=liquidatingVaults,proto3" json:"liquidating_vaults,omitempty"` + VaultLiquidationStatus map[uint64]*VaultLiquidationStatus `protobuf:"bytes,4,rep,name=vault_liquidation_status,json=vaultLiquidationStatus,proto3" json:"vault_liquidation_status,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *Liquidation) Reset() { *m = Liquidation{} } +func (m *Liquidation) String() string { return proto.CompactTextString(m) } +func (*Liquidation) ProtoMessage() {} +func (*Liquidation) Descriptor() ([]byte, []int) { + return fileDescriptor_1f12ab0d072f9f7c, []int{5} +} +func (m *Liquidation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Liquidation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Liquidation.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Liquidation) XXX_Merge(src proto.Message) { + xxx_messageInfo_Liquidation.Merge(m, src) +} +func (m *Liquidation) XXX_Size() int { + return m.Size() +} +func (m *Liquidation) XXX_DiscardUnknown() { + xxx_messageInfo_Liquidation.DiscardUnknown(m) +} + +var xxx_messageInfo_Liquidation proto.InternalMessageInfo + +func (m *Liquidation) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + +func (m *Liquidation) GetLiquidatingVaults() []*Vault { + if m != nil { + return m.LiquidatingVaults + } + return nil +} + +func (m *Liquidation) GetVaultLiquidationStatus() map[uint64]*VaultLiquidationStatus { + if m != nil { + return m.VaultLiquidationStatus + } + return nil +} + +type LastUpdate struct { + Time time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time"` +} + +func (m *LastUpdate) Reset() { *m = LastUpdate{} } +func (m *LastUpdate) String() string { return proto.CompactTextString(m) } +func (*LastUpdate) ProtoMessage() {} +func (*LastUpdate) Descriptor() ([]byte, []int) { + return fileDescriptor_1f12ab0d072f9f7c, []int{6} +} +func (m *LastUpdate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LastUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LastUpdate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LastUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_LastUpdate.Merge(m, src) +} +func (m *LastUpdate) XXX_Size() int { + return m.Size() +} +func (m *LastUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_LastUpdate.DiscardUnknown(m) +} + +var xxx_messageInfo_LastUpdate proto.InternalMessageInfo + +func (m *LastUpdate) GetTime() time.Time { + if m != nil { + return m.Time + } + return time.Time{} +} + +func init() { + proto.RegisterEnum("reserve.vaults.VaultStatus", VaultStatus_name, VaultStatus_value) + proto.RegisterType((*Params)(nil), "reserve.vaults.Params") + proto.RegisterType((*VaultMamagerParams)(nil), "reserve.vaults.VaultMamagerParams") + proto.RegisterType((*VaultMamager)(nil), "reserve.vaults.VaultMamager") + proto.RegisterType((*Vault)(nil), "reserve.vaults.Vault") + proto.RegisterType((*VaultLiquidationStatus)(nil), "reserve.vaults.VaultLiquidationStatus") + proto.RegisterType((*Liquidation)(nil), "reserve.vaults.Liquidation") + proto.RegisterMapType((map[uint64]*VaultLiquidationStatus)(nil), "reserve.vaults.Liquidation.VaultLiquidationStatusEntry") + proto.RegisterType((*LastUpdate)(nil), "reserve.vaults.LastUpdate") +} + +func init() { proto.RegisterFile("reserve/vaults/params.proto", fileDescriptor_1f12ab0d072f9f7c) } + +var fileDescriptor_1f12ab0d072f9f7c = []byte{ + // 1095 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x4f, 0x1b, 0x47, + 0x14, 0xf7, 0xda, 0xc6, 0x84, 0x67, 0x30, 0x66, 0x4a, 0xa8, 0x63, 0x54, 0x63, 0xf9, 0x50, 0x21, + 0xd4, 0xec, 0x36, 0x8e, 0xd4, 0x46, 0x51, 0x7b, 0x00, 0x6c, 0x2a, 0x2b, 0x4e, 0x0a, 0x0b, 0x49, + 0xa4, 0xf4, 0x60, 0x8d, 0x77, 0x27, 0xcb, 0x88, 0xdd, 0x1d, 0xb3, 0x3b, 0x76, 0xf0, 0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, 0x98, 0x8f, 0x2a, 0x61, 0x31, 0xd7, + 0xc5, 0x9c, 0x04, 0xd8, 0xed, 0x88, 0x80, 0x4a, 0x69, 0x51, 0x8d, 0x4f, 0x54, 0x35, 0x16, 0xcf, + 0x56, 0xa3, 0x4d, 0x1c, 0x6c, 0x0d, 0x1b, 0xc4, 0x4a, 0xd4, 0xa4, 0x41, 0x2c, 0x19, 0x3e, 0xf2, + 0xa8, 0xbf, 0x3e, 0x82, 0x34, 0x23, 0x44, 0x64, 0xc1, 0x5c, 0x9c, 0x14, 0x65, 0xbe, 0xba, 0x26, + 0x73, 0xa9, 0x6b, 0x8a, 0x09, 0x40, 0x79, 0xc9, 0x1d, 0xb8, 0xe2, 0xe1, 0x03, 0x29, 0xa8, 0xec, + 0xff, 0x14, 0xd4, 0xa4, 0x87, 0x0f, 0x84, 0x92, 0xbe, 0x82, 0x99, 0x90, 0xe3, 0x2e, 0x75, 0x29, + 0x1f, 0x76, 0x1e, 0x13, 0x52, 0x9a, 0xb8, 0x54, 0xb4, 0xd3, 0x23, 0xb0, 0x0d, 0x42, 0x90, 0x03, + 0xef, 0x25, 0xe9, 0xe8, 0x11, 0x1f, 0xbb, 0x7c, 0x58, 0xca, 0x5d, 0x8e, 0xf7, 0x04, 0xe4, 0xa6, + 0x44, 0x44, 0x0f, 0x21, 0x1f, 0x95, 0x3b, 0x12, 0x78, 0x94, 0xc3, 0xe4, 0xa5, 0x2e, 0x00, 0x05, + 0xb5, 0x41, 0x48, 0xed, 0x67, 0x0d, 0xa6, 0x93, 0x82, 0x43, 0x4d, 0xc8, 0xc9, 0x29, 0x25, 0x64, + 0x96, 0xaf, 0xd7, 0xf4, 0xb7, 0xc7, 0x94, 0x7e, 0x56, 0x9e, 0x6b, 0x53, 0x51, 0x20, 0x12, 0x5b, + 0x39, 0xa3, 0x79, 0x98, 0x88, 0x7b, 0x36, 0x12, 0xab, 0x5c, 0xa0, 0x87, 0x50, 0x10, 0x3a, 0xc6, + 0x03, 0x4c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xa1, 0x32, + 0x5c, 0xd9, 0x31, 0x57, 0xef, 0x6d, 0x6f, 0x34, 0xcd, 0x62, 0xba, 0x3c, 0x7d, 0x78, 0x54, 0x1d, + 0xad, 0x23, 0xd4, 0xf5, 0xf6, 0x97, 0xdb, 0xcd, 0x46, 0x31, 0x23, 0x51, 0xe5, 0x0a, 0x55, 0x00, + 0x62, 0x88, 0x66, 0xa3, 0x98, 0x2d, 0x17, 0x0e, 0x8f, 0xaa, 0x89, 0x9d, 0x72, 0xf6, 0xeb, 0x1f, + 0x2a, 0xa9, 0xb5, 0xd6, 0x8b, 0xe3, 0x8a, 0xf6, 0xf2, 0xb8, 0xa2, 0xfd, 0x79, 0x5c, 0xd1, 0x9e, + 0x9e, 0x54, 0x52, 0x2f, 0x4f, 0x2a, 0xa9, 0x5f, 0x4f, 0x2a, 0xa9, 0x47, 0x86, 0x43, 0xf9, 0x6e, + 0xbf, 0xab, 0x5b, 0xcc, 0x33, 0x98, 0xcf, 0xbc, 0xa1, 0x48, 0xdb, 0x62, 0xae, 0x71, 0xe6, 0x9b, + 0x80, 0x0f, 0x7b, 0x24, 0xec, 0xe6, 0x84, 0xc1, 0xcd, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2f, + 0xed, 0x5a, 0x7d, 0x4c, 0x0a, 0x00, 0x00, +} + +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.MinInitialDebt.Equal(that1.MinInitialDebt) { + return false + } + if len(this.AllowedMintDenom) != len(that1.AllowedMintDenom) { + return false + } + for i := range this.AllowedMintDenom { + if this.AllowedMintDenom[i] != that1.AllowedMintDenom[i] { + return false + } + } + if this.ChargingPeriod != that1.ChargingPeriod { + return false + } + if this.LiquidatePeriod != that1.LiquidatePeriod { + return false + } + return true +} +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.LiquidatePeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.LiquidatePeriod):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintParams(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x22 + n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.ChargingPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.ChargingPeriod):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintParams(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x1a + if len(m.AllowedMintDenom) > 0 { + for iNdEx := len(m.AllowedMintDenom) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowedMintDenom[iNdEx]) + copy(dAtA[i:], m.AllowedMintDenom[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.AllowedMintDenom[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + { + size := m.MinInitialDebt.Size() + i -= size + if _, err := m.MinInitialDebt.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *VaultMamagerParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *VaultMamagerParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VaultMamagerParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MintingFee.Size() + i -= size + if _, err := m.MintingFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size := m.LiquidationPenalty.Size() + i -= size + if _, err := m.LiquidationPenalty.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.StabilityFee.Size() + i -= size + if _, err := m.StabilityFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.MaxDebt.Size() + i -= size + if _, err := m.MaxDebt.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.LiquidationRatio.Size() + i -= size + if _, err := m.LiquidationRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.MinCollateralRatio.Size() + i -= size + if _, err := m.MinCollateralRatio.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.MintDenom) > 0 { + i -= len(m.MintDenom) + copy(dAtA[i:], m.MintDenom) + i = encodeVarintParams(dAtA, i, uint64(len(m.MintDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *VaultMamager) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *VaultMamager) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VaultMamager) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MintAvailable.Size() + i -= size + if _, err := m.MintAvailable.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintParams(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Vault) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Vault) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintParams(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x3a + } + { + size := m.LiquidationPrice.Size() + i -= size + if _, err := m.LiquidationPrice.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + if m.Status != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x28 + } + { + size, err := m.CollateralLocked.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size, err := m.Debt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintParams(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if m.Id != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *VaultLiquidationStatus) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *VaultLiquidationStatus) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *VaultLiquidationStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.RemainCollateral.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size, err := m.Sold.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + return len(dAtA) - i, nil +} + +func (m *Liquidation) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Liquidation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Liquidation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.VaultLiquidationStatus) > 0 { + for k := range m.VaultLiquidationStatus { + v := m.VaultLiquidationStatus[k] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i = encodeVarintParams(dAtA, i, uint64(k)) + i-- + dAtA[i] = 0x8 + i = encodeVarintParams(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x22 + } + } + if len(m.LiquidatingVaults) > 0 { + for iNdEx := len(m.LiquidatingVaults) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LiquidatingVaults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintParams(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LastUpdate) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LastUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LastUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n9, err9 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) + if err9 != nil { + return 0, err9 + } + i -= n9 + i = encodeVarintParams(dAtA, i, uint64(n9)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.MinInitialDebt.Size() + n += 1 + l + sovParams(uint64(l)) + if len(m.AllowedMintDenom) > 0 { + for _, s := range m.AllowedMintDenom { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.ChargingPeriod) + n += 1 + l + sovParams(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.LiquidatePeriod) + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *VaultMamagerParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MintDenom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.MinCollateralRatio.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.LiquidationRatio.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MaxDebt.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.StabilityFee.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.LiquidationPenalty.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MintingFee.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *VaultMamager) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovParams(uint64(l)) + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.MintAvailable.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *Vault) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovParams(uint64(m.Id)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = m.Debt.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.CollateralLocked.Size() + n += 1 + l + sovParams(uint64(l)) + if m.Status != 0 { + n += 1 + sovParams(uint64(m.Status)) + } + l = m.LiquidationPrice.Size() + n += 1 + l + sovParams(uint64(l)) + l = len(m.Address) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + return n +} + +func (m *VaultLiquidationStatus) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Sold.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.RemainCollateral.Size() + n += 1 + l + sovParams(uint64(l)) + return n +} + +func (m *Liquidation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if len(m.LiquidatingVaults) > 0 { + for _, e := range m.LiquidatingVaults { + l = e.Size() + n += 1 + l + sovParams(uint64(l)) + } + } + if len(m.VaultLiquidationStatus) > 0 { + for k, v := range m.VaultLiquidationStatus { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovParams(uint64(l)) + } + mapEntrySize := 1 + sovParams(uint64(k)) + l + n += mapEntrySize + 1 + sovParams(uint64(mapEntrySize)) + } + } + return n +} + +func (m *LastUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time) + n += 1 + l + sovParams(uint64(l)) + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinInitialDebt", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinInitialDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowedMintDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowedMintDenom = append(m.AllowedMintDenom, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChargingPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.ChargingPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidatePeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.LiquidatePeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VaultMamagerParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: VaultMamagerParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VaultMamagerParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MintDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinCollateralRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinCollateralRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidationRatio", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LiquidationRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxDebt", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StabilityFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.StabilityFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidationPenalty", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LiquidationPenalty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintingFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MintingFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VaultMamager) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: VaultMamager: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VaultMamager: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintAvailable", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MintAvailable.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Vault) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Vault: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Vault: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + m.Id = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Debt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Debt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CollateralLocked", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CollateralLocked.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= VaultStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidationPrice", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LiquidationPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *VaultLiquidationStatus) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: VaultLiquidationStatus: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: VaultLiquidationStatus: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sold", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Sold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RemainCollateral", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.RemainCollateral.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Liquidation) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Liquidation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Liquidation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidatingVaults", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidatingVaults = append(m.LiquidatingVaults, &Vault{}) + if err := m.LiquidatingVaults[len(m.LiquidatingVaults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VaultLiquidationStatus", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.VaultLiquidationStatus == nil { + m.VaultLiquidationStatus = make(map[uint64]*VaultLiquidationStatus) + } + var mapkey uint64 + var mapvalue *VaultLiquidationStatus + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthParams + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthParams + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &VaultLiquidationStatus{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.VaultLiquidationStatus[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LastUpdate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LastUpdate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LastUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.Time, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/reserve/vaults/params.proto b/proto/reserve/vaults/params.proto index 84e00349..1ad8ea69 100644 --- a/proto/reserve/vaults/params.proto +++ b/proto/reserve/vaults/params.proto @@ -22,7 +22,7 @@ message Params { (gogoproto.nullable) = false ]; - string mint_denom = 2; + repeated string allowed_mint_denom = 2; google.protobuf.Duration charging_period = 3 [ (gogoproto.stdduration) = true, @@ -33,42 +33,44 @@ message Params { // VaultParams defines the parameters for each collateral vault type. message VaultMamagerParams { - string min_collateral_ratio = 1 [ + string mint_denom = 1; + + string min_collateral_ratio = 2 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (amino.dont_omitempty) = true, (gogoproto.nullable) = false ]; - string liquidation_ratio = 2 [ + string liquidation_ratio = 3 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (amino.dont_omitempty) = true, (gogoproto.nullable) = false ]; - string max_debt = 3 [ + string max_debt = 4 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", (amino.dont_omitempty) = true, (gogoproto.nullable) = false ]; - string stability_fee = 4 [ + string stability_fee = 5 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (amino.dont_omitempty) = true, (gogoproto.nullable) = false ]; - string liquidation_penalty = 5 [ + string liquidation_penalty = 6 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (amino.dont_omitempty) = true, (gogoproto.nullable) = false ]; - string minting_fee = 6 [ + string minting_fee = 7 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (amino.dont_omitempty) = true, diff --git a/x/auction/keeper/abci.go b/x/auction/keeper/abci.go index 35491155..2ebb231d 100644 --- a/x/auction/keeper/abci.go +++ b/x/auction/keeper/abci.go @@ -2,162 +2,21 @@ package keeper import ( "context" - "time" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/onomyprotocol/reserve/x/auction/types" - vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" ) func (k *Keeper) BeginBlocker(ctx context.Context) error { - params := k.GetParams(ctx) + // get allowed mint denom + allowedMintDenoms := k.vaultKeeper.GetAllowedMintDenoms(ctx) - currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time - lastAuctionPeriods := time.Unix(k.LastestAuctionPeriod, 0) - // check if has reached the next auction periods - if lastAuctionPeriods.Add(params.AuctionPeriods).Before(currentTime) { - // update latest auction period - k.LastestAuctionPeriod = lastAuctionPeriods.Add(params.AuctionPeriods).Unix() - - liquidations, err := k.vaultKeeper.GetLiquidations(ctx) + for _, mintDenom := range allowedMintDenoms { + err := k.handleLiquidation(ctx, mintDenom) if err != nil { return err } - - liquidatedVaults := make([]*vaultstypes.Vault, 0) - for _, liq := range liquidations { - liquidatedVaults = append(liquidatedVaults, liq.LiquidatingVaults...) - } - - // create new auction for this vault - for _, vault := range liquidatedVaults { - //calcualte initial price and target price - auction, isCreate, err := k.GetNewAuction(ctx, currentTime, vault.LiquidationPrice, vault.CollateralLocked, vault.Debt, vault.Id) - if err != nil { - return err - } - - if isCreate { - err = k.Auctions.Set(ctx, auction.AuctionId, *auction) - if err != nil { - return err - } - err = k.Bids.Set(ctx, auction.AuctionId, types.BidQueue{AuctionId: auction.AuctionId, Bids: []*types.Bid{}}) - if err != nil { - return err - } - err = k.BidIdSeq.Set(ctx, auction.AuctionId, 0) - if err != nil { - return err - } - } - if err != nil { - return err - } - } - } - - // loop through all auctions - // get liquidations data then distribute debt & collateral remain - liquidationMap := make(map[string]*vaultstypes.Liquidation) - err := k.Auctions.Walk(ctx, nil, func(auctionId uint64, auction types.Auction) (bool, error) { - bidQueue, err := k.Bids.Get(ctx, auction.AuctionId) - if err != nil { - return true, err - } - vault, err := k.vaultKeeper.GetVault(ctx, auction.VaultId) - if err != nil { - return true, err - } - - needCleanup := false - currentRate := math.LegacyMustNewDecFromStr(auction.CurrentRate) - lowestRate := math.LegacyMustNewDecFromStr(params.LowestRate) - if auction.Status == types.AuctionStatus_AUCTION_STATUS_FINISHED || - auction.Status == types.AuctionStatus_AUCTION_STATUS_OUT_OF_COLLATHERAL || - currentRate.Equal(lowestRate) { - liquidation_tmp, ok := liquidationMap[auction.Item.Denom] - if ok && liquidation_tmp != nil { - liquidation_tmp.Denom = auction.Item.Denom - liquidation_tmp.LiquidatingVaults = append(liquidation_tmp.LiquidatingVaults, &vault) - liquidation_tmp.VaultLiquidationStatus[vault.Id] = &vaultstypes.VaultLiquidationStatus{ - Sold: auction.TokenRaised, - RemainCollateral: auction.Item, - } - } else { - liquidation_tmp = &vaultstypes.Liquidation{ - Denom: auction.Item.Denom, - LiquidatingVaults: []*vaultstypes.Vault{&vault}, - VaultLiquidationStatus: make(map[uint64]*vaultstypes.VaultLiquidationStatus), - } - - liquidation_tmp.VaultLiquidationStatus[vault.Id] = &vaultstypes.VaultLiquidationStatus{ - Sold: auction.TokenRaised, - RemainCollateral: auction.Item, - } - liquidationMap[auction.Item.Denom] = liquidation_tmp - } - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, vaultstypes.ModuleName, sdk.NewCoins(liquidationMap[auction.Item.Denom].VaultLiquidationStatus[vault.Id].Sold)) - if err != nil { - return true, err - } - - needCleanup = true - // skip other logic - } - - if needCleanup { - err = k.refundBidders(ctx, bidQueue) - if err != nil { - return true, err - } - - // clear the auction afterward - err = k.DeleteAuction(ctx, auction.AuctionId) - if err != nil { - return true, err - } - - return false, nil - } - - // check if reach next reduce step - if auction.LastDiscountTime.Add(params.ReduceStep).Before(currentTime) { - // get new discount rate - newRate, err := k.discountRate(auction, params) - if err != nil { - return true, err - } - - // apply new changes - auction.CurrentRate = newRate - auction.LastDiscountTime = auction.LastDiscountTime.Add(params.ReduceStep) - - // update new rate and last discount time - err = k.Auctions.Set(ctx, auctionId, auction) - if err != nil { - return true, err - } - } - - err = k.fillBids(ctx, auction, bidQueue) - if err != nil { - return true, err - } - - return false, nil - }) - - // Loop through liquidationMap and liquidate - for _, liq := range liquidationMap { - err := k.vaultKeeper.Liquidate(ctx, *liq) - if err != nil { - return err - } - } - if err != nil { - return err } return nil diff --git a/x/auction/keeper/auction.go b/x/auction/keeper/auction.go index 9e199612..40d984df 100644 --- a/x/auction/keeper/auction.go +++ b/x/auction/keeper/auction.go @@ -7,7 +7,6 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/onomyprotocol/reserve/x/auction/types" - vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" ) // return aution, is create, error @@ -17,8 +16,12 @@ func (k Keeper) GetNewAuction(ctx context.Context, item, targetGoal sdk.Coin, vaultId uint64, ) (*types.Auction, bool, error) { + vault, err := k.vaultKeeper.GetVault(ctx, vaultId) + if err != nil { + return nil, true, err + } var newAuction *types.Auction - err := k.Auctions.Walk(ctx, nil, func(key uint64, value types.Auction) (stop bool, err error) { + err = k.Auctions.Walk(ctx, nil, func(key uint64, value types.Auction) (stop bool, err error) { if value.VaultId == vaultId { newAuction = &value return true, nil @@ -31,7 +34,8 @@ func (k Keeper) GetNewAuction(ctx context.Context, if newAuction != nil { return newAuction, false, nil } - newAuction, err = k.NewAuction(ctx, startTime, initialPrice, item, targetGoal, vaultId) + newAuction, err = k.NewAuction(ctx, startTime, initialPrice, item, targetGoal, vaultId, vault.Debt.Denom) + if err != nil { return newAuction, true, err } @@ -43,6 +47,7 @@ func (k Keeper) NewAuction(ctx context.Context, initialPrice math.LegacyDec, item, targetGoal sdk.Coin, vaultId uint64, + mintDenom string, ) (*types.Auction, error) { auctionId, err := k.AuctionIdSeq.Next(ctx) if err != nil { @@ -58,7 +63,7 @@ func (k Keeper) NewAuction(ctx context.Context, LastDiscountTime: startTime, Status: types.AuctionStatus_AUCTION_STATUS_ACTIVE, TargetGoal: targetGoal, - TokenRaised: sdk.NewCoin(vaultstypes.DefaultMintDenom, math.ZeroInt()), + TokenRaised: sdk.NewCoin(mintDenom, math.ZeroInt()), VaultId: vaultId, }, nil } diff --git a/x/auction/keeper/liquidate.go b/x/auction/keeper/liquidate.go new file mode 100644 index 00000000..bbbbb62e --- /dev/null +++ b/x/auction/keeper/liquidate.go @@ -0,0 +1,178 @@ +package keeper + +import ( + "context" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/onomyprotocol/reserve/x/auction/types" + vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" +) + +func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error { + // Implement the logic for handling liquidation + // This might include checking conditions, updating states, and logging events + params := k.GetParams(ctx) + currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time + + lastAuctionPeriods_unix, err := k.lastestAuctionPeriod.Get(ctx) + if err != nil { + return err + } + lastAuctionPeriods := time.Unix(lastAuctionPeriods_unix, 0) + // check if has reached the next auction periods + if lastAuctionPeriods.Add(params.AuctionPeriods).Before(currentTime) { + // update latest auction period + err := k.lastestAuctionPeriod.Set(ctx, lastAuctionPeriods.Add(params.AuctionPeriods).Unix()) + if err != nil { + return err + } + + liquidations, err := k.vaultKeeper.GetLiquidations(ctx, mintDenom) + if err != nil { + return err + } + + liquidatedVaults := make([]*vaultstypes.Vault, 0) + for _, liq := range liquidations { + liquidatedVaults = append(liquidatedVaults, liq.LiquidatingVaults...) + } + + // create new auction for this vault + for _, vault := range liquidatedVaults { + //calcualte initial price and target price + auction, isCreate, err := k.GetNewAuction(ctx, currentTime, vault.LiquidationPrice, vault.CollateralLocked, vault.Debt, vault.Id) + if err != nil { + return err + } + + if isCreate { + err = k.Auctions.Set(ctx, auction.AuctionId, *auction) + if err != nil { + return err + } + err = k.Bids.Set(ctx, auction.AuctionId, types.BidQueue{AuctionId: auction.AuctionId, Bids: []*types.Bid{}}) + if err != nil { + return err + } + err = k.BidIdSeq.Set(ctx, auction.AuctionId, 0) + if err != nil { + return err + } + } + if err != nil { + return err + } + } + } + + // loop through all auctions + // get liquidations data then distribute debt & collateral remain + liquidationMap, err := k.newLiquidateMap(ctx, mintDenom, params) + if err != nil { + return err + } + + // Loop through liquidationMap and liquidate + for _, liq := range liquidationMap { + err := k.vaultKeeper.Liquidate(ctx, *liq, mintDenom) + if err != nil { + return err + } + } + if err != nil { + return err + } + return nil +} + +// TODO: testing +// TODO: implement the logic for handling liquidation per mint denom +func (k Keeper) newLiquidateMap(ctx context.Context, mintDenom string, params types.Params) (map[string]*vaultstypes.Liquidation, error) { + // loop through all auctions + // get liquidations data then distribute debt & collateral remain + liquidationMap := make(map[string]*vaultstypes.Liquidation) + currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time + + err := k.Auctions.Walk(ctx, nil, func(auctionId uint64, auction types.Auction) (bool, error) { + bidQueue, err := k.Bids.Get(ctx, auction.AuctionId) + if err != nil { + return true, err + } + vault, err := k.vaultKeeper.GetVault(ctx, auction.VaultId) + if err != nil { + return true, err + } + + needCleanup := false + if auction.Status == types.AuctionStatus_AUCTION_STATUS_FINISHED || + auction.Status == types.AuctionStatus_AUCTION_STATUS_OUT_OF_COLLATHERAL || + auction.EndTime.Before(currentTime) { + liquidation_tmp, ok := liquidationMap[auction.Item.Denom] + if ok && liquidation_tmp != nil { + liquidation_tmp.Denom = auction.Item.Denom + liquidation_tmp.LiquidatingVaults = append(liquidation_tmp.LiquidatingVaults, &vault) + liquidation_tmp.VaultLiquidationStatus[vault.Id].Sold = liquidation_tmp.VaultLiquidationStatus[vault.Id].Sold.Add(auction.TokenRaised) + liquidation_tmp.VaultLiquidationStatus[vault.Id].RemainCollateral = liquidation_tmp.VaultLiquidationStatus[vault.Id].RemainCollateral.Add(auction.Item) + } else { + liquidation_tmp = &vaultstypes.Liquidation{ + Denom: auction.Item.Denom, + LiquidatingVaults: []*vaultstypes.Vault{&vault}, + VaultLiquidationStatus: make(map[uint64]*vaultstypes.VaultLiquidationStatus), + } + + liquidation_tmp.VaultLiquidationStatus[vault.Id] = &vaultstypes.VaultLiquidationStatus{ + Sold: auction.TokenRaised, + RemainCollateral: auction.Item, + } + liquidationMap[auction.Item.Denom] = liquidation_tmp + } + err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, vaultstypes.ModuleName, sdk.NewCoins(liquidationMap[auction.Item.Denom].VaultLiquidationStatus[vault.Id].Sold)) + if err != nil { + return true, err + } + + needCleanup = true + // skip other logic + } + + if needCleanup { + k.refundBidders(ctx, bidQueue) + + // clear the auction afterward + err = k.DeleteAuction(ctx, auction.AuctionId) + if err != nil { + return true, err + } + + return false, nil + } + + // check if reach next reduce step + if auction.LastDiscountTime.Add(params.ReduceStep).Before(currentTime) { + // get new discount rate + newRate, err := k.discountRate(auction, params) + if err != nil { + return true, err + } + + // apply new changes + auction.CurrentRate = newRate + auction.LastDiscountTime = auction.LastDiscountTime.Add(params.ReduceStep) + + // update new rate and last discount time + err = k.Auctions.Set(ctx, auctionId, auction) + if err != nil { + return true, err + } + } + + err = k.fillBids(ctx, auction, bidQueue) + if err != nil { + return true, err + } + + return false, nil + }) + return liquidationMap, err +} diff --git a/x/auction/types/expected_keepers.go b/x/auction/types/expected_keepers.go index 994ceebe..bc1509bb 100644 --- a/x/auction/types/expected_keepers.go +++ b/x/auction/types/expected_keepers.go @@ -43,9 +43,10 @@ type ParamSubspace interface { } type VaultKeeper interface { - GetLiquidations(ctx context.Context) ([]*vaulttypes.Liquidation, error) - Liquidate(ctx context.Context, liquidation vaulttypes.Liquidation) error + GetLiquidations(ctx context.Context, mintDenom string) ([]*vaulttypes.Liquidation, error) + Liquidate(ctx context.Context, liquidation vaulttypes.Liquidation, mintDenom string) error GetVault(ctx context.Context, vaultId uint64) (vaulttypes.Vault, error) + GetAllowedMintDenoms(ctx context.Context) []string } type OracleKeeper interface { diff --git a/x/vaults/keeper/keeper.go b/x/vaults/keeper/keeper.go index c99ff752..a951508b 100644 --- a/x/vaults/keeper/keeper.go +++ b/x/vaults/keeper/keeper.go @@ -156,3 +156,7 @@ func (k *Keeper) IsActived( has, _ := k.VaultsManager.Has(ctx, denom) return has } + +func (k *Keeper) GetAllowedMintDenoms(ctx context.Context) []string { + return k.GetParams(ctx).AllowedMintDenom +} diff --git a/x/vaults/keeper/keeper_test.go b/x/vaults/keeper/keeper_test.go index 8b2df65e..03fc3363 100644 --- a/x/vaults/keeper/keeper_test.go +++ b/x/vaults/keeper/keeper_test.go @@ -25,7 +25,7 @@ func (s *KeeperTestSuite) SetupTest() { mockOK := mock.NewMockOracleKeeper() mockOK.SetPrice("atom", math.LegacyMustNewDecFromStr("8.0")) - mockOK.SetPrice(types.DefaultMintDenom, math.LegacyMustNewDecFromStr("1")) + mockOK.SetPrice(types.DefaultMintDenom[0], math.LegacyMustNewDecFromStr("1")) s.App.VaultsKeeper.OracleKeeper = mockOK s.k = s.App.VaultsKeeper s.msgServer = keeper.NewMsgServerImpl(s.k) diff --git a/x/vaults/keeper/vault.go b/x/vaults/keeper/vault.go index 14a99704..219e2a49 100644 --- a/x/vaults/keeper/vault.go +++ b/x/vaults/keeper/vault.go @@ -38,7 +38,7 @@ func (k *Keeper) CreateNewVault( } // Calculate collateral ratio - price := k.OracleKeeper.GetPrice(ctx, denom, types.DefaultMintDenom) + price := k.OracleKeeper.GetPrice(ctx, denom, types.DefaultMintDenom[0]) // TODO: recalculate with denom decimal? collateralValue := math.LegacyNewDecFromInt(collateral.Amount).Mul(*price) ratio := collateralValue.QuoInt(mint.Amount) @@ -155,7 +155,7 @@ func (k *Keeper) MintCoin( } lockedCoin := vault.CollateralLocked - price := k.OracleKeeper.GetPrice(ctx, lockedCoin.Denom, types.DefaultMintDenom) + price := k.OracleKeeper.GetPrice(ctx, lockedCoin.Denom, types.DefaultMintDenom[0]) lockedValue := math.LegacyNewDecFromInt(lockedCoin.Amount).Mul(*price) feeAmount := math.LegacyNewDecFromInt(mint.Amount).Mul(vm.Params.MintingFee).TruncateInt() @@ -335,7 +335,7 @@ func (k *Keeper) WithdrawFromVault( } newLock := vault.CollateralLocked.Sub(collateral) - price := k.OracleKeeper.GetPrice(ctx, collateral.Denom, types.DefaultMintDenom) + price := k.OracleKeeper.GetPrice(ctx, collateral.Denom, types.DefaultMintDenom[0]) newLockValue := math.LegacyNewDecFromInt(newLock.Amount).Mul(*price) ratio := newLockValue.Quo(math.LegacyNewDecFromInt(vault.Debt.Amount)) @@ -427,8 +427,8 @@ func (k *Keeper) shouldLiquidate( func (k *Keeper) GetLiquidations( ctx context.Context, + mintDenom string, ) ([]*types.Liquidation, error) { - // denom to liquidationRatios liquidationRatios := make(map[string]math.LegacyDec) // denom to price @@ -437,7 +437,7 @@ func (k *Keeper) GetLiquidations( liquidations := make(map[string]*types.Liquidation) err := k.VaultsManager.Walk(ctx, nil, func(key string, vm types.VaultMamager) (bool, error) { - price := k.OracleKeeper.GetPrice(ctx, vm.Denom, types.DefaultMintDenom) + price := k.OracleKeeper.GetPrice(ctx, vm.Denom, mintDenom) prices[vm.Denom] = *price liquidationRatios[vm.Denom] = vm.Params.LiquidationRatio liquidations[vm.Denom] = types.NewEmptyLiquidation(vm.Denom) @@ -450,6 +450,10 @@ func (k *Keeper) GetLiquidations( err = k.Vaults.Walk(ctx, nil, func(id uint64, vault types.Vault) (bool, error) { denom := vault.CollateralLocked.Denom + if vault.Debt.Denom != mintDenom { + return false, nil + } + shouldLiquidate, err := k.shouldLiquidate(vault, prices[denom], liquidationRatios[denom]) if shouldLiquidate && err == nil { liquidations[denom].LiquidatingVaults = append(liquidations[denom].LiquidatingVaults, &vault) @@ -483,6 +487,7 @@ func (k *Keeper) GetLiquidations( func (k *Keeper) Liquidate( ctx context.Context, liquidation types.Liquidation, + mintDenom string, ) error { sdkCtx := sdk.UnwrapSDKContext(ctx) params := k.GetParams(ctx) @@ -627,7 +632,7 @@ func (k *Keeper) Liquidate( collateralRemain := liquidation.VaultLiquidationStatus[vault.Id].RemainCollateral.Amount penaltyAmount := math.LegacyNewDecFromInt(vault.Debt.Amount).Quo(vault.LiquidationPrice).Mul(vm.Params.LiquidationPenalty).TruncateInt() - // If remain collateral not enough for penalty, + // If collateral locked not enough for penalty, // transfer all and mark vault CLOSED if penaltyAmount.GT(collateralRemain) { soldAmount := liquidation.VaultLiquidationStatus[vault.Id].Sold.Amount diff --git a/x/vaults/keeper/vaults_test.go b/x/vaults/keeper/vaults_test.go index b62116de..15c8ec7d 100644 --- a/x/vaults/keeper/vaults_test.go +++ b/x/vaults/keeper/vaults_test.go @@ -29,7 +29,7 @@ func (s *KeeperTestSuite) TestCreateNewVault() { s.SetupTest() var ( denom = "atom" - mintDenom = types.DefaultMintDenom + mintDenom = types.DefaultMintDenom[0] collateral = sdk.NewCoin(denom, math.NewInt(10_000_000)) // 10 atom = 80$ maxDebt = math.NewInt(100_000_000) ) @@ -267,7 +267,7 @@ func (s *KeeperTestSuite) TestWithdrawFromVault() { func (s *KeeperTestSuite) TestLiquidate() { // s.SetupTest() - vaultOwnerAddr := sdk.AccAddress([]byte("addr1_______________")) + // vaultOwnerAddr := sdk.AccAddress([]byte("addr1_______________")) tests := []struct { name string @@ -458,8 +458,8 @@ func (s *KeeperTestSuite) TestLiquidate() { vault.Id = vaultId vault.Address = vaultAddr.String() - err := s.App.VaultsKeeper.SetVault(s.Ctx, *vault) - s.Require().NoError(err) + // err := s.App.VaultsKeeper.SetVault(s.Ctx, *vault) + // s.Require().NoError(err) // Fund collateral locked for vault lockCoins := sdk.NewCoins(t.liquidation.VaultLiquidationStatus[vaultId].RemainCollateral) diff --git a/x/vaults/types/params.go b/x/vaults/types/params.go index ac2505ca..9292db53 100644 --- a/x/vaults/types/params.go +++ b/x/vaults/types/params.go @@ -13,7 +13,8 @@ var ( DefaultLiquidationPenalty = math.LegacyMustNewDecFromStr("0.05") DefaultMinInitialDebt = math.NewInt(50_000_000) DefaultRecalculateDebtPeriod = time.Hour - DefaultMintDenom = "nomUSD" + DefaultLiquidatePeriod = time.Hour + DefaultMintDenom = []string{"nomUSD"} KeyMintingFee = []byte("MintingFee") KeyStabilityFee = []byte("StabilityFee") @@ -25,13 +26,13 @@ var ( // NewParams creates a new Params instance. func NewParams( minInitialDebt math.Int, - mintDenom string, + mintDenom []string, chargingPeriod time.Duration, ) Params { return Params{ - MinInitialDebt: minInitialDebt, - ChargingPeriod: chargingPeriod, - MintDenom: mintDenom, + MinInitialDebt: minInitialDebt, + ChargingPeriod: chargingPeriod, + AllowedMintDenom: mintDenom, } } diff --git a/x/vaults/types/params.pb.go b/x/vaults/types/params.pb.go index f7323cf5..99f4f342 100644 --- a/x/vaults/types/params.pb.go +++ b/x/vaults/types/params.pb.go @@ -78,9 +78,10 @@ func (VaultStatus) EnumDescriptor() ([]byte, []int) { // Params defines the parameters for the module. type Params struct { - MinInitialDebt cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=min_initial_debt,json=minInitialDebt,proto3,customtype=cosmossdk.io/math.Int" json:"min_initial_debt"` - MintDenom string `protobuf:"bytes,2,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` - ChargingPeriod time.Duration `protobuf:"bytes,3,opt,name=charging_period,json=chargingPeriod,proto3,stdduration" json:"charging_period"` + MinInitialDebt cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=min_initial_debt,json=minInitialDebt,proto3,customtype=cosmossdk.io/math.Int" json:"min_initial_debt"` + AllowedMintDenom []string `protobuf:"bytes,2,rep,name=allowed_mint_denom,json=allowedMintDenom,proto3" json:"allowed_mint_denom,omitempty"` + ChargingPeriod time.Duration `protobuf:"bytes,3,opt,name=charging_period,json=chargingPeriod,proto3,stdduration" json:"charging_period"` + LiquidatePeriod time.Duration `protobuf:"bytes,4,opt,name=liquidate_period,json=liquidatePeriod,proto3,stdduration" json:"liquidate_period"` } func (m *Params) Reset() { *m = Params{} } @@ -116,11 +117,11 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetMintDenom() string { +func (m *Params) GetAllowedMintDenom() []string { if m != nil { - return m.MintDenom + return m.AllowedMintDenom } - return "" + return nil } func (m *Params) GetChargingPeriod() time.Duration { @@ -132,12 +133,13 @@ func (m *Params) GetChargingPeriod() time.Duration { // VaultParams defines the parameters for each collateral vault type. type VaultMamagerParams struct { - MinCollateralRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=min_collateral_ratio,json=minCollateralRatio,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_collateral_ratio"` - LiquidationRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=liquidation_ratio,json=liquidationRatio,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_ratio"` - MaxDebt cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=max_debt,json=maxDebt,proto3,customtype=cosmossdk.io/math.Int" json:"max_debt"` - StabilityFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=stability_fee,json=stabilityFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"stability_fee"` - LiquidationPenalty cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=liquidation_penalty,json=liquidationPenalty,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_penalty"` - MintingFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=minting_fee,json=mintingFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"minting_fee"` + MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` + MinCollateralRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=min_collateral_ratio,json=minCollateralRatio,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_collateral_ratio"` + LiquidationRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=liquidation_ratio,json=liquidationRatio,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_ratio"` + MaxDebt cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=max_debt,json=maxDebt,proto3,customtype=cosmossdk.io/math.Int" json:"max_debt"` + StabilityFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=stability_fee,json=stabilityFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"stability_fee"` + LiquidationPenalty cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=liquidation_penalty,json=liquidationPenalty,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_penalty"` + MintingFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=minting_fee,json=mintingFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"minting_fee"` } func (m *VaultMamagerParams) Reset() { *m = VaultMamagerParams{} } @@ -173,6 +175,13 @@ func (m *VaultMamagerParams) XXX_DiscardUnknown() { var xxx_messageInfo_VaultMamagerParams proto.InternalMessageInfo +func (m *VaultMamagerParams) GetMintDenom() string { + if m != nil { + return m.MintDenom + } + return "" +} + // VaultMamager defines the manager of each collateral vault type. type VaultMamager struct { Params VaultMamagerParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` @@ -483,73 +492,76 @@ func init() { func init() { proto.RegisterFile("reserve/vaults/params.proto", fileDescriptor_1f12ab0d072f9f7c) } var fileDescriptor_1f12ab0d072f9f7c = []byte{ - // 1047 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcf, 0x4f, 0x1b, 0xc7, - 0x17, 0xf7, 0xda, 0xc6, 0x84, 0x67, 0x70, 0xcc, 0x7c, 0x09, 0x5f, 0xc7, 0xa8, 0xc6, 0xf2, 0xa1, - 0x42, 0x48, 0x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, 0xd6, - 0x4f, 0xce, 0x02, 0x75, 0xad, 0xfb, 0xe5, 0x56, 0xbb, 0x55, 0xce, 0x29, 0x54, 0x75, 0x42, 0x35, - 0x80, 0x04, 0xa2, 0xdd, 0x2a, 0xe7, 0xab, 0xa5, 0x83, 0xc3, 0x7a, 0xea, 0xa6, 0x9a, 0xff, 0xe6, - 0xc7, 0x5a, 0x66, 0xb5, 0xf3, 0xfc, 0xa8, 0x66, 0xbc, 0x3c, 0xaa, 0x19, 0x7f, 0x1c, 0xd5, 0x8c, - 0x27, 0xc7, 0xb5, 0xcc, 0xcb, 0xe3, 0x5a, 0xe6, 0xd7, 0xe3, 0x5a, 0xe6, 0x91, 0xe5, 0x51, 0xbe, - 0x33, 0xec, 0x9b, 0x0e, 0x0b, 0x2c, 0x16, 0xb2, 0x60, 0x2c, 0xd3, 0x76, 0x98, 0x6f, 0x9d, 0x7b, - 0xf4, 0xf9, 0x78, 0x40, 0xe2, 0x7e, 0x41, 0x2a, 0xdc, 0xfa, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x07, - 0x17, 0x0f, 0x8e, 0xc9, 0x09, 0x00, 0x00, + // 1095 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x4f, 0x1b, 0x47, + 0x14, 0xf7, 0xda, 0xc6, 0x84, 0x67, 0x30, 0x66, 0x4a, 0xa8, 0x63, 0x54, 0x63, 0xf9, 0x50, 0x21, + 0xd4, 0xec, 0x36, 0x8e, 0xd4, 0x46, 0x51, 0x7b, 0x00, 0x6c, 0x2a, 0x2b, 0x4e, 0x0a, 0x0b, 0x49, + 0xa4, 0xf4, 0x60, 0x8d, 0x77, 0x27, 0xcb, 0x88, 0xdd, 0x1d, 0xb3, 0x3b, 0x76, 0xf0, 0x37, 0xa8, + 0x38, 0xe5, 0xd8, 0x0b, 0x52, 0xff, 0xa8, 0x52, 0x8f, 0x39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, 0xba, 0x3c, 0x7d, 0x78, 0x54, 0x1d, + 0xad, 0x23, 0xd4, 0xf5, 0xf6, 0x97, 0xdb, 0xcd, 0x46, 0x31, 0x23, 0x51, 0xe5, 0x0a, 0x55, 0x00, + 0x62, 0x88, 0x66, 0xa3, 0x98, 0x2d, 0x17, 0x0e, 0x8f, 0xaa, 0x89, 0x9d, 0x72, 0xf6, 0xeb, 0x1f, + 0x2a, 0xa9, 0xb5, 0xd6, 0x8b, 0xe3, 0x8a, 0xf6, 0xf2, 0xb8, 0xa2, 0xfd, 0x79, 0x5c, 0xd1, 0x9e, + 0x9e, 0x54, 0x52, 0x2f, 0x4f, 0x2a, 0xa9, 0x5f, 0x4f, 0x2a, 0xa9, 0x47, 0x86, 0x43, 0xf9, 0x6e, + 0xbf, 0xab, 0x5b, 0xcc, 0x33, 0x98, 0xcf, 0xbc, 0xa1, 0x48, 0xdb, 0x62, 0xae, 0x71, 0xe6, 0x9b, + 0x80, 0x0f, 0x7b, 0x24, 0xec, 0xe6, 0x84, 0xc1, 0xcd, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2f, + 0xed, 0x5a, 0x7d, 0x4c, 0x0a, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -574,9 +586,14 @@ func (this *Params) Equal(that interface{}) bool { if !this.MinInitialDebt.Equal(that1.MinInitialDebt) { return false } - if this.MintDenom != that1.MintDenom { + if len(this.AllowedMintDenom) != len(that1.AllowedMintDenom) { return false } + for i := range this.AllowedMintDenom { + if this.AllowedMintDenom[i] != that1.AllowedMintDenom[i] { + return false + } + } if this.ChargingPeriod != that1.ChargingPeriod { return false } @@ -610,12 +627,14 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(n1)) i-- dAtA[i] = 0x1a - if len(m.MintDenom) > 0 { - i -= len(m.MintDenom) - copy(dAtA[i:], m.MintDenom) - i = encodeVarintParams(dAtA, i, uint64(len(m.MintDenom))) - i-- - dAtA[i] = 0x12 + if len(m.AllowedMintDenom) > 0 { + for iNdEx := len(m.AllowedMintDenom) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowedMintDenom[iNdEx]) + copy(dAtA[i:], m.AllowedMintDenom[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.AllowedMintDenom[iNdEx]))) + i-- + dAtA[i] = 0x12 + } } { size := m.MinInitialDebt.Size() @@ -659,7 +678,7 @@ func (m *VaultMamagerParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a { size := m.LiquidationPenalty.Size() i -= size @@ -669,7 +688,7 @@ func (m *VaultMamagerParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 { size := m.StabilityFee.Size() i -= size @@ -679,7 +698,7 @@ func (m *VaultMamagerParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a { size := m.MaxDebt.Size() i -= size @@ -689,7 +708,7 @@ func (m *VaultMamagerParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 { size := m.LiquidationRatio.Size() i -= size @@ -699,7 +718,7 @@ func (m *VaultMamagerParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a { size := m.MinCollateralRatio.Size() i -= size @@ -709,7 +728,14 @@ func (m *VaultMamagerParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintParams(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + if len(m.MintDenom) > 0 { + i -= len(m.MintDenom) + copy(dAtA[i:], m.MintDenom) + i = encodeVarintParams(dAtA, i, uint64(len(m.MintDenom))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -1001,9 +1027,11 @@ func (m *Params) Size() (n int) { _ = l l = m.MinInitialDebt.Size() n += 1 + l + sovParams(uint64(l)) - l = len(m.MintDenom) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) + if len(m.AllowedMintDenom) > 0 { + for _, s := range m.AllowedMintDenom { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } } l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.ChargingPeriod) n += 1 + l + sovParams(uint64(l)) @@ -1016,6 +1044,10 @@ func (m *VaultMamagerParams) Size() (n int) { } var l int _ = l + l = len(m.MintDenom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } l = m.MinCollateralRatio.Size() n += 1 + l + sovParams(uint64(l)) l = m.LiquidationRatio.Size() @@ -1204,7 +1236,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MintDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AllowedMintDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1232,7 +1264,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MintDenom = string(dAtA[iNdEx:postIndex]) + m.AllowedMintDenom = append(m.AllowedMintDenom, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 3: if wireType != 2 { @@ -1318,6 +1350,38 @@ func (m *VaultMamagerParams) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MintDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinCollateralRatio", wireType) } @@ -1351,7 +1415,7 @@ func (m *VaultMamagerParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LiquidationRatio", wireType) } @@ -1385,7 +1449,7 @@ func (m *VaultMamagerParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MaxDebt", wireType) } @@ -1419,7 +1483,7 @@ func (m *VaultMamagerParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StabilityFee", wireType) } @@ -1453,7 +1517,7 @@ func (m *VaultMamagerParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field LiquidationPenalty", wireType) } @@ -1487,7 +1551,7 @@ func (m *VaultMamagerParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MintingFee", wireType) } From 7f62acdaeb20c896922010d2bbd811cf0bebc7ed Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 1 Nov 2024 03:08:31 +0700 Subject: [PATCH 03/42] allow multiple mint denom in vault --- .../reserve/x/vaults/types/params.pb.go | 2576 ----------------- proto/reserve/vaults/params.proto | 4 +- x/auction/keeper/liquidate.go | 6 +- x/vaults/keeper/vault.go | 18 +- x/vaults/types/liquidation.go | 5 +- x/vaults/types/params.pb.go | 212 +- 6 files changed, 151 insertions(+), 2670 deletions(-) delete mode 100644 proto/github.com/onomyprotocol/reserve/x/vaults/types/params.pb.go diff --git a/proto/github.com/onomyprotocol/reserve/x/vaults/types/params.pb.go b/proto/github.com/onomyprotocol/reserve/x/vaults/types/params.pb.go deleted file mode 100644 index 0e266d35..00000000 --- a/proto/github.com/onomyprotocol/reserve/x/vaults/types/params.pb.go +++ /dev/null @@ -1,2576 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: reserve/vaults/params.proto - -package types - -import ( - cosmossdk_io_math "cosmossdk.io/math" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" - _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" - github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" - _ "google.golang.org/protobuf/types/known/durationpb" - _ "google.golang.org/protobuf/types/known/timestamppb" - io "io" - math "math" - math_bits "math/bits" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// VaultStatus is the status of a vault. -type VaultStatus int32 - -const ( - // ACTIVE - vault is in use and can be changed - ACTIVE VaultStatus = 0 - // LIQUIDATING - vault is being liquidated by the vault manager, and cannot be - // changed by the user. If liquidation fails, vaults may remain in this state. - // An upgrade might be able to recover them. - LIQUIDATING VaultStatus = 1 - // TRANSFER - vault is able to be transferred (payments and debits frozen - // until it has a new owner) - TRANSFER VaultStatus = 2 - // CLOSED - vault was closed by the user and all assets have been paid out - CLOSED VaultStatus = 3 - // LIQUIDATED - vault was closed by the manager, with remaining assets paid to - // owner - LIQUIDATED VaultStatus = 4 -) - -var VaultStatus_name = map[int32]string{ - 0: "ACTIVE", - 1: "LIQUIDATING", - 2: "TRANSFER", - 3: "CLOSED", - 4: "LIQUIDATED", -} - -var VaultStatus_value = map[string]int32{ - "ACTIVE": 0, - "LIQUIDATING": 1, - "TRANSFER": 2, - "CLOSED": 3, - "LIQUIDATED": 4, -} - -func (x VaultStatus) String() string { - return proto.EnumName(VaultStatus_name, int32(x)) -} - -func (VaultStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_1f12ab0d072f9f7c, []int{0} -} - -// Params defines the parameters for the module. -type Params struct { - MinInitialDebt cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=min_initial_debt,json=minInitialDebt,proto3,customtype=cosmossdk.io/math.Int" json:"min_initial_debt"` - AllowedMintDenom []string `protobuf:"bytes,2,rep,name=allowed_mint_denom,json=allowedMintDenom,proto3" json:"allowed_mint_denom,omitempty"` - ChargingPeriod time.Duration `protobuf:"bytes,3,opt,name=charging_period,json=chargingPeriod,proto3,stdduration" json:"charging_period"` - LiquidatePeriod time.Duration `protobuf:"bytes,4,opt,name=liquidate_period,json=liquidatePeriod,proto3,stdduration" json:"liquidate_period"` -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_1f12ab0d072f9f7c, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetAllowedMintDenom() []string { - if m != nil { - return m.AllowedMintDenom - } - return nil -} - -func (m *Params) GetChargingPeriod() time.Duration { - if m != nil { - return m.ChargingPeriod - } - return 0 -} - -func (m *Params) GetLiquidatePeriod() time.Duration { - if m != nil { - return m.LiquidatePeriod - } - return 0 -} - -// VaultParams defines the parameters for each collateral vault type. -type VaultMamagerParams struct { - MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` - MinCollateralRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=min_collateral_ratio,json=minCollateralRatio,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"min_collateral_ratio"` - LiquidationRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=liquidation_ratio,json=liquidationRatio,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_ratio"` - MaxDebt cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=max_debt,json=maxDebt,proto3,customtype=cosmossdk.io/math.Int" json:"max_debt"` - StabilityFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=stability_fee,json=stabilityFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"stability_fee"` - LiquidationPenalty cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=liquidation_penalty,json=liquidationPenalty,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_penalty"` - MintingFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=minting_fee,json=mintingFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"minting_fee"` -} - -func (m *VaultMamagerParams) Reset() { *m = VaultMamagerParams{} } -func (m *VaultMamagerParams) String() string { return proto.CompactTextString(m) } -func (*VaultMamagerParams) ProtoMessage() {} -func (*VaultMamagerParams) Descriptor() ([]byte, []int) { - return fileDescriptor_1f12ab0d072f9f7c, []int{1} -} -func (m *VaultMamagerParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VaultMamagerParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VaultMamagerParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *VaultMamagerParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_VaultMamagerParams.Merge(m, src) -} -func (m *VaultMamagerParams) XXX_Size() int { - return m.Size() -} -func (m *VaultMamagerParams) XXX_DiscardUnknown() { - xxx_messageInfo_VaultMamagerParams.DiscardUnknown(m) -} - -var xxx_messageInfo_VaultMamagerParams proto.InternalMessageInfo - -func (m *VaultMamagerParams) GetMintDenom() string { - if m != nil { - return m.MintDenom - } - return "" -} - -// VaultMamager defines the manager of each collateral vault type. -type VaultMamager struct { - Params VaultMamagerParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - MintAvailable cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=mint_available,json=mintAvailable,proto3,customtype=cosmossdk.io/math.Int" json:"mint_available"` -} - -func (m *VaultMamager) Reset() { *m = VaultMamager{} } -func (m *VaultMamager) String() string { return proto.CompactTextString(m) } -func (*VaultMamager) ProtoMessage() {} -func (*VaultMamager) Descriptor() ([]byte, []int) { - return fileDescriptor_1f12ab0d072f9f7c, []int{2} -} -func (m *VaultMamager) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VaultMamager) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VaultMamager.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *VaultMamager) XXX_Merge(src proto.Message) { - xxx_messageInfo_VaultMamager.Merge(m, src) -} -func (m *VaultMamager) XXX_Size() int { - return m.Size() -} -func (m *VaultMamager) XXX_DiscardUnknown() { - xxx_messageInfo_VaultMamager.DiscardUnknown(m) -} - -var xxx_messageInfo_VaultMamager proto.InternalMessageInfo - -func (m *VaultMamager) GetParams() VaultMamagerParams { - if m != nil { - return m.Params - } - return VaultMamagerParams{} -} - -func (m *VaultMamager) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -type Vault struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` - Debt types.Coin `protobuf:"bytes,3,opt,name=debt,proto3" json:"debt"` - CollateralLocked types.Coin `protobuf:"bytes,4,opt,name=collateral_locked,json=collateralLocked,proto3" json:"collateral_locked"` - Status VaultStatus `protobuf:"varint,5,opt,name=status,proto3,enum=reserve.vaults.VaultStatus" json:"status,omitempty"` - LiquidationPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=liquidation_price,json=liquidationPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidation_price"` - Address string `protobuf:"bytes,7,opt,name=address,proto3" json:"address,omitempty"` -} - -func (m *Vault) Reset() { *m = Vault{} } -func (m *Vault) String() string { return proto.CompactTextString(m) } -func (*Vault) ProtoMessage() {} -func (*Vault) Descriptor() ([]byte, []int) { - return fileDescriptor_1f12ab0d072f9f7c, []int{3} -} -func (m *Vault) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Vault) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Vault.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Vault) XXX_Merge(src proto.Message) { - xxx_messageInfo_Vault.Merge(m, src) -} -func (m *Vault) XXX_Size() int { - return m.Size() -} -func (m *Vault) XXX_DiscardUnknown() { - xxx_messageInfo_Vault.DiscardUnknown(m) -} - -var xxx_messageInfo_Vault proto.InternalMessageInfo - -func (m *Vault) GetId() uint64 { - if m != nil { - return m.Id - } - return 0 -} - -func (m *Vault) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} - -func (m *Vault) GetDebt() types.Coin { - if m != nil { - return m.Debt - } - return types.Coin{} -} - -func (m *Vault) GetCollateralLocked() types.Coin { - if m != nil { - return m.CollateralLocked - } - return types.Coin{} -} - -func (m *Vault) GetStatus() VaultStatus { - if m != nil { - return m.Status - } - return ACTIVE -} - -func (m *Vault) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -type VaultLiquidationStatus struct { - Sold types.Coin `protobuf:"bytes,4,opt,name=sold,proto3" json:"sold"` - RemainCollateral types.Coin `protobuf:"bytes,5,opt,name=remain_collateral,json=remainCollateral,proto3" json:"remain_collateral"` -} - -func (m *VaultLiquidationStatus) Reset() { *m = VaultLiquidationStatus{} } -func (m *VaultLiquidationStatus) String() string { return proto.CompactTextString(m) } -func (*VaultLiquidationStatus) ProtoMessage() {} -func (*VaultLiquidationStatus) Descriptor() ([]byte, []int) { - return fileDescriptor_1f12ab0d072f9f7c, []int{4} -} -func (m *VaultLiquidationStatus) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VaultLiquidationStatus) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VaultLiquidationStatus.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *VaultLiquidationStatus) XXX_Merge(src proto.Message) { - xxx_messageInfo_VaultLiquidationStatus.Merge(m, src) -} -func (m *VaultLiquidationStatus) XXX_Size() int { - return m.Size() -} -func (m *VaultLiquidationStatus) XXX_DiscardUnknown() { - xxx_messageInfo_VaultLiquidationStatus.DiscardUnknown(m) -} - -var xxx_messageInfo_VaultLiquidationStatus proto.InternalMessageInfo - -func (m *VaultLiquidationStatus) GetSold() types.Coin { - if m != nil { - return m.Sold - } - return types.Coin{} -} - -func (m *VaultLiquidationStatus) GetRemainCollateral() types.Coin { - if m != nil { - return m.RemainCollateral - } - return types.Coin{} -} - -type Liquidation struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - LiquidatingVaults []*Vault `protobuf:"bytes,3,rep,name=liquidating_vaults,json=liquidatingVaults,proto3" json:"liquidating_vaults,omitempty"` - VaultLiquidationStatus map[uint64]*VaultLiquidationStatus `protobuf:"bytes,4,rep,name=vault_liquidation_status,json=vaultLiquidationStatus,proto3" json:"vault_liquidation_status,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (m *Liquidation) Reset() { *m = Liquidation{} } -func (m *Liquidation) String() string { return proto.CompactTextString(m) } -func (*Liquidation) ProtoMessage() {} -func (*Liquidation) Descriptor() ([]byte, []int) { - return fileDescriptor_1f12ab0d072f9f7c, []int{5} -} -func (m *Liquidation) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Liquidation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Liquidation.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Liquidation) XXX_Merge(src proto.Message) { - xxx_messageInfo_Liquidation.Merge(m, src) -} -func (m *Liquidation) XXX_Size() int { - return m.Size() -} -func (m *Liquidation) XXX_DiscardUnknown() { - xxx_messageInfo_Liquidation.DiscardUnknown(m) -} - -var xxx_messageInfo_Liquidation proto.InternalMessageInfo - -func (m *Liquidation) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *Liquidation) GetLiquidatingVaults() []*Vault { - if m != nil { - return m.LiquidatingVaults - } - return nil -} - -func (m *Liquidation) GetVaultLiquidationStatus() map[uint64]*VaultLiquidationStatus { - if m != nil { - return m.VaultLiquidationStatus - } - return nil -} - -type LastUpdate struct { - Time time.Time `protobuf:"bytes,1,opt,name=time,proto3,stdtime" json:"time"` -} - -func (m *LastUpdate) Reset() { *m = LastUpdate{} } -func (m *LastUpdate) String() string { return proto.CompactTextString(m) } -func (*LastUpdate) ProtoMessage() {} -func (*LastUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_1f12ab0d072f9f7c, []int{6} -} -func (m *LastUpdate) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LastUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LastUpdate.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *LastUpdate) XXX_Merge(src proto.Message) { - xxx_messageInfo_LastUpdate.Merge(m, src) -} -func (m *LastUpdate) XXX_Size() int { - return m.Size() -} -func (m *LastUpdate) XXX_DiscardUnknown() { - xxx_messageInfo_LastUpdate.DiscardUnknown(m) -} - -var xxx_messageInfo_LastUpdate proto.InternalMessageInfo - -func (m *LastUpdate) GetTime() time.Time { - if m != nil { - return m.Time - } - return time.Time{} -} - -func init() { - proto.RegisterEnum("reserve.vaults.VaultStatus", VaultStatus_name, VaultStatus_value) - proto.RegisterType((*Params)(nil), "reserve.vaults.Params") - proto.RegisterType((*VaultMamagerParams)(nil), "reserve.vaults.VaultMamagerParams") - proto.RegisterType((*VaultMamager)(nil), "reserve.vaults.VaultMamager") - proto.RegisterType((*Vault)(nil), "reserve.vaults.Vault") - proto.RegisterType((*VaultLiquidationStatus)(nil), "reserve.vaults.VaultLiquidationStatus") - proto.RegisterType((*Liquidation)(nil), "reserve.vaults.Liquidation") - proto.RegisterMapType((map[uint64]*VaultLiquidationStatus)(nil), "reserve.vaults.Liquidation.VaultLiquidationStatusEntry") - proto.RegisterType((*LastUpdate)(nil), "reserve.vaults.LastUpdate") -} - -func init() { proto.RegisterFile("reserve/vaults/params.proto", fileDescriptor_1f12ab0d072f9f7c) } - -var fileDescriptor_1f12ab0d072f9f7c = []byte{ - // 1095 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x4f, 0x1b, 0x47, - 0x14, 0xf7, 0xda, 0xc6, 0x84, 0x67, 0x30, 0x66, 0x4a, 0xa8, 0x63, 0x54, 0x63, 0xf9, 0x50, 0x21, - 0xd4, 0xec, 0x36, 0x8e, 0xd4, 0x46, 0x51, 0x7b, 0x00, 0x6c, 0x2a, 0x2b, 0x4e, 0x0a, 0x0b, 0x49, - 0xa4, 0xf4, 0x60, 0x8d, 0x77, 0x27, 0xcb, 0x88, 0xdd, 0x1d, 0xb3, 0x3b, 0x76, 0xf0, 0x37, 0xa8, - 0x38, 0xe5, 0xd8, 0x0b, 0x52, 0xff, 0xa8, 0x52, 0x8f, 0x39, 0xe4, 0x23, 0xf4, 0x90, 0x5b, 0xa3, - 0x9c, 0xaa, 0xaa, 0x4a, 0x2b, 0x38, 0xa4, 0xa7, 0x7e, 0x86, 0x6a, 0x67, 0x66, 0xed, 0x0d, 0xd0, - 0x2a, 0x94, 0x8b, 0xe5, 0x99, 0x79, 0xef, 0x37, 0xef, 0xfd, 0xde, 0xef, 0xbd, 0x59, 0x58, 0x0c, - 0x48, 0x48, 0x82, 0x01, 0x31, 0x06, 0xb8, 0xef, 0xf2, 0xd0, 0xe8, 0xe1, 0x00, 0x7b, 0xa1, 0xde, - 0x0b, 0x18, 0x67, 0xa8, 0xa0, 0x0e, 0x75, 0x79, 0x58, 0x9e, 0x77, 0x98, 0xc3, 0xc4, 0x91, 0x11, - 0xfd, 0x93, 0x56, 0xe5, 0x39, 0xec, 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 0x76, 0x1e, 0x13, 0x52, 0x9a, 0xb8, 0x54, 0xb4, 0xd3, 0x23, 0xb0, 0x0d, 0x42, 0x90, 0x03, - 0xef, 0x25, 0xe9, 0xe8, 0x11, 0x1f, 0xbb, 0x7c, 0x58, 0xca, 0x5d, 0x8e, 0xf7, 0x04, 0xe4, 0xa6, - 0x44, 0x44, 0x0f, 0x21, 0x1f, 0x95, 0x3b, 0x12, 0x78, 0x94, 0xc3, 0xe4, 0xa5, 0x2e, 0x00, 0x05, - 0xb5, 0x41, 0x48, 0xed, 0x67, 0x0d, 0xa6, 0x93, 0x82, 0x43, 0x4d, 0xc8, 0xc9, 0x29, 0x25, 0x64, - 0x96, 0xaf, 0xd7, 0xf4, 0xb7, 0xc7, 0x94, 0x7e, 0x56, 0x9e, 0x6b, 0x53, 0x51, 0x20, 0x12, 0x5b, - 0x39, 0xa3, 0x79, 0x98, 0x88, 0x7b, 0x36, 0x12, 0xab, 0x5c, 0xa0, 0x87, 0x50, 0x10, 0x3a, 0xc6, - 0x03, 0x4c, 0x5d, 0xdc, 0x75, 0x89, 0xd2, 0xce, 0xc5, 0xeb, 0x3b, 0x13, 0xe1, 0xac, 0xc6, 0x30, - 0xb5, 0xef, 0x33, 0x30, 0x21, 0x02, 0x43, 0x05, 0x48, 0x53, 0x5b, 0xc4, 0x9e, 0x35, 0xd3, 0xd4, - 0x46, 0x3a, 0x4c, 0xb0, 0x27, 0x3e, 0x09, 0x54, 0x33, 0x94, 0x5e, 0x3d, 0xbf, 0x3e, 0xaf, 0xc0, - 0x56, 0x6d, 0x3b, 0x20, 0x61, 0xb8, 0xcd, 0x03, 0xea, 0x3b, 0xa6, 0x34, 0x43, 0xb7, 0x20, 0x2b, - 0x84, 0x17, 0x0f, 0x10, 0x65, 0x1b, 0xcd, 0x5a, 0x5d, 0xcd, 0x5a, 0x7d, 0x9d, 0x51, 0x3f, 0x99, - 0xb4, 0xf0, 0x40, 0x5b, 0x30, 0x97, 0xe8, 0x40, 0x97, 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 0x33, 0x98, 0xcf, 0xbc, 0xa1, 0x48, 0xdb, 0x62, 0xae, 0x71, 0xe6, 0x9b, - 0x80, 0x0f, 0x7b, 0x24, 0xec, 0xe6, 0x84, 0xc1, 0xcd, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2f, - 0xed, 0x5a, 0x7d, 0x4c, 0x0a, 0x00, 0x00, -} - -func (this *Params) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Params) - if !ok { - that2, ok := that.(Params) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.MinInitialDebt.Equal(that1.MinInitialDebt) { - return false - } - if len(this.AllowedMintDenom) != len(that1.AllowedMintDenom) { - return false - } - for i := range this.AllowedMintDenom { - if this.AllowedMintDenom[i] != that1.AllowedMintDenom[i] { - return false - } - } - if this.ChargingPeriod != that1.ChargingPeriod { - return false - } - if this.LiquidatePeriod != that1.LiquidatePeriod { - return false - } - return true -} -func (m *Params) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n1, err1 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.LiquidatePeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.LiquidatePeriod):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintParams(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x22 - n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.ChargingPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.ChargingPeriod):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintParams(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x1a - if len(m.AllowedMintDenom) > 0 { - for iNdEx := len(m.AllowedMintDenom) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.AllowedMintDenom[iNdEx]) - copy(dAtA[i:], m.AllowedMintDenom[iNdEx]) - i = encodeVarintParams(dAtA, i, uint64(len(m.AllowedMintDenom[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - { - size := m.MinInitialDebt.Size() - i -= size - if _, err := m.MinInitialDebt.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *VaultMamagerParams) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *VaultMamagerParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VaultMamagerParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.MintingFee.Size() - i -= size - if _, err := m.MintingFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - { - size := m.LiquidationPenalty.Size() - i -= size - if _, err := m.LiquidationPenalty.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size := m.StabilityFee.Size() - i -= size - if _, err := m.StabilityFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.MaxDebt.Size() - i -= size - if _, err := m.MaxDebt.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.LiquidationRatio.Size() - i -= size - if _, err := m.LiquidationRatio.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.MinCollateralRatio.Size() - i -= size - if _, err := m.MinCollateralRatio.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if len(m.MintDenom) > 0 { - i -= len(m.MintDenom) - copy(dAtA[i:], m.MintDenom) - i = encodeVarintParams(dAtA, i, uint64(len(m.MintDenom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *VaultMamager) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *VaultMamager) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VaultMamager) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.MintAvailable.Size() - i -= size - if _, err := m.MintAvailable.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintParams(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0x12 - } - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Vault) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Vault) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintParams(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0x3a - } - { - size := m.LiquidationPrice.Size() - i -= size - if _, err := m.LiquidationPrice.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - if m.Status != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x28 - } - { - size, err := m.CollateralLocked.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size, err := m.Debt.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.Owner) > 0 { - i -= len(m.Owner) - copy(dAtA[i:], m.Owner) - i = encodeVarintParams(dAtA, i, uint64(len(m.Owner))) - i-- - dAtA[i] = 0x12 - } - if m.Id != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *VaultLiquidationStatus) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *VaultLiquidationStatus) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VaultLiquidationStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.RemainCollateral.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size, err := m.Sold.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - return len(dAtA) - i, nil -} - -func (m *Liquidation) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Liquidation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Liquidation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.VaultLiquidationStatus) > 0 { - for k := range m.VaultLiquidationStatus { - v := m.VaultLiquidationStatus[k] - baseI := i - if v != nil { - { - size, err := v.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - i = encodeVarintParams(dAtA, i, uint64(k)) - i-- - dAtA[i] = 0x8 - i = encodeVarintParams(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x22 - } - } - if len(m.LiquidatingVaults) > 0 { - for iNdEx := len(m.LiquidatingVaults) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LiquidatingVaults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintParams(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *LastUpdate) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *LastUpdate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LastUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n9, err9 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time):]) - if err9 != nil { - return 0, err9 - } - i -= n9 - i = encodeVarintParams(dAtA, i, uint64(n9)) - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.MinInitialDebt.Size() - n += 1 + l + sovParams(uint64(l)) - if len(m.AllowedMintDenom) > 0 { - for _, s := range m.AllowedMintDenom { - l = len(s) - n += 1 + l + sovParams(uint64(l)) - } - } - l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.ChargingPeriod) - n += 1 + l + sovParams(uint64(l)) - l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.LiquidatePeriod) - n += 1 + l + sovParams(uint64(l)) - return n -} - -func (m *VaultMamagerParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.MintDenom) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = m.MinCollateralRatio.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.LiquidationRatio.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.MaxDebt.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.StabilityFee.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.LiquidationPenalty.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.MintingFee.Size() - n += 1 + l + sovParams(uint64(l)) - return n -} - -func (m *VaultMamager) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovParams(uint64(l)) - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = m.MintAvailable.Size() - n += 1 + l + sovParams(uint64(l)) - return n -} - -func (m *Vault) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovParams(uint64(m.Id)) - } - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = m.Debt.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.CollateralLocked.Size() - n += 1 + l + sovParams(uint64(l)) - if m.Status != 0 { - n += 1 + sovParams(uint64(m.Status)) - } - l = m.LiquidationPrice.Size() - n += 1 + l + sovParams(uint64(l)) - l = len(m.Address) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - return n -} - -func (m *VaultLiquidationStatus) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Sold.Size() - n += 1 + l + sovParams(uint64(l)) - l = m.RemainCollateral.Size() - n += 1 + l + sovParams(uint64(l)) - return n -} - -func (m *Liquidation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - if len(m.LiquidatingVaults) > 0 { - for _, e := range m.LiquidatingVaults { - l = e.Size() - n += 1 + l + sovParams(uint64(l)) - } - } - if len(m.VaultLiquidationStatus) > 0 { - for k, v := range m.VaultLiquidationStatus { - _ = k - _ = v - l = 0 - if v != nil { - l = v.Size() - l += 1 + sovParams(uint64(l)) - } - mapEntrySize := 1 + sovParams(uint64(k)) + l - n += mapEntrySize + 1 + sovParams(uint64(mapEntrySize)) - } - } - return n -} - -func (m *LastUpdate) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.Time) - n += 1 + l + sovParams(uint64(l)) - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinInitialDebt", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinInitialDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AllowedMintDenom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AllowedMintDenom = append(m.AllowedMintDenom, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChargingPeriod", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.ChargingPeriod, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidatePeriod", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.LiquidatePeriod, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *VaultMamagerParams) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: VaultMamagerParams: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VaultMamagerParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MintDenom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MintDenom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinCollateralRatio", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinCollateralRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidationRatio", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LiquidationRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxDebt", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxDebt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StabilityFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.StabilityFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidationPenalty", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LiquidationPenalty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MintingFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MintingFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *VaultMamager) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: VaultMamager: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VaultMamager: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MintAvailable", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MintAvailable.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Vault) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Vault: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Vault: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Debt", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Debt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CollateralLocked", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CollateralLocked.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= VaultStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidationPrice", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LiquidationPrice.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *VaultLiquidationStatus) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: VaultLiquidationStatus: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VaultLiquidationStatus: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sold", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Sold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RemainCollateral", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RemainCollateral.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Liquidation) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Liquidation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Liquidation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidatingVaults", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LiquidatingVaults = append(m.LiquidatingVaults, &Vault{}) - if err := m.LiquidatingVaults[len(m.LiquidatingVaults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VaultLiquidationStatus", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.VaultLiquidationStatus == nil { - m.VaultLiquidationStatus = make(map[uint64]*VaultLiquidationStatus) - } - var mapkey uint64 - var mapvalue *VaultLiquidationStatus - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthParams - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthParams - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &VaultLiquidationStatus{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.VaultLiquidationStatus[mapkey] = mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LastUpdate) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LastUpdate: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LastUpdate: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.Time, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/proto/reserve/vaults/params.proto b/proto/reserve/vaults/params.proto index 1ad8ea69..aae3ec31 100644 --- a/proto/reserve/vaults/params.proto +++ b/proto/reserve/vaults/params.proto @@ -144,7 +144,9 @@ message VaultLiquidationStatus { } message Liquidation { - string denom = 1; + string debt_denom = 1; + + string mint_denom = 2; repeated Vault liquidating_vaults = 3; diff --git a/x/auction/keeper/liquidate.go b/x/auction/keeper/liquidate.go index bbbbb62e..70a45704 100644 --- a/x/auction/keeper/liquidate.go +++ b/x/auction/keeper/liquidate.go @@ -110,13 +110,15 @@ func (k Keeper) newLiquidateMap(ctx context.Context, mintDenom string, params ty auction.EndTime.Before(currentTime) { liquidation_tmp, ok := liquidationMap[auction.Item.Denom] if ok && liquidation_tmp != nil { - liquidation_tmp.Denom = auction.Item.Denom + liquidation_tmp.DebtDenom = auction.Item.Denom + liquidation_tmp.DebtDenom = mintDenom liquidation_tmp.LiquidatingVaults = append(liquidation_tmp.LiquidatingVaults, &vault) liquidation_tmp.VaultLiquidationStatus[vault.Id].Sold = liquidation_tmp.VaultLiquidationStatus[vault.Id].Sold.Add(auction.TokenRaised) liquidation_tmp.VaultLiquidationStatus[vault.Id].RemainCollateral = liquidation_tmp.VaultLiquidationStatus[vault.Id].RemainCollateral.Add(auction.Item) } else { liquidation_tmp = &vaultstypes.Liquidation{ - Denom: auction.Item.Denom, + MintDenom: mintDenom, + DebtDenom: auction.Item.Denom, LiquidatingVaults: []*vaultstypes.Vault{&vault}, VaultLiquidationStatus: make(map[uint64]*vaultstypes.VaultLiquidationStatus), } diff --git a/x/vaults/keeper/vault.go b/x/vaults/keeper/vault.go index 219e2a49..9d47115a 100644 --- a/x/vaults/keeper/vault.go +++ b/x/vaults/keeper/vault.go @@ -425,6 +425,7 @@ func (k *Keeper) shouldLiquidate( return false, nil } +// GetLiquidations return all liquidations for mint denom and change the potentially liquidated vaults vault status to LIQUIDATING func (k *Keeper) GetLiquidations( ctx context.Context, mintDenom string, @@ -440,7 +441,7 @@ func (k *Keeper) GetLiquidations( price := k.OracleKeeper.GetPrice(ctx, vm.Denom, mintDenom) prices[vm.Denom] = *price liquidationRatios[vm.Denom] = vm.Params.LiquidationRatio - liquidations[vm.Denom] = types.NewEmptyLiquidation(vm.Denom) + liquidations[vm.Denom] = types.NewEmptyLiquidation(vm.Denom, mintDenom) return false, nil }) @@ -490,17 +491,16 @@ func (k *Keeper) Liquidate( mintDenom string, ) error { sdkCtx := sdk.UnwrapSDKContext(ctx) - params := k.GetParams(ctx) - vm, err := k.GetVaultManager(ctx, liquidation.Denom) + vm, err := k.GetVaultManager(ctx, liquidation.DebtDenom) if err != nil { return err } vaultIds := "" - totalDebt := sdk.NewCoin(params.MintDenom, math.ZeroInt()) - sold := sdk.NewCoin(params.MintDenom, math.ZeroInt()) - totalCollateralRemain := sdk.NewCoin(liquidation.Denom, math.ZeroInt()) + totalDebt := sdk.NewCoin(mintDenom, math.ZeroInt()) + sold := sdk.NewCoin(mintDenom, math.ZeroInt()) + totalCollateralRemain := sdk.NewCoin(liquidation.DebtDenom, math.ZeroInt()) for _, vault := range liquidation.LiquidatingVaults { vaultIds = vaultIds + fmt.Sprintf("%d, ", vault.Id) @@ -529,7 +529,7 @@ func (k *Keeper) Liquidate( } // Increase mint available vm.MintAvailable = vm.MintAvailable.Add(totalDebt.Amount) - err = k.VaultsManager.Set(ctx, liquidation.Denom, vm) + err = k.VaultsManager.Set(ctx, liquidation.DebtDenom, vm) if err != nil { return err } @@ -582,7 +582,7 @@ func (k *Keeper) Liquidate( } // Increase mint available vm.MintAvailable = vm.MintAvailable.Add(sold.Amount) - err = k.VaultsManager.Set(ctx, liquidation.Denom, vm) + err = k.VaultsManager.Set(ctx, liquidation.DebtDenom, vm) if err != nil { return err } @@ -644,7 +644,7 @@ func (k *Keeper) Liquidate( penaltyAmount = collateralRemain vault.Status = types.CLOSED } - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ReserveModuleName, sdk.NewCoins(sdk.NewCoin(liquidation.Denom, penaltyAmount))) + err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, types.ReserveModuleName, sdk.NewCoins(sdk.NewCoin(liquidation.DebtDenom, penaltyAmount))) if err != nil { return err } diff --git a/x/vaults/types/liquidation.go b/x/vaults/types/liquidation.go index e1d22c98..22fa27af 100644 --- a/x/vaults/types/liquidation.go +++ b/x/vaults/types/liquidation.go @@ -2,9 +2,10 @@ package types // this line is used by starport scaffolding # 1 -func NewEmptyLiquidation(denom string) *Liquidation { +func NewEmptyLiquidation(debtDenom, mintDenom string) *Liquidation { return &Liquidation{ - Denom: denom, + DebtDenom: debtDenom, + MintDenom: mintDenom, LiquidatingVaults: []*Vault{}, VaultLiquidationStatus: make(map[uint64]*VaultLiquidationStatus), } diff --git a/x/vaults/types/params.pb.go b/x/vaults/types/params.pb.go index 99f4f342..7f9c89c8 100644 --- a/x/vaults/types/params.pb.go +++ b/x/vaults/types/params.pb.go @@ -374,7 +374,8 @@ func (m *VaultLiquidationStatus) GetRemainCollateral() types.Coin { } type Liquidation struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` + DebtDenom string `protobuf:"bytes,1,opt,name=debt_denom,json=debtDenom,proto3" json:"debt_denom,omitempty"` + MintDenom string `protobuf:"bytes,2,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` LiquidatingVaults []*Vault `protobuf:"bytes,3,rep,name=liquidating_vaults,json=liquidatingVaults,proto3" json:"liquidating_vaults,omitempty"` VaultLiquidationStatus map[uint64]*VaultLiquidationStatus `protobuf:"bytes,4,rep,name=vault_liquidation_status,json=vaultLiquidationStatus,proto3" json:"vault_liquidation_status,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } @@ -412,9 +413,16 @@ func (m *Liquidation) XXX_DiscardUnknown() { var xxx_messageInfo_Liquidation proto.InternalMessageInfo -func (m *Liquidation) GetDenom() string { +func (m *Liquidation) GetDebtDenom() string { if m != nil { - return m.Denom + return m.DebtDenom + } + return "" +} + +func (m *Liquidation) GetMintDenom() string { + if m != nil { + return m.MintDenom } return "" } @@ -492,76 +500,77 @@ func init() { func init() { proto.RegisterFile("reserve/vaults/params.proto", fileDescriptor_1f12ab0d072f9f7c) } var fileDescriptor_1f12ab0d072f9f7c = []byte{ - // 1095 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x4f, 0x1b, 0x47, - 0x14, 0xf7, 0xda, 0xc6, 0x84, 0x67, 0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1, 0x7b, 0xb4, 0x00, 0xb9, 0xd5, 0xf5, 0x9d, 0xd6, 0x83, - 0x66, 0x31, 0x55, 0x86, 0xc3, 0xa3, 0xaa, 0x5a, 0xa1, 0x2a, 0xe4, 0xdb, 0xad, 0xad, 0xfb, 0xad, - 0xc6, 0xea, 0x4e, 0xeb, 0xde, 0x17, 0x45, 0xad, 0x3c, 0x7b, 0x78, 0x54, 0x4d, 0x6e, 0xa1, 0x32, - 0x5c, 0xd9, 0x31, 0x57, 0xef, 0x6d, 0x6f, 0x34, 0xcd, 0x62, 0xba, 0x3c, 0x7d, 0x78, 0x54, 0x1d, - 0xad, 0x23, 0xd4, 0xf5, 0xf6, 0x97, 0xdb, 0xcd, 0x46, 0x31, 0x23, 0x51, 0xe5, 0x0a, 0x55, 0x00, - 0x62, 0x88, 0x66, 0xa3, 0x98, 0x2d, 0x17, 0x0e, 0x8f, 0xaa, 0x89, 0x9d, 0x72, 0xf6, 0xeb, 0x1f, - 0x2a, 0xa9, 0xb5, 0xd6, 0x8b, 0xe3, 0x8a, 0xf6, 0xf2, 0xb8, 0xa2, 0xfd, 0x79, 0x5c, 0xd1, 0x9e, - 0x9e, 0x54, 0x52, 0x2f, 0x4f, 0x2a, 0xa9, 0x5f, 0x4f, 0x2a, 0xa9, 0x47, 0x86, 0x43, 0xf9, 0x6e, - 0xbf, 0xab, 0x5b, 0xcc, 0x33, 0x98, 0xcf, 0xbc, 0xa1, 0x48, 0xdb, 0x62, 0xae, 0x71, 0xe6, 0x9b, - 0x80, 0x0f, 0x7b, 0x24, 0xec, 0xe6, 0x84, 0xc1, 0xcd, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x2f, - 0xed, 0x5a, 0x7d, 0x4c, 0x0a, 0x00, 0x00, + // 1107 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x3b, 0x6f, 0x1b, 0x47, + 0x10, 0xe6, 0x91, 0x14, 0x6d, 0x0d, 0x6d, 0x8a, 0xda, 0xc8, 0x0a, 0x4d, 0x21, 0x14, 0xc1, 0x22, + 0x10, 0x84, 0xf8, 0x2e, 0xa6, 0x81, 0xc4, 0x30, 0x92, 0x42, 0x12, 0xa9, 0x80, 0x30, 0xed, 0x48, + 0x27, 0xd9, 0x06, 0x9c, 0x82, 0x58, 0x1e, 0xd7, 0xa7, 0x85, 0xee, 0x6e, 0xa9, 0xbb, 0x25, 0x2d, + 0xfe, 0x83, 0x40, 0x95, 0xcb, 0x34, 0x02, 0xf2, 0x40, 0x80, 0x94, 0x2e, 0xfc, 0x13, 0x52, 0xb8, + 0x34, 0x5c, 0x05, 0x41, 0xe0, 0x04, 0x52, 0xe1, 0x54, 0x69, 0xd3, 0x06, 0xfb, 0x38, 0xea, 0xf4, + 0x48, 0x60, 0x45, 0x0d, 0xc1, 0xdd, 0x9d, 0xf9, 0x76, 0xe6, 0x9b, 0x6f, 0x66, 0x0f, 0xe6, 0x42, + 0x12, 0x91, 0x70, 0x48, 0xac, 0x21, 0x1e, 0x78, 0x3c, 0xb2, 0xfa, 0x38, 0xc4, 0x7e, 0x64, 0xf6, + 0x43, 0xc6, 0x19, 0x2a, 0xe8, 0x43, 0x53, 0x1d, 0x96, 0x67, 0x5c, 0xe6, 0x32, 0x79, 0x64, 0x89, + 0x7f, 0xca, 0xaa, 0x3c, 0x8d, 0x7d, 0x1a, 0x30, 0x4b, 0xfe, 0xea, 0xad, 0x8a, 0xc3, 0x22, 0x9f, + 0x45, 0x56, 0x17, 0x47, 0xc4, 0x1a, 0xde, 0xec, 0x12, 0x8e, 0x6f, 0x5a, 0x0e, 0xa3, 0x81, 0x3e, + 0xbf, 0xae, 0xce, 0x3b, 0x0a, 0x4b, 0x2d, 0x62, 0x57, 0x97, 0x31, 0xd7, 0x23, 0x96, 0x5c, 0x75, + 0x07, 0x4f, 0xac, 0xde, 0x20, 0xc4, 0x9c, 0xb2, 0xd8, 0x75,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0x53, 0xfd, + 0xf3, 0xdb, 0x79, 0x63, 0xef, 0xed, 0xf3, 0xc5, 0xf7, 0x63, 0x5d, 0xec, 0xc6, 0xca, 0x50, 0x9c, + 0xd6, 0xfe, 0xca, 0x02, 0x7a, 0x28, 0x76, 0xee, 0x61, 0x1f, 0xbb, 0x24, 0xd4, 0x54, 0x7f, 0x00, + 0x90, 0xa0, 0x41, 0x92, 0x6c, 0x4f, 0xfa, 0xe3, 0xfc, 0xb7, 0x60, 0x46, 0x54, 0xc2, 0x61, 0x9e, + 0x87, 0x39, 0x09, 0xb1, 0xd7, 0x91, 0x01, 0x95, 0xd2, 0xb2, 0x1a, 0x9f, 0xe8, 0x6a, 0xcc, 0x9d, + 0xae, 0x46, 0x9b, 0xb8, 0xd8, 0x19, 0x35, 0x88, 0x93, 0xa8, 0x49, 0x83, 0x38, 0x2a, 0x7c, 0xe4, + 0xd3, 0x60, 0x65, 0x0c, 0x69, 0x0b, 0x44, 0xe4, 0xc0, 0x74, 0x9c, 0x14, 0x65, 0x81, 0xbe, 0x26, + 0x73, 0xa1, 0x6b, 0x8a, 0x09, 0x40, 0x75, 0xc9, 0x5d, 0xb8, 0xec, 0xe3, 0x5d, 0x25, 0xa8, 0xec, + 0xff, 0x14, 0xd4, 0x25, 0x1f, 0xef, 0x4a, 0x25, 0x7d, 0x05, 0x57, 0x23, 0x8e, 0xbb, 0xd4, 0xa3, + 0x7c, 0xd4, 0x79, 0x42, 0x48, 0x69, 0xe2, 0x42, 0xd1, 0x5e, 0x19, 0x83, 0xad, 0x12, 0x82, 0x5c, + 0x78, 0x2f, 0x49, 0x47, 0x9f, 0x04, 0xd8, 0xe3, 0xa3, 0x52, 0xee, 0x62, 0xbc, 0x27, 0x20, 0xd7, + 0x14, 0x22, 0x7a, 0x04, 0x79, 0x51, 0x6e, 0x21, 0x70, 0x91, 0xc3, 0xa5, 0x0b, 0x5d, 0x00, 0x1a, + 0x6a, 0x95, 0x90, 0xda, 0xcf, 0x06, 0x5c, 0x49, 0x0a, 0x0e, 0x35, 0x21, 0xa7, 0xa6, 0x94, 0x94, + 0x59, 0xbe, 0x5e, 0x33, 0x8f, 0x8f, 0x29, 0xf3, 0xb4, 0x3c, 0x97, 0x27, 0x45, 0x20, 0x0a, 0x5b, + 0x3b, 0xa3, 0x19, 0x98, 0x88, 0x7b, 0x56, 0x88, 0x55, 0x2d, 0xd0, 0x23, 0x28, 0x48, 0x1d, 0xe3, + 0x21, 0xa6, 0x1e, 0xee, 0x7a, 0x44, 0x6b, 0xe7, 0xfc, 0xf5, 0xbd, 0x2a, 0x70, 0x96, 0x62, 0x98, + 0xda, 0xf7, 0x19, 0x98, 0x90, 0x81, 0xa1, 0x02, 0xa4, 0x69, 0x4f, 0xc6, 0x9e, 0xb5, 0xd3, 0xb4, + 0x87, 0x4c, 0x98, 0x60, 0x4f, 0x03, 0x12, 0xea, 0x66, 0x28, 0xbd, 0x7e, 0x71, 0x63, 0x46, 0x83, + 0x2d, 0xf5, 0x7a, 0x21, 0x89, 0xa2, 0x0d, 0x1e, 0xd2, 0xc0, 0xb5, 0x95, 0x19, 0xba, 0x0d, 0x59, + 0x29, 0xbc, 0x78, 0x80, 0x68, 0x5b, 0x31, 0x6b, 0x4d, 0x3d, 0x6b, 0xcd, 0x15, 0x46, 0x83, 0x64, + 0xd2, 0xd2, 0x03, 0xad, 0xc3, 0x74, 0xa2, 0x03, 0x3d, 0xe6, 0x6c, 0x93, 0xa3, 0x99, 0xf1, 0x2e, + 0x30, 0xc5, 0x23, 0xf7, 0xb6, 0xf4, 0x46, 0xb7, 0x20, 0x17, 0x71, 0xcc, 0x07, 0x91, 0x54, 0x6d, + 0xa1, 0x3e, 0x77, 0x66, 0x31, 0x36, 0xa4, 0x89, 0xad, 0x4d, 0x4f, 0xf6, 0x68, 0x3f, 0xa4, 0x0e, + 0xb9, 0xa0, 0x24, 0x93, 0x3d, 0xba, 0x26, 0xf0, 0x50, 0x1d, 0x2e, 0x61, 0x45, 0x9f, 0x16,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 0xfe, 0x36, 0x51, 0x0f, 0xef, 0xb3, 0xf1, 0xc3, 0x2b, 0xdd, 0x16, 0xbf, 0x33, + 0x20, 0x9f, 0xe8, 0x0f, 0x34, 0x0b, 0xb9, 0xa5, 0x95, 0xcd, 0xd6, 0xc3, 0x66, 0x31, 0x55, 0x86, + 0xbd, 0xfd, 0xaa, 0x5e, 0xa1, 0x2a, 0xe4, 0xdb, 0xad, 0xf5, 0x07, 0xad, 0xc6, 0xd2, 0x66, 0xeb, + 0xfe, 0x17, 0x45, 0xa3, 0x3c, 0xb5, 0xb7, 0x5f, 0x4d, 0x6e, 0xa1, 0x32, 0x5c, 0xde, 0xb4, 0x97, + 0xee, 0x6f, 0xac, 0x36, 0xed, 0x62, 0xba, 0x7c, 0x65, 0x6f, 0xbf, 0x3a, 0x5e, 0x0b, 0xd4, 0x95, + 0xf6, 0x97, 0x1b, 0xcd, 0x46, 0x31, 0xa3, 0x50, 0xd5, 0x0a, 0x55, 0x00, 0x62, 0x88, 0x66, 0xa3, + 0x98, 0x2d, 0x17, 0xf6, 0xf6, 0xab, 0x89, 0x9d, 0x72, 0xf6, 0xeb, 0x1f, 0x2a, 0xa9, 0xe5, 0xd6, + 0xcb, 0x83, 0x8a, 0xf1, 0xea, 0xa0, 0x62, 0xfc, 0x71, 0x50, 0x31, 0x9e, 0x1d, 0x56, 0x52, 0xaf, + 0x0e, 0x2b, 0xa9, 0x5f, 0x0e, 0x2b, 0xa9, 0xc7, 0x96, 0x4b, 0xf9, 0xd6, 0xa0, 0x6b, 0x3a, 0xcc, + 0xb7, 0x58, 0xc0, 0xfc, 0x91, 0x4c, 0xdb, 0x61, 0x9e, 0x75, 0xea, 0xdb, 0x81, 0x8f, 0xfa, 0x24, + 0xea, 0xe6, 0xa4, 0xc1, 0xad, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x91, 0x71, 0x1a, 0xeb, 0x74, + 0x0a, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -967,10 +976,17 @@ func (m *Liquidation) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintParams(dAtA, i, uint64(len(m.Denom))) + if len(m.MintDenom) > 0 { + i -= len(m.MintDenom) + copy(dAtA[i:], m.MintDenom) + i = encodeVarintParams(dAtA, i, uint64(len(m.MintDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.DebtDenom) > 0 { + i -= len(m.DebtDenom) + copy(dAtA[i:], m.DebtDenom) + i = encodeVarintParams(dAtA, i, uint64(len(m.DebtDenom))) i-- dAtA[i] = 0xa } @@ -1128,7 +1144,11 @@ func (m *Liquidation) Size() (n int) { } var l int _ = l - l = len(m.Denom) + l = len(m.DebtDenom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.MintDenom) if l > 0 { n += 1 + l + sovParams(uint64(l)) } @@ -2154,7 +2174,7 @@ func (m *Liquidation) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DebtDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2182,7 +2202,39 @@ func (m *Liquidation) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.DebtDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MintDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { From 4536c35117fc3dd6c45f82a014b09a68934eeb71 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 1 Nov 2024 03:21:44 +0700 Subject: [PATCH 04/42] update liquidate logic --- x/auction/keeper/liquidate.go | 41 +++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/x/auction/keeper/liquidate.go b/x/auction/keeper/liquidate.go index 70a45704..128386dc 100644 --- a/x/auction/keeper/liquidate.go +++ b/x/auction/keeper/liquidate.go @@ -4,29 +4,21 @@ import ( "context" "time" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/onomyprotocol/reserve/x/auction/types" vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" ) func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error { - // Implement the logic for handling liquidation - // This might include checking conditions, updating states, and logging events params := k.GetParams(ctx) - currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time - lastAuctionPeriods_unix, err := k.lastestAuctionPeriod.Get(ctx) - if err != nil { - return err - } - lastAuctionPeriods := time.Unix(lastAuctionPeriods_unix, 0) + currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time + lastAuctionPeriods := time.Unix(k.LastestAuctionPeriod, 0) // check if has reached the next auction periods if lastAuctionPeriods.Add(params.AuctionPeriods).Before(currentTime) { // update latest auction period - err := k.lastestAuctionPeriod.Set(ctx, lastAuctionPeriods.Add(params.AuctionPeriods).Unix()) - if err != nil { - return err - } + k.LastestAuctionPeriod = lastAuctionPeriods.Add(params.AuctionPeriods).Unix() liquidations, err := k.vaultKeeper.GetLiquidations(ctx, mintDenom) if err != nil { @@ -94,6 +86,7 @@ func (k Keeper) newLiquidateMap(ctx context.Context, mintDenom string, params ty liquidationMap := make(map[string]*vaultstypes.Liquidation) currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time + // loop through all auctions err := k.Auctions.Walk(ctx, nil, func(auctionId uint64, auction types.Auction) (bool, error) { bidQueue, err := k.Bids.Get(ctx, auction.AuctionId) if err != nil { @@ -105,20 +98,23 @@ func (k Keeper) newLiquidateMap(ctx context.Context, mintDenom string, params ty } needCleanup := false + currentRate := math.LegacyMustNewDecFromStr(auction.CurrentRate) + lowestRate := math.LegacyMustNewDecFromStr(params.LowestRate) if auction.Status == types.AuctionStatus_AUCTION_STATUS_FINISHED || auction.Status == types.AuctionStatus_AUCTION_STATUS_OUT_OF_COLLATHERAL || - auction.EndTime.Before(currentTime) { + currentRate.Equal(lowestRate) { liquidation_tmp, ok := liquidationMap[auction.Item.Denom] if ok && liquidation_tmp != nil { liquidation_tmp.DebtDenom = auction.Item.Denom - liquidation_tmp.DebtDenom = mintDenom liquidation_tmp.LiquidatingVaults = append(liquidation_tmp.LiquidatingVaults, &vault) - liquidation_tmp.VaultLiquidationStatus[vault.Id].Sold = liquidation_tmp.VaultLiquidationStatus[vault.Id].Sold.Add(auction.TokenRaised) - liquidation_tmp.VaultLiquidationStatus[vault.Id].RemainCollateral = liquidation_tmp.VaultLiquidationStatus[vault.Id].RemainCollateral.Add(auction.Item) + liquidation_tmp.VaultLiquidationStatus[vault.Id] = &vaultstypes.VaultLiquidationStatus{ + Sold: auction.TokenRaised, + RemainCollateral: auction.Item, + } } else { liquidation_tmp = &vaultstypes.Liquidation{ - MintDenom: mintDenom, DebtDenom: auction.Item.Denom, + MintDenom: mintDenom, LiquidatingVaults: []*vaultstypes.Vault{&vault}, VaultLiquidationStatus: make(map[uint64]*vaultstypes.VaultLiquidationStatus), } @@ -139,7 +135,10 @@ func (k Keeper) newLiquidateMap(ctx context.Context, mintDenom string, params ty } if needCleanup { - k.refundBidders(ctx, bidQueue) + err = k.refundBidders(ctx, bidQueue) + if err != nil { + return true, err + } // clear the auction afterward err = k.DeleteAuction(ctx, auction.AuctionId) @@ -176,5 +175,9 @@ func (k Keeper) newLiquidateMap(ctx context.Context, mintDenom string, params ty return false, nil }) - return liquidationMap, err + + if err != nil { + return nil, err + } + return liquidationMap, nil } From 7ce2dc85079b34c59916d64daa4e7b5abe24e627 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 1 Nov 2024 03:29:58 +0700 Subject: [PATCH 05/42] psm keeper should use const from psm types --- x/auction/keeper/keeper_test.go | 2 +- x/psm/keeper/abci.go | 3 +-- x/psm/keeper/keeper_test.go | 6 +++--- x/psm/keeper/msg_server.go | 10 +++++----- x/psm/keeper/msg_server_test.go | 5 ++--- x/psm/keeper/swap.go | 9 +++++---- x/psm/keeper/swap_test.go | 3 +-- x/psm/types/genesis.go | 1 + x/vaults/keeper/vault.go | 1 + 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/x/auction/keeper/keeper_test.go b/x/auction/keeper/keeper_test.go index 20e26845..5412e6b3 100644 --- a/x/auction/keeper/keeper_test.go +++ b/x/auction/keeper/keeper_test.go @@ -28,7 +28,7 @@ func (s *KeeperTestSuite) SetupTest() { mockOracleKeeper := MockOracleKeeper{ prices: make(map[string]math.LegacyDec), } - mockOracleKeeper.SetPrice(s.Ctx, vaultstypes.DefaultMintDenom, math.LegacyMustNewDecFromStr("1")) + mockOracleKeeper.SetPrice(s.Ctx, vaultstypes.DefaultMintDenom[0], math.LegacyMustNewDecFromStr("1")) s.App.AuctionKeeper.OracleKeeper = mockOracleKeeper s.mockOracleKeeper = &mockOracleKeeper diff --git a/x/psm/keeper/abci.go b/x/psm/keeper/abci.go index e3cd5761..e0fbb4e4 100644 --- a/x/psm/keeper/abci.go +++ b/x/psm/keeper/abci.go @@ -5,7 +5,6 @@ import ( "cosmossdk.io/math" "github.com/onomyprotocol/reserve/x/psm/types" - vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" ) func (k Keeper) BeginBlocker(ctx context.Context) error { @@ -14,7 +13,7 @@ func (k Keeper) BeginBlocker(ctx context.Context) error { func (k Keeper) UpdatesStablecoinEpoch(ctx context.Context) error { updatePrice := func(red types.Stablecoin) bool { - price := k.OracleKeeper.GetPrice(ctx, red.Denom, vaultstypes.DefaultMintDenom) + price := k.OracleKeeper.GetPrice(ctx, red.Denom, types.DefaultMintDenom) if price == nil { return false } diff --git a/x/psm/keeper/keeper_test.go b/x/psm/keeper/keeper_test.go index 4089e7c7..bb0178a8 100644 --- a/x/psm/keeper/keeper_test.go +++ b/x/psm/keeper/keeper_test.go @@ -2,15 +2,15 @@ package keeper_test import ( "context" - "cosmossdk.io/math" "testing" + "cosmossdk.io/math" + "github.com/stretchr/testify/suite" "github.com/onomyprotocol/reserve/app/apptesting" "github.com/onomyprotocol/reserve/x/psm/keeper" "github.com/onomyprotocol/reserve/x/psm/types" - vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" ) var ( @@ -67,7 +67,7 @@ func (s *KeeperTestSuite) SetupTest() { mockOracleKeeper := MockOracleKeeper{ prices: make(map[string]math.LegacyDec), } - mockOracleKeeper.SetPrice(s.Ctx, vaultstypes.DefaultMintDenom, math.LegacyMustNewDecFromStr("1")) + mockOracleKeeper.SetPrice(s.Ctx, types.DefaultMintDenom, math.LegacyMustNewDecFromStr("1")) s.App.PSMKeeper.OracleKeeper = mockOracleKeeper s.mockOracleKeeper = &mockOracleKeeper diff --git a/x/psm/keeper/msg_server.go b/x/psm/keeper/msg_server.go index b43fbaf8..7a2aff1d 100644 --- a/x/psm/keeper/msg_server.go +++ b/x/psm/keeper/msg_server.go @@ -2,13 +2,13 @@ package keeper import ( "context" + "fmt" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - "fmt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/onomyprotocol/reserve/x/psm/types" - vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" ) type msgServer struct { @@ -86,7 +86,7 @@ func (k msgServer) SwapTonomUSD(ctx context.Context, msg *types.MsgSwapTonomUSD) } // mint nomUSD - coinsMint := sdk.NewCoins(sdk.NewCoin(vaultstypes.DefaultMintDenom, receiveAmountnomUSD)) + coinsMint := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenom, receiveAmountnomUSD)) err = k.keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) if err != nil { return nil, err @@ -141,7 +141,7 @@ func (k msgServer) SwapToStablecoin(ctx context.Context, msg *types.MsgSwapToSta } // burn nomUSD - coinsBurn := sdk.NewCoins(sdk.NewCoin(vaultstypes.DefaultMintDenom, msg.Amount)) + coinsBurn := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenom, msg.Amount)) err = k.keeper.BankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, coinsBurn) if err != nil { return nil, err @@ -170,7 +170,7 @@ func (k msgServer) SwapToStablecoin(ctx context.Context, msg *types.MsgSwapToSta sdkCtx.EventManager().EmitEvent( sdk.NewEvent( types.EventSwapToStablecoin, - sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()+vaultstypes.DefaultMintDenom), + sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()+types.DefaultMintDenom), sdk.NewAttribute(types.AttributeReceive, stablecoinReceive.String()), sdk.NewAttribute(types.AttributeFeeOut, fee_out.String()), ), diff --git a/x/psm/keeper/msg_server_test.go b/x/psm/keeper/msg_server_test.go index 680e6316..8c149253 100644 --- a/x/psm/keeper/msg_server_test.go +++ b/x/psm/keeper/msg_server_test.go @@ -10,7 +10,6 @@ import ( "github.com/onomyprotocol/reserve/x/psm/keeper" "github.com/onomyprotocol/reserve/x/psm/types" - vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" ) func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { @@ -85,7 +84,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { _, err := s.msgServer.SwapTonomUSD(s.Ctx, msg) if t.expectPass { s.Require().NoError(err) - balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, vaultstypes.DefaultMintDenom) + balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenom) s.Require().Equal(t.expectedReceive, balance.Amount) } else { @@ -154,7 +153,7 @@ func (s *KeeperTestSuite) TestMsgSwapToStablecoin() { _, err := s.msgServer.SwapToStablecoin(s.Ctx, msg) if t.expectPass { s.Require().NoError(err) - balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, vaultstypes.DefaultMintDenom) + balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenom) s.Require().Equal(t.expectedBalancenomUSD.String(), balance.Amount.String()) } else { diff --git a/x/psm/keeper/swap.go b/x/psm/keeper/swap.go index 68c6ff27..106274f3 100644 --- a/x/psm/keeper/swap.go +++ b/x/psm/keeper/swap.go @@ -2,16 +2,17 @@ package keeper import ( "context" - "cosmossdk.io/math" "fmt" + + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" + "github.com/onomyprotocol/reserve/x/psm/types" ) // SwapToStablecoin return receiveAmount, fee, error func (k Keeper) SwapToStablecoin(ctx context.Context, addr sdk.AccAddress, amount math.Int, toDenom string) (math.Int, sdk.DecCoin, error) { - denomMint := vaultstypes.DefaultMintDenom + denomMint := types.DefaultMintDenom asset := k.BankKeeper.GetBalance(ctx, addr, denomMint) if asset.Amount.LT(amount) { @@ -34,7 +35,7 @@ func (k Keeper) SwapToStablecoin(ctx context.Context, addr sdk.AccAddress, amoun } func (k Keeper) SwapTonomUSD(ctx context.Context, addr sdk.AccAddress, stablecoin sdk.Coin) (math.Int, sdk.DecCoin, error) { - denomMint := vaultstypes.DefaultMintDenom + denomMint := types.DefaultMintDenom asset := k.BankKeeper.GetBalance(ctx, addr, stablecoin.Denom) if asset.Amount.LT(stablecoin.Amount) { diff --git a/x/psm/keeper/swap_test.go b/x/psm/keeper/swap_test.go index bae21b82..c4283857 100644 --- a/x/psm/keeper/swap_test.go +++ b/x/psm/keeper/swap_test.go @@ -10,7 +10,6 @@ import ( "github.com/onomyprotocol/reserve/x/psm/keeper" "github.com/onomyprotocol/reserve/x/psm/types" - vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" ) func (s *KeeperTestSuite) TestSwapTonomUSD() { @@ -104,7 +103,7 @@ func (s *KeeperTestSuite) TestSwapToStablecoin() { { name: "success", setup: func(ctx context.Context, keeper keeper.Keeper) { - coinsMint := sdk.NewCoins(sdk.NewCoin(vaultstypes.DefaultMintDenom, math.NewInt(1000000))) + coinsMint := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenom, math.NewInt(1000000))) err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) s.Require().NoError(err) err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) diff --git a/x/psm/types/genesis.go b/x/psm/types/genesis.go index f2689b73..f1a5374c 100644 --- a/x/psm/types/genesis.go +++ b/x/psm/types/genesis.go @@ -2,6 +2,7 @@ package types // DefaultIndex is the default global index const DefaultIndex uint64 = 1 +const DefaultMintDenom = "nomUSD" // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { diff --git a/x/vaults/keeper/vault.go b/x/vaults/keeper/vault.go index 9d47115a..8ec37c9c 100644 --- a/x/vaults/keeper/vault.go +++ b/x/vaults/keeper/vault.go @@ -25,6 +25,7 @@ func (k *Keeper) CreateNewVault( return fmt.Errorf("%s was not actived", denom) } + // TODO: Check if mint denom is allowed if mint.Denom != types.DefaultMintDenom { return fmt.Errorf("minted denom must be %s", types.DefaultMintDenom) } From d981cba7031d0c1e33f7787f1206f98212db3512 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Fri, 1 Nov 2024 12:38:39 +0700 Subject: [PATCH 06/42] cancel bid in bidbyaddress --- x/auction/keeper/keeper.go | 20 +++++++++++++++++++- x/auction/keeper/msg_server.go | 6 +++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index bc445b2f..03ea8ffe 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -162,7 +162,7 @@ func (k Keeper) AddBidEntry(ctx context.Context, auctionId uint64, bidderAddr sd } // CancelBidEntry cancel existing bid entry for the given auction id -func (k Keeper) CancelBidEntry(ctx context.Context, auctionId, bidId uint64) error { +func (k Keeper) CancelBidEntry(ctx context.Context, auctionId, bidId uint64, bidder sdk.AccAddress) error { has, err := k.Auctions.Has(ctx, auctionId) if err != nil { return err @@ -193,6 +193,24 @@ func (k Keeper) CancelBidEntry(ctx context.Context, auctionId, bidId uint64) err return err } + bidsByAddress, err := k.BidByAddress.Get(ctx, collections.Join(auctionId, bidder)) + if err != nil { + return err + } + + // since this only use for query let not add any checks here if the bid exist or not + for i, bid := range bidsByAddress.Bids { + if bid.BidId == bidId { + bid.IsHandle = true + bidsByAddress.Bids[i] = bid + break + } + } + err = k.BidByAddress.Set(ctx, collections.Join(auctionId, bidder), bidsByAddress) + if err != nil { + return err + } + if refundAddr == "" || refundAmt.IsNil() { return fmt.Errorf("cannot find bid entry with id %v for auction %v", bidId, auctionId) } diff --git a/x/auction/keeper/msg_server.go b/x/auction/keeper/msg_server.go index ef09c990..5bc6b3df 100644 --- a/x/auction/keeper/msg_server.go +++ b/x/auction/keeper/msg_server.go @@ -96,8 +96,12 @@ func (k msgServer) Bid(ctx context.Context, msg *types.MsgBid) (*types.MsgBidRes } func (k msgServer) CancelBid(ctx context.Context, msg *types.MsgCancelBid) (*types.MsgCancelBidResponse, error) { + bidderAddr, err := k.authKeeper.AddressCodec().StringToBytes(msg.Bidder) + if err != nil { + return nil, err + } - err := k.CancelBidEntry(ctx, msg.AuctionId, msg.BidId) + err = k.CancelBidEntry(ctx, msg.AuctionId, msg.BidId, bidderAddr) if err != nil { return nil, err } From 9b77243bf5b676eef87453f46f14a194238a0160 Mon Sep 17 00:00:00 2001 From: sontrinh16 Date: Fri, 1 Nov 2024 12:52:37 +0700 Subject: [PATCH 07/42] add query bidder bids --- proto/reserve/auction/v1/auction.proto | 4 +- proto/reserve/auction/v1/query.proto | 17 +- x/auction/keeper/abci.go | 2 +- x/auction/keeper/grpc_query.go | 23 +- x/auction/keeper/keeper.go | 6 +- x/auction/types/auction.pb.go | 112 +++--- x/auction/types/query.pb.go | 489 +++++++++++++++++++++++-- x/auction/types/query.pb.gw.go | 121 +++++- 8 files changed, 679 insertions(+), 95 deletions(-) diff --git a/proto/reserve/auction/v1/auction.proto b/proto/reserve/auction/v1/auction.proto index 0e1fcc87..e538e4b8 100644 --- a/proto/reserve/auction/v1/auction.proto +++ b/proto/reserve/auction/v1/auction.proto @@ -88,11 +88,11 @@ message BidQueue { uint64 auction_id = 1; // array of bid entries with bidder address - repeated Bid bids = 2; + repeated Bid bids = 2 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } // Bids defines a list of bid entries message Bids { // array of bid entries with bidder address - repeated Bid bids = 1; + repeated Bid bids = 1 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } \ No newline at end of file diff --git a/proto/reserve/auction/v1/query.proto b/proto/reserve/auction/v1/query.proto index 0b78bdb9..54d0ef38 100644 --- a/proto/reserve/auction/v1/query.proto +++ b/proto/reserve/auction/v1/query.proto @@ -22,7 +22,11 @@ service Query { } rpc QueryAllBids(QueryAllBidsRequest) returns (QueryAllBidsResponse){ - option (google.api.http).get = "/reserve/auction/auction"; + option (google.api.http).get = "/reserve/auction/bids"; + } + + rpc QueryAllBidderBids(QueryAllBidderBidsRequest) returns (QueryAllBidderBidsResponse){ + option (google.api.http).get = "/reserve/auction/bids/{bidder}"; } } @@ -52,4 +56,15 @@ message QueryAllBidsResponse { // params holds all the parameters of this module. repeated Bid Bids = 1 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; +} + +message QueryAllBidderBidsRequest { + string bidder = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + uint64 auction_id = 2; +} + +message QueryAllBidderBidsResponse { + // params holds all the parameters of this module. + repeated Bid Bids = 1 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } \ No newline at end of file diff --git a/x/auction/keeper/abci.go b/x/auction/keeper/abci.go index 35491155..9168af2f 100644 --- a/x/auction/keeper/abci.go +++ b/x/auction/keeper/abci.go @@ -43,7 +43,7 @@ func (k *Keeper) BeginBlocker(ctx context.Context) error { if err != nil { return err } - err = k.Bids.Set(ctx, auction.AuctionId, types.BidQueue{AuctionId: auction.AuctionId, Bids: []*types.Bid{}}) + err = k.Bids.Set(ctx, auction.AuctionId, types.BidQueue{AuctionId: auction.AuctionId, Bids: []types.Bid{}}) if err != nil { return err } diff --git a/x/auction/keeper/grpc_query.go b/x/auction/keeper/grpc_query.go index 91b3d459..dee27f03 100644 --- a/x/auction/keeper/grpc_query.go +++ b/x/auction/keeper/grpc_query.go @@ -3,6 +3,7 @@ package keeper import ( "context" + "cosmossdk.io/collections" sdk "github.com/cosmos/cosmos-sdk/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -55,7 +56,7 @@ func (k Querier) QueryAllBids(ctx context.Context, req *types.QueryAllBidsReques err := k.k.Bids.Walk(ctx, nil, func(key uint64, value types.BidQueue) (stop bool, err error) { for _, bid := range value.Bids { - allBids = append(allBids, *bid) + allBids = append(allBids, bid) } return false, nil }) @@ -64,3 +65,23 @@ func (k Querier) QueryAllBids(ctx context.Context, req *types.QueryAllBidsReques Bids: allBids, }, err } + +func (k Querier) QueryAllBidderBids(ctx context.Context, req *types.QueryAllBidderBidsRequest) (*types.QueryAllBidderBidsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + bidderAddr, err := k.k.authKeeper.AddressCodec().StringToBytes(req.Bidder) + if err != nil { + return nil, err + } + + bidsByAddress, err := k.k.BidByAddress.Get(ctx, collections.Join(req.AuctionId, sdk.AccAddress(bidderAddr))) + if err != nil { + return nil, err + } + + return &types.QueryAllBidderBidsResponse{ + Bids: bidsByAddress.Bids, + }, err +} diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 03ea8ffe..8193f413 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -129,7 +129,7 @@ func (k Keeper) AddBidEntry(ctx context.Context, auctionId uint64, bidderAddr sd bid.Index = uint64(len(bidQueue.Bids)) - bidQueue.Bids = append(bidQueue.Bids, &bid) + bidQueue.Bids = append(bidQueue.Bids, bid) err = k.Bids.Set(ctx, auctionId, bidQueue) if err != nil { return err @@ -141,14 +141,14 @@ func (k Keeper) AddBidEntry(ctx context.Context, auctionId uint64, bidderAddr sd if err != nil { return err } - bids.Bids = append(bids.Bids, &bid) + bids.Bids = append(bids.Bids, bid) err = k.BidByAddress.Set(ctx, collections.Join(auctionId, bidderAddr), bids) if err != nil { return err } } else { bids := types.Bids{ - Bids: []*types.Bid{&bid}, + Bids: []types.Bid{bid}, } err = k.BidByAddress.Set(ctx, collections.Join(auctionId, bidderAddr), bids) if err != nil { diff --git a/x/auction/types/auction.pb.go b/x/auction/types/auction.pb.go index efe4b046..a330c292 100644 --- a/x/auction/types/auction.pb.go +++ b/x/auction/types/auction.pb.go @@ -291,7 +291,7 @@ type BidQueue struct { // bidder address AuctionId uint64 `protobuf:"varint,1,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` // array of bid entries with bidder address - Bids []*Bid `protobuf:"bytes,2,rep,name=bids,proto3" json:"bids,omitempty"` + Bids []Bid `protobuf:"bytes,2,rep,name=bids,proto3" json:"bids"` } func (m *BidQueue) Reset() { *m = BidQueue{} } @@ -334,7 +334,7 @@ func (m *BidQueue) GetAuctionId() uint64 { return 0 } -func (m *BidQueue) GetBids() []*Bid { +func (m *BidQueue) GetBids() []Bid { if m != nil { return m.Bids } @@ -344,7 +344,7 @@ func (m *BidQueue) GetBids() []*Bid { // Bids defines a list of bid entries type Bids struct { // array of bid entries with bidder address - Bids []*Bid `protobuf:"bytes,1,rep,name=bids,proto3" json:"bids,omitempty"` + Bids []Bid `protobuf:"bytes,1,rep,name=bids,proto3" json:"bids"` } func (m *Bids) Reset() { *m = Bids{} } @@ -380,7 +380,7 @@ func (m *Bids) XXX_DiscardUnknown() { var xxx_messageInfo_Bids proto.InternalMessageInfo -func (m *Bids) GetBids() []*Bid { +func (m *Bids) GetBids() []Bid { if m != nil { return m.Bids } @@ -398,56 +398,56 @@ func init() { func init() { proto.RegisterFile("reserve/auction/v1/auction.proto", fileDescriptor_8758264ed04201a2) } var fileDescriptor_8758264ed04201a2 = []byte{ - // 770 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x6f, 0xdb, 0x36, - 0x14, 0xc7, 0xad, 0x44, 0x71, 0x6c, 0x2a, 0x29, 0x3c, 0x22, 0x5d, 0x15, 0x17, 0x53, 0xdc, 0x00, - 0x03, 0x8c, 0x0e, 0x95, 0xea, 0xe4, 0xb2, 0x01, 0xbb, 0x58, 0xb6, 0xd2, 0x68, 0x08, 0xe2, 0x4c, - 0xb6, 0xbb, 0x61, 0x17, 0x81, 0x12, 0x39, 0x95, 0x98, 0x24, 0x1a, 0x22, 0x65, 0xb8, 0x1f, 0x61, - 0xb7, 0x7e, 0x8c, 0x61, 0xa7, 0x1d, 0x7a, 0xd9, 0x37, 0xe8, 0xb1, 0xe8, 0x69, 0xa7, 0x6d, 0x48, - 0x0e, 0xfb, 0x1a, 0x83, 0x28, 0xba, 0xc0, 0xbc, 0xa2, 0x48, 0x2e, 0x06, 0x1f, 0xdf, 0xef, 0xaf, - 0xf7, 0xfc, 0xf8, 0x27, 0x41, 0xaf, 0x20, 0x9c, 0x14, 0x4b, 0xe2, 0xa0, 0x32, 0x16, 0x94, 0xe5, - 0xce, 0x72, 0xb0, 0x5e, 0xda, 0x8b, 0x82, 0x09, 0x06, 0xa1, 0x22, 0xec, 0xf5, 0xf6, 0x72, 0xd0, - 0xfd, 0x04, 0x65, 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 0x1e, 0xb3, 0x32, 0x17, 0x61, 0x35, - 0x0d, 0x73, 0x57, 0x96, 0xee, 0xda, 0xf5, 0xa8, 0xec, 0xf5, 0xa8, 0xec, 0xd9, 0x7a, 0x54, 0xee, - 0x7e, 0x55, 0xfb, 0xd5, 0x5f, 0x47, 0x5a, 0x5d, 0xbf, 0x53, 0x7d, 0x64, 0xac, 0xbe, 0x51, 0x51, - 0xf0, 0x19, 0xd8, 0x13, 0xec, 0x27, 0x92, 0x87, 0x05, 0xa2, 0x9c, 0x60, 0xb3, 0x75, 0x87, 0x7f, - 0x63, 0x48, 0x65, 0x20, 0x85, 0xf0, 0x2b, 0xd0, 0xe4, 0x02, 0x89, 0x92, 0x9b, 0xed, 0x9e, 0xd6, - 0xbf, 0x77, 0xf2, 0xc8, 0xfe, 0xbf, 0x31, 0x6c, 0x75, 0x1e, 0x53, 0x09, 0x06, 0x4a, 0x00, 0x3d, - 0x60, 0x08, 0x54, 0x24, 0x44, 0x84, 0x09, 0x43, 0xa9, 0x09, 0xee, 0xd0, 0x02, 0xa8, 0x85, 0xcf, - 0x18, 0x4a, 0xe1, 0x21, 0x68, 0x2d, 0x51, 0x99, 0x8a, 0xea, 0x88, 0x0d, 0x79, 0xc4, 0xbb, 0x32, - 0xf6, 0xf1, 0xf1, 0xef, 0x5b, 0x60, 0xdb, 0xa5, 0x18, 0xde, 0x07, 0xcd, 0x88, 0xe2, 0x0a, 0xd0, - 0x24, 0xb0, 0x13, 0x51, 0xec, 0x63, 0xf8, 0x54, 0x6e, 0x63, 0x52, 0x98, 0x5b, 0xf2, 0x28, 0xcc, - 0x77, 0xaf, 0x9f, 0x1c, 0xa8, 0xf2, 0x43, 0x8c, 0x0b, 0xc2, 0xf9, 0x54, 0x14, 0x34, 0x4f, 0x02, - 0xc5, 0xc1, 0xaf, 0x41, 0x13, 0x65, 0xd5, 0x10, 0xa5, 0x99, 0x6e, 0xdb, 0xad, 0xd2, 0x54, 0x06, - 0x28, 0x48, 0x4c, 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d1, 0x46, 0x6e, 0x32, 0x9f, 0x85, 0x93, 0xb3, 0x70, 0x34, - 0xb9, 0xb8, 0x18, 0xce, 0xce, 0xbd, 0x60, 0x78, 0xd1, 0xd1, 0xdd, 0x6f, 0xde, 0x5c, 0x5b, 0xda, - 0xdb, 0x6b, 0x4b, 0xfb, 0xfb, 0xda, 0xd2, 0x5e, 0xdd, 0x58, 0x8d, 0xb7, 0x37, 0x56, 0xe3, 0x8f, - 0x1b, 0xab, 0xf1, 0xc3, 0xd3, 0x84, 0x8a, 0x17, 0x65, 0x64, 0xc7, 0x2c, 0x73, 0x58, 0xce, 0xb2, - 0x97, 0xf2, 0xea, 0xc6, 0x2c, 0x75, 0xd6, 0xef, 0xed, 0xea, 0xfd, 0x8b, 0x2b, 0x5e, 0x2e, 0x08, - 0x8f, 0x9a, 0x92, 0x38, 0xfd, 0x37, 0x00, 0x00, 0xff, 0xff, 0x36, 0xe4, 0x60, 0x5e, 0x91, 0x05, - 0x00, 0x00, + // 774 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x8b, 0xdb, 0x46, + 0x14, 0xc7, 0xad, 0x5d, 0xad, 0xd7, 0x1e, 0xed, 0x06, 0x77, 0xd8, 0x34, 0x5a, 0x87, 0x6a, 0x9d, + 0x85, 0x82, 0x09, 0x44, 0x8a, 0x37, 0x50, 0x5a, 0x28, 0x05, 0xcb, 0xd6, 0x66, 0x55, 0x96, 0xf5, + 0x56, 0xb6, 0xdb, 0xd2, 0x8b, 0x18, 0x69, 0xa6, 0xca, 0x50, 0x49, 0x63, 0x34, 0x23, 0xe3, 0x7c, + 0x84, 0xde, 0xf2, 0x31, 0x4a, 0x4f, 0x3d, 0xe4, 0xd2, 0x6f, 0x90, 0x63, 0xc8, 0xa9, 0xa7, 0xb6, + 0xec, 0x1e, 0xfa, 0x35, 0x8a, 0x46, 0xe3, 0x40, 0xdc,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x71, 0xa7, 0x01, 0x8f, + 0xc1, 0xdd, 0x8d, 0xfc, 0x70, 0x34, 0xf3, 0xbf, 0xf5, 0x3a, 0x1a, 0xbc, 0x0f, 0xee, 0x6d, 0xa4, + 0xce, 0xfd, 0x2b, 0x7f, 0x7a, 0xe1, 0x8d, 0x3b, 0x3b, 0xb0, 0x0b, 0x3e, 0xde, 0x48, 0x7a, 0xdf, + 0x5f, 0xfb, 0x81, 0x37, 0xee, 0xec, 0xc2, 0x4f, 0xc1, 0x83, 0x8d, 0xdc, 0x64, 0x3e, 0x0b, 0x27, + 0xe7, 0xe1, 0x68, 0x72, 0x79, 0x39, 0x9c, 0x5d, 0x78, 0xc1, 0xf0, 0xb2, 0xa3, 0xbb, 0x5f, 0xbf, + 0xba, 0xb1, 0xb4, 0xd7, 0x37, 0x96, 0xf6, 0xf7, 0x8d, 0xa5, 0xbd, 0xb8, 0xb5, 0x1a, 0xaf, 0x6f, + 0xad, 0xc6, 0x1f, 0xb7, 0x56, 0xe3, 0x87, 0xc7, 0x09, 0x15, 0xcf, 0xca, 0xc8, 0x8e, 0x59, 0xe6, + 0xb0, 0x9c, 0x65, 0xcf, 0xe5, 0x85, 0x8e, 0x59, 0xea, 0xac, 0x5f, 0xe1, 0xd5, 0xdb, 0x77, 0x58, + 0x3c, 0x5f, 0x10, 0x1e, 0x35, 0x25, 0xf1, 0xe4, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5b, 0x39, + 0xe5, 0xd7, 0xa7, 0x05, 0x00, 0x00, } func (m *Auction) Marshal() (dAtA []byte, err error) { @@ -1428,7 +1428,7 @@ func (m *BidQueue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Bids = append(m.Bids, &Bid{}) + m.Bids = append(m.Bids, Bid{}) if err := m.Bids[len(m.Bids)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1512,7 +1512,7 @@ func (m *Bids) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Bids = append(m.Bids, &Bid{}) + m.Bids = append(m.Bids, Bid{}) if err := m.Bids[len(m.Bids)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/auction/types/query.pb.go b/x/auction/types/query.pb.go index 1a1c1b2d..f9da488b 100644 --- a/x/auction/types/query.pb.go +++ b/x/auction/types/query.pb.go @@ -276,6 +276,103 @@ func (m *QueryAllBidsResponse) GetBids() []Bid { return nil } +type QueryAllBidderBidsRequest struct { + Bidder string `protobuf:"bytes,1,opt,name=bidder,proto3" json:"bidder,omitempty"` + AuctionId uint64 `protobuf:"varint,2,opt,name=auction_id,json=auctionId,proto3" json:"auction_id,omitempty"` +} + +func (m *QueryAllBidderBidsRequest) Reset() { *m = QueryAllBidderBidsRequest{} } +func (m *QueryAllBidderBidsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllBidderBidsRequest) ProtoMessage() {} +func (*QueryAllBidderBidsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c0d0f2ec58bf1126, []int{6} +} +func (m *QueryAllBidderBidsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllBidderBidsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllBidderBidsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllBidderBidsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllBidderBidsRequest.Merge(m, src) +} +func (m *QueryAllBidderBidsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllBidderBidsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllBidderBidsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllBidderBidsRequest proto.InternalMessageInfo + +func (m *QueryAllBidderBidsRequest) GetBidder() string { + if m != nil { + return m.Bidder + } + return "" +} + +func (m *QueryAllBidderBidsRequest) GetAuctionId() uint64 { + if m != nil { + return m.AuctionId + } + return 0 +} + +type QueryAllBidderBidsResponse struct { + // params holds all the parameters of this module. + Bids []Bid `protobuf:"bytes,1,rep,name=Bids,proto3" json:"Bids"` +} + +func (m *QueryAllBidderBidsResponse) Reset() { *m = QueryAllBidderBidsResponse{} } +func (m *QueryAllBidderBidsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllBidderBidsResponse) ProtoMessage() {} +func (*QueryAllBidderBidsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c0d0f2ec58bf1126, []int{7} +} +func (m *QueryAllBidderBidsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllBidderBidsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllBidderBidsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAllBidderBidsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllBidderBidsResponse.Merge(m, src) +} +func (m *QueryAllBidderBidsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllBidderBidsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllBidderBidsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllBidderBidsResponse proto.InternalMessageInfo + +func (m *QueryAllBidderBidsResponse) GetBids() []Bid { + if m != nil { + return m.Bids + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "reserve.auction.v1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "reserve.auction.v1.QueryParamsResponse") @@ -283,41 +380,49 @@ func init() { proto.RegisterType((*QueryAllAuctionResponse)(nil), "reserve.auction.v1.QueryAllAuctionResponse") proto.RegisterType((*QueryAllBidsRequest)(nil), "reserve.auction.v1.QueryAllBidsRequest") proto.RegisterType((*QueryAllBidsResponse)(nil), "reserve.auction.v1.QueryAllBidsResponse") + proto.RegisterType((*QueryAllBidderBidsRequest)(nil), "reserve.auction.v1.QueryAllBidderBidsRequest") + proto.RegisterType((*QueryAllBidderBidsResponse)(nil), "reserve.auction.v1.QueryAllBidderBidsResponse") } func init() { proto.RegisterFile("reserve/auction/v1/query.proto", fileDescriptor_c0d0f2ec58bf1126) } var fileDescriptor_c0d0f2ec58bf1126 = []byte{ - // 449 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcf, 0xaa, 0xd3, 0x40, - 0x14, 0xc6, 0x33, 0x5e, 0x2d, 0x3a, 0x57, 0x10, 0xc7, 0x6a, 0x7b, 0xa3, 0xa4, 0x25, 0x0b, 0x6f, - 0xa9, 0x90, 0xb1, 0x15, 0xdc, 0xb9, 0x68, 0x96, 0x2e, 0x44, 0x8b, 0x2b, 0x41, 0x24, 0x4d, 0x87, - 0x18, 0x48, 0x72, 0xd2, 0x4c, 0x52, 0xac, 0x4b, 0xdd, 0xba, 0x10, 0xdc, 0xf8, 0x08, 0x2e, 0x7d, - 0x8c, 0x2e, 0x0b, 0x6e, 0x5c, 0x89, 0xb4, 0x82, 0xaf, 0x21, 0x99, 0x99, 0x86, 0xb4, 0x89, 0xb7, - 0xdd, 0xb4, 0x33, 0x73, 0xbe, 0xf3, 0xfd, 0xce, 0x1f, 0x82, 0x8d, 0x84, 0x71, 0x96, 0xcc, 0x19, - 0x75, 0x32, 0x37, 0xf5, 0x21, 0xa2, 0xf3, 0x01, 0x9d, 0x65, 0x2c, 0x59, 0x58, 0x71, 0x02, 0x29, - 0x10, 0xa2, 0xe2, 0x96, 0x8a, 0x5b, 0xf3, 0x81, 0x7e, 0xd3, 0x09, 0xfd, 0x08, 0xa8, 0xf8, 0x95, - 0x32, 0xbd, 0xe9, 0x81, 0x07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 0x13, 0xd7, 0xcf, 0x0f, 0xea, - 0x64, 0x71, 0x66, 0xe7, 0xc3, 0x8f, 0x3f, 0x5f, 0x2e, 0x9d, 0x91, 0x16, 0xdd, 0x5f, 0xbb, 0x9c, - 0x32, 0xf9, 0x84, 0xf0, 0x8d, 0xbd, 0x61, 0x92, 0xfe, 0x7f, 0xdd, 0x2b, 0xbb, 0xd0, 0x1f, 0x1c, - 0xa5, 0x55, 0xd5, 0x74, 0x45, 0x35, 0x3a, 0x69, 0x57, 0xaa, 0x51, 0xff, 0xe4, 0x23, 0xc2, 0xd7, - 0xcb, 0x53, 0x26, 0xe7, 0x17, 0xf9, 0x97, 0xd6, 0xa3, 0xf7, 0x0e, 0x0b, 0x8f, 0xad, 0xc2, 0x7e, - 0xba, 0x5c, 0x1b, 0x68, 0xb5, 0x36, 0xd0, 0xef, 0xb5, 0x81, 0x3e, 0x6f, 0x0c, 0x6d, 0xb5, 0x31, - 0xb4, 0x9f, 0x1b, 0x43, 0x7b, 0xf5, 0xd0, 0xf3, 0xd3, 0xb7, 0xd9, 0xc4, 0x72, 0x21, 0xa4, 0x10, - 0x41, 0xb8, 0x10, 0xdf, 0x85, 0x0b, 0x41, 0xe1, 0xf5, 0xae, 0x70, 0x4b, 0x17, 0x31, 0xe3, 0x93, - 0x86, 0x50, 0x3c, 0xfa, 0x17, 0x00, 0x00, 0xff, 0xff, 0x91, 0x1e, 0x9b, 0x35, 0x14, 0x04, 0x00, - 0x00, + // 560 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xee, 0xac, 0x6b, 0xb1, 0xb3, 0x82, 0x38, 0x76, 0x6d, 0x1b, 0xdd, 0x34, 0xe4, 0xb0, 0x5b, + 0x56, 0x36, 0xb3, 0x5b, 0xc1, 0x9b, 0x87, 0xe6, 0xa6, 0x07, 0xd1, 0xba, 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, 0xb7, 0x08, 0x5f, 0x39, 0x13, 0x08, 0xb2, 0xfb, 0x57, + 0xf6, 0x42, 0x9e, 0xb4, 0x5b, 0xe7, 0xc2, 0x82, 0x1b, 0x43, 0xba, 0xd1, 0x48, 0xb3, 0xe0, 0x06, + 0xbe, 0xc9, 0x6b, 0x84, 0x2f, 0xe7, 0x93, 0x42, 0x76, 0xfe, 0xc5, 0x9f, 0xbb, 0x75, 0xad, 0xb3, + 0x1a, 0x08, 0x2e, 0xb6, 0xa4, 0x8b, 0x06, 0xd9, 0x2c, 0xb8, 0x18, 0x64, 0x8a, 0x1f, 0x10, 0xfc, + 0x51, 0x97, 0xae, 0x9b, 0xec, 0xad, 0xe0, 0x5f, 0x0e, 0xa1, 0x66, 0x9d, 0x17, 0x0e, 0xa6, 0xb6, + 0xa5, 0x29, 0x83, 0xe8, 0xa5, 0xa6, 0xe8, 0x4b, 0x95, 0xd4, 0x57, 0xf6, 0xfd, 0x93, 0xa9, 0x8e, + 0x4e, 0xa7, 0x3a, 0xfa, 0x39, 0xd5, 0xd1, 0xbb, 0x99, 0x5e, 0x39, 0x9d, 0xe9, 0x95, 0xef, 0x33, + 0xbd, 0xf2, 0x64, 0xdf, 0xf3, 0xd3, 0x67, 0xa3, 0x81, 0x35, 0xe4, 0x21, 0xe5, 0x11, 0x0f, 0x27, + 0xf2, 0xb5, 0x33, 0xe4, 0xc1, 0x82, 0xf1, 0xf9, 0x82, 0x33, 0x9d, 0xc4, 0x4c, 0x0c, 0xaa, 0x12, + 0x71, 0xfb, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x53, 0xc4, 0xaf, 0x6b, 0x73, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -336,6 +441,7 @@ type QueryClient interface { Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) QueryAllAuction(ctx context.Context, in *QueryAllAuctionRequest, opts ...grpc.CallOption) (*QueryAllAuctionResponse, error) QueryAllBids(ctx context.Context, in *QueryAllBidsRequest, opts ...grpc.CallOption) (*QueryAllBidsResponse, error) + QueryAllBidderBids(ctx context.Context, in *QueryAllBidderBidsRequest, opts ...grpc.CallOption) (*QueryAllBidderBidsResponse, error) } type queryClient struct { @@ -373,12 +479,22 @@ func (c *queryClient) QueryAllBids(ctx context.Context, in *QueryAllBidsRequest, return out, nil } +func (c *queryClient) QueryAllBidderBids(ctx context.Context, in *QueryAllBidderBidsRequest, opts ...grpc.CallOption) (*QueryAllBidderBidsResponse, error) { + out := new(QueryAllBidderBidsResponse) + err := c.cc.Invoke(ctx, "/reserve.auction.v1.Query/QueryAllBidderBids", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) QueryAllAuction(context.Context, *QueryAllAuctionRequest) (*QueryAllAuctionResponse, error) QueryAllBids(context.Context, *QueryAllBidsRequest) (*QueryAllBidsResponse, error) + QueryAllBidderBids(context.Context, *QueryAllBidderBidsRequest) (*QueryAllBidderBidsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -394,6 +510,9 @@ func (*UnimplementedQueryServer) QueryAllAuction(ctx context.Context, req *Query func (*UnimplementedQueryServer) QueryAllBids(ctx context.Context, req *QueryAllBidsRequest) (*QueryAllBidsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryAllBids not implemented") } +func (*UnimplementedQueryServer) QueryAllBidderBids(ctx context.Context, req *QueryAllBidderBidsRequest) (*QueryAllBidderBidsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryAllBidderBids not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -453,6 +572,24 @@ func _Query_QueryAllBids_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Query_QueryAllBidderBids_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllBidderBidsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryAllBidderBids(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/reserve.auction.v1.Query/QueryAllBidderBids", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryAllBidderBids(ctx, req.(*QueryAllBidderBidsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "reserve.auction.v1.Query", HandlerType: (*QueryServer)(nil), @@ -469,6 +606,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryAllBids", Handler: _Query_QueryAllBids_Handler, }, + { + MethodName: "QueryAllBidderBids", + Handler: _Query_QueryAllBidderBids_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "reserve/auction/v1/query.proto", @@ -650,6 +791,78 @@ func (m *QueryAllBidsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryAllBidderBidsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllBidderBidsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllBidderBidsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AuctionId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.AuctionId)) + i-- + dAtA[i] = 0x10 + } + if len(m.Bidder) > 0 { + i -= len(m.Bidder) + copy(dAtA[i:], m.Bidder) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Bidder))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAllBidderBidsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAllBidderBidsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllBidderBidsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Bids) > 0 { + for iNdEx := len(m.Bids) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Bids[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -729,6 +942,37 @@ func (m *QueryAllBidsResponse) Size() (n int) { return n } +func (m *QueryAllBidderBidsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Bidder) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.AuctionId != 0 { + n += 1 + sovQuery(uint64(m.AuctionId)) + } + return n +} + +func (m *QueryAllBidderBidsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Bids) > 0 { + for _, e := range m.Bids { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1136,6 +1380,191 @@ func (m *QueryAllBidsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryAllBidderBidsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllBidderBidsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllBidderBidsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bidder", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bidder = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType) + } + m.AuctionId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AuctionId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAllBidderBidsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAllBidderBidsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllBidderBidsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bids", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bids = append(m.Bids, Bid{}) + if err := m.Bids[len(m.Bids)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/auction/types/query.pb.gw.go b/x/auction/types/query.pb.gw.go index 1bad430e..a8d08035 100644 --- a/x/auction/types/query.pb.gw.go +++ b/x/auction/types/query.pb.gw.go @@ -87,6 +87,78 @@ func local_request_Query_QueryAllBids_0(ctx context.Context, marshaler runtime.M } +var ( + filter_Query_QueryAllBidderBids_0 = &utilities.DoubleArray{Encoding: map[string]int{"bidder": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_QueryAllBidderBids_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllBidderBidsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["bidder"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bidder") + } + + protoReq.Bidder, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bidder", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAllBidderBids_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QueryAllBidderBids(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryAllBidderBids_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllBidderBidsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["bidder"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "bidder") + } + + protoReq.Bidder, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "bidder", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAllBidderBids_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QueryAllBidderBids(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -162,6 +234,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryAllBidderBids_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryAllBidderBids_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAllBidderBids_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -263,6 +358,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryAllBidderBids_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryAllBidderBids_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAllBidderBids_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -271,7 +386,9 @@ var ( pattern_Query_QueryAllAuction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1}, []string{"reserve", "auction"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryAllBids_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1}, []string{"reserve", "auction"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAllBids_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"reserve", "auction", "bids"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryAllBidderBids_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"reserve", "auction", "bids", "bidder"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -280,4 +397,6 @@ var ( forward_Query_QueryAllAuction_0 = runtime.ForwardResponseMessage forward_Query_QueryAllBids_0 = runtime.ForwardResponseMessage + + forward_Query_QueryAllBidderBids_0 = runtime.ForwardResponseMessage ) From 245e106d41c0d308e23cba856643dfcc5c9b77c5 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 1 Nov 2024 16:46:41 +0700 Subject: [PATCH 08/42] refactor testcase --- x/vaults/keeper/vault.go | 23 +++++++----- x/vaults/keeper/vaults_test.go | 66 ++++++++++++++++++---------------- 2 files changed, 51 insertions(+), 38 deletions(-) diff --git a/x/vaults/keeper/vault.go b/x/vaults/keeper/vault.go index 8ec37c9c..7dcd32c8 100644 --- a/x/vaults/keeper/vault.go +++ b/x/vaults/keeper/vault.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + "slices" "sort" "strconv" "time" @@ -25,9 +26,10 @@ func (k *Keeper) CreateNewVault( return fmt.Errorf("%s was not actived", denom) } + allowedMintDenoms := k.GetAllowedMintDenoms(ctx) // TODO: Check if mint denom is allowed - if mint.Denom != types.DefaultMintDenom { - return fmt.Errorf("minted denom must be %s", types.DefaultMintDenom) + if !slices.Contains(allowedMintDenoms, mint.Denom) { + return fmt.Errorf("minted denom must in list %s, but got %s", types.DefaultMintDenom, mint.Denom) } params := k.GetParams(ctx) @@ -140,16 +142,19 @@ func (k *Keeper) MintCoin( sender sdk.AccAddress, mint sdk.Coin, ) error { - if mint.Denom != types.DefaultMintDenom { - return fmt.Errorf("minted denom must be %s", types.DefaultMintDenom) - } + vault, err := k.GetVault(ctx, vaultId) if err != nil { return err } + if vault.Status != types.ACTIVE { return fmt.Errorf("vault is not actived") } + + if mint.Denom != vault.Debt.Denom { + return fmt.Errorf("mint denom must be %s, got %s", vault.Debt.Denom, mint.Denom) + } vm, err := k.GetVaultManager(ctx, vault.CollateralLocked.Denom) if err != nil { return fmt.Errorf("%s was not actived", vault.CollateralLocked.Denom) @@ -218,14 +223,16 @@ func (k *Keeper) RepayDebt( sender sdk.AccAddress, repay sdk.Coin, ) error { - if repay.Denom != types.DefaultMintDenom { - return fmt.Errorf("minted denom must be %s", types.DefaultMintDenom) - } vault, err := k.GetVault(ctx, vaultId) if err != nil { return err } + + if repay.Denom != vault.Debt.Denom { + return fmt.Errorf("repay denom must be %s, got %s", vault.Debt.Denom, repay.Denom) + } + if vault.Status != types.ACTIVE { return fmt.Errorf("vault is not actived") } diff --git a/x/vaults/keeper/vaults_test.go b/x/vaults/keeper/vaults_test.go index 15c8ec7d..3061f49b 100644 --- a/x/vaults/keeper/vaults_test.go +++ b/x/vaults/keeper/vaults_test.go @@ -120,11 +120,11 @@ func (s *KeeperTestSuite) TestRepayDebt() { s.SetupTest() var ( denom = "atom" - repayAsset = sdk.NewCoin(types.DefaultMintDenom, math.NewInt(2000000)) + repayAsset = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(2000000)) collateralAsset = sdk.NewCoin(denom, math.NewInt(100000000000)) fund = sdk.NewCoin(denom, math.NewInt(1000000000000)) maxDebt = math.NewInt(2000000000) - mintedCoin = sdk.NewCoin(types.DefaultMintDenom, math.NewInt(300000000)) + mintedCoin = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(300000000)) ) tests := []struct { @@ -177,7 +177,7 @@ func (s *KeeperTestSuite) TestDepositToVault() { collateralAsset = sdk.NewCoin(denom, math.NewInt(100000000000)) fund = sdk.NewCoin(denom, math.NewInt(1000000000000)) maxDebt = math.NewInt(2000000000) - mintedCoin = sdk.NewCoin(types.DefaultMintDenom, math.NewInt(200000000)) + mintedCoin = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(200000000)) ) tests := []struct { @@ -224,7 +224,7 @@ func (s *KeeperTestSuite) TestWithdrawFromVault() { coinMintToAcc = sdk.NewCoin(denom, math.NewInt(100000000000)) fund = sdk.NewCoin(denom, math.NewInt(10000000000000)) maxDebt = math.NewInt(2000000000) - mintedCoin = sdk.NewCoin(types.DefaultMintDenom, math.NewInt(200000000)) + mintedCoin = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(200000000)) ) tests := []struct { @@ -267,7 +267,7 @@ func (s *KeeperTestSuite) TestWithdrawFromVault() { func (s *KeeperTestSuite) TestLiquidate() { // s.SetupTest() - // vaultOwnerAddr := sdk.AccAddress([]byte("addr1_______________")) + vaultOwnerAddr := sdk.AccAddress([]byte("addr1_______________")) tests := []struct { name string @@ -280,11 +280,12 @@ func (s *KeeperTestSuite) TestLiquidate() { { name: "single vault - sold all, enough to cover debt", liquidation: types.Liquidation{ - Denom: "atom", + DebtDenom: "atom", + MintDenom: types.DefaultMintDenom[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -295,22 +296,23 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 0 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(35_000_000)), + Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(35_000_000)), RemainCollateral: sdk.NewCoin("atom", math.ZeroInt()), }, }, }, expVaultStatus: []types.VaultStatus{types.CLOSED}, - reserveBalances: sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenom, math.NewInt(10_000_000))), + reserveBalances: sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(10_000_000))), }, { name: "single vault - sold all, not enough to cover debt", liquidation: types.Liquidation{ - Denom: "atom", + DebtDenom: "atom", + MintDenom: types.DefaultMintDenom[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -321,22 +323,23 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 0 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(20_000_000)), + Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(20_000_000)), RemainCollateral: sdk.NewCoin("atom", math.ZeroInt()), }, }, }, expVaultStatus: []types.VaultStatus{types.LIQUIDATED}, - shortfallAmount: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(5_000_000)), + shortfallAmount: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(5_000_000)), }, { name: "single vault - remain collateral, enough to cover debt", liquidation: types.Liquidation{ - Denom: "atom", + DebtDenom: "atom", + MintDenom: types.DefaultMintDenom[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -349,25 +352,26 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 1 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(26_000_000)), + Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(26_000_000)), RemainCollateral: sdk.NewCoin("atom", math.NewInt(1_000_000)), }, }, }, expVaultStatus: []types.VaultStatus{types.LIQUIDATED}, reserveBalances: sdk.NewCoins( - sdk.NewCoin(types.DefaultMintDenom, math.NewInt(1_000_000)), + sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(1_000_000)), sdk.NewCoin("atom", math.LegacyNewDec(25_000_000).QuoInt(math.NewInt(7)).Mul(math.LegacyNewDecWithPrec(5, 2)).TruncateInt()), // (25/7)*0.05 ), }, { name: "single vault - remain collateral, not enough to cover debt, can reconstitute vault", liquidation: types.Liquidation{ - Denom: "atom", + DebtDenom: "atom", + MintDenom: types.DefaultMintDenom[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -377,7 +381,7 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 5 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom, math.ZeroInt()), + Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.ZeroInt()), RemainCollateral: sdk.NewCoin("atom", math.NewInt(5_000_000)), }, }, @@ -391,11 +395,12 @@ func (s *KeeperTestSuite) TestLiquidate() { { name: "single vault - remain collateral, not enough to cover debt, can reconstitute vault", liquidation: types.Liquidation{ - Denom: "atom", + DebtDenom: "atom", + MintDenom: types.DefaultMintDenom[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -405,7 +410,7 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 5 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom, math.ZeroInt()), + Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.ZeroInt()), RemainCollateral: sdk.NewCoin("atom", math.NewInt(5_000_000)), }, }, @@ -419,11 +424,12 @@ func (s *KeeperTestSuite) TestLiquidate() { { name: "single vault - remain collateral, not enough to cover debt, can not reconstitute vault", liquidation: types.Liquidation{ - Denom: "atom", + DebtDenom: "atom", + MintDenom: types.DefaultMintDenom[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -434,7 +440,7 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 4 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(7_000_000)), + Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(7_000_000)), RemainCollateral: sdk.NewCoin("atom", math.NewInt(4_000_000)), }, }, @@ -444,7 +450,7 @@ func (s *KeeperTestSuite) TestLiquidate() { // penalty sdk.NewCoin("atom", math.NewInt(4_000_000)), // (25/7)*0.05 ), - shortfallAmount: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(18_000_000)), + shortfallAmount: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(18_000_000)), }, } for _, t := range tests { @@ -458,8 +464,8 @@ func (s *KeeperTestSuite) TestLiquidate() { vault.Id = vaultId vault.Address = vaultAddr.String() - // err := s.App.VaultsKeeper.SetVault(s.Ctx, *vault) - // s.Require().NoError(err) + err := s.App.VaultsKeeper.SetVault(s.Ctx, *vault) + s.Require().NoError(err) // Fund collateral locked for vault lockCoins := sdk.NewCoins(t.liquidation.VaultLiquidationStatus[vaultId].RemainCollateral) @@ -474,7 +480,7 @@ func (s *KeeperTestSuite) TestLiquidate() { s.Require().NoError(err) } - err = s.App.VaultsKeeper.Liquidate(s.Ctx, t.liquidation) + err = s.App.VaultsKeeper.Liquidate(s.Ctx, t.liquidation, types.DefaultMintDenom[0]) s.Require().NoError(err) if t.reserveBalances != nil { From 1ee268b614bef25c1861029c4160031aad2d4848 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 1 Nov 2024 16:48:51 +0700 Subject: [PATCH 09/42] nit --- x/auction/keeper/liquidate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/auction/keeper/liquidate.go b/x/auction/keeper/liquidate.go index 128386dc..79e7632d 100644 --- a/x/auction/keeper/liquidate.go +++ b/x/auction/keeper/liquidate.go @@ -43,7 +43,7 @@ func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error { if err != nil { return err } - err = k.Bids.Set(ctx, auction.AuctionId, types.BidQueue{AuctionId: auction.AuctionId, Bids: []*types.Bid{}}) + err = k.Bids.Set(ctx, auction.AuctionId, types.BidQueue{AuctionId: auction.AuctionId, Bids: []types.Bid{}}) if err != nil { return err } From bd160837343ed8cc7f6a30112b0e5313f3cbaf34 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Mon, 4 Nov 2024 09:48:53 +0700 Subject: [PATCH 10/42] nits --- x/auction/keeper/grpc_query.go | 4 +--- x/auction/keeper/liquidate.go | 4 +--- x/oracle/keeper/band_oracle.go | 2 +- x/vaults/keeper/vaults_test.go | 6 +++--- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/x/auction/keeper/grpc_query.go b/x/auction/keeper/grpc_query.go index dee27f03..7cf0d65b 100644 --- a/x/auction/keeper/grpc_query.go +++ b/x/auction/keeper/grpc_query.go @@ -55,9 +55,7 @@ func (k Querier) QueryAllBids(ctx context.Context, req *types.QueryAllBidsReques allBids := []types.Bid{} err := k.k.Bids.Walk(ctx, nil, func(key uint64, value types.BidQueue) (stop bool, err error) { - for _, bid := range value.Bids { - allBids = append(allBids, bid) - } + allBids = append(allBids, value.Bids...) return false, nil }) diff --git a/x/auction/keeper/liquidate.go b/x/auction/keeper/liquidate.go index 79e7632d..b7178318 100644 --- a/x/auction/keeper/liquidate.go +++ b/x/auction/keeper/liquidate.go @@ -72,9 +72,7 @@ func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error { return err } } - if err != nil { - return err - } + return nil } diff --git a/x/oracle/keeper/band_oracle.go b/x/oracle/keeper/band_oracle.go index 7ceec386..a5efc1c4 100644 --- a/x/oracle/keeper/band_oracle.go +++ b/x/oracle/keeper/band_oracle.go @@ -296,7 +296,7 @@ func (k Keeper) GetPrice(ctx context.Context, base, quote string) *math.LegacyDe return nil } - if quote == types.QuoteUSD || quote == vaultstypes.DefaultMintDenom { + if quote == types.QuoteUSD || quote == vaultstypes.DefaultMintDenom[0] { return &basePriceState.PriceState.Price } diff --git a/x/vaults/keeper/vaults_test.go b/x/vaults/keeper/vaults_test.go index 18917ab0..07620e61 100644 --- a/x/vaults/keeper/vaults_test.go +++ b/x/vaults/keeper/vaults_test.go @@ -236,7 +236,7 @@ func (s *KeeperTestSuite) TestRepayDebt() { Owner: s.TestAccs[0].String(), Id: 0, Status: types.LIQUIDATED, - Debt: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(1000)), + Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(1000)), CollateralLocked: sdk.NewCoin(denom, math.ZeroInt()), }) s.Require().NoError(err) @@ -326,7 +326,7 @@ func (s *KeeperTestSuite) TestDepositToVault() { err = s.k.SetVault(s.Ctx, types.Vault{ Id: 0, Status: types.LIQUIDATED, - Debt: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(1000)), + Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(1000)), CollateralLocked: sdk.NewCoin(denom, math.ZeroInt()), }) s.Require().NoError(err) @@ -427,7 +427,7 @@ func (s *KeeperTestSuite) TestWithdrawFromVault() { Owner: s.TestAccs[0].String(), Id: 0, Status: types.LIQUIDATED, - Debt: sdk.NewCoin(types.DefaultMintDenom, math.NewInt(1000)), + Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(1000)), CollateralLocked: sdk.NewCoin(denom, math.ZeroInt()), }) s.Require().NoError(err) From 13f43deaa809fe0756ddfe699976a15ad1050fd2 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Mon, 4 Nov 2024 09:50:45 +0700 Subject: [PATCH 11/42] import nit --- x/oracle/keeper/keeper.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/x/oracle/keeper/keeper.go b/x/oracle/keeper/keeper.go index 6783db3f..0efb6ed0 100644 --- a/x/oracle/keeper/keeper.go +++ b/x/oracle/keeper/keeper.go @@ -6,7 +6,6 @@ import ( "cosmossdk.io/core/store" errorsmod "cosmossdk.io/errors" - ibchost "github.com/cosmos/ibc-go/v8/modules/core/24-host" "cosmossdk.io/log" "cosmossdk.io/store/prefix" @@ -81,7 +80,7 @@ func (k Keeper) Logger(ctx context.Context) log.Logger { // ChanCloseInit defines a wrapper function for the channel Keeper's function func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error { - capName := ibchost.ChannelCapabilityPath(portID, channelID) + capName := host.ChannelCapabilityPath(portID, channelID) chanCap, ok := k.scopedKeeper.GetCapability(ctx, capName) if !ok { return errorsmod.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName) @@ -91,7 +90,7 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error { // IsBound checks if the module is already bound to the desired port func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { - _, ok := k.scopedKeeper.GetCapability(ctx, ibchost.PortPath(portID)) + _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) return ok } From 7df5199861e14b128da1a37d1481d030044f6496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 14:32:21 +0700 Subject: [PATCH 12/42] proto --- proto/reserve/psm/v1/genesis.proto | 3 + proto/reserve/psm/v1/psm.proto | 2 +- proto/reserve/psm/v1/tx.proto | 3 +- x/psm/client/cli/tx.go | 2 +- x/psm/keeper/msg_server.go | 6 +- x/psm/keeper/msg_server_test.go | 6 +- x/psm/types/genesis.pb.go | 73 +++++++++++++-- x/psm/types/msgs.go | 2 +- x/psm/types/params.go | 2 +- x/psm/types/psm.pb.go | 2 +- x/psm/types/tx.pb.go | 131 +++++++++++++-------------- x/vaults/types/params.pb.go | 141 ++++++++++++++--------------- 12 files changed, 212 insertions(+), 161 deletions(-) diff --git a/proto/reserve/psm/v1/genesis.proto b/proto/reserve/psm/v1/genesis.proto index 8ed1a5f0..677ec7be 100644 --- a/proto/reserve/psm/v1/genesis.proto +++ b/proto/reserve/psm/v1/genesis.proto @@ -18,4 +18,7 @@ message GenesisState { repeated Stablecoin stablecoins = 2 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; + + repeated string nom = 3 + [ (amino.dont_omitempty) = true ]; } diff --git a/proto/reserve/psm/v1/psm.proto b/proto/reserve/psm/v1/psm.proto index 580cd16b..1e9cbb3d 100644 --- a/proto/reserve/psm/v1/psm.proto +++ b/proto/reserve/psm/v1/psm.proto @@ -11,7 +11,7 @@ option go_package = "github.com/onomyprotocol/reserve/x/psm/types"; message Stablecoin { // stablecoin name string denom = 1; - // limit total stablecoin module support + // limit total stablecoin bytes limit_total = 2 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", diff --git a/proto/reserve/psm/v1/tx.proto b/proto/reserve/psm/v1/tx.proto index f9e283e0..0582677c 100644 --- a/proto/reserve/psm/v1/tx.proto +++ b/proto/reserve/psm/v1/tx.proto @@ -48,7 +48,8 @@ message MsgSwapTonomUSD { option (cosmos.msg.v1.signer) = "address"; string address = 1; - cosmos.base.v1beta1.Coin coin = 2; + cosmos.base.v1beta1.Coin coin = 2 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } message MsgSwapTonomUSDResponse {} diff --git a/x/psm/client/cli/tx.go b/x/psm/client/cli/tx.go index d1902b7b..5b321668 100644 --- a/x/psm/client/cli/tx.go +++ b/x/psm/client/cli/tx.go @@ -49,7 +49,7 @@ func NewSwapTonomUSDCmd() *cobra.Command { } addr := clientCtx.GetFromAddress() - msg := types.NewMsgSwapTonomUSD(addr.String(), &stablecoin) + msg := types.NewMsgSwapTonomUSD(addr.String(), stablecoin) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, diff --git a/x/psm/keeper/msg_server.go b/x/psm/keeper/msg_server.go index 2cc38600..056cc28b 100644 --- a/x/psm/keeper/msg_server.go +++ b/x/psm/keeper/msg_server.go @@ -63,19 +63,19 @@ func (k msgServer) SwapTonomUSD(ctx context.Context, msg *types.MsgSwapTonomUSD) // check balance user and calculate amount of coins received addr := sdk.MustAccAddressFromBech32(msg.Address) - receiveAmountnomUSD, fee_in, err := k.keeper.SwapTonomUSD(ctx, addr, *msg.Coin) + receiveAmountnomUSD, fee_in, err := k.keeper.SwapTonomUSD(ctx, addr, msg.Coin) if err != nil { return nil, err } // add total stablecoin lock - err = k.keeper.AddTotalStablecoinLock(ctx, *msg.Coin) + err = k.keeper.AddTotalStablecoinLock(ctx, msg.Coin) if err != nil { return nil, err } // send stablecoin to module - err = k.keeper.BankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, sdk.NewCoins(*msg.Coin)) + err = k.keeper.BankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, sdk.NewCoins(msg.Coin)) if err != nil { return nil, err } diff --git a/x/psm/keeper/msg_server_test.go b/x/psm/keeper/msg_server_test.go index dd40872f..470dee20 100644 --- a/x/psm/keeper/msg_server_test.go +++ b/x/psm/keeper/msg_server_test.go @@ -46,7 +46,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { amountSwap := sdk.NewCoin(usdt, math.NewInt(1000)) return &types.MsgSwapTonomUSD{ Address: s.TestAccs[0].String(), - Coin: &amountSwap, + Coin: amountSwap, } }, @@ -69,7 +69,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { amountSwap := sdk.NewCoin(usdc, math.NewInt(1000)) return &types.MsgSwapTonomUSD{ Address: s.TestAccs[1].String(), - Coin: &amountSwap, + Coin: amountSwap, } }, @@ -130,7 +130,7 @@ func (s *KeeperTestSuite) TestMsgSwapToStablecoin() { amountSwap := sdk.NewCoin(usdt, math.NewInt(1001)) msg := &types.MsgSwapTonomUSD{ Address: s.TestAccs[0].String(), - Coin: &amountSwap, + Coin: amountSwap, } _, err = s.msgServer.SwapTonomUSD(s.Ctx, msg) s.Require().NoError(err) diff --git a/x/psm/types/genesis.pb.go b/x/psm/types/genesis.pb.go index 6353f3f8..a4ff1c2a 100644 --- a/x/psm/types/genesis.pb.go +++ b/x/psm/types/genesis.pb.go @@ -29,6 +29,7 @@ type GenesisState struct { // params defines all the parameters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` Stablecoins []Stablecoin `protobuf:"bytes,2,rep,name=stablecoins,proto3" json:"stablecoins"` + Nom []string `protobuf:"bytes,3,rep,name=nom,proto3" json:"nom,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -78,6 +79,13 @@ func (m *GenesisState) GetStablecoins() []Stablecoin { return nil } +func (m *GenesisState) GetNom() []string { + if m != nil { + return m.Nom + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "reserve.psm.v1.GenesisState") } @@ -85,23 +93,25 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/genesis.proto", fileDescriptor_fbe4ca1f3927cde8) } var fileDescriptor_fbe4ca1f3927cde8 = []byte{ - // 256 bytes of a gzipped FileDescriptorProto + // 275 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x4a, 0x2d, 0x4e, 0x2d, 0x2a, 0x4b, 0xd5, 0x2f, 0x28, 0xce, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xca, 0xea, 0x15, 0x14, 0xe7, 0xea, 0x95, 0x19, 0x4a, 0x09, 0x26, 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x12, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, 0x53, 0x1f, 0xc4, 0x82, 0x8a, 0x4a, 0xa3, 0x19, 0x5b, 0x90, - 0x58, 0x94, 0x98, 0x0b, 0x35, 0x55, 0x4a, 0x02, 0x5d, 0xb2, 0x38, 0x17, 0x22, 0xa3, 0x34, 0x89, + 0x58, 0x94, 0x98, 0x0b, 0x35, 0x55, 0x4a, 0x02, 0x5d, 0xb2, 0x38, 0x17, 0x22, 0xa3, 0xb4, 0x9a, 0x91, 0x8b, 0xc7, 0x1d, 0xe2, 0x82, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x4b, 0x2e, 0x36, 0x88, 0x56, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x31, 0x3d, 0x54, 0x17, 0xe9, 0x05, 0x80, 0x65, 0x9d, 0x38, 0x4f, 0xdc, 0x93, 0x67, 0x58, 0xf1, 0x7c, 0x83, 0x16, 0x63, 0x10, 0x54, 0x83, 0x90, 0x3b, 0x17, 0x77, 0x71, 0x49, 0x62, 0x52, 0x4e, 0x6a, 0x72, 0x7e, 0x66, 0x5e, 0xb1, 0x04, 0x93, - 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x14, 0xba, 0xfe, 0x60, 0xb8, 0x12, 0x64, 0x33, 0x90, 0x75, 0x3a, - 0xb9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, - 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, - 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x7e, 0x5e, 0x7e, 0x6e, 0x25, 0xd8, 0x17, 0xc9, - 0xf9, 0x39, 0xfa, 0x30, 0x1f, 0x56, 0x80, 0xfd, 0x58, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, - 0x96, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x42, 0x95, 0xd9, 0x55, 0x73, 0x01, 0x00, 0x00, + 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x14, 0xba, 0xfe, 0x60, 0xb8, 0x12, 0x64, 0x33, 0x90, 0x75, 0x0a, + 0x89, 0x73, 0x31, 0xe7, 0xe5, 0xe7, 0x4a, 0x30, 0x2b, 0x30, 0x6b, 0x70, 0x3a, 0xb1, 0x42, 0x14, + 0x80, 0x44, 0x9c, 0xdc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, + 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x27, + 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x3f, 0x2f, 0x3f, 0xb7, 0x12, + 0xec, 0xbd, 0xe4, 0xfc, 0x1c, 0x7d, 0x98, 0xd7, 0x2b, 0xc0, 0x9e, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, + 0x4e, 0x62, 0x03, 0xcb, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xb1, 0xea, 0xbb, 0x8c, + 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -124,6 +134,15 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Nom) > 0 { + for iNdEx := len(m.Nom) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Nom[iNdEx]) + copy(dAtA[i:], m.Nom[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Nom[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } if len(m.Stablecoins) > 0 { for iNdEx := len(m.Stablecoins) - 1; iNdEx >= 0; iNdEx-- { { @@ -176,6 +195,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.Nom) > 0 { + for _, s := range m.Nom { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -281,6 +306,38 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Nom = append(m.Nom, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/psm/types/msgs.go b/x/psm/types/msgs.go index d0e6f483..e7dd1137 100644 --- a/x/psm/types/msgs.go +++ b/x/psm/types/msgs.go @@ -31,7 +31,7 @@ func init() { } -func NewMsgSwapTonomUSD(addr string, coin *sdk.Coin) *MsgSwapTonomUSD { +func NewMsgSwapTonomUSD(addr string, coin sdk.Coin) *MsgSwapTonomUSD { return &MsgSwapTonomUSD{ Address: addr, Coin: coin, diff --git a/x/psm/types/params.go b/x/psm/types/params.go index 62041a52..288a8ef1 100644 --- a/x/psm/types/params.go +++ b/x/psm/types/params.go @@ -24,7 +24,7 @@ func NewParams( return Params{ LimitTotal: limitTotal, AcceptablePriceRatio: acceptablePriceRatio, - AdjustmentFee: DefaultAdjustmentFee, + AdjustmentFee: adjustmentFee, } } diff --git a/x/psm/types/psm.pb.go b/x/psm/types/psm.pb.go index a4ec34cf..af6741aa 100644 --- a/x/psm/types/psm.pb.go +++ b/x/psm/types/psm.pb.go @@ -30,7 +30,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Stablecoin struct { // stablecoin name Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - // limit total stablecoin module support + // limit total stablecoin LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` // stablecoin to nomUSD exchange fee, fee_in when 1 stablecoin = 1nomUSD FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` diff --git a/x/psm/types/tx.pb.go b/x/psm/types/tx.pb.go index b5546a6f..20e0eb1c 100644 --- a/x/psm/types/tx.pb.go +++ b/x/psm/types/tx.pb.go @@ -129,8 +129,8 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo type MsgSwapTonomUSD struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Coin *types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin"` } func (m *MsgSwapTonomUSD) Reset() { *m = MsgSwapTonomUSD{} } @@ -173,11 +173,11 @@ func (m *MsgSwapTonomUSD) GetAddress() string { return "" } -func (m *MsgSwapTonomUSD) GetCoin() *types.Coin { +func (m *MsgSwapTonomUSD) GetCoin() types.Coin { if m != nil { return m.Coin } - return nil + return types.Coin{} } type MsgSwapTonomUSDResponse struct { @@ -503,54 +503,54 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/tx.proto", fileDescriptor_d0ff2d5421e71e2a) } var fileDescriptor_d0ff2d5421e71e2a = []byte{ - // 750 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xc1, 0x4e, 0xdb, 0x4a, - 0x14, 0x8d, 0x09, 0x81, 0x97, 0x21, 0x7a, 0x8f, 0xe7, 0x86, 0xe2, 0x98, 0x62, 0xa2, 0xb4, 0x52, - 0x23, 0x0a, 0x36, 0xa1, 0x6a, 0xa5, 0xb2, 0x23, 0x8d, 0xaa, 0x52, 0x15, 0x95, 0x26, 0x20, 0xa1, - 0x6e, 0xa2, 0x89, 0x3d, 0x38, 0x56, 0x63, 0x8f, 0xe5, 0x99, 0xa4, 0x64, 0x57, 0x55, 0x5d, 0x75, - 0xd5, 0x6f, 0xe8, 0xaa, 0x4b, 0x16, 0xa8, 0xdf, 0xc0, 0x12, 0xb1, 0xaa, 0xba, 0x40, 0x15, 0x2c, - 0xf8, 0x09, 0x16, 0xd5, 0xd8, 0x13, 0x13, 0x3b, 0xa1, 0x20, 0xba, 0xed, 0x26, 0xca, 0xcc, 0x3d, - 0xf7, 0xdc, 0x73, 0xcf, 0x5c, 0x5d, 0x83, 0x69, 0x0f, 0x11, 0xe4, 0x75, 0x90, 0xe6, 0x12, 0x5b, - 0xeb, 0x94, 0x34, 0xba, 0xab, 0xba, 0x1e, 0xa6, 0x58, 0xfc, 0x97, 0x07, 0x54, 0x97, 0xd8, 0x6a, - 0xa7,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47, 0x1a, - 0xf5, 0xd9, 0x4a, 0x9c, 0x6d, 0x66, 0x90, 0xed, 0x25, 0x32, 0xa1, 0xde, 0xad, 0x20, 0xbd, 0x8f, - 0xb3, 0x82, 0xf4, 0x6a, 0x6a, 0x07, 0xa1, 0x35, 0x47, 0x7c, 0x01, 0xc6, 0x19, 0x13, 0x6e, 0x53, - 0x29, 0x75, 0x53, 0x2a, 0xa6, 0xe5, 0x55, 0x9b, 0xae, 0x94, 0x06, 0x27, 0x5c, 0x19, 0x98, 0xf0, - 0x88, 0xd3, 0x05, 0x19, 0x48, 0xf1, 0xbb, 0xf0, 0x69, 0x3e, 0x26, 0x41, 0x36, 0x9c, 0x7f, 0xf2, - 0xf7, 0x79, 0xfe, 0xf4, 0x79, 0x1e, 0x0d, 0x3e, 0x4f, 0xe1, 0x92, 0x05, 0xd4, 0xe7, 0x76, 0x41, - 0x01, 0x77, 0x86, 0xdd, 0xf7, 0x9e, 0x69, 0xf9, 0x3c, 0x09, 0x92, 0xeb, 0xc4, 0x14, 0xb7, 0x41, - 0x26, 0xb2, 0x62, 0xe7, 0xe2, 0xab, 0x31, 0xb6, 0xcb, 0xe4, 0xfb, 0x57, 0x00, 0x7a, 0x15, 0x44, - 0x1d, 0x4c, 0x45, 0x26, 0x64, 0xc3, 0xc3, 0x2e, 0x26, 0xb0, 0x25, 0xe6, 0x87, 0x30, 0x44, 0x90, - 0x72, 0xf1, 0x2a, 0x44, 0x58, 0x04, 0x83, 0xdc, 0x40, 0x8f, 0x61, 0xa1, 0x7b, 0x97, 0x4a, 0xed, - 0x43, 0xcb, 0x0b, 0xd7, 0x41, 0x85, 0x05, 0xb7, 0x41, 0x26, 0xb2, 0xbf, 0x87, 0xf9, 0xd5, 0x0f, - 0x18, 0xea, 0xd7, 0xb0, 0xbd, 0x2c, 0x1a, 0x60, 0x72, 0x60, 0x27, 0xdf, 0xbd, 0x34, 0xf9, 0x02, - 0x24, 0x3f, 0xb8, 0x06, 0xa8, 0x57, 0x45, 0x4e, 0xbd, 0x67, 0x73, 0x5f, 0x7e, 0x76, 0x70, 0xa2, - 0x08, 0x87, 0x27, 0x8a, 0xf0, 0xf3, 0x44, 0x11, 0x3e, 0x9f, 0x2a, 0x89, 0xc3, 0x53, 0x25, 0xf1, - 0xfd, 0x54, 0x49, 0xbc, 0x59, 0x30, 0x2d, 0xda, 0x6c, 0x37, 0x54, 0x1d, 0xdb, 0x1a, 0x93, 0xd8, - 0xf5, 0x3f, 0xc7, 0x3a, 0x6e, 0x69, 0xd1, 0xa9, 0xa3, 0x5d, 0x17, 0x91, 0xc6, 0x98, 0x1f, 0x7d, - 0xf8, 0x2b, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x63, 0xf9, 0xdb, 0x71, 0x08, 0x00, 0x00, + // 751 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xc1, 0x4f, 0x13, 0x4f, + 0x14, 0xee, 0x52, 0x0a, 0xbf, 0x0e, 0xcd, 0x4f, 0x5c, 0x8b, 0x6c, 0x17, 0x59, 0x9a, 0x6a, 0x62, + 0x83, 0xb0, 0x4b, 0x31, 0x1a, 0xe5, 0x46, 0x6d, 0x8c, 0x18, 0x89, 0xd8, 0x42, 0x42, 0xbc, 0x34, + 0xd3, 0xdd, 0x61, 0xd9, 0xd8, 0xdd, 0xd9, 0xec, 0x4c, 0x2b, 0xbd, 0x19, 0xe3, 0xc9, 0x93, 0x7f, + 0x83, 0x27, 0x8f, 0x1c, 0x88, 0x7f, 0x03, 0x47, 0xc2, 0xc9, 0x78, 0x20, 0x06, 0x0e, 0xfc, 0x13, + 0x1c, 0xcc, 0xec, 0x4e, 0x97, 0xee, 0xb6, 0x08, 0xc1, 0xab, 0x97, 0xa6, 0x33, 0xef, 0xbd, 0xef, + 0x7d, 0xdf, 0x37, 0xaf, 0xaf, 0x60, 0xd2, 0x43, 0x04, 0x79, 0x6d, 0xa4,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e3, 0x0b, 0x8b, 0x91, 0x2c, 0xe4, 0xc0, 0x64, 0xec, 0xaa, 0x8a, 0x88, 0x8b, 0x1d, + 0x82, 0x0a, 0xc4, 0x97, 0x54, 0x7b, 0x0f, 0xdd, 0x75, 0xec, 0x60, 0x7b, 0xa3, 0x56, 0x11, 0x25, + 0x30, 0x0a, 0x03, 0xda, 0x81, 0xa0, 0x6a, 0xf7, 0x28, 0x3e, 0x01, 0xc3, 0xcc, 0x0e, 0x4e, 0x39, + 0xa7, 0x72, 0x91, 0xcc, 0x2f, 0x95, 0xfb, 0xa5, 0x3e, 0xc3, 0x96, 0xd3, 0xcb, 0xda, 0xaf, 0x58, + 0xca, 0x30, 0xce, 0x5d, 0x1c, 0xce, 0xa7, 0xb7, 0x69, 0xc8, 0xe7, 0xab, 0x00, 0x6e, 0x85, 0xb1, + 0x1a, 0x85, 0x8d, 0x26, 0x62, 0x00, 0x7f, 0x20, 0x95, 0x03, 0xff, 0x51, 0x5c, 0x37, 0x90, 0x83, + 0x6d, 0x9f, 0x58, 0xba, 0x3a, 0x4a, 0x71, 0x85, 0x1d, 0xc5, 0x17, 0x60, 0x04, 0xda, 0xb8, 0xe5, + 0x50, 0x29, 0x99, 0x17, 0x8a, 0x99, 0xf2, 0x02, 0xa3, 0xf5, 0xf3, 0x68, 0x66, 0x22, 0x20, 0x4e, + 0x8c, 0x77, 0xaa, 0x85, 0x35, 0x1b, 0xd2, 0x6d, 0x75, 0xc5, 0xa1, 0x87, 0x7b, 0xf3, 0x80, 0x2b, + 0x5a, 0x71, 0x28, 0xf7, 0x3c, 0xa8, 0x8f, 0xf1, 0x9f, 0x06, 0x53, 0x03, 0x38, 0x86, 0x1a, 0xce, + 0x86, 0xc0, 0xf8, 0x2a, 0x31, 0x97, 0x0d, 0x23, 0x08, 0x32, 0x4b, 0xae, 0x3d, 0x28, 0x59, 0x90, + 0xea, 0xd5, 0x16, 0x1c, 0xc4, 0x37, 0x60, 0xac, 0x69, 0xd9, 0x16, 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 0xd7, 0xa0, 0xbd, 0x2c, 0x1a, 0x60, 0xbc, 0x6f, 0x27, 0xdf, 0xbd, 0xb0, 0xf8, 0x3c, + 0x49, 0x7e, 0x70, 0x85, 0xa4, 0x6e, 0x17, 0x39, 0xf5, 0x81, 0xcd, 0x7d, 0xf9, 0xf9, 0xfe, 0xb1, + 0x22, 0x1c, 0x1c, 0x2b, 0xc2, 0xaf, 0x63, 0x45, 0xf8, 0x72, 0xa2, 0x24, 0x0e, 0x4e, 0x94, 0xc4, + 0x8f, 0x13, 0x25, 0xf1, 0x76, 0xce, 0xb4, 0xe8, 0x76, 0xab, 0xa1, 0xea, 0xd8, 0xd6, 0x18, 0xc5, + 0x8e, 0xff, 0xcf, 0xac, 0xe3, 0xa6, 0x16, 0x9d, 0x3a, 0xda, 0x71, 0x11, 0x69, 0x8c, 0xf8, 0xd1, + 0x87, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x87, 0x77, 0x02, 0xba, 0x7c, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -864,18 +864,16 @@ func (m *MsgSwapTonomUSD) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Coin != nil { - { - size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + { + size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) @@ -1204,10 +1202,8 @@ func (m *MsgSwapTonomUSD) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.Coin != nil { - l = m.Coin.Size() - n += 1 + l + sovTx(uint64(l)) - } + l = m.Coin.Size() + n += 1 + l + sovTx(uint64(l)) return n } @@ -1573,9 +1569,6 @@ func (m *MsgSwapTonomUSD) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Coin == nil { - m.Coin = &types.Coin{} - } if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/vaults/types/params.pb.go b/x/vaults/types/params.pb.go index 7f9c89c8..2600ff0d 100644 --- a/x/vaults/types/params.pb.go +++ b/x/vaults/types/params.pb.go @@ -81,7 +81,6 @@ type Params struct { MinInitialDebt cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=min_initial_debt,json=minInitialDebt,proto3,customtype=cosmossdk.io/math.Int" json:"min_initial_debt"` AllowedMintDenom []string `protobuf:"bytes,2,rep,name=allowed_mint_denom,json=allowedMintDenom,proto3" json:"allowed_mint_denom,omitempty"` ChargingPeriod time.Duration `protobuf:"bytes,3,opt,name=charging_period,json=chargingPeriod,proto3,stdduration" json:"charging_period"` - LiquidatePeriod time.Duration `protobuf:"bytes,4,opt,name=liquidate_period,json=liquidatePeriod,proto3,stdduration" json:"liquidate_period"` } func (m *Params) Reset() { *m = Params{} } @@ -500,77 +499,75 @@ func init() { func init() { proto.RegisterFile("reserve/vaults/params.proto", fileDescriptor_1f12ab0d072f9f7c) } var fileDescriptor_1f12ab0d072f9f7c = []byte{ - // 1107 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x3b, 0x6f, 0x1b, 0x47, - 0x10, 0xe6, 0x91, 0x14, 0x6d, 0x0d, 0x6d, 0x8a, 0xda, 0xc8, 0x0a, 0x4d, 0x21, 0x14, 0xc1, 0x22, - 0x10, 0x84, 0xf8, 0x2e, 0xa6, 0x81, 0xc4, 0x30, 0x92, 0x42, 0x12, 0xa9, 0x80, 0x30, 0xed, 0x48, - 0x27, 0xd9, 0x06, 0x9c, 0x82, 0x58, 0x1e, 0xd7, 0xa7, 0x85, 0xee, 0x6e,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fc, 0xb7, 0x60, 0x46, 0x54, 0xc2, 0x61, 0x9e, - 0x87, 0x39, 0x09, 0xb1, 0xd7, 0x91, 0x01, 0x95, 0xd2, 0xb2, 0x1a, 0x9f, 0xe8, 0x6a, 0xcc, 0x9d, - 0xae, 0x46, 0x9b, 0xb8, 0xd8, 0x19, 0x35, 0x88, 0x93, 0xa8, 0x49, 0x83, 0x38, 0x2a, 0x7c, 0xe4, - 0xd3, 0x60, 0x65, 0x0c, 0x69, 0x0b, 0x44, 0xe4, 0xc0, 0x74, 0x9c, 0x14, 0x65, 0x81, 0xbe, 0x26, - 0x73, 0xa1, 0x6b, 0x8a, 0x09, 0x40, 0x75, 0xc9, 0x5d, 0xb8, 0xec, 0xe3, 0x5d, 0x25, 0xa8, 0xec, - 0xff, 0x14, 0xd4, 0x25, 0x1f, 0xef, 0x4a, 0x25, 0x7d, 0x05, 0x57, 0x23, 0x8e, 0xbb, 0xd4, 0xa3, - 0x7c, 0xd4, 0x79, 0x42, 0x48, 0x69, 0xe2, 0x42, 0xd1, 0x5e, 0x19, 0x83, 0xad, 0x12, 0x82, 0x5c, - 0x78, 0x2f, 0x49, 0x47, 0x9f, 0x04, 0xd8, 0xe3, 0xa3, 0x52, 0xee, 0x62, 0xbc, 0x27, 0x20, 0xd7, - 0x14, 0x22, 0x7a, 0x04, 0x79, 0x51, 0x6e, 0x21, 0x70, 0x91, 0xc3, 0xa5, 0x0b, 0x5d, 0x00, 0x1a, - 0x6a, 0x95, 0x90, 0xda, 0xcf, 0x06, 0x5c, 0x49, 0x0a, 0x0e, 0x35, 0x21, 0xa7, 0xa6, 0x94, 0x94, - 0x59, 0xbe, 0x5e, 0x33, 0x8f, 0x8f, 0x29, 0xf3, 0xb4, 0x3c, 0x97, 0x27, 0x45, 0x20, 0x0a, 0x5b, - 0x3b, 0xa3, 0x19, 0x98, 0x88, 0x7b, 0x56, 0x88, 0x55, 0x2d, 0xd0, 0x23, 0x28, 0x48, 0x1d, 0xe3, - 0x21, 0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c6, 0xd2, 0x66, 0xeb, - 0xfe, 0x17, 0x45, 0xa3, 0x3c, 0xb5, 0xb7, 0x5f, 0x4d, 0x6e, 0xa1, 0x32, 0x5c, 0xde, 0xb4, 0x97, - 0xee, 0x6f, 0xac, 0x36, 0xed, 0x62, 0xba, 0x7c, 0x65, 0x6f, 0xbf, 0x3a, 0x5e, 0x0b, 0xd4, 0x95, - 0xf6, 0x97, 0x1b, 0xcd, 0x46, 0x31, 0xa3, 0x50, 0xd5, 0x0a, 0x55, 0x00, 0x62, 0x88, 0x66, 0xa3, - 0x98, 0x2d, 0x17, 0xf6, 0xf6, 0xab, 0x89, 0x9d, 0x72, 0xf6, 0xeb, 0x1f, 0x2a, 0xa9, 0xe5, 0xd6, - 0xcb, 0x83, 0x8a, 0xf1, 0xea, 0xa0, 0x62, 0xfc, 0x71, 0x50, 0x31, 0x9e, 0x1d, 0x56, 0x52, 0xaf, - 0x0e, 0x2b, 0xa9, 0x5f, 0x0e, 0x2b, 0xa9, 0xc7, 0x96, 0x4b, 0xf9, 0xd6, 0xa0, 0x6b, 0x3a, 0xcc, - 0xb7, 0x58, 0xc0, 0xfc, 0x91, 0x4c, 0xdb, 0x61, 0x9e, 0x75, 0xea, 0xdb, 0x81, 0x8f, 0xfa, 0x24, - 0xea, 0xe6, 0xa4, 0xc1, 0xad, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x91, 0x71, 0x1a, 0xeb, 0x74, - 0x0a, 0x00, 0x00, + // 1088 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xbb, 0x6f, 0xdb, 0x46, + 0x18, 0x17, 0x25, 0x59, 0x89, 0x3f, 0x25, 0x8a, 0x7c, 0x75, 0x5c, 0x45, 0x46, 0x65, 0x41, 0x43, + 0x61, 0x18, 0x0d, 0xd9, 0x28, 0x40, 0x1b, 0x04, 0xed, 0x60, 0x5b, 0x72, 0x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, 0x1b, 0x9d, 0x7b, 0x5f, 0x94, + 0x8d, 0xea, 0x95, 0xdd, 0xbd, 0x7a, 0x5a, 0x84, 0xaa, 0x70, 0x71, 0xc3, 0x5e, 0xbc, 0xb7, 0xbe, + 0xd2, 0xb6, 0xcb, 0xd9, 0xea, 0xa5, 0xdd, 0xbd, 0xfa, 0xe1, 0x59, 0xa0, 0x2e, 0x77, 0xbf, 0x5c, + 0x6f, 0xb7, 0xca, 0x39, 0x85, 0xaa, 0x4e, 0xa8, 0x06, 0x90, 0x40, 0xb4, 0x5b, 0xe5, 0x7c, 0xb5, + 0xb4, 0xbb, 0x57, 0x4f, 0x49, 0xaa, 0xf9, 0x6f, 0x7e, 0xac, 0x65, 0x96, 0x3a, 0x2f, 0xf6, 0x6b, + 0xc6, 0xcb, 0xfd, 0x9a, 0xf1, 0xc7, 0x7e, 0xcd, 0x78, 0x7a, 0x50, 0xcb, 0xbc, 0x3c, 0xa8, 0x65, + 0x7e, 0x3d, 0xa8, 0x65, 0x1e, 0x59, 0x1e, 0xe5, 0x9b, 0xc3, 0xbe, 0xe9, 0xb0, 0xc0, 0x62, 0x21, + 0x0b, 0xc6, 0x32, 0x6d, 0x87, 0xf9, 0xd6, 0xa9, 0xb7, 0x03, 0x1f, 0x0f, 0x48, 0xdc, 0x2f, 0x48, + 0x83, 0x9b, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0xc5, 0x27, 0x38, 0xb9, 0x1f, 0x0a, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { From 8391e3df10c56d6c08d6f8b43d62bf6dc1a54ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 14:39:25 +0700 Subject: [PATCH 13/42] nits --- proto/reserve/psm/v1/psm.proto | 2 + x/psm/types/genesis.go | 1 + x/psm/types/psm.pb.go | 105 +++++++++++++++++++++++++-------- 3 files changed, 82 insertions(+), 26 deletions(-) diff --git a/proto/reserve/psm/v1/psm.proto b/proto/reserve/psm/v1/psm.proto index 1e9cbb3d..dba7fd8b 100644 --- a/proto/reserve/psm/v1/psm.proto +++ b/proto/reserve/psm/v1/psm.proto @@ -43,4 +43,6 @@ message Stablecoin { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; + // type nom which swaps at a 1:1 ratio, as nomUSD ~ 1 USDT + string nom_type = 7; } diff --git a/x/psm/types/genesis.go b/x/psm/types/genesis.go index e4b4f58d..2f417171 100644 --- a/x/psm/types/genesis.go +++ b/x/psm/types/genesis.go @@ -10,6 +10,7 @@ func DefaultGenesis() *GenesisState { // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), Stablecoins: []Stablecoin{}, + Nom: []string{DefaultMintDenom}, } } diff --git a/x/psm/types/psm.pb.go b/x/psm/types/psm.pb.go index af6741aa..959a4fc8 100644 --- a/x/psm/types/psm.pb.go +++ b/x/psm/types/psm.pb.go @@ -40,6 +40,8 @@ type Stablecoin struct { TotalStablecoinLock cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=total_stablecoin_lock,json=totalStablecoinLock,proto3,customtype=cosmossdk.io/math.Int" json:"total_stablecoin_lock"` // maximum fee for when either fee = 0 FeeMaxStablecoin cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=fee_max_stablecoin,json=feeMaxStablecoin,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_max_stablecoin"` + // type nom which swaps at a 1:1 ratio, as nomUSD ~ 1 USDT + NomType string `protobuf:"bytes,7,opt,name=nom_type,json=nomType,proto3" json:"nom_type,omitempty"` } func (m *Stablecoin) Reset() { *m = Stablecoin{} } @@ -82,6 +84,13 @@ func (m *Stablecoin) GetDenom() string { return "" } +func (m *Stablecoin) GetNomType() string { + if m != nil { + return m.NomType + } + return "" +} + func init() { proto.RegisterType((*Stablecoin)(nil), "reserve.psm.v1.Stablecoin") } @@ -89,32 +98,33 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/psm.proto", fileDescriptor_59572214fa05fb2f) } var fileDescriptor_59572214fa05fb2f = []byte{ - // 392 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0xc1, 0xca, 0xd3, 0x40, - 0x10, 0xc7, 0x13, 0x3f, 0x5b, 0x71, 0x15, 0xd1, 0xf5, 0xfb, 0x20, 0x7e, 0x42, 0x5a, 0x3c, 0x15, - 0xd1, 0xac, 0xc1, 0x37, 0x28, 0x45, 0xac, 0x54, 0xc4, 0xea, 0xc9, 0x4b, 0xd8, 0x6c, 0xa7, 0x69, - 0x68, 0x76, 0xa7, 0x74, 0xb7, 0xa1, 0x7d, 0x0b, 0x1f, 0xc3, 0xa3, 0x07, 0x1f, 0xa2, 0xc7, 0xd2, - 0x93, 0x78, 0x28, 0xd2, 0x1e, 0x7c, 0x0d, 0xd9, 0x4d, 0xb4, 0x85, 0xef, 0xd6, 0x4b, 0xb2, 0x33, - 0xff, 0xe1, 0x37, 0xff, 0x19, 0x86, 0x04, 0x73, 0xd0, 0x30, 0x2f, 0x81, 0xcd, 0xb4, 0x64, 0x65, - 0x6c, 0x7f, 0xd1, 0x6c, 0x8e, 0x06, 0xe9, 0x83, 0x5a, 0x89, 0x6c, 0xaa, 0x8c, 0xaf, 0x2f, 0x33, - 0xcc, 0xd0, 0x49, 0xcc, 0xbe, 0xaa, 0xaa, 0xeb, 0x27, 0x02, 0xb5, 0x44, 0x9d, 0x54, 0x42, 0x15, - 0xd4, 0xd2, 0x23, 0x2e, 0x73, 0x85, 0xcc, 0x7d, 0xeb, 0x54, 0x58, 0x15, 0xb0, 0x94, 0x6b, 0x60, - 0x65, 0x9c, 0x82, 0xe1, 0x31, 0x13, 0x98, 0xab, 0x4a, 0x7f, 0xb6, 0xbd, 0x20, 0xe4, 0x93, 0xe1, - 0x69, 0x01, 0x36, 0x49, 0x2f, 0x49, 0x63, 0x04, 0x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, 0xcb, 0xcd, - 0x64, 0x91, 0x46, 0x02, 0x25, 0x43, 0x85, 0x72, 0xe5, 0xae, 0x40, 0x60, 0xc1, 0xfe, 0x5d, 0xe5, - 0xd2, 0xdd, 0xa5, 0x59, 0xcd, 0x40, 0xa7, 0x4d, 0xa7, 0xbe, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, - 0xb3, 0x1e, 0x39, 0x3f, 0xb3, 0x02, 0x00, 0x00, + // 412 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x4f, 0x8e, 0xd3, 0x30, + 0x14, 0xc6, 0x13, 0x86, 0xb6, 0x60, 0x10, 0x02, 0x33, 0x23, 0x79, 0x06, 0x29, 0x33, 0x62, 0x35, + 0x42, 0x10, 0x13, 0x71, 0x83, 0xd1, 0x08, 0x51, 0x34, 0x08, 0x51, 0x66, 0xc5, 0x26, 0x72, 0xdc, + 0xd7, 0x4c, 0xd4, 0xd8, 0x2f, 0xaa, 0xdd, 0xa8, 0xb9, 0x05, 0xc7, 0x60, 0xc9, 0x82, 0x43, 0xcc, + 0xb2, 0x62, 0x85, 0x58, 0x54, 0xa8, 0x5d, 0xb0, 0xe2, 0x0e, 0xc8, 0x4e, 0x80, 0x4a, 0xec, 0xba, + 0x49, 0xec, 0xf7, 0x59, 0xbf, 0xf7, 0xbd, 0x3f, 0x84, 0xcd, 0xc0, 0xc0, 0xac, 0x06, 0x5e, 0x19, + 0xc5, 0xeb, 0xc4, 0xfd, 0xe2, 0x6a, 0x86, 0x16, 0xe9, 0xbd, 0x4e, 0x89, 0x5d, 0xa8, 0x4e, 0x8e, + 0xf6, 0x73, 0xcc, 0xd1, 0x4b, 0xdc, 0x9d, 0xda, 0x57, 0x47, 0x87, 0x12, 0x8d, 0x42, 0x93, 0xb6, + 0x42, 0x7b, 0xe9, 0xa4, 0x07, 0x42, 0x15, 0x1a, 0xb9, 0xff,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xae, + 0xe6, 0xef, 0x4f, 0x00, 0xde, 0x88, 0xc5, 0xd6, 0x14, 0x0f, 0xc9, 0x2d, 0x8d, 0x2a, 0xb5, 0x4d, + 0x05, 0x6c, 0xe0, 0x07, 0x39, 0xd0, 0xa8, 0x2e, 0x9b, 0x0a, 0xce, 0x5e, 0x5e, 0xaf, 0xa3, 0x70, + 0xb9, 0x8e, 0xc2, 0x1f, 0xeb, 0x28, 0xfc, 0xb8, 0x89, 0x82, 0xe5, 0x26, 0x0a, 0xbe, 0x6d, 0xa2, + 0xe0, 0xc3, 0xd3, 0xbc, 0xb0, 0x57, 0xf3, 0x2c, 0x96, 0xa8, 0x38, 0x6a, 0x54, 0x8d, 0x5f, 0x10, + 0x89, 0x25, 0xff, 0xb3, 0xb0, 0x0b, 0xbf, 0xb2, 0x8e, 0x6a, 0xb2, 0xbe, 0x57, 0x5f, 0xfc, 0x0e, + 0x00, 0x00, 0xff, 0xff, 0x0b, 0x61, 0x14, 0x2b, 0xce, 0x02, 0x00, 0x00, } func (m *Stablecoin) Marshal() (dAtA []byte, err error) { @@ -137,6 +147,13 @@ func (m *Stablecoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.NomType) > 0 { + i -= len(m.NomType) + copy(dAtA[i:], m.NomType) + i = encodeVarintPsm(dAtA, i, uint64(len(m.NomType))) + i-- + dAtA[i] = 0x3a + } { size := m.FeeMaxStablecoin.Size() i -= size @@ -228,6 +245,10 @@ func (m *Stablecoin) Size() (n int) { n += 1 + l + sovPsm(uint64(l)) l = m.FeeMaxStablecoin.Size() n += 1 + l + sovPsm(uint64(l)) + l = len(m.NomType) + if l > 0 { + n += 1 + l + sovPsm(uint64(l)) + } return n } @@ -463,6 +484,38 @@ func (m *Stablecoin) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NomType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPsm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPsm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPsm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NomType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPsm(dAtA[iNdEx:]) From 1e740fff4a8cac7d1f5c9f0c1bc7832db2e768ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 14:50:50 +0700 Subject: [PATCH 14/42] add Noms for genesis --- proto/reserve/psm/v1/genesis.proto | 2 +- x/psm/keeper/keeper.go | 2 ++ x/psm/module/genesis.go | 15 +++++++++++ x/psm/types/genesis.go | 2 +- x/psm/types/genesis.pb.go | 42 +++++++++++++++--------------- x/psm/types/keys.go | 9 +------ 6 files changed, 41 insertions(+), 31 deletions(-) diff --git a/proto/reserve/psm/v1/genesis.proto b/proto/reserve/psm/v1/genesis.proto index 677ec7be..44104e8d 100644 --- a/proto/reserve/psm/v1/genesis.proto +++ b/proto/reserve/psm/v1/genesis.proto @@ -19,6 +19,6 @@ message GenesisState { repeated Stablecoin stablecoins = 2 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; - repeated string nom = 3 + repeated string noms = 3 [ (amino.dont_omitempty) = true ]; } diff --git a/x/psm/keeper/keeper.go b/x/psm/keeper/keeper.go index 65311290..6d6ee508 100644 --- a/x/psm/keeper/keeper.go +++ b/x/psm/keeper/keeper.go @@ -37,6 +37,7 @@ type ( OracleKeeper types.OracleKeeper Stablecoins collections.Map[string, types.Stablecoin] + Noms collections.Map[string, string] } ) @@ -69,6 +70,7 @@ func NewKeeper( OracleKeeper: oracleKeeper, Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), Stablecoins: collections.NewMap(sb, types.KeyStableCoin, "stablecoins", collections.StringKey, codec.CollValue[types.Stablecoin](cdc)), + Noms: collections.NewMap(sb, types.KeyNoms, "nom types", collections.StringKey, collections.StringValue), } schema, err := sb.Build() diff --git a/x/psm/module/genesis.go b/x/psm/module/genesis.go index d5f1107a..1791aa05 100644 --- a/x/psm/module/genesis.go +++ b/x/psm/module/genesis.go @@ -17,6 +17,13 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) } } + for _, nom := range genState.Noms { + err := k.Noms.Set(ctx, nom, nom) + if err != nil { + return err + } + } + return k.Params.Set(ctx, genState.Params) } @@ -34,6 +41,14 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) (*types.GenesisState, error genesis.Stablecoins = append(genesis.Stablecoins, value) return false, nil }) + if err != nil { + return nil, err + } + + err = k.Noms.Walk(ctx, nil, func(key string, value string) (stop bool, err error) { + genesis.Noms = append(genesis.Noms, value) + return false, nil + }) return genesis, err } diff --git a/x/psm/types/genesis.go b/x/psm/types/genesis.go index 2f417171..8f57c092 100644 --- a/x/psm/types/genesis.go +++ b/x/psm/types/genesis.go @@ -10,7 +10,7 @@ func DefaultGenesis() *GenesisState { // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), Stablecoins: []Stablecoin{}, - Nom: []string{DefaultMintDenom}, + Noms: []string{DefaultMintDenom}, } } diff --git a/x/psm/types/genesis.pb.go b/x/psm/types/genesis.pb.go index a4ff1c2a..9d102265 100644 --- a/x/psm/types/genesis.pb.go +++ b/x/psm/types/genesis.pb.go @@ -29,7 +29,7 @@ type GenesisState struct { // params defines all the parameters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` Stablecoins []Stablecoin `protobuf:"bytes,2,rep,name=stablecoins,proto3" json:"stablecoins"` - Nom []string `protobuf:"bytes,3,rep,name=nom,proto3" json:"nom,omitempty"` + Noms []string `protobuf:"bytes,3,rep,name=noms,proto3" json:"noms,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -79,9 +79,9 @@ func (m *GenesisState) GetStablecoins() []Stablecoin { return nil } -func (m *GenesisState) GetNom() []string { +func (m *GenesisState) GetNoms() []string { if m != nil { - return m.Nom + return m.Noms } return nil } @@ -93,25 +93,25 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/genesis.proto", fileDescriptor_fbe4ca1f3927cde8) } var fileDescriptor_fbe4ca1f3927cde8 = []byte{ - // 275 bytes of a gzipped FileDescriptorProto + // 276 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x4a, 0x2d, 0x4e, 0x2d, 0x2a, 0x4b, 0xd5, 0x2f, 0x28, 0xce, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xca, 0xea, 0x15, 0x14, 0xe7, 0xea, 0x95, 0x19, 0x4a, 0x09, 0x26, 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x12, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, 0x53, 0x1f, 0xc4, 0x82, 0x8a, 0x4a, 0xa3, 0x19, 0x5b, 0x90, - 0x58, 0x94, 0x98, 0x0b, 0x35, 0x55, 0x4a, 0x02, 0x5d, 0xb2, 0x38, 0x17, 0x22, 0xa3, 0xb4, 0x9a, + 0x58, 0x94, 0x98, 0x0b, 0x35, 0x55, 0x4a, 0x02, 0x5d, 0xb2, 0x38, 0x17, 0x22, 0xa3, 0xb4, 0x96, 0x91, 0x8b, 0xc7, 0x1d, 0xe2, 0x82, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x4b, 0x2e, 0x36, 0x88, 0x56, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x31, 0x3d, 0x54, 0x17, 0xe9, 0x05, 0x80, 0x65, 0x9d, 0x38, 0x4f, 0xdc, 0x93, 0x67, 0x58, 0xf1, 0x7c, 0x83, 0x16, 0x63, 0x10, 0x54, 0x83, 0x90, 0x3b, 0x17, 0x77, 0x71, 0x49, 0x62, 0x52, 0x4e, 0x6a, 0x72, 0x7e, 0x66, 0x5e, 0xb1, 0x04, 0x93, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x14, 0xba, 0xfe, 0x60, 0xb8, 0x12, 0x64, 0x33, 0x90, 0x75, 0x0a, - 0x89, 0x73, 0x31, 0xe7, 0xe5, 0xe7, 0x4a, 0x30, 0x2b, 0x30, 0x6b, 0x70, 0x3a, 0xb1, 0x42, 0x14, - 0x80, 0x44, 0x9c, 0xdc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, - 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x27, - 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x3f, 0x2f, 0x3f, 0xb7, 0x12, - 0xec, 0xbd, 0xe4, 0xfc, 0x1c, 0x7d, 0x98, 0xd7, 0x2b, 0xc0, 0x9e, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, - 0x4e, 0x62, 0x03, 0xcb, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xb1, 0xea, 0xbb, 0x8c, - 0x01, 0x00, 0x00, + 0x49, 0x72, 0xb1, 0xe4, 0xe5, 0xe7, 0x16, 0x4b, 0x30, 0x2b, 0x30, 0x6b, 0x70, 0x3a, 0xb1, 0x42, + 0x54, 0x80, 0x85, 0x9c, 0xdc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, + 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, + 0x27, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x3f, 0x2f, 0x3f, 0xb7, + 0x12, 0xec, 0xc1, 0xe4, 0xfc, 0x1c, 0x7d, 0x98, 0xe7, 0x2b, 0xc0, 0xde, 0x2f, 0xa9, 0x2c, 0x48, + 0x2d, 0x4e, 0x62, 0x03, 0xcb, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc9, 0xef, 0x95, 0x72, + 0x8e, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -134,11 +134,11 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Nom) > 0 { - for iNdEx := len(m.Nom) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Nom[iNdEx]) - copy(dAtA[i:], m.Nom[iNdEx]) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Nom[iNdEx]))) + if len(m.Noms) > 0 { + for iNdEx := len(m.Noms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Noms[iNdEx]) + copy(dAtA[i:], m.Noms[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Noms[iNdEx]))) i-- dAtA[i] = 0x1a } @@ -195,8 +195,8 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.Nom) > 0 { - for _, s := range m.Nom { + if len(m.Noms) > 0 { + for _, s := range m.Noms { l = len(s) n += 1 + l + sovGenesis(uint64(l)) } @@ -308,7 +308,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Nom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Noms", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -336,7 +336,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Nom = append(m.Nom, string(dAtA[iNdEx:postIndex])) + m.Noms = append(m.Noms, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/psm/types/keys.go b/x/psm/types/keys.go index 4d124461..4a6bc331 100644 --- a/x/psm/types/keys.go +++ b/x/psm/types/keys.go @@ -24,12 +24,5 @@ var ( ParamsKey = []byte{0x4} KeyTotalStablecoinLock = []byte{0x5} KeyFeeMax = []byte{0x6} + KeyNoms = []byte{0x01} ) - -func GetKeyStableCoin(denom string) []byte { - return append(KeyStableCoin, []byte(denom)...) -} - -func GetKeyLockCoin(denom string) []byte { - return append(KeyLockStableCoin, []byte(denom)...) -} From b8a84b489a9310338100a9854a6c32530c61ffb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 15:06:51 +0700 Subject: [PATCH 15/42] add Nom types for msg gov --- proto/reserve/psm/v1/tx.proto | 2 + x/psm/types/psm.go | 2 + x/psm/types/tx.pb.go | 200 ++++++++++++++++++++++++++-------- 3 files changed, 156 insertions(+), 48 deletions(-) diff --git a/proto/reserve/psm/v1/tx.proto b/proto/reserve/psm/v1/tx.proto index 0582677c..61b673e2 100644 --- a/proto/reserve/psm/v1/tx.proto +++ b/proto/reserve/psm/v1/tx.proto @@ -92,6 +92,7 @@ message MsgAddStableCoin { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; + string nom_type = 6; } message MsgAddStableCoinResponse {} @@ -121,6 +122,7 @@ message MsgUpdatesStableCoin { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; + string nom_type = 6; } message MsgUpdatesStableCoinResponse {} \ No newline at end of file diff --git a/x/psm/types/psm.go b/x/psm/types/psm.go index 20179c0e..21d1b2c7 100644 --- a/x/psm/types/psm.go +++ b/x/psm/types/psm.go @@ -12,6 +12,7 @@ func GetMsgStablecoin(msg getStablecoinFromMsg) Stablecoin { FeeOut: msg.GetFeeOut(), TotalStablecoinLock: math.ZeroInt(), FeeMaxStablecoin: msg.GetFeeIn().Add(msg.GetFeeOut()), + NomType: msg.GetNomType(), } } @@ -21,4 +22,5 @@ type getStablecoinFromMsg interface { // GetPrice() math.LegacyDec GetFeeIn() math.LegacyDec GetFeeOut() math.LegacyDec + GetNomType() string } diff --git a/x/psm/types/tx.pb.go b/x/psm/types/tx.pb.go index 20e0eb1c..23c607c9 100644 --- a/x/psm/types/tx.pb.go +++ b/x/psm/types/tx.pb.go @@ -311,6 +311,7 @@ type MsgAddStableCoin struct { LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` FeeOut cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=fee_out,json=feeOut,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_out"` + NomType string `protobuf:"bytes,6,opt,name=nom_type,json=nomType,proto3" json:"nom_type,omitempty"` } func (m *MsgAddStableCoin) Reset() { *m = MsgAddStableCoin{} } @@ -360,6 +361,13 @@ func (m *MsgAddStableCoin) GetDenom() string { return "" } +func (m *MsgAddStableCoin) GetNomType() string { + if m != nil { + return m.NomType + } + return "" +} + type MsgAddStableCoinResponse struct { } @@ -402,6 +410,7 @@ type MsgUpdatesStableCoin struct { LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` FeeOut cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=fee_out,json=feeOut,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_out"` + NomType string `protobuf:"bytes,6,opt,name=nom_type,json=nomType,proto3" json:"nom_type,omitempty"` } func (m *MsgUpdatesStableCoin) Reset() { *m = MsgUpdatesStableCoin{} } @@ -451,6 +460,13 @@ func (m *MsgUpdatesStableCoin) GetDenom() string { return "" } +func (m *MsgUpdatesStableCoin) GetNomType() string { + if m != nil { + return m.NomType + } + return "" +} + type MsgUpdatesStableCoinResponse struct { } @@ -503,54 +519,56 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/tx.proto", fileDescriptor_d0ff2d5421e71e2a) } var fileDescriptor_d0ff2d5421e71e2a = []byte{ - // 751 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xc1, 0x4f, 0x13, 0x4f, - 0x14, 0xee, 0x52, 0x0a, 0xbf, 0x0e, 0xcd, 0x4f, 0x5c, 0x8b, 0x6c, 0x17, 0x59, 0x9a, 0x6a, 0x62, - 0x83, 0xb0, 0x4b, 0x31, 0x1a, 0xe5, 0x46, 0x6d, 0x8c, 0x18, 0x89, 0xd8, 0x42, 0x42, 0xbc, 0x34, - 0xd3, 0xdd, 0x61, 0xd9, 0xd8, 0xdd, 0xd9, 0xec, 0x4c, 0x2b, 0xbd, 0x19, 0xe3, 0xc9, 0x93, 0x7f, - 0x83, 0x27, 0x8f, 0x1c, 0x88, 0x7f, 0x03, 0x47, 0xc2, 0xc9, 0x78, 0x20, 0x06, 0x0e, 0xfc, 0x13, - 0x1c, 0xcc, 0xec, 0x4e, 0x97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0x74, 0xef, 0x42, 0xaa, 0x3d, - 0xd9, 0xf2, 0xdc, 0x55, 0xb2, 0xc2, 0x86, 0x9b, 0x20, 0x13, 0x59, 0xe5, 0x83, 0xfc, 0xea, 0x4d, - 0x18, 0xe8, 0xd7, 0xa0, 0xbd, 0x2c, 0x1a, 0x60, 0xbc, 0x6f, 0x27, 0xdf, 0xbd, 0xb0, 0xf8, 0x3c, - 0x49, 0x7e, 0x70, 0x85, 0xa4, 0x6e, 0x17, 0x39, 0xf5, 0x81, 0xcd, 0x7d, 0xf9, 0xf9, 0xfe, 0xb1, - 0x22, 0x1c, 0x1c, 0x2b, 0xc2, 0xaf, 0x63, 0x45, 0xf8, 0x72, 0xa2, 0x24, 0x0e, 0x4e, 0x94, 0xc4, - 0x8f, 0x13, 0x25, 0xf1, 0x76, 0xce, 0xb4, 0xe8, 0x76, 0xab, 0xa1, 0xea, 0xd8, 0xd6, 0x18, 0xc5, - 0x8e, 0xff, 0xcf, 0xac, 0xe3, 0xa6, 0x16, 0x9d, 0x3a, 0xda, 0x71, 0x11, 0x69, 0x8c, 0xf8, 0xd1, - 0x87, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x87, 0x77, 0x02, 0xba, 0x7c, 0x08, 0x00, 0x00, + // 770 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcf, 0x4f, 0x13, 0x4d, + 0x18, 0xee, 0x7e, 0xa5, 0xe5, 0xeb, 0xd0, 0x7c, 0x1f, 0xae, 0x45, 0xb6, 0x8b, 0x2c, 0x4d, 0x35, + 0xb1, 0x41, 0xd8, 0xa5, 0x18, 0x8d, 0x72, 0xa3, 0x36, 0x46, 0x8c, 0x44, 0x6c, 0x21, 0x21, 0x5e, + 0x9a, 0xe9, 0xee, 0xb0, 0x6c, 0xec, 0xec, 0x6c, 0x76, 0xa6, 0x95, 0xde, 0x8c, 0x47, 0x4f, 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 0xf7, 0xec, 0xe8, 0x99, 0xfe, 0xdd, 0xda, 0xb7, 0x0c, 0xd5, 0x3b, 0x17, 0x04, 0x74, + 0x2a, 0xc8, 0x26, 0x98, 0xe8, 0xb9, 0x3c, 0x6b, 0x3e, 0xf1, 0x08, 0x85, 0x0d, 0x39, 0x37, 0x04, + 0xa1, 0x27, 0x52, 0x2d, 0x5c, 0x14, 0x11, 0x15, 0x21, 0x20, 0x3b, 0xa0, 0x31, 0x2a, 0x74, 0xfb, + 0x5c, 0xaa, 0x5d, 0xd1, 0xea, 0xdc, 0x65, 0xa2, 0xa2, 0x82, 0x9b, 0x20, 0xdd, 0xf3, 0x01, 0x18, + 0xd6, 0xaf, 0xee, 0x80, 0xa1, 0xfd, 0x1a, 0xb6, 0xcd, 0x65, 0x0b, 0x8c, 0x0f, 0x6c, 0xf2, 0x5b, + 0xe7, 0x26, 0x9f, 0x05, 0xa9, 0x77, 0x2f, 0x11, 0xd4, 0xa9, 0xa2, 0x26, 0xde, 0xf2, 0x27, 0x51, + 0x7a, 0xb2, 0x7f, 0xac, 0x49, 0x07, 0xc7, 0x9a, 0xf4, 0xe3, 0x58, 0x93, 0x3e, 0x9c, 0x68, 0xb1, + 0x83, 0x13, 0x2d, 0xf6, 0xed, 0x44, 0x8b, 0xbd, 0x9a, 0xb3, 0x1d, 0xb6, 0xdd, 0xac, 0xeb, 0x26, + 0xc1, 0x06, 0xa7, 0xd8, 0x0e, 0xbe, 0xe7, 0x26, 0x69, 0x18, 0xbd, 0xb7, 0x8e, 0xdf, 0x55, 0x5a, + 0x4f, 0x06, 0xde, 0x7b, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa4, 0x8f, 0x67, 0xd8, 0xb2, 0x08, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -997,6 +1015,13 @@ func (m *MsgAddStableCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.NomType) > 0 { + i -= len(m.NomType) + copy(dAtA[i:], m.NomType) + i = encodeVarintTx(dAtA, i, uint64(len(m.NomType))) + i-- + dAtA[i] = 0x32 + } { size := m.FeeOut.Size() i -= size @@ -1087,6 +1112,13 @@ func (m *MsgUpdatesStableCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.NomType) > 0 { + i -= len(m.NomType) + copy(dAtA[i:], m.NomType) + i = encodeVarintTx(dAtA, i, uint64(len(m.NomType))) + i-- + dAtA[i] = 0x32 + } { size := m.FeeOut.Size() i -= size @@ -1264,6 +1296,10 @@ func (m *MsgAddStableCoin) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.FeeOut.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.NomType) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -1296,6 +1332,10 @@ func (m *MsgUpdatesStableCoin) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.FeeOut.Size() n += 1 + l + sovTx(uint64(l)) + l = len(m.NomType) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -2033,6 +2073,38 @@ func (m *MsgAddStableCoin) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NomType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NomType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2296,6 +2368,38 @@ func (m *MsgUpdatesStableCoin) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NomType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NomType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 32d9fdb360dfcd38be83f69aea93d1c7f1ea806f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 16:02:28 +0700 Subject: [PATCH 16/42] updates msg server and test full script --- proto/reserve/psm/v1/tx.proto | 8 +- script/proposal-2.json | 4 +- x/oracle/keeper/band_oracle.go | 116 ++++++++++++++++++++++++++++ x/oracle/module/genesis.go | 1 + x/psm/client/cli/tx.go | 2 +- x/psm/keeper/abci.go | 2 +- x/psm/keeper/keeper.go | 2 +- x/psm/keeper/keeper_test.go | 2 +- x/psm/keeper/msg_server.go | 20 +++-- x/psm/keeper/msg_server_test.go | 9 ++- x/psm/keeper/stablecoin.go | 14 ++-- x/psm/keeper/swap.go | 12 ++- x/psm/keeper/swap_test.go | 2 +- x/psm/types/genesis.go | 6 +- x/psm/types/keys.go | 2 +- x/psm/types/msgs.go | 22 +++--- x/psm/types/tx.pb.go | 132 +++++++++++++++++--------------- 17 files changed, 244 insertions(+), 112 deletions(-) diff --git a/proto/reserve/psm/v1/tx.proto b/proto/reserve/psm/v1/tx.proto index 61b673e2..983ba54d 100644 --- a/proto/reserve/psm/v1/tx.proto +++ b/proto/reserve/psm/v1/tx.proto @@ -58,12 +58,8 @@ message MsgSwapToStablecoin { string address = 1; string to_denom = 2; - bytes amount = 3 [ - (cosmos_proto.scalar) = "cosmos.Int", - (gogoproto.customtype) = "cosmossdk.io/math.Int", - (gogoproto.nullable) = false, - (amino.dont_omitempty) = true - ]; + cosmos.base.v1beta1.Coin coin = 3 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } message MsgSwapToStablecoinResponse {} diff --git a/script/proposal-2.json b/script/proposal-2.json index 27fbb9ec..84501f75 100644 --- a/script/proposal-2.json +++ b/script/proposal-2.json @@ -5,8 +5,8 @@ "denom": "usdt", "limit_total": "100000000000000000000000000000", "fee_in": "0.001000000000000000", - "fee_out": "0.001000000000000000" - + "fee_out": "0.001000000000000000", + "nom_type":"nomUSD" }], "deposit": "100000000stake", "title": "My proposal", diff --git a/x/oracle/keeper/band_oracle.go b/x/oracle/keeper/band_oracle.go index a5efc1c4..50409ed5 100644 --- a/x/oracle/keeper/band_oracle.go +++ b/x/oracle/keeper/band_oracle.go @@ -547,3 +547,119 @@ func (k *Keeper) getPreviousRecordIDs(ctx context.Context, clientID uint64) []ui return staleIDs } + +func (k Keeper) SetInitPrice(ctx context.Context) error { + initPrice := []*types.BandPriceState{ + // multiplier = 1000 + { + Symbol: "nomUSD", + Rate: math.NewInt(10000), //1 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), + }, + { + Symbol: "nomEUR", + Rate: math.NewInt(10910), //1.091 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1.091"), time.Now().Unix()), + }, + { + Symbol: "nomJPY", + Rate: math.NewInt(66), //0.0066 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.0066"), time.Now().Unix()), + }, + { + Symbol: "anom", + Rate: math.NewInt(330), //0.03 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.03"), time.Now().Unix()), + }, + { + Symbol: "usdt", + Rate: math.NewInt(10000), //1 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), + }, + { + Symbol: "usdc", + Rate: math.NewInt(10000), //1 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), + }, + { + Symbol: "eurt", + Rate: math.NewInt(10910), //1.091 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1.091"), time.Now().Unix()), + }, + { + Symbol: "jpyt", + Rate: math.NewInt(66), //0.0066 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.0066"), time.Now().Unix()), + }, + { + Symbol: "uatom", + Rate: math.NewInt(80000), //8 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("8"), time.Now().Unix()), + }, + { + Symbol: "uosmo", + Rate: math.NewInt(4500), //0.45 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.45"), time.Now().Unix()), + }, + { + Symbol: "uusdt", + Rate: math.NewInt(10000), //0.45 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), + }, + { + Symbol: "atom", + Rate: math.NewInt(80000), //0.45 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("8"), time.Now().Unix()), + }, + { + Symbol: "ibc/E50A183716AB596378047D9688FE648CD3470C4D196FB4C2C8E61989DB48562E", //transfer/channel-10/transfer/channel-7/transfer/channel-143/erc20/tether/usdt + Rate: math.NewInt(10000), + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), + }, + { + Symbol: "ibc/BE4C72028781730B9DF0542466EB26DEA6DDD42C32316D774F943151F6010320", // transfer/channel-5/usdt + Rate: math.NewInt(10000), + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), + }, + { + Symbol: "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518", //transfer/channel-0/uosmo + Rate: math.NewInt(4500), //0.45 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.45"), time.Now().Unix()), + }, + { + Symbol: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", //ibc-atom + Rate: math.NewInt(80000), //0.45 + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("8"), time.Now().Unix()), + }, + { + Symbol: "ibc/BC599B88586F8C22E408569D7F6FAD40AEBF808A67D2051B86958CBB5F0A16B0", //usdt + Rate: math.NewInt(10000), + ResolveTime: uint64(time.Now().Unix()), + PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), + }, + } + + for _, i := range initPrice { + err := k.SetBandPriceState(ctx, i.Symbol, i) + if err != nil { + return err + } + } + return nil +} diff --git a/x/oracle/module/genesis.go b/x/oracle/module/genesis.go index 5148f5fc..2720ffbb 100644 --- a/x/oracle/module/genesis.go +++ b/x/oracle/module/genesis.go @@ -21,6 +21,7 @@ func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisSta sdkCtx.Logger().Info("can not set band price state for symbol %s", bandPriceState.Symbol) } } + // k.SetInitPrice(ctx) for _, bandOracleRequest := range genState.BandOracleRequests { err := k.SetBandOracleRequest(ctx, *bandOracleRequest) diff --git a/x/psm/client/cli/tx.go b/x/psm/client/cli/tx.go index 5b321668..63b46d77 100644 --- a/x/psm/client/cli/tx.go +++ b/x/psm/client/cli/tx.go @@ -82,7 +82,7 @@ func NewSwapToStablecoinCmd() *cobra.Command { } addr := clientCtx.GetFromAddress() - msg := types.NewMsgSwapToStablecoin(addr.String(), args[0], nomUSDcoin.Amount) + msg := types.NewMsgSwapToStablecoin(addr.String(), args[0], nomUSDcoin) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, diff --git a/x/psm/keeper/abci.go b/x/psm/keeper/abci.go index 40002e42..d7f248de 100644 --- a/x/psm/keeper/abci.go +++ b/x/psm/keeper/abci.go @@ -13,7 +13,7 @@ func (k Keeper) BeginBlocker(ctx context.Context) error { func (k Keeper) UpdatesStablecoinEpoch(ctx context.Context) error { updatePrice := func(red types.Stablecoin) bool { - price := k.OracleKeeper.GetPrice(ctx, red.Denom, types.DefaultMintDenom) + price := k.OracleKeeper.GetPrice(ctx, red.Denom, red.NomType) if price == nil || price.IsNil() { return false } diff --git a/x/psm/keeper/keeper.go b/x/psm/keeper/keeper.go index 6d6ee508..4a5944e6 100644 --- a/x/psm/keeper/keeper.go +++ b/x/psm/keeper/keeper.go @@ -70,7 +70,7 @@ func NewKeeper( OracleKeeper: oracleKeeper, Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), Stablecoins: collections.NewMap(sb, types.KeyStableCoin, "stablecoins", collections.StringKey, codec.CollValue[types.Stablecoin](cdc)), - Noms: collections.NewMap(sb, types.KeyNoms, "nom types", collections.StringKey, collections.StringValue), + Noms: collections.NewMap(sb, types.KeyNoms, "nomtypes", collections.StringKey, collections.StringValue), } schema, err := sb.Build() diff --git a/x/psm/keeper/keeper_test.go b/x/psm/keeper/keeper_test.go index bb0178a8..d54cc99f 100644 --- a/x/psm/keeper/keeper_test.go +++ b/x/psm/keeper/keeper_test.go @@ -67,7 +67,7 @@ func (s *KeeperTestSuite) SetupTest() { mockOracleKeeper := MockOracleKeeper{ prices: make(map[string]math.LegacyDec), } - mockOracleKeeper.SetPrice(s.Ctx, types.DefaultMintDenom, math.LegacyMustNewDecFromStr("1")) + mockOracleKeeper.SetPrice(s.Ctx, types.DefaultMintDenoms[0], math.LegacyMustNewDecFromStr("1")) s.App.PSMKeeper.OracleKeeper = mockOracleKeeper s.mockOracleKeeper = &mockOracleKeeper diff --git a/x/psm/keeper/msg_server.go b/x/psm/keeper/msg_server.go index 056cc28b..2109e287 100644 --- a/x/psm/keeper/msg_server.go +++ b/x/psm/keeper/msg_server.go @@ -50,7 +50,7 @@ func (k msgServer) SwapTonomUSD(ctx context.Context, msg *types.MsgSwapTonomUSD) } // check stablecoin is suport - _, err := k.keeper.Stablecoins.Get(ctx, msg.Coin.Denom) + stablecoin, err := k.keeper.Stablecoins.Get(ctx, msg.Coin.Denom) if err != nil { return nil, fmt.Errorf("%s not in list stablecoin supported", msg.Coin.Denom) } @@ -81,7 +81,7 @@ func (k msgServer) SwapTonomUSD(ctx context.Context, msg *types.MsgSwapTonomUSD) } // mint nomUSD - coinsMint := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenom, receiveAmountnomUSD)) + coinsMint := sdk.NewCoins(sdk.NewCoin(stablecoin.NomType, receiveAmountnomUSD)) err = k.keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) if err != nil { return nil, err @@ -112,11 +112,15 @@ func (k msgServer) SwapToStablecoin(ctx context.Context, msg *types.MsgSwapToSta } // check stablecoin is suport - _, err := k.keeper.Stablecoins.Get(ctx, msg.ToDenom) + stablecoin, err := k.keeper.Stablecoins.Get(ctx, msg.ToDenom) if err != nil { return nil, fmt.Errorf("%s not in list stablecoin supported", msg.ToDenom) } + if stablecoin.NomType != msg.Coin.Denom { + return nil, fmt.Errorf("can't exchange %s for %s, not same type", msg.Coin.Denom, msg.ToDenom) + } + // check lock Coin of user totalStablecoinLock, err := k.keeper.TotalStablecoinLock(ctx, msg.ToDenom) if err != nil { @@ -125,7 +129,7 @@ func (k msgServer) SwapToStablecoin(ctx context.Context, msg *types.MsgSwapToSta // check balace and calculate amount of coins received addr := sdk.MustAccAddressFromBech32(msg.Address) - receiveAmountStablecoin, fee_out, err := k.keeper.SwapToStablecoin(ctx, addr, msg.Amount, msg.ToDenom) + receiveAmountStablecoin, fee_out, err := k.keeper.SwapToStablecoin(ctx, addr, msg.Coin.Amount, msg.ToDenom) if err != nil { return nil, err } @@ -136,7 +140,7 @@ func (k msgServer) SwapToStablecoin(ctx context.Context, msg *types.MsgSwapToSta } // burn nomUSD - coinsBurn := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenom, msg.Amount)) + coinsBurn := sdk.NewCoins(msg.Coin) err = k.keeper.BankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, coinsBurn) if err != nil { return nil, err @@ -164,7 +168,7 @@ func (k msgServer) SwapToStablecoin(ctx context.Context, msg *types.MsgSwapToSta sdkCtx.EventManager().EmitEvent( sdk.NewEvent( types.EventSwapToStablecoin, - sdk.NewAttribute(types.AttributeAmount, msg.Amount.String()+types.DefaultMintDenom), + sdk.NewAttribute(types.AttributeAmount, msg.Coin.String()), sdk.NewAttribute(types.AttributeReceive, stablecoinReceive.String()), sdk.NewAttribute(types.AttributeFeeOut, fee_out.String()), ), @@ -182,6 +186,10 @@ func (k msgServer) AddStableCoinProposal(ctx context.Context, msg *types.MsgAddS return &types.MsgAddStableCoinResponse{}, err } + // if msg. { + + // } + _, err := k.keeper.Stablecoins.Get(ctx, msg.Denom) if err == nil { return &types.MsgAddStableCoinResponse{}, fmt.Errorf("%s has existed", msg.Denom) diff --git a/x/psm/keeper/msg_server_test.go b/x/psm/keeper/msg_server_test.go index 470dee20..afd86182 100644 --- a/x/psm/keeper/msg_server_test.go +++ b/x/psm/keeper/msg_server_test.go @@ -40,6 +40,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { LimitTotal: limitUSDT, FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", }) s.Require().NoError(err) @@ -63,6 +64,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { LimitTotal: limitUSDC, FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", }) s.Require().NoError(err) @@ -85,7 +87,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { _, err := s.msgServer.SwapTonomUSD(s.Ctx, msg) if t.expectPass { s.Require().NoError(err) - balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenom) + balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenoms[0]) s.Require().Equal(t.expectedReceive, balance.Amount) } else { @@ -124,6 +126,7 @@ func (s *KeeperTestSuite) TestMsgSwapToStablecoin() { LimitTotal: limitUSDT, FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", }) s.Require().NoError(err) @@ -138,7 +141,7 @@ func (s *KeeperTestSuite) TestMsgSwapToStablecoin() { return &types.MsgSwapToStablecoin{ Address: s.TestAccs[0].String(), ToDenom: usdt, - Amount: math.NewInt(1000), + Coin: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000)), } }, @@ -154,7 +157,7 @@ func (s *KeeperTestSuite) TestMsgSwapToStablecoin() { _, err := s.msgServer.SwapToStablecoin(s.Ctx, msg) if t.expectPass { s.Require().NoError(err) - balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenom) + balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenoms[0]) s.Require().Equal(t.expectedBalancenomUSD.String(), balance.Amount.String()) } else { diff --git a/x/psm/keeper/stablecoin.go b/x/psm/keeper/stablecoin.go index eb48962e..b56d25d0 100644 --- a/x/psm/keeper/stablecoin.go +++ b/x/psm/keeper/stablecoin.go @@ -15,13 +15,13 @@ func (k Keeper) GetTotalLimitWithDenomStablecoin(ctx context.Context, denom stri return s.LimitTotal, nil } -// func (k Keeper) GetPrice(ctx context.Context, denom string) (math.LegacyDec, error) { -// s, found := k.GetStablecoin(ctx, denom) -// if !found { -// return math.LegacyDec{}, fmt.Errorf("not found Stable coin %s", denom) -// } -// return s.Price, nil -// } +func (k Keeper) GetNomType(ctx context.Context, denom string) (string, error) { + s, err := k.Stablecoins.Get(ctx, denom) + if err != nil { + return "", fmt.Errorf("not found Stable coin %s", denom) + } + return s.NomType, nil +} func (k Keeper) GetFeeIn(ctx context.Context, denom string) (math.LegacyDec, error) { s, err := k.Stablecoins.Get(ctx, denom) diff --git a/x/psm/keeper/swap.go b/x/psm/keeper/swap.go index c6bd88df..ae4a8432 100644 --- a/x/psm/keeper/swap.go +++ b/x/psm/keeper/swap.go @@ -9,12 +9,15 @@ import ( errors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" oracletypes "github.com/onomyprotocol/reserve/x/oracle/types" - "github.com/onomyprotocol/reserve/x/psm/types" ) // SwapToStablecoin return receiveAmount, fee, error func (k Keeper) SwapToStablecoin(ctx context.Context, addr sdk.AccAddress, amount math.Int, toDenom string) (math.Int, sdk.DecCoin, error) { - denomMint := types.DefaultMintDenom + denomMint, err := k.GetNomType(ctx, toDenom) + if err != nil { + return math.ZeroInt(), sdk.DecCoin{}, err + } + asset := k.BankKeeper.GetBalance(ctx, addr, denomMint) if asset.Amount.LT(amount) { @@ -37,7 +40,10 @@ func (k Keeper) SwapToStablecoin(ctx context.Context, addr sdk.AccAddress, amoun } func (k Keeper) SwapTonomUSD(ctx context.Context, addr sdk.AccAddress, stablecoin sdk.Coin) (math.Int, sdk.DecCoin, error) { - denomMint := types.DefaultMintDenom + denomMint, err := k.GetNomType(ctx, stablecoin.Denom) + if err != nil { + return math.ZeroInt(), sdk.DecCoin{}, err + } asset := k.BankKeeper.GetBalance(ctx, addr, stablecoin.Denom) if asset.Amount.LT(stablecoin.Amount) { diff --git a/x/psm/keeper/swap_test.go b/x/psm/keeper/swap_test.go index c4283857..fcb3798a 100644 --- a/x/psm/keeper/swap_test.go +++ b/x/psm/keeper/swap_test.go @@ -103,7 +103,7 @@ func (s *KeeperTestSuite) TestSwapToStablecoin() { { name: "success", setup: func(ctx context.Context, keeper keeper.Keeper) { - coinsMint := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenom, math.NewInt(1000000))) + coinsMint := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000000))) err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) s.Require().NoError(err) err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) diff --git a/x/psm/types/genesis.go b/x/psm/types/genesis.go index 8f57c092..1ef13978 100644 --- a/x/psm/types/genesis.go +++ b/x/psm/types/genesis.go @@ -1,8 +1,6 @@ package types -// DefaultIndex is the default global index -const DefaultIndex uint64 = 1 -const DefaultMintDenom = "nomUSD" +var DefaultMintDenoms = []string{"nomUSD", "nomJPY", "nomEUR"} // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { @@ -10,7 +8,7 @@ func DefaultGenesis() *GenesisState { // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), Stablecoins: []Stablecoin{}, - Noms: []string{DefaultMintDenom}, + Noms: DefaultMintDenoms, } } diff --git a/x/psm/types/keys.go b/x/psm/types/keys.go index 4a6bc331..a7c90d50 100644 --- a/x/psm/types/keys.go +++ b/x/psm/types/keys.go @@ -24,5 +24,5 @@ var ( ParamsKey = []byte{0x4} KeyTotalStablecoinLock = []byte{0x5} KeyFeeMax = []byte{0x6} - KeyNoms = []byte{0x01} + KeyNoms = []byte{0x07} ) diff --git a/x/psm/types/msgs.go b/x/psm/types/msgs.go index e7dd1137..be359bba 100644 --- a/x/psm/types/msgs.go +++ b/x/psm/types/msgs.go @@ -58,11 +58,11 @@ func (msg MsgSwapTonomUSD) GetSigners() []sdk.AccAddress { func (msg MsgSwapTonomUSD) Route() string { return RouterKey } // /////////// -func NewMsgSwapToStablecoin(addr, toDenom string, amount math.Int) *MsgSwapToStablecoin { +func NewMsgSwapToStablecoin(addr, toDenom string, amount sdk.Coin) *MsgSwapToStablecoin { return &MsgSwapToStablecoin{ Address: addr, ToDenom: toDenom, - Amount: amount, + Coin: amount, } } @@ -73,10 +73,8 @@ func (msg MsgSwapToStablecoin) ValidateBasic() error { if msg.ToDenom == "" { return fmt.Errorf("empty denom") } - if msg.Amount.LT(math.ZeroInt()) { - return fmt.Errorf("total limit less than zero") - } - return nil + + return msg.Coin.Validate() } func (msg MsgSwapToStablecoin) GetSigners() []sdk.AccAddress { @@ -128,9 +126,9 @@ func (msg MsgAddStableCoin) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "limittotal less than zero") } - // if msg.Price.LT(math.LegacyZeroDec()) { - // return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "price less than zero") - // } + if msg.NomType == "" { + return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty nom type") + } if msg.FeeIn.LT(math.LegacyZeroDec()) { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "feein less than zero") @@ -167,9 +165,9 @@ func (msg MsgUpdatesStableCoin) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "limittotal less than zero") } - // if msg.Price.LT(math.LegacyZeroDec()) { - // return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "price less than zero") - // } + if msg.NomType == "" { + return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty nom type") + } if msg.FeeIn.LT(math.LegacyZeroDec()) { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "feein less than zero") diff --git a/x/psm/types/tx.pb.go b/x/psm/types/tx.pb.go index 23c607c9..43cbbf3b 100644 --- a/x/psm/types/tx.pb.go +++ b/x/psm/types/tx.pb.go @@ -217,9 +217,9 @@ func (m *MsgSwapTonomUSDResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSwapTonomUSDResponse proto.InternalMessageInfo type MsgSwapToStablecoin struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - ToDenom string `protobuf:"bytes,2,opt,name=to_denom,json=toDenom,proto3" json:"to_denom,omitempty"` - Amount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + ToDenom string `protobuf:"bytes,2,opt,name=to_denom,json=toDenom,proto3" json:"to_denom,omitempty"` + Coin types.Coin `protobuf:"bytes,3,opt,name=coin,proto3" json:"coin"` } func (m *MsgSwapToStablecoin) Reset() { *m = MsgSwapToStablecoin{} } @@ -269,6 +269,13 @@ func (m *MsgSwapToStablecoin) GetToDenom() string { return "" } +func (m *MsgSwapToStablecoin) GetCoin() types.Coin { + if m != nil { + return m.Coin + } + return types.Coin{} +} + type MsgSwapToStablecoinResponse struct { } @@ -519,56 +526,55 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/tx.proto", fileDescriptor_d0ff2d5421e71e2a) } var fileDescriptor_d0ff2d5421e71e2a = []byte{ - // 770 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcf, 0x4f, 0x13, 0x4d, - 0x18, 0xee, 0x7e, 0xa5, 0xe5, 0xeb, 0xd0, 0x7c, 0x1f, 0xae, 0x45, 0xb6, 0x8b, 0x2c, 0x4d, 0x35, - 0xb1, 0x41, 0xd8, 0xa5, 0x18, 0x8d, 0x72, 0xa3, 0x36, 0x46, 0x8c, 0x44, 0x6c, 0x21, 0x21, 0x5e, - 0x9a, 0xe9, 0xee, 0xb0, 0x6c, 0xec, 0xec, 0x6c, 0x76, 0xa6, 0x95, 0xde, 0x8c, 0x47, 0x4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x48, 0xf7, 0xec, 0xe8, 0x99, 0xfe, 0xdd, 0xda, 0xb7, 0x0c, 0xd5, 0x3b, 0x17, 0x04, 0x74, - 0x2a, 0xc8, 0x26, 0x98, 0xe8, 0xb9, 0x3c, 0x6b, 0x3e, 0xf1, 0x08, 0x85, 0x0d, 0x39, 0x37, 0x04, - 0xa1, 0x27, 0x52, 0x2d, 0x5c, 0x14, 0x11, 0x15, 0x21, 0x20, 0x3b, 0xa0, 0x31, 0x2a, 0x74, 0xfb, - 0x5c, 0xaa, 0x5d, 0xd1, 0xea, 0xdc, 0x65, 0xa2, 0xa2, 0x82, 0x9b, 0x20, 0xdd, 0xf3, 0x01, 0x18, - 0xd6, 0xaf, 0xee, 0x80, 0xa1, 0xfd, 0x1a, 0xb6, 0xcd, 0x65, 0x0b, 0x8c, 0x0f, 0x6c, 0xf2, 0x5b, - 0xe7, 0x26, 0x9f, 0x05, 0xa9, 0x77, 0x2f, 0x11, 0xd4, 0xa9, 0xa2, 0x26, 0xde, 0xf2, 0x27, 0x51, - 0x7a, 0xb2, 0x7f, 0xac, 0x49, 0x07, 0xc7, 0x9a, 0xf4, 0xe3, 0x58, 0x93, 0x3e, 0x9c, 0x68, 0xb1, - 0x83, 0x13, 0x2d, 0xf6, 0xed, 0x44, 0x8b, 0xbd, 0x9a, 0xb3, 0x1d, 0xb6, 0xdd, 0xac, 0xeb, 0x26, - 0xc1, 0x06, 0xa7, 0xd8, 0x0e, 0xbe, 0xe7, 0x26, 0x69, 0x18, 0xbd, 0xb7, 0x8e, 0xdf, 0x55, 0x5a, - 0x4f, 0x06, 0xde, 0x7b, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa4, 0x8f, 0x67, 0xd8, 0xb2, 0x08, - 0x00, 0x00, + // 760 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcf, 0x4f, 0x13, 0x5b, + 0x14, 0x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0x00, 0x00, 0xff, 0xff, + 0xaa, 0x41, 0xe4, 0x79, 0xa2, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -946,11 +952,11 @@ func (m *MsgSwapToStablecoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { + size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } + i -= size i = encodeVarintTx(dAtA, i, uint64(size)) } i-- @@ -1262,7 +1268,7 @@ func (m *MsgSwapToStablecoin) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.Amount.Size() + l = m.Coin.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1779,9 +1785,9 @@ func (m *MsgSwapToStablecoin) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1791,22 +1797,22 @@ func (m *MsgSwapToStablecoin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From eba4c8f73a18c80af9edc12ac864bfdbce531b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 16:16:06 +0700 Subject: [PATCH 17/42] updates script and fix test pass ci --- script/proposal-2.json | 14 ------------- script/proposal-psm.json | 41 +++++++++++++++++++++++++++++++++++++++ script/psm-test.sh | 30 +++++++++++++++++----------- x/psm/keeper/abci_test.go | 1 + 4 files changed, 61 insertions(+), 25 deletions(-) delete mode 100644 script/proposal-2.json create mode 100644 script/proposal-psm.json diff --git a/script/proposal-2.json b/script/proposal-2.json deleted file mode 100644 index 84501f75..00000000 --- a/script/proposal-2.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "messages": [{ - "@type": "/reserve.psm.v1.MsgAddStableCoin", - "authority":"onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k", - "denom": "usdt", - "limit_total": "100000000000000000000000000000", - "fee_in": "0.001000000000000000", - "fee_out": "0.001000000000000000", - "nom_type":"nomUSD" - }], - "deposit": "100000000stake", - "title": "My proposal", - "summary": "A short summary of my proposal" - } \ No newline at end of file diff --git a/script/proposal-psm.json b/script/proposal-psm.json new file mode 100644 index 00000000..046b0140 --- /dev/null +++ b/script/proposal-psm.json @@ -0,0 +1,41 @@ +{ + "messages": [{ + "@type": "/reserve.psm.v1.MsgAddStableCoin", + "authority":"onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k", + "denom": "usdt", + "limit_total": "100000000000000000000000000000", + "fee_in": "0.001000000000000000", + "fee_out": "0.001000000000000000", + "nom_type":"nomUSD" + }, + { + "@type": "/reserve.psm.v1.MsgAddStableCoin", + "authority":"onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k", + "denom": "usdc", + "limit_total": "100000000000000000000000000000", + "fee_in": "0.001000000000000000", + "fee_out": "0.001000000000000000", + "nom_type":"nomUSD" + }, + { + "@type": "/reserve.psm.v1.MsgAddStableCoin", + "authority":"onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k", + "denom": "jpyt", + "limit_total": "100000000000000000000000000000", + "fee_in": "0.001000000000000000", + "fee_out": "0.001000000000000000", + "nom_type":"nomJPY" + }, + { + "@type": "/reserve.psm.v1.MsgAddStableCoin", + "authority":"onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k", + "denom": "eurt", + "limit_total": "100000000000000000000000000000", + "fee_in": "0.001000000000000000", + "fee_out": "0.001000000000000000", + "nom_type":"nomEUR" + }], + "deposit": "100000000stake", + "title": "My proposal", + "summary": "A short summary of my proposal" + } \ No newline at end of file diff --git a/script/psm-test.sh b/script/psm-test.sh index ae9e3b48..1f29af11 100755 --- a/script/psm-test.sh +++ b/script/psm-test.sh @@ -25,15 +25,15 @@ echo $mnemonic2| reserved keys add validator2 --recover --keyring-backend=test - echo $mnemonic3| reserved keys add validator3 --recover --keyring-backend=test --home=$HOME/.reserved/validator3 # create validator node with tokens to transfer to the three other nodes -reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator1 -reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator1 -reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator1 -reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator2 -reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator2 -reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator2 -reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator3 -reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator3 -reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt --home=$HOME/.reserved/validator3 +reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator1 +reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator1 +reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator1 +reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator2 +reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator2 +reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator2 +reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator3 +reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator3 +reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator3 reserved genesis gentx validator1 1000000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator1 --chain-id=testing-1 reserved genesis gentx validator2 1000000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator2 --chain-id=testing-1 reserved genesis gentx validator3 1000000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator3 --chain-id=testing-1 @@ -118,7 +118,7 @@ screen -S onomy3 -t onomy3 -d -m reserved start --home=$HOME/.reserved/validator # submit proposal add usdt sleep 7 -reserved tx gov submit-proposal ./script/proposal-2.json --home=$HOME/.reserved/validator1 --from validator1 --keyring-backend test --fees 20stake --chain-id testing-1 -y +reserved tx gov submit-proposal ./script/proposal-psm.json --home=$HOME/.reserved/validator1 --from validator1 --keyring-backend test --fees 20stake --chain-id testing-1 -y # # # vote sleep 7 @@ -138,10 +138,18 @@ reserved q bank balances $(reserved keys show validator1 -a --keyring-backend te # echo "========swap===========" reserved tx psm swap-to-nomUSD 100000000000000000000000usdt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake +sleep 7 + +reserved tx psm swap-to-nomUSD 100000000000000000000000eurt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake + +sleep 7 + +reserved tx psm swap-to-nomUSD 100000000000000000000000usdc --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake +sleep 7 +reserved tx psm swap-to-nomUSD 100000000000000000000000jpyt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake sleep 7 # # Check account after swap reserved q bank balances $(reserved keys show validator1 -a --keyring-backend test --home /Users/donglieu/.reserved/validator1) - # # tx swap nomUSD to usdt # reserved tx psm swap-to-stablecoin usdt 1000nomUSD --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake diff --git a/x/psm/keeper/abci_test.go b/x/psm/keeper/abci_test.go index b2a67f24..95bb17be 100644 --- a/x/psm/keeper/abci_test.go +++ b/x/psm/keeper/abci_test.go @@ -45,6 +45,7 @@ func (s *KeeperTestSuite) TestUpdatesStablecoinEpoch() { LimitTotal: limitUSDT, FeeIn: t.feeIn, FeeOut: t.feeOut, + NomType: "nomUSD", }) s.mockOracleKeeper.SetPrice(s.Ctx, sc.Denom, t.priceCurrent) err := s.k.Stablecoins.Set(s.Ctx, sc.Denom, sc) From abd2daa4a585592201447bc5a483336c45036393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 16:25:13 +0700 Subject: [PATCH 18/42] updates tests and rename msg --- proto/reserve/psm/v1/params.proto | 2 +- proto/reserve/psm/v1/psm.proto | 4 +- proto/reserve/psm/v1/tx.proto | 6 +- x/psm/client/cli/tx.go | 2 +- x/psm/keeper/msg_server.go | 4 +- x/psm/keeper/msg_server_test.go | 16 +-- x/psm/keeper/proposals_test.go | 1 + x/psm/types/codec.go | 2 +- x/psm/types/msgs.go | 12 +- x/psm/types/params.pb.go | 2 +- x/psm/types/psm.pb.go | 4 +- x/psm/types/tx.pb.go | 218 +++++++++++++++--------------- 12 files changed, 137 insertions(+), 136 deletions(-) diff --git a/proto/reserve/psm/v1/params.proto b/proto/reserve/psm/v1/params.proto index 572c5a6b..f7a5a32e 100644 --- a/proto/reserve/psm/v1/params.proto +++ b/proto/reserve/psm/v1/params.proto @@ -8,7 +8,7 @@ import "cosmos_proto/cosmos.proto"; option go_package = "github.com/onomyprotocol/reserve/x/psm/types"; message Params { - // total $nomUSD can mint + // total $nomX can mint bytes limit_total = 1 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", diff --git a/proto/reserve/psm/v1/psm.proto b/proto/reserve/psm/v1/psm.proto index dba7fd8b..1c14eca2 100644 --- a/proto/reserve/psm/v1/psm.proto +++ b/proto/reserve/psm/v1/psm.proto @@ -18,13 +18,13 @@ message Stablecoin { (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; - // stablecoin to nomUSD exchange fee, fee_in when 1 stablecoin = 1nomUSD + // stablecoin to nom exchange fee, fee_in when 1 stablecoin = 1nomUSD bytes fee_in = 3 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - // nomUSD to stablecoin exchange fee, fee_out when 1 stablecoin = 1nomUSD + // nom to stablecoin exchange fee, fee_out when 1 stablecoin = 1nomUSD bytes fee_out = 4 [ (cosmos_proto.scalar) = "cosmos.Dec", (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", diff --git a/proto/reserve/psm/v1/tx.proto b/proto/reserve/psm/v1/tx.proto index 983ba54d..67535b20 100644 --- a/proto/reserve/psm/v1/tx.proto +++ b/proto/reserve/psm/v1/tx.proto @@ -19,7 +19,7 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); rpc AddStableCoinProposal(MsgAddStableCoin) returns (MsgAddStableCoinResponse); rpc UpdatesStableCoinProposal(MsgUpdatesStableCoin) returns (MsgUpdatesStableCoinResponse); - rpc SwapTonomUSD(MsgSwapTonomUSD) returns (MsgSwapTonomUSDResponse); + rpc SwapToNom(MsgSwapToNom) returns (MsgSwapToNomResponse); rpc SwapToStablecoin(MsgSwapToStablecoin) returns (MsgSwapToStablecoinResponse); } @@ -44,14 +44,14 @@ message MsgUpdateParams { // MsgUpdateParams message. message MsgUpdateParamsResponse {} -message MsgSwapTonomUSD { +message MsgSwapToNom { option (cosmos.msg.v1.signer) = "address"; string address = 1; cosmos.base.v1beta1.Coin coin = 2 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } -message MsgSwapTonomUSDResponse {} +message MsgSwapToNomResponse {} message MsgSwapToStablecoin { option (cosmos.msg.v1.signer) = "address"; diff --git a/x/psm/client/cli/tx.go b/x/psm/client/cli/tx.go index 63b46d77..aeb42f93 100644 --- a/x/psm/client/cli/tx.go +++ b/x/psm/client/cli/tx.go @@ -49,7 +49,7 @@ func NewSwapTonomUSDCmd() *cobra.Command { } addr := clientCtx.GetFromAddress() - msg := types.NewMsgSwapTonomUSD(addr.String(), stablecoin) + msg := types.NewMsgSwapToNom(addr.String(), stablecoin) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, diff --git a/x/psm/keeper/msg_server.go b/x/psm/keeper/msg_server.go index 2109e287..a96bb664 100644 --- a/x/psm/keeper/msg_server.go +++ b/x/psm/keeper/msg_server.go @@ -43,7 +43,7 @@ func (k msgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) return &types.MsgUpdateParamsResponse{}, nil } -func (k msgServer) SwapTonomUSD(ctx context.Context, msg *types.MsgSwapTonomUSD) (*types.MsgSwapTonomUSDResponse, error) { +func (k msgServer) SwapToNom(ctx context.Context, msg *types.MsgSwapToNom) (*types.MsgSwapToNomResponse, error) { // validate msg if err := msg.ValidateBasic(); err != nil { return nil, err @@ -102,7 +102,7 @@ func (k msgServer) SwapTonomUSD(ctx context.Context, msg *types.MsgSwapTonomUSD) sdk.NewAttribute(types.AttributeFeeIn, fee_in.String()), ), ) - return &types.MsgSwapTonomUSDResponse{}, nil + return &types.MsgSwapToNomResponse{}, nil } func (k msgServer) SwapToStablecoin(ctx context.Context, msg *types.MsgSwapToStablecoin) (*types.MsgSwapToStablecoinResponse, error) { diff --git a/x/psm/keeper/msg_server_test.go b/x/psm/keeper/msg_server_test.go index afd86182..f0df048b 100644 --- a/x/psm/keeper/msg_server_test.go +++ b/x/psm/keeper/msg_server_test.go @@ -19,7 +19,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { tests := []struct { name string addr sdk.AccAddress - setup func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapTonomUSD + setup func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom expectPass bool expectedReceive math.Int @@ -27,7 +27,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { { name: "success", addr: s.TestAccs[0], - setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapTonomUSD { + setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom { coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) s.Require().NoError(err) @@ -45,7 +45,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { s.Require().NoError(err) amountSwap := sdk.NewCoin(usdt, math.NewInt(1000)) - return &types.MsgSwapTonomUSD{ + return &types.MsgSwapToNom{ Address: s.TestAccs[0].String(), Coin: amountSwap, } @@ -57,7 +57,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { { name: "insufficient balance", addr: s.TestAccs[1], - setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapTonomUSD { + setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom { _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), Denom: usdc, @@ -69,7 +69,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { s.Require().NoError(err) amountSwap := sdk.NewCoin(usdc, math.NewInt(1000)) - return &types.MsgSwapTonomUSD{ + return &types.MsgSwapToNom{ Address: s.TestAccs[1].String(), Coin: amountSwap, } @@ -84,7 +84,7 @@ func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { s.Run(t.name, func() { msg := t.setup(s.Ctx, s.k) - _, err := s.msgServer.SwapTonomUSD(s.Ctx, msg) + _, err := s.msgServer.SwapToNom(s.Ctx, msg) if t.expectPass { s.Require().NoError(err) balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenoms[0]) @@ -131,11 +131,11 @@ func (s *KeeperTestSuite) TestMsgSwapToStablecoin() { s.Require().NoError(err) amountSwap := sdk.NewCoin(usdt, math.NewInt(1001)) - msg := &types.MsgSwapTonomUSD{ + msg := &types.MsgSwapToNom{ Address: s.TestAccs[0].String(), Coin: amountSwap, } - _, err = s.msgServer.SwapTonomUSD(s.Ctx, msg) + _, err = s.msgServer.SwapToNom(s.Ctx, msg) s.Require().NoError(err) return &types.MsgSwapToStablecoin{ diff --git a/x/psm/keeper/proposals_test.go b/x/psm/keeper/proposals_test.go index 67cc4ed9..79cf321d 100644 --- a/x/psm/keeper/proposals_test.go +++ b/x/psm/keeper/proposals_test.go @@ -36,6 +36,7 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() { Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", } _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &proAdd) diff --git a/x/psm/types/codec.go b/x/psm/types/codec.go index c281b27f..4c59fd4b 100644 --- a/x/psm/types/codec.go +++ b/x/psm/types/codec.go @@ -14,7 +14,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateParams{}, &MsgSwapToStablecoin{}, - &MsgSwapTonomUSD{}, + &MsgSwapToNom{}, &MsgSwapToStablecoin{}, &MsgAddStableCoin{}, &MsgUpdatesStableCoin{}, diff --git a/x/psm/types/msgs.go b/x/psm/types/msgs.go index be359bba..95130edf 100644 --- a/x/psm/types/msgs.go +++ b/x/psm/types/msgs.go @@ -9,7 +9,7 @@ import ( ) var ( - _ sdk.Msg = &MsgSwapTonomUSD{} + _ sdk.Msg = &MsgSwapToNom{} _ sdk.Msg = &MsgSwapToStablecoin{} _ sdk.Msg = &MsgAddStableCoin{} _ sdk.Msg = &MsgUpdatesStableCoin{} @@ -31,14 +31,14 @@ func init() { } -func NewMsgSwapTonomUSD(addr string, coin sdk.Coin) *MsgSwapTonomUSD { - return &MsgSwapTonomUSD{ +func NewMsgSwapToNom(addr string, coin sdk.Coin) *MsgSwapToNom { + return &MsgSwapToNom{ Address: addr, Coin: coin, } } -func (msg MsgSwapTonomUSD) ValidateBasic() error { +func (msg MsgSwapToNom) ValidateBasic() error { if msg.Address == "" { return fmt.Errorf("empty address") } @@ -46,7 +46,7 @@ func (msg MsgSwapTonomUSD) ValidateBasic() error { return msg.Coin.Validate() } -func (msg MsgSwapTonomUSD) GetSigners() []sdk.AccAddress { +func (msg MsgSwapToNom) GetSigners() []sdk.AccAddress { acc, err := sdk.AccAddressFromBech32(msg.Address) if err != nil { panic(err) @@ -55,7 +55,7 @@ func (msg MsgSwapTonomUSD) GetSigners() []sdk.AccAddress { } // Route implements the sdk.Msg interface. -func (msg MsgSwapTonomUSD) Route() string { return RouterKey } +func (msg MsgSwapToNom) Route() string { return RouterKey } // /////////// func NewMsgSwapToStablecoin(addr, toDenom string, amount sdk.Coin) *MsgSwapToStablecoin { diff --git a/x/psm/types/params.pb.go b/x/psm/types/params.pb.go index 9fa3b6d1..fb71b2d9 100644 --- a/x/psm/types/params.pb.go +++ b/x/psm/types/params.pb.go @@ -27,7 +27,7 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { - // total $nomUSD can mint + // total $nomX can mint LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` // The price cannot be exactly 1, an acceptable such as 0.9999 (AcceptablePriceRatio = 0.0001) AcceptablePriceRatio cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=acceptable_price_ratio,json=acceptablePriceRatio,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"acceptable_price_ratio"` diff --git a/x/psm/types/psm.pb.go b/x/psm/types/psm.pb.go index 959a4fc8..56b53715 100644 --- a/x/psm/types/psm.pb.go +++ b/x/psm/types/psm.pb.go @@ -32,9 +32,9 @@ type Stablecoin struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` // limit total stablecoin LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` - // stablecoin to nomUSD exchange fee, fee_in when 1 stablecoin = 1nomUSD + // stablecoin to nom exchange fee, fee_in when 1 stablecoin = 1nomUSD FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` - // nomUSD to stablecoin exchange fee, fee_out when 1 stablecoin = 1nomUSD + // nom to stablecoin exchange fee, fee_out when 1 stablecoin = 1nomUSD FeeOut cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=fee_out,json=feeOut,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_out"` // amount of stablecoins locked in exchange for nomUSD TotalStablecoinLock cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=total_stablecoin_lock,json=totalStablecoinLock,proto3,customtype=cosmossdk.io/math.Int" json:"total_stablecoin_lock"` diff --git a/x/psm/types/tx.pb.go b/x/psm/types/tx.pb.go index 43cbbf3b..d8abd3a9 100644 --- a/x/psm/types/tx.pb.go +++ b/x/psm/types/tx.pb.go @@ -128,23 +128,23 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo -type MsgSwapTonomUSD struct { +type MsgSwapToNom struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin"` } -func (m *MsgSwapTonomUSD) Reset() { *m = MsgSwapTonomUSD{} } -func (m *MsgSwapTonomUSD) String() string { return proto.CompactTextString(m) } -func (*MsgSwapTonomUSD) ProtoMessage() {} -func (*MsgSwapTonomUSD) Descriptor() ([]byte, []int) { +func (m *MsgSwapToNom) Reset() { *m = MsgSwapToNom{} } +func (m *MsgSwapToNom) String() string { return proto.CompactTextString(m) } +func (*MsgSwapToNom) ProtoMessage() {} +func (*MsgSwapToNom) Descriptor() ([]byte, []int) { return fileDescriptor_d0ff2d5421e71e2a, []int{2} } -func (m *MsgSwapTonomUSD) XXX_Unmarshal(b []byte) error { +func (m *MsgSwapToNom) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSwapTonomUSD) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSwapToNom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSwapTonomUSD.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSwapToNom.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -154,47 +154,47 @@ func (m *MsgSwapTonomUSD) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *MsgSwapTonomUSD) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSwapTonomUSD.Merge(m, src) +func (m *MsgSwapToNom) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapToNom.Merge(m, src) } -func (m *MsgSwapTonomUSD) XXX_Size() int { +func (m *MsgSwapToNom) XXX_Size() int { return m.Size() } -func (m *MsgSwapTonomUSD) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSwapTonomUSD.DiscardUnknown(m) +func (m *MsgSwapToNom) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapToNom.DiscardUnknown(m) } -var xxx_messageInfo_MsgSwapTonomUSD proto.InternalMessageInfo +var xxx_messageInfo_MsgSwapToNom proto.InternalMessageInfo -func (m *MsgSwapTonomUSD) GetAddress() string { +func (m *MsgSwapToNom) GetAddress() string { if m != nil { return m.Address } return "" } -func (m *MsgSwapTonomUSD) GetCoin() types.Coin { +func (m *MsgSwapToNom) GetCoin() types.Coin { if m != nil { return m.Coin } return types.Coin{} } -type MsgSwapTonomUSDResponse struct { +type MsgSwapToNomResponse struct { } -func (m *MsgSwapTonomUSDResponse) Reset() { *m = MsgSwapTonomUSDResponse{} } -func (m *MsgSwapTonomUSDResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSwapTonomUSDResponse) ProtoMessage() {} -func (*MsgSwapTonomUSDResponse) Descriptor() ([]byte, []int) { +func (m *MsgSwapToNomResponse) Reset() { *m = MsgSwapToNomResponse{} } +func (m *MsgSwapToNomResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSwapToNomResponse) ProtoMessage() {} +func (*MsgSwapToNomResponse) Descriptor() ([]byte, []int) { return fileDescriptor_d0ff2d5421e71e2a, []int{3} } -func (m *MsgSwapTonomUSDResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgSwapToNomResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSwapTonomUSDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSwapToNomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSwapTonomUSDResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSwapToNomResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -204,17 +204,17 @@ func (m *MsgSwapTonomUSDResponse) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *MsgSwapTonomUSDResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSwapTonomUSDResponse.Merge(m, src) +func (m *MsgSwapToNomResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSwapToNomResponse.Merge(m, src) } -func (m *MsgSwapTonomUSDResponse) XXX_Size() int { +func (m *MsgSwapToNomResponse) XXX_Size() int { return m.Size() } -func (m *MsgSwapTonomUSDResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSwapTonomUSDResponse.DiscardUnknown(m) +func (m *MsgSwapToNomResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSwapToNomResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgSwapTonomUSDResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgSwapToNomResponse proto.InternalMessageInfo type MsgSwapToStablecoin struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` @@ -513,8 +513,8 @@ var xxx_messageInfo_MsgUpdatesStableCoinResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgUpdateParams)(nil), "reserve.psm.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "reserve.psm.v1.MsgUpdateParamsResponse") - proto.RegisterType((*MsgSwapTonomUSD)(nil), "reserve.psm.v1.MsgSwapTonomUSD") - proto.RegisterType((*MsgSwapTonomUSDResponse)(nil), "reserve.psm.v1.MsgSwapTonomUSDResponse") + proto.RegisterType((*MsgSwapToNom)(nil), "reserve.psm.v1.MsgSwapToNom") + proto.RegisterType((*MsgSwapToNomResponse)(nil), "reserve.psm.v1.MsgSwapToNomResponse") proto.RegisterType((*MsgSwapToStablecoin)(nil), "reserve.psm.v1.MsgSwapToStablecoin") proto.RegisterType((*MsgSwapToStablecoinResponse)(nil), "reserve.psm.v1.MsgSwapToStablecoinResponse") proto.RegisterType((*MsgAddStableCoin)(nil), "reserve.psm.v1.MsgAddStableCoin") @@ -526,55 +526,55 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/tx.proto", fileDescriptor_d0ff2d5421e71e2a) } var fileDescriptor_d0ff2d5421e71e2a = []byte{ - // 760 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcf, 0x4f, 0x13, 0x5b, - 0x14, 0xee, 0xbc, 0xd2, 0xf2, 0x7a, 0x69, 0xde, 0xe3, 0xcd, 0x2b, 0x32, 0x1d, 0x64, 0x20, 0xd5, - 0x44, 0x82, 0x30, 0x43, 0x31, 0x1a, 0x65, 0x47, 0x6d, 0x8c, 0x18, 0x89, 0xd8, 0x42, 0x42, 0xdc, - 0x34, 0xb7, 0x33, 0x97, 0x61, 0x62, 0xef, 0xdc, 0xc9, 0xdc, 0xdb, 0x4a, 0x77, 0xc6, 0xa5, 0x2b, - 0xe3, 0xc6, 0xa5, 0x5b, 0x97, 0x2c, 0x88, 0x7f, 0x03, 0x4b, 0xc2, 0xca, 0xb8, 0x20, 0x06, 0x16, - 0xfc, 0x13, 0x2e, 0xcc, 0x9d, 0x3b, 0x1d, 0x3a, 0x6d, 0x11, 0x82, 0x71, 0xe7, 0x86, 0x70, 0xcf, - 0xf9, 0xce, 0x77, 0xbe, 0xf3, 0x63, 0x4e, 0xc1, 0xb8, 0x8f, 0x28, 0xf2, 0x5b, 0xc8, 0xf0, 0x28, - 0x36, 0x5a, 0x45, 0x83, 0xed, 0xe8, 0x9e, 0x4f, 0x18, 0x91, 0xff, 0x09, 0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a5, 0xa8, 0x40, 0x83, 0x92, 0xaa, 0xaf, 0xa0, 0xb7, 0x4e, 0x5c, 0x82, 0x37, 0xaa, - 0x65, 0x59, 0x01, 0xc3, 0x50, 0xc8, 0x16, 0x05, 0x55, 0x3a, 0x4f, 0xf9, 0x3e, 0x18, 0xe2, 0xed, - 0x08, 0x25, 0xe7, 0xf5, 0xb0, 0x48, 0xde, 0x2f, 0x3d, 0xec, 0x97, 0xfe, 0x90, 0x38, 0x6e, 0xb7, - 0xea, 0x20, 0x62, 0x29, 0xcb, 0x35, 0x77, 0x78, 0x42, 0x3d, 0xdd, 0x49, 0x23, 0x3d, 0xef, 0x25, - 0xf0, 0x7f, 0xe4, 0xab, 0x32, 0x58, 0x6f, 0x20, 0x4e, 0xf0, 0x13, 0x51, 0x79, 0xf0, 0x37, 0x23, - 0x35, 0x0b, 0xb9, 0x04, 0x07, 0xc2, 0x32, 0x95, 0x61, 0x46, 0xca, 0xfc, 0x19, 0xe9, 0x4d, 0xfe, - 0xa2, 0xde, 0x49, 0x30, 0x31, 0x40, 0x53, 0xa4, 0xf9, 0x43, 0x12, 0x8c, 0xae, 0x52, 0x7b, 0xd9, - 0xb2, 0x84, 0x93, 0x53, 0x5e, 0x79, 0x31, 0x72, 0x20, 0xd5, 0x5d, 0x8b, 0x78, 0xc8, 0xcf, 0xc1, - 0x48, 0xc3, 0xc1, 0x0e, 0xab, 0x31, 0xc2, 0x60, 0x23, 0x28, 0x28, 0x5b, 0x5a, 0xe0, 0xaa, 0xbf, - 0x1e, 0x4d, 0x8d, 0x09, 0x4e, 0x6a, 0xbd, 0xd4, 0x1d, 0x62, 0x60, 0xc8, 0xb6, 0xf5, 0x15, 0x97, - 0x1d, 0xee, 0xcd, 0x83, 0x30, 0xd9, 0x8a, 0xcb, 0x44, 0x71, 0x20, 0x20, 0x59, 0xe7, 0x1c, 0xf2, - 0x63, 0x90, 0xde, 0x42, 0xa8, 0xe6, 0xb8, 0xca, 0x50, 0xc0, 0x56, 0x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 0x30, 0xda, 0x77, 0xb9, 0x6f, 0x9c, 0x1b, 0x7c, 0x06, 0x52, 0x6f, 0x5f, 0x02, 0xd4, 0xc9, - 0xa2, 0xa6, 0x5e, 0xf3, 0x4f, 0xa2, 0xf4, 0x68, 0xff, 0x58, 0x93, 0x0e, 0x8e, 0x35, 0xe9, 0xdb, - 0xb1, 0x26, 0xbd, 0x3b, 0xd1, 0x12, 0x07, 0x27, 0x5a, 0xe2, 0xcb, 0x89, 0x96, 0x78, 0x31, 0x67, - 0x3b, 0x6c, 0xbb, 0x59, 0xd7, 0x4d, 0x82, 0x0d, 0x2e, 0xb1, 0x1d, 0xfc, 0x7e, 0x9b, 0xa4, 0x61, - 0xc4, 0xb7, 0x8e, 0xef, 0x2a, 0xad, 0xa7, 0x03, 0xef, 0x9d, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0xaa, 0x41, 0xe4, 0x79, 0xa2, 0x08, 0x00, 0x00, + // 763 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0x4f, 0x4f, 0x13, 0x5b, + 0x14, 0xef, 0xbc, 0xd2, 0xf2, 0x7a, 0x69, 0xde, 0xe3, 0xcd, 0x2b, 0x30, 0x1d, 0x60, 0x20, 0x95, + 0x44, 0x82, 0x30, 0x43, 0x31, 0x1a, 0x65, 0x47, 0x25, 0x46, 0x8c, 0x15, 0x2c, 0x98, 0x18, 0x37, + 0xcd, 0xed, 0xcc, 0x65, 0x98, 0xd8, 0x3b, 0x77, 0x32, 0xf7, 0xb6, 0xd2, 0x9d, 0x71, 0xe9, 0xca, + 0xb8, 0x71, 0xe9, 0xd6, 0x25, 0x0b, 0xe2, 0x67, 0x60, 0x49, 0x58, 0x19, 0x17, 0xc4, 0xc0, 0x82, + 0x0f, 0xe0, 0x17, 0x30, 0x77, 0xee, 0x74, 0xfa, 0x97, 0x3f, 0xc1, 0xb8, 0x73, 0x43, 0x38, 0xe7, + 0x77, 0xce, 0xef, 0xfc, 0xce, 0x3d, 0x67, 0x4e, 0xc1, 0x98, 0x8f, 0x28, 0xf2, 0xeb, 0xc8, 0xf0, + 0x28, 0x36, 0xea, 0x79, 0x83, 0xed, 0xea, 0x9e, 0x4f, 0x18, 0x91, 0xff, 0x09, 0x01, 0xdd, 0xa3, + 0x58, 0xaf, 0xe7, 0xd5, 0xff, 0x20, 0x76, 0x5c, 0x62, 0x04, 0x7f, 0x45, 0x88, 0x3a, 0x66, 0x12, + 0x8a, 0x09, 0x35, 0x30, 0xb5, 0x79, 0x2a, 0xa6, 0x76, 0x08, 0x64, 0x05, 0x50, 0x0e, 0x2c, 0x43, + 0x18, 0x21, 0x94, 0xb1, 0x89, 0x4d, 0x84, 0x9f, 0xff, 0x17, 0x7a, 0xc7, 0xbb, 0x54, 0x78, 0xd0, + 0x87, 0xb8, 0x99, 0xa2, 0x85, 0x65, 0x2a, 0x90, 0x22, 0xa3, 0x9e, 0xaf, 0x20, 0x06, 0xf3, 0x86, + 0x49, 0x1c, 0x57, 0xe0, 0xb9, 0x2f, 0x12, 0xf8, 0xb7, 0x48, 0xed, 0xe7, 0x9e, 0x05, 0x19, 0xda, + 0x08, 0x32, 0xe5, 0xbb, 0x20, 0x05, 0x6b, 0x6c, 0x87, 0xf8, 0x0e, 0x6b, 0x28, 0xd2, 0xb4, 0x34, + 0x9b, 0x2a, 0x28, 0x47, 0xfb, 0x0b, 0x99, 0x50, 0xcb, 0x8a, 0x65, 0xf9, 0x88, 0xd2, 0x4d, 0xe6, + 0x3b, 0xae, 0x5d, 0x6a, 0x85, 0xca, 0xf7, 0x41, 0x52, 0xd4, 0x56, 0xfe, 0x9a, 0x96, 0x66, 0x87, + 0x96, 0x46, 0xf5, 0xce, 0x67, 0xd0, 0x05, 0x7f, 0x21, 0x75, 0x70, 0x3c, 0x15, 0xfb, 0x7c, 0xb6, + 0x37, 0x27, 0x95, 0xc2, 0x84, 0xe5, 0xc5,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 0x7a, 0x8c, 0x0a, 0xcd, 0x9c, 0x2b, 0xb5, 0x2d, 0x5a, 0x9d, 0xbf, + 0x4a, 0x54, 0x54, 0x70, 0x1d, 0xa4, 0x5a, 0xa7, 0x7e, 0xa2, 0x4f, 0x6a, 0x84, 0xaa, 0x33, 0x17, + 0xa1, 0x11, 0xa1, 0x05, 0x86, 0x7b, 0x0e, 0xf6, 0x8d, 0x73, 0x33, 0x5b, 0x41, 0xea, 0xad, 0x2b, + 0x04, 0x35, 0xab, 0xa8, 0x89, 0x37, 0xfc, 0x4b, 0x28, 0x3c, 0x3c, 0x38, 0xd1, 0xa4, 0xc3, 0x13, + 0x4d, 0xfa, 0x7e, 0xa2, 0x49, 0xef, 0x4f, 0xb5, 0xd8, 0xe1, 0xa9, 0x16, 0xfb, 0x7a, 0xaa, 0xc5, + 0x5e, 0xce, 0xdb, 0x0e, 0xdb, 0xa9, 0x55, 0x74, 0x93, 0x60, 0x83, 0xb8, 0x04, 0x37, 0x82, 0x1f, + 0x6c, 0x93, 0x54, 0x8d, 0xce, 0x65, 0xe3, 0x2b, 0x4a, 0x2b, 0xc9, 0x00, 0xbd, 0xfd, 0x33, 0x00, + 0x00, 0xff, 0xff, 0xc0, 0x4e, 0x98, 0x0e, 0x93, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -594,7 +594,7 @@ type MsgClient interface { UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) AddStableCoinProposal(ctx context.Context, in *MsgAddStableCoin, opts ...grpc.CallOption) (*MsgAddStableCoinResponse, error) UpdatesStableCoinProposal(ctx context.Context, in *MsgUpdatesStableCoin, opts ...grpc.CallOption) (*MsgUpdatesStableCoinResponse, error) - SwapTonomUSD(ctx context.Context, in *MsgSwapTonomUSD, opts ...grpc.CallOption) (*MsgSwapTonomUSDResponse, error) + SwapToNom(ctx context.Context, in *MsgSwapToNom, opts ...grpc.CallOption) (*MsgSwapToNomResponse, error) SwapToStablecoin(ctx context.Context, in *MsgSwapToStablecoin, opts ...grpc.CallOption) (*MsgSwapToStablecoinResponse, error) } @@ -633,9 +633,9 @@ func (c *msgClient) UpdatesStableCoinProposal(ctx context.Context, in *MsgUpdate return out, nil } -func (c *msgClient) SwapTonomUSD(ctx context.Context, in *MsgSwapTonomUSD, opts ...grpc.CallOption) (*MsgSwapTonomUSDResponse, error) { - out := new(MsgSwapTonomUSDResponse) - err := c.cc.Invoke(ctx, "/reserve.psm.v1.Msg/SwapTonomUSD", in, out, opts...) +func (c *msgClient) SwapToNom(ctx context.Context, in *MsgSwapToNom, opts ...grpc.CallOption) (*MsgSwapToNomResponse, error) { + out := new(MsgSwapToNomResponse) + err := c.cc.Invoke(ctx, "/reserve.psm.v1.Msg/SwapToNom", in, out, opts...) if err != nil { return nil, err } @@ -658,7 +658,7 @@ type MsgServer interface { UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) AddStableCoinProposal(context.Context, *MsgAddStableCoin) (*MsgAddStableCoinResponse, error) UpdatesStableCoinProposal(context.Context, *MsgUpdatesStableCoin) (*MsgUpdatesStableCoinResponse, error) - SwapTonomUSD(context.Context, *MsgSwapTonomUSD) (*MsgSwapTonomUSDResponse, error) + SwapToNom(context.Context, *MsgSwapToNom) (*MsgSwapToNomResponse, error) SwapToStablecoin(context.Context, *MsgSwapToStablecoin) (*MsgSwapToStablecoinResponse, error) } @@ -675,8 +675,8 @@ func (*UnimplementedMsgServer) AddStableCoinProposal(ctx context.Context, req *M func (*UnimplementedMsgServer) UpdatesStableCoinProposal(ctx context.Context, req *MsgUpdatesStableCoin) (*MsgUpdatesStableCoinResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdatesStableCoinProposal not implemented") } -func (*UnimplementedMsgServer) SwapTonomUSD(ctx context.Context, req *MsgSwapTonomUSD) (*MsgSwapTonomUSDResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SwapTonomUSD not implemented") +func (*UnimplementedMsgServer) SwapToNom(ctx context.Context, req *MsgSwapToNom) (*MsgSwapToNomResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SwapToNom not implemented") } func (*UnimplementedMsgServer) SwapToStablecoin(ctx context.Context, req *MsgSwapToStablecoin) (*MsgSwapToStablecoinResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SwapToStablecoin not implemented") @@ -740,20 +740,20 @@ func _Msg_UpdatesStableCoinProposal_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } -func _Msg_SwapTonomUSD_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSwapTonomUSD) +func _Msg_SwapToNom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSwapToNom) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).SwapTonomUSD(ctx, in) + return srv.(MsgServer).SwapToNom(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/reserve.psm.v1.Msg/SwapTonomUSD", + FullMethod: "/reserve.psm.v1.Msg/SwapToNom", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SwapTonomUSD(ctx, req.(*MsgSwapTonomUSD)) + return srv.(MsgServer).SwapToNom(ctx, req.(*MsgSwapToNom)) } return interceptor(ctx, in, info, handler) } @@ -793,8 +793,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_UpdatesStableCoinProposal_Handler, }, { - MethodName: "SwapTonomUSD", - Handler: _Msg_SwapTonomUSD_Handler, + MethodName: "SwapToNom", + Handler: _Msg_SwapToNom_Handler, }, { MethodName: "SwapToStablecoin", @@ -868,7 +868,7 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *MsgSwapTonomUSD) Marshal() (dAtA []byte, err error) { +func (m *MsgSwapToNom) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -878,12 +878,12 @@ func (m *MsgSwapTonomUSD) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSwapTonomUSD) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSwapToNom) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSwapTonomUSD) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSwapToNom) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -908,7 +908,7 @@ func (m *MsgSwapTonomUSD) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgSwapTonomUSDResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgSwapToNomResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -918,12 +918,12 @@ func (m *MsgSwapTonomUSDResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSwapTonomUSDResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSwapToNomResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSwapTonomUSDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSwapToNomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1230,7 +1230,7 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } -func (m *MsgSwapTonomUSD) Size() (n int) { +func (m *MsgSwapToNom) Size() (n int) { if m == nil { return 0 } @@ -1245,7 +1245,7 @@ func (m *MsgSwapTonomUSD) Size() (n int) { return n } -func (m *MsgSwapTonomUSDResponse) Size() (n int) { +func (m *MsgSwapToNomResponse) Size() (n int) { if m == nil { return 0 } @@ -1525,7 +1525,7 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSwapTonomUSD) Unmarshal(dAtA []byte) error { +func (m *MsgSwapToNom) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1548,10 +1548,10 @@ func (m *MsgSwapTonomUSD) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSwapTonomUSD: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSwapToNom: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSwapTonomUSD: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSwapToNom: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1640,7 +1640,7 @@ func (m *MsgSwapTonomUSD) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSwapTonomUSDResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSwapToNomResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1663,10 +1663,10 @@ func (m *MsgSwapTonomUSDResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSwapTonomUSDResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSwapToNomResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSwapTonomUSDResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSwapToNomResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From 17404ce2e93d06240e7331e54499c1f7f33cc9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 16:27:04 +0700 Subject: [PATCH 19/42] nits --- x/psm/keeper/proposals_test.go | 1 + x/psm/keeper/swap_test.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/x/psm/keeper/proposals_test.go b/x/psm/keeper/proposals_test.go index 79cf321d..6e9dd493 100644 --- a/x/psm/keeper/proposals_test.go +++ b/x/psm/keeper/proposals_test.go @@ -16,6 +16,7 @@ func (s *KeeperTestSuite) TestAddStableCoinProposal() { Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", } _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &proAdd) diff --git a/x/psm/keeper/swap_test.go b/x/psm/keeper/swap_test.go index fcb3798a..ca2eaca3 100644 --- a/x/psm/keeper/swap_test.go +++ b/x/psm/keeper/swap_test.go @@ -40,6 +40,7 @@ func (s *KeeperTestSuite) TestSwapTonomUSD() { LimitTotal: limitUSDT, FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", }) s.Require().NoError(err) }, @@ -58,6 +59,7 @@ func (s *KeeperTestSuite) TestSwapTonomUSD() { LimitTotal: limitUSDC, FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", }) s.Require().NoError(err) }, @@ -115,6 +117,7 @@ func (s *KeeperTestSuite) TestSwapToStablecoin() { LimitTotal: limitUSDT, FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", }) s.Require().NoError(err) }, @@ -134,6 +137,7 @@ func (s *KeeperTestSuite) TestSwapToStablecoin() { LimitTotal: limitUSDC, FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", }) s.Require().NoError(err) }, From fb8ec9eadd682a4aabb954d771f25c93fc17d695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 16:30:17 +0700 Subject: [PATCH 20/42] minor --- x/psm/keeper/proposals_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/psm/keeper/proposals_test.go b/x/psm/keeper/proposals_test.go index 6e9dd493..65930900 100644 --- a/x/psm/keeper/proposals_test.go +++ b/x/psm/keeper/proposals_test.go @@ -57,6 +57,7 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() { Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), + NomType: "nomUSD", } _, err = s.msgServer.UpdatesStableCoinProposal(s.Ctx, &proUpdates) From 175dcf75de023e05240c94fb218611af9c68660e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Mon, 4 Nov 2024 16:41:40 +0700 Subject: [PATCH 21/42] rename and update scipt psm --- script/psm-test.sh | 22 ++++++++++++++-------- x/psm/client/cli/tx.go | 17 +++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/script/psm-test.sh b/script/psm-test.sh index 1f29af11..f141ae0d 100755 --- a/script/psm-test.sh +++ b/script/psm-test.sh @@ -136,24 +136,30 @@ reserved q bank balances $(reserved keys show validator1 -a --keyring-backend te # # tx swap usdt to nomUSD # echo "========swap===========" -reserved tx psm swap-to-nomUSD 100000000000000000000000usdt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake +reserved tx psm swap-to-nom 100000000000000000000000usdt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake sleep 7 -reserved tx psm swap-to-nomUSD 100000000000000000000000eurt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake +reserved tx psm swap-to-nom 100000000000000000000000eurt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake sleep 7 -reserved tx psm swap-to-nomUSD 100000000000000000000000usdc --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake +reserved tx psm swap-to-nom 100000000000000000000000usdc --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake sleep 7 -reserved tx psm swap-to-nomUSD 100000000000000000000000jpyt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake +reserved tx psm swap-to-nom 100000000000000000000000jpyt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake sleep 7 # # Check account after swap reserved q bank balances $(reserved keys show validator1 -a --keyring-backend test --home /Users/donglieu/.reserved/validator1) # # tx swap nomUSD to usdt -# reserved tx psm swap-to-stablecoin usdt 1000nomUSD --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake +reserved tx psm swap-to-stablecoin usdc 1000nomUSD --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake -# sleep 7 -# # Check account after swap -# reserved q bank balances $(reserved keys show validator1 -a --keyring-backend test --home /Users/donglieu/.reserved/validator1) +sleep 7 +# Check account after swap +reserved tx psm swap-to-stablecoin eurt 1000nomEUR --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake + +sleep 7 +reserved tx psm swap-to-stablecoin jpyt 1000nomJPY --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake + +sleep 7 +reserved q bank balances $(reserved keys show validator1 -a --keyring-backend test --home /Users/donglieu/.reserved/validator1) # # killall reserved || true \ No newline at end of file diff --git a/x/psm/client/cli/tx.go b/x/psm/client/cli/tx.go index aeb42f93..7ab48018 100644 --- a/x/psm/client/cli/tx.go +++ b/x/psm/client/cli/tx.go @@ -22,20 +22,21 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand(NewSwapToStablecoinCmd()) - cmd.AddCommand(NewSwapTonomUSDCmd()) + cmd.AddCommand(NewSwapToNomCmd()) return cmd } -func NewSwapTonomUSDCmd() *cobra.Command { +func NewSwapToNomCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "swap-to-nomUSD [stablecoin]", + Use: "swap-to-nom [stablecoin]", Args: cobra.ExactArgs(1), Short: "swap stablecoin to $nomUSD ", Long: `swap stablecoin to $nomUSD. Example: - $ onomyd tx psm swap-to-nomUSD 1000usdt --from mykey + $ onomyd tx psm swap-to-nom 100000000000000000000000usdt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake + `, RunE: func(cmd *cobra.Command, args []string) error { @@ -62,13 +63,13 @@ func NewSwapTonomUSDCmd() *cobra.Command { func NewSwapToStablecoinCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "swap-to-stablecoin [stable-coin-type] [amount-nomUSD]", + Use: "swap-to-stablecoin [stable-coin-type] [amount-nomX]", Args: cobra.ExactArgs(2), - Short: "swap $nomUSD to stablecoin ", - Long: `swap $nomUSD to stablecoin. + Short: "swap $nomX to stablecoin. ", + Long: `swap $nomX to stablecoin. Example: - $ onomyd tx psm swap-to-stablecoin usdt 10000nomUSD --from mykey + $ onomyd tx psm swap-to-stablecoin usdc 10000nomUSD --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake `, RunE: func(cmd *cobra.Command, args []string) error { From 2c6e0f95cc8b923099fb8059cb294018d36411a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Tue, 5 Nov 2024 17:25:24 +0700 Subject: [PATCH 22/42] use collections --- x/auction/keeper/genesis.go | 2 +- x/auction/keeper/keeper.go | 29 +++++++++++++++-------------- x/auction/keeper/liquidate.go | 11 +++++++++-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/x/auction/keeper/genesis.go b/x/auction/keeper/genesis.go index 9bd33850..61f1f6e6 100644 --- a/x/auction/keeper/genesis.go +++ b/x/auction/keeper/genesis.go @@ -10,7 +10,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { if err := k.SetParams(ctx, genState.Params); err != nil { panic(err) } - k.LastestAuctionPeriod = ctx.BlockTime().Unix() + k.LastestAuctionPeriods.Set(ctx, "LastestAuctionPeriods", ctx.BlockTime().Unix()) } func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 8193f413..d12a98b4 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -31,7 +31,7 @@ type ( authority string // timestamp of lastest auction period (Unix timestamp) - LastestAuctionPeriod int64 + LastestAuctionPeriods collections.Map[string, int64] AuctionIdSeq collections.Sequence @@ -66,19 +66,20 @@ func NewKeeper( sb := collections.NewSchemaBuilder(storeService) return Keeper{ - cdc: cdc, - storeService: storeService, - authority: authority, - logger: logger, - authKeeper: ak, - bankKeeper: bk, - vaultKeeper: vk, - OracleKeeper: ok, - AuctionIdSeq: collections.NewSequence(sb, types.AuctionIdSeqPrefix, "auction_id_sequence"), - BidIdSeq: collections.NewMap(sb, types.BidIdSeqPrefix, "bid_id_sequence", collections.Uint64Key, collections.Uint64Value), - Auctions: collections.NewMap(sb, types.AuctionsPrefix, "auctions", collections.Uint64Key, codec.CollValue[types.Auction](cdc)), - Bids: collections.NewMap(sb, types.BidsPrefix, "bids", collections.Uint64Key, codec.CollValue[types.BidQueue](cdc)), - BidByAddress: collections.NewMap(sb, types.BidByAddressPrefix, "bids_by_address", collections.PairKeyCodec(collections.Uint64Key, sdk.LengthPrefixedAddressKey(sdk.AccAddressKey)), codec.CollValue[types.Bids](cdc)), //nolint:staticcheck + cdc: cdc, + storeService: storeService, + authority: authority, + logger: logger, + authKeeper: ak, + bankKeeper: bk, + vaultKeeper: vk, + OracleKeeper: ok, + AuctionIdSeq: collections.NewSequence(sb, types.AuctionIdSeqPrefix, "auction_id_sequence"), + LastestAuctionPeriods: collections.NewMap(sb, types.LastestAuctionPeriodPrefix, "lastestAuctionPeriods", collections.StringKey, collections.Int64Value), + BidIdSeq: collections.NewMap(sb, types.BidIdSeqPrefix, "bid_id_sequence", collections.Uint64Key, collections.Uint64Value), + Auctions: collections.NewMap(sb, types.AuctionsPrefix, "auctions", collections.Uint64Key, codec.CollValue[types.Auction](cdc)), + Bids: collections.NewMap(sb, types.BidsPrefix, "bids", collections.Uint64Key, codec.CollValue[types.BidQueue](cdc)), + BidByAddress: collections.NewMap(sb, types.BidByAddressPrefix, "bids_by_address", collections.PairKeyCodec(collections.Uint64Key, sdk.LengthPrefixedAddressKey(sdk.AccAddressKey)), codec.CollValue[types.Bids](cdc)), //nolint:staticcheck } } diff --git a/x/auction/keeper/liquidate.go b/x/auction/keeper/liquidate.go index b7178318..c3c2a4de 100644 --- a/x/auction/keeper/liquidate.go +++ b/x/auction/keeper/liquidate.go @@ -14,11 +14,18 @@ func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error { params := k.GetParams(ctx) currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time - lastAuctionPeriods := time.Unix(k.LastestAuctionPeriod, 0) + lastestAuctionPeriod, err := k.LastestAuctionPeriods.Get(ctx, "LastestAuctionPeriods") + if err != nil { + return err + } + lastAuctionPeriods := time.Unix(lastestAuctionPeriod, 0) // check if has reached the next auction periods if lastAuctionPeriods.Add(params.AuctionPeriods).Before(currentTime) { // update latest auction period - k.LastestAuctionPeriod = lastAuctionPeriods.Add(params.AuctionPeriods).Unix() + err = k.LastestAuctionPeriods.Set(ctx, "LastestAuctionPeriods", lastAuctionPeriods.Add(params.AuctionPeriods).Unix()) + if err != nil { + return err + } liquidations, err := k.vaultKeeper.GetLiquidations(ctx, mintDenom) if err != nil { From 474bc3c3c5b204998deb4c9ebe37509720922826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Tue, 5 Nov 2024 17:27:59 +0700 Subject: [PATCH 23/42] lint --- x/auction/keeper/genesis.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/auction/keeper/genesis.go b/x/auction/keeper/genesis.go index 61f1f6e6..0e9aa5cf 100644 --- a/x/auction/keeper/genesis.go +++ b/x/auction/keeper/genesis.go @@ -10,7 +10,10 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { if err := k.SetParams(ctx, genState.Params); err != nil { panic(err) } - k.LastestAuctionPeriods.Set(ctx, "LastestAuctionPeriods", ctx.BlockTime().Unix()) + err := k.LastestAuctionPeriods.Set(ctx, "LastestAuctionPeriods", ctx.BlockTime().Unix()) + if err != nil { + panic(err) + } } func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { From 63b0f5c18690bca160e2ff8cb2bac74eb096d98a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Tue, 5 Nov 2024 17:38:44 +0700 Subject: [PATCH 24/42] fix abci aution --- x/auction/keeper/abci.go | 9 ++--- x/auction/keeper/liquidate.go | 74 ++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/x/auction/keeper/abci.go b/x/auction/keeper/abci.go index 2ebb231d..a0496658 100644 --- a/x/auction/keeper/abci.go +++ b/x/auction/keeper/abci.go @@ -10,13 +10,10 @@ import ( func (k *Keeper) BeginBlocker(ctx context.Context) error { // get allowed mint denom - allowedMintDenoms := k.vaultKeeper.GetAllowedMintDenoms(ctx) - for _, mintDenom := range allowedMintDenoms { - err := k.handleLiquidation(ctx, mintDenom) - if err != nil { - return err - } + err := k.handleLiquidation(ctx) + if err != nil { + return err } return nil diff --git a/x/auction/keeper/liquidate.go b/x/auction/keeper/liquidate.go index c3c2a4de..e48446a5 100644 --- a/x/auction/keeper/liquidate.go +++ b/x/auction/keeper/liquidate.go @@ -10,8 +10,9 @@ import ( vaultstypes "github.com/onomyprotocol/reserve/x/vaults/types" ) -func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error { +func (k Keeper) handleLiquidation(ctx context.Context) error { params := k.GetParams(ctx) + allowedMintDenoms := k.vaultKeeper.GetAllowedMintDenoms(ctx) currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time lastestAuctionPeriod, err := k.LastestAuctionPeriods.Get(ctx, "LastestAuctionPeriods") @@ -26,58 +27,61 @@ func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error { if err != nil { return err } - - liquidations, err := k.vaultKeeper.GetLiquidations(ctx, mintDenom) - if err != nil { - return err - } - - liquidatedVaults := make([]*vaultstypes.Vault, 0) - for _, liq := range liquidations { - liquidatedVaults = append(liquidatedVaults, liq.LiquidatingVaults...) - } - - // create new auction for this vault - for _, vault := range liquidatedVaults { - //calcualte initial price and target price - auction, isCreate, err := k.GetNewAuction(ctx, currentTime, vault.LiquidationPrice, vault.CollateralLocked, vault.Debt, vault.Id) + for _, mintDenom := range allowedMintDenoms { + liquidations, err := k.vaultKeeper.GetLiquidations(ctx, mintDenom) if err != nil { return err } - if isCreate { - err = k.Auctions.Set(ctx, auction.AuctionId, *auction) + liquidatedVaults := make([]*vaultstypes.Vault, 0) + for _, liq := range liquidations { + liquidatedVaults = append(liquidatedVaults, liq.LiquidatingVaults...) + } + + // create new auction for this vault + for _, vault := range liquidatedVaults { + //calcualte initial price and target price + auction, isCreate, err := k.GetNewAuction(ctx, currentTime, vault.LiquidationPrice, vault.CollateralLocked, vault.Debt, vault.Id) if err != nil { return err } - err = k.Bids.Set(ctx, auction.AuctionId, types.BidQueue{AuctionId: auction.AuctionId, Bids: []types.Bid{}}) - if err != nil { - return err + + if isCreate { + err = k.Auctions.Set(ctx, auction.AuctionId, *auction) + if err != nil { + return err + } + err = k.Bids.Set(ctx, auction.AuctionId, types.BidQueue{AuctionId: auction.AuctionId, Bids: []types.Bid{}}) + if err != nil { + return err + } + err = k.BidIdSeq.Set(ctx, auction.AuctionId, 0) + if err != nil { + return err + } } - err = k.BidIdSeq.Set(ctx, auction.AuctionId, 0) if err != nil { return err } } - if err != nil { - return err - } } } - // loop through all auctions - // get liquidations data then distribute debt & collateral remain - liquidationMap, err := k.newLiquidateMap(ctx, mintDenom, params) - if err != nil { - return err - } - - // Loop through liquidationMap and liquidate - for _, liq := range liquidationMap { - err := k.vaultKeeper.Liquidate(ctx, *liq, mintDenom) + for _, mintDenom := range allowedMintDenoms { + // loop through all auctions + // get liquidations data then distribute debt & collateral remain + liquidationMap, err := k.newLiquidateMap(ctx, mintDenom, params) if err != nil { return err } + + // Loop through liquidationMap and liquidate + for _, liq := range liquidationMap { + err := k.vaultKeeper.Liquidate(ctx, *liq, mintDenom) + if err != nil { + return err + } + } } return nil From 3c0516dac08b0c817aa93ef1de1f6760c58fb0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Tue, 5 Nov 2024 20:39:00 +0700 Subject: [PATCH 25/42] check denom --- x/auction/keeper/liquidate.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x/auction/keeper/liquidate.go b/x/auction/keeper/liquidate.go index e48446a5..9d459eaf 100644 --- a/x/auction/keeper/liquidate.go +++ b/x/auction/keeper/liquidate.go @@ -106,6 +106,10 @@ func (k Keeper) newLiquidateMap(ctx context.Context, mintDenom string, params ty return true, err } + if vault.Debt.Denom != mintDenom { + return false, nil + } + needCleanup := false currentRate := math.LegacyMustNewDecFromStr(auction.CurrentRate) lowestRate := math.LegacyMustNewDecFromStr(params.LowestRate) From 799bfa16c7f09e38ecaf4531b578ebe3fd2c1c6c Mon Sep 17 00:00:00 2001 From: vuong177 Date: Wed, 6 Nov 2024 09:56:46 +0700 Subject: [PATCH 26/42] nits --- x/auction/keeper/genesis.go | 2 +- x/auction/keeper/keeper.go | 4 ++-- x/auction/keeper/liquidate.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x/auction/keeper/genesis.go b/x/auction/keeper/genesis.go index 0e9aa5cf..1baed163 100644 --- a/x/auction/keeper/genesis.go +++ b/x/auction/keeper/genesis.go @@ -10,7 +10,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { if err := k.SetParams(ctx, genState.Params); err != nil { panic(err) } - err := k.LastestAuctionPeriods.Set(ctx, "LastestAuctionPeriods", ctx.BlockTime().Unix()) + err := k.LastestAuctionPeriods.Set(ctx, ctx.BlockTime().Unix()) if err != nil { panic(err) } diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index d12a98b4..c4614035 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -31,7 +31,7 @@ type ( authority string // timestamp of lastest auction period (Unix timestamp) - LastestAuctionPeriods collections.Map[string, int64] + LastestAuctionPeriods collections.Item[int64] AuctionIdSeq collections.Sequence @@ -75,7 +75,7 @@ func NewKeeper( vaultKeeper: vk, OracleKeeper: ok, AuctionIdSeq: collections.NewSequence(sb, types.AuctionIdSeqPrefix, "auction_id_sequence"), - LastestAuctionPeriods: collections.NewMap(sb, types.LastestAuctionPeriodPrefix, "lastestAuctionPeriods", collections.StringKey, collections.Int64Value), + LastestAuctionPeriods: collections.NewItem(sb, types.LastestAuctionPeriodPrefix, "lastestAuctionPeriods", collections.Int64Value), BidIdSeq: collections.NewMap(sb, types.BidIdSeqPrefix, "bid_id_sequence", collections.Uint64Key, collections.Uint64Value), Auctions: collections.NewMap(sb, types.AuctionsPrefix, "auctions", collections.Uint64Key, codec.CollValue[types.Auction](cdc)), Bids: collections.NewMap(sb, types.BidsPrefix, "bids", collections.Uint64Key, codec.CollValue[types.BidQueue](cdc)), diff --git a/x/auction/keeper/liquidate.go b/x/auction/keeper/liquidate.go index c3c2a4de..da014f8e 100644 --- a/x/auction/keeper/liquidate.go +++ b/x/auction/keeper/liquidate.go @@ -14,7 +14,7 @@ func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error { params := k.GetParams(ctx) currentTime := sdk.UnwrapSDKContext(ctx).BlockHeader().Time - lastestAuctionPeriod, err := k.LastestAuctionPeriods.Get(ctx, "LastestAuctionPeriods") + lastestAuctionPeriod, err := k.LastestAuctionPeriods.Get(ctx) if err != nil { return err } @@ -22,7 +22,7 @@ func (k Keeper) handleLiquidation(ctx context.Context, mintDenom string) error { // check if has reached the next auction periods if lastAuctionPeriods.Add(params.AuctionPeriods).Before(currentTime) { // update latest auction period - err = k.LastestAuctionPeriods.Set(ctx, "LastestAuctionPeriods", lastAuctionPeriods.Add(params.AuctionPeriods).Unix()) + err = k.LastestAuctionPeriods.Set(ctx, lastAuctionPeriods.Add(params.AuctionPeriods).Unix()) if err != nil { return err } From d82580eb6a6c6a879fd34250c7d7c37124884e05 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Wed, 6 Nov 2024 10:00:31 +0700 Subject: [PATCH 27/42] check vault owner when mint coin --- x/vaults/keeper/vault.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/x/vaults/keeper/vault.go b/x/vaults/keeper/vault.go index e1caec3e..dbf6300e 100644 --- a/x/vaults/keeper/vault.go +++ b/x/vaults/keeper/vault.go @@ -163,6 +163,10 @@ func (k *Keeper) MintCoin( return fmt.Errorf("vault is not actived") } + if sender.String() != vault.Owner { + return fmt.Errorf("sender is not the vault owner") + } + if mint.Denom != vault.Debt.Denom { return fmt.Errorf("mint denom must be %s, got %s", vault.Debt.Denom, mint.Denom) } @@ -243,13 +247,14 @@ func (k *Keeper) RepayDebt( return err } + if sender.String() != vault.Owner { + return fmt.Errorf("sender is not the vault owner") + } + if repay.Denom != vault.Debt.Denom { return fmt.Errorf("repay denom must be %s, got %s", vault.Debt.Denom, repay.Denom) } - if sender.String() != vault.Owner { - return fmt.Errorf("sender is not the vault owner") - } if vault.Status != types.ACTIVE { return fmt.Errorf("vault is not actived") } From da16681e5db740ac75572d416618aaafb23b4943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Wed, 6 Nov 2024 16:55:07 +0700 Subject: [PATCH 28/42] test beginblocker for vaults --- x/vaults/keeper/abci_test.go | 108 +++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 x/vaults/keeper/abci_test.go diff --git a/x/vaults/keeper/abci_test.go b/x/vaults/keeper/abci_test.go new file mode 100644 index 00000000..ff868871 --- /dev/null +++ b/x/vaults/keeper/abci_test.go @@ -0,0 +1,108 @@ +package keeper_test + +import ( + "fmt" + "time" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/onomyprotocol/reserve/x/vaults/types" +) + +func (s *KeeperTestSuite) TestBeginBlock() { + var ( + stabilityFee = math.LegacyMustNewDecFromStr("0.1") //10% + denom = "atom" + maxDebt = math.NewInt(100_000_000_000_000_000) + fund = sdk.NewCoin(denom, math.NewInt(1000000000000)) + collateralAsset = sdk.NewCoin(denom, math.NewInt(100000000000)) + mintedCoin = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(200000000)) + ) + + tests := []struct { + name string + setup func() + expErr bool + expDebt sdk.Coin + expLastUpdateTime time.Time + hasVaults bool + }{ + { + name: "success: one vault", + setup: func() { // 100000000000atom debt 210000000nomUSD(get 200000000nomUSD + 10000000nomUSD MintingFee) + err := s.k.ActiveCollateralAsset(s.Ctx, + denom, math.LegacyMustNewDecFromStr("1.6"), + math.LegacyMustNewDecFromStr("1.5"), + maxDebt, stabilityFee, + types.DefaultMintingFee, + types.DefaultLiquidationPenalty, 1, + ) + s.Require().NoError(err) + + s.FundAccount(s.TestAccs[0], types.ModuleName, sdk.NewCoins(fund)) + err = s.k.CreateNewVault(s.Ctx, s.TestAccs[0], collateralAsset, mintedCoin) + s.Require().NoError(err) + vault, err := s.k.GetVault(s.Ctx, 0) + s.Require().NoError(err) + fmt.Println(vault.Debt) + + p := s.k.GetParams(s.Ctx) + p.ChargingPeriod = time.Second * 15 + err = s.k.SetParams(s.Ctx, p) + s.Require().NoError(err) + err = s.k.LastUpdateTime.Set(s.Ctx, types.LastUpdate{Time: time.Now().Add(-time.Second * 16)}) + s.Require().NoError(err) + }, + expErr: false, + expDebt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(210000010)), // 10% * 15/(60 * 60 * 24 * 365) * 210000000 + 210000000 = 210000010 + expLastUpdateTime: s.Ctx.BlockTime(), + hasVaults: false, + }, + { + name: "success: no vault, LastUpdateTime updates", + setup: func() { // 100000000000atom debt 210000000nomUSD(get 200000000nomUSD + 10000000nomUSD MintingFee) + err := s.k.ActiveCollateralAsset(s.Ctx, + denom, math.LegacyMustNewDecFromStr("1.6"), + math.LegacyMustNewDecFromStr("1.5"), + maxDebt, stabilityFee, + types.DefaultMintingFee, + types.DefaultLiquidationPenalty, 1, + ) + s.Require().NoError(err) + + p := s.k.GetParams(s.Ctx) + p.ChargingPeriod = time.Second * 15 + err = s.k.SetParams(s.Ctx, p) + s.Require().NoError(err) + err = s.k.LastUpdateTime.Set(s.Ctx, types.LastUpdate{Time: time.Now().Add(-time.Second * 16)}) + s.Require().NoError(err) + }, + expErr: false, + expLastUpdateTime: s.Ctx.BlockTime(), + hasVaults: false, + }, + } + + for _, t := range tests { + s.Run(t.name, func() { + s.SetupTest() + t.setup() + err := s.k.BeginBlocker(s.Ctx) + if t.expErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + LastUpdateTime, err := s.k.LastUpdateTime.Get(s.Ctx) + s.Require().NoError(err) + s.Require().Equal(t.expLastUpdateTime, LastUpdateTime.Time) + + if t.hasVaults { + vault, err := s.k.GetVault(s.Ctx, 0) + s.Require().NoError(err) + fmt.Println(vault.Debt) + s.Require().True(vault.Debt.Equal(t.expDebt)) + } + } + }) + } +} From fc5d3e4b3a1412c0e2fb1e8860c90e077d1013f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Thu, 7 Nov 2024 10:49:18 +0700 Subject: [PATCH 29/42] add beginblocker vaults module --- x/vaults/keeper/abci.go | 5 ++++- x/vaults/module/module.go | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/x/vaults/keeper/abci.go b/x/vaults/keeper/abci.go index 56e11cf7..a4edefd2 100644 --- a/x/vaults/keeper/abci.go +++ b/x/vaults/keeper/abci.go @@ -1,11 +1,14 @@ package keeper import ( + "context" + sdk "github.com/cosmos/cosmos-sdk/types" ) // EndBlocker called at every block, update validator set -func (k *Keeper) BeginBlocker(ctx sdk.Context) error { +func (k *Keeper) BeginBlocker(goCtx context.Context) error { + ctx := sdk.UnwrapSDKContext(goCtx) currentTime := ctx.BlockTime() params := k.GetParams(ctx) // TODO: Recalculate debt diff --git a/x/vaults/module/module.go b/x/vaults/module/module.go index 9df83d45..570ad8fa 100644 --- a/x/vaults/module/module.go +++ b/x/vaults/module/module.go @@ -132,8 +132,8 @@ func (a AppModule) RegisterServices(cfg module.Configurator) { types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServerImpl(a.keeper)) } -func (a AppModule) BeginBlock(_ context.Context) error { - return nil +func (a AppModule) BeginBlock(ctx context.Context) error { + return a.keeper.BeginBlocker(ctx) } func (a AppModule) EndBlock(_ sdk.Context) []abci.ValidatorUpdate { From 16835b56d08476a84d3841664dde64f2457cdbe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Thu, 7 Nov 2024 11:22:18 +0700 Subject: [PATCH 30/42] add validate StabilityFee --- x/vaults/types/msgs.go | 8 ++++++++ x/vaults/types/params.go | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/x/vaults/types/msgs.go b/x/vaults/types/msgs.go index 20b3c5a3..0dc5b779 100644 --- a/x/vaults/types/msgs.go +++ b/x/vaults/types/msgs.go @@ -139,6 +139,10 @@ func (msg *MsgActiveCollateral) ValidateBasic() error { return fmt.Errorf("minCollateralRatio cannot be less than 0") } + if msg.StabilityFee.LTE(math.LegacyZeroDec()) { + return fmt.Errorf("StabilityFee cannot be less than 0") + } + if msg.LiquidationPenalty.LT(math.LegacyZeroDec()) { return fmt.Errorf("minCollateralRatio cannot be less than 0") } @@ -174,6 +178,10 @@ func (msg *MsgUpdatesCollateral) ValidateBasic() error { return fmt.Errorf("minCollateralRatio cannot be less than 0") } + if msg.StabilityFee.LTE(math.LegacyZeroDec()) { + return fmt.Errorf("StabilityFee cannot be less than 0") + } + if msg.LiquidationPenalty.LT(math.LegacyZeroDec()) { return fmt.Errorf("minCollateralRatio cannot be less than 0") } diff --git a/x/vaults/types/params.go b/x/vaults/types/params.go index 9292db53..d3336997 100644 --- a/x/vaults/types/params.go +++ b/x/vaults/types/params.go @@ -13,7 +13,6 @@ var ( DefaultLiquidationPenalty = math.LegacyMustNewDecFromStr("0.05") DefaultMinInitialDebt = math.NewInt(50_000_000) DefaultRecalculateDebtPeriod = time.Hour - DefaultLiquidatePeriod = time.Hour DefaultMintDenom = []string{"nomUSD"} KeyMintingFee = []byte("MintingFee") From d19c3039ae1cbb9fde685d21780eaec58122d80c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Thu, 7 Nov 2024 11:29:02 +0700 Subject: [PATCH 31/42] minor --- x/oracle/keeper/band_oracle.go | 116 --------------------------------- x/oracle/module/genesis.go | 1 - 2 files changed, 117 deletions(-) diff --git a/x/oracle/keeper/band_oracle.go b/x/oracle/keeper/band_oracle.go index 50409ed5..a5efc1c4 100644 --- a/x/oracle/keeper/band_oracle.go +++ b/x/oracle/keeper/band_oracle.go @@ -547,119 +547,3 @@ func (k *Keeper) getPreviousRecordIDs(ctx context.Context, clientID uint64) []ui return staleIDs } - -func (k Keeper) SetInitPrice(ctx context.Context) error { - initPrice := []*types.BandPriceState{ - // multiplier = 1000 - { - Symbol: "nomUSD", - Rate: math.NewInt(10000), //1 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), - }, - { - Symbol: "nomEUR", - Rate: math.NewInt(10910), //1.091 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1.091"), time.Now().Unix()), - }, - { - Symbol: "nomJPY", - Rate: math.NewInt(66), //0.0066 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.0066"), time.Now().Unix()), - }, - { - Symbol: "anom", - Rate: math.NewInt(330), //0.03 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.03"), time.Now().Unix()), - }, - { - Symbol: "usdt", - Rate: math.NewInt(10000), //1 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), - }, - { - Symbol: "usdc", - Rate: math.NewInt(10000), //1 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), - }, - { - Symbol: "eurt", - Rate: math.NewInt(10910), //1.091 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1.091"), time.Now().Unix()), - }, - { - Symbol: "jpyt", - Rate: math.NewInt(66), //0.0066 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.0066"), time.Now().Unix()), - }, - { - Symbol: "uatom", - Rate: math.NewInt(80000), //8 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("8"), time.Now().Unix()), - }, - { - Symbol: "uosmo", - Rate: math.NewInt(4500), //0.45 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.45"), time.Now().Unix()), - }, - { - Symbol: "uusdt", - Rate: math.NewInt(10000), //0.45 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), - }, - { - Symbol: "atom", - Rate: math.NewInt(80000), //0.45 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("8"), time.Now().Unix()), - }, - { - Symbol: "ibc/E50A183716AB596378047D9688FE648CD3470C4D196FB4C2C8E61989DB48562E", //transfer/channel-10/transfer/channel-7/transfer/channel-143/erc20/tether/usdt - Rate: math.NewInt(10000), - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), - }, - { - Symbol: "ibc/BE4C72028781730B9DF0542466EB26DEA6DDD42C32316D774F943151F6010320", // transfer/channel-5/usdt - Rate: math.NewInt(10000), - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), - }, - { - Symbol: "ibc/ED07A3391A112B175915CD8FAF43A2DA8E4790EDE12566649D0C2F97716B8518", //transfer/channel-0/uosmo - Rate: math.NewInt(4500), //0.45 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("0.45"), time.Now().Unix()), - }, - { - Symbol: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", //ibc-atom - Rate: math.NewInt(80000), //0.45 - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("8"), time.Now().Unix()), - }, - { - Symbol: "ibc/BC599B88586F8C22E408569D7F6FAD40AEBF808A67D2051B86958CBB5F0A16B0", //usdt - Rate: math.NewInt(10000), - ResolveTime: uint64(time.Now().Unix()), - PriceState: *types.NewPriceState(math.LegacyMustNewDecFromStr("1"), time.Now().Unix()), - }, - } - - for _, i := range initPrice { - err := k.SetBandPriceState(ctx, i.Symbol, i) - if err != nil { - return err - } - } - return nil -} diff --git a/x/oracle/module/genesis.go b/x/oracle/module/genesis.go index 2720ffbb..5148f5fc 100644 --- a/x/oracle/module/genesis.go +++ b/x/oracle/module/genesis.go @@ -21,7 +21,6 @@ func InitGenesis(ctx context.Context, k keeper.Keeper, genState types.GenesisSta sdkCtx.Logger().Info("can not set band price state for symbol %s", bandPriceState.Symbol) } } - // k.SetInitPrice(ctx) for _, bandOracleRequest := range genState.BandOracleRequests { err := k.SetBandOracleRequest(ctx, *bandOracleRequest) From cc1924ab8bc37b150e2e49cb163a6fa9e25e7ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Thu, 7 Nov 2024 15:28:41 +0700 Subject: [PATCH 32/42] minor --- x/auction/keeper/keeper_test.go | 2 +- x/oracle/keeper/band_oracle.go | 2 +- x/vaults/keeper/abci_test.go | 4 +-- x/vaults/keeper/keeper_test.go | 2 +- x/vaults/keeper/vault.go | 10 +++--- x/vaults/keeper/vaults_test.go | 62 ++++++++++++++++----------------- x/vaults/types/params.go | 10 ++---- 7 files changed, 43 insertions(+), 49 deletions(-) diff --git a/x/auction/keeper/keeper_test.go b/x/auction/keeper/keeper_test.go index 5412e6b3..ec3d99c6 100644 --- a/x/auction/keeper/keeper_test.go +++ b/x/auction/keeper/keeper_test.go @@ -28,7 +28,7 @@ func (s *KeeperTestSuite) SetupTest() { mockOracleKeeper := MockOracleKeeper{ prices: make(map[string]math.LegacyDec), } - mockOracleKeeper.SetPrice(s.Ctx, vaultstypes.DefaultMintDenom[0], math.LegacyMustNewDecFromStr("1")) + mockOracleKeeper.SetPrice(s.Ctx, vaultstypes.DefaultMintDenoms[0], math.LegacyMustNewDecFromStr("1")) s.App.AuctionKeeper.OracleKeeper = mockOracleKeeper s.mockOracleKeeper = &mockOracleKeeper diff --git a/x/oracle/keeper/band_oracle.go b/x/oracle/keeper/band_oracle.go index a5efc1c4..1993b94a 100644 --- a/x/oracle/keeper/band_oracle.go +++ b/x/oracle/keeper/band_oracle.go @@ -296,7 +296,7 @@ func (k Keeper) GetPrice(ctx context.Context, base, quote string) *math.LegacyDe return nil } - if quote == types.QuoteUSD || quote == vaultstypes.DefaultMintDenom[0] { + if quote == types.QuoteUSD || quote == vaultstypes.DefaultMintDenoms[0] { return &basePriceState.PriceState.Price } diff --git a/x/vaults/keeper/abci_test.go b/x/vaults/keeper/abci_test.go index ff868871..37b251e2 100644 --- a/x/vaults/keeper/abci_test.go +++ b/x/vaults/keeper/abci_test.go @@ -16,7 +16,7 @@ func (s *KeeperTestSuite) TestBeginBlock() { maxDebt = math.NewInt(100_000_000_000_000_000) fund = sdk.NewCoin(denom, math.NewInt(1000000000000)) collateralAsset = sdk.NewCoin(denom, math.NewInt(100000000000)) - mintedCoin = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(200000000)) + mintedCoin = sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(200000000)) ) tests := []struct { @@ -54,7 +54,7 @@ func (s *KeeperTestSuite) TestBeginBlock() { s.Require().NoError(err) }, expErr: false, - expDebt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(210000010)), // 10% * 15/(60 * 60 * 24 * 365) * 210000000 + 210000000 = 210000010 + expDebt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(210000010)), // 10% * 15/(60 * 60 * 24 * 365) * 210000000 + 210000000 = 210000010 expLastUpdateTime: s.Ctx.BlockTime(), hasVaults: false, }, diff --git a/x/vaults/keeper/keeper_test.go b/x/vaults/keeper/keeper_test.go index 03fc3363..99336fb8 100644 --- a/x/vaults/keeper/keeper_test.go +++ b/x/vaults/keeper/keeper_test.go @@ -25,7 +25,7 @@ func (s *KeeperTestSuite) SetupTest() { mockOK := mock.NewMockOracleKeeper() mockOK.SetPrice("atom", math.LegacyMustNewDecFromStr("8.0")) - mockOK.SetPrice(types.DefaultMintDenom[0], math.LegacyMustNewDecFromStr("1")) + mockOK.SetPrice(types.DefaultMintDenoms[0], math.LegacyMustNewDecFromStr("1")) s.App.VaultsKeeper.OracleKeeper = mockOK s.k = s.App.VaultsKeeper s.msgServer = keeper.NewMsgServerImpl(s.k) diff --git a/x/vaults/keeper/vault.go b/x/vaults/keeper/vault.go index dbf6300e..812a365b 100644 --- a/x/vaults/keeper/vault.go +++ b/x/vaults/keeper/vault.go @@ -31,7 +31,7 @@ func (k *Keeper) CreateNewVault( allowedMintDenoms := k.GetAllowedMintDenoms(ctx) // TODO: Check if mint denom is allowed if !slices.Contains(allowedMintDenoms, mint.Denom) { - return fmt.Errorf("minted denom must in list %s, but got %s", types.DefaultMintDenom, mint.Denom) + return fmt.Errorf("minted denom must in list %s, but got %s", types.DefaultMintDenoms, mint.Denom) } params := k.GetParams(ctx) @@ -45,7 +45,7 @@ func (k *Keeper) CreateNewVault( // Calculate collateral ratio price := k.OracleKeeper.GetPrice(ctx, denom, mint.Denom) if price == nil || price.IsNil() { - return errors.Wrapf(oracletypes.ErrInvalidOracle, "CreateNewVault: can not get price with base %s quote %s", denom, types.DefaultMintDenom) + return errors.Wrapf(oracletypes.ErrInvalidOracle, "CreateNewVault: can not get price with base %s quote %s", denom, types.DefaultMintDenoms) } // TODO: recalculate with denom decimal? collateralValue := math.LegacyNewDecFromInt(collateral.Amount).Mul(*price) @@ -178,7 +178,7 @@ func (k *Keeper) MintCoin( lockedCoin := vault.CollateralLocked price := k.OracleKeeper.GetPrice(ctx, lockedCoin.Denom, mint.Denom) if price == nil || price.IsNil() { - return errors.Wrapf(oracletypes.ErrInvalidOracle, "MintCoin: can not get price with base %s quote %s", lockedCoin.Denom, types.DefaultMintDenom) + return errors.Wrapf(oracletypes.ErrInvalidOracle, "MintCoin: can not get price with base %s quote %s", lockedCoin.Denom, types.DefaultMintDenoms) } lockedValue := math.LegacyNewDecFromInt(lockedCoin.Amount).Mul(*price) @@ -380,7 +380,7 @@ func (k *Keeper) WithdrawFromVault( price := k.OracleKeeper.GetPrice(ctx, collateral.Denom, vault.Debt.Denom) // defensive programming: should never happen since when withdraw should always have a valid oracle price if price == nil || price.IsNil() { - return errors.Wrapf(oracletypes.ErrInvalidOracle, "WithdrawFromVault: can not get price with base %s quote %s", collateral.Denom, types.DefaultMintDenom) + return errors.Wrapf(oracletypes.ErrInvalidOracle, "WithdrawFromVault: can not get price with base %s quote %s", collateral.Denom, types.DefaultMintDenoms) } newLockValue := math.LegacyNewDecFromInt(newLock.Amount).Mul(*price) @@ -487,7 +487,7 @@ func (k *Keeper) GetLiquidations( err := k.VaultsManager.Walk(ctx, nil, func(key string, vm types.VaultMamager) (bool, error) { price := k.OracleKeeper.GetPrice(ctx, vm.Denom, mintDenom) if price == nil || price.IsNil() { - return true, errors.Wrapf(oracletypes.ErrInvalidOracle, "GetLiquidations: can not get price with base %s quote %s", vm.Denom, types.DefaultMintDenom) + return true, errors.Wrapf(oracletypes.ErrInvalidOracle, "GetLiquidations: can not get price with base %s quote %s", vm.Denom, types.DefaultMintDenoms) } prices[vm.Denom] = *price liquidationRatios[vm.Denom] = vm.Params.LiquidationRatio diff --git a/x/vaults/keeper/vaults_test.go b/x/vaults/keeper/vaults_test.go index 07620e61..b7b1074c 100644 --- a/x/vaults/keeper/vaults_test.go +++ b/x/vaults/keeper/vaults_test.go @@ -29,7 +29,7 @@ func (s *KeeperTestSuite) TestCreateNewVault() { s.SetupTest() var ( denom = "atom" - mintDenom = types.DefaultMintDenom[0] + mintDenom = types.DefaultMintDenoms[0] collateral = sdk.NewCoin(denom, math.NewInt(10_000_000)) // 10 atom = 80$ maxDebt = math.NewInt(100_000_000) ) @@ -160,11 +160,11 @@ func (s *KeeperTestSuite) TestRepayDebt() { s.SetupTest() var ( denom = "atom" - repayAsset = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(2000000)) + repayAsset = sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(2000000)) collateralAsset = sdk.NewCoin(denom, math.NewInt(100000000000)) fund = sdk.NewCoin(denom, math.NewInt(1000000000000)) maxDebt = math.NewInt(2000000000) - mintedCoin = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(300000000)) + mintedCoin = sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(300000000)) ) err := s.k.ActiveCollateralAsset(s.Ctx, denom, math.LegacyMustNewDecFromStr("0.1"), math.LegacyMustNewDecFromStr("0.1"), maxDebt, types.DefaultStabilityFee, types.DefaultMintingFee, types.DefaultLiquidationPenalty, 1) s.Require().NoError(err) @@ -236,7 +236,7 @@ func (s *KeeperTestSuite) TestRepayDebt() { Owner: s.TestAccs[0].String(), Id: 0, Status: types.LIQUIDATED, - Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(1000)), + Debt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000)), CollateralLocked: sdk.NewCoin(denom, math.ZeroInt()), }) s.Require().NoError(err) @@ -282,7 +282,7 @@ func (s *KeeperTestSuite) TestDepositToVault() { collateralAsset = sdk.NewCoin(denom, math.NewInt(100000000000)) fund = sdk.NewCoin(denom, math.NewInt(1000000000000)) maxDebt = math.NewInt(2000000000) - mintedCoin = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(200000000)) + mintedCoin = sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(200000000)) ) err := s.k.ActiveCollateralAsset(s.Ctx, denom, math.LegacyMustNewDecFromStr("0.1"), math.LegacyMustNewDecFromStr("0.1"), maxDebt, types.DefaultStabilityFee, types.DefaultMintingFee, types.DefaultLiquidationPenalty, 1) s.Require().NoError(err) @@ -326,7 +326,7 @@ func (s *KeeperTestSuite) TestDepositToVault() { err = s.k.SetVault(s.Ctx, types.Vault{ Id: 0, Status: types.LIQUIDATED, - Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(1000)), + Debt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000)), CollateralLocked: sdk.NewCoin(denom, math.ZeroInt()), }) s.Require().NoError(err) @@ -391,7 +391,7 @@ func (s *KeeperTestSuite) TestWithdrawFromVault() { coinMintToAcc = sdk.NewCoin(denom, math.NewInt(100000000000)) fund = sdk.NewCoin(denom, math.NewInt(10000000000000)) maxDebt = math.NewInt(2000000000) - mintedCoin = sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(200000000)) + mintedCoin = sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(200000000)) ) tests := []struct { @@ -427,7 +427,7 @@ func (s *KeeperTestSuite) TestWithdrawFromVault() { Owner: s.TestAccs[0].String(), Id: 0, Status: types.LIQUIDATED, - Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(1000)), + Debt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000)), CollateralLocked: sdk.NewCoin(denom, math.ZeroInt()), }) s.Require().NoError(err) @@ -534,11 +534,11 @@ func (s *KeeperTestSuite) TestLiquidate() { name: "single vault - sold all, enough to cover debt", liquidation: types.Liquidation{ DebtDenom: "atom", - MintDenom: types.DefaultMintDenom[0], + MintDenom: types.DefaultMintDenoms[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -549,23 +549,23 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 0 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(35_000_000)), + Sold: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(35_000_000)), RemainCollateral: sdk.NewCoin("atom", math.ZeroInt()), }, }, }, expVaultStatus: []types.VaultStatus{types.CLOSED}, - reserveBalances: sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(10_000_000))), + reserveBalances: sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(10_000_000))), }, { name: "single vault - sold all, not enough to cover debt", liquidation: types.Liquidation{ DebtDenom: "atom", - MintDenom: types.DefaultMintDenom[0], + MintDenom: types.DefaultMintDenoms[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -576,23 +576,23 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 0 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(20_000_000)), + Sold: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(20_000_000)), RemainCollateral: sdk.NewCoin("atom", math.ZeroInt()), }, }, }, expVaultStatus: []types.VaultStatus{types.LIQUIDATED}, - shortfallAmount: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(5_000_000)), + shortfallAmount: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(5_000_000)), }, { name: "single vault - remain collateral, enough to cover debt", liquidation: types.Liquidation{ DebtDenom: "atom", - MintDenom: types.DefaultMintDenom[0], + MintDenom: types.DefaultMintDenoms[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -605,14 +605,14 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 1 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(26_000_000)), + Sold: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(26_000_000)), RemainCollateral: sdk.NewCoin("atom", math.NewInt(1_000_000)), }, }, }, expVaultStatus: []types.VaultStatus{types.LIQUIDATED}, reserveBalances: sdk.NewCoins( - sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(1_000_000)), + sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1_000_000)), sdk.NewCoin("atom", math.LegacyNewDec(25_000_000).QuoInt(math.NewInt(7)).Mul(math.LegacyNewDecWithPrec(5, 2)).TruncateInt()), // (25/7)*0.05 ), }, @@ -620,11 +620,11 @@ func (s *KeeperTestSuite) TestLiquidate() { name: "single vault - remain collateral, not enough to cover debt, can reconstitute vault", liquidation: types.Liquidation{ DebtDenom: "atom", - MintDenom: types.DefaultMintDenom[0], + MintDenom: types.DefaultMintDenoms[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -634,7 +634,7 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 5 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.ZeroInt()), + Sold: sdk.NewCoin(types.DefaultMintDenoms[0], math.ZeroInt()), RemainCollateral: sdk.NewCoin("atom", math.NewInt(5_000_000)), }, }, @@ -649,11 +649,11 @@ func (s *KeeperTestSuite) TestLiquidate() { name: "single vault - remain collateral, not enough to cover debt, can reconstitute vault", liquidation: types.Liquidation{ DebtDenom: "atom", - MintDenom: types.DefaultMintDenom[0], + MintDenom: types.DefaultMintDenoms[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -663,7 +663,7 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 5 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.ZeroInt()), + Sold: sdk.NewCoin(types.DefaultMintDenoms[0], math.ZeroInt()), RemainCollateral: sdk.NewCoin("atom", math.NewInt(5_000_000)), }, }, @@ -678,11 +678,11 @@ func (s *KeeperTestSuite) TestLiquidate() { name: "single vault - remain collateral, not enough to cover debt, can not reconstitute vault", liquidation: types.Liquidation{ DebtDenom: "atom", - MintDenom: types.DefaultMintDenom[0], + MintDenom: types.DefaultMintDenoms[0], LiquidatingVaults: []*types.Vault{ { Owner: vaultOwnerAddr.String(), - Debt: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(25_000_000)), + Debt: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(25_000_000)), CollateralLocked: sdk.NewCoin("atom", math.NewInt(5_000_000)), // lock 5 ATOM at price 8, ratio = 160% Status: types.LIQUIDATING, LiquidationPrice: math.LegacyNewDecWithPrec(7, 0), // liquidate at price 7, ratio = 140% @@ -693,7 +693,7 @@ func (s *KeeperTestSuite) TestLiquidate() { // Remain collateral = 4 VaultLiquidationStatus: map[uint64]*types.VaultLiquidationStatus{ 0: { - Sold: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(7_000_000)), + Sold: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(7_000_000)), RemainCollateral: sdk.NewCoin("atom", math.NewInt(4_000_000)), }, }, @@ -703,7 +703,7 @@ func (s *KeeperTestSuite) TestLiquidate() { // penalty sdk.NewCoin("atom", math.NewInt(4_000_000)), // (25/7)*0.05 ), - shortfallAmount: sdk.NewCoin(types.DefaultMintDenom[0], math.NewInt(18_000_000)), + shortfallAmount: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(18_000_000)), }, } for _, t := range tests { @@ -733,7 +733,7 @@ func (s *KeeperTestSuite) TestLiquidate() { s.Require().NoError(err) } - err = s.App.VaultsKeeper.Liquidate(s.Ctx, t.liquidation, types.DefaultMintDenom[0]) + err = s.App.VaultsKeeper.Liquidate(s.Ctx, t.liquidation, types.DefaultMintDenoms[0]) s.Require().NoError(err) if t.reserveBalances != nil { diff --git a/x/vaults/types/params.go b/x/vaults/types/params.go index d3336997..79090656 100644 --- a/x/vaults/types/params.go +++ b/x/vaults/types/params.go @@ -13,13 +13,7 @@ var ( DefaultLiquidationPenalty = math.LegacyMustNewDecFromStr("0.05") DefaultMinInitialDebt = math.NewInt(50_000_000) DefaultRecalculateDebtPeriod = time.Hour - DefaultMintDenom = []string{"nomUSD"} - - KeyMintingFee = []byte("MintingFee") - KeyStabilityFee = []byte("StabilityFee") - KeyLiquidationPenalty = []byte("LiquidationPenalty") - KeyMinInitialDebt = []byte("MinInitialDebt") - KeyRecalculateDebtPeriod = []byte("RecalculateDebtPeriod") + DefaultMintDenoms = []string{"nomUSD", "nomEUR", "nomJPY"} ) // NewParams creates a new Params instance. @@ -39,7 +33,7 @@ func NewParams( func DefaultParams() Params { return NewParams( DefaultMinInitialDebt, - DefaultMintDenom, + DefaultMintDenoms, DefaultRecalculateDebtPeriod, ) } From efff47573e273dbeaff2a0723051305cc696c30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Fri, 8 Nov 2024 12:34:19 +0700 Subject: [PATCH 33/42] check status --- x/vaults/keeper/vault.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/x/vaults/keeper/vault.go b/x/vaults/keeper/vault.go index b2e8a657..990791ad 100644 --- a/x/vaults/keeper/vault.go +++ b/x/vaults/keeper/vault.go @@ -128,6 +128,10 @@ func (k *Keeper) CloseVault( return fmt.Errorf("sender is not the vault owner") } + if !isStatusGood(vault) { + return fmt.Errorf("vault is not actived") + } + // User have to pay all the debt to close the vault if vault.Debt.Amount.GT(math.ZeroInt()) { err := k.BankKeeper.SendCoins(ctx, sdk.MustAccAddressFromBech32(vault.Owner), sdk.MustAccAddressFromBech32(vault.Address), sdk.NewCoins(vault.Debt)) @@ -355,7 +359,7 @@ func (k *Keeper) WithdrawFromVault( if err != nil { return err } - if vault.Status != types.ACTIVE { + if !isStatusGood(vault) { return fmt.Errorf("vault is not actived") } @@ -829,3 +833,17 @@ func (k *Keeper) GetVaultIdAndAddress( return id, address } + +func isStatusGood(vault types.Vault) bool { + if vault.Status == types.ACTIVE { + return true + } + if vault.Status == types.LIQUIDATED { + if vault.Debt.Amount.GT(math.ZeroInt()) { + return true + } else { + return false + } + } + return false +} From b0489101b19f65b8b030acb63adee1ca79a4ed90 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 8 Nov 2024 14:58:56 +0700 Subject: [PATCH 34/42] refactor swap msg --- proto/reserve/psm/v1/genesis.proto | 2 +- proto/reserve/psm/v1/psm.proto | 4 +- proto/reserve/psm/v1/query.proto | 4 +- proto/reserve/psm/v1/tx.proto | 39 +- x/psm/client/cli/tx.go | 46 +- x/psm/keeper/abci.go | 12 +- x/psm/keeper/abci_test.go | 5 +- x/psm/keeper/keeper.go | 26 +- x/psm/keeper/msg_server.go | 140 +--- x/psm/keeper/msg_server_test.go | 323 ++++---- x/psm/keeper/proposals_test.go | 9 +- x/psm/keeper/query.go | 6 +- x/psm/keeper/query_test.go | 4 +- x/psm/keeper/stablecoin.go | 14 +- x/psm/keeper/stablecoin_test.go | 14 +- x/psm/keeper/swap.go | 88 ++- x/psm/keeper/swap_test.go | 316 ++++---- x/psm/module/genesis.go | 4 +- x/psm/types/codec.go | 4 +- x/psm/types/genesis.go | 4 +- x/psm/types/genesis.pb.go | 32 +- x/psm/types/keys.go | 6 + x/psm/types/msgs.go | 67 +- x/psm/types/psm.go | 6 +- x/psm/types/psm.pb.go | 151 ++-- x/psm/types/query.pb.go | 87 +- x/psm/types/tx.pb.go | 1188 +++++++++------------------- 27 files changed, 929 insertions(+), 1672 deletions(-) diff --git a/proto/reserve/psm/v1/genesis.proto b/proto/reserve/psm/v1/genesis.proto index 44104e8d..32f514dd 100644 --- a/proto/reserve/psm/v1/genesis.proto +++ b/proto/reserve/psm/v1/genesis.proto @@ -16,7 +16,7 @@ message GenesisState { (amino.dont_omitempty) = true ]; - repeated Stablecoin stablecoins = 2 + repeated StablecoinInfo stablecoins = 2 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; repeated string noms = 3 diff --git a/proto/reserve/psm/v1/psm.proto b/proto/reserve/psm/v1/psm.proto index 1c14eca2..896eaad0 100644 --- a/proto/reserve/psm/v1/psm.proto +++ b/proto/reserve/psm/v1/psm.proto @@ -8,7 +8,7 @@ import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/onomyprotocol/reserve/x/psm/types"; -message Stablecoin { +message StablecoinInfo { // stablecoin name string denom = 1; // limit total stablecoin @@ -43,6 +43,4 @@ message Stablecoin { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - // type nom which swaps at a 1:1 ratio, as nomUSD ~ 1 USDT - string nom_type = 7; } diff --git a/proto/reserve/psm/v1/query.proto b/proto/reserve/psm/v1/query.proto index b34e261a..7bc5e1dc 100644 --- a/proto/reserve/psm/v1/query.proto +++ b/proto/reserve/psm/v1/query.proto @@ -45,7 +45,7 @@ message QueryStablecoinRequest { } message QueryStablecoinResponse { - Stablecoin stablecoin = 1 [(gogoproto.nullable) = false]; + StablecoinInfo stablecoin = 1 [(gogoproto.nullable) = false]; bytes swapable_quantity = 3 [ (cosmos_proto.scalar) = "cosmos.Int", @@ -63,7 +63,7 @@ message QueryAllStablecoinResponse { } message StablecoinResponse { - Stablecoin stablecoin = 1 [(gogoproto.nullable) = false]; + StablecoinInfo stablecoin = 1 [(gogoproto.nullable) = false]; bytes swapable_quantity = 3 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "cosmossdk.io/math.Int", diff --git a/proto/reserve/psm/v1/tx.proto b/proto/reserve/psm/v1/tx.proto index 67535b20..d822ff2c 100644 --- a/proto/reserve/psm/v1/tx.proto +++ b/proto/reserve/psm/v1/tx.proto @@ -19,8 +19,7 @@ service Msg { rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); rpc AddStableCoinProposal(MsgAddStableCoin) returns (MsgAddStableCoinResponse); rpc UpdatesStableCoinProposal(MsgUpdatesStableCoin) returns (MsgUpdatesStableCoinResponse); - rpc SwapToNom(MsgSwapToNom) returns (MsgSwapToNomResponse); - rpc SwapToStablecoin(MsgSwapToStablecoin) returns (MsgSwapToStablecoinResponse); + rpc StableSwap(MsgStableSwap) returns (MsgStableSwapResponse); } // MsgUpdateParams is the Msg/UpdateParams request type. @@ -44,24 +43,6 @@ message MsgUpdateParams { // MsgUpdateParams message. message MsgUpdateParamsResponse {} -message MsgSwapToNom { - option (cosmos.msg.v1.signer) = "address"; - - string address = 1; - cosmos.base.v1beta1.Coin coin = 2 - [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; -} -message MsgSwapToNomResponse {} - -message MsgSwapToStablecoin { - option (cosmos.msg.v1.signer) = "address"; - - string address = 1; - string to_denom = 2; - cosmos.base.v1beta1.Coin coin = 3 - [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; -} -message MsgSwapToStablecoinResponse {} message MsgAddStableCoin { option (cosmos.msg.v1.signer) = "authority"; @@ -88,7 +69,6 @@ message MsgAddStableCoin { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - string nom_type = 6; } message MsgAddStableCoinResponse {} @@ -118,7 +98,20 @@ message MsgUpdatesStableCoin { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; - string nom_type = 6; } -message MsgUpdatesStableCoinResponse {} \ No newline at end of file +message MsgUpdatesStableCoinResponse {} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgStableSwap message. + +message MsgStableSwap { + option (cosmos.msg.v1.signer) = "address"; + + string address = 1; + string expected_denom = 2; + cosmos.base.v1beta1.Coin offer_coin = 3 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; + +} +message MsgStableSwapResponse {} diff --git a/x/psm/client/cli/tx.go b/x/psm/client/cli/tx.go index 7ab48018..61f16465 100644 --- a/x/psm/client/cli/tx.go +++ b/x/psm/client/cli/tx.go @@ -21,7 +21,6 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand(NewSwapToStablecoinCmd()) cmd.AddCommand(NewSwapToNomCmd()) return cmd @@ -29,13 +28,13 @@ func GetTxCmd() *cobra.Command { func NewSwapToNomCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "swap-to-nom [stablecoin]", + Use: "swap [offer_stable_coin] [expected_denom]", Args: cobra.ExactArgs(1), - Short: "swap stablecoin to $nomUSD ", - Long: `swap stablecoin to $nomUSD. + Short: "stable swap ", + Long: `swap between stable coins. Example: - $ onomyd tx psm swap-to-nom 100000000000000000000000usdt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake + $ onomyd tx psm swap 100000000000000000000000usdt ibc/xxxxx --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake `, @@ -44,46 +43,13 @@ func NewSwapToNomCmd() *cobra.Command { if err != nil { return err } - stablecoin, err := sdk.ParseCoinNormalized(args[0]) + offerCoin, err := sdk.ParseCoinNormalized(args[0]) if err != nil { return err } addr := clientCtx.GetFromAddress() - msg := types.NewMsgSwapToNom(addr.String(), stablecoin) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} - -func NewSwapToStablecoinCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "swap-to-stablecoin [stable-coin-type] [amount-nomX]", - Args: cobra.ExactArgs(2), - Short: "swap $nomX to stablecoin. ", - Long: `swap $nomX to stablecoin. - - Example: - $ onomyd tx psm swap-to-stablecoin usdc 10000nomUSD --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake - `, - - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - nomUSDcoin, err := sdk.ParseCoinNormalized(args[1]) - if err != nil { - return err - } - - addr := clientCtx.GetFromAddress() - msg := types.NewMsgSwapToStablecoin(addr.String(), args[0], nomUSDcoin) + msg := types.NewMsgStableSwap(addr.String(), offerCoin, args[1]) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, diff --git a/x/psm/keeper/abci.go b/x/psm/keeper/abci.go index d7f248de..0c39eede 100644 --- a/x/psm/keeper/abci.go +++ b/x/psm/keeper/abci.go @@ -12,21 +12,21 @@ func (k Keeper) BeginBlocker(ctx context.Context) error { } func (k Keeper) UpdatesStablecoinEpoch(ctx context.Context) error { - updatePrice := func(red types.Stablecoin) bool { - price := k.OracleKeeper.GetPrice(ctx, red.Denom, red.NomType) + updatePrice := func(info types.StablecoinInfo) bool { + price := k.OracleKeeper.GetPrice(ctx, info.Denom, "USD") if price == nil || price.IsNil() { return false } - sc := k.stablecoinUpdate(ctx, *price, red) - err := k.Stablecoins.Set(ctx, sc.Denom, sc) + sc := k.stablecoinUpdate(ctx, *price, info) + err := k.StablecoinInfo.Set(ctx, sc.Denom, sc) if err != nil { return false } return false } - return k.Stablecoins.Walk(ctx, nil, func(key string, value types.Stablecoin) (stop bool, err error) { + return k.StablecoinInfo.Walk(ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { return updatePrice(value), nil }) //k.IterateStablecoin(ctx, updatePrice) } @@ -56,7 +56,7 @@ func (k Keeper) UpdatesStablecoinEpoch(ctx context.Context) error { // newfeeOut = 0.02 - 0.014948314143157351 = 0.005051685856842649 // So $nomUSD swap to $USDT will be cheaper than $USDT swap to $nomUSD -func (k Keeper) stablecoinUpdate(ctx context.Context, newPrice math.LegacyDec, stablecoin types.Stablecoin) types.Stablecoin { +func (k Keeper) stablecoinUpdate(ctx context.Context, newPrice math.LegacyDec, stablecoin types.StablecoinInfo) types.StablecoinInfo { params, err := k.GetParams(ctx) if err != nil { panic(err) diff --git a/x/psm/keeper/abci_test.go b/x/psm/keeper/abci_test.go index 95bb17be..c35ff4a8 100644 --- a/x/psm/keeper/abci_test.go +++ b/x/psm/keeper/abci_test.go @@ -45,10 +45,9 @@ func (s *KeeperTestSuite) TestUpdatesStablecoinEpoch() { LimitTotal: limitUSDT, FeeIn: t.feeIn, FeeOut: t.feeOut, - NomType: "nomUSD", }) s.mockOracleKeeper.SetPrice(s.Ctx, sc.Denom, t.priceCurrent) - err := s.k.Stablecoins.Set(s.Ctx, sc.Denom, sc) + err := s.k.StablecoinInfo.Set(s.Ctx, sc.Denom, sc) s.Require().NoError(err) s.mockOracleKeeper.SetPrice(s.Ctx, usdt, t.priceUpdate) @@ -56,7 +55,7 @@ func (s *KeeperTestSuite) TestUpdatesStablecoinEpoch() { err = s.k.UpdatesStablecoinEpoch(s.Ctx) s.Require().NoError(err) - scUpdate, err := s.k.Stablecoins.Get(s.Ctx, usdt) + scUpdate, err := s.k.StablecoinInfo.Get(s.Ctx, usdt) s.Require().NoError(err) // s.Require().Equal(t.priceUpdate, scUpdate.Price) s.Require().Equal(t.expectFeeIn.String(), scUpdate.FeeIn.String()) diff --git a/x/psm/keeper/keeper.go b/x/psm/keeper/keeper.go index 4a5944e6..5dcf8b7b 100644 --- a/x/psm/keeper/keeper.go +++ b/x/psm/keeper/keeper.go @@ -36,8 +36,8 @@ type ( AccountKeeper types.AccountKeeper OracleKeeper types.OracleKeeper - Stablecoins collections.Map[string, types.Stablecoin] - Noms collections.Map[string, string] + StablecoinInfo collections.Map[string, types.StablecoinInfo] + Noms collections.Map[string, string] } ) @@ -65,12 +65,12 @@ func NewKeeper( authority: authority, // logger: logger, - BankKeeper: bankKeeper, - AccountKeeper: accountKeeper, - OracleKeeper: oracleKeeper, - Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), - Stablecoins: collections.NewMap(sb, types.KeyStableCoin, "stablecoins", collections.StringKey, codec.CollValue[types.Stablecoin](cdc)), - Noms: collections.NewMap(sb, types.KeyNoms, "nomtypes", collections.StringKey, collections.StringValue), + BankKeeper: bankKeeper, + AccountKeeper: accountKeeper, + OracleKeeper: oracleKeeper, + Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), + StablecoinInfo: collections.NewMap(sb, types.KeyStableCoin, "stablecoins", collections.StringKey, codec.CollValue[types.StablecoinInfo](cdc)), + Noms: collections.NewMap(sb, types.KeyNoms, "nomtypes", collections.StringKey, collections.StringValue), } schema, err := sb.Build() @@ -93,7 +93,7 @@ func (k Keeper) Logger() log.Logger { } func (k Keeper) TotalStablecoinLock(ctx context.Context, nameStablecoin string) (math.Int, error) { - sc, err := k.Stablecoins.Get(ctx, nameStablecoin) + sc, err := k.StablecoinInfo.Get(ctx, nameStablecoin) if err != nil { return math.Int{}, fmt.Errorf("canot found stablecoin name %s", nameStablecoin) } @@ -102,7 +102,7 @@ func (k Keeper) TotalStablecoinLock(ctx context.Context, nameStablecoin string) } func (k Keeper) AddTotalStablecoinLock(ctx context.Context, amountAdd sdk.Coin) error { - sc, err := k.Stablecoins.Get(ctx, amountAdd.Denom) + sc, err := k.StablecoinInfo.Get(ctx, amountAdd.Denom) if err != nil { return fmt.Errorf("canot found stablecoin name %s", amountAdd.Denom) } @@ -112,11 +112,11 @@ func (k Keeper) AddTotalStablecoinLock(ctx context.Context, amountAdd sdk.Coin) return fmt.Errorf("exceed limitTotal stablecoin %s", amountAdd.Denom) } - return k.Stablecoins.Set(ctx, sc.Denom, sc) + return k.StablecoinInfo.Set(ctx, sc.Denom, sc) } func (k Keeper) SubTotalStablecoinLock(ctx context.Context, amountSub sdk.Coin) error { - sc, err := k.Stablecoins.Get(ctx, amountSub.Denom) + sc, err := k.StablecoinInfo.Get(ctx, amountSub.Denom) if err != nil { return fmt.Errorf("canot found stablecoin name %s", amountSub.Denom) } @@ -125,5 +125,5 @@ func (k Keeper) SubTotalStablecoinLock(ctx context.Context, amountSub sdk.Coin) if sc.TotalStablecoinLock.LT(math.ZeroInt()) { return fmt.Errorf("not enough stablecoins %s to pay", amountSub.Denom) } - return k.Stablecoins.Set(ctx, sc.Denom, sc) + return k.StablecoinInfo.Set(ctx, sc.Denom, sc) } diff --git a/x/psm/keeper/msg_server.go b/x/psm/keeper/msg_server.go index a96bb664..276f0d10 100644 --- a/x/psm/keeper/msg_server.go +++ b/x/psm/keeper/msg_server.go @@ -3,6 +3,7 @@ package keeper import ( "context" "fmt" + "strings" errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" @@ -43,137 +44,34 @@ func (k msgServer) UpdateParams(ctx context.Context, req *types.MsgUpdateParams) return &types.MsgUpdateParamsResponse{}, nil } -func (k msgServer) SwapToNom(ctx context.Context, msg *types.MsgSwapToNom) (*types.MsgSwapToNomResponse, error) { +func (k msgServer) StableSwap(ctx context.Context, msg *types.MsgStableSwap) (_ *types.MsgStableSwapResponse, err error) { // validate msg - if err := msg.ValidateBasic(); err != nil { + if err = msg.ValidateBasic(); err != nil { return nil, err } - // check stablecoin is suport - stablecoin, err := k.keeper.Stablecoins.Get(ctx, msg.Coin.Denom) - if err != nil { - return nil, fmt.Errorf("%s not in list stablecoin supported", msg.Coin.Denom) - } - - // check limit swap - err = k.keeper.checkLimitTotalStablecoin(ctx, msg.Coin.Denom, msg.Coin.Amount) - if err != nil { - return nil, err - } + // balance check - // check balance user and calculate amount of coins received - addr := sdk.MustAccAddressFromBech32(msg.Address) - receiveAmountnomUSD, fee_in, err := k.keeper.SwapTonomUSD(ctx, addr, msg.Coin) - if err != nil { - return nil, err + asset := k.keeper.BankKeeper.GetBalance(ctx, sdk.AccAddress(msg.Address), msg.OfferCoin.Denom) + if asset.Amount.LT(msg.OfferCoin.Amount) { + return nil, fmt.Errorf("insufficient balance") } - // add total stablecoin lock - err = k.keeper.AddTotalStablecoinLock(ctx, msg.Coin) + accAddress, err := sdk.AccAddressFromBech32(msg.Address) if err != nil { return nil, err } - - // send stablecoin to module - err = k.keeper.BankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, sdk.NewCoins(msg.Coin)) - if err != nil { - return nil, err + if strings.Contains(msg.OfferCoin.Denom, types.ReserveStableCoinDenomPrefix) { + err = k.keeper.SwapToOtherStablecoin(ctx, accAddress, msg.OfferCoin, msg.ExpectedDenom) + } else { + err = k.keeper.SwapToOnomyStableToken(ctx, accAddress, msg.OfferCoin, msg.ExpectedDenom) } - // mint nomUSD - coinsMint := sdk.NewCoins(sdk.NewCoin(stablecoin.NomType, receiveAmountnomUSD)) - err = k.keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) - if err != nil { - return nil, err - } - // send to user - err = k.keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, coinsMint) if err != nil { return nil, err } - // event - sdkCtx := sdk.UnwrapSDKContext(ctx) - sdkCtx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventSwapTonomUSD, - sdk.NewAttribute(types.AttributeAmount, msg.Coin.String()), - sdk.NewAttribute(types.AttributeReceive, coinsMint.String()), - sdk.NewAttribute(types.AttributeFeeIn, fee_in.String()), - ), - ) - return &types.MsgSwapToNomResponse{}, nil -} - -func (k msgServer) SwapToStablecoin(ctx context.Context, msg *types.MsgSwapToStablecoin) (*types.MsgSwapToStablecoinResponse, error) { - // validate basic - if err := msg.ValidateBasic(); err != nil { - return nil, err - } - - // check stablecoin is suport - stablecoin, err := k.keeper.Stablecoins.Get(ctx, msg.ToDenom) - if err != nil { - return nil, fmt.Errorf("%s not in list stablecoin supported", msg.ToDenom) - } - - if stablecoin.NomType != msg.Coin.Denom { - return nil, fmt.Errorf("can't exchange %s for %s, not same type", msg.Coin.Denom, msg.ToDenom) - } - - // check lock Coin of user - totalStablecoinLock, err := k.keeper.TotalStablecoinLock(ctx, msg.ToDenom) - if err != nil { - return nil, err - } - - // check balace and calculate amount of coins received - addr := sdk.MustAccAddressFromBech32(msg.Address) - receiveAmountStablecoin, fee_out, err := k.keeper.SwapToStablecoin(ctx, addr, msg.Coin.Amount, msg.ToDenom) - if err != nil { - return nil, err - } - - // locked stablecoin is greater than the amount desired - if totalStablecoinLock.LT(receiveAmountStablecoin) { - return nil, fmt.Errorf("amount %s locked lesser than amount desired", msg.ToDenom) - } - - // burn nomUSD - coinsBurn := sdk.NewCoins(msg.Coin) - err = k.keeper.BankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, coinsBurn) - if err != nil { - return nil, err - } - err = k.keeper.BankKeeper.BurnCoins(ctx, types.ModuleName, coinsBurn) - if err != nil { - return nil, err - } - - stablecoinReceive := sdk.NewCoin(msg.ToDenom, receiveAmountStablecoin) - - // sub total stablecoin lock - err = k.keeper.SubTotalStablecoinLock(ctx, stablecoinReceive) - if err != nil { - return nil, err - } - // send stablecoin to user - err = k.keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, sdk.NewCoins(stablecoinReceive)) - if err != nil { - return nil, err - } - - // event - sdkCtx := sdk.UnwrapSDKContext(ctx) - sdkCtx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventSwapToStablecoin, - sdk.NewAttribute(types.AttributeAmount, msg.Coin.String()), - sdk.NewAttribute(types.AttributeReceive, stablecoinReceive.String()), - sdk.NewAttribute(types.AttributeFeeOut, fee_out.String()), - ), - ) - return &types.MsgSwapToStablecoinResponse{}, nil + return &types.MsgStableSwapResponse{}, nil } func (k msgServer) AddStableCoinProposal(ctx context.Context, msg *types.MsgAddStableCoin) (*types.MsgAddStableCoinResponse, error) { @@ -186,16 +84,12 @@ func (k msgServer) AddStableCoinProposal(ctx context.Context, msg *types.MsgAddS return &types.MsgAddStableCoinResponse{}, err } - // if msg. { - - // } - - _, err := k.keeper.Stablecoins.Get(ctx, msg.Denom) + _, err := k.keeper.StablecoinInfo.Get(ctx, msg.Denom) if err == nil { return &types.MsgAddStableCoinResponse{}, fmt.Errorf("%s has existed", msg.Denom) } - err = k.keeper.Stablecoins.Set(ctx, msg.Denom, types.GetMsgStablecoin(msg)) + err = k.keeper.StablecoinInfo.Set(ctx, msg.Denom, types.GetMsgStablecoin(msg)) if err != nil { return &types.MsgAddStableCoinResponse{}, err } @@ -224,7 +118,7 @@ func (k msgServer) UpdatesStableCoinProposal(ctx context.Context, msg *types.Msg return &types.MsgUpdatesStableCoinResponse{}, err } - oldStablecoin, err := k.keeper.Stablecoins.Get(ctx, msg.Denom) + oldStablecoin, err := k.keeper.StablecoinInfo.Get(ctx, msg.Denom) if err != nil { return &types.MsgUpdatesStableCoinResponse{}, fmt.Errorf("%s not existed", msg.Denom) } @@ -232,7 +126,7 @@ func (k msgServer) UpdatesStableCoinProposal(ctx context.Context, msg *types.Msg newStablecoin := types.GetMsgStablecoin(msg) newStablecoin.TotalStablecoinLock = oldStablecoin.TotalStablecoinLock - err = k.keeper.Stablecoins.Set(ctx, newStablecoin.Denom, newStablecoin) + err = k.keeper.StablecoinInfo.Set(ctx, newStablecoin.Denom, newStablecoin) if err != nil { return &types.MsgUpdatesStableCoinResponse{}, err } diff --git a/x/psm/keeper/msg_server_test.go b/x/psm/keeper/msg_server_test.go index f0df048b..a22c06c5 100644 --- a/x/psm/keeper/msg_server_test.go +++ b/x/psm/keeper/msg_server_test.go @@ -1,169 +1,158 @@ package keeper_test -import ( - "context" - // "fmt" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/onomyprotocol/reserve/x/psm/keeper" - "github.com/onomyprotocol/reserve/x/psm/types" -) - -func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { - s.SetupTest() - - tests := []struct { - name string - addr sdk.AccAddress - setup func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom - - expectPass bool - expectedReceive math.Int - }{ - { - name: "success", - addr: s.TestAccs[0], - setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom { - coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) - err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) - s.Require().NoError(err) - err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) - s.Require().NoError(err) - - _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Denom: usdt, - LimitTotal: limitUSDT, - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", - }) - s.Require().NoError(err) - - amountSwap := sdk.NewCoin(usdt, math.NewInt(1000)) - return &types.MsgSwapToNom{ - Address: s.TestAccs[0].String(), - Coin: amountSwap, - } - }, - - expectPass: true, - expectedReceive: math.NewInt(999), - }, - { - name: "insufficient balance", - addr: s.TestAccs[1], - setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom { - _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Denom: usdc, - LimitTotal: limitUSDC, - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", - }) - s.Require().NoError(err) - - amountSwap := sdk.NewCoin(usdc, math.NewInt(1000)) - return &types.MsgSwapToNom{ - Address: s.TestAccs[1].String(), - Coin: amountSwap, - } - }, - - expectPass: false, - expectedReceive: math.NewInt(999), - }, - } - - for _, t := range tests { - s.Run(t.name, func() { - msg := t.setup(s.Ctx, s.k) - - _, err := s.msgServer.SwapToNom(s.Ctx, msg) - if t.expectPass { - s.Require().NoError(err) - balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenoms[0]) - s.Require().Equal(t.expectedReceive, balance.Amount) - - } else { - s.Require().Error(err) - } - - }) - } -} - -func (s *KeeperTestSuite) TestMsgSwapToStablecoin() { - s.SetupTest() - - tests := []struct { - name string - addr sdk.AccAddress - setup func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToStablecoin - - expectPass bool - expectedBalancenomUSD math.Int - }{ - { - name: "success", - addr: s.TestAccs[0], - setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToStablecoin { - // swaptonomUSD - coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) - err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) - s.Require().NoError(err) - err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) - s.Require().NoError(err) - - _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Denom: usdt, - LimitTotal: limitUSDT, - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", - }) - s.Require().NoError(err) - - amountSwap := sdk.NewCoin(usdt, math.NewInt(1001)) - msg := &types.MsgSwapToNom{ - Address: s.TestAccs[0].String(), - Coin: amountSwap, - } - _, err = s.msgServer.SwapToNom(s.Ctx, msg) - s.Require().NoError(err) - - return &types.MsgSwapToStablecoin{ - Address: s.TestAccs[0].String(), - ToDenom: usdt, - Coin: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000)), - } - }, - - expectPass: true, - expectedBalancenomUSD: math.NewInt(0), - }, - } - - for _, t := range tests { - s.Run(t.name, func() { - msg := t.setup(s.Ctx, s.k) - - _, err := s.msgServer.SwapToStablecoin(s.Ctx, msg) - if t.expectPass { - s.Require().NoError(err) - balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenoms[0]) - s.Require().Equal(t.expectedBalancenomUSD.String(), balance.Amount.String()) - - } else { - s.Require().Error(err) - } - - }) - } -} +// "fmt" + +// func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { +// s.SetupTest() + +// tests := []struct { +// name string +// addr sdk.AccAddress +// setup func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom + +// expectPass bool +// expectedReceive math.Int +// }{ +// { +// name: "success", +// addr: s.TestAccs[0], +// setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom { +// coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) +// err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) +// s.Require().NoError(err) +// err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) +// s.Require().NoError(err) + +// _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ +// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), +// Denom: usdt, +// LimitTotal: limitUSDT, +// FeeIn: math.LegacyMustNewDecFromStr("0.001"), +// FeeOut: math.LegacyMustNewDecFromStr("0.001"), +// NomType: "nomUSD", +// }) +// s.Require().NoError(err) + +// amountSwap := sdk.NewCoin(usdt, math.NewInt(1000)) +// return &types.MsgSwapToNom{ +// Address: s.TestAccs[0].String(), +// Coin: amountSwap, +// } +// }, + +// expectPass: true, +// expectedReceive: math.NewInt(999), +// }, +// { +// name: "insufficient balance", +// addr: s.TestAccs[1], +// setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom { +// _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ +// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), +// Denom: usdc, +// LimitTotal: limitUSDC, +// FeeIn: math.LegacyMustNewDecFromStr("0.001"), +// FeeOut: math.LegacyMustNewDecFromStr("0.001"), +// NomType: "nomUSD", +// }) +// s.Require().NoError(err) + +// amountSwap := sdk.NewCoin(usdc, math.NewInt(1000)) +// return &types.MsgSwapToNom{ +// Address: s.TestAccs[1].String(), +// Coin: amountSwap, +// } +// }, + +// expectPass: false, +// expectedReceive: math.NewInt(999), +// }, +// } + +// for _, t := range tests { +// s.Run(t.name, func() { +// msg := t.setup(s.Ctx, s.k) + +// _, err := s.msgServer.SwapToNom(s.Ctx, msg) +// if t.expectPass { +// s.Require().NoError(err) +// balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenoms[0]) +// s.Require().Equal(t.expectedReceive, balance.Amount) + +// } else { +// s.Require().Error(err) +// } + +// }) +// } +// } + +// func (s *KeeperTestSuite) TestMsgSwapToStablecoin() { +// s.SetupTest() + +// tests := []struct { +// name string +// addr sdk.AccAddress +// setup func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToStablecoin + +// expectPass bool +// expectedBalancenomUSD math.Int +// }{ +// { +// name: "success", +// addr: s.TestAccs[0], +// setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToStablecoin { +// // swaptonomUSD +// coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) +// err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) +// s.Require().NoError(err) +// err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) +// s.Require().NoError(err) + +// _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ +// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), +// Denom: usdt, +// LimitTotal: limitUSDT, +// FeeIn: math.LegacyMustNewDecFromStr("0.001"), +// FeeOut: math.LegacyMustNewDecFromStr("0.001"), +// NomType: "nomUSD", +// }) +// s.Require().NoError(err) + +// amountSwap := sdk.NewCoin(usdt, math.NewInt(1001)) +// msg := &types.MsgSwapToNom{ +// Address: s.TestAccs[0].String(), +// Coin: amountSwap, +// } +// _, err = s.msgServer.SwapToNom(s.Ctx, msg) +// s.Require().NoError(err) + +// return &types.MsgSwapToStablecoin{ +// Address: s.TestAccs[0].String(), +// ToDenom: usdt, +// Coin: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000)), +// } +// }, + +// expectPass: true, +// expectedBalancenomUSD: math.NewInt(0), +// }, +// } + +// for _, t := range tests { +// s.Run(t.name, func() { +// msg := t.setup(s.Ctx, s.k) + +// _, err := s.msgServer.SwapToStablecoin(s.Ctx, msg) +// if t.expectPass { +// s.Require().NoError(err) +// balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenoms[0]) +// s.Require().Equal(t.expectedBalancenomUSD.String(), balance.Amount.String()) + +// } else { +// s.Require().Error(err) +// } + +// }) +// } +// } diff --git a/x/psm/keeper/proposals_test.go b/x/psm/keeper/proposals_test.go index 65930900..86728399 100644 --- a/x/psm/keeper/proposals_test.go +++ b/x/psm/keeper/proposals_test.go @@ -16,13 +16,12 @@ func (s *KeeperTestSuite) TestAddStableCoinProposal() { Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", } _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &proAdd) s.Require().NoError(err) - stablecoin, err := s.k.Stablecoins.Get(s.Ctx, proAdd.Denom) + stablecoin, err := s.k.StablecoinInfo.Get(s.Ctx, proAdd.Denom) s.Require().NoError(err) s.Require().Equal(stablecoin.Denom, proAdd.Denom) s.Require().Equal(stablecoin.LimitTotal, limitUSDT) @@ -37,13 +36,12 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() { Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", } _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &proAdd) s.Require().NoError(err) - stablecoin, err := s.k.Stablecoins.Get(s.Ctx, proAdd.Denom) + stablecoin, err := s.k.StablecoinInfo.Get(s.Ctx, proAdd.Denom) s.Require().NoError(err) s.Require().Equal(stablecoin.Denom, proAdd.Denom) s.Require().Equal(stablecoin.LimitTotal, limitUSDT) @@ -57,13 +55,12 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() { Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", } _, err = s.msgServer.UpdatesStableCoinProposal(s.Ctx, &proUpdates) s.Require().NoError(err) - stablecoin, err = s.k.Stablecoins.Get(s.Ctx, proAdd.Denom) + stablecoin, err = s.k.StablecoinInfo.Get(s.Ctx, proAdd.Denom) s.Require().NoError(err) s.Require().Equal(stablecoin.Denom, proAdd.Denom) s.Require().Equal(stablecoin.LimitTotal, limitTotalUpdates) diff --git a/x/psm/keeper/query.go b/x/psm/keeper/query.go index 03219351..f682e821 100644 --- a/x/psm/keeper/query.go +++ b/x/psm/keeper/query.go @@ -46,7 +46,7 @@ func (q queryServer) Stablecoin(ctx context.Context, req *types.QueryStablecoinR return nil, status.Error(codes.InvalidArgument, "invalid request") } - stablecoin, err := q.keeper.Stablecoins.Get(ctx, req.Denom) + stablecoin, err := q.keeper.StablecoinInfo.Get(ctx, req.Denom) if err != nil { return nil, status.Errorf(codes.NotFound, "not found stablecoin %s", req.Denom) } @@ -63,7 +63,7 @@ func (q queryServer) AllStablecoin(ctx context.Context, req *types.QueryAllStabl } allStablecoins := []*types.StablecoinResponse{} - adder := func(s types.Stablecoin) { + adder := func(s types.StablecoinInfo) { newStablecoinResponse := types.StablecoinResponse{ Stablecoin: s, SwapableQuantity: s.LimitTotal.Sub(s.TotalStablecoinLock), @@ -71,7 +71,7 @@ func (q queryServer) AllStablecoin(ctx context.Context, req *types.QueryAllStabl allStablecoins = append(allStablecoins, &newStablecoinResponse) } - err := q.keeper.Stablecoins.Walk(ctx, nil, func(key string, value types.Stablecoin) (stop bool, err error) { + err := q.keeper.StablecoinInfo.Walk(ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { adder(value) return false, nil }) diff --git a/x/psm/keeper/query_test.go b/x/psm/keeper/query_test.go index 917770ff..d641c704 100644 --- a/x/psm/keeper/query_test.go +++ b/x/psm/keeper/query_test.go @@ -16,7 +16,7 @@ func (s *KeeperTestSuite) TestQueryParams() { func (s *KeeperTestSuite) TestStablecoin() { s.SetupTest() - sc := types.Stablecoin{ + sc := types.StablecoinInfo{ Denom: usdt, LimitTotal: limitUSDT, FeeIn: math.LegacyMustNewDecFromStr("0.001"), @@ -24,7 +24,7 @@ func (s *KeeperTestSuite) TestStablecoin() { TotalStablecoinLock: math.ZeroInt(), FeeMaxStablecoin: math.LegacyZeroDec(), } - err := s.k.Stablecoins.Set(s.Ctx, sc.Denom, sc) + err := s.k.StablecoinInfo.Set(s.Ctx, sc.Denom, sc) s.Require().NoError(err) rp, err := s.queryServer.Stablecoin(s.Ctx, &types.QueryStablecoinRequest{Denom: usdt}) diff --git a/x/psm/keeper/stablecoin.go b/x/psm/keeper/stablecoin.go index b56d25d0..e6c61eb0 100644 --- a/x/psm/keeper/stablecoin.go +++ b/x/psm/keeper/stablecoin.go @@ -8,23 +8,15 @@ import ( ) func (k Keeper) GetTotalLimitWithDenomStablecoin(ctx context.Context, denom string) (math.Int, error) { - s, err := k.Stablecoins.Get(ctx, denom) + s, err := k.StablecoinInfo.Get(ctx, denom) if err != nil { return math.Int{}, fmt.Errorf("not found Stable coin %s", denom) } return s.LimitTotal, nil } -func (k Keeper) GetNomType(ctx context.Context, denom string) (string, error) { - s, err := k.Stablecoins.Get(ctx, denom) - if err != nil { - return "", fmt.Errorf("not found Stable coin %s", denom) - } - return s.NomType, nil -} - func (k Keeper) GetFeeIn(ctx context.Context, denom string) (math.LegacyDec, error) { - s, err := k.Stablecoins.Get(ctx, denom) + s, err := k.StablecoinInfo.Get(ctx, denom) if err != nil { return math.LegacyDec{}, fmt.Errorf("not found Stable coin %s", denom) } @@ -32,7 +24,7 @@ func (k Keeper) GetFeeIn(ctx context.Context, denom string) (math.LegacyDec, err } func (k Keeper) GetFeeOut(ctx context.Context, denom string) (math.LegacyDec, error) { - s, err := k.Stablecoins.Get(ctx, denom) + s, err := k.StablecoinInfo.Get(ctx, denom) if err != nil { return math.LegacyDec{}, fmt.Errorf("not found Stable coin %s", denom) } diff --git a/x/psm/keeper/stablecoin_test.go b/x/psm/keeper/stablecoin_test.go index 79864603..9f5d9137 100644 --- a/x/psm/keeper/stablecoin_test.go +++ b/x/psm/keeper/stablecoin_test.go @@ -9,36 +9,36 @@ import ( func (s *KeeperTestSuite) TestStoreStablecoin() { s.SetupTest() - s1 := types.Stablecoin{ + s1 := types.StablecoinInfo{ Denom: usdt, LimitTotal: limitUSDT, FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), } - s2 := types.Stablecoin{ + s2 := types.StablecoinInfo{ Denom: usdc, LimitTotal: limitUSDC, FeeIn: math.LegacyMustNewDecFromStr("0.001"), FeeOut: math.LegacyMustNewDecFromStr("0.001"), } - err := s.k.Stablecoins.Set(s.Ctx, s1.Denom, s1) + err := s.k.StablecoinInfo.Set(s.Ctx, s1.Denom, s1) s.Require().NoError(err) - err = s.k.Stablecoins.Set(s.Ctx, s2.Denom, s2) + err = s.k.StablecoinInfo.Set(s.Ctx, s2.Denom, s2) s.Require().NoError(err) - stablecoin1, err := s.k.Stablecoins.Get(s.Ctx, usdt) + stablecoin1, err := s.k.StablecoinInfo.Get(s.Ctx, usdt) s.Require().NoError(err) s.Require().Equal(stablecoin1.Denom, usdt) s.Require().Equal(stablecoin1.LimitTotal, limitUSDT) - stablecoin2, err := s.k.Stablecoins.Get(s.Ctx, usdc) + stablecoin2, err := s.k.StablecoinInfo.Get(s.Ctx, usdc) s.Require().NoError(err) s.Require().Equal(stablecoin2.Denom, usdc) s.Require().Equal(stablecoin2.LimitTotal, limitUSDC) count := 0 - err = s.k.Stablecoins.Walk(s.Ctx, nil, func(key string, value types.Stablecoin) (stop bool, err error) { + err = s.k.StablecoinInfo.Walk(s.Ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { count += 1 return false, nil }) diff --git a/x/psm/keeper/swap.go b/x/psm/keeper/swap.go index ae4a8432..aa7ca8a4 100644 --- a/x/psm/keeper/swap.go +++ b/x/psm/keeper/swap.go @@ -4,66 +4,86 @@ import ( "context" "fmt" + "cosmossdk.io/errors" "cosmossdk.io/math" + oracletypes "github.com/onomyprotocol/reserve/x/oracle/types" - errors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - oracletypes "github.com/onomyprotocol/reserve/x/oracle/types" + "github.com/onomyprotocol/reserve/x/psm/types" ) // SwapToStablecoin return receiveAmount, fee, error -func (k Keeper) SwapToStablecoin(ctx context.Context, addr sdk.AccAddress, amount math.Int, toDenom string) (math.Int, sdk.DecCoin, error) { - denomMint, err := k.GetNomType(ctx, toDenom) +func (k Keeper) SwapToOtherStablecoin(ctx context.Context, addr sdk.AccAddress, offerCoin sdk.Coin, expectedDenom string) error { + // check stablecoin is suport + stablecoinInfo, err := k.StablecoinInfo.Get(ctx, expectedDenom) if err != nil { - return math.ZeroInt(), sdk.DecCoin{}, err + return fmt.Errorf("%s not in list stablecoin supported", expectedDenom) } - asset := k.BankKeeper.GetBalance(ctx, addr, denomMint) + // check lock Coin of user + totalStablecoinLock, err := k.TotalStablecoinLock(ctx, expectedDenom) + if err != nil { + return err + } - if asset.Amount.LT(amount) { - return math.ZeroInt(), sdk.DecCoin{}, fmt.Errorf("insufficient balance") + rate := k.OracleKeeper.GetPrice(ctx, expectedDenom, types.USD) + if rate == nil || rate.IsNil() { + return errors.Wrapf(oracletypes.ErrInvalidOracle, "can not get price with base %s quote %s", offerCoin.Denom, types.USD) } - multiplier := k.OracleKeeper.GetPrice(ctx, toDenom, denomMint) - if multiplier == nil || multiplier.IsNil() { - return math.Int{}, sdk.DecCoin{}, errors.Wrapf(oracletypes.ErrInvalidOracle, "can not get price with base %s quote %s", toDenom, denomMint) + expectedAmount := offerCoin.Amount.ToLegacyDec().Quo(*rate).RoundInt() + + // locked stablecoin is greater than the amount desired + if totalStablecoinLock.LT(expectedAmount) { + //TODO: register error + return fmt.Errorf("insufficient balance, PSM module have %d USD but request %d", totalStablecoinLock, expectedAmount) } - amountStablecoin := amount.ToLegacyDec().Quo(*multiplier) - fee, err := k.PayFeesOut(ctx, amountStablecoin.RoundInt(), toDenom) + fee, err := k.PayFeesOut(ctx, expectedAmount, expectedDenom) if err != nil { - return math.Int{}, sdk.DecCoin{}, err + return err } - receiveAmount := amountStablecoin.Sub(fee) - return receiveAmount.RoundInt(), sdk.NewDecCoinFromDec(toDenom, fee), nil -} - -func (k Keeper) SwapTonomUSD(ctx context.Context, addr sdk.AccAddress, stablecoin sdk.Coin) (math.Int, sdk.DecCoin, error) { - denomMint, err := k.GetNomType(ctx, stablecoin.Denom) + // burn nomUSD + coinsBurn := sdk.NewCoins(offerCoin) + err = k.BankKeeper.SendCoinsFromAccountToModule(ctx, addr, types.ModuleName, coinsBurn) if err != nil { - return math.ZeroInt(), sdk.DecCoin{}, err + return err } - asset := k.BankKeeper.GetBalance(ctx, addr, stablecoin.Denom) - - if asset.Amount.LT(stablecoin.Amount) { - return math.ZeroInt(), sdk.DecCoin{}, fmt.Errorf("insufficient balance") + err = k.BankKeeper.BurnCoins(ctx, types.ModuleName, coinsBurn) + if err != nil { + return err } - multiplier := k.OracleKeeper.GetPrice(ctx, stablecoin.Denom, denomMint) - if multiplier == nil || multiplier.IsNil() { - return math.Int{}, sdk.DecCoin{}, errors.Wrapf(oracletypes.ErrInvalidOracle, "can not get price with base %s quote %s", stablecoin.Denom, denomMint) + // update stable coin info + stablecoinReceive := sdk.NewCoin(expectedDenom, math.Int(expectedAmount)) + stablecoinInfo.TotalStablecoinLock = totalStablecoinLock.Sub(expectedAmount) + err = k.StablecoinInfo.Set(ctx, expectedDenom, stablecoinInfo) + if err != nil { + return err } - amountnomUSD := multiplier.Mul(stablecoin.Amount.ToLegacyDec()) - - fee, err := k.PayFeesIn(ctx, amountnomUSD.RoundInt(), stablecoin.Denom) + // send stablecoin to user + err = k.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, sdk.NewCoins(stablecoinReceive)) if err != nil { - return math.Int{}, sdk.DecCoin{}, err + return err } - receiveAmountnomUSD := amountnomUSD.Sub(fee) - return receiveAmountnomUSD.RoundInt(), sdk.NewDecCoinFromDec(denomMint, fee), nil + // event + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventSwapTonomUSD, + sdk.NewAttribute(types.AttributeAmount, offerCoin.String()), + sdk.NewAttribute(types.AttributeReceive, expectedAmount.String()), + sdk.NewAttribute(types.AttributeFeeIn, fee.String()), + ), + ) + return nil +} + +func (k Keeper) SwapToOnomyStableToken(ctx context.Context, accAddress sdk.AccAddress, offerCoin sdk.Coin, expectedDenom string) error { + return nil } func (k Keeper) PayFeesOut(ctx context.Context, amount math.Int, denom string) (math.LegacyDec, error) { diff --git a/x/psm/keeper/swap_test.go b/x/psm/keeper/swap_test.go index ca2eaca3..18ca8c06 100644 --- a/x/psm/keeper/swap_test.go +++ b/x/psm/keeper/swap_test.go @@ -1,168 +1,152 @@ package keeper_test -import ( - "context" - - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/onomyprotocol/reserve/x/psm/keeper" - "github.com/onomyprotocol/reserve/x/psm/types" -) - -func (s *KeeperTestSuite) TestSwapTonomUSD() { - s.SetupTest() - - tests := []struct { - name string - setup func(ctx context.Context, keeper keeper.Keeper) - addr sdk.AccAddress - stablecoin sdk.Coin - - expectPass bool - expectedReceive math.Int - expectedFee math.LegacyDec - }{ - { - name: "success", - setup: func(ctx context.Context, keeper keeper.Keeper) { - coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) - err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) - s.Require().NoError(err) - err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) - s.Require().NoError(err) - - _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Denom: usdt, - LimitTotal: limitUSDT, - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", - }) - s.Require().NoError(err) - }, - addr: s.TestAccs[0], - stablecoin: sdk.NewCoin(usdt, math.NewInt(1000)), - expectPass: true, - expectedReceive: math.NewInt(999), - expectedFee: math.LegacyMustNewDecFromStr("1"), - }, - { - name: "insufficient balance", - setup: func(ctx context.Context, keeper keeper.Keeper) { - _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Denom: usdc, - LimitTotal: limitUSDC, - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", - }) - s.Require().NoError(err) - }, - addr: s.TestAccs[1], - stablecoin: sdk.NewCoin(usdt, math.NewInt(1000)), - expectPass: false, - expectedReceive: math.NewInt(999), - expectedFee: math.LegacyMustNewDecFromStr("1"), - }, - } - - for _, t := range tests { - s.Run(t.name, func() { - t.setup(s.Ctx, s.k) - - receiveAmount, fee, err := s.k.SwapTonomUSD(s.Ctx, t.addr, t.stablecoin) - if t.expectPass { - s.Require().NoError(err) - s.Require().Equal(t.expectedReceive, receiveAmount) - s.Require().Equal(t.expectedFee, fee.Amount) - } else { - s.Require().Error(err) - } - - }) - } -} - -func (s *KeeperTestSuite) TestSwapToStablecoin() { - s.SetupTest() - - tests := []struct { - name string - setup func(ctx context.Context, keeper keeper.Keeper) - addr sdk.AccAddress - amount math.Int - toDenom string - - expectPass bool - expectedReceive math.Int - expectedFee math.LegacyDec - }{ - { - name: "success", - setup: func(ctx context.Context, keeper keeper.Keeper) { - coinsMint := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000000))) - err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) - s.Require().NoError(err) - err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) - s.Require().NoError(err) - - _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Denom: usdt, - LimitTotal: limitUSDT, - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", - }) - s.Require().NoError(err) - }, - addr: s.TestAccs[0], - amount: math.NewInt(1000), - toDenom: usdt, - expectPass: true, - expectedReceive: math.NewInt(999), - expectedFee: math.LegacyMustNewDecFromStr("1"), - }, - { - name: "insufficient balance", - setup: func(ctx context.Context, keeper keeper.Keeper) { - _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Denom: usdc, - LimitTotal: limitUSDC, - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), - NomType: "nomUSD", - }) - s.Require().NoError(err) - }, - addr: s.TestAccs[1], - amount: math.NewInt(1000), - toDenom: usdt, - expectPass: false, - expectedReceive: math.NewInt(999), - expectedFee: math.LegacyMustNewDecFromStr("1"), - }, - } - - for _, t := range tests { - s.Run(t.name, func() { - t.setup(s.Ctx, s.k) - - receiveAmount, fee, err := s.k.SwapToStablecoin(s.Ctx, t.addr, t.amount, t.toDenom) - if t.expectPass { - s.Require().NoError(err) - s.Require().Equal(t.expectedReceive, receiveAmount) - s.Require().Equal(t.expectedFee, fee.Amount) - } else { - s.Require().Error(err) - } - - }) - } -} +// TODO: refactor test +// func (s *KeeperTestSuite) TestSwapTonomUSD() { +// s.SetupTest() + +// tests := []struct { +// name string +// setup func(ctx context.Context, keeper keeper.Keeper) +// addr sdk.AccAddress +// stablecoin sdk.Coin + +// expectPass bool +// expectedReceive math.Int +// expectedFee math.LegacyDec +// }{ +// { +// name: "success", +// setup: func(ctx context.Context, keeper keeper.Keeper) { +// coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) +// err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) +// s.Require().NoError(err) +// err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) +// s.Require().NoError(err) + +// _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ +// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), +// Denom: usdt, +// LimitTotal: limitUSDT, +// FeeIn: math.LegacyMustNewDecFromStr("0.001"), +// FeeOut: math.LegacyMustNewDecFromStr("0.001"), +// }) +// s.Require().NoError(err) +// }, +// addr: s.TestAccs[0], +// stablecoin: sdk.NewCoin(usdt, math.NewInt(1000)), +// expectPass: true, +// expectedReceive: math.NewInt(999), +// expectedFee: math.LegacyMustNewDecFromStr("1"), +// }, +// { +// name: "insufficient balance", +// setup: func(ctx context.Context, keeper keeper.Keeper) { +// _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ +// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), +// Denom: usdc, +// LimitTotal: limitUSDC, +// FeeIn: math.LegacyMustNewDecFromStr("0.001"), +// FeeOut: math.LegacyMustNewDecFromStr("0.001"), +// }) +// s.Require().NoError(err) +// }, +// addr: s.TestAccs[1], +// stablecoin: sdk.NewCoin(usdt, math.NewInt(1000)), +// expectPass: false, +// expectedReceive: math.NewInt(999), +// expectedFee: math.LegacyMustNewDecFromStr("1"), +// }, +// } + +// for _, t := range tests { +// s.Run(t.name, func() { +// t.setup(s.Ctx, s.k) + +// receiveAmount, fee, err := s.k.SwapToOnomyStableToken(s.Ctx, t.addr, t.stablecoin) +// if t.expectPass { +// s.Require().NoError(err) +// s.Require().Equal(t.expectedReceive, receiveAmount) +// s.Require().Equal(t.expectedFee, fee.Amount) +// } else { +// s.Require().Error(err) +// } + +// }) +// } +// } + +// func (s *KeeperTestSuite) TestSwapToStablecoin() { +// s.SetupTest() + +// tests := []struct { +// name string +// setup func(ctx context.Context, keeper keeper.Keeper) +// addr sdk.AccAddress +// amount math.Int +// toDenom string + +// expectPass bool +// expectedReceive math.Int +// expectedFee math.LegacyDec +// }{ +// { +// name: "success", +// setup: func(ctx context.Context, keeper keeper.Keeper) { +// coinsMint := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000000))) +// err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) +// s.Require().NoError(err) +// err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) +// s.Require().NoError(err) + +// _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ +// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), +// Denom: usdt, +// LimitTotal: limitUSDT, +// FeeIn: math.LegacyMustNewDecFromStr("0.001"), +// FeeOut: math.LegacyMustNewDecFromStr("0.001"), +// NomType: "nomUSD", +// }) +// s.Require().NoError(err) +// }, +// addr: s.TestAccs[0], +// amount: math.NewInt(1000), +// toDenom: usdt, +// expectPass: true, +// expectedReceive: math.NewInt(999), +// expectedFee: math.LegacyMustNewDecFromStr("1"), +// }, +// { +// name: "insufficient balance", +// setup: func(ctx context.Context, keeper keeper.Keeper) { +// _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ +// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), +// Denom: usdc, +// LimitTotal: limitUSDC, +// FeeIn: math.LegacyMustNewDecFromStr("0.001"), +// FeeOut: math.LegacyMustNewDecFromStr("0.001"), +// }) +// s.Require().NoError(err) +// }, +// addr: s.TestAccs[1], +// amount: math.NewInt(1000), +// toDenom: usdt, +// expectPass: false, +// expectedReceive: math.NewInt(999), +// expectedFee: math.LegacyMustNewDecFromStr("1"), +// }, +// } + +// for _, t := range tests { +// s.Run(t.name, func() { +// t.setup(s.Ctx, s.k) +// // TODO: balances check +// err := s.k.SwapToOtherStablecoin(s.Ctx, t.amount, t.toDenom) +// if t.expectPass { +// s.Require().NoError(err) +// } else { +// s.Require().Error(err) +// } + +// }) +// } +// } diff --git a/x/psm/module/genesis.go b/x/psm/module/genesis.go index 1791aa05..75d752c4 100644 --- a/x/psm/module/genesis.go +++ b/x/psm/module/genesis.go @@ -11,7 +11,7 @@ import ( func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) error { // this line is used by starport scaffolding # genesis/module/init for _, sb := range genState.Stablecoins { - err := k.Stablecoins.Set(ctx, sb.Denom, sb) + err := k.StablecoinInfo.Set(ctx, sb.Denom, sb) if err != nil { return err } @@ -37,7 +37,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) (*types.GenesisState, error return nil, err } - err = k.Stablecoins.Walk(ctx, nil, func(key string, value types.Stablecoin) (stop bool, err error) { + err = k.StablecoinInfo.Walk(ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { genesis.Stablecoins = append(genesis.Stablecoins, value) return false, nil }) diff --git a/x/psm/types/codec.go b/x/psm/types/codec.go index 4c59fd4b..a9746755 100644 --- a/x/psm/types/codec.go +++ b/x/psm/types/codec.go @@ -13,9 +13,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateParams{}, - &MsgSwapToStablecoin{}, - &MsgSwapToNom{}, - &MsgSwapToStablecoin{}, + &MsgStableSwap{}, &MsgAddStableCoin{}, &MsgUpdatesStableCoin{}, ) diff --git a/x/psm/types/genesis.go b/x/psm/types/genesis.go index 1ef13978..15bd79db 100644 --- a/x/psm/types/genesis.go +++ b/x/psm/types/genesis.go @@ -1,13 +1,13 @@ package types -var DefaultMintDenoms = []string{"nomUSD", "nomJPY", "nomEUR"} +var DefaultMintDenoms = []string{"nomUSD"} // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), - Stablecoins: []Stablecoin{}, + Stablecoins: []StablecoinInfo{}, Noms: DefaultMintDenoms, } } diff --git a/x/psm/types/genesis.pb.go b/x/psm/types/genesis.pb.go index 9d102265..9a21f97d 100644 --- a/x/psm/types/genesis.pb.go +++ b/x/psm/types/genesis.pb.go @@ -27,9 +27,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the psm module's genesis state. type GenesisState struct { // params defines all the parameters of the module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - Stablecoins []Stablecoin `protobuf:"bytes,2,rep,name=stablecoins,proto3" json:"stablecoins"` - Noms []string `protobuf:"bytes,3,rep,name=noms,proto3" json:"noms,omitempty"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Stablecoins []StablecoinInfo `protobuf:"bytes,2,rep,name=stablecoins,proto3" json:"stablecoins"` + Noms []string `protobuf:"bytes,3,rep,name=noms,proto3" json:"noms,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -72,7 +72,7 @@ func (m *GenesisState) GetParams() Params { return Params{} } -func (m *GenesisState) GetStablecoins() []Stablecoin { +func (m *GenesisState) GetStablecoins() []StablecoinInfo { if m != nil { return m.Stablecoins } @@ -93,25 +93,25 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/genesis.proto", fileDescriptor_fbe4ca1f3927cde8) } var fileDescriptor_fbe4ca1f3927cde8 = []byte{ - // 276 bytes of a gzipped FileDescriptorProto + // 280 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x4a, 0x2d, 0x4e, 0x2d, 0x2a, 0x4b, 0xd5, 0x2f, 0x28, 0xce, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xca, 0xea, 0x15, 0x14, 0xe7, 0xea, 0x95, 0x19, 0x4a, 0x09, 0x26, 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x12, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, 0x53, 0x1f, 0xc4, 0x82, 0x8a, 0x4a, 0xa3, 0x19, 0x5b, 0x90, - 0x58, 0x94, 0x98, 0x0b, 0x35, 0x55, 0x4a, 0x02, 0x5d, 0xb2, 0x38, 0x17, 0x22, 0xa3, 0xb4, 0x96, + 0x58, 0x94, 0x98, 0x0b, 0x35, 0x55, 0x4a, 0x02, 0x5d, 0xb2, 0x38, 0x17, 0x22, 0xa3, 0xb4, 0x91, 0x91, 0x8b, 0xc7, 0x1d, 0xe2, 0x82, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x4b, 0x2e, 0x36, 0x88, 0x56, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x31, 0x3d, 0x54, 0x17, 0xe9, 0x05, 0x80, 0x65, 0x9d, 0x38, 0x4f, 0xdc, 0x93, 0x67, 0x58, 0xf1, 0x7c, 0x83, 0x16, 0x63, 0x10, 0x54, 0x83, 0x90, - 0x3b, 0x17, 0x77, 0x71, 0x49, 0x62, 0x52, 0x4e, 0x6a, 0x72, 0x7e, 0x66, 0x5e, 0xb1, 0x04, 0x93, - 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x14, 0xba, 0xfe, 0x60, 0xb8, 0x12, 0x64, 0x33, 0x90, 0x75, 0x0a, - 0x49, 0x72, 0xb1, 0xe4, 0xe5, 0xe7, 0x16, 0x4b, 0x30, 0x2b, 0x30, 0x6b, 0x70, 0x3a, 0xb1, 0x42, - 0x54, 0x80, 0x85, 0x9c, 0xdc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, - 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, - 0x27, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x3f, 0x2f, 0x3f, 0xb7, - 0x12, 0xec, 0xc1, 0xe4, 0xfc, 0x1c, 0x7d, 0x98, 0xe7, 0x2b, 0xc0, 0xde, 0x2f, 0xa9, 0x2c, 0x48, - 0x2d, 0x4e, 0x62, 0x03, 0xcb, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc9, 0xef, 0x95, 0x72, - 0x8e, 0x01, 0x00, 0x00, + 0x37, 0x17, 0x77, 0x71, 0x49, 0x62, 0x52, 0x4e, 0x6a, 0x72, 0x7e, 0x66, 0x5e, 0xb1, 0x04, 0x93, + 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x1c, 0xba, 0xfe, 0x60, 0xb8, 0x12, 0xcf, 0xbc, 0xb4, 0x7c, 0x64, + 0x73, 0x90, 0x75, 0x0b, 0x49, 0x72, 0xb1, 0xe4, 0xe5, 0xe7, 0x16, 0x4b, 0x30, 0x2b, 0x30, 0x6b, + 0x70, 0x3a, 0xb1, 0x42, 0x54, 0x80, 0x85, 0x9c, 0xdc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, + 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, + 0x58, 0x8e, 0x21, 0x4a, 0x27, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, + 0x3f, 0x2f, 0x3f, 0xb7, 0x12, 0xec, 0xc9, 0xe4, 0xfc, 0x1c, 0x7d, 0x58, 0x00, 0x54, 0x80, 0x83, + 0xa0, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x2c, 0x6b, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, + 0xef, 0x05, 0xd9, 0x0a, 0x92, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -301,7 +301,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Stablecoins = append(m.Stablecoins, Stablecoin{}) + m.Stablecoins = append(m.Stablecoins, StablecoinInfo{}) if err := m.Stablecoins[len(m.Stablecoins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/psm/types/keys.go b/x/psm/types/keys.go index a7c90d50..1d2cc23e 100644 --- a/x/psm/types/keys.go +++ b/x/psm/types/keys.go @@ -15,6 +15,12 @@ const ( // MemStoreKey defines the in-memory store key. MemStoreKey = "mem_psm" + + // Reserve Stable Coin denom prefix + ReserveStableCoinDenomPrefix = "nom" + + // USD + USD = "USD" ) var ( diff --git a/x/psm/types/msgs.go b/x/psm/types/msgs.go index 95130edf..1990cc7e 100644 --- a/x/psm/types/msgs.go +++ b/x/psm/types/msgs.go @@ -1,16 +1,16 @@ package types import ( + "fmt" + sdkerrors "cosmossdk.io/errors" "cosmossdk.io/math" - "fmt" sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) var ( - _ sdk.Msg = &MsgSwapToNom{} - _ sdk.Msg = &MsgSwapToStablecoin{} + _ sdk.Msg = &MsgStableSwap{} _ sdk.Msg = &MsgAddStableCoin{} _ sdk.Msg = &MsgUpdatesStableCoin{} _ getStablecoinFromMsg = &MsgAddStableCoin{} @@ -31,53 +31,23 @@ func init() { } -func NewMsgSwapToNom(addr string, coin sdk.Coin) *MsgSwapToNom { - return &MsgSwapToNom{ - Address: addr, - Coin: coin, - } -} - -func (msg MsgSwapToNom) ValidateBasic() error { - if msg.Address == "" { - return fmt.Errorf("empty address") - } - - return msg.Coin.Validate() -} - -func (msg MsgSwapToNom) GetSigners() []sdk.AccAddress { - acc, err := sdk.AccAddressFromBech32(msg.Address) - if err != nil { - panic(err) - } - return []sdk.AccAddress{acc} -} - -// Route implements the sdk.Msg interface. -func (msg MsgSwapToNom) Route() string { return RouterKey } - -// /////////// -func NewMsgSwapToStablecoin(addr, toDenom string, amount sdk.Coin) *MsgSwapToStablecoin { - return &MsgSwapToStablecoin{ - Address: addr, - ToDenom: toDenom, - Coin: amount, +func NewMsgStableSwap(addr string, coin sdk.Coin, expectedDenom string) *MsgStableSwap { + return &MsgStableSwap{ + Address: addr, + OfferCoin: coin, + ExpectedDenom: expectedDenom, } } -func (msg MsgSwapToStablecoin) ValidateBasic() error { +func (msg MsgStableSwap) ValidateBasic() error { if msg.Address == "" { return fmt.Errorf("empty address") } - if msg.ToDenom == "" { - return fmt.Errorf("empty denom") - } - return msg.Coin.Validate() + return msg.OfferCoin.Validate() } -func (msg MsgSwapToStablecoin) GetSigners() []sdk.AccAddress { +func (msg MsgStableSwap) GetSigners() []sdk.AccAddress { acc, err := sdk.AccAddressFromBech32(msg.Address) if err != nil { panic(err) @@ -86,12 +56,7 @@ func (msg MsgSwapToStablecoin) GetSigners() []sdk.AccAddress { } // Route implements the sdk.Msg interface. -func (msg MsgSwapToStablecoin) Route() string { return RouterKey } - -var ( - Query_serviceDesc = _Query_serviceDesc - Msg_serviceDesc = _Msg_serviceDesc -) +func (msg MsgStableSwap) Route() string { return RouterKey } // func (msg MsgAddStableCoin) GetPrice() math.LegacyDec { // return msg.Price @@ -126,10 +91,6 @@ func (msg MsgAddStableCoin) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "limittotal less than zero") } - if msg.NomType == "" { - return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty nom type") - } - if msg.FeeIn.LT(math.LegacyZeroDec()) { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "feein less than zero") } @@ -165,10 +126,6 @@ func (msg MsgUpdatesStableCoin) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "limittotal less than zero") } - if msg.NomType == "" { - return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty nom type") - } - if msg.FeeIn.LT(math.LegacyZeroDec()) { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "feein less than zero") } diff --git a/x/psm/types/psm.go b/x/psm/types/psm.go index 21d1b2c7..d6dc604f 100644 --- a/x/psm/types/psm.go +++ b/x/psm/types/psm.go @@ -4,15 +4,14 @@ import ( "cosmossdk.io/math" ) -func GetMsgStablecoin(msg getStablecoinFromMsg) Stablecoin { - return Stablecoin{ +func GetMsgStablecoin(msg getStablecoinFromMsg) StablecoinInfo { + return StablecoinInfo{ Denom: msg.GetDenom(), LimitTotal: msg.GetLimitTotal(), FeeIn: msg.GetFeeIn(), FeeOut: msg.GetFeeOut(), TotalStablecoinLock: math.ZeroInt(), FeeMaxStablecoin: msg.GetFeeIn().Add(msg.GetFeeOut()), - NomType: msg.GetNomType(), } } @@ -22,5 +21,4 @@ type getStablecoinFromMsg interface { // GetPrice() math.LegacyDec GetFeeIn() math.LegacyDec GetFeeOut() math.LegacyDec - GetNomType() string } diff --git a/x/psm/types/psm.pb.go b/x/psm/types/psm.pb.go index 56b53715..80a6d564 100644 --- a/x/psm/types/psm.pb.go +++ b/x/psm/types/psm.pb.go @@ -27,7 +27,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type Stablecoin struct { +type StablecoinInfo struct { // stablecoin name Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` // limit total stablecoin @@ -40,22 +40,20 @@ type Stablecoin struct { TotalStablecoinLock cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=total_stablecoin_lock,json=totalStablecoinLock,proto3,customtype=cosmossdk.io/math.Int" json:"total_stablecoin_lock"` // maximum fee for when either fee = 0 FeeMaxStablecoin cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=fee_max_stablecoin,json=feeMaxStablecoin,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_max_stablecoin"` - // type nom which swaps at a 1:1 ratio, as nomUSD ~ 1 USDT - NomType string `protobuf:"bytes,7,opt,name=nom_type,json=nomType,proto3" json:"nom_type,omitempty"` } -func (m *Stablecoin) Reset() { *m = Stablecoin{} } -func (m *Stablecoin) String() string { return proto.CompactTextString(m) } -func (*Stablecoin) ProtoMessage() {} -func (*Stablecoin) Descriptor() ([]byte, []int) { +func (m *StablecoinInfo) Reset() { *m = StablecoinInfo{} } +func (m *StablecoinInfo) String() string { return proto.CompactTextString(m) } +func (*StablecoinInfo) ProtoMessage() {} +func (*StablecoinInfo) Descriptor() ([]byte, []int) { return fileDescriptor_59572214fa05fb2f, []int{0} } -func (m *Stablecoin) XXX_Unmarshal(b []byte) error { +func (m *StablecoinInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *Stablecoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *StablecoinInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_Stablecoin.Marshal(b, m, deterministic) + return xxx_messageInfo_StablecoinInfo.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -65,69 +63,61 @@ func (m *Stablecoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *Stablecoin) XXX_Merge(src proto.Message) { - xxx_messageInfo_Stablecoin.Merge(m, src) +func (m *StablecoinInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_StablecoinInfo.Merge(m, src) } -func (m *Stablecoin) XXX_Size() int { +func (m *StablecoinInfo) XXX_Size() int { return m.Size() } -func (m *Stablecoin) XXX_DiscardUnknown() { - xxx_messageInfo_Stablecoin.DiscardUnknown(m) +func (m *StablecoinInfo) XXX_DiscardUnknown() { + xxx_messageInfo_StablecoinInfo.DiscardUnknown(m) } -var xxx_messageInfo_Stablecoin proto.InternalMessageInfo +var xxx_messageInfo_StablecoinInfo proto.InternalMessageInfo -func (m *Stablecoin) GetDenom() string { +func (m *StablecoinInfo) GetDenom() string { if m != nil { return m.Denom } return "" } -func (m *Stablecoin) GetNomType() string { - if m != nil { - return m.NomType - } - return "" -} - func init() { - proto.RegisterType((*Stablecoin)(nil), "reserve.psm.v1.Stablecoin") + proto.RegisterType((*StablecoinInfo)(nil), "reserve.psm.v1.StablecoinInfo") } func init() { proto.RegisterFile("reserve/psm/v1/psm.proto", fileDescriptor_59572214fa05fb2f) } var fileDescriptor_59572214fa05fb2f = []byte{ - // 412 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x4f, 0x8e, 0xd3, 0x30, - 0x14, 0xc6, 0x13, 0x86, 0xb6, 0x60, 0x10, 0x02, 0x33, 0x23, 0x79, 0x06, 0x29, 0x33, 0x62, 0x35, - 0x42, 0x10, 0x13, 0x71, 0x83, 0xd1, 0x08, 0x51, 0x34, 0x08, 0x51, 0x66, 0xc5, 0x26, 0x72, 0xdc, - 0xd7, 0x4c, 0xd4, 0xd8, 0x2f, 0xaa, 0xdd, 0xa8, 0xb9, 0x05, 0xc7, 0x60, 0xc9, 0x82, 0x43, 0xcc, - 0xb2, 0x62, 0x85, 0x58, 0x54, 0xa8, 0x5d, 0xb0, 0xe2, 0x0e, 0xc8, 0x4e, 0x80, 0x4a, 0xec, 0xba, - 0x49, 0xec, 0xf7, 0x59, 0xbf, 0xf7, 0xbd, 0x3f, 0x84, 0xcd, 0xc0, 0xc0, 0xac, 0x06, 0x5e, 0x19, - 0xc5, 0xeb, 0xc4, 0xfd, 0xe2, 0x6a, 0x86, 0x16, 0xe9, 0xbd, 0x4e, 0x89, 0x5d, 0xa8, 0x4e, 0x8e, - 0xf6, 0x73, 0xcc, 0xd1, 0x4b, 0xdc, 0x9d, 0xda, 0x57, 0x47, 0x87, 0x12, 0x8d, 0x42, 0x93, 0xb6, - 0x42, 0x7b, 0xe9, 0xa4, 0x07, 0x42, 0x15, 0x1a, 0xb9, 0xff, 0x76, 0xa1, 0xa8, 0x7d, 0xc0, 0x33, - 0x61, 0x80, 0xd7, 0x49, 0x06, 0x56, 0x24, 0x5c, 0x62, 0xa1, 0x5b, 0xfd, 0xf1, 0xaf, 0x3d, 0x42, - 0xde, 0x5b, 0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x2e, 0x9b, 0x0a, 0xce, 0x5e, 0x5e, 0xaf, 0xa3, 0x70, - 0xb9, 0x8e, 0xc2, 0x1f, 0xeb, 0x28, 0xfc, 0xb8, 0x89, 0x82, 0xe5, 0x26, 0x0a, 0xbe, 0x6d, 0xa2, - 0xe0, 0xc3, 0xd3, 0xbc, 0xb0, 0x57, 0xf3, 0x2c, 0x96, 0xa8, 0x38, 0x6a, 0x54, 0x8d, 0x5f, 0x10, - 0x89, 0x25, 0xff, 0xb3, 0xb0, 0x0b, 0xbf, 0xb2, 0x8e, 0x6a, 0xb2, 0xbe, 0x57, 0x5f, 0xfc, 0x0e, - 0x00, 0x00, 0xff, 0xff, 0x0b, 0x61, 0x14, 0x2b, 0xce, 0x02, 0x00, 0x00, + // 397 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x41, 0xab, 0xd3, 0x40, + 0x10, 0xc7, 0x13, 0x9f, 0xad, 0xb8, 0xca, 0x43, 0xd7, 0xf7, 0x20, 0x3e, 0x21, 0xef, 0xe1, 0xe9, + 0x21, 0x9a, 0x35, 0xf8, 0x0d, 0x4a, 0x11, 0x23, 0x15, 0xb1, 0x7a, 0xf2, 0x12, 0x36, 0xdb, 0x49, + 0x1a, 0x9a, 0xdd, 0x29, 0xdd, 0x6d, 0x68, 0xbf, 0x85, 0x1f, 0xc3, 0xa3, 0x07, 0x3f, 0x44, 0x8f, + 0xc5, 0x83, 0x88, 0x87, 0x22, 0xed, 0xc1, 0xaf, 0x21, 0xbb, 0x89, 0xb6, 0xe0, 0xad, 0x97, 0x64, + 0x67, 0xfe, 0xc3, 0x6f, 0xfe, 0x33, 0x0c, 0x09, 0x66, 0xa0, 0x61, 0x56, 0x03, 0x9b, 0x6a, 0xc9, + 0xea, 0xd8, 0xfe, 0xa2, 0xe9, 0x0c, 0x0d, 0xd2, 0xd3, 0x56, 0x89, 0x6c, 0xaa, 0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 0xf5, 0xbf, 0xb5, 0xa4, 0x15, 0x8a, 0x49, 0xd0, 0x39, 0x72, 0xe4, 0x07, 0x0e, + 0xb7, 0x5f, 0xf2, 0x00, 0xc5, 0x84, 0xa6, 0x84, 0x5a, 0xc7, 0x92, 0x2f, 0x0e, 0xfa, 0x04, 0xdd, + 0x63, 0xcd, 0xdf, 0xcb, 0x01, 0xde, 0xf0, 0xc5, 0xbe, 0x49, 0xef, 0xe5, 0x6a, 0x1b, 0xfa, 0xeb, + 0x6d, 0xe8, 0xff, 0xda, 0x86, 0xfe, 0xa7, 0x5d, 0xe8, 0xad, 0x77, 0xa1, 0xf7, 0x63, 0x17, 0x7a, + 0x1f, 0x9f, 0x16, 0xa5, 0x19, 0xcf, 0xb3, 0x48, 0xa0, 0x64, 0xa8, 0x50, 0x2e, 0xdd, 0x25, 0x08, + 0xac, 0xd8, 0xdf, 0xcb, 0x5c, 0xb8, 0xdb, 0x34, 0xcb, 0x29, 0xe8, 0xac, 0xeb, 0xd4, 0x17, 0x7f, + 0x02, 0x00, 0x00, 0xff, 0xff, 0xad, 0x79, 0xba, 0x33, 0xb7, 0x02, 0x00, 0x00, } -func (m *Stablecoin) Marshal() (dAtA []byte, err error) { +func (m *StablecoinInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -137,23 +127,16 @@ func (m *Stablecoin) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Stablecoin) MarshalTo(dAtA []byte) (int, error) { +func (m *StablecoinInfo) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Stablecoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *StablecoinInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.NomType) > 0 { - i -= len(m.NomType) - copy(dAtA[i:], m.NomType) - i = encodeVarintPsm(dAtA, i, uint64(len(m.NomType))) - i-- - dAtA[i] = 0x3a - } { size := m.FeeMaxStablecoin.Size() i -= size @@ -225,7 +208,7 @@ func encodeVarintPsm(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *Stablecoin) Size() (n int) { +func (m *StablecoinInfo) Size() (n int) { if m == nil { return 0 } @@ -245,10 +228,6 @@ func (m *Stablecoin) Size() (n int) { n += 1 + l + sovPsm(uint64(l)) l = m.FeeMaxStablecoin.Size() n += 1 + l + sovPsm(uint64(l)) - l = len(m.NomType) - if l > 0 { - n += 1 + l + sovPsm(uint64(l)) - } return n } @@ -258,7 +237,7 @@ func sovPsm(x uint64) (n int) { func sozPsm(x uint64) (n int) { return sovPsm(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Stablecoin) Unmarshal(dAtA []byte) error { +func (m *StablecoinInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -281,10 +260,10 @@ func (m *Stablecoin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Stablecoin: wiretype end group for non-group") + return fmt.Errorf("proto: StablecoinInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Stablecoin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: StablecoinInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -484,38 +463,6 @@ func (m *Stablecoin) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NomType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPsm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPsm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPsm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NomType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPsm(dAtA[iNdEx:]) diff --git a/x/psm/types/query.pb.go b/x/psm/types/query.pb.go index 5d55bb3a..6a9536ae 100644 --- a/x/psm/types/query.pb.go +++ b/x/psm/types/query.pb.go @@ -161,7 +161,7 @@ func (m *QueryStablecoinRequest) GetDenom() string { } type QueryStablecoinResponse struct { - Stablecoin Stablecoin `protobuf:"bytes,1,opt,name=stablecoin,proto3" json:"stablecoin"` + Stablecoin StablecoinInfo `protobuf:"bytes,1,opt,name=stablecoin,proto3" json:"stablecoin"` SwapableQuantity cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=swapable_quantity,json=swapableQuantity,proto3,customtype=cosmossdk.io/math.Int" json:"swapable_quantity"` } @@ -198,11 +198,11 @@ func (m *QueryStablecoinResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryStablecoinResponse proto.InternalMessageInfo -func (m *QueryStablecoinResponse) GetStablecoin() Stablecoin { +func (m *QueryStablecoinResponse) GetStablecoin() StablecoinInfo { if m != nil { return m.Stablecoin } - return Stablecoin{} + return StablecoinInfo{} } type QueryAllStablecoinRequest struct { @@ -286,7 +286,7 @@ func (m *QueryAllStablecoinResponse) GetAllStablecoinResponse() []*StablecoinRes } type StablecoinResponse struct { - Stablecoin Stablecoin `protobuf:"bytes,1,opt,name=stablecoin,proto3" json:"stablecoin"` + Stablecoin StablecoinInfo `protobuf:"bytes,1,opt,name=stablecoin,proto3" json:"stablecoin"` SwapableQuantity cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=swapable_quantity,json=swapableQuantity,proto3,customtype=cosmossdk.io/math.Int" json:"swapable_quantity"` } @@ -323,11 +323,11 @@ func (m *StablecoinResponse) XXX_DiscardUnknown() { var xxx_messageInfo_StablecoinResponse proto.InternalMessageInfo -func (m *StablecoinResponse) GetStablecoin() Stablecoin { +func (m *StablecoinResponse) GetStablecoin() StablecoinInfo { if m != nil { return m.Stablecoin } - return Stablecoin{} + return StablecoinInfo{} } func init() { @@ -343,43 +343,43 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/query.proto", fileDescriptor_46bfc761c6109b8c) } var fileDescriptor_46bfc761c6109b8c = []byte{ - // 568 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x53, 0xb1, 0x6f, 0x13, 0x3f, - 0x18, 0x8d, 0x7f, 0xf9, 0x35, 0x52, 0x5d, 0x40, 0xd4, 0xa4, 0x6d, 0x72, 0x41, 0xd7, 0x70, 0xa0, - 0x12, 0xa2, 0x72, 0x26, 0x61, 0x62, 0x83, 0x0c, 0x48, 0xdd, 0xda, 0xb0, 0x55, 0x42, 0x91, 0x93, - 0x5a, 0xd7, 0x13, 0x67, 0xfb, 0x72, 0x76, 0x42, 0x33, 0x81, 0xd8, 0xd8, 0x90, 0x18, 0xf8, 0x17, - 0x18, 0x19, 0x60, 0xe1, 0x2f, 0xe8, 0x58, 0xc1, 0x82, 0x18, 0x2a, 0x94, 0x20, 0xf1, 0x6f, 0xa0, - 0xd8, 0x0e, 0x21, 0xc9, 0x15, 0xba, 0xb2, 0x44, 0x67, 0xbf, 0xf7, 0xbd, 0xef, 0x7d, 0x2f, 0x9f, - 0xa1, 0x93, 0x50, 0x49, 0x93, 0x3e, 0xc5, 0xb1, 0x64, 0xb8, 0x5f, 0xc3, 0xdd, 0x1e, 0x4d, 0x06, - 0x7e, 0x9c, 0x08, 0x25, 0xd0, 0x25, 0x8b, 0xf9, 0xb1, 0x64, 0x7e, 0xbf, 0xe6, 0xac, 0x12, 0x16, - 0x72, 0x81, 0xf5, 0xaf, 0xa1, 0x38, 0xf9, 0x40, 0x04, 0x42, 0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x73, 0xaa, 0xe7, 0xa1, 0x9e, 0xdb, 0x4b, 0xe3, 0xe1, 0xf1, - 0xd0, 0x05, 0x27, 0x43, 0x17, 0x7c, 0x1b, 0xba, 0xe0, 0xd5, 0xc8, 0xcd, 0x9c, 0x8c, 0xdc, 0xcc, - 0x97, 0x91, 0x9b, 0xd9, 0xdf, 0x0e, 0x42, 0x75, 0xd8, 0x6b, 0xfb, 0x1d, 0xc1, 0xce, 0x08, 0xf6, - 0x48, 0x0b, 0xa9, 0x41, 0x4c, 0x65, 0x3b, 0xa7, 0xd1, 0xbb, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, - 0x07, 0x48, 0xb5, 0xe2, 0x7f, 0x05, 0x00, 0x00, + // 570 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x53, 0x31, 0x6f, 0x13, 0x31, + 0x18, 0x8d, 0x09, 0x8d, 0x54, 0x17, 0x10, 0x35, 0x69, 0x9b, 0x5c, 0xd0, 0x35, 0x1c, 0xa8, 0x84, + 0xa8, 0x9c, 0x49, 0x98, 0x18, 0x89, 0x10, 0x52, 0xb6, 0x36, 0x6c, 0x95, 0x50, 0xe4, 0xa4, 0xe6, + 0x7a, 0xe2, 0xce, 0xbe, 0x9c, 0x9d, 0xd0, 0x4c, 0x20, 0x36, 0x36, 0x24, 0x06, 0xfe, 0x02, 0x23, + 0x03, 0x0b, 0x0b, 0x73, 0xc7, 0x0a, 0x16, 0xc4, 0x50, 0xa1, 0x04, 0x89, 0xbf, 0x81, 0x62, 0x3b, + 0x84, 0xe4, 0xae, 0xd0, 0x95, 0x25, 0x3a, 0xfb, 0xbd, 0xef, 0x7d, 0xef, 0x7b, 0xf9, 0x0c, 0xad, + 0x98, 0x0a, 0x1a, 0x0f, 0x28, 0x8e, 0x44, 0x88, 0x07, 0x35, 0xdc, 0xeb, 0xd3, 0x78, 0xe8, 0x46, + 0x31, 0x97, 0x1c, 0x5d, 0x32, 0x98, 0x1b, 0x89, 0xd0, 0x1d, 0xd4, 0xac, 0x55, 0x12, 0xfa, 0x8c, + 0x63, 0xf5, 0xab, 0x29, 0x56, 0xde, 0xe3, 0x1e, 0x57, 0x9f, 0x78, 0xf2, 0x65, 0x6e, 0xaf, 0x7a, + 0x9c, 0x7b, 0x01, 0xc5, 0x24, 0xf2, 0x31, 0x61, 0x8c, 0x4b, 0x22, 0x7d, 0xce, 0x84, 0x41, 0xab, + 0x5d, 0x2e, 0x42, 0x2e, 0x70, 0x87, 0x08, 0xaa, 0xfb, 0xe1, 0x41, 0xad, 0x43, 0x25, 0xa9, 0xe1, + 0x88, 0x78, 0x3e, 0x53, 0x64, 0xc3, 0x2d, 0x2d, 0xd8, 0x8b, 0x48, 0x4c, 0xc2, 0xa9, 0x50, 0x61, + 0x11, 0x14, 0xa1, 0x41, 0x8a, 0xba, 0x45, 0x5b, 0x3b, 0xd3, 0x07, 0x0d, 0x39, 0x79, 0x88, 0x76, + 0x27, 0x3d, 0x77, 0x94, 0x52, 0x8b, 0xf6, 0xfa, 0x54, 0x48, 0x67, 0x07, 0x5e, 0x99, 0xbb, 0x15, + 0x11, 0x67, 0x82, 0xa2, 0x7b, 0x30, 0xa7, 0x3b, 0x16, 0x40, 0x19, 0x54, 0x56, 0xea, 0xeb, 0xee, + 0x7c, 0x24, 0xae, 0xe6, 0x37, 0x96, 0x8f, 0x4e, 0x36, 0x33, 0xef, 0x7e, 0xbe, 0xaf, 0x82, 0x96, + 0x29, 0x70, 0x5c, 0xb8, 0xae, 0x14, 0x1f, 0x49, 0xd2, 0x09, 0x68, 0x97, 0xfb, 0xcc, 0xf4, 0x42, + 0x79, 0xb8, 0xb4, 0x4f, 0x19, 0x0f, 0x95, 0xe6, 0x72, 0x4b, 0x1f, 0x9c, 0x4f, 0x00, 0x6e, 0x24, + 0x0a, 0x8c, 0x8d, 0x07, 0x10, 0x8a, 0xdf, 0xb7, 0xc6, 0x8a, 0x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 0xdc, 0x5c, 0x53, 0x6e, 0x4a, 0xa8, 0xb8, 0xe0, 0x66, 0xf6, 0xb4, 0xd1, 0x2b, 0x00, 0x2f, 0xce, + 0xed, 0x0f, 0xba, 0x95, 0xaa, 0x9e, 0xb6, 0x80, 0x56, 0xf5, 0x2c, 0xd4, 0x33, 0x7b, 0x69, 0x3c, + 0x3c, 0x1a, 0xd9, 0xe0, 0x78, 0x64, 0x83, 0xef, 0x23, 0x1b, 0xbc, 0x1e, 0xdb, 0x99, 0xe3, 0xb1, + 0x9d, 0xf9, 0x3a, 0xb6, 0x33, 0x7b, 0xdb, 0x9e, 0x2f, 0x0f, 0xfa, 0x1d, 0xb7, 0xcb, 0xc3, 0x53, + 0x82, 0x3d, 0x54, 0x42, 0x72, 0x18, 0x51, 0xd1, 0xc9, 0x29, 0xf4, 0xee, 0xaf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x11, 0xce, 0x91, 0xf7, 0x87, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -515,6 +515,7 @@ func _Query_AllStablecoin_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +var Query_serviceDesc = _Query_serviceDesc var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "reserve.psm.v1.Query", HandlerType: (*QueryServer)(nil), diff --git a/x/psm/types/tx.pb.go b/x/psm/types/tx.pb.go index d8abd3a9..2b360f70 100644 --- a/x/psm/types/tx.pb.go +++ b/x/psm/types/tx.pb.go @@ -128,204 +128,19 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo -type MsgSwapToNom struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Coin types.Coin `protobuf:"bytes,2,opt,name=coin,proto3" json:"coin"` -} - -func (m *MsgSwapToNom) Reset() { *m = MsgSwapToNom{} } -func (m *MsgSwapToNom) String() string { return proto.CompactTextString(m) } -func (*MsgSwapToNom) ProtoMessage() {} -func (*MsgSwapToNom) Descriptor() ([]byte, []int) { - return fileDescriptor_d0ff2d5421e71e2a, []int{2} -} -func (m *MsgSwapToNom) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSwapToNom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSwapToNom.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSwapToNom) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSwapToNom.Merge(m, src) -} -func (m *MsgSwapToNom) XXX_Size() int { - return m.Size() -} -func (m *MsgSwapToNom) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSwapToNom.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSwapToNom proto.InternalMessageInfo - -func (m *MsgSwapToNom) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *MsgSwapToNom) GetCoin() types.Coin { - if m != nil { - return m.Coin - } - return types.Coin{} -} - -type MsgSwapToNomResponse struct { -} - -func (m *MsgSwapToNomResponse) Reset() { *m = MsgSwapToNomResponse{} } -func (m *MsgSwapToNomResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSwapToNomResponse) ProtoMessage() {} -func (*MsgSwapToNomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d0ff2d5421e71e2a, []int{3} -} -func (m *MsgSwapToNomResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSwapToNomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSwapToNomResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSwapToNomResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSwapToNomResponse.Merge(m, src) -} -func (m *MsgSwapToNomResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgSwapToNomResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSwapToNomResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSwapToNomResponse proto.InternalMessageInfo - -type MsgSwapToStablecoin struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - ToDenom string `protobuf:"bytes,2,opt,name=to_denom,json=toDenom,proto3" json:"to_denom,omitempty"` - Coin types.Coin `protobuf:"bytes,3,opt,name=coin,proto3" json:"coin"` -} - -func (m *MsgSwapToStablecoin) Reset() { *m = MsgSwapToStablecoin{} } -func (m *MsgSwapToStablecoin) String() string { return proto.CompactTextString(m) } -func (*MsgSwapToStablecoin) ProtoMessage() {} -func (*MsgSwapToStablecoin) Descriptor() ([]byte, []int) { - return fileDescriptor_d0ff2d5421e71e2a, []int{4} -} -func (m *MsgSwapToStablecoin) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSwapToStablecoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSwapToStablecoin.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSwapToStablecoin) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSwapToStablecoin.Merge(m, src) -} -func (m *MsgSwapToStablecoin) XXX_Size() int { - return m.Size() -} -func (m *MsgSwapToStablecoin) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSwapToStablecoin.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSwapToStablecoin proto.InternalMessageInfo - -func (m *MsgSwapToStablecoin) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func (m *MsgSwapToStablecoin) GetToDenom() string { - if m != nil { - return m.ToDenom - } - return "" -} - -func (m *MsgSwapToStablecoin) GetCoin() types.Coin { - if m != nil { - return m.Coin - } - return types.Coin{} -} - -type MsgSwapToStablecoinResponse struct { -} - -func (m *MsgSwapToStablecoinResponse) Reset() { *m = MsgSwapToStablecoinResponse{} } -func (m *MsgSwapToStablecoinResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSwapToStablecoinResponse) ProtoMessage() {} -func (*MsgSwapToStablecoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d0ff2d5421e71e2a, []int{5} -} -func (m *MsgSwapToStablecoinResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSwapToStablecoinResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSwapToStablecoinResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MsgSwapToStablecoinResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSwapToStablecoinResponse.Merge(m, src) -} -func (m *MsgSwapToStablecoinResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgSwapToStablecoinResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSwapToStablecoinResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSwapToStablecoinResponse proto.InternalMessageInfo - type MsgAddStableCoin struct { Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` FeeOut cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=fee_out,json=feeOut,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_out"` - NomType string `protobuf:"bytes,6,opt,name=nom_type,json=nomType,proto3" json:"nom_type,omitempty"` } func (m *MsgAddStableCoin) Reset() { *m = MsgAddStableCoin{} } func (m *MsgAddStableCoin) String() string { return proto.CompactTextString(m) } func (*MsgAddStableCoin) ProtoMessage() {} func (*MsgAddStableCoin) Descriptor() ([]byte, []int) { - return fileDescriptor_d0ff2d5421e71e2a, []int{6} + return fileDescriptor_d0ff2d5421e71e2a, []int{2} } func (m *MsgAddStableCoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -368,13 +183,6 @@ func (m *MsgAddStableCoin) GetDenom() string { return "" } -func (m *MsgAddStableCoin) GetNomType() string { - if m != nil { - return m.NomType - } - return "" -} - type MsgAddStableCoinResponse struct { } @@ -382,7 +190,7 @@ func (m *MsgAddStableCoinResponse) Reset() { *m = MsgAddStableCoinRespon func (m *MsgAddStableCoinResponse) String() string { return proto.CompactTextString(m) } func (*MsgAddStableCoinResponse) ProtoMessage() {} func (*MsgAddStableCoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d0ff2d5421e71e2a, []int{7} + return fileDescriptor_d0ff2d5421e71e2a, []int{3} } func (m *MsgAddStableCoinResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -417,14 +225,13 @@ type MsgUpdatesStableCoin struct { LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` FeeOut cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=fee_out,json=feeOut,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_out"` - NomType string `protobuf:"bytes,6,opt,name=nom_type,json=nomType,proto3" json:"nom_type,omitempty"` } func (m *MsgUpdatesStableCoin) Reset() { *m = MsgUpdatesStableCoin{} } func (m *MsgUpdatesStableCoin) String() string { return proto.CompactTextString(m) } func (*MsgUpdatesStableCoin) ProtoMessage() {} func (*MsgUpdatesStableCoin) Descriptor() ([]byte, []int) { - return fileDescriptor_d0ff2d5421e71e2a, []int{8} + return fileDescriptor_d0ff2d5421e71e2a, []int{4} } func (m *MsgUpdatesStableCoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -467,13 +274,6 @@ func (m *MsgUpdatesStableCoin) GetDenom() string { return "" } -func (m *MsgUpdatesStableCoin) GetNomType() string { - if m != nil { - return m.NomType - } - return "" -} - type MsgUpdatesStableCoinResponse struct { } @@ -481,7 +281,7 @@ func (m *MsgUpdatesStableCoinResponse) Reset() { *m = MsgUpdatesStableCo func (m *MsgUpdatesStableCoinResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdatesStableCoinResponse) ProtoMessage() {} func (*MsgUpdatesStableCoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d0ff2d5421e71e2a, []int{9} + return fileDescriptor_d0ff2d5421e71e2a, []int{5} } func (m *MsgUpdatesStableCoinResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -510,71 +310,162 @@ func (m *MsgUpdatesStableCoinResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdatesStableCoinResponse proto.InternalMessageInfo +type MsgStableSwap struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + ExpectedDenom string `protobuf:"bytes,2,opt,name=expected_denom,json=expectedDenom,proto3" json:"expected_denom,omitempty"` + OfferCoin types.Coin `protobuf:"bytes,3,opt,name=offer_coin,json=offerCoin,proto3" json:"offer_coin"` +} + +func (m *MsgStableSwap) Reset() { *m = MsgStableSwap{} } +func (m *MsgStableSwap) String() string { return proto.CompactTextString(m) } +func (*MsgStableSwap) ProtoMessage() {} +func (*MsgStableSwap) Descriptor() ([]byte, []int) { + return fileDescriptor_d0ff2d5421e71e2a, []int{6} +} +func (m *MsgStableSwap) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgStableSwap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgStableSwap.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgStableSwap) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgStableSwap.Merge(m, src) +} +func (m *MsgStableSwap) XXX_Size() int { + return m.Size() +} +func (m *MsgStableSwap) XXX_DiscardUnknown() { + xxx_messageInfo_MsgStableSwap.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgStableSwap proto.InternalMessageInfo + +func (m *MsgStableSwap) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *MsgStableSwap) GetExpectedDenom() string { + if m != nil { + return m.ExpectedDenom + } + return "" +} + +func (m *MsgStableSwap) GetOfferCoin() types.Coin { + if m != nil { + return m.OfferCoin + } + return types.Coin{} +} + +type MsgStableSwapResponse struct { +} + +func (m *MsgStableSwapResponse) Reset() { *m = MsgStableSwapResponse{} } +func (m *MsgStableSwapResponse) String() string { return proto.CompactTextString(m) } +func (*MsgStableSwapResponse) ProtoMessage() {} +func (*MsgStableSwapResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d0ff2d5421e71e2a, []int{7} +} +func (m *MsgStableSwapResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgStableSwapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgStableSwapResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgStableSwapResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgStableSwapResponse.Merge(m, src) +} +func (m *MsgStableSwapResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgStableSwapResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgStableSwapResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgStableSwapResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgUpdateParams)(nil), "reserve.psm.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "reserve.psm.v1.MsgUpdateParamsResponse") - proto.RegisterType((*MsgSwapToNom)(nil), "reserve.psm.v1.MsgSwapToNom") - proto.RegisterType((*MsgSwapToNomResponse)(nil), "reserve.psm.v1.MsgSwapToNomResponse") - proto.RegisterType((*MsgSwapToStablecoin)(nil), "reserve.psm.v1.MsgSwapToStablecoin") - proto.RegisterType((*MsgSwapToStablecoinResponse)(nil), "reserve.psm.v1.MsgSwapToStablecoinResponse") proto.RegisterType((*MsgAddStableCoin)(nil), "reserve.psm.v1.MsgAddStableCoin") proto.RegisterType((*MsgAddStableCoinResponse)(nil), "reserve.psm.v1.MsgAddStableCoinResponse") proto.RegisterType((*MsgUpdatesStableCoin)(nil), "reserve.psm.v1.MsgUpdatesStableCoin") proto.RegisterType((*MsgUpdatesStableCoinResponse)(nil), "reserve.psm.v1.MsgUpdatesStableCoinResponse") + proto.RegisterType((*MsgStableSwap)(nil), "reserve.psm.v1.MsgStableSwap") + proto.RegisterType((*MsgStableSwapResponse)(nil), "reserve.psm.v1.MsgStableSwapResponse") } func init() { proto.RegisterFile("reserve/psm/v1/tx.proto", fileDescriptor_d0ff2d5421e71e2a) } var fileDescriptor_d0ff2d5421e71e2a = []byte{ - // 763 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0x4f, 0x4f, 0x13, 0x5b, - 0x14, 0xef, 0xbc, 0xd2, 0xf2, 0x7a, 0x69, 0xde, 0xe3, 0xcd, 0x2b, 0x30, 0x1d, 0x60, 0x20, 0x95, - 0x44, 0x82, 0x30, 0x43, 0x31, 0x1a, 0x65, 0x47, 0x25, 0x46, 0x8c, 0x15, 0x2c, 0x98, 0x18, 0x37, - 0xcd, 0xed, 0xcc, 0x65, 0x98, 0xd8, 0x3b, 0x77, 0x32, 0xf7, 0xb6, 0xd2, 0x9d, 0x71, 0xe9, 0xca, - 0xb8, 0x71, 0xe9, 0xd6, 0x25, 0x0b, 0xe2, 0x67, 0x60, 0x49, 0x58, 0x19, 0x17, 0xc4, 0xc0, 0x82, - 0x0f, 0xe0, 0x17, 0x30, 0x77, 0xee, 0x74, 0xfa, 0x97, 0x3f, 0xc1, 0xb8, 0x73, 0x43, 0x38, 0xe7, - 0x77, 0xce, 0xef, 0xfc, 0xce, 0x3d, 0x67, 0x4e, 0xc1, 0x98, 0x8f, 0x28, 0xf2, 0xeb, 0xc8, 0xf0, - 0x28, 0x36, 0xea, 0x79, 0x83, 0xed, 0xea, 0x9e, 0x4f, 0x18, 0x91, 0xff, 0x09, 0x01, 0xdd, 0xa3, - 0x58, 0xaf, 0xe7, 0xd5, 0xff, 0x20, 0x76, 0x5c, 0x62, 0x04, 0x7f, 0x45, 0x88, 0x3a, 0x66, 0x12, - 0x8a, 0x09, 0x35, 0x30, 0xb5, 0x79, 0x2a, 0xa6, 0x76, 0x08, 0x64, 0x05, 0x50, 0x0e, 0x2c, 0x43, - 0x18, 0x21, 0x94, 0xb1, 0x89, 0x4d, 0x84, 0x9f, 0xff, 0x17, 0x7a, 0xc7, 0xbb, 0x54, 0x78, 0xd0, - 0x87, 0xb8, 0x99, 0xa2, 0x85, 0x65, 0x2a, 0x90, 0x22, 0xa3, 0x9e, 0xaf, 0x20, 0x06, 0xf3, 0x86, - 0x49, 0x1c, 0x57, 0xe0, 0xb9, 0x2f, 0x12, 0xf8, 0xb7, 0x48, 0xed, 0xe7, 0x9e, 0x05, 0x19, 0xda, - 0x08, 0x32, 0xe5, 0xbb, 0x20, 0x05, 0x6b, 0x6c, 0x87, 0xf8, 0x0e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0x20, 0x72, 0x1a, 0x98, 0xe8, 0xe7, 0x6f, - 0x4e, 0x70, 0xe9, 0x47, 0x1c, 0xc4, 0x8b, 0xd4, 0x96, 0x5f, 0x80, 0x74, 0xc7, 0x35, 0x9e, 0xea, - 0xbe, 0xa2, 0x5d, 0x67, 0x4f, 0xbd, 0x79, 0x49, 0x40, 0xb3, 0x82, 0x6c, 0x82, 0x91, 0x8e, 0xe5, - 0xd9, 0xf0, 0x89, 0x47, 0x28, 0xac, 0xca, 0xd3, 0x7d, 0x18, 0x3a, 0x22, 0xd5, 0xd9, 0xcb, 0x22, - 0xa2, 0x22, 0x04, 0x64, 0x7b, 0x7a, 0x8c, 0x0a, 0xcd, 0x9c, 0x2b, 0xb5, 0x2d, 0x5a, 0x9d, 0xbf, - 0x4a, 0x54, 0x54, 0x70, 0x1d, 0xa4, 0x5a, 0xa7, 0x7e, 0xa2, 0x4f, 0x6a, 0x84, 0xaa, 0x33, 0x17, - 0xa1, 0x11, 0xa1, 0x05, 0x86, 0x7b, 0x0e, 0xf6, 0x8d, 0x73, 0x33, 0x5b, 0x41, 0xea, 0xad, 0x2b, - 0x04, 0x35, 0xab, 0xa8, 0x89, 0x37, 0xfc, 0x4b, 0x28, 0x3c, 0x3c, 0x38, 0xd1, 0xa4, 0xc3, 0x13, - 0x4d, 0xfa, 0x7e, 0xa2, 0x49, 0xef, 0x4f, 0xb5, 0xd8, 0xe1, 0xa9, 0x16, 0xfb, 0x7a, 0xaa, 0xc5, - 0x5e, 0xce, 0xdb, 0x0e, 0xdb, 0xa9, 0x55, 0x74, 0x93, 0x60, 0x83, 0xb8, 0x04, 0x37, 0x82, 0x1f, - 0x6c, 0x93, 0x54, 0x8d, 0xce, 0x65, 0xe3, 0x2b, 0x4a, 0x2b, 0xc9, 0x00, 0xbd, 0xfd, 0x33, 0x00, - 0x00, 0xff, 0xff, 0xc0, 0x4e, 0x98, 0x0e, 0x93, 0x08, 0x00, 0x00, + // 716 bytes of a gzipped FileDescriptorProto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, 0xd9, 0xa0, 0xce, 0x8f, 0xae, 0x4e, 0xf8, 0x72, 0xe3, 0xce, 0x72, 0x1e, 0xa6, 0x13, + 0x43, 0xc6, 0xe3, 0xaf, 0xec, 0xa5, 0x21, 0x5d, 0xa5, 0x26, 0xff, 0x06, 0x26, 0x12, 0x8b, 0x6d, + 0xae, 0x7f, 0x21, 0xf5, 0x6d, 0x10, 0xf1, 0xfe, 0x15, 0x09, 0x71, 0x07, 0x5e, 0x87, 0xe9, 0xc4, + 0x03, 0xdf, 0xf2, 0x88, 0x4b, 0x28, 0x6a, 0xf2, 0xc5, 0x21, 0x0c, 0x89, 0x4c, 0xb1, 0x74, 0x55, + 0x46, 0xb7, 0x09, 0x81, 0xc2, 0x80, 0x45, 0xdd, 0x46, 0xf7, 0x2e, 0x1d, 0xb5, 0x27, 0x5b, 0x5c, + 0xfc, 0x9b, 0xac, 0x6e, 0x43, 0x0d, 0xa0, 0xc7, 0xf2, 0xd9, 0x21, 0xb5, 0x17, 0xb0, 0x38, 0xff, + 0x47, 0x38, 0xe6, 0x14, 0x33, 0x1f, 0x7c, 0x13, 0x2b, 0x4f, 0x0e, 0x4f, 0x25, 0xee, 0xe8, 0x54, + 0xe2, 0x7e, 0x9e, 0x4a, 0xdc, 0xde, 0x99, 0x94, 0x3a, 0x3a, 0x93, 0x52, 0xdf, 0xcf, 0xa4, 0xd4, + 0xdb, 0x45, 0xd3, 0x62, 0x3b, 0xad, 0xba, 0xa2, 0x13, 0x5b, 0x25, 0x0e, 0xb1, 0x3b, 0xc1, 0x1f, + 0x93, 0x4e, 0x9a, 0x6a, 0xf2, 0x21, 0xb3, 0x8e, 0x8b, 0x69, 0x7d, 0x34, 0x40, 0x1f, 0xfc, 0x0e, + 0x00, 0x00, 0xff, 0xff, 0x0d, 0xfe, 0x18, 0xec, 0x7b, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -594,8 +485,7 @@ type MsgClient interface { UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) AddStableCoinProposal(ctx context.Context, in *MsgAddStableCoin, opts ...grpc.CallOption) (*MsgAddStableCoinResponse, error) UpdatesStableCoinProposal(ctx context.Context, in *MsgUpdatesStableCoin, opts ...grpc.CallOption) (*MsgUpdatesStableCoinResponse, error) - SwapToNom(ctx context.Context, in *MsgSwapToNom, opts ...grpc.CallOption) (*MsgSwapToNomResponse, error) - SwapToStablecoin(ctx context.Context, in *MsgSwapToStablecoin, opts ...grpc.CallOption) (*MsgSwapToStablecoinResponse, error) + StableSwap(ctx context.Context, in *MsgStableSwap, opts ...grpc.CallOption) (*MsgStableSwapResponse, error) } type msgClient struct { @@ -633,18 +523,9 @@ func (c *msgClient) UpdatesStableCoinProposal(ctx context.Context, in *MsgUpdate return out, nil } -func (c *msgClient) SwapToNom(ctx context.Context, in *MsgSwapToNom, opts ...grpc.CallOption) (*MsgSwapToNomResponse, error) { - out := new(MsgSwapToNomResponse) - err := c.cc.Invoke(ctx, "/reserve.psm.v1.Msg/SwapToNom", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) SwapToStablecoin(ctx context.Context, in *MsgSwapToStablecoin, opts ...grpc.CallOption) (*MsgSwapToStablecoinResponse, error) { - out := new(MsgSwapToStablecoinResponse) - err := c.cc.Invoke(ctx, "/reserve.psm.v1.Msg/SwapToStablecoin", in, out, opts...) +func (c *msgClient) StableSwap(ctx context.Context, in *MsgStableSwap, opts ...grpc.CallOption) (*MsgStableSwapResponse, error) { + out := new(MsgStableSwapResponse) + err := c.cc.Invoke(ctx, "/reserve.psm.v1.Msg/StableSwap", in, out, opts...) if err != nil { return nil, err } @@ -658,8 +539,7 @@ type MsgServer interface { UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) AddStableCoinProposal(context.Context, *MsgAddStableCoin) (*MsgAddStableCoinResponse, error) UpdatesStableCoinProposal(context.Context, *MsgUpdatesStableCoin) (*MsgUpdatesStableCoinResponse, error) - SwapToNom(context.Context, *MsgSwapToNom) (*MsgSwapToNomResponse, error) - SwapToStablecoin(context.Context, *MsgSwapToStablecoin) (*MsgSwapToStablecoinResponse, error) + StableSwap(context.Context, *MsgStableSwap) (*MsgStableSwapResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -675,11 +555,8 @@ func (*UnimplementedMsgServer) AddStableCoinProposal(ctx context.Context, req *M func (*UnimplementedMsgServer) UpdatesStableCoinProposal(ctx context.Context, req *MsgUpdatesStableCoin) (*MsgUpdatesStableCoinResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdatesStableCoinProposal not implemented") } -func (*UnimplementedMsgServer) SwapToNom(ctx context.Context, req *MsgSwapToNom) (*MsgSwapToNomResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SwapToNom not implemented") -} -func (*UnimplementedMsgServer) SwapToStablecoin(ctx context.Context, req *MsgSwapToStablecoin) (*MsgSwapToStablecoinResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SwapToStablecoin not implemented") +func (*UnimplementedMsgServer) StableSwap(ctx context.Context, req *MsgStableSwap) (*MsgStableSwapResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StableSwap not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -740,42 +617,25 @@ func _Msg_UpdatesStableCoinProposal_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } -func _Msg_SwapToNom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSwapToNom) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).SwapToNom(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/reserve.psm.v1.Msg/SwapToNom", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SwapToNom(ctx, req.(*MsgSwapToNom)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_SwapToStablecoin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSwapToStablecoin) +func _Msg_StableSwap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgStableSwap) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).SwapToStablecoin(ctx, in) + return srv.(MsgServer).StableSwap(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/reserve.psm.v1.Msg/SwapToStablecoin", + FullMethod: "/reserve.psm.v1.Msg/StableSwap", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SwapToStablecoin(ctx, req.(*MsgSwapToStablecoin)) + return srv.(MsgServer).StableSwap(ctx, req.(*MsgStableSwap)) } return interceptor(ctx, in, info, handler) } +var Msg_serviceDesc = _Msg_serviceDesc var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "reserve.psm.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -793,12 +653,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_UpdatesStableCoinProposal_Handler, }, { - MethodName: "SwapToNom", - Handler: _Msg_SwapToNom_Handler, - }, - { - MethodName: "SwapToStablecoin", - Handler: _Msg_SwapToStablecoin_Handler, + MethodName: "StableSwap", + Handler: _Msg_StableSwap_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -868,7 +724,7 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *MsgSwapToNom) Marshal() (dAtA []byte, err error) { +func (m *MsgAddStableCoin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -878,107 +734,64 @@ func (m *MsgSwapToNom) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSwapToNom) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddStableCoin) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSwapToNom) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddStableCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.FeeOut.Size() + i -= size + if _, err := m.FeeOut.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.FeeIn.Size() + i -= size + if _, err := m.FeeIn.MarshalTo(dAtA[i:]); err != nil { return 0, err } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.LimitTotal.Size() i -= size + if _, err := m.LimitTotal.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + dAtA[i] = 0x1a + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x12 + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgSwapToNomResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgSwapToNomResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSwapToNomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *MsgSwapToStablecoin) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MsgSwapToStablecoin) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSwapToStablecoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Coin.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ToDenom) > 0 { - i -= len(m.ToDenom) - copy(dAtA[i:], m.ToDenom) - i = encodeVarintTx(dAtA, i, uint64(len(m.ToDenom))) - i-- - dAtA[i] = 0x12 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgSwapToStablecoinResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgAddStableCoinResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -988,12 +801,12 @@ func (m *MsgSwapToStablecoinResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSwapToStablecoinResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgAddStableCoinResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSwapToStablecoinResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgAddStableCoinResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1001,7 +814,7 @@ func (m *MsgSwapToStablecoinResponse) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *MsgAddStableCoin) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdatesStableCoin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1011,23 +824,16 @@ func (m *MsgAddStableCoin) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddStableCoin) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdatesStableCoin) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddStableCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdatesStableCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.NomType) > 0 { - i -= len(m.NomType) - copy(dAtA[i:], m.NomType) - i = encodeVarintTx(dAtA, i, uint64(len(m.NomType))) - i-- - dAtA[i] = 0x32 - } { size := m.FeeOut.Size() i -= size @@ -1075,7 +881,7 @@ func (m *MsgAddStableCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MsgAddStableCoinResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdatesStableCoinResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1085,12 +891,12 @@ func (m *MsgAddStableCoinResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgAddStableCoinResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdatesStableCoinResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgAddStableCoinResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdatesStableCoinResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1098,7 +904,7 @@ func (m *MsgAddStableCoinResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *MsgUpdatesStableCoin) Marshal() (dAtA []byte, err error) { +func (m *MsgStableSwap) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1108,71 +914,44 @@ func (m *MsgUpdatesStableCoin) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdatesStableCoin) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgStableSwap) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdatesStableCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgStableSwap) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.NomType) > 0 { - i -= len(m.NomType) - copy(dAtA[i:], m.NomType) - i = encodeVarintTx(dAtA, i, uint64(len(m.NomType))) - i-- - dAtA[i] = 0x32 - } { - size := m.FeeOut.Size() - i -= size - if _, err := m.FeeOut.MarshalTo(dAtA[i:]); err != nil { + size, err := m.OfferCoin.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.FeeIn.Size() i -= size - if _, err := m.FeeIn.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.LimitTotal.Size() - i -= size - if _, err := m.LimitTotal.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } i = encodeVarintTx(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) + if len(m.ExpectedDenom) > 0 { + i -= len(m.ExpectedDenom) + copy(dAtA[i:], m.ExpectedDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.ExpectedDenom))) i-- dAtA[i] = 0x12 } - if len(m.Authority) > 0 { - i -= len(m.Authority) - copy(dAtA[i:], m.Authority) - i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgUpdatesStableCoinResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgStableSwapResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1182,12 +961,12 @@ func (m *MsgUpdatesStableCoinResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdatesStableCoinResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgStableSwapResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdatesStableCoinResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgStableSwapResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1230,50 +1009,30 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } -func (m *MsgSwapToNom) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.Coin.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgSwapToNomResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *MsgSwapToStablecoin) Size() (n int) { +func (m *MsgAddStableCoin) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Address) + l = len(m.Authority) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.ToDenom) + l = len(m.Denom) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.Coin.Size() + l = m.LimitTotal.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.FeeIn.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.FeeOut.Size() n += 1 + l + sovTx(uint64(l)) return n } -func (m *MsgSwapToStablecoinResponse) Size() (n int) { +func (m *MsgAddStableCoinResponse) Size() (n int) { if m == nil { return 0 } @@ -1282,7 +1041,7 @@ func (m *MsgSwapToStablecoinResponse) Size() (n int) { return n } -func (m *MsgAddStableCoin) Size() (n int) { +func (m *MsgUpdatesStableCoin) Size() (n int) { if m == nil { return 0 } @@ -1302,14 +1061,10 @@ func (m *MsgAddStableCoin) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.FeeOut.Size() n += 1 + l + sovTx(uint64(l)) - l = len(m.NomType) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } return n } -func (m *MsgAddStableCoinResponse) Size() (n int) { +func (m *MsgUpdatesStableCoinResponse) Size() (n int) { if m == nil { return 0 } @@ -1318,34 +1073,26 @@ func (m *MsgAddStableCoinResponse) Size() (n int) { return n } -func (m *MsgUpdatesStableCoin) Size() (n int) { +func (m *MsgStableSwap) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Authority) + l = len(m.Address) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Denom) + l = len(m.ExpectedDenom) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.LimitTotal.Size() + l = m.OfferCoin.Size() n += 1 + l + sovTx(uint64(l)) - l = m.FeeIn.Size() - n += 1 + l + sovTx(uint64(l)) - l = m.FeeOut.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.NomType) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } return n } -func (m *MsgUpdatesStableCoinResponse) Size() (n int) { +func (m *MsgStableSwapResponse) Size() (n int) { if m == nil { return 0 } @@ -1386,177 +1133,12 @@ func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Authority = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgSwapToNom) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MsgSwapToNom: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSwapToNom: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1584,11 +1166,11 @@ func (m *MsgSwapToNom) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1615,7 +1197,7 @@ func (m *MsgSwapToNom) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1640,7 +1222,7 @@ func (m *MsgSwapToNom) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSwapToNomResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1663,10 +1245,10 @@ func (m *MsgSwapToNomResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSwapToNomResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSwapToNomResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1690,7 +1272,7 @@ func (m *MsgSwapToNomResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSwapToStablecoin) Unmarshal(dAtA []byte) error { +func (m *MsgAddStableCoin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1713,15 +1295,15 @@ func (m *MsgSwapToStablecoin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSwapToStablecoin: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAddStableCoin: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSwapToStablecoin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAddStableCoin: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1749,11 +1331,11 @@ func (m *MsgSwapToStablecoin) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Authority = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ToDenom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1781,13 +1363,13 @@ func (m *MsgSwapToStablecoin) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ToDenom = string(dAtA[iNdEx:postIndex]) + m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Coin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LimitTotal", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1797,22 +1379,88 @@ func (m *MsgSwapToStablecoin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.LimitTotal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeIn", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.FeeIn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeOut", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Coin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.FeeOut.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1837,7 +1485,7 @@ func (m *MsgSwapToStablecoin) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSwapToStablecoinResponse) Unmarshal(dAtA []byte) error { +func (m *MsgAddStableCoinResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1860,10 +1508,10 @@ func (m *MsgSwapToStablecoinResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSwapToStablecoinResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAddStableCoinResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSwapToStablecoinResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAddStableCoinResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1887,7 +1535,7 @@ func (m *MsgSwapToStablecoinResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAddStableCoin) Unmarshal(dAtA []byte) error { +func (m *MsgUpdatesStableCoin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1910,10 +1558,10 @@ func (m *MsgAddStableCoin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddStableCoin: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdatesStableCoin: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddStableCoin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdatesStableCoin: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2079,38 +1727,6 @@ func (m *MsgAddStableCoin) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NomType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NomType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2132,7 +1748,7 @@ func (m *MsgAddStableCoin) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgAddStableCoinResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdatesStableCoinResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2155,10 +1771,10 @@ func (m *MsgAddStableCoinResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgAddStableCoinResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdatesStableCoinResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgAddStableCoinResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdatesStableCoinResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -2182,7 +1798,7 @@ func (m *MsgAddStableCoinResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdatesStableCoin) Unmarshal(dAtA []byte) error { +func (m *MsgStableSwap) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2205,15 +1821,15 @@ func (m *MsgUpdatesStableCoin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdatesStableCoin: wiretype end group for non-group") + return fmt.Errorf("proto: MsgStableSwap: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdatesStableCoin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgStableSwap: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2241,11 +1857,11 @@ func (m *MsgUpdatesStableCoin) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Authority = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExpectedDenom", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2273,79 +1889,13 @@ func (m *MsgUpdatesStableCoin) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom = string(dAtA[iNdEx:postIndex]) + m.ExpectedDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LimitTotal", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LimitTotal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeeIn", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.FeeIn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeeOut", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field OfferCoin", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -2355,57 +1905,25 @@ func (m *MsgUpdatesStableCoin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.FeeOut.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.OfferCoin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NomType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NomType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2427,7 +1945,7 @@ func (m *MsgUpdatesStableCoin) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdatesStableCoinResponse) Unmarshal(dAtA []byte) error { +func (m *MsgStableSwapResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2450,10 +1968,10 @@ func (m *MsgUpdatesStableCoinResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdatesStableCoinResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgStableSwapResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdatesStableCoinResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgStableSwapResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From 4f09b4ef1d3ff926ec96fc9f1d97f8ea63ba7dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Fri, 8 Nov 2024 15:38:28 +0700 Subject: [PATCH 35/42] rename --- x/psm/keeper/abci.go | 4 ++-- x/psm/keeper/abci_test.go | 4 ++-- x/psm/keeper/keeper.go | 26 +++++++++++++------------- x/psm/keeper/msg_server.go | 8 ++++---- x/psm/keeper/proposals_test.go | 6 +++--- x/psm/keeper/query.go | 4 ++-- x/psm/keeper/query_test.go | 2 +- x/psm/keeper/stablecoin.go | 6 +++--- x/psm/keeper/stablecoin_test.go | 10 +++++----- x/psm/keeper/swap.go | 4 ++-- x/psm/module/genesis.go | 4 ++-- 11 files changed, 39 insertions(+), 39 deletions(-) diff --git a/x/psm/keeper/abci.go b/x/psm/keeper/abci.go index 0c39eede..6182a5bc 100644 --- a/x/psm/keeper/abci.go +++ b/x/psm/keeper/abci.go @@ -19,14 +19,14 @@ func (k Keeper) UpdatesStablecoinEpoch(ctx context.Context) error { } sc := k.stablecoinUpdate(ctx, *price, info) - err := k.StablecoinInfo.Set(ctx, sc.Denom, sc) + err := k.StablecoinInfos.Set(ctx, sc.Denom, sc) if err != nil { return false } return false } - return k.StablecoinInfo.Walk(ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { + return k.StablecoinInfos.Walk(ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { return updatePrice(value), nil }) //k.IterateStablecoin(ctx, updatePrice) } diff --git a/x/psm/keeper/abci_test.go b/x/psm/keeper/abci_test.go index c35ff4a8..3b042548 100644 --- a/x/psm/keeper/abci_test.go +++ b/x/psm/keeper/abci_test.go @@ -47,7 +47,7 @@ func (s *KeeperTestSuite) TestUpdatesStablecoinEpoch() { FeeOut: t.feeOut, }) s.mockOracleKeeper.SetPrice(s.Ctx, sc.Denom, t.priceCurrent) - err := s.k.StablecoinInfo.Set(s.Ctx, sc.Denom, sc) + err := s.k.StablecoinInfos.Set(s.Ctx, sc.Denom, sc) s.Require().NoError(err) s.mockOracleKeeper.SetPrice(s.Ctx, usdt, t.priceUpdate) @@ -55,7 +55,7 @@ func (s *KeeperTestSuite) TestUpdatesStablecoinEpoch() { err = s.k.UpdatesStablecoinEpoch(s.Ctx) s.Require().NoError(err) - scUpdate, err := s.k.StablecoinInfo.Get(s.Ctx, usdt) + scUpdate, err := s.k.StablecoinInfos.Get(s.Ctx, usdt) s.Require().NoError(err) // s.Require().Equal(t.priceUpdate, scUpdate.Price) s.Require().Equal(t.expectFeeIn.String(), scUpdate.FeeIn.String()) diff --git a/x/psm/keeper/keeper.go b/x/psm/keeper/keeper.go index 5dcf8b7b..aa99faf8 100644 --- a/x/psm/keeper/keeper.go +++ b/x/psm/keeper/keeper.go @@ -36,8 +36,8 @@ type ( AccountKeeper types.AccountKeeper OracleKeeper types.OracleKeeper - StablecoinInfo collections.Map[string, types.StablecoinInfo] - Noms collections.Map[string, string] + StablecoinInfos collections.Map[string, types.StablecoinInfo] + Noms collections.Map[string, string] } ) @@ -65,12 +65,12 @@ func NewKeeper( authority: authority, // logger: logger, - BankKeeper: bankKeeper, - AccountKeeper: accountKeeper, - OracleKeeper: oracleKeeper, - Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), - StablecoinInfo: collections.NewMap(sb, types.KeyStableCoin, "stablecoins", collections.StringKey, codec.CollValue[types.StablecoinInfo](cdc)), - Noms: collections.NewMap(sb, types.KeyNoms, "nomtypes", collections.StringKey, collections.StringValue), + BankKeeper: bankKeeper, + AccountKeeper: accountKeeper, + OracleKeeper: oracleKeeper, + Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), + StablecoinInfos: collections.NewMap(sb, types.KeyStableCoin, "stablecoins", collections.StringKey, codec.CollValue[types.StablecoinInfo](cdc)), + Noms: collections.NewMap(sb, types.KeyNoms, "nomtypes", collections.StringKey, collections.StringValue), } schema, err := sb.Build() @@ -93,7 +93,7 @@ func (k Keeper) Logger() log.Logger { } func (k Keeper) TotalStablecoinLock(ctx context.Context, nameStablecoin string) (math.Int, error) { - sc, err := k.StablecoinInfo.Get(ctx, nameStablecoin) + sc, err := k.StablecoinInfos.Get(ctx, nameStablecoin) if err != nil { return math.Int{}, fmt.Errorf("canot found stablecoin name %s", nameStablecoin) } @@ -102,7 +102,7 @@ func (k Keeper) TotalStablecoinLock(ctx context.Context, nameStablecoin string) } func (k Keeper) AddTotalStablecoinLock(ctx context.Context, amountAdd sdk.Coin) error { - sc, err := k.StablecoinInfo.Get(ctx, amountAdd.Denom) + sc, err := k.StablecoinInfos.Get(ctx, amountAdd.Denom) if err != nil { return fmt.Errorf("canot found stablecoin name %s", amountAdd.Denom) } @@ -112,11 +112,11 @@ func (k Keeper) AddTotalStablecoinLock(ctx context.Context, amountAdd sdk.Coin) return fmt.Errorf("exceed limitTotal stablecoin %s", amountAdd.Denom) } - return k.StablecoinInfo.Set(ctx, sc.Denom, sc) + return k.StablecoinInfos.Set(ctx, sc.Denom, sc) } func (k Keeper) SubTotalStablecoinLock(ctx context.Context, amountSub sdk.Coin) error { - sc, err := k.StablecoinInfo.Get(ctx, amountSub.Denom) + sc, err := k.StablecoinInfos.Get(ctx, amountSub.Denom) if err != nil { return fmt.Errorf("canot found stablecoin name %s", amountSub.Denom) } @@ -125,5 +125,5 @@ func (k Keeper) SubTotalStablecoinLock(ctx context.Context, amountSub sdk.Coin) if sc.TotalStablecoinLock.LT(math.ZeroInt()) { return fmt.Errorf("not enough stablecoins %s to pay", amountSub.Denom) } - return k.StablecoinInfo.Set(ctx, sc.Denom, sc) + return k.StablecoinInfos.Set(ctx, sc.Denom, sc) } diff --git a/x/psm/keeper/msg_server.go b/x/psm/keeper/msg_server.go index 276f0d10..0e68fff4 100644 --- a/x/psm/keeper/msg_server.go +++ b/x/psm/keeper/msg_server.go @@ -84,12 +84,12 @@ func (k msgServer) AddStableCoinProposal(ctx context.Context, msg *types.MsgAddS return &types.MsgAddStableCoinResponse{}, err } - _, err := k.keeper.StablecoinInfo.Get(ctx, msg.Denom) + _, err := k.keeper.StablecoinInfos.Get(ctx, msg.Denom) if err == nil { return &types.MsgAddStableCoinResponse{}, fmt.Errorf("%s has existed", msg.Denom) } - err = k.keeper.StablecoinInfo.Set(ctx, msg.Denom, types.GetMsgStablecoin(msg)) + err = k.keeper.StablecoinInfos.Set(ctx, msg.Denom, types.GetMsgStablecoin(msg)) if err != nil { return &types.MsgAddStableCoinResponse{}, err } @@ -118,7 +118,7 @@ func (k msgServer) UpdatesStableCoinProposal(ctx context.Context, msg *types.Msg return &types.MsgUpdatesStableCoinResponse{}, err } - oldStablecoin, err := k.keeper.StablecoinInfo.Get(ctx, msg.Denom) + oldStablecoin, err := k.keeper.StablecoinInfos.Get(ctx, msg.Denom) if err != nil { return &types.MsgUpdatesStableCoinResponse{}, fmt.Errorf("%s not existed", msg.Denom) } @@ -126,7 +126,7 @@ func (k msgServer) UpdatesStableCoinProposal(ctx context.Context, msg *types.Msg newStablecoin := types.GetMsgStablecoin(msg) newStablecoin.TotalStablecoinLock = oldStablecoin.TotalStablecoinLock - err = k.keeper.StablecoinInfo.Set(ctx, newStablecoin.Denom, newStablecoin) + err = k.keeper.StablecoinInfos.Set(ctx, newStablecoin.Denom, newStablecoin) if err != nil { return &types.MsgUpdatesStableCoinResponse{}, err } diff --git a/x/psm/keeper/proposals_test.go b/x/psm/keeper/proposals_test.go index 86728399..c3d23486 100644 --- a/x/psm/keeper/proposals_test.go +++ b/x/psm/keeper/proposals_test.go @@ -21,7 +21,7 @@ func (s *KeeperTestSuite) TestAddStableCoinProposal() { _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &proAdd) s.Require().NoError(err) - stablecoin, err := s.k.StablecoinInfo.Get(s.Ctx, proAdd.Denom) + stablecoin, err := s.k.StablecoinInfos.Get(s.Ctx, proAdd.Denom) s.Require().NoError(err) s.Require().Equal(stablecoin.Denom, proAdd.Denom) s.Require().Equal(stablecoin.LimitTotal, limitUSDT) @@ -41,7 +41,7 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() { _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &proAdd) s.Require().NoError(err) - stablecoin, err := s.k.StablecoinInfo.Get(s.Ctx, proAdd.Denom) + stablecoin, err := s.k.StablecoinInfos.Get(s.Ctx, proAdd.Denom) s.Require().NoError(err) s.Require().Equal(stablecoin.Denom, proAdd.Denom) s.Require().Equal(stablecoin.LimitTotal, limitUSDT) @@ -60,7 +60,7 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() { _, err = s.msgServer.UpdatesStableCoinProposal(s.Ctx, &proUpdates) s.Require().NoError(err) - stablecoin, err = s.k.StablecoinInfo.Get(s.Ctx, proAdd.Denom) + stablecoin, err = s.k.StablecoinInfos.Get(s.Ctx, proAdd.Denom) s.Require().NoError(err) s.Require().Equal(stablecoin.Denom, proAdd.Denom) s.Require().Equal(stablecoin.LimitTotal, limitTotalUpdates) diff --git a/x/psm/keeper/query.go b/x/psm/keeper/query.go index f682e821..06535254 100644 --- a/x/psm/keeper/query.go +++ b/x/psm/keeper/query.go @@ -46,7 +46,7 @@ func (q queryServer) Stablecoin(ctx context.Context, req *types.QueryStablecoinR return nil, status.Error(codes.InvalidArgument, "invalid request") } - stablecoin, err := q.keeper.StablecoinInfo.Get(ctx, req.Denom) + stablecoin, err := q.keeper.StablecoinInfos.Get(ctx, req.Denom) if err != nil { return nil, status.Errorf(codes.NotFound, "not found stablecoin %s", req.Denom) } @@ -71,7 +71,7 @@ func (q queryServer) AllStablecoin(ctx context.Context, req *types.QueryAllStabl allStablecoins = append(allStablecoins, &newStablecoinResponse) } - err := q.keeper.StablecoinInfo.Walk(ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { + err := q.keeper.StablecoinInfos.Walk(ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { adder(value) return false, nil }) diff --git a/x/psm/keeper/query_test.go b/x/psm/keeper/query_test.go index d641c704..a8a1f538 100644 --- a/x/psm/keeper/query_test.go +++ b/x/psm/keeper/query_test.go @@ -24,7 +24,7 @@ func (s *KeeperTestSuite) TestStablecoin() { TotalStablecoinLock: math.ZeroInt(), FeeMaxStablecoin: math.LegacyZeroDec(), } - err := s.k.StablecoinInfo.Set(s.Ctx, sc.Denom, sc) + err := s.k.StablecoinInfos.Set(s.Ctx, sc.Denom, sc) s.Require().NoError(err) rp, err := s.queryServer.Stablecoin(s.Ctx, &types.QueryStablecoinRequest{Denom: usdt}) diff --git a/x/psm/keeper/stablecoin.go b/x/psm/keeper/stablecoin.go index e6c61eb0..01d289f6 100644 --- a/x/psm/keeper/stablecoin.go +++ b/x/psm/keeper/stablecoin.go @@ -8,7 +8,7 @@ import ( ) func (k Keeper) GetTotalLimitWithDenomStablecoin(ctx context.Context, denom string) (math.Int, error) { - s, err := k.StablecoinInfo.Get(ctx, denom) + s, err := k.StablecoinInfos.Get(ctx, denom) if err != nil { return math.Int{}, fmt.Errorf("not found Stable coin %s", denom) } @@ -16,7 +16,7 @@ func (k Keeper) GetTotalLimitWithDenomStablecoin(ctx context.Context, denom stri } func (k Keeper) GetFeeIn(ctx context.Context, denom string) (math.LegacyDec, error) { - s, err := k.StablecoinInfo.Get(ctx, denom) + s, err := k.StablecoinInfos.Get(ctx, denom) if err != nil { return math.LegacyDec{}, fmt.Errorf("not found Stable coin %s", denom) } @@ -24,7 +24,7 @@ func (k Keeper) GetFeeIn(ctx context.Context, denom string) (math.LegacyDec, err } func (k Keeper) GetFeeOut(ctx context.Context, denom string) (math.LegacyDec, error) { - s, err := k.StablecoinInfo.Get(ctx, denom) + s, err := k.StablecoinInfos.Get(ctx, denom) if err != nil { return math.LegacyDec{}, fmt.Errorf("not found Stable coin %s", denom) } diff --git a/x/psm/keeper/stablecoin_test.go b/x/psm/keeper/stablecoin_test.go index 9f5d9137..3dd67cad 100644 --- a/x/psm/keeper/stablecoin_test.go +++ b/x/psm/keeper/stablecoin_test.go @@ -22,23 +22,23 @@ func (s *KeeperTestSuite) TestStoreStablecoin() { FeeOut: math.LegacyMustNewDecFromStr("0.001"), } - err := s.k.StablecoinInfo.Set(s.Ctx, s1.Denom, s1) + err := s.k.StablecoinInfos.Set(s.Ctx, s1.Denom, s1) s.Require().NoError(err) - err = s.k.StablecoinInfo.Set(s.Ctx, s2.Denom, s2) + err = s.k.StablecoinInfos.Set(s.Ctx, s2.Denom, s2) s.Require().NoError(err) - stablecoin1, err := s.k.StablecoinInfo.Get(s.Ctx, usdt) + stablecoin1, err := s.k.StablecoinInfos.Get(s.Ctx, usdt) s.Require().NoError(err) s.Require().Equal(stablecoin1.Denom, usdt) s.Require().Equal(stablecoin1.LimitTotal, limitUSDT) - stablecoin2, err := s.k.StablecoinInfo.Get(s.Ctx, usdc) + stablecoin2, err := s.k.StablecoinInfos.Get(s.Ctx, usdc) s.Require().NoError(err) s.Require().Equal(stablecoin2.Denom, usdc) s.Require().Equal(stablecoin2.LimitTotal, limitUSDC) count := 0 - err = s.k.StablecoinInfo.Walk(s.Ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { + err = s.k.StablecoinInfos.Walk(s.Ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { count += 1 return false, nil }) diff --git a/x/psm/keeper/swap.go b/x/psm/keeper/swap.go index aa7ca8a4..0f60d761 100644 --- a/x/psm/keeper/swap.go +++ b/x/psm/keeper/swap.go @@ -15,7 +15,7 @@ import ( // SwapToStablecoin return receiveAmount, fee, error func (k Keeper) SwapToOtherStablecoin(ctx context.Context, addr sdk.AccAddress, offerCoin sdk.Coin, expectedDenom string) error { // check stablecoin is suport - stablecoinInfo, err := k.StablecoinInfo.Get(ctx, expectedDenom) + stablecoinInfo, err := k.StablecoinInfos.Get(ctx, expectedDenom) if err != nil { return fmt.Errorf("%s not in list stablecoin supported", expectedDenom) } @@ -58,7 +58,7 @@ func (k Keeper) SwapToOtherStablecoin(ctx context.Context, addr sdk.AccAddress, // update stable coin info stablecoinReceive := sdk.NewCoin(expectedDenom, math.Int(expectedAmount)) stablecoinInfo.TotalStablecoinLock = totalStablecoinLock.Sub(expectedAmount) - err = k.StablecoinInfo.Set(ctx, expectedDenom, stablecoinInfo) + err = k.StablecoinInfos.Set(ctx, expectedDenom, stablecoinInfo) if err != nil { return err } diff --git a/x/psm/module/genesis.go b/x/psm/module/genesis.go index 75d752c4..41e9d44a 100644 --- a/x/psm/module/genesis.go +++ b/x/psm/module/genesis.go @@ -11,7 +11,7 @@ import ( func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) error { // this line is used by starport scaffolding # genesis/module/init for _, sb := range genState.Stablecoins { - err := k.StablecoinInfo.Set(ctx, sb.Denom, sb) + err := k.StablecoinInfos.Set(ctx, sb.Denom, sb) if err != nil { return err } @@ -37,7 +37,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) (*types.GenesisState, error return nil, err } - err = k.StablecoinInfo.Walk(ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { + err = k.StablecoinInfos.Walk(ctx, nil, func(key string, value types.StablecoinInfo) (stop bool, err error) { genesis.Stablecoins = append(genesis.Stablecoins, value) return false, nil }) From 04cd748e98aef494dfd31069c424ce240e5f1dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Fri, 8 Nov 2024 16:58:53 +0700 Subject: [PATCH 36/42] updates --- script/proposal-psm.json | 24 +------ script/psm-test.sh | 52 +++++----------- x/psm/client/cli/tx.go | 4 +- x/psm/keeper/msg_server.go | 36 +++++------ x/psm/keeper/swap.go | 124 ++++++++++++++++++++++++++++++------- x/psm/types/keys.go | 5 +- 6 files changed, 141 insertions(+), 104 deletions(-) diff --git a/script/proposal-psm.json b/script/proposal-psm.json index 046b0140..921ad6b8 100644 --- a/script/proposal-psm.json +++ b/script/proposal-psm.json @@ -5,8 +5,7 @@ "denom": "usdt", "limit_total": "100000000000000000000000000000", "fee_in": "0.001000000000000000", - "fee_out": "0.001000000000000000", - "nom_type":"nomUSD" + "fee_out": "0.001000000000000000" }, { "@type": "/reserve.psm.v1.MsgAddStableCoin", @@ -14,26 +13,7 @@ "denom": "usdc", "limit_total": "100000000000000000000000000000", "fee_in": "0.001000000000000000", - "fee_out": "0.001000000000000000", - "nom_type":"nomUSD" - }, - { - "@type": "/reserve.psm.v1.MsgAddStableCoin", - "authority":"onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k", - "denom": "jpyt", - "limit_total": "100000000000000000000000000000", - "fee_in": "0.001000000000000000", - "fee_out": "0.001000000000000000", - "nom_type":"nomJPY" - }, - { - "@type": "/reserve.psm.v1.MsgAddStableCoin", - "authority":"onomy10d07y265gmmuvt4z0w9aw880jnsr700jqr8n8k", - "denom": "eurt", - "limit_total": "100000000000000000000000000000", - "fee_in": "0.001000000000000000", - "fee_out": "0.001000000000000000", - "nom_type":"nomEUR" + "fee_out": "0.001000000000000000" }], "deposit": "100000000stake", "title": "My proposal", diff --git a/script/psm-test.sh b/script/psm-test.sh index f141ae0d..2823aa36 100755 --- a/script/psm-test.sh +++ b/script/psm-test.sh @@ -25,15 +25,15 @@ echo $mnemonic2| reserved keys add validator2 --recover --keyring-backend=test - echo $mnemonic3| reserved keys add validator3 --recover --keyring-backend=test --home=$HOME/.reserved/validator3 # create validator node with tokens to transfer to the three other nodes -reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator1 -reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator1 -reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator1 -reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator2 -reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator2 -reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator2 -reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator3 -reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator3 -reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000eurt,10000000000000000000000000000000usdc,10000000000000000000000000000000jpyt --home=$HOME/.reserved/validator3 +reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000usdc --home=$HOME/.reserved/validator1 +reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000usdc --home=$HOME/.reserved/validator1 +reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000usdc --home=$HOME/.reserved/validator1 +reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000usdc --home=$HOME/.reserved/validator2 +reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000usdc --home=$HOME/.reserved/validator2 +reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000usdc --home=$HOME/.reserved/validator2 +reserved genesis add-genesis-account $(reserved keys show validator1 -a --keyring-backend=test --home=$HOME/.reserved/validator1) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000usdc --home=$HOME/.reserved/validator3 +reserved genesis add-genesis-account $(reserved keys show validator2 -a --keyring-backend=test --home=$HOME/.reserved/validator2) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000usdc --home=$HOME/.reserved/validator3 +reserved genesis add-genesis-account $(reserved keys show validator3 -a --keyring-backend=test --home=$HOME/.reserved/validator3) 10000000000000000000000000000000stake,10000000000000000000000000000000usdt,10000000000000000000000000000000usdc --home=$HOME/.reserved/validator3 reserved genesis gentx validator1 1000000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator1 --chain-id=testing-1 reserved genesis gentx validator2 1000000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator2 --chain-id=testing-1 reserved genesis gentx validator3 1000000000000000000000stake --keyring-backend=test --home=$HOME/.reserved/validator3 --chain-id=testing-1 @@ -130,36 +130,18 @@ reserved tx gov vote 1 yes --from validator3 --keyring-backend test --home ~/.r sleep 15 # echo "========sleep==========" -# # check add usdt, balances -# reserved q psm all-stablecoin +# # # check add usdt, balances +# # reserved q psm all-stablecoin reserved q bank balances $(reserved keys show validator1 -a --keyring-backend test --home /Users/donglieu/.reserved/validator1) -# # tx swap usdt to nomUSD -# echo "========swap===========" -reserved tx psm swap-to-nom 100000000000000000000000usdt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake +# # # tx swap usdt to nomUSD +# # echo "========swap===========" +reserved tx psm swap 100000000000000000000000usdt nomUSD --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake sleep 7 -reserved tx psm swap-to-nom 100000000000000000000000eurt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake - -sleep 7 - -reserved tx psm swap-to-nom 100000000000000000000000usdc --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake +reserved tx psm swap 1000000000usdc nomUSD --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake sleep 7 -reserved tx psm swap-to-nom 100000000000000000000000jpyt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake -sleep 7 -# # Check account after swap -reserved q bank balances $(reserved keys show validator1 -a --keyring-backend test --home /Users/donglieu/.reserved/validator1) -# # tx swap nomUSD to usdt -reserved tx psm swap-to-stablecoin usdc 1000nomUSD --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake - +reserved tx psm swap 1000nomUSD usdc --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake sleep 7 -# Check account after swap -reserved tx psm swap-to-stablecoin eurt 1000nomEUR --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake - -sleep 7 -reserved tx psm swap-to-stablecoin jpyt 1000nomJPY --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake - -sleep 7 -reserved q bank balances $(reserved keys show validator1 -a --keyring-backend test --home /Users/donglieu/.reserved/validator1) -# # killall reserved || true \ No newline at end of file +reserved tx psm swap 1000nomUSD usdt --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake diff --git a/x/psm/client/cli/tx.go b/x/psm/client/cli/tx.go index 61f16465..2614d9ee 100644 --- a/x/psm/client/cli/tx.go +++ b/x/psm/client/cli/tx.go @@ -29,12 +29,12 @@ func GetTxCmd() *cobra.Command { func NewSwapToNomCmd() *cobra.Command { cmd := &cobra.Command{ Use: "swap [offer_stable_coin] [expected_denom]", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), Short: "stable swap ", Long: `swap between stable coins. Example: - $ onomyd tx psm swap 100000000000000000000000usdt ibc/xxxxx --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake + $ onomyd tx psm swap 100000000000000000000000nomUSD ibc/xxxxx --from validator1 --keyring-backend test --home ~/.reserved/validator1 --chain-id testing-1 -y --fees 20stake `, diff --git a/x/psm/keeper/msg_server.go b/x/psm/keeper/msg_server.go index 0e68fff4..aa16eb6f 100644 --- a/x/psm/keeper/msg_server.go +++ b/x/psm/keeper/msg_server.go @@ -3,10 +3,8 @@ package keeper import ( "context" "fmt" - "strings" errorsmod "cosmossdk.io/errors" - "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/onomyprotocol/reserve/x/psm/types" @@ -50,25 +48,27 @@ func (k msgServer) StableSwap(ctx context.Context, msg *types.MsgStableSwap) (_ return nil, err } - // balance check + accAddress, err := sdk.AccAddressFromBech32(msg.Address) + if err != nil { + return nil, err + } - asset := k.keeper.BankKeeper.GetBalance(ctx, sdk.AccAddress(msg.Address), msg.OfferCoin.Denom) + // balance check + asset := k.keeper.BankKeeper.GetBalance(ctx, accAddress, msg.OfferCoin.Denom) if asset.Amount.LT(msg.OfferCoin.Amount) { return nil, fmt.Errorf("insufficient balance") } - accAddress, err := sdk.AccAddressFromBech32(msg.Address) - if err != nil { - return nil, err - } - if strings.Contains(msg.OfferCoin.Denom, types.ReserveStableCoinDenomPrefix) { + if msg.OfferCoin.Denom == types.ReserveStableCoinDenom { err = k.keeper.SwapToOtherStablecoin(ctx, accAddress, msg.OfferCoin, msg.ExpectedDenom) + if err != nil { + return nil, err + } } else { err = k.keeper.SwapToOnomyStableToken(ctx, accAddress, msg.OfferCoin, msg.ExpectedDenom) - } - - if err != nil { - return nil, err + if err != nil { + return nil, err + } } return &types.MsgStableSwapResponse{}, nil @@ -140,18 +140,18 @@ func (k msgServer) UpdatesStableCoinProposal(ctx context.Context, msg *types.Msg return &types.MsgUpdatesStableCoinResponse{}, nil } -func (k Keeper) checkLimitTotalStablecoin(ctx context.Context, denom string, amountSwap math.Int) error { - totalStablecoinLock, err := k.TotalStablecoinLock(ctx, denom) +func (k Keeper) checkLimitTotalStablecoin(ctx context.Context, coin sdk.Coin) error { + totalStablecoinLock, err := k.TotalStablecoinLock(ctx, coin.Denom) if err != nil { return err } - totalLimit, err := k.GetTotalLimitWithDenomStablecoin(ctx, denom) + totalLimit, err := k.GetTotalLimitWithDenomStablecoin(ctx, coin.Denom) if err != nil { return err } - if (totalStablecoinLock.Add(amountSwap)).GT(totalLimit) { - return fmt.Errorf("unable to perform %s token swap transaction because the amount of %s you want to swap exceeds the allowed limit, can only swap up to %s%s", denom, denom, (totalLimit).Sub(totalStablecoinLock).String(), denom) + if (totalStablecoinLock.Add(coin.Amount)).GT(totalLimit) { + return fmt.Errorf("unable to perform %s token swap transaction because the amount of %s you want to swap exceeds the allowed limit, can only swap up to %s%s", coin.Denom, coin.Denom, (totalLimit).Sub(totalStablecoinLock).String(), coin.Denom) } return nil diff --git a/x/psm/keeper/swap.go b/x/psm/keeper/swap.go index 0f60d761..0a7de402 100644 --- a/x/psm/keeper/swap.go +++ b/x/psm/keeper/swap.go @@ -15,8 +15,8 @@ import ( // SwapToStablecoin return receiveAmount, fee, error func (k Keeper) SwapToOtherStablecoin(ctx context.Context, addr sdk.AccAddress, offerCoin sdk.Coin, expectedDenom string) error { // check stablecoin is suport - stablecoinInfo, err := k.StablecoinInfos.Get(ctx, expectedDenom) - if err != nil { + ok, err := k.StablecoinInfos.Has(ctx, expectedDenom) + if err != nil || !ok { return fmt.Errorf("%s not in list stablecoin supported", expectedDenom) } @@ -26,22 +26,15 @@ func (k Keeper) SwapToOtherStablecoin(ctx context.Context, addr sdk.AccAddress, return err } - rate := k.OracleKeeper.GetPrice(ctx, expectedDenom, types.USD) - if rate == nil || rate.IsNil() { - return errors.Wrapf(oracletypes.ErrInvalidOracle, "can not get price with base %s quote %s", offerCoin.Denom, types.USD) + // check balace and calculate amount of coins received + receiveAmountStablecoin, fee_out, err := k.calculateSwapToStablecoin(ctx, offerCoin.Amount, expectedDenom) + if err != nil { + return err } - expectedAmount := offerCoin.Amount.ToLegacyDec().Quo(*rate).RoundInt() - // locked stablecoin is greater than the amount desired - if totalStablecoinLock.LT(expectedAmount) { - //TODO: register error - return fmt.Errorf("insufficient balance, PSM module have %d USD but request %d", totalStablecoinLock, expectedAmount) - } - - fee, err := k.PayFeesOut(ctx, expectedAmount, expectedDenom) - if err != nil { - return err + if totalStablecoinLock.LT(receiveAmountStablecoin) { + return fmt.Errorf("amount %s locked lesser than amount desired", expectedDenom) } // burn nomUSD @@ -55,14 +48,13 @@ func (k Keeper) SwapToOtherStablecoin(ctx context.Context, addr sdk.AccAddress, return err } - // update stable coin info - stablecoinReceive := sdk.NewCoin(expectedDenom, math.Int(expectedAmount)) - stablecoinInfo.TotalStablecoinLock = totalStablecoinLock.Sub(expectedAmount) - err = k.StablecoinInfos.Set(ctx, expectedDenom, stablecoinInfo) + stablecoinReceive := sdk.NewCoin(expectedDenom, receiveAmountStablecoin) + + // sub total stablecoin lock + err = k.SubTotalStablecoinLock(ctx, stablecoinReceive) if err != nil { return err } - // send stablecoin to user err = k.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, addr, sdk.NewCoins(stablecoinReceive)) if err != nil { @@ -73,16 +65,68 @@ func (k Keeper) SwapToOtherStablecoin(ctx context.Context, addr sdk.AccAddress, sdkCtx := sdk.UnwrapSDKContext(ctx) sdkCtx.EventManager().EmitEvent( sdk.NewEvent( - types.EventSwapTonomUSD, + types.EventSwapToStablecoin, sdk.NewAttribute(types.AttributeAmount, offerCoin.String()), - sdk.NewAttribute(types.AttributeReceive, expectedAmount.String()), - sdk.NewAttribute(types.AttributeFeeIn, fee.String()), + sdk.NewAttribute(types.AttributeReceive, stablecoinReceive.String()), + sdk.NewAttribute(types.AttributeFeeOut, fee_out.String()), ), ) return nil } func (k Keeper) SwapToOnomyStableToken(ctx context.Context, accAddress sdk.AccAddress, offerCoin sdk.Coin, expectedDenom string) error { + // check stablecoin is suport + ok, err := k.StablecoinInfos.Has(ctx, offerCoin.Denom) + if err != nil || !ok { + return fmt.Errorf("%s not in list stablecoin supported", offerCoin.Denom) + } + + // check limit swap + err = k.checkLimitTotalStablecoin(ctx, offerCoin) + if err != nil { + return err + } + + // check balance user and calculate amount of coins received + receiveAmountnomUSD, fee_in, err := k.calculateSwapToOnomyStableToken(ctx, offerCoin) + if err != nil { + return err + } + + // add total stablecoin lock + err = k.AddTotalStablecoinLock(ctx, offerCoin) + if err != nil { + return err + } + + // send stablecoin to module + err = k.BankKeeper.SendCoinsFromAccountToModule(ctx, accAddress, types.ModuleName, sdk.NewCoins(offerCoin)) + if err != nil { + return fmt.Errorf(err.Error() + "1111") + } + + // mint nomUSD + coinsMint := sdk.NewCoins(sdk.NewCoin(types.ReserveStableCoinDenom, receiveAmountnomUSD)) + err = k.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) + if err != nil { + return err + } + // send to user + err = k.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, accAddress, coinsMint) + if err != nil { + return fmt.Errorf(err.Error() + "222") + } + + // event + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventSwapTonomUSD, + sdk.NewAttribute(types.AttributeAmount, offerCoin.String()), + sdk.NewAttribute(types.AttributeReceive, coinsMint.String()), + sdk.NewAttribute(types.AttributeFeeIn, fee_in.String()), + ), + ) return nil } @@ -104,3 +148,37 @@ func (k Keeper) PayFeesIn(ctx context.Context, amount math.Int, denom string) (m fee := ratioSwapInFees.MulInt(amount) return fee, nil } + +// SwapToStablecoin return receiveAmount, fee, error +func (k Keeper) calculateSwapToStablecoin(ctx context.Context, amount math.Int, toDenom string) (math.Int, sdk.DecCoin, error) { + multiplier := k.OracleKeeper.GetPrice(ctx, toDenom, types.ReserveStableCoinDenom) + if multiplier == nil || multiplier.IsNil() { + return math.Int{}, sdk.DecCoin{}, errors.Wrapf(oracletypes.ErrInvalidOracle, "can not get price with base %s quote %s", toDenom, types.ReserveStableCoinDenom) + } + amountStablecoin := amount.ToLegacyDec().Quo(*multiplier) + + fee, err := k.PayFeesOut(ctx, amountStablecoin.RoundInt(), toDenom) + if err != nil { + return math.Int{}, sdk.DecCoin{}, err + } + + receiveAmount := amountStablecoin.Sub(fee) + return receiveAmount.RoundInt(), sdk.NewDecCoinFromDec(toDenom, fee), nil +} + +func (k Keeper) calculateSwapToOnomyStableToken(ctx context.Context, stablecoin sdk.Coin) (math.Int, sdk.DecCoin, error) { + multiplier := k.OracleKeeper.GetPrice(ctx, stablecoin.Denom, types.ReserveStableCoinDenom) + if multiplier == nil || multiplier.IsNil() { + return math.Int{}, sdk.DecCoin{}, errors.Wrapf(oracletypes.ErrInvalidOracle, "can not get price with base %s quote %s", stablecoin.Denom, types.ReserveStableCoinDenom) + } + + amountnomUSD := multiplier.Mul(stablecoin.Amount.ToLegacyDec()) + + fee, err := k.PayFeesIn(ctx, amountnomUSD.RoundInt(), stablecoin.Denom) + if err != nil { + return math.Int{}, sdk.DecCoin{}, err + } + + receiveAmountnomUSD := amountnomUSD.Sub(fee) + return receiveAmountnomUSD.RoundInt(), sdk.NewDecCoinFromDec(types.ReserveStableCoinDenom, fee), nil +} diff --git a/x/psm/types/keys.go b/x/psm/types/keys.go index 1d2cc23e..837ac4f9 100644 --- a/x/psm/types/keys.go +++ b/x/psm/types/keys.go @@ -17,10 +17,7 @@ const ( MemStoreKey = "mem_psm" // Reserve Stable Coin denom prefix - ReserveStableCoinDenomPrefix = "nom" - - // USD - USD = "USD" + ReserveStableCoinDenom = "nomUSD" ) var ( From 1eb130a268863702c63959ba73d38fcbc79bd831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Fri, 8 Nov 2024 17:02:12 +0700 Subject: [PATCH 37/42] remove noms --- proto/reserve/psm/v1/genesis.proto | 3 -- x/psm/keeper/keeper.go | 2 - x/psm/keeper/keeper_test.go | 2 +- x/psm/module/genesis.go | 12 ----- x/psm/types/genesis.go | 3 -- x/psm/types/genesis.pb.go | 72 ++++-------------------------- 6 files changed, 9 insertions(+), 85 deletions(-) diff --git a/proto/reserve/psm/v1/genesis.proto b/proto/reserve/psm/v1/genesis.proto index 32f514dd..48afaa6c 100644 --- a/proto/reserve/psm/v1/genesis.proto +++ b/proto/reserve/psm/v1/genesis.proto @@ -18,7 +18,4 @@ message GenesisState { repeated StablecoinInfo stablecoins = 2 [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; - - repeated string noms = 3 - [ (amino.dont_omitempty) = true ]; } diff --git a/x/psm/keeper/keeper.go b/x/psm/keeper/keeper.go index aa99faf8..2dc7413d 100644 --- a/x/psm/keeper/keeper.go +++ b/x/psm/keeper/keeper.go @@ -37,7 +37,6 @@ type ( OracleKeeper types.OracleKeeper StablecoinInfos collections.Map[string, types.StablecoinInfo] - Noms collections.Map[string, string] } ) @@ -70,7 +69,6 @@ func NewKeeper( OracleKeeper: oracleKeeper, Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)), StablecoinInfos: collections.NewMap(sb, types.KeyStableCoin, "stablecoins", collections.StringKey, codec.CollValue[types.StablecoinInfo](cdc)), - Noms: collections.NewMap(sb, types.KeyNoms, "nomtypes", collections.StringKey, collections.StringValue), } schema, err := sb.Build() diff --git a/x/psm/keeper/keeper_test.go b/x/psm/keeper/keeper_test.go index d54cc99f..fc8f0a69 100644 --- a/x/psm/keeper/keeper_test.go +++ b/x/psm/keeper/keeper_test.go @@ -67,7 +67,7 @@ func (s *KeeperTestSuite) SetupTest() { mockOracleKeeper := MockOracleKeeper{ prices: make(map[string]math.LegacyDec), } - mockOracleKeeper.SetPrice(s.Ctx, types.DefaultMintDenoms[0], math.LegacyMustNewDecFromStr("1")) + mockOracleKeeper.SetPrice(s.Ctx, types.ReserveStableCoinDenom, math.LegacyMustNewDecFromStr("1")) s.App.PSMKeeper.OracleKeeper = mockOracleKeeper s.mockOracleKeeper = &mockOracleKeeper diff --git a/x/psm/module/genesis.go b/x/psm/module/genesis.go index 41e9d44a..9720a6d5 100644 --- a/x/psm/module/genesis.go +++ b/x/psm/module/genesis.go @@ -17,13 +17,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) } } - for _, nom := range genState.Noms { - err := k.Noms.Set(ctx, nom, nom) - if err != nil { - return err - } - } - return k.Params.Set(ctx, genState.Params) } @@ -45,10 +38,5 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) (*types.GenesisState, error return nil, err } - err = k.Noms.Walk(ctx, nil, func(key string, value string) (stop bool, err error) { - genesis.Noms = append(genesis.Noms, value) - return false, nil - }) - return genesis, err } diff --git a/x/psm/types/genesis.go b/x/psm/types/genesis.go index 15bd79db..c5ea7560 100644 --- a/x/psm/types/genesis.go +++ b/x/psm/types/genesis.go @@ -1,14 +1,11 @@ package types -var DefaultMintDenoms = []string{"nomUSD"} - // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), Stablecoins: []StablecoinInfo{}, - Noms: DefaultMintDenoms, } } diff --git a/x/psm/types/genesis.pb.go b/x/psm/types/genesis.pb.go index 9a21f97d..fc609658 100644 --- a/x/psm/types/genesis.pb.go +++ b/x/psm/types/genesis.pb.go @@ -29,7 +29,6 @@ type GenesisState struct { // params defines all the parameters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` Stablecoins []StablecoinInfo `protobuf:"bytes,2,rep,name=stablecoins,proto3" json:"stablecoins"` - Noms []string `protobuf:"bytes,3,rep,name=noms,proto3" json:"noms,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -79,13 +78,6 @@ func (m *GenesisState) GetStablecoins() []StablecoinInfo { return nil } -func (m *GenesisState) GetNoms() []string { - if m != nil { - return m.Noms - } - return nil -} - func init() { proto.RegisterType((*GenesisState)(nil), "reserve.psm.v1.GenesisState") } @@ -93,25 +85,24 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/genesis.proto", fileDescriptor_fbe4ca1f3927cde8) } var fileDescriptor_fbe4ca1f3927cde8 = []byte{ - // 280 bytes of a gzipped FileDescriptorProto + // 260 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x4a, 0x2d, 0x4e, 0x2d, 0x2a, 0x4b, 0xd5, 0x2f, 0x28, 0xce, 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x83, 0xca, 0xea, 0x15, 0x14, 0xe7, 0xea, 0x95, 0x19, 0x4a, 0x09, 0x26, 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x12, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, 0x53, 0x1f, 0xc4, 0x82, 0x8a, 0x4a, 0xa3, 0x19, 0x5b, 0x90, - 0x58, 0x94, 0x98, 0x0b, 0x35, 0x55, 0x4a, 0x02, 0x5d, 0xb2, 0x38, 0x17, 0x22, 0xa3, 0xb4, 0x91, + 0x58, 0x94, 0x98, 0x0b, 0x35, 0x55, 0x4a, 0x02, 0x5d, 0xb2, 0x38, 0x17, 0x22, 0xa3, 0x34, 0x8d, 0x91, 0x8b, 0xc7, 0x1d, 0xe2, 0x82, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x4b, 0x2e, 0x36, 0x88, 0x56, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x31, 0x3d, 0x54, 0x17, 0xe9, 0x05, 0x80, 0x65, 0x9d, 0x38, 0x4f, 0xdc, 0x93, 0x67, 0x58, 0xf1, 0x7c, 0x83, 0x16, 0x63, 0x10, 0x54, 0x83, 0x90, 0x37, 0x17, 0x77, 0x71, 0x49, 0x62, 0x52, 0x4e, 0x6a, 0x72, 0x7e, 0x66, 0x5e, 0xb1, 0x04, 0x93, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x1c, 0xba, 0xfe, 0x60, 0xb8, 0x12, 0xcf, 0xbc, 0xb4, 0x7c, 0x64, - 0x73, 0x90, 0x75, 0x0b, 0x49, 0x72, 0xb1, 0xe4, 0xe5, 0xe7, 0x16, 0x4b, 0x30, 0x2b, 0x30, 0x6b, - 0x70, 0x3a, 0xb1, 0x42, 0x54, 0x80, 0x85, 0x9c, 0xdc, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, - 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, - 0x58, 0x8e, 0x21, 0x4a, 0x27, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, - 0x3f, 0x2f, 0x3f, 0xb7, 0x12, 0xec, 0xc9, 0xe4, 0xfc, 0x1c, 0x7d, 0x58, 0x00, 0x54, 0x80, 0x83, - 0xa0, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x2c, 0x6b, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, - 0xef, 0x05, 0xd9, 0x0a, 0x92, 0x01, 0x00, 0x00, + 0x73, 0x90, 0x75, 0x3b, 0xb9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, + 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, + 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x7e, 0x5e, 0x7e, 0x6e, + 0x25, 0xd8, 0x27, 0xc9, 0xf9, 0x39, 0xfa, 0x30, 0x5f, 0x56, 0x80, 0xfd, 0x59, 0x52, 0x59, 0x90, + 0x5a, 0x9c, 0xc4, 0x06, 0x96, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x72, 0xe2, 0x56, 0xab, + 0x77, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -134,15 +125,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Noms) > 0 { - for iNdEx := len(m.Noms) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Noms[iNdEx]) - copy(dAtA[i:], m.Noms[iNdEx]) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Noms[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } if len(m.Stablecoins) > 0 { for iNdEx := len(m.Stablecoins) - 1; iNdEx >= 0; iNdEx-- { { @@ -195,12 +177,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.Noms) > 0 { - for _, s := range m.Noms { - l = len(s) - n += 1 + l + sovGenesis(uint64(l)) - } - } return n } @@ -306,38 +282,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Noms", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Noms = append(m.Noms, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) From ed665859c4d5617c73c0e948605747a5feb4bd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Fri, 8 Nov 2024 17:15:29 +0700 Subject: [PATCH 38/42] oracle script --- proto/reserve/psm/v1/tx.proto | 3 + x/psm/keeper/msg_server.go | 2 +- x/psm/types/msgs.go | 12 ++- x/psm/types/tx.pb.go | 184 +++++++++++++++++++++++----------- x/psm/types/types.go | 1 - 5 files changed, 140 insertions(+), 62 deletions(-) delete mode 100644 x/psm/types/types.go diff --git a/proto/reserve/psm/v1/tx.proto b/proto/reserve/psm/v1/tx.proto index d822ff2c..252a9a4f 100644 --- a/proto/reserve/psm/v1/tx.proto +++ b/proto/reserve/psm/v1/tx.proto @@ -69,6 +69,7 @@ message MsgAddStableCoin { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; + int64 oracle_script = 6; } message MsgAddStableCoinResponse {} @@ -98,6 +99,8 @@ message MsgUpdatesStableCoin { (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; + + int64 oracle_script = 6; } message MsgUpdatesStableCoinResponse {} diff --git a/x/psm/keeper/msg_server.go b/x/psm/keeper/msg_server.go index aa16eb6f..1009153a 100644 --- a/x/psm/keeper/msg_server.go +++ b/x/psm/keeper/msg_server.go @@ -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.Denom, 1) + err = k.keeper.OracleKeeper.AddNewSymbolToBandOracleRequest(ctx, msg.Denom, msg.OracleScript) if err != nil { return &types.MsgAddStableCoinResponse{}, err } diff --git a/x/psm/types/msgs.go b/x/psm/types/msgs.go index 1990cc7e..00ac8548 100644 --- a/x/psm/types/msgs.go +++ b/x/psm/types/msgs.go @@ -58,10 +58,6 @@ func (msg MsgStableSwap) GetSigners() []sdk.AccAddress { // Route implements the sdk.Msg interface. func (msg MsgStableSwap) Route() string { return RouterKey } -// func (msg MsgAddStableCoin) GetPrice() math.LegacyDec { -// return msg.Price -// } - func (msg MsgAddStableCoin) GetLimitTotal() math.Int { return msg.LimitTotal } @@ -87,6 +83,10 @@ func (msg MsgAddStableCoin) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty denom") } + if msg.OracleScript <= 0 { + return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty oracle script") + } + if msg.LimitTotal.LT(math.ZeroInt()) { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "limittotal less than zero") } @@ -126,6 +126,10 @@ func (msg MsgUpdatesStableCoin) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "limittotal less than zero") } + if msg.OracleScript <= 0 { + return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "empty oracle script") + } + if msg.FeeIn.LT(math.LegacyZeroDec()) { return sdkerrors.Wrap(ErrInvalidAddStableCoinProposal, "feein less than zero") } diff --git a/x/psm/types/tx.pb.go b/x/psm/types/tx.pb.go index 2b360f70..66d2aa4e 100644 --- a/x/psm/types/tx.pb.go +++ b/x/psm/types/tx.pb.go @@ -129,11 +129,12 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo type MsgAddStableCoin struct { - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` - FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` - FeeOut cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=fee_out,json=feeOut,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_out"` + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` + FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` + FeeOut cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=fee_out,json=feeOut,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_out"` + OracleScript int64 `protobuf:"varint,6,opt,name=oracle_script,json=oracleScript,proto3" json:"oracle_script,omitempty"` } func (m *MsgAddStableCoin) Reset() { *m = MsgAddStableCoin{} } @@ -183,6 +184,13 @@ func (m *MsgAddStableCoin) GetDenom() string { return "" } +func (m *MsgAddStableCoin) GetOracleScript() int64 { + if m != nil { + return m.OracleScript + } + return 0 +} + type MsgAddStableCoinResponse struct { } @@ -220,11 +228,12 @@ func (m *MsgAddStableCoinResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAddStableCoinResponse proto.InternalMessageInfo type MsgUpdatesStableCoin struct { - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` - FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` - FeeOut cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=fee_out,json=feeOut,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_out"` + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + LimitTotal cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=limit_total,json=limitTotal,proto3,customtype=cosmossdk.io/math.Int" json:"limit_total"` + FeeIn cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=fee_in,json=feeIn,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_in"` + FeeOut cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=fee_out,json=feeOut,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"fee_out"` + OracleScript int64 `protobuf:"varint,6,opt,name=oracle_script,json=oracleScript,proto3" json:"oracle_script,omitempty"` } func (m *MsgUpdatesStableCoin) Reset() { *m = MsgUpdatesStableCoin{} } @@ -274,6 +283,13 @@ func (m *MsgUpdatesStableCoin) GetDenom() string { return "" } +func (m *MsgUpdatesStableCoin) GetOracleScript() int64 { + if m != nil { + return m.OracleScript + } + return 0 +} + type MsgUpdatesStableCoinResponse struct { } @@ -420,52 +436,54 @@ func init() { func init() { proto.RegisterFile("reserve/psm/v1/tx.proto", fileDescriptor_d0ff2d5421e71e2a) } var fileDescriptor_d0ff2d5421e71e2a = []byte{ - // 716 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0x4d, 0x4f, 0x13, 0x51, - 0x14, 0xed, 0x50, 0x0b, 0xe9, 0xe5, 0x43, 0x9d, 0x14, 0x3b, 0x1d, 0x64, 0x68, 0x26, 0x12, 0x1b, - 0x02, 0x33, 0x14, 0xa3, 0x89, 0xec, 0x28, 0xc4, 0x88, 0xb1, 0x11, 0x07, 0x4d, 0x8c, 0x9b, 0xe6, - 0x75, 0xe6, 0x75, 0x98, 0xd8, 0x99, 0x37, 0x99, 0xf7, 0x5a, 0xe9, 0xce, 0x18, 0x57, 0xae, 0xf8, - 0x0f, 0x6e, 0x5c, 0xb2, 0x20, 0xfe, 0x06, 0x96, 0x84, 0x95, 0x71, 0x41, 0x0c, 0x2c, 0xf8, 0x13, - 0x2e, 0xcc, 0x7c, 0x95, 0x4e, 0x5b, 0xc4, 0xe0, 0xd6, 0x4d, 0xd3, 0x77, 0xcf, 0xbd, 0xe7, 0xde, - 0xf3, 0xce, 0xeb, 0x2d, 0xe4, 0x3d, 0x4c, 0xb1, 0xd7, 0xc6, 0xaa, 0x4b, 0x6d, 0xb5, 0x5d, 0x56, - 0xd9, 0xae, 0xe2, 0x7a, 0x84, 0x11, 0x7e, 0x2a, 0x02, 0x14, 0x97, 0xda, 0x4a, 0xbb, 0x2c, 0xde, - 0x46, 0xb6, 0xe5, 0x10, 0x35, 0xf8, 0x0c, 0x53, 0xc4, 0xbc, 0x4e, 0xa8, 0x4d, 0xa8, 0x6a, 0x53, - 0xd3, 0x2f, 0xb5, 0xa9, 0x19, 0x01, 0x85, 0x10, 0xa8, 0x05, 0x27, 0x35, 0x3c, 0x44, 0x50, 0xce, - 0x24, 0x26, 0x09, 0xe3, 0xfe, 0xb7, 0x28, 0x3a, 0xd3, 0x37, 0x85, 0x8b, 0x3c, 0x64, 0xc7,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4, 0x44, 0xdb, 0x49, 0xf1, 0x27, 0xe9, - 0xdd, 0x11, 0xd9, 0xa0, 0xce, 0x8f, 0xae, 0x4e, 0xf8, 0x72, 0xe3, 0xce, 0x72, 0x1e, 0xa6, 0x13, - 0x43, 0xc6, 0xe3, 0xaf, 0xec, 0xa5, 0x21, 0x5d, 0xa5, 0x26, 0xff, 0x06, 0x26, 0x12, 0x8b, 0x6d, - 0xae, 0x7f, 0x21, 0xf5, 0x6d, 0x10, 0xf1, 0xfe, 0x15, 0x09, 0x71, 0x07, 0x5e, 0x87, 0xe9, 0xc4, - 0x03, 0xdf, 0xf2, 0x88, 0x4b, 0x28, 0x6a, 0xf2, 0xc5, 0x21, 0x0c, 0x89, 0x4c, 0xb1, 0x74, 0x55, - 0x46, 0xb7, 0x09, 0x81, 0xc2, 0x80, 0x45, 0xdd, 0x46, 0xf7, 0x2e, 0x1d, 0xb5, 0x27, 0x5b, 0x5c, - 0xfc, 0x9b, 0xac, 0x6e, 0x43, 0x0d, 0xa0, 0xc7, 0xf2, 0xd9, 0x21, 0xb5, 0x17, 0xb0, 0x38, 0xff, - 0x47, 0x38, 0xe6, 0x14, 0x33, 0x1f, 0x7c, 0x13, 0x2b, 0x4f, 0x0e, 0x4f, 0x25, 0xee, 0xe8, 0x54, - 0xe2, 0x7e, 0x9e, 0x4a, 0xdc, 0xde, 0x99, 0x94, 0x3a, 0x3a, 0x93, 0x52, 0xdf, 0xcf, 0xa4, 0xd4, - 0xdb, 0x45, 0xd3, 0x62, 0x3b, 0xad, 0xba, 0xa2, 0x13, 0x5b, 0x25, 0x0e, 0xb1, 0x3b, 0xc1, 0x1f, - 0x93, 0x4e, 0x9a, 0x6a, 0xf2, 0x21, 0xb3, 0x8e, 0x8b, 0x69, 0x7d, 0x34, 0x40, 0x1f, 0xfc, 0x0e, - 0x00, 0x00, 0xff, 0xff, 0x0d, 0xfe, 0x18, 0xec, 0x7b, 0x07, 0x00, 0x00, + // 738 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0xcf, 0x4f, 0xd3, 0x60, + 0x18, 0xc7, 0x57, 0xe7, 0x46, 0xf6, 0x30, 0x50, 0x9b, 0xe1, 0xba, 0x22, 0x65, 0x99, 0x12, 0x17, + 0x02, 0x2d, 0xc3, 0x68, 0x22, 0x37, 0x06, 0x31, 0x62, 0x5c, 0xc4, 0x4e, 0x13, 0xe3, 0x65, 0x79, + 0xd7, 0xbe, 0x2b, 0x8d, 0x6b, 0xdf, 0xa6, 0xef, 0xbb, 0xc9, 0x6e, 0xc6, 0xa3, 0x27, 0xfe, 0x05, + 0xe3, 0x45, 0x6f, 0x1c, 0x88, 0x7f, 0x03, 0x47, 0xc2, 0xc9, 0x78, 0x20, 0x06, 0x0e, 0xfc, 0x1b, + 0xa6, 0xbf, 0xc6, 0xba, 0x81, 0x18, 0x0e, 0x9e, 0xbc, 0x2c, 0x7b, 0x7e, 0x7d, 0x9f, 0xe7, 0xd9, + 0x67, 0x7d, 0x0a, 0x79, 0x17, 0x53, 0xec, 0x76, 0xb1, 0xe2, 0x50, 0x4b, 0xe9, 0x56, 0x14, 0xb6, + 0x2d, 0x3b, 0x2e, 0x61, 0x84, 0x9f, 0x0c, 0x03, 0xb2, 0x43, 0x2d, 0xb9, 0x5b, 0x11, 0x6f, 0x21, + 0xcb, 0xb4, 0x89, 0xe2, 0x7f, 0x06, 0x29, 0x62, 0x5e, 0x23, 0xd4, 0x22, 0x54, 0xb1, 0xa8, 0xe1, + 0x95, 0x5a, 0xd4, 0x08, 0x03, 0x85, 0x20, 0xd0, 0xf0, 0x2d, 0x25, 0x30, 0xc2, 0x50, 0xce, 0x20, + 0x06, 0x09, 0xfc, 0xde, 0xb7, 0xd0, 0x3b, 0x3d, 0x34, 0x85, 0x83, 0x5c, 0x64, 0x45, 0x25, 0x52, + 0xd8, 0xa6, 0x89, 0x28, 0x56, 0xba, 0x95, 0x26,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63, 0x3e, 0xb6, 0xf1, 0xe5, 0x82, 0x1c, 0xee, 0xed, 0xdd, 0x39, 0x39, + 0xbc, 0x73, 0xb2, 0x37, 0xc9, 0xe0, 0xb5, 0xc9, 0xf8, 0x75, 0x9e, 0x77, 0x25, 0xeb, 0xad, 0x1b, + 0x75, 0x2e, 0xe5, 0x61, 0x2a, 0x36, 0x64, 0x34, 0xfe, 0xf2, 0x4e, 0x12, 0x92, 0x35, 0x6a, 0xf0, + 0x6f, 0x20, 0x1b, 0x3b, 0x91, 0xb3, 0xc3, 0xa7, 0x6d, 0xe8, 0x16, 0x89, 0xf7, 0x2f, 0x49, 0x88, + 0x3a, 0xf0, 0x1a, 0x4c, 0xc5, 0x9e, 0x82, 0x4d, 0x97, 0x38, 0x84, 0xa2, 0x36, 0x5f, 0x3c, 0x47, + 0x21, 0x96, 0x29, 0x96, 0x2f, 0xcb, 0xe8, 0x37, 0x21, 0x50, 0x18, 0x41, 0xd4, 0x6f, 0x74, 0xef, + 0xc2, 0x51, 0x07, 0xb2, 0xc5, 0x85, 0xbf, 0xc9, 0xea, 0x37, 0x54, 0x01, 0x06, 0x90, 0xcf, 0x9c, + 0x53, 0x7b, 0x16, 0x16, 0xe7, 0xfe, 0x18, 0x8e, 0x34, 0xc5, 0xd4, 0x07, 0x0f, 0x62, 0xf5, 0xc9, + 0xfe, 0xb1, 0xc4, 0x1d, 0x1c, 0x4b, 0xdc, 0xaf, 0x63, 0x89, 0xdb, 0x39, 0x91, 0x12, 0x07, 0x27, + 0x52, 0xe2, 0xc7, 0x89, 0x94, 0x78, 0xbb, 0x60, 0x98, 0x6c, 0xab, 0xd3, 0x94, 0x35, 0x62, 0x29, + 0xc4, 0x26, 0x56, 0xcf, 0x7f, 0xc5, 0x69, 0xa4, 0xad, 0xc4, 0xff, 0xc8, 0xac, 0xe7, 0x60, 0xda, + 0x4c, 0xfb, 0xd1, 0x07, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x18, 0x0a, 0xb3, 0x04, 0xc5, 0x07, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -744,6 +762,11 @@ func (m *MsgAddStableCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.OracleScript != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.OracleScript)) + i-- + dAtA[i] = 0x30 + } { size := m.FeeOut.Size() i -= size @@ -834,6 +857,11 @@ func (m *MsgUpdatesStableCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.OracleScript != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.OracleScript)) + i-- + dAtA[i] = 0x30 + } { size := m.FeeOut.Size() i -= size @@ -1029,6 +1057,9 @@ func (m *MsgAddStableCoin) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.FeeOut.Size() n += 1 + l + sovTx(uint64(l)) + if m.OracleScript != 0 { + n += 1 + sovTx(uint64(m.OracleScript)) + } return n } @@ -1061,6 +1092,9 @@ func (m *MsgUpdatesStableCoin) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.FeeOut.Size() n += 1 + l + sovTx(uint64(l)) + if m.OracleScript != 0 { + n += 1 + sovTx(uint64(m.OracleScript)) + } return n } @@ -1464,6 +1498,25 @@ func (m *MsgAddStableCoin) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleScript", wireType) + } + m.OracleScript = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OracleScript |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -1727,6 +1780,25 @@ func (m *MsgUpdatesStableCoin) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleScript", wireType) + } + m.OracleScript = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.OracleScript |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/psm/types/types.go b/x/psm/types/types.go deleted file mode 100644 index ab1254f4..00000000 --- a/x/psm/types/types.go +++ /dev/null @@ -1 +0,0 @@ -package types From 86bd072fffc5787e92088083ac71efe2e2ba6e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Fri, 8 Nov 2024 17:18:14 +0700 Subject: [PATCH 39/42] updates file proposal psm --- script/proposal-psm.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script/proposal-psm.json b/script/proposal-psm.json index 921ad6b8..816b6054 100644 --- a/script/proposal-psm.json +++ b/script/proposal-psm.json @@ -5,7 +5,8 @@ "denom": "usdt", "limit_total": "100000000000000000000000000000", "fee_in": "0.001000000000000000", - "fee_out": "0.001000000000000000" + "fee_out": "0.001000000000000000", + "oracle_script": "44" }, { "@type": "/reserve.psm.v1.MsgAddStableCoin", @@ -13,7 +14,8 @@ "denom": "usdc", "limit_total": "100000000000000000000000000000", "fee_in": "0.001000000000000000", - "fee_out": "0.001000000000000000" + "fee_out": "0.001000000000000000", + "oracle_script": "44" }], "deposit": "100000000stake", "title": "My proposal", From d89cee4e1a7079805d90ded8979c68ce60e84f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Fri, 8 Nov 2024 17:19:58 +0700 Subject: [PATCH 40/42] nits --- x/psm/keeper/swap.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/psm/keeper/swap.go b/x/psm/keeper/swap.go index 0a7de402..fb1a6844 100644 --- a/x/psm/keeper/swap.go +++ b/x/psm/keeper/swap.go @@ -102,7 +102,7 @@ func (k Keeper) SwapToOnomyStableToken(ctx context.Context, accAddress sdk.AccAd // send stablecoin to module err = k.BankKeeper.SendCoinsFromAccountToModule(ctx, accAddress, types.ModuleName, sdk.NewCoins(offerCoin)) if err != nil { - return fmt.Errorf(err.Error() + "1111") + return err } // mint nomUSD @@ -114,7 +114,7 @@ func (k Keeper) SwapToOnomyStableToken(ctx context.Context, accAddress sdk.AccAd // send to user err = k.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, accAddress, coinsMint) if err != nil { - return fmt.Errorf(err.Error() + "222") + return err } // event From 02856bdfb0789b734a522d476695d8f8a0fe1755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Fri, 8 Nov 2024 17:51:25 +0700 Subject: [PATCH 41/42] fix test pass ci --- x/psm/keeper/abci.go | 2 +- x/psm/keeper/abci_test.go | 9 +- x/psm/keeper/keeper_test.go | 4 +- x/psm/keeper/msg_server_test.go | 158 ---------------- x/psm/keeper/proposals_test.go | 33 ++-- x/psm/keeper/swap_test.go | 315 +++++++++++++++++--------------- 6 files changed, 191 insertions(+), 330 deletions(-) delete mode 100644 x/psm/keeper/msg_server_test.go diff --git a/x/psm/keeper/abci.go b/x/psm/keeper/abci.go index 6182a5bc..6753b025 100644 --- a/x/psm/keeper/abci.go +++ b/x/psm/keeper/abci.go @@ -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.Denom, "USD") + price := k.OracleKeeper.GetPrice(ctx, info.Denom, types.ReserveStableCoinDenom) if price == nil || price.IsNil() { return false } diff --git a/x/psm/keeper/abci_test.go b/x/psm/keeper/abci_test.go index 3b042548..4730605b 100644 --- a/x/psm/keeper/abci_test.go +++ b/x/psm/keeper/abci_test.go @@ -41,10 +41,11 @@ func (s *KeeperTestSuite) TestUpdatesStablecoinEpoch() { for _, t := range tests { s.Run(t.name, func() { sc := types.GetMsgStablecoin(&types.MsgAddStableCoin{ - Denom: usdt, - LimitTotal: limitUSDT, - FeeIn: t.feeIn, - FeeOut: t.feeOut, + Denom: usdt, + LimitTotal: limitUSDT, + FeeIn: t.feeIn, + FeeOut: t.feeOut, + OracleScript: 44, }) s.mockOracleKeeper.SetPrice(s.Ctx, sc.Denom, t.priceCurrent) err := s.k.StablecoinInfos.Set(s.Ctx, sc.Denom, sc) diff --git a/x/psm/keeper/keeper_test.go b/x/psm/keeper/keeper_test.go index fc8f0a69..c157a7ab 100644 --- a/x/psm/keeper/keeper_test.go +++ b/x/psm/keeper/keeper_test.go @@ -17,8 +17,8 @@ var ( usdt = "usdt" usdc = "usdc" - limitUSDT = math.NewInt(1000000) - limitUSDC = math.NewInt(1000000) + limitUSDT = math.NewInt(100000000) + limitUSDC = math.NewInt(100000000) ) type MockOracleKeeper struct { diff --git a/x/psm/keeper/msg_server_test.go b/x/psm/keeper/msg_server_test.go deleted file mode 100644 index a22c06c5..00000000 --- a/x/psm/keeper/msg_server_test.go +++ /dev/null @@ -1,158 +0,0 @@ -package keeper_test - -// "fmt" - -// func (s *KeeperTestSuite) TestMsgServerSwapTonomUSD() { -// s.SetupTest() - -// tests := []struct { -// name string -// addr sdk.AccAddress -// setup func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom - -// expectPass bool -// expectedReceive math.Int -// }{ -// { -// name: "success", -// addr: s.TestAccs[0], -// setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom { -// coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) -// err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) -// s.Require().NoError(err) -// err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) -// s.Require().NoError(err) - -// _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ -// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), -// Denom: usdt, -// LimitTotal: limitUSDT, -// FeeIn: math.LegacyMustNewDecFromStr("0.001"), -// FeeOut: math.LegacyMustNewDecFromStr("0.001"), -// NomType: "nomUSD", -// }) -// s.Require().NoError(err) - -// amountSwap := sdk.NewCoin(usdt, math.NewInt(1000)) -// return &types.MsgSwapToNom{ -// Address: s.TestAccs[0].String(), -// Coin: amountSwap, -// } -// }, - -// expectPass: true, -// expectedReceive: math.NewInt(999), -// }, -// { -// name: "insufficient balance", -// addr: s.TestAccs[1], -// setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToNom { -// _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ -// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), -// Denom: usdc, -// LimitTotal: limitUSDC, -// FeeIn: math.LegacyMustNewDecFromStr("0.001"), -// FeeOut: math.LegacyMustNewDecFromStr("0.001"), -// NomType: "nomUSD", -// }) -// s.Require().NoError(err) - -// amountSwap := sdk.NewCoin(usdc, math.NewInt(1000)) -// return &types.MsgSwapToNom{ -// Address: s.TestAccs[1].String(), -// Coin: amountSwap, -// } -// }, - -// expectPass: false, -// expectedReceive: math.NewInt(999), -// }, -// } - -// for _, t := range tests { -// s.Run(t.name, func() { -// msg := t.setup(s.Ctx, s.k) - -// _, err := s.msgServer.SwapToNom(s.Ctx, msg) -// if t.expectPass { -// s.Require().NoError(err) -// balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenoms[0]) -// s.Require().Equal(t.expectedReceive, balance.Amount) - -// } else { -// s.Require().Error(err) -// } - -// }) -// } -// } - -// func (s *KeeperTestSuite) TestMsgSwapToStablecoin() { -// s.SetupTest() - -// tests := []struct { -// name string -// addr sdk.AccAddress -// setup func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToStablecoin - -// expectPass bool -// expectedBalancenomUSD math.Int -// }{ -// { -// name: "success", -// addr: s.TestAccs[0], -// setup: func(ctx context.Context, keeper keeper.Keeper) *types.MsgSwapToStablecoin { -// // swaptonomUSD -// coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) -// err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) -// s.Require().NoError(err) -// err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) -// s.Require().NoError(err) - -// _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ -// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), -// Denom: usdt, -// LimitTotal: limitUSDT, -// FeeIn: math.LegacyMustNewDecFromStr("0.001"), -// FeeOut: math.LegacyMustNewDecFromStr("0.001"), -// NomType: "nomUSD", -// }) -// s.Require().NoError(err) - -// amountSwap := sdk.NewCoin(usdt, math.NewInt(1001)) -// msg := &types.MsgSwapToNom{ -// Address: s.TestAccs[0].String(), -// Coin: amountSwap, -// } -// _, err = s.msgServer.SwapToNom(s.Ctx, msg) -// s.Require().NoError(err) - -// return &types.MsgSwapToStablecoin{ -// Address: s.TestAccs[0].String(), -// ToDenom: usdt, -// Coin: sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000)), -// } -// }, - -// expectPass: true, -// expectedBalancenomUSD: math.NewInt(0), -// }, -// } - -// for _, t := range tests { -// s.Run(t.name, func() { -// msg := t.setup(s.Ctx, s.k) - -// _, err := s.msgServer.SwapToStablecoin(s.Ctx, msg) -// if t.expectPass { -// s.Require().NoError(err) -// balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.DefaultMintDenoms[0]) -// s.Require().Equal(t.expectedBalancenomUSD.String(), balance.Amount.String()) - -// } else { -// s.Require().Error(err) -// } - -// }) -// } -// } diff --git a/x/psm/keeper/proposals_test.go b/x/psm/keeper/proposals_test.go index c3d23486..5a122725 100644 --- a/x/psm/keeper/proposals_test.go +++ b/x/psm/keeper/proposals_test.go @@ -11,11 +11,12 @@ func (s *KeeperTestSuite) TestAddStableCoinProposal() { s.SetupTest() proAdd := types.MsgAddStableCoin{ - Denom: usdt, - LimitTotal: limitUSDT, - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), + Denom: usdt, + LimitTotal: limitUSDT, + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + FeeIn: math.LegacyMustNewDecFromStr("0.001"), + FeeOut: math.LegacyMustNewDecFromStr("0.001"), + OracleScript: 44, } _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &proAdd) @@ -31,11 +32,12 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() { s.SetupTest() proAdd := types.MsgAddStableCoin{ - Denom: usdt, - LimitTotal: limitUSDT, - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), + Denom: usdt, + LimitTotal: limitUSDT, + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + FeeIn: math.LegacyMustNewDecFromStr("0.001"), + FeeOut: math.LegacyMustNewDecFromStr("0.001"), + OracleScript: 44, } _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &proAdd) @@ -50,11 +52,12 @@ func (s *KeeperTestSuite) TestUpdateStableCoinProposal() { limitTotalUpdates := math.NewInt(2000000) proUpdates := types.MsgUpdatesStableCoin{ - Denom: usdt, - LimitTotal: limitTotalUpdates, - Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - FeeIn: math.LegacyMustNewDecFromStr("0.001"), - FeeOut: math.LegacyMustNewDecFromStr("0.001"), + Denom: usdt, + LimitTotal: limitTotalUpdates, + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + FeeIn: math.LegacyMustNewDecFromStr("0.001"), + FeeOut: math.LegacyMustNewDecFromStr("0.001"), + OracleScript: 44, } _, err = s.msgServer.UpdatesStableCoinProposal(s.Ctx, &proUpdates) diff --git a/x/psm/keeper/swap_test.go b/x/psm/keeper/swap_test.go index 18ca8c06..03b1775b 100644 --- a/x/psm/keeper/swap_test.go +++ b/x/psm/keeper/swap_test.go @@ -1,152 +1,167 @@ package keeper_test -// TODO: refactor test -// func (s *KeeperTestSuite) TestSwapTonomUSD() { -// s.SetupTest() - -// tests := []struct { -// name string -// setup func(ctx context.Context, keeper keeper.Keeper) -// addr sdk.AccAddress -// stablecoin sdk.Coin - -// expectPass bool -// expectedReceive math.Int -// expectedFee math.LegacyDec -// }{ -// { -// name: "success", -// setup: func(ctx context.Context, keeper keeper.Keeper) { -// coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) -// err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) -// s.Require().NoError(err) -// err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) -// s.Require().NoError(err) - -// _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ -// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), -// Denom: usdt, -// LimitTotal: limitUSDT, -// FeeIn: math.LegacyMustNewDecFromStr("0.001"), -// FeeOut: math.LegacyMustNewDecFromStr("0.001"), -// }) -// s.Require().NoError(err) -// }, -// addr: s.TestAccs[0], -// stablecoin: sdk.NewCoin(usdt, math.NewInt(1000)), -// expectPass: true, -// expectedReceive: math.NewInt(999), -// expectedFee: math.LegacyMustNewDecFromStr("1"), -// }, -// { -// name: "insufficient balance", -// setup: func(ctx context.Context, keeper keeper.Keeper) { -// _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ -// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), -// Denom: usdc, -// LimitTotal: limitUSDC, -// FeeIn: math.LegacyMustNewDecFromStr("0.001"), -// FeeOut: math.LegacyMustNewDecFromStr("0.001"), -// }) -// s.Require().NoError(err) -// }, -// addr: s.TestAccs[1], -// stablecoin: sdk.NewCoin(usdt, math.NewInt(1000)), -// expectPass: false, -// expectedReceive: math.NewInt(999), -// expectedFee: math.LegacyMustNewDecFromStr("1"), -// }, -// } - -// for _, t := range tests { -// s.Run(t.name, func() { -// t.setup(s.Ctx, s.k) - -// receiveAmount, fee, err := s.k.SwapToOnomyStableToken(s.Ctx, t.addr, t.stablecoin) -// if t.expectPass { -// s.Require().NoError(err) -// s.Require().Equal(t.expectedReceive, receiveAmount) -// s.Require().Equal(t.expectedFee, fee.Amount) -// } else { -// s.Require().Error(err) -// } - -// }) -// } -// } - -// func (s *KeeperTestSuite) TestSwapToStablecoin() { -// s.SetupTest() - -// tests := []struct { -// name string -// setup func(ctx context.Context, keeper keeper.Keeper) -// addr sdk.AccAddress -// amount math.Int -// toDenom string - -// expectPass bool -// expectedReceive math.Int -// expectedFee math.LegacyDec -// }{ -// { -// name: "success", -// setup: func(ctx context.Context, keeper keeper.Keeper) { -// coinsMint := sdk.NewCoins(sdk.NewCoin(types.DefaultMintDenoms[0], math.NewInt(1000000))) -// err := keeper.BankKeeper.MintCoins(ctx, types.ModuleName, coinsMint) -// s.Require().NoError(err) -// err = keeper.BankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, s.TestAccs[0], coinsMint) -// s.Require().NoError(err) - -// _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ -// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), -// Denom: usdt, -// LimitTotal: limitUSDT, -// FeeIn: math.LegacyMustNewDecFromStr("0.001"), -// FeeOut: math.LegacyMustNewDecFromStr("0.001"), -// NomType: "nomUSD", -// }) -// s.Require().NoError(err) -// }, -// addr: s.TestAccs[0], -// amount: math.NewInt(1000), -// toDenom: usdt, -// expectPass: true, -// expectedReceive: math.NewInt(999), -// expectedFee: math.LegacyMustNewDecFromStr("1"), -// }, -// { -// name: "insufficient balance", -// setup: func(ctx context.Context, keeper keeper.Keeper) { -// _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ -// Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), -// Denom: usdc, -// LimitTotal: limitUSDC, -// FeeIn: math.LegacyMustNewDecFromStr("0.001"), -// FeeOut: math.LegacyMustNewDecFromStr("0.001"), -// }) -// s.Require().NoError(err) -// }, -// addr: s.TestAccs[1], -// amount: math.NewInt(1000), -// toDenom: usdt, -// expectPass: false, -// expectedReceive: math.NewInt(999), -// expectedFee: math.LegacyMustNewDecFromStr("1"), -// }, -// } - -// for _, t := range tests { -// s.Run(t.name, func() { -// t.setup(s.Ctx, s.k) -// // TODO: balances check -// err := s.k.SwapToOtherStablecoin(s.Ctx, t.amount, t.toDenom) -// if t.expectPass { -// s.Require().NoError(err) -// } else { -// s.Require().Error(err) -// } - -// }) -// } -// } +import ( + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/onomyprotocol/reserve/x/psm/types" +) + +func (s *KeeperTestSuite) TestSwapToOnomyStableToken() { + tests := []struct { + name string + addr sdk.AccAddress + offerCoin sdk.Coin + expectedDenom string + + setup func() + + expectPass bool + expectedReceive math.Int + }{ + { + name: "success", + addr: s.TestAccs[0], + offerCoin: sdk.NewCoin(usdt, math.NewInt(1000)), + expectedDenom: types.ReserveStableCoinDenom, + setup: func() { + coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(1000000))) + err := s.k.BankKeeper.MintCoins(s.Ctx, types.ModuleName, coinsMint) + s.Require().NoError(err) + err = s.k.BankKeeper.SendCoinsFromModuleToAccount(s.Ctx, types.ModuleName, s.TestAccs[0], coinsMint) + s.Require().NoError(err) + + _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Denom: usdt, + LimitTotal: limitUSDT, + FeeIn: math.LegacyMustNewDecFromStr("0.001"), + FeeOut: math.LegacyMustNewDecFromStr("0.001"), + OracleScript: 44, + }) + s.Require().NoError(err) + }, + + expectPass: true, + expectedReceive: math.NewInt(999), + }, + { + name: "insufficient balance", + addr: s.TestAccs[1], + setup: func() { + _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Denom: usdc, + LimitTotal: limitUSDC, + FeeIn: math.LegacyMustNewDecFromStr("0.001"), + FeeOut: math.LegacyMustNewDecFromStr("0.001"), + OracleScript: 44, + }) + s.Require().NoError(err) + }, + + expectPass: false, + expectedReceive: math.NewInt(999), + }, + } + + for _, t := range tests { + s.Run(t.name, func() { + s.SetupTest() + t.setup() + + err := s.k.SwapToOnomyStableToken(s.Ctx, t.addr, t.offerCoin, t.expectedDenom) + if t.expectPass { + s.Require().NoError(err) + balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, types.ReserveStableCoinDenom) + s.Require().Equal(t.expectedReceive, balance.Amount) + + } else { + s.Require().Error(err) + } + + }) + } +} + +func (s *KeeperTestSuite) TestSwapToOtherStablecoin() { + tests := []struct { + name string + addr sdk.AccAddress + offerCoin sdk.Coin + expectedDenom string + + setup func() + + expectPass bool + expectedReceive math.Int + }{ + { + name: "success", + addr: s.TestAccs[0], + offerCoin: sdk.NewCoin(types.ReserveStableCoinDenom, math.NewInt(1000)), + expectedDenom: usdt, + setup: func() { + coinsMint := sdk.NewCoins(sdk.NewCoin(usdt, math.NewInt(2000000))) + err := s.k.BankKeeper.MintCoins(s.Ctx, types.ModuleName, coinsMint) + s.Require().NoError(err) + err = s.k.BankKeeper.SendCoinsFromModuleToAccount(s.Ctx, types.ModuleName, s.TestAccs[0], coinsMint) + s.Require().NoError(err) + + _, err = s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Denom: usdt, + LimitTotal: limitUSDT, + FeeIn: math.LegacyMustNewDecFromStr("0.001"), + FeeOut: math.LegacyMustNewDecFromStr("0.001"), + OracleScript: 44, + }) + s.Require().NoError(err) + + // lock + err = s.k.SwapToOnomyStableToken(s.Ctx, s.TestAccs[0], coinsMint[0], types.ReserveStableCoinDenom) + s.Require().NoError(err) + }, + + expectPass: true, + expectedReceive: math.NewInt(999), + }, + { + name: "insufficient balance", + addr: s.TestAccs[1], + setup: func() { + _, err := s.msgServer.AddStableCoinProposal(s.Ctx, &types.MsgAddStableCoin{ + Authority: authtypes.NewModuleAddress(govtypes.ModuleName).String(), + Denom: usdc, + LimitTotal: limitUSDC, + FeeIn: math.LegacyMustNewDecFromStr("0.001"), + FeeOut: math.LegacyMustNewDecFromStr("0.001"), + OracleScript: 44, + }) + s.Require().NoError(err) + }, + + expectPass: false, + expectedReceive: math.NewInt(999), + }, + } + + for _, t := range tests { + s.Run(t.name, func() { + s.SetupTest() + t.setup() + + err := s.k.SwapToOtherStablecoin(s.Ctx, t.addr, t.offerCoin, t.expectedDenom) + if t.expectPass { + s.Require().NoError(err) + balance := s.k.BankKeeper.GetBalance(s.Ctx, t.addr, usdt) + s.Require().True(t.expectedReceive.Equal(balance.Amount)) + } else { + s.Require().Error(err) + } + + }) + } +} From 038f33bb7d3c84797f630d5aec35384188723937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CDongLieu=E2=80=9D?= Date: Fri, 8 Nov 2024 18:12:36 +0700 Subject: [PATCH 42/42] update spec psm --- x/psm/README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/x/psm/README.md b/x/psm/README.md index 733e72af..5f39d028 100644 --- a/x/psm/README.md +++ b/x/psm/README.md @@ -110,15 +110,16 @@ message Stablecoin { ``` -## Messages +## Messages -### MsgSwapTonomUSD -Allows users to swap accepted stablecoins for nomUSD. `Address` is the sender's address, `Coin` is the amount of stablecoin the user sent +### MsgStableSwap (swap to nomUSD) +Allows users to swap accepted stablecoins for nomUSD. `Address` is the sender's address, `OfferCoin` is the amount of stablecoin the user sent. `ExpectedDenom` is the type of denom expected to be received. ```{.go} -type MsgSwapTonomUSD struct { - Address string - Coin *types.Coin +type MsgStableSwap struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + ExpectedDenom string `protobuf:"bytes,2,opt,name=expected_denom,json=expectedDenom,proto3" json:"expected_denom,omitempty"` + OfferCoin types.Coin `protobuf:"bytes,3,opt,name=offer_coin,json=offerCoin,proto3" json:"offer_coin"` } ``` @@ -132,14 +133,14 @@ type MsgSwapTonomUSD struct { - Transfer stablecoin from user to psm module. - Mint nomUSD and send for user -### MsgSwapToStablecoin -Allows users to swap accepted nomUSD for stablecoins. `Address` is the sender's address, `ToDenom` is the stablecoin name to receive ,`Amount` is the amount of nomUSD the user sent +### MsgStableSwap (swap to stablecoin) +Allows users to swap accepted nomUSD for stablecoins. `Address` is the sender's address, `ExpectedDenom` is the stablecoin name to receive ,`OfferCoin` is the amount of nomUSD the user sent ```{.go} -type MsgSwapToStablecoin struct { - Address string - ToDenom string - Amount math.Int +type MsgStableSwap struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + ExpectedDenom string `protobuf:"bytes,2,opt,name=expected_denom,json=expectedDenom,proto3" json:"expected_denom,omitempty"` + OfferCoin types.Coin `protobuf:"bytes,3,opt,name=offer_coin,json=offerCoin,proto3" json:"offer_coin"` } ``` @@ -158,8 +159,7 @@ type MsgSwapToStablecoin struct { The PSM module emits events for various operations: - **AddStablecoin**: Emitted when a new stablecoin is added. - **UpdateStablecoin**: Emitted when a stablecoin is updates -- **SwapToStablecoin**: Emitted when exchanging nomUSD for stablecoin -- **SwapTonomUSD**: Emitted when exchanging stablecoin for nomUSD +- **Swap**: Emitted when exchanging nomUSD for stablecoin. Emitted when exchanging stablecoin for nomUSD ## ABCI