Skip to content

Commit

Permalink
WIP: adding quota v2
Browse files Browse the repository at this point in the history
  • Loading branch information
gsk967 committed Oct 26, 2023
1 parent ff4a594 commit 5578d8c
Show file tree
Hide file tree
Showing 10 changed files with 355 additions and 87 deletions.
12 changes: 11 additions & 1 deletion proto/umee/uibc/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ message GenesisState {
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
(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",
Expand All @@ -31,4 +30,15 @@ message GenesisState {
(gogoproto.jsontag) = "quota_duration,omitempty",
(gogoproto.moretags) = "yaml:\"quota_expires\""
];
// inflows defines inflow amount of denoms
repeated cosmos.base.v1beta1.DecCoin inflows = 5 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
(gogoproto.nullable) = false
];
// total_inflow_sum defines the total inflow sum of ibc-transfer in USD.
string total_inflow_sum = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}
6 changes: 6 additions & 0 deletions proto/umee/uibc/v1/quota.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ message Params {
(gogoproto.jsontag) = "quota_duration,omitempty",
(gogoproto.moretags) = "yaml:\"quota_duration\""
];
// total_inflow_quota defines the total inflow limit of ibc-transfer in USD
string total_inflow_quota = 5 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

// IBCTransferStatus status of ibc-transfer quota check for inflow and outflow
Expand Down
165 changes: 136 additions & 29 deletions x/uibc/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions x/uibc/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
// DefaultParams returns default genesis params
func DefaultParams() Params {
return Params{
IbcStatus: IBCTransferStatus_IBC_TRANSFER_STATUS_QUOTA_ENABLED,
TotalQuota: sdk.NewDec(1_000_000),
TokenQuota: sdk.NewDec(600_000),
QuotaDuration: time.Second * 60 * 60 * 24, // 24h
IbcStatus: IBCTransferStatus_IBC_TRANSFER_STATUS_QUOTA_ENABLED,
TotalQuota: sdk.NewDec(1_000_000),
TokenQuota: sdk.NewDec(600_000),
QuotaDuration: time.Second * 60 * 60 * 24, // 24h
TotalInflowQuota: sdk.NewDec(1_000_000),
}
}

Expand All @@ -30,6 +31,9 @@ func (p Params) Validate() error {
if err := validateQuota(p.TokenQuota, "quota per token"); err != nil {
return err
}
if err := validateQuota(p.TotalInflowQuota, "total inflow quota"); err != nil {
return err
}
if p.TotalQuota.LT(p.TokenQuota) {
return fmt.Errorf("token quota shouldn't be less than quota per denom")
}
Expand Down
Loading

0 comments on commit 5578d8c

Please sign in to comment.