-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP: add ibc rate limit middleware to ibc transfer * WIP: add cll tx,query cmds 1. add cli queries for rate_limits and params 2. add updateProposal for rate_limits and ibcPause status * WIP: add check rate limits for ibc denom * remove ibc-rate-limits and move rate limits into ibctransfer module * move the umme ibctransfer into ics20 folder * fix: fix the lint * refactor: change the module structure to 'authz' type of cosmos-sdk * remove inflow_limit in rate limits * chore: check the rate limits by exchange rate * add denom exponent to calculate amount in USD * calculating the sent amount with exponent of registerd token * fix: fix the amount calculation * fix: fix the rate-limit reset issue * refactor: update the params 1. add token_quota, total_quota, quota_duration params 2. ibc-transfer token quota checking with token_quota and total_quota params * fix: fix the build * chore: update the limits and quota interval * chore: fix the lint issues * chore: fix the lint issues * chore: addree the pr comments 1. rename ibcratelimit to uibc module 2. update the uibc cli tx and queries 3. fix the quota expires of ibc-transfer * chore: remove the param subspace from uibc * refactor: refactor the proto and logic 1. ibc-transfer status now enum (enabled,disabled,paused) 2. get the exchange from base denom (ibc/xxx) * chore: address the pr comments 1. remove expire time for quota records 2. removed params subspace keys * fix: fix the buf lint * chore: get the exchange price from TokenValue of leverage * chore: convert uToken to baseToken in ibc-transfer quota checking * chore: add typed events for emit events * address the review comments 1. Rename ibc_denom to denom query * refactor the code 1. rename the GovUpdateTransferStatus to GovSetIBCPause 2. address the pr comments * address the pr comments * chore: fix the build issue * chore: add tests for params * fix: fix the update quota params * chore: address the pr comments * chore: fix the lint * address the pr comments++ * address the pr comments * update reset quota * move to Marshal to MustMarshal in uibc * add TODO for ibc middleware acknowledgement * add comment to outflow_sum --------- Co-authored-by: Robert Zaremba <robert@zaremba.ch>
- Loading branch information
1 parent
6253a22
commit 5d1a0a3
Showing
42 changed files
with
5,713 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
package umee.uibc.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/umee-network/umee/v4/x/uibc"; | ||
option (gogoproto.goproto_getters_all) = false; | ||
|
||
// EventBadRevert is emitted on failure of ibc-transfer quota. | ||
message EventBadRevert { | ||
// module name | ||
string module = 1; | ||
// failure event type | ||
string failure_type = 2; | ||
// ibc packet data | ||
string packet = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
syntax = "proto3"; | ||
package umee.uibc.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
import "umee/uibc/v1/quota.proto"; | ||
|
||
option go_package = "github.com/umee-network/umee/v4/x/uibc"; | ||
option (gogoproto.goproto_getters_all) = false; | ||
|
||
// GenesisState defines the uibc module's genesis state. | ||
message GenesisState { | ||
Params params = 1 [(gogoproto.nullable) = false]; | ||
repeated Quota quotas = 2 [(gogoproto.nullable) = false]; | ||
// total_outflow_sum defines the total outflow sum of ibc-transfer in USD | ||
string total_outflow_sum = 3 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", | ||
(gogoproto.nullable) = false | ||
]; | ||
// quota_expires defines quota expires for ibc-transfer denom in seconds | ||
google.protobuf.Timestamp quota_expires = 4 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.stdtime) = true, | ||
(gogoproto.jsontag) = "quota_duration,omitempty", | ||
(gogoproto.moretags) = "yaml:\"quota_expires\"" | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
syntax = "proto3"; | ||
package umee.uibc.v1; | ||
|
||
import "google/api/annotations.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "umee/uibc/v1/quota.proto"; | ||
|
||
option go_package = "github.com/umee-network/umee/v4/x/uibc"; | ||
|
||
option (gogoproto.goproto_getters_all) = false; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// Params queries the parameters of the x/uibc module. | ||
rpc Params(QueryParams) returns (QueryParamsResponse) { | ||
option (google.api.http).get = "/umee/uibc/v1/params"; | ||
} | ||
|
||
// Quota queries the rate limits of ibc denoms. | ||
// If denom is empty, returns quota for all tokens. | ||
rpc Quota(QueryQuota) returns (QueryQuotaResponse) { | ||
option (google.api.http).get = "/umee/uibc/v1/quota/{denom}"; | ||
} | ||
} | ||
|
||
// QueryParams defines the request structure for the Params gRPC service | ||
// handler. | ||
message QueryParams {} | ||
|
||
// QueryParamsResponse defines the response structure for the Params gRPC | ||
// service handler. | ||
message QueryParamsResponse { | ||
Params params = 1 [(gogoproto.nullable) = false]; | ||
} | ||
|
||
// QueryQuota defines request type for query the quota of denoms | ||
message QueryQuota { | ||
string denom = 1; | ||
} | ||
|
||
// QueryQuotaResponse defines response type of Query/Quota | ||
message QueryQuotaResponse { | ||
repeated Quota quota = 1 [(gogoproto.nullable) = false]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
syntax = "proto3"; | ||
package umee.uibc.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/protobuf/duration.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
|
||
option go_package = "github.com/umee-network/umee/v4/x/uibc"; | ||
|
||
// Quota stores current sum of IBC outflow transfers of IBC Denom. | ||
message Quota { | ||
// ibc_denom defines the ibc denom | ||
string ibc_denom = 1; | ||
// outflow_sum defines the sum of price (USD) value of outflow tokens through ibc-transfer | ||
string outflow_sum = 3 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// Params of x/uibc module | ||
message Params { | ||
// ibc_status defines the wethever ibc-transfer enabled, disbaled or paused | ||
IBCTransferStatus ibc_pause = 1; | ||
// total_quota defines the total outflow limit of ibc-transfer in USD | ||
string total_quota = 2 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", | ||
(gogoproto.nullable) = false | ||
]; | ||
// token_quota defines the outflow limit per token in USD | ||
string token_quota = 3 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", | ||
(gogoproto.nullable) = false | ||
]; | ||
// quota_duration defines quota expires for each ibc-transfer denom in seconds | ||
google.protobuf.Duration quota_duration = 4 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.stdduration) = true, | ||
(gogoproto.jsontag) = "quota_duration,omitempty", | ||
(gogoproto.moretags) = "yaml:\"quota_duration\"" | ||
]; | ||
} | ||
|
||
// IBCTransferStatus status of ibc-transfer | ||
enum IBCTransferStatus { | ||
// UNSPECIFIED defines a no-op status. | ||
IBC_TRANSFER_STATUS_UNSPECIFIED = 0; | ||
// DISABLED defines the quota checking diabled for ibc-transfer. | ||
IBC_TRANSFER_STATUS_DISABLED = 1; | ||
// ENABLED defines the enable quota checking for ibc-transfer. | ||
IBC_TRANSFER_STATUS_ENABLED = 2; | ||
// PAUSED defines pause the ibc-transfer from app. | ||
IBC_TRANSFER_STATUS_PAUSED = 3; | ||
} |
Oops, something went wrong.