Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(x/metoken) rewards auction integration #2513

Merged
merged 11 commits into from
May 3, 2024
5 changes: 5 additions & 0 deletions proto/umee/auction/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ message EventRewardsAuctionResult {
// Auctioned tokens.
repeated cosmos.base.v1beta1.Coin rewards = 4 [(gogoproto.nullable) = false];
}

// EventFundRewardsAuction is emitted when sending rewards to auction module
message EventFundRewardsAuction {
repeated cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false];
}
5 changes: 0 additions & 5 deletions proto/umee/leverage/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,3 @@ message EventFundOracle {
// Assets sent to oracle module
repeated cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false];
}

// EventFundAuction is emitted when sending rewards to auction module
message EventFundAuction {
repeated cosmos.base.v1beta1.Coin assets = 1 [(gogoproto.nullable) = false];
}
11 changes: 10 additions & 1 deletion proto/umee/metoken/v1/metoken.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ message Params {
// Interest claiming frequency in seconds, determines how often metoken module will claim accrued interest from
// leverage module
int64 claiming_frequency = 2;

// Rewards Auction Factor determines the portion of swap and redeem fee that is sent to the
// auction module for the rewards auction.
// Valid values: 0-10000 (in basis points, 2000 = 20%).
uint32 rewards_auction_factor = 3 [
(gogoproto.customtype) = "github.com/umee-network/umee/v6/util/bpmath.FixedBP",
(gogoproto.nullable) = false
];
}

// Index defines an index of assets that are allowed to swap and redeem for the Index's meToken,
Expand All @@ -40,7 +48,8 @@ message Index {
uint32 exponent = 3;

// Fee contains fee parameters used for swap and redemption fee calculations for all underlying
// assets in this index.
// assets in this index. `Params.rewards_auction_factor` of the fee will go for the burn
// auction.
Fee fee = 4 [(gogoproto.nullable) = false];

// Accepted Assets is the list of underlying Tokens that can be swapped and redeemed for the Index's meToken,
Expand Down
45 changes: 42 additions & 3 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5709,7 +5709,10 @@ paths:
Fee contains fee parameters used for swap and redemption
fee calculations for all underlying
assets in this index.
assets in this index. `Params.rewards_auction_factor` of
the fee will go for the burn
auction.
type: object
properties:
min_fee:
Expand Down Expand Up @@ -5867,6 +5870,16 @@ paths:
often metoken module will claim accrued interest from
leverage module
rewards_auction_factor:
type: integer
format: int64
description: >-
Rewards Auction Factor determines the portion of swap and
redeem fee that is sent to the
auction module for the rewards auction.
Valid values: 0-10000 (in basis points, 2000 = 20%).
description: Params defines the parameters for the metoken module.
description: >-
QueryParamsResponse defines the response structure for the Params
Expand Down Expand Up @@ -10333,7 +10346,10 @@ definitions:
Fee contains fee parameters used for swap and redemption fee
calculations for all underlying
assets in this index.
assets in this index. `Params.rewards_auction_factor` of the fee will
go for the burn
auction.
type: object
properties:
min_fee:
Expand Down Expand Up @@ -10532,6 +10548,16 @@ definitions:
module will claim accrued interest from
leverage module
rewards_auction_factor:
type: integer
format: int64
description: >-
Rewards Auction Factor determines the portion of swap and redeem fee
that is sent to the
auction module for the rewards auction.
Valid values: 0-10000 (in basis points, 2000 = 20%).
description: Params defines the parameters for the metoken module.
umee.metoken.v1.QueryIndexBalancesResponse:
type: object
Expand Down Expand Up @@ -10752,7 +10778,10 @@ definitions:
Fee contains fee parameters used for swap and redemption fee
calculations for all underlying
assets in this index.
assets in this index. `Params.rewards_auction_factor` of the fee
will go for the burn
auction.
type: object
properties:
min_fee:
Expand Down Expand Up @@ -10866,6 +10895,16 @@ definitions:
metoken module will claim accrued interest from
leverage module
rewards_auction_factor:
type: integer
format: int64
description: >-
Rewards Auction Factor determines the portion of swap and redeem
fee that is sent to the
auction module for the rewards auction.
Valid values: 0-10000 (in basis points, 2000 = 20%).
description: Params defines the parameters for the metoken module.
description: |-
QueryParamsResponse defines the response structure for the Params gRPC
Expand Down
5 changes: 5 additions & 0 deletions util/bpmath/bp.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func (bp BP) MulDec(a sdk.Dec) sdk.Dec {
return MulDec(a, bp)
}

// Equal returns true if bp==a.
func (bp BP) Equal(a BP) bool {
return bp == a
}

// FromQuo returns a/b in basis points.
// Contract: a>=0 and b > 0.
// Panics if a/b >= MaxUint32/10'000 or if b==0.
Expand Down
12 changes: 12 additions & 0 deletions util/bpmath/bp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,15 @@ func TestBPMulDec(t *testing.T) {
require.Equal(sdk.MustNewDecFromStr("6.2501"), bp3.MulDec(d))
require.Equal(sdk.MustNewDecFromStr("25.0004"), bp4.MulDec(d))
}

func TestBPEqual(t *testing.T) {
t.Parallel()
require := require.New(t)

var b1 BP = 1
var b2 BP = 1
var b3 BP = 10
require.True(b1.Equal(b2))
require.True(b2.Equal(b2))
require.False(b1.Equal(b3))
}
5 changes: 5 additions & 0 deletions util/bpmath/fixed_bp.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ func (bp FixedBP) Mul(a math.Int) math.Int {
func (bp FixedBP) MulDec(a sdk.Dec) sdk.Dec {
return MulDec(a, bp)
}

// Equal returns true if bp==a.
func (bp FixedBP) Equal(a FixedBP) bool {
return bp == a
}
12 changes: 12 additions & 0 deletions util/bpmath/fixed_bp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,15 @@ func TestFixedBPMulDec(t *testing.T) {
require.Equal(sdk.MustNewDecFromStr("6.2501"), bp3.MulDec(d))
require.Equal(sdk.MustNewDecFromStr("25.0004"), bp4.MulDec(d))
}

func TestFixedBPEqual(t *testing.T) {
t.Parallel()
require := require.New(t)

var b1 FixedBP = 1
var b2 FixedBP = 1
var b3 FixedBP = 10
require.True(b1.Equal(b2))
require.True(b2.Equal(b2))
require.False(b1.Equal(b3))
}
Loading
Loading