diff --git a/proto/side/btcbridge/params.proto b/proto/side/btcbridge/params.proto index 3350380a..543fe7e0 100644 --- a/proto/side/btcbridge/params.proto +++ b/proto/side/btcbridge/params.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package side.btcbridge; import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/sideprotocol/side/x/btcbridge/types"; @@ -13,9 +14,16 @@ message Params { int32 confirmations = 2; // Indicates the maximum depth or distance from the latest block up to which transactions are considered for acceptance. uint64 max_acceptable_block_depth = 3; - // the denomanation of the voucher + // The denomination of the voucher string btc_voucher_denom = 4; + // Vault list repeated Vault vaults = 5; + // Protocol limitations + ProtocolLimits protocol_limits = 6; + // Protocol fees + ProtocolFees protocol_fees = 7; + // Network fee for withdrawal to bitcoin + int64 NetworkFee = 8; } // AssetType defines the type of asset @@ -26,11 +34,11 @@ enum AssetType { ASSET_TYPE_BTC = 1; // BRC20: ordi, sats ASSET_TYPE_BRC20 = 2; - // RUNE: dog*go*to*the*moon + // RUNE, dog*go*to*the*moon ASSET_TYPE_RUNE = 3; } -// Vault defines the vault. +// Vault defines the asset vault message Vault { // the depositor should send their btc to this address string address = 1; @@ -39,3 +47,23 @@ message Vault { // the address to which the voucher is sent AssetType asset_type = 3; } + +// ProtocolLimits defines the params related to the the protocol limitations +message ProtocolLimits { + // The minimum deposit amount for btc + int64 btc_min_deposit = 1; + // The minimum withdrawal amount for btc + int64 btc_min_withdraw = 2; + // The maximum withdrawal amount for btc + int64 btc_max_withdraw = 3; +} + +// ProtocolFees defines the params related to the protocol fees +message ProtocolFees { + // Protocol fee amount for deposit + int64 deposit_fee = 1; + // Protocol fee amount for withdrawal + int64 withdraw_fee = 2; + // Protocol fee collector + string collector = 3; +} diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index 7da7c87a..9598adef 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -194,22 +194,32 @@ func (k Keeper) mintBTC(ctx sdk.Context, tx *btcutil.Tx, height uint64, sender s } k.addToMintHistory(ctx, hash) - // mint the voucher token - if len(denom) == 0 { - denom = "sat" + params := k.GetParams(ctx) + + protocolFee := sdk.NewInt64Coin(denom, params.ProtocolFees.DepositFee) + protocolFeeCollector := sdk.MustAccAddressFromBech32(params.ProtocolFees.Collector) + + amount := sdk.NewInt64Coin(denom, out.Value) + + depositAmount := amount.Sub(protocolFee) + if depositAmount.Amount.Int64() < params.ProtocolLimits.BtcMinDeposit { + return types.ErrInvalidDepositAmount } - coins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(out.Value))) receipient, err := sdk.AccAddressFromBech32(sender) if err != nil { return err } - if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, coins); err != nil { + if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(amount)); err != nil { + return err + } + + if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receipient, sdk.NewCoins(depositAmount)); err != nil { return err } - if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receipient, coins); err != nil { + if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, protocolFeeCollector, sdk.NewCoins(protocolFee)); err != nil { return err } diff --git a/x/btcbridge/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go index 07c4cdc3..d5906111 100644 --- a/x/btcbridge/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -131,25 +131,44 @@ func (m msgServer) WithdrawBitcoin(goCtx context.Context, msg *types.MsgWithdraw ctx := sdk.UnwrapSDKContext(goCtx) + params := m.GetParams(ctx) + sender := sdk.MustAccAddressFromBech32(msg.Sender) - coin, err := sdk.ParseCoinNormalized(msg.Amount) + amount, err := sdk.ParseCoinNormalized(msg.Amount) if err != nil { return nil, err } - if coin.Denom == m.GetParams(ctx).BtcVoucherDenom { - if err := types.CheckOutputAmount(msg.Sender, coin.Amount.Int64()); err != nil { + networkFee := sdk.NewInt64Coin(params.BtcVoucherDenom, params.NetworkFee) + + if amount.Denom == params.BtcVoucherDenom { + protocolFee := sdk.NewInt64Coin(params.BtcVoucherDenom, params.ProtocolFees.WithdrawFee) + + amount = amount.Sub(networkFee).Sub(protocolFee) + if amount.Amount.Int64() < params.ProtocolLimits.BtcMinWithdraw || amount.Amount.Int64() > params.ProtocolLimits.BtcMaxWithdraw { + return nil, types.ErrInvalidWithdrawAmount + } + + if err := types.CheckOutputAmount(msg.Sender, amount.Amount.Int64()); err != nil { + return nil, types.ErrInvalidWithdrawAmount + } + + if err := m.bankKeeper.SendCoins(ctx, sender, sdk.MustAccAddressFromBech32(params.ProtocolFees.Collector), sdk.NewCoins(protocolFee)); err != nil { return nil, err } } - req, err := m.Keeper.NewWithdrawRequest(ctx, msg.Sender, coin) + req, err := m.Keeper.NewWithdrawRequest(ctx, msg.Sender, amount) if err != nil { return nil, err } - if err = m.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.NewCoins(coin)); err != nil { + if err := m.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.NewCoins(amount, networkFee)); err != nil { + return nil, err + } + + if err := m.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(amount, networkFee)); err != nil { return nil, err } diff --git a/x/btcbridge/types/errors.go b/x/btcbridge/types/errors.go index 20db4999..fbffc27f 100644 --- a/x/btcbridge/types/errors.go +++ b/x/btcbridge/types/errors.go @@ -36,4 +36,7 @@ var ( ErrInvalidRuneId = errorsmod.Register(ModuleName, 6101, "invalid rune id") ErrInvalidParams = errorsmod.Register(ModuleName, 7100, "invalid module params") + + ErrInvalidDepositAmount = errorsmod.Register(ModuleName, 8100, "invalid deposit amount") + ErrInvalidWithdrawAmount = errorsmod.Register(ModuleName, 8101, "invalid withdrawal amount") ) diff --git a/x/btcbridge/types/params.go b/x/btcbridge/types/params.go index d22ce6ee..9aab0cc9 100644 --- a/x/btcbridge/types/params.go +++ b/x/btcbridge/types/params.go @@ -27,6 +27,16 @@ func NewParams(relayers []string) Params { PubKey: "", AssetType: AssetType_ASSET_TYPE_RUNE, }}, + ProtocolLimits: &ProtocolLimits{ + BtcMinDeposit: 50000, // 0.0005BTC + BtcMinWithdraw: 30000, // 0.0003BTC + BtcMaxWithdraw: 500000000, // 5BTC + }, + ProtocolFees: &ProtocolFees{ + DepositFee: 8000, // 0.00008BTC + WithdrawFee: 12000, // 0.00012BTC + Collector: "", + }, } } @@ -78,6 +88,21 @@ func (p Params) Validate() error { } } + if p.ProtocolLimits != nil { + if p.ProtocolLimits.BtcMinWithdraw > p.ProtocolLimits.BtcMaxWithdraw { + return ErrInvalidParams + } + } + + if p.ProtocolFees != nil { + if len(p.ProtocolFees.Collector) != 0 { + _, err := sdk.AccAddressFromBech32(p.ProtocolFees.Collector) + if err != nil { + return ErrInvalidParams + } + } + } + return nil } diff --git a/x/btcbridge/types/params.pb.go b/x/btcbridge/types/params.pb.go index f6884a6c..5f432d71 100644 --- a/x/btcbridge/types/params.pb.go +++ b/x/btcbridge/types/params.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -33,7 +34,7 @@ const ( AssetType_ASSET_TYPE_BTC AssetType = 1 // BRC20: ordi, sats AssetType_ASSET_TYPE_BRC20 AssetType = 2 - // RUNE: dog*go*to*the*moon + // RUNE, dog*go*to*the*moon AssetType_ASSET_TYPE_RUNE AssetType = 3 ) @@ -67,9 +68,16 @@ type Params struct { Confirmations int32 `protobuf:"varint,2,opt,name=confirmations,proto3" json:"confirmations,omitempty"` // Indicates the maximum depth or distance from the latest block up to which transactions are considered for acceptance. MaxAcceptableBlockDepth uint64 `protobuf:"varint,3,opt,name=max_acceptable_block_depth,json=maxAcceptableBlockDepth,proto3" json:"max_acceptable_block_depth,omitempty"` - // the denomanation of the voucher - BtcVoucherDenom string `protobuf:"bytes,4,opt,name=btc_voucher_denom,json=btcVoucherDenom,proto3" json:"btc_voucher_denom,omitempty"` - Vaults []*Vault `protobuf:"bytes,5,rep,name=vaults,proto3" json:"vaults,omitempty"` + // The denomination of the voucher + BtcVoucherDenom string `protobuf:"bytes,4,opt,name=btc_voucher_denom,json=btcVoucherDenom,proto3" json:"btc_voucher_denom,omitempty"` + // Vault list + Vaults []*Vault `protobuf:"bytes,5,rep,name=vaults,proto3" json:"vaults,omitempty"` + // Protocol limitations + ProtocolLimits *ProtocolLimits `protobuf:"bytes,6,opt,name=protocol_limits,json=protocolLimits,proto3" json:"protocol_limits,omitempty"` + // Protocol fees + ProtocolFees *ProtocolFees `protobuf:"bytes,7,opt,name=protocol_fees,json=protocolFees,proto3" json:"protocol_fees,omitempty"` + // Network fee for withdrawal to bitcoin + NetworkFee int64 `protobuf:"varint,8,opt,name=NetworkFee,proto3" json:"NetworkFee,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -140,7 +148,28 @@ func (m *Params) GetVaults() []*Vault { return nil } -// Vault defines the vault. +func (m *Params) GetProtocolLimits() *ProtocolLimits { + if m != nil { + return m.ProtocolLimits + } + return nil +} + +func (m *Params) GetProtocolFees() *ProtocolFees { + if m != nil { + return m.ProtocolFees + } + return nil +} + +func (m *Params) GetNetworkFee() int64 { + if m != nil { + return m.NetworkFee + } + return 0 +} + +// Vault defines the asset vault type Vault struct { // the depositor should send their btc to this address Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` @@ -204,44 +233,187 @@ func (m *Vault) GetAssetType() AssetType { return AssetType_ASSET_TYPE_UNSPECIFIED } +// ProtocolLimits defines the params related to the the protocol limitations +type ProtocolLimits struct { + // The minimum deposit amount for btc + BtcMinDeposit int64 `protobuf:"varint,1,opt,name=btc_min_deposit,json=btcMinDeposit,proto3" json:"btc_min_deposit,omitempty"` + // The minimum withdrawal amount for btc + BtcMinWithdraw int64 `protobuf:"varint,2,opt,name=btc_min_withdraw,json=btcMinWithdraw,proto3" json:"btc_min_withdraw,omitempty"` + // The maximum withdrawal amount for btc + BtcMaxWithdraw int64 `protobuf:"varint,3,opt,name=btc_max_withdraw,json=btcMaxWithdraw,proto3" json:"btc_max_withdraw,omitempty"` +} + +func (m *ProtocolLimits) Reset() { *m = ProtocolLimits{} } +func (m *ProtocolLimits) String() string { return proto.CompactTextString(m) } +func (*ProtocolLimits) ProtoMessage() {} +func (*ProtocolLimits) Descriptor() ([]byte, []int) { + return fileDescriptor_f1d33573cda8a6d2, []int{2} +} +func (m *ProtocolLimits) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProtocolLimits) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProtocolLimits.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 *ProtocolLimits) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProtocolLimits.Merge(m, src) +} +func (m *ProtocolLimits) XXX_Size() int { + return m.Size() +} +func (m *ProtocolLimits) XXX_DiscardUnknown() { + xxx_messageInfo_ProtocolLimits.DiscardUnknown(m) +} + +var xxx_messageInfo_ProtocolLimits proto.InternalMessageInfo + +func (m *ProtocolLimits) GetBtcMinDeposit() int64 { + if m != nil { + return m.BtcMinDeposit + } + return 0 +} + +func (m *ProtocolLimits) GetBtcMinWithdraw() int64 { + if m != nil { + return m.BtcMinWithdraw + } + return 0 +} + +func (m *ProtocolLimits) GetBtcMaxWithdraw() int64 { + if m != nil { + return m.BtcMaxWithdraw + } + return 0 +} + +// ProtocolFees defines the params related to the protocol fees +type ProtocolFees struct { + // Protocol fee amount for deposit + DepositFee int64 `protobuf:"varint,1,opt,name=deposit_fee,json=depositFee,proto3" json:"deposit_fee,omitempty"` + // Protocol fee amount for withdrawal + WithdrawFee int64 `protobuf:"varint,2,opt,name=withdraw_fee,json=withdrawFee,proto3" json:"withdraw_fee,omitempty"` + // Protocol fee collector + Collector string `protobuf:"bytes,3,opt,name=collector,proto3" json:"collector,omitempty"` +} + +func (m *ProtocolFees) Reset() { *m = ProtocolFees{} } +func (m *ProtocolFees) String() string { return proto.CompactTextString(m) } +func (*ProtocolFees) ProtoMessage() {} +func (*ProtocolFees) Descriptor() ([]byte, []int) { + return fileDescriptor_f1d33573cda8a6d2, []int{3} +} +func (m *ProtocolFees) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProtocolFees) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProtocolFees.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 *ProtocolFees) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProtocolFees.Merge(m, src) +} +func (m *ProtocolFees) XXX_Size() int { + return m.Size() +} +func (m *ProtocolFees) XXX_DiscardUnknown() { + xxx_messageInfo_ProtocolFees.DiscardUnknown(m) +} + +var xxx_messageInfo_ProtocolFees proto.InternalMessageInfo + +func (m *ProtocolFees) GetDepositFee() int64 { + if m != nil { + return m.DepositFee + } + return 0 +} + +func (m *ProtocolFees) GetWithdrawFee() int64 { + if m != nil { + return m.WithdrawFee + } + return 0 +} + +func (m *ProtocolFees) GetCollector() string { + if m != nil { + return m.Collector + } + return "" +} + func init() { proto.RegisterEnum("side.btcbridge.AssetType", AssetType_name, AssetType_value) proto.RegisterType((*Params)(nil), "side.btcbridge.Params") proto.RegisterType((*Vault)(nil), "side.btcbridge.Vault") + proto.RegisterType((*ProtocolLimits)(nil), "side.btcbridge.ProtocolLimits") + proto.RegisterType((*ProtocolFees)(nil), "side.btcbridge.ProtocolFees") } func init() { proto.RegisterFile("side/btcbridge/params.proto", fileDescriptor_f1d33573cda8a6d2) } var fileDescriptor_f1d33573cda8a6d2 = []byte{ - // 443 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x4d, 0x6b, 0xdb, 0x30, - 0x18, 0xc7, 0xe3, 0xa6, 0x49, 0xb1, 0xc6, 0x52, 0x4f, 0xed, 0x56, 0x2f, 0x03, 0x63, 0xca, 0x0e, - 0xa6, 0x30, 0x7b, 0x64, 0x97, 0xc1, 0x4e, 0x79, 0xf1, 0x58, 0x19, 0x94, 0xa0, 0xa4, 0x85, 0xed, - 0x22, 0x24, 0x59, 0x4d, 0x4c, 0xed, 0xc8, 0x48, 0x72, 0x89, 0xf7, 0x29, 0xf6, 0xb1, 0x76, 0xec, - 0x71, 0xc7, 0x91, 0x7c, 0x88, 0x5d, 0x87, 0xdc, 0x36, 0x4b, 0x7a, 0xd3, 0xf3, 0xfb, 0xfd, 0xfd, - 0xf2, 0x17, 0x0f, 0x78, 0xa3, 0xd2, 0x84, 0x47, 0x54, 0x33, 0x2a, 0xd3, 0x64, 0xc6, 0xa3, 0x82, - 0x48, 0x92, 0xab, 0xb0, 0x90, 0x42, 0x0b, 0xd8, 0x31, 0x32, 0xdc, 0xc8, 0xee, 0xf1, 0x4c, 0xcc, - 0x44, 0xad, 0x22, 0x73, 0xba, 0x4f, 0x9d, 0xfe, 0xb5, 0x40, 0x7b, 0x5c, 0x3f, 0x06, 0x23, 0x70, - 0x44, 0x4a, 0x3d, 0x17, 0x32, 0xfd, 0xc1, 0x13, 0x2c, 0x79, 0x46, 0x2a, 0x2e, 0x95, 0x6b, 0xf9, - 0xcd, 0xc0, 0x46, 0xf0, 0xbf, 0x42, 0x0f, 0x06, 0xbe, 0x05, 0xcf, 0x99, 0x58, 0x5c, 0xa7, 0x32, - 0x27, 0x3a, 0x15, 0x0b, 0xe5, 0xee, 0xf9, 0x56, 0xd0, 0x42, 0xbb, 0x10, 0x7e, 0x02, 0xdd, 0x9c, - 0x2c, 0x31, 0x61, 0x8c,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, 0xc3, 0xde, 0x7b, 0x67, 0x0f, - 0x1e, 0x81, 0xc3, 0x2d, 0x8a, 0x2e, 0x2f, 0x62, 0xa7, 0x39, 0xf8, 0xf2, 0x6b, 0xe5, 0x59, 0x77, - 0x2b, 0xcf, 0xfa, 0xb3, 0xf2, 0xac, 0x9f, 0x6b, 0xaf, 0x71, 0xb7, 0xf6, 0x1a, 0xbf, 0xd7, 0x5e, - 0xe3, 0x7b, 0x38, 0x4b, 0xf5, 0xbc, 0xa4, 0x21, 0x13, 0x79, 0x64, 0xfe, 0xb8, 0xde, 0x03, 0x26, - 0xb2, 0x7a, 0x88, 0x96, 0x5b, 0xeb, 0x64, 0xca, 0x29, 0xda, 0xae, 0x03, 0x1f, 0xfe, 0x05, 0x00, - 0x00, 0xff, 0xff, 0x7b, 0xe1, 0x72, 0xe5, 0x6d, 0x02, 0x00, 0x00, + // 647 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x94, 0xcd, 0x6e, 0xd3, 0x40, + 0x14, 0x85, 0xe3, 0xba, 0x4d, 0xc9, 0x4d, 0x9b, 0x86, 0x69, 0xa1, 0x26, 0x54, 0x26, 0x44, 0x08, + 0x59, 0x95, 0x88, 0x69, 0xd8, 0x20, 0xb1, 0x4a, 0x9b, 0x04, 0x2a, 0xa0, 0x8a, 0xa6, 0x69, 0x11, + 0x6c, 0xac, 0xf1, 0x78, 0x9a, 0x58, 0xb5, 0x33, 0x96, 0x67, 0xd2, 0x26, 0x3c, 0x03, 0x0b, 0xde, + 0x81, 0x97, 0x61, 0xd9, 0x25, 0x4b, 0xd4, 0xbe, 0x08, 0x9a, 0xc9, 0x7f, 0x25, 0x76, 0xbe, 0xe7, + 0x7c, 0xb9, 0x39, 0x39, 0x37, 0x32, 0x3c, 0x15, 0x61, 0xc0, 0x5c, 0x5f, 0x52, 0x3f, 0x0d, 0x83, + 0x2e, 0x73, 0x13, 0x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32, 0x51, 0x67, 0x24, 0x19, 0xce, 0x49, 0x73, 0x4e, 0x92, 0xe1, 0x94, 0xac, 0x24, 0xb0, 0xb1, + 0x58, 0x21, 0x7a, 0x06, 0xf9, 0x49, 0x06, 0x55, 0xfb, 0x24, 0x07, 0x4c, 0xa4, 0x16, 0x63, 0xe8, + 0x39, 0x6c, 0x4c, 0x57, 0x6a, 0x62, 0x1c, 0x20, 0x3f, 0xd5, 0x14, 0xb2, 0x07, 0x39, 0xca, 0xa3, + 0x88, 0x51, 0xc9, 0x53, 0xfd, 0xb5, 0x39, 0x3c, 0x17, 0xf6, 0x2f, 0x20, 0x37, 0x2b, 0x06, 0x95, + 0xe0, 0x71, 0xfd, 0xf4, 0xb4, 0xd9, 0xf1, 0x3a, 0x5f, 0xdb, 0x4d, 0xef, 0xec, 0xe4, 0xb4, 0xdd, + 0x3c, 0x3a, 0x6e, 0x1d, 0x37, 0x1b, 0xc5, 0x0c, 0x42, 0x50, 0x58, 0xf0, 0x0e, 0x3b, 0x47, 0x45, + 0x03, 0xed, 0x40, 0x71, 0x51, 0xc3, 0x47, 0xb5, 0xd7, 0xc5, 0x15, 0xb4, 0x0d, 0x5b, 0x0b, 0x2a, + 0x3e, 0x3b, 0x69, 0x16, 0xcd, 0xc3, 0x0f, 0xbf, 0x6f, 0x6d, 0xe3, 0xe6, 0xd6, 0x36, 0xfe, 0xde, + 0xda, 0xc6, 0xcf, 0x3b, 0x3b, 0x73, 0x73, 0x67, 0x67, 0xfe, 0xdc, 0xd9, 0x99, 0x6f, 0xd5, 0x6e, + 0x28, 0x7b, 0x03, 0xbf, 0x4a, 0x79, 0xec, 0xaa, 0x93, 0x4d, 0xff, 0x35, 0x7a, 0x70, 0x87, 0x0b, + 0xef, 0x06, 0x75, 0x5d, 0xe1, 0x67, 0x35, 0xf0, 0xe6, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, + 0x97, 0x9a, 0x31, 0x3a, 0x04, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -264,6 +436,35 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.NetworkFee != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.NetworkFee)) + i-- + dAtA[i] = 0x40 + } + if m.ProtocolFees != nil { + { + size, err := m.ProtocolFees.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if m.ProtocolLimits != nil { + { + size, err := m.ProtocolLimits.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } if len(m.Vaults) > 0 { for iNdEx := len(m.Vaults) - 1; iNdEx >= 0; iNdEx-- { { @@ -349,6 +550,84 @@ func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ProtocolLimits) 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 *ProtocolLimits) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProtocolLimits) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BtcMaxWithdraw != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.BtcMaxWithdraw)) + i-- + dAtA[i] = 0x18 + } + if m.BtcMinWithdraw != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.BtcMinWithdraw)) + i-- + dAtA[i] = 0x10 + } + if m.BtcMinDeposit != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.BtcMinDeposit)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ProtocolFees) 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 *ProtocolFees) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProtocolFees) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Collector) > 0 { + i -= len(m.Collector) + copy(dAtA[i:], m.Collector) + i = encodeVarintParams(dAtA, i, uint64(len(m.Collector))) + i-- + dAtA[i] = 0x1a + } + if m.WithdrawFee != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.WithdrawFee)) + i-- + dAtA[i] = 0x10 + } + if m.DepositFee != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.DepositFee)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -388,6 +667,17 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) } } + if m.ProtocolLimits != nil { + l = m.ProtocolLimits.Size() + n += 1 + l + sovParams(uint64(l)) + } + if m.ProtocolFees != nil { + l = m.ProtocolFees.Size() + n += 1 + l + sovParams(uint64(l)) + } + if m.NetworkFee != 0 { + n += 1 + sovParams(uint64(m.NetworkFee)) + } return n } @@ -411,6 +701,43 @@ func (m *Vault) Size() (n int) { return n } +func (m *ProtocolLimits) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BtcMinDeposit != 0 { + n += 1 + sovParams(uint64(m.BtcMinDeposit)) + } + if m.BtcMinWithdraw != 0 { + n += 1 + sovParams(uint64(m.BtcMinWithdraw)) + } + if m.BtcMaxWithdraw != 0 { + n += 1 + sovParams(uint64(m.BtcMaxWithdraw)) + } + return n +} + +func (m *ProtocolFees) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.DepositFee != 0 { + n += 1 + sovParams(uint64(m.DepositFee)) + } + if m.WithdrawFee != 0 { + n += 1 + sovParams(uint64(m.WithdrawFee)) + } + l = len(m.Collector) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + return n +} + func sovParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -582,6 +909,97 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProtocolLimits", 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.ProtocolLimits == nil { + m.ProtocolLimits = &ProtocolLimits{} + } + if err := m.ProtocolLimits.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProtocolFees", 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.ProtocolFees == nil { + m.ProtocolFees = &ProtocolFees{} + } + if err := m.ProtocolFees.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NetworkFee", wireType) + } + m.NetworkFee = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NetworkFee |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) @@ -736,6 +1154,233 @@ func (m *Vault) Unmarshal(dAtA []byte) error { } return nil } +func (m *ProtocolLimits) 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: ProtocolLimits: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProtocolLimits: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcMinDeposit", wireType) + } + m.BtcMinDeposit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BtcMinDeposit |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcMinWithdraw", wireType) + } + m.BtcMinWithdraw = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BtcMinWithdraw |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcMaxWithdraw", wireType) + } + m.BtcMaxWithdraw = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BtcMaxWithdraw |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *ProtocolFees) 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: ProtocolFees: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProtocolFees: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DepositFee", wireType) + } + m.DepositFee = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DepositFee |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawFee", wireType) + } + m.WithdrawFee = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.WithdrawFee |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Collector", 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.Collector = 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 skipParams(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0