Skip to content

Commit

Permalink
feat: pool
Browse files Browse the repository at this point in the history
  • Loading branch information
kimurayu45z committed May 19, 2024
1 parent 670f7a8 commit d949b7d
Show file tree
Hide file tree
Showing 11 changed files with 2,289 additions and 445 deletions.
1,094 changes: 1,017 additions & 77 deletions api/sunrise/liquiditypool/pool.pulsar.go

Large diffs are not rendered by default.

249 changes: 197 additions & 52 deletions api/sunrise/liquiditypool/position.pulsar.go

Large diffs are not rendered by default.

474 changes: 276 additions & 198 deletions api/sunrise/liquiditypool/tx.pulsar.go

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions proto/sunrise/liquiditypool/pool.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
syntax = "proto3";
package sunrise.liquiditypool;

import "amino/amino.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/sunriselayer/sunrise/x/liquiditypool/types";

message Pool {
uint64 id = 1;
string denom_base = 2;
string denom_quote = 3;
string fee_rate = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
TickParams tick_params = 5 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
int64 current_tick = 6;
string current_tick_liquidity = 7 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
string current_sqrt_price = 8 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
}

message TickParams {

}
18 changes: 15 additions & 3 deletions proto/sunrise/liquiditypool/position.proto
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
syntax = "proto3";
package sunrise.liquiditypool;

import "amino/amino.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/sunriselayer/sunrise/x/liquiditypool/types";

message Position {
uint64 id = 1;
string sender = 2;
int64 lower_tick = 3;
int64 upper_tick = 4;
string address = 2;
uint64 pool_id = 3;
int64 lower_tick = 4;
int64 upper_tick = 5;
string liquidity = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
}
6 changes: 6 additions & 0 deletions proto/sunrise/liquiditypool/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ message MsgCreatePool {
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string denom_base = 2;
string denom_quote = 3;
string fee_rate = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
}

message MsgCreatePoolResponse {
Expand Down
10 changes: 8 additions & 2 deletions x/liquiditypool/types/message_collect_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (

var _ sdk.Msg = &MsgCollectFees{}

func NewMsgCollectFees(sender string) *MsgCollectFees {
func NewMsgCollectFees(sender string, positionIds []uint64) *MsgCollectFees {
return &MsgCollectFees{
Sender: sender,
Sender: sender,
PositionIds: positionIds,
}
}

Expand All @@ -19,5 +20,10 @@ func (msg *MsgCollectFees) ValidateBasic() error {
if err != nil {
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err)
}

if len(msg.PositionIds) == 0 {
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "position ids cannot be empty")
}

return nil
}
10 changes: 8 additions & 2 deletions x/liquiditypool/types/message_collect_incentives.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (

var _ sdk.Msg = &MsgCollectIncentives{}

func NewMsgCollectIncentives(sender string) *MsgCollectIncentives {
func NewMsgCollectIncentives(sender string, positionIds []uint64) *MsgCollectIncentives {
return &MsgCollectIncentives{
Sender: sender,
Sender: sender,
PositionIds: positionIds,
}
}

Expand All @@ -19,5 +20,10 @@ func (msg *MsgCollectIncentives) ValidateBasic() error {
if err != nil {
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err)
}

if len(msg.PositionIds) == 0 {
return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "position ids cannot be empty")
}

return nil
}
Loading

0 comments on commit d949b7d

Please sign in to comment.