From b3da19909563704322ac9f01fab735491951782f Mon Sep 17 00:00:00 2001 From: orngefrost Date: Sun, 18 Oct 2020 22:30:10 +0900 Subject: [PATCH 1/3] feat(proto): add liquidity-pool related protobuf messages --- proto/osmosis/gamm/v1beta1/pool.proto | 55 +++++++++++++++++++++++++++ proto/osmosis/gamm/v1beta1/tx.proto | 24 ++++-------- 2 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 proto/osmosis/gamm/v1beta1/pool.proto diff --git a/proto/osmosis/gamm/v1beta1/pool.proto b/proto/osmosis/gamm/v1beta1/pool.proto new file mode 100644 index 00000000000..8b48e5f60de --- /dev/null +++ b/proto/osmosis/gamm/v1beta1/pool.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; +package osmosis.gamm.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/c-osmosis/osmosis/x/gamm/types"; + +message Record { + string denormalizedWeight = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"denormalized_weight\"", + (gogoproto.nullable) = false + ]; + string balance = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"balance\"", + (gogoproto.nullable) = false + ]; +} + +message LP { + string name = 1 [ + (gogoproto.moretags) = "yaml:\"name\"" + ]; + string totalSupply = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"total_supply\"", + (gogoproto.nullable) = false + ]; +} + +message Pool { + uint64 id = 1 [ + (gogoproto.moretags) = "yaml:\"id\"" + ]; + string swapFee = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"swap_fee\"", + (gogoproto.nullable) = false + ]; + string totalWeight = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"total_weight\"", + (gogoproto.nullable) = false + ]; + LP token = 4 [ + (gogoproto.moretags) = "yaml:\"token\"", + (gogoproto.nullable) = false + ]; + map records = 5 [ + (gogoproto.moretags) = "yaml:\"records\"", + (gogoproto.nullable) = false + ]; +} diff --git a/proto/osmosis/gamm/v1beta1/tx.proto b/proto/osmosis/gamm/v1beta1/tx.proto index df7ea9a74af..6a213995342 100644 --- a/proto/osmosis/gamm/v1beta1/tx.proto +++ b/proto/osmosis/gamm/v1beta1/tx.proto @@ -9,10 +9,8 @@ option go_package = "github.com/c-osmosis/osmosis/x/gamm/types"; // ===================== MsgJoinPool message MaxAmountIn { - cosmos.base.v1beta1.Coin token = 1 [ - (gogoproto.moretags) = "yaml:\"token\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.nullable) = false + string denom = 1 [ + (gogoproto.moretags) = "yaml:\"denom\"" ]; string maxAmount = 2 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -26,8 +24,7 @@ message MsgJoinPool { (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", (gogoproto.moretags) = "yaml:\"sender\"" ]; - bytes targetPool = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + uint64 targetPool = 2 [ (gogoproto.moretags) = "yaml:\"target_pool\"" ]; string poolAmountOut = 3 [ @@ -44,10 +41,8 @@ message MsgJoinPool { // ===================== MsgExitPool message MinAmountOut { - cosmos.base.v1beta1.Coin token = 1 [ - (gogoproto.moretags) = "yaml:\"token\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.nullable) = false + string denom = 1 [ + (gogoproto.moretags) = "yaml:\"denom\"" ]; string minAmount = 2 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", @@ -61,8 +56,7 @@ message MsgExitPool { (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", (gogoproto.moretags) = "yaml:\"sender\"" ]; - bytes targetPool = 2 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + uint64 targetPool = 2 [ (gogoproto.moretags) = "yaml:\"target_pool\"" ]; string poolAmountIn = 3 [ @@ -79,10 +73,8 @@ message MsgExitPool { // ===================== MsgCreatePool message TokenInfo { - cosmos.base.v1beta1.Coin token = 1 [ - (gogoproto.moretags) = "yaml:\"token\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Coin", - (gogoproto.nullable) = false + string denom = 1 [ + (gogoproto.moretags) = "yaml:\"denom\"" ]; string ratio = 2 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", From 2c7acfa039dc00177938146bb82736b594b15c2d Mon Sep 17 00:00:00 2001 From: orngefrost Date: Sun, 18 Oct 2020 22:30:31 +0900 Subject: [PATCH 2/3] feat(x/gamm): generate protobuf messages --- x/gamm/types/pool.pb.go | 1082 +++++++++++++++++++++++++++++++++++++++ x/gamm/types/tx.pb.go | 306 +++++------ 2 files changed, 1224 insertions(+), 164 deletions(-) create mode 100644 x/gamm/types/pool.pb.go diff --git a/x/gamm/types/pool.pb.go b/x/gamm/types/pool.pb.go new file mode 100644 index 00000000000..8a2b2d5aa99 --- /dev/null +++ b/x/gamm/types/pool.pb.go @@ -0,0 +1,1082 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/gamm/v1beta1/pool.proto + +package types + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + _ "github.com/cosmos/cosmos-sdk/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +type Record struct { + DenormalizedWeight github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=denormalizedWeight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"denormalizedWeight" yaml:"denormalized_weight"` + Balance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=balance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"balance" yaml:"balance"` +} + +func (m *Record) Reset() { *m = Record{} } +func (m *Record) String() string { return proto.CompactTextString(m) } +func (*Record) ProtoMessage() {} +func (*Record) Descriptor() ([]byte, []int) { + return fileDescriptor_e5ab9bc6d45f98ce, []int{0} +} +func (m *Record) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Record) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Record.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 *Record) XXX_Merge(src proto.Message) { + xxx_messageInfo_Record.Merge(m, src) +} +func (m *Record) XXX_Size() int { + return m.Size() +} +func (m *Record) XXX_DiscardUnknown() { + xxx_messageInfo_Record.DiscardUnknown(m) +} + +var xxx_messageInfo_Record proto.InternalMessageInfo + +type LP struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + TotalSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=totalSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"totalSupply" yaml:"total_supply"` +} + +func (m *LP) Reset() { *m = LP{} } +func (m *LP) String() string { return proto.CompactTextString(m) } +func (*LP) ProtoMessage() {} +func (*LP) Descriptor() ([]byte, []int) { + return fileDescriptor_e5ab9bc6d45f98ce, []int{1} +} +func (m *LP) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LP) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LP.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 *LP) XXX_Merge(src proto.Message) { + xxx_messageInfo_LP.Merge(m, src) +} +func (m *LP) XXX_Size() int { + return m.Size() +} +func (m *LP) XXX_DiscardUnknown() { + xxx_messageInfo_LP.DiscardUnknown(m) +} + +var xxx_messageInfo_LP proto.InternalMessageInfo + +func (m *LP) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +type Pool struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swapFee" yaml:"swap_fee"` + TotalWeight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=totalWeight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"totalWeight" yaml:"total_weight"` + Token LP `protobuf:"bytes,4,opt,name=token,proto3" json:"token" yaml:"token"` + Records map[string]Record `protobuf:"bytes,5,rep,name=records,proto3" json:"records" yaml:"records" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *Pool) Reset() { *m = Pool{} } +func (m *Pool) String() string { return proto.CompactTextString(m) } +func (*Pool) ProtoMessage() {} +func (*Pool) Descriptor() ([]byte, []int) { + return fileDescriptor_e5ab9bc6d45f98ce, []int{2} +} +func (m *Pool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Pool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Pool.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 *Pool) XXX_Merge(src proto.Message) { + xxx_messageInfo_Pool.Merge(m, src) +} +func (m *Pool) XXX_Size() int { + return m.Size() +} +func (m *Pool) XXX_DiscardUnknown() { + xxx_messageInfo_Pool.DiscardUnknown(m) +} + +var xxx_messageInfo_Pool proto.InternalMessageInfo + +func (m *Pool) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *Pool) GetToken() LP { + if m != nil { + return m.Token + } + return LP{} +} + +func (m *Pool) GetRecords() map[string]Record { + if m != nil { + return m.Records + } + return nil +} + +func init() { + proto.RegisterType((*Record)(nil), "osmosis.gamm.v1beta1.Record") + proto.RegisterType((*LP)(nil), "osmosis.gamm.v1beta1.LP") + proto.RegisterType((*Pool)(nil), "osmosis.gamm.v1beta1.Pool") + proto.RegisterMapType((map[string]Record)(nil), "osmosis.gamm.v1beta1.Pool.RecordsEntry") +} + +func init() { proto.RegisterFile("osmosis/gamm/v1beta1/pool.proto", fileDescriptor_e5ab9bc6d45f98ce) } + +var fileDescriptor_e5ab9bc6d45f98ce = []byte{ + // 524 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcf, 0x6e, 0xd3, 0x30, + 0x1c, 0xc7, 0x9b, 0xfe, 0x59, 0x35, 0x77, 0x30, 0x64, 0x2a, 0x54, 0x55, 0x90, 0x54, 0x46, 0x82, + 0x72, 0x58, 0xa2, 0x95, 0x0b, 0xda, 0x09, 0xca, 0x86, 0x84, 0xd4, 0x43, 0x65, 0x0e, 0xc0, 0x38, + 0x54, 0x6e, 0x62, 0xb2, 0xa8, 0x49, 0x1c, 0xd5, 0xee, 0x46, 0x10, 0x0f, 0x81, 0x78, 0xaa, 0x1d, + 0x77, 0x44, 0x1c, 0x22, 0xd4, 0x4a, 0x3c, 0x40, 0x9e, 0x00, 0xc5, 0x76, 0xa6, 0x1c, 0x7a, 0xa9, + 0xb4, 0x93, 0xad, 0xf8, 0xfb, 0xfb, 0x7c, 0xfd, 0xfb, 0xe3, 0x00, 0x8b, 0xf1, 0x88, 0xf1, 0x80, + 0x3b, 0x3e, 0x89, 0x22, 0xe7, 0xf2, 0x78, 0x4e, 0x05, 0x39, 0x76, 0x12, 0xc6, 0x42, 0x3b, 0x59, + 0x32, 0xc1, 0x60, 0x57, 0x0b, 0xec, 0x42, 0x60, 0x6b, 0x41, 0xbf, 0xeb, 0x33, 0x9f, 0x49, 0x81, + 0x53, 0xec, 0x94, 0xb6, 0x6f, 0xba, 0x52, 0xec, 0xcc, 0x09, 0xa7, 0xb7, 0x2c, 0x97, 0x05, 0xb1, + 0x3a, 0x47, 0x6b, 0x03, 0xec, 0x61, 0xea, 0xb2, 0xa5, 0x07, 0x7f, 0x00, 0xe8, 0xd1, 0x98, 0x2d, + 0x23, 0x12, 0x06, 0xdf, 0xa9, 0xf7, 0x91, 0x06, 0xfe, 0x85, 0xe8, 0x19, 0x03, 0x63, 0xb8, 0x3f, + 0x9e, 0x5c, 0x67, 0x56, 0xed, 0x4f, 0x66, 0x3d, 0xf3, 0x03, 0x71, 0xb1, 0x9a, 0xdb, 0x2e, 0x8b, + 0x1c, 0x4d, 0x56, 0xcb, 0x11, 0xf7, 0x16, 0x8e, 0x48, 0x13, 0xca, 0xed, 0x53, 0xea, 0xe6, 0x99, + 0xd5, 0x4f, 0x49, 0x14, 0x9e, 0xa0, 0x2a, 0x71, 0x76, 0x25, 0x91, 0x08, 0x6f, 0xf1, 0x81, 0xe7, + 0xa0, 0x3d, 0x27, 0x21, 0x89, 0x5d, 0xda, 0xab, 0x4b, 0xcb, 0xd7, 0x3b, 0x58, 0xbe, 0x8f, 0x45, + 0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2, 0x58, 0x3d, 0x23, 0x9a, 0x82, 0x70, 0xc9, 0xeb, + 0x7f, 0x02, 0x07, 0xd5, 0x00, 0xf8, 0x00, 0x34, 0x16, 0x34, 0x55, 0xb3, 0x82, 0x8b, 0x2d, 0x1c, + 0x81, 0xd6, 0x25, 0x09, 0x57, 0xaa, 0x0d, 0x9d, 0xd1, 0xe3, 0xed, 0xd6, 0x0a, 0x82, 0x95, 0xf4, + 0xa4, 0xfe, 0xca, 0x18, 0xbf, 0xbd, 0x5e, 0x9b, 0xc6, 0xcd, 0xda, 0x34, 0xfe, 0xae, 0x4d, 0xe3, + 0xe7, 0xc6, 0xac, 0xdd, 0x6c, 0xcc, 0xda, 0xef, 0x8d, 0x59, 0x3b, 0x7f, 0x51, 0x2d, 0xf0, 0x51, + 0xf9, 0xec, 0xcb, 0xf5, 0x9b, 0xfa, 0x01, 0xc8, 0x3a, 0xcf, 0xf7, 0xe4, 0x73, 0x7d, 0xf9, 0x3f, + 0x00, 0x00, 0xff, 0xff, 0xe9, 0x4f, 0x0f, 0x88, 0x1d, 0x04, 0x00, 0x00, +} + +func (m *Record) 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 *Record) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Record) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Balance.Size() + i -= size + if _, err := m.Balance.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.DenormalizedWeight.Size() + i -= size + if _, err := m.DenormalizedWeight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *LP) 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 *LP) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LP) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TotalSupply.Size() + i -= size + if _, err := m.TotalSupply.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintPool(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Pool) 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 *Pool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Records) > 0 { + for k := range m.Records { + v := m.Records[k] + baseI := i + { + size, err := (&v).MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintPool(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintPool(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x2a + } + } + { + size, err := m.Token.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.TotalWeight.Size() + i -= size + if _, err := m.TotalWeight.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.SwapFee.Size() + i -= size + if _, err := m.SwapFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.Id != 0 { + i = encodeVarintPool(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintPool(dAtA []byte, offset int, v uint64) int { + offset -= sovPool(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Record) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.DenormalizedWeight.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.Balance.Size() + n += 1 + l + sovPool(uint64(l)) + return n +} + +func (m *LP) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovPool(uint64(l)) + } + l = m.TotalSupply.Size() + n += 1 + l + sovPool(uint64(l)) + return n +} + +func (m *Pool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovPool(uint64(m.Id)) + } + l = m.SwapFee.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.TotalWeight.Size() + n += 1 + l + sovPool(uint64(l)) + l = m.Token.Size() + n += 1 + l + sovPool(uint64(l)) + if len(m.Records) > 0 { + for k, v := range m.Records { + _ = k + _ = v + l = v.Size() + mapEntrySize := 1 + len(k) + sovPool(uint64(len(k))) + 1 + l + sovPool(uint64(l)) + n += mapEntrySize + 1 + sovPool(uint64(mapEntrySize)) + } + } + return n +} + +func sovPool(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPool(x uint64) (n int) { + return sovPool(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Record) 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 ErrIntOverflowPool + } + 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: Record: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Record: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenormalizedWeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DenormalizedWeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LP) 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 ErrIntOverflowPool + } + 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: LP: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LP: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalSupply", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Pool) 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 ErrIntOverflowPool + } + 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: Pool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Pool: 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 ErrIntOverflowPool + } + 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 SwapFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SwapFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalWeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalWeight.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Records == nil { + m.Records = make(map[string]Record) + } + var mapkey string + mapvalue := &Record{} + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + 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 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthPool + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthPool + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthPool + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthPool + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &Record{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Records[mapkey] = *mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPool(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthPool + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPool(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, ErrIntOverflowPool + } + 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, ErrIntOverflowPool + } + 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, ErrIntOverflowPool + } + 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, ErrInvalidLengthPool + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPool + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPool + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPool = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPool = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPool = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/gamm/types/tx.pb.go b/x/gamm/types/tx.pb.go index 716756fb43f..564b4a58771 100644 --- a/x/gamm/types/tx.pb.go +++ b/x/gamm/types/tx.pb.go @@ -28,8 +28,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // ===================== MsgJoinPool type MaxAmountIn struct { - Token github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,1,opt,name=token,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"token" yaml:"token"` - MaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=maxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"maxAmount" yaml:"max_amount"` + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + MaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=maxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"maxAmount" yaml:"max_amount"` } func (m *MaxAmountIn) Reset() { *m = MaxAmountIn{} } @@ -65,9 +65,16 @@ func (m *MaxAmountIn) XXX_DiscardUnknown() { var xxx_messageInfo_MaxAmountIn proto.InternalMessageInfo +func (m *MaxAmountIn) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + type MsgJoinPool struct { Sender github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=sender,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"sender,omitempty" yaml:"sender"` - TargetPool github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=targetPool,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"targetPool,omitempty" yaml:"target_pool"` + TargetPool uint64 `protobuf:"varint,2,opt,name=targetPool,proto3" json:"targetPool,omitempty" yaml:"target_pool"` PoolAmountOut github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=poolAmountOut,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"poolAmountOut" yaml:"pool_amount_out"` MaxAmountsIn []MaxAmountIn `protobuf:"bytes,4,rep,name=maxAmountsIn,proto3" json:"maxAmountsIn" yaml:"max_amounts_in"` } @@ -112,11 +119,11 @@ func (m *MsgJoinPool) GetSender() github_com_cosmos_cosmos_sdk_types.AccAddress return nil } -func (m *MsgJoinPool) GetTargetPool() github_com_cosmos_cosmos_sdk_types.AccAddress { +func (m *MsgJoinPool) GetTargetPool() uint64 { if m != nil { return m.TargetPool } - return nil + return 0 } func (m *MsgJoinPool) GetMaxAmountsIn() []MaxAmountIn { @@ -128,8 +135,8 @@ func (m *MsgJoinPool) GetMaxAmountsIn() []MaxAmountIn { // ===================== MsgExitPool type MinAmountOut struct { - Token github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,1,opt,name=token,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"token" yaml:"token"` - MinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=minAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"minAmount" yaml:"min_amount"` + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + MinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=minAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"minAmount" yaml:"min_amount"` } func (m *MinAmountOut) Reset() { *m = MinAmountOut{} } @@ -165,9 +172,16 @@ func (m *MinAmountOut) XXX_DiscardUnknown() { var xxx_messageInfo_MinAmountOut proto.InternalMessageInfo +func (m *MinAmountOut) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + type MsgExitPool struct { Sender github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=sender,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"sender,omitempty" yaml:"sender"` - TargetPool github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=targetPool,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"targetPool,omitempty" yaml:"target_pool"` + TargetPool uint64 `protobuf:"varint,2,opt,name=targetPool,proto3" json:"targetPool,omitempty" yaml:"target_pool"` PoolAmountIn github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=poolAmountIn,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"poolAmountIn" yaml:"pool_amount_in"` MinAmountsOut []MinAmountOut `protobuf:"bytes,4,rep,name=minAmountsOut,proto3" json:"minAmountsOut" yaml:"min_amounts_out"` } @@ -212,11 +226,11 @@ func (m *MsgExitPool) GetSender() github_com_cosmos_cosmos_sdk_types.AccAddress return nil } -func (m *MsgExitPool) GetTargetPool() github_com_cosmos_cosmos_sdk_types.AccAddress { +func (m *MsgExitPool) GetTargetPool() uint64 { if m != nil { return m.TargetPool } - return nil + return 0 } func (m *MsgExitPool) GetMinAmountsOut() []MinAmountOut { @@ -228,9 +242,9 @@ func (m *MsgExitPool) GetMinAmountsOut() []MinAmountOut { // ===================== MsgCreatePool type TokenInfo struct { - Token github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,1,opt,name=token,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Coin" json:"token" yaml:"token"` - Ratio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=ratio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"ratio" yaml:"ratio"` - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount" yaml:"ratio"` + Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + Ratio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=ratio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"ratio" yaml:"ratio"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount" yaml:"ratio"` } func (m *TokenInfo) Reset() { *m = TokenInfo{} } @@ -266,6 +280,13 @@ func (m *TokenInfo) XXX_DiscardUnknown() { var xxx_messageInfo_TokenInfo proto.InternalMessageInfo +func (m *TokenInfo) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + type MsgCreatePool struct { Sender github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=sender,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"sender,omitempty" yaml:"sender"` SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swapFee" yaml:"swap_fee"` @@ -331,48 +352,47 @@ func init() { func init() { proto.RegisterFile("osmosis/gamm/v1beta1/tx.proto", fileDescriptor_cfc8fd3ac7df3247) } var fileDescriptor_cfc8fd3ac7df3247 = []byte{ - // 655 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x96, 0xcf, 0x6a, 0x13, 0x4f, - 0x1c, 0xc0, 0xb3, 0xcd, 0xaf, 0xfd, 0x91, 0x49, 0x82, 0x74, 0x69, 0x4b, 0x5a, 0xe8, 0x6e, 0x9d, - 0x83, 0xd6, 0x43, 0x77, 0x69, 0xbd, 0x79, 0xa8, 0x64, 0xa3, 0xd6, 0x08, 0x41, 0x59, 0x8a, 0x48, - 0x3d, 0x84, 0xc9, 0x66, 0xba, 0x5d, 0x9a, 0x9d, 0x59, 0x76, 0x26, 0x36, 0x7d, 0x0b, 0x9f, 0xc1, - 0x93, 0xe2, 0x8b, 0xf4, 0xd8, 0xa3, 0x78, 0x58, 0x24, 0x79, 0x83, 0x1c, 0x3d, 0xc9, 0xce, 0xcc, - 0x26, 0x9b, 0x5a, 0xa1, 0x51, 0xa4, 0xe0, 0x69, 0x43, 0xbe, 0x33, 0x9f, 0xef, 0xbf, 0x0f, 0xec, - 0x82, 0x4d, 0xca, 0x42, 0xca, 0x02, 0x66, 0xfb, 0x28, 0x0c, 0xed, 0x77, 0xbb, 0x1d, 0xcc, 0xd1, - 0xae, 0xcd, 0x07, 0x56, 0x14, 0x53, 0x4e, 0xf5, 0x15, 0x15, 0xb6, 0xd2, 0xb0, 0xa5, 0xc2, 0x1b, - 0x2b, 0x3e, 0xf5, 0xa9, 0x38, 0x60, 0xa7, 0xbf, 0xe4, 0xd9, 0x0d, 0xc3, 0x13, 0x87, 0xed, 0x0e, - 0x62, 0x78, 0x42, 0xf2, 0x68, 0x40, 0x64, 0x1c, 0x0e, 0x35, 0x50, 0x6e, 0xa1, 0x41, 0x3d, 0xa4, - 0x7d, 0xc2, 0x9b, 0x44, 0x8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x45, 0x83, 0x1f, 0x16, 0x40, 0xb5, 0xc5, 0xfc, 0x46, 0x8c, 0x11, 0xc7, 0x7f, 0xdd, 0xed, - 0xb7, 0xe0, 0x7f, 0x76, 0x86, 0xa2, 0x67, 0x18, 0xab, 0xe9, 0xd4, 0xe7, 0x9e, 0xce, 0x1d, 0x55, - 0xca, 0x19, 0x8a, 0xda, 0xc7, 0x18, 0x43, 0x37, 0x23, 0xea, 0x6f, 0x40, 0x89, 0x67, 0x7b, 0xaf, - 0x15, 0x85, 0x5e, 0xe6, 0xf5, 0x7a, 0x4d, 0xf4, 0x70, 0xd6, 0x95, 0x5b, 0xcb, 0xb9, 0x4d, 0xb6, - 0x03, 0x72, 0x4c, 0xa1, 0x3b, 0x85, 0x39, 0x8d, 0x8b, 0xa1, 0xa1, 0x5d, 0x0e, 0x0d, 0xed, 0xdb, - 0xd0, 0xd0, 0xde, 0x8f, 0x8c, 0xc2, 0xe5, 0xc8, 0x28, 0x7c, 0x19, 0x19, 0x85, 0xa3, 0x07, 0xf9, - 0xba, 0x77, 0xb2, 0xcf, 0x80, 0xec, 0x39, 0x90, 0x1f, 0x04, 0xa2, 0xfc, 0xce, 0x92, 0x78, 0x81, - 0x3f, 0xfc, 0x11, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x56, 0xff, 0x82, 0x2d, 0x08, 0x00, 0x00, + // 633 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x95, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0xc7, 0x9b, 0xbd, 0xa1, 0x7a, 0xad, 0x80, 0x68, 0x9b, 0xca, 0xa4, 0x25, 0xc3, 0x87, 0x69, + 0x1c, 0x96, 0x68, 0x20, 0x71, 0xe0, 0x30, 0xa9, 0x19, 0x6f, 0x45, 0xaa, 0x40, 0xd1, 0x84, 0xd0, + 0x38, 0x44, 0x6e, 0xe2, 0x65, 0xd1, 0x1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, 0xbe, 0x77, 0xf2, 0x67, 0x2c, 0xff, + 0x0e, 0xe4, 0x83, 0x26, 0xda, 0xef, 0x2c, 0x89, 0x07, 0xe8, 0xc1, 0xaf, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x52, 0xa9, 0x56, 0x26, 0xed, 0x06, 0x00, 0x00, } func (m *MaxAmountIn) Marshal() (dAtA []byte, err error) { @@ -405,16 +425,13 @@ func (m *MaxAmountIn) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - { - size := m.Token.Size() - i -= size - if _, err := m.Token.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) + 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] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -462,12 +479,10 @@ func (m *MsgJoinPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x1a - if len(m.TargetPool) > 0 { - i -= len(m.TargetPool) - copy(dAtA[i:], m.TargetPool) - i = encodeVarintTx(dAtA, i, uint64(len(m.TargetPool))) + if m.TargetPool != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TargetPool)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.Sender) > 0 { i -= len(m.Sender) @@ -509,16 +524,13 @@ func (m *MinAmountOut) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - { - size := m.Token.Size() - i -= size - if _, err := m.Token.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) + 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] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -566,12 +578,10 @@ func (m *MsgExitPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x1a - if len(m.TargetPool) > 0 { - i -= len(m.TargetPool) - copy(dAtA[i:], m.TargetPool) - i = encodeVarintTx(dAtA, i, uint64(len(m.TargetPool))) + if m.TargetPool != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.TargetPool)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x10 } if len(m.Sender) > 0 { i -= len(m.Sender) @@ -623,16 +633,13 @@ func (m *TokenInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - { - size := m.Token.Size() - i -= size - if _, err := m.Token.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) + 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] = 0xa } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -707,8 +714,10 @@ func (m *MaxAmountIn) Size() (n int) { } var l int _ = l - l = m.Token.Size() - n += 1 + l + sovTx(uint64(l)) + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = m.MaxAmount.Size() n += 1 + l + sovTx(uint64(l)) return n @@ -724,9 +733,8 @@ func (m *MsgJoinPool) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.TargetPool) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.TargetPool != 0 { + n += 1 + sovTx(uint64(m.TargetPool)) } l = m.PoolAmountOut.Size() n += 1 + l + sovTx(uint64(l)) @@ -745,8 +753,10 @@ func (m *MinAmountOut) Size() (n int) { } var l int _ = l - l = m.Token.Size() - n += 1 + l + sovTx(uint64(l)) + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = m.MinAmount.Size() n += 1 + l + sovTx(uint64(l)) return n @@ -762,9 +772,8 @@ func (m *MsgExitPool) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.TargetPool) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.TargetPool != 0 { + n += 1 + sovTx(uint64(m.TargetPool)) } l = m.PoolAmountIn.Size() n += 1 + l + sovTx(uint64(l)) @@ -783,8 +792,10 @@ func (m *TokenInfo) Size() (n int) { } var l int _ = l - l = m.Token.Size() - n += 1 + l + sovTx(uint64(l)) + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } l = m.Ratio.Size() n += 1 + l + sovTx(uint64(l)) l = m.Amount.Size() @@ -850,9 +861,9 @@ func (m *MaxAmountIn) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -862,24 +873,23 @@ func (m *MaxAmountIn) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1003,10 +1013,10 @@ func (m *MsgJoinPool) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TargetPool", wireType) } - var byteLen int + m.TargetPool = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1016,26 +1026,11 @@ func (m *MsgJoinPool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.TargetPool |= uint64(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 - } - m.TargetPool = append(m.TargetPool[:0], dAtA[iNdEx:postIndex]...) - if m.TargetPool == nil { - m.TargetPool = []byte{} - } - iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PoolAmountOut", wireType) @@ -1159,9 +1154,9 @@ func (m *MinAmountOut) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1171,24 +1166,23 @@ func (m *MinAmountOut) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -1312,10 +1306,10 @@ func (m *MsgExitPool) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TargetPool", wireType) } - var byteLen int + m.TargetPool = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1325,26 +1319,11 @@ func (m *MsgExitPool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.TargetPool |= uint64(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 - } - m.TargetPool = append(m.TargetPool[:0], dAtA[iNdEx:postIndex]...) - if m.TargetPool == nil { - m.TargetPool = []byte{} - } - iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PoolAmountIn", wireType) @@ -1468,9 +1447,9 @@ func (m *TokenInfo) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1480,24 +1459,23 @@ func (m *TokenInfo) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { From 575fadd41ce5c348dac9ff787d39ca93c8cd9dbf Mon Sep 17 00:00:00 2001 From: orngefrost Date: Sun, 18 Oct 2020 22:32:05 +0900 Subject: [PATCH 3/3] feat(x/gamm): add some methods * methods * CreatePool * JoinPool * ExitPool * errors * ErrPoolNotFound * ErrMathApprox * ErrLimitExceed * keys * PoolPrefix * GlobalPoolNumber * utils * Uint64ToBytes --- x/gamm/keeper/keeper.go | 24 ++++++--- x/gamm/keeper/pool/lp.go | 32 +++++++++++ x/gamm/keeper/pool/pool.go | 14 ----- x/gamm/keeper/pool/service.go | 99 ++++++++++++++++++++++++++++++----- x/gamm/keeper/pool/store.go | 82 +++++++++++++++++++++++++++++ x/gamm/types/errors.go | 10 ++++ x/gamm/types/key.go | 5 ++ x/gamm/utils/conv.go | 9 ++++ 8 files changed, 242 insertions(+), 33 deletions(-) create mode 100644 x/gamm/keeper/pool/lp.go delete mode 100644 x/gamm/keeper/pool/pool.go create mode 100644 x/gamm/keeper/pool/store.go create mode 100644 x/gamm/types/errors.go create mode 100644 x/gamm/utils/conv.go diff --git a/x/gamm/keeper/keeper.go b/x/gamm/keeper/keeper.go index cf516172620..eb5226d3257 100644 --- a/x/gamm/keeper/keeper.go +++ b/x/gamm/keeper/keeper.go @@ -10,25 +10,35 @@ import ( var _ Keeper = (*keeper)(nil) +// type alias +type poolService = pool.Service + type Keeper interface { - pool.Service + poolService } type keeper struct { - pool.Service + poolService + + // stores + poolStore pool.Store - cdc codec.BinaryMarshaler - storeKey sdk.StoreKey + // keepers accountKeeper types.AccountKeeper bankKeeper bankkeeper.Keeper } func NewKeeper(cdc codec.BinaryMarshaler, storeKey sdk.StoreKey, accountKeeper types.AccountKeeper, bankKeeper bankkeeper.Keeper) Keeper { + var ( + poolStore = pool.NewStore(cdc, storeKey) + poolService = pool.NewService(poolStore, accountKeeper, bankKeeper) + ) return keeper{ - Service: pool.NewService(cdc, storeKey, accountKeeper, bankKeeper), + // pool + poolService: poolService, + poolStore: poolStore, - cdc: cdc, - storeKey: storeKey, + // keepers accountKeeper: accountKeeper, bankKeeper: bankKeeper, } diff --git a/x/gamm/keeper/pool/lp.go b/x/gamm/keeper/pool/lp.go new file mode 100644 index 00000000000..82202b8bc18 --- /dev/null +++ b/x/gamm/keeper/pool/lp.go @@ -0,0 +1,32 @@ +package pool + +import ( + "github.com/c-osmosis/osmosis/x/gamm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" +) + +type lp struct { + denom string + bankKeeper bankkeeper.Keeper +} + +func (p lp) pushPoolShare(ctx sdk.Context, to sdk.AccAddress, amount sdk.Int) error { + lp := sdk.Coin{Denom: p.denom, Amount: amount} + return p.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, to, sdk.Coins{lp}) +} + +func (p lp) pullPoolShare(ctx sdk.Context, from sdk.AccAddress, amount sdk.Int) error { + lp := sdk.Coin{Denom: p.denom, Amount: amount} + return p.bankKeeper.SendCoinsFromAccountToModule(ctx, from, types.ModuleName, sdk.Coins{lp}) +} + +func (p lp) mintPoolShare(ctx sdk.Context, amount sdk.Int) error { + lp := sdk.Coin{Denom: p.denom, Amount: amount} + return p.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.Coins{lp}) +} + +func (p lp) burnPoolShare(ctx sdk.Context, amount sdk.Int) error { + lp := sdk.Coin{Denom: p.denom, Amount: amount} + return p.bankKeeper.BurnCoins(ctx, types.ModuleName, sdk.Coins{lp}) +} diff --git a/x/gamm/keeper/pool/pool.go b/x/gamm/keeper/pool/pool.go deleted file mode 100644 index b334bb010a8..00000000000 --- a/x/gamm/keeper/pool/pool.go +++ /dev/null @@ -1,14 +0,0 @@ -package pool - -import sdk "github.com/cosmos/cosmos-sdk/types" - -type Record struct { - DenormalizedWeight sdk.Dec - Balance sdk.Int -} - -type Pool struct { - Address sdk.AccAddress - Records map[string]Record - TotalWeight sdk.Int -} diff --git a/x/gamm/keeper/pool/service.go b/x/gamm/keeper/pool/service.go index fb578d14b8a..10a8675be47 100644 --- a/x/gamm/keeper/pool/service.go +++ b/x/gamm/keeper/pool/service.go @@ -2,33 +2,30 @@ package pool import ( "github.com/c-osmosis/osmosis/x/gamm/types" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" ) type Service interface { CreatePool(sdk.Context, sdk.AccAddress, sdk.Dec, []types.TokenInfo) error - JoinPool(sdk.Context, sdk.AccAddress, sdk.AccAddress, sdk.Int, []types.MaxAmountIn) error - ExitPool(sdk.Context, sdk.AccAddress, sdk.AccAddress, sdk.Int, []types.MinAmountOut) error + JoinPool(sdk.Context, sdk.AccAddress, uint64, sdk.Int, []types.MaxAmountIn) error + ExitPool(sdk.Context, sdk.AccAddress, uint64, sdk.Int, []types.MinAmountOut) error } type poolService struct { - cdc codec.BinaryMarshaler - storeKey sdk.StoreKey + store Store accountKeeper types.AccountKeeper bankKeeper bankkeeper.Keeper } func NewService( - cdc codec.BinaryMarshaler, - storeKey sdk.StoreKey, + store Store, accountKeeper types.AccountKeeper, bankKeeper bankkeeper.Keeper, ) Service { return poolService{ - cdc: cdc, - storeKey: storeKey, + store: store, accountKeeper: accountKeeper, bankKeeper: bankKeeper, } @@ -40,23 +37,101 @@ func (p poolService) CreatePool( swapFee sdk.Dec, tokenInfo []types.TokenInfo, ) error { - return nil + records := make(map[string]types.Record, len(tokenInfo)) + for _, info := range tokenInfo { + records[info.Denom] = types.Record{ + DenormalizedWeight: info.Ratio, + Balance: info.Amount, + } + } + + pool := types.Pool{ + Id: p.store.GetNextPoolNumber(ctx), + SwapFee: swapFee, + TotalWeight: sdk.NewInt(0), + Records: records, + } + + p.store.StorePool(ctx, pool) + + var coins sdk.Coins + for denom, record := range records { + coins = append(coins, sdk.Coin{ + Denom: denom, + Amount: record.Balance, + }) + } + + return p.bankKeeper.SendCoinsFromAccountToModule( + ctx, + sender, + types.ModuleName, + coins, + ) } func (p poolService) JoinPool( ctx sdk.Context, sender sdk.AccAddress, - targetPool sdk.AccAddress, + targetPoolId uint64, poolAmountOut sdk.Int, maxAmountsIn []types.MaxAmountIn, ) error { + pool, err := p.store.FetchPool(ctx, targetPoolId) + if err != nil { + return err + } + + poolTotal := pool.Token.TotalSupply.ToDec() + poolRatio := poolAmountOut.ToDec().Quo(poolTotal) + if poolRatio.Equal(sdk.NewDec(0)) { + return sdkerrors.Wrapf(types.ErrMathApprox, "calc poolRatio") + } + + var sendTargets sdk.Coins + for _, maxAmountIn := range maxAmountsIn { + record := pool.Records[maxAmountIn.Denom] + tokenAmountIn := poolRatio.Mul(record.Balance.ToDec()).TruncateInt() + if tokenAmountIn.Equal(sdk.NewInt(0)) { + return sdkerrors.Wrapf(types.ErrMathApprox, "calc tokenAmountIn") + } + if tokenAmountIn.GT(maxAmountIn.MaxAmount) { + return sdkerrors.Wrapf(types.ErrLimitExceed, "limit exceeded") + } + record.Balance = record.Balance.Add(tokenAmountIn) + sendTargets = append(sendTargets, sdk.Coin{ + Denom: maxAmountIn.Denom, + Amount: tokenAmountIn, + }) + } + + err = p.bankKeeper.SendCoinsFromAccountToModule( + ctx, + sender, + types.ModuleName, + sendTargets, + ) + if err != nil { + return err + } + + poolShare := lp{ + denom: pool.Token.Name, + bankKeeper: p.bankKeeper, + } + if err := poolShare.mintPoolShare(ctx, poolAmountOut); err != nil { + return err + } + if err := poolShare.pushPoolShare(ctx, sender, poolAmountOut); err != nil { + return err + } return nil } func (p poolService) ExitPool( ctx sdk.Context, sender sdk.AccAddress, - targetPool sdk.AccAddress, + targetPoolId uint64, poolAmountIn sdk.Int, minAmountsOut []types.MinAmountOut, ) error { diff --git a/x/gamm/keeper/pool/store.go b/x/gamm/keeper/pool/store.go new file mode 100644 index 00000000000..ce6e44a84e1 --- /dev/null +++ b/x/gamm/keeper/pool/store.go @@ -0,0 +1,82 @@ +package pool + +import ( + "github.com/c-osmosis/osmosis/x/gamm/types" + "github.com/c-osmosis/osmosis/x/gamm/utils" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + gogotypes "github.com/gogo/protobuf/types" +) + +type Store interface { + GetNextPoolNumber(sdk.Context) uint64 + + StorePool(sdk.Context, types.Pool) + FetchPool(sdk.Context, uint64) (types.Pool, error) + DeletePool(sdk.Context, uint64) +} + +type poolStore struct { + cdc codec.BinaryMarshaler + storeKey sdk.StoreKey +} + +func NewStore(cdc codec.BinaryMarshaler, storeKey sdk.StoreKey) Store { + return poolStore{ + cdc: cdc, + storeKey: storeKey, + } +} + +func (ps poolStore) getStore(ctx sdk.Context) prefix.Store { + return prefix.NewStore(ctx.KVStore(ps.storeKey), types.PoolPrefix) +} + +func (ps poolStore) GetNextPoolNumber(ctx sdk.Context) uint64 { + var poolNumber uint64 + store := ctx.KVStore(ps.storeKey) + + bz := store.Get(types.GlobalPoolNumber) + if bz == nil { + // initialize the account numbers + poolNumber = 0 + } else { + val := gogotypes.UInt64Value{} + + err := ps.cdc.UnmarshalBinaryBare(bz, &val) + if err != nil { + panic(err) + } + + poolNumber = val.GetValue() + } + + bz = ps.cdc.MustMarshalBinaryBare(&gogotypes.UInt64Value{Value: poolNumber + 1}) + store.Set(types.GlobalPoolNumber, bz) + + return poolNumber +} + +func (ps poolStore) StorePool(ctx sdk.Context, pool types.Pool) { + store := ps.getStore(ctx) + bz := ps.cdc.MustMarshalBinaryBare(&pool) + store.Set(utils.Uint64ToBytes(pool.Id), bz) +} + +func (ps poolStore) FetchPool(ctx sdk.Context, poolId uint64) (types.Pool, error) { + store := ps.getStore(ctx) + bz := store.Get(utils.Uint64ToBytes(poolId)) + if bz == nil { + return types.Pool{}, types.ErrPoolNotFound + } + + var pool types.Pool + ps.cdc.MustUnmarshalBinaryBare(bz, &pool) + return pool, nil +} + +func (ps poolStore) DeletePool(ctx sdk.Context, poolId uint64) { + store := ps.getStore(ctx) + store.Delete(utils.Uint64ToBytes(poolId)) +} diff --git a/x/gamm/types/errors.go b/x/gamm/types/errors.go new file mode 100644 index 00000000000..b9cabb2a747 --- /dev/null +++ b/x/gamm/types/errors.go @@ -0,0 +1,10 @@ +package types + +import sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + +// x/gamm module sentinel errors +var ( + ErrPoolNotFound = sdkerrors.Register(ModuleName, 2, "pool not found") + ErrMathApprox = sdkerrors.Register(ModuleName, 3, "math approx error") + ErrLimitExceed = sdkerrors.Register(ModuleName, 4, "limit exceeded") +) diff --git a/x/gamm/types/key.go b/x/gamm/types/key.go index 3ff2f8e8274..e8e72442d3e 100644 --- a/x/gamm/types/key.go +++ b/x/gamm/types/key.go @@ -9,3 +9,8 @@ const ( QuerierRoute = ModuleName ) + +var ( + PoolPrefix = []byte("gmm_liquidity_pool") + GlobalPoolNumber = []byte("gmm_global_pool_number") +) diff --git a/x/gamm/utils/conv.go b/x/gamm/utils/conv.go new file mode 100644 index 00000000000..9355af45bdb --- /dev/null +++ b/x/gamm/utils/conv.go @@ -0,0 +1,9 @@ +package utils + +import "encoding/binary" + +func Uint64ToBytes(i uint64) []byte { + key := make([]byte, 8) + binary.LittleEndian.PutUint64(key, i) + return key +}