Skip to content

Commit

Permalink
update metoken params name and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed May 15, 2024
1 parent aae72f6 commit 15d9dbe
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 79 deletions.
2 changes: 1 addition & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (app *UmeeApp) registerUpgrade6_5(upgradeInfo upgradetypes.Plan) {

mekeeper := app.MetokenKeeperB.Keeper(&ctx)
meparams := mekeeper.GetParams()
meparams.RewardsAuctionFactor = metoken.DefaultParams().RewardsAuctionFactor
meparams.RewardsAuctionFeeFactor = metoken.DefaultParams().RewardsAuctionFeeFactor
if err := mekeeper.SetParams(meparams); err != nil {
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions proto/umee/metoken/v1/metoken.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ message Params {
// 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.
// Rewards Auction Fee Factor determines the portion of total fees collected by the metoken
// module that will go for the rewards auction. Note: this is different than x/leverage
// Params.rewards_auction_factor.
// Valid values: 0-10000 (in basis points, 2000 = 20%).
uint32 rewards_auction_factor = 3 [
uint32 rewards_auction_fee_factor = 3 [
(gogoproto.customtype) = "github.com/umee-network/umee/v6/util/bpmath.FixedBP",
(gogoproto.nullable) = false
];
Expand Down
33 changes: 21 additions & 12 deletions swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5870,14 +5870,17 @@ paths:
often metoken module will claim accrued interest from
leverage module
rewards_auction_factor:
rewards_auction_fee_factor:
type: integer
format: int64
description: >-
Rewards Auction Factor determines the portion of swap and
redeem fee that is sent to the
Rewards Auction Fee Factor determines the portion of total
fees collected by the metoken
module that will go for the rewards auction. Note: this is
different than x/leverage
auction module for the rewards auction.
Params.rewards_auction_factor.
Valid values: 0-10000 (in basis points, 2000 = 20%).
description: Params defines the parameters for the metoken module.
Expand Down Expand Up @@ -10548,14 +10551,17 @@ definitions:
module will claim accrued interest from
leverage module
rewards_auction_factor:
rewards_auction_fee_factor:
type: integer
format: int64
description: >-
Rewards Auction Factor determines the portion of swap and redeem fee
that is sent to the
Rewards Auction Fee Factor determines the portion of total fees
collected by the metoken
auction module for the rewards auction.
module that will go for the rewards auction. Note: this is different
than x/leverage
Params.rewards_auction_factor.
Valid values: 0-10000 (in basis points, 2000 = 20%).
description: Params defines the parameters for the metoken module.
Expand Down Expand Up @@ -10895,14 +10901,17 @@ definitions:
metoken module will claim accrued interest from
leverage module
rewards_auction_factor:
rewards_auction_fee_factor:
type: integer
format: int64
description: >-
Rewards Auction Factor determines the portion of swap and redeem
fee that is sent to the
Rewards Auction Fee Factor determines the portion of total fees
collected by the metoken
module that will go for the rewards auction. Note: this is
different than x/leverage
auction module for the rewards auction.
Params.rewards_auction_factor.
Valid values: 0-10000 (in basis points, 2000 = 20%).
description: Params defines the parameters for the metoken module.
Expand Down
4 changes: 2 additions & 2 deletions x/metoken/keeper/intest/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ func verifySwap(

// totalfee = feeRate * amount
totalFee := sdk.NewCoin(denom, feeRate.MulInt(tc.asset.Amount).TruncateInt())
feeToAuction := params.RewardsAuctionFactor.Mul(totalFee.Amount)
feeToAuction := params.RewardsAuctionFeeFactor.Mul(totalFee.Amount)
feeToReserve := totalFee.Amount.Sub(feeToAuction)

// amount_to_swap = swap_amount - fee
Expand Down Expand Up @@ -1718,7 +1718,7 @@ func verifyRedeem(

// totalfee = feeRate * amount_to_redeem
totalFee := sdk.NewCoin(tc.denom, feeRate.MulInt(amountToWithdraw).TruncateInt())
feeToAuction := params.RewardsAuctionFactor.Mul(totalFee.Amount)
feeToAuction := params.RewardsAuctionFeeFactor.Mul(totalFee.Amount)
feeToReserve := totalFee.Amount.Sub(feeToAuction)

amountToRedeem := amountToWithdraw.Sub(totalFee.Amount)
Expand Down
2 changes: 1 addition & 1 deletion x/metoken/keeper/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (k Keeper) availableToSupply(denom string) (bool, sdkmath.Int, error) {
// breakFee calculates the protocol fee for the burn auction and the reminder
func (k Keeper) breakFee(fee sdkmath.Int) (sdkmath.Int, sdkmath.Int) {
p := k.GetParams()
toAuction := p.RewardsAuctionFactor.Mul(fee)
toAuction := p.RewardsAuctionFeeFactor.Mul(fee)
return toAuction, fee.Sub(toAuction)
}

Expand Down
4 changes: 2 additions & 2 deletions x/metoken/keeper/swap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestSwap_Valid(t *testing.T) {
usdBal2, n := indexBal2.AssetBalance(tenUSDT.Denom)
assert.GreaterOrEqual(n, 0)
usdBal1, _ := indexBal1.AssetBalance(tenUSDT.Denom)
toAuction := params.RewardsAuctionFactor.Mul(resp.fee.Amount)
toAuction := params.RewardsAuctionFeeFactor.Mul(resp.fee.Amount)
assert.Equal(usdBal2.Fees.Sub(usdBal1.Fees), resp.fee.Amount.Sub(toAuction))

// exchange_rate = coin_price / metoken_price
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestBreakFees(t *testing.T) {
assert := assert.New(t)
k := initMeUSDNoopKeper(t)
p := k.GetParams()
assert.EqualValues(p.RewardsAuctionFactor, 1000)
assert.EqualValues(p.RewardsAuctionFeeFactor, 1000)

amount := sdkmath.NewInt(2_000)
toAuction, toRevenue := k.breakFee(amount)
Expand Down
115 changes: 58 additions & 57 deletions x/metoken/metoken.pb.go

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

2 changes: 1 addition & 1 deletion x/metoken/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ func DefaultParams() Params {
return Params{
RebalancingFrequency: 60 * 60 * 12, // 12h
ClaimingFrequency: 60 * 60 * 24 * 7, // 7d
RewardsAuctionFactor: 2000, // 20% of fees goes to rewards auction
RewardsAuctionFeeFactor: 2000, // 20% of fees goes to rewards auction
}
}

0 comments on commit 15d9dbe

Please sign in to comment.