From 9772ef1d02dc0ce8a36809fe26019cdea98a9a8f Mon Sep 17 00:00:00 2001 From: Robert Zaremba Date: Fri, 19 Apr 2024 15:10:09 +0200 Subject: [PATCH] update tests --- x/leverage/client/tests/tests.go | 4 ++-- x/leverage/fixtures/params.go | 1 + x/leverage/keeper/grpc_query_test.go | 13 +++++++------ x/leverage/keeper/interest_test.go | 6 +++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/x/leverage/client/tests/tests.go b/x/leverage/client/tests/tests.go index 86373ffd49..2dd9ad55a6 100644 --- a/x/leverage/client/tests/tests.go +++ b/x/leverage/client/tests/tests.go @@ -132,8 +132,8 @@ func (s *IntegrationTests) TestLeverageScenario() { OracleHistoricPrice: &oracleSymbolPrice, UTokenExchangeRate: sdk.OneDec(), // Borrow rate * (1 - ReserveFactor - OracleRewardFactor) - // 1.52 * (1 - 0.2 - 0.01) = 1.2008 - Supply_APY: sdk.MustNewDecFromStr("1.2008"), + // 1.52 * (1 - 0.2 - 0.01 - 0.02) + Supply_APY: sdk.MustNewDecFromStr("1.1704"), // This is an edge case technically - when effective supply, meaning // module balance + total borrows, is zero, utilization (0/0) is // interpreted as 100% so max borrow rate (152% APY) is used. diff --git a/x/leverage/fixtures/params.go b/x/leverage/fixtures/params.go index d609716a92..6f808f3546 100644 --- a/x/leverage/fixtures/params.go +++ b/x/leverage/fixtures/params.go @@ -12,6 +12,7 @@ func Params() types.Params { CompleteLiquidationThreshold: sdk.MustNewDecFromStr("0.1"), MinimumCloseFactor: sdk.MustNewDecFromStr("0.01"), OracleRewardFactor: sdk.MustNewDecFromStr("0.01"), + RewardsAuctionFactor: sdk.MustNewDecFromStr("0.02"), SmallLiquidationSize: sdk.MustNewDecFromStr("100.00"), DirectLiquidationFee: sdk.MustNewDecFromStr("0.1"), } diff --git a/x/leverage/keeper/grpc_query_test.go b/x/leverage/keeper/grpc_query_test.go index e819596ec5..9c5ff17b8c 100644 --- a/x/leverage/keeper/grpc_query_test.go +++ b/x/leverage/keeper/grpc_query_test.go @@ -76,12 +76,13 @@ func (s *IntegrationTestSuite) TestQuerier_MarketSummary() { oracleSymbolPrice := sdk.MustNewDecFromStr("4.21") expected := types.QueryMarketSummaryResponse{ - SymbolDenom: "UMEE", - Exponent: 6, - OraclePrice: &oracleSymbolPrice, - OracleHistoricPrice: &oracleSymbolPrice, - UTokenExchangeRate: sdk.OneDec(), - Supply_APY: sdk.MustNewDecFromStr("1.2008"), + SymbolDenom: "UMEE", + Exponent: 6, + OraclePrice: &oracleSymbolPrice, + OracleHistoricPrice: &oracleSymbolPrice, + UTokenExchangeRate: sdk.OneDec(), + // see cli/tests "query market summary - zero supply" + Supply_APY: sdk.MustNewDecFromStr("1.1704"), Borrow_APY: sdk.MustNewDecFromStr("1.52"), Supplied: sdk.ZeroInt(), Reserved: sdk.ZeroInt(), diff --git a/x/leverage/keeper/interest_test.go b/x/leverage/keeper/interest_test.go index 6b825177cf..8762eadc38 100644 --- a/x/leverage/keeper/interest_test.go +++ b/x/leverage/keeper/interest_test.go @@ -37,10 +37,10 @@ func (s *IntegrationTestSuite) TestAccrueZeroInterest() { require.Equal(sdk.MustNewDecFromStr("0.03"), borrowAPY) // supply APY when borrow APY is 3% - // and utilization is 4%, and reservefactor is 20%, and OracleRewardFactor is 1% - // 0.03 * 0.04 * (1 - 0.21) = 0.000948 + // and utilization is 4%, and reserve factor=20%, OracleRewardFactor=1% RewardsAuctionFactor=2% + // 0.03 * 0.04 * (1 - 0.2 - 0.01 - 0.02) supplyAPY := app.LeverageKeeper.DeriveSupplyAPY(ctx, appparams.BondDenom) - require.Equal(sdk.MustNewDecFromStr("0.000948"), supplyAPY) + require.Equal(sdk.MustNewDecFromStr("0.000924"), supplyAPY) } func (s *IntegrationTestSuite) TestDynamicInterest() {