Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Apr 19, 2024
1 parent eec9baf commit 9772ef1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions x/leverage/client/tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions x/leverage/fixtures/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
Expand Down
13 changes: 7 additions & 6 deletions x/leverage/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions x/leverage/keeper/interest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 9772ef1

Please sign in to comment.