Skip to content

Commit

Permalink
initial protos for x/ibcratelimit
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyding committed Dec 8, 2023
1 parent fe82149 commit 2bceab4
Show file tree
Hide file tree
Showing 10 changed files with 3,638 additions and 0 deletions.
20 changes: 20 additions & 0 deletions proto/dydxprotocol/ibcratelimit/capacity.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;

import "gogoproto/gogo.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";

// DenomCapacity stores a list of rate limit capacity for a denom.
message DenomCapacity {
// denom is the denomination of the token being rate limited.
// e.g. ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5
string denom = 1;
// capacity_list is a list of capacity amount tracked for each `Limiter`
// on the denom. This list has a 1:1 mapping to `limiter` list under `LimitParams`.
repeated bytes capacity_list = 2 [
(gogoproto.customtype) =
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
(gogoproto.nullable) = false
];
}
13 changes: 13 additions & 0 deletions proto/dydxprotocol/ibcratelimit/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;

import "gogoproto/gogo.proto";
import "dydxprotocol/ibcratelimit/limit_params.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";

// GenesisState defines the ibcratelimit module's genesis state.
message GenesisState {
// limit_params_list defines the list of `LimitParams` at genesis.
repeated LimitParams limit_params_list = 1 [ (gogoproto.nullable) = false ];
}
35 changes: 35 additions & 0 deletions proto/dydxprotocol/ibcratelimit/limit_params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;

import "gogoproto/gogo.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";

// LimitParams defines rate limit params on a denom.
message LimitParams {
// denom is the denomination of the token being rate limited.
// e.g. ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5
string denom = 1;
// limiters is a list of rate-limiters on this denom. All limiters
// must be satified for a withdrawal to proceed.
repeated Limiter limiters = 2;
}

// Limiter defines one rate-limiter on a specfic denom.
message Limiter {
// period_sec is the rolling time period for which the limit applies
// e.g. 3600 (an hour)
uint32 period_sec = 2;
// baseline_minimum is the minimum maximum withdrawal coin amount within the
// time period.
// e.g. 100_000_000_000 uusdc for 100k USDC; 5e22 adv4tnt for 50k DV4TNT
bytes baseline_minimum = 3 [
(gogoproto.customtype) =
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
(gogoproto.nullable) = false
];
// baseline_tvl_ppm is the maximum ratio of TVL withdrawable in
// the time period, in part-per-million.
// e.g. 100_000 (10%)
uint32 baseline_tvl_ppm = 4;
}
46 changes: 46 additions & 0 deletions proto/dydxprotocol/ibcratelimit/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;

import "gogoproto/gogo.proto";
import "dydxprotocol/ibcratelimit/limit_params.proto";

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";

// Query defines the gRPC querier service.
service Query {
// List all limit params.
rpc ListLimitParams(ListLimitParamsRequest)
returns (ListLimitParamsResponse);

// Query capacity by denom.
rpc CapacityByDenom(QueryCapacityByDenomRequest)
returns (QueryCapacityByDenomResponse);
}

// ListLimitParamsRequest is a request type of the ListLimitParams RPC method.
message ListLimitParamsRequest {}

// ListLimitParamsResponse is a response type of the ListLimitParams RPC method.
message ListLimitParamsResponse {
repeated LimitParams limit_params_list = 1;
}

// QueryCapacityByDenomRequest is a request type for the CapacityByDenom RPC method.
message QueryCapacityByDenomRequest {
string denom = 1;
}

// CapacityResult is a specific rate limit for a denom.
message CapacityResult {
uint32 period_sec = 1;
bytes capacity = 2 [
(gogoproto.customtype) =
"github.com/dydxprotocol/v4-chain/protocol/dtypes.SerializableInt",
(gogoproto.nullable) = false
];
}

// QueryCapacityByDenomResponse is a response type of the CapacityByDenom RPC method.
message QueryCapacityByDenomResponse {
repeated CapacityResult results = 1;
}
42 changes: 42 additions & 0 deletions proto/dydxprotocol/ibcratelimit/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
syntax = "proto3";
package dydxprotocol.ibcratelimit;

option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/ibcratelimit/types";

import "cosmos/msg/v1/msg.proto";
import "dydxprotocol/ibcratelimit/limit_params.proto";

// Msg defines the Msg service.
service Msg {
// SetLimitParams sets a `LimitParams` object in state.
rpc SetLimitParams(MsgSetLimitParams) returns (MsgSetLimitParamsResponse);

// DeleteLimitParams removes a `LimitParams` object in state.
rpc DeleteLimitParams(MsgDeleteLimitParams) returns (MsgDeleteLimitParamsResponse);
}

// MsgSetLimitParams is the Msg/SetLimitParams request type.
message MsgSetLimitParams {
// The address that controls the module.
option (cosmos.msg.v1.signer) = "authority";
string authority = 1;

// Defines the parameters to set. All parameters must be supplied.
LimitParams limit_params = 2;
}

// MsgSetLimitParamsResponse is the Msg/SetLimitParams response type.
message MsgSetLimitParamsResponse {}

// MsgDeleteLimitParams is the Msg/SetLimitParams request type.
message MsgDeleteLimitParams {
// The address that controls the module.
option (cosmos.msg.v1.signer) = "authority";
string authority = 1;

// The denom for which the `LimitParams` should be deleted.
string denom = 2;
}

// MsgDeleteLimitParamsResponse is the Msg/DeleteLimitParams response type.
message MsgDeleteLimitParamsResponse {}
Loading

0 comments on commit 2bceab4

Please sign in to comment.