Skip to content

Commit

Permalink
borrow and maxborrow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
toteki committed Jun 27, 2023
1 parent 9d0421f commit 4104e6f
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions x/leverage/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,13 @@ func (s *IntegrationTestSuite) TestMsgBorrow() {
// collateral value is $50 (current) or $100 (historic)
// collateral weights are always 0.25 in testing

// create an UMEE borrower using STABLE collateral
stableUmeeBorrower := s.newAccount(coin.New(stableDenom, 40_000000))
s.supply(stableUmeeBorrower, coin.New(stableDenom, 40_000000))
s.collateralize(stableUmeeBorrower, coin.New("u/"+stableDenom, 40_000000))
s.borrow(stableUmeeBorrower, coin.New(umeeDenom, 3_000000))
// UMEE and STABLE have the same price but different collateral weights

tcs := []testCase{
{
"uToken",
Expand All @@ -1332,14 +1339,19 @@ func (s *IntegrationTestSuite) TestMsgBorrow() {
coin.New(umeeDenom, 70_000000),
nil,
}, {
"additional borrow",
borrower,
coin.New(umeeDenom, 20_000000),
"stable umee borrower (acceptable)",
stableUmeeBorrower,
coin.New(umeeDenom, 17_000000),
nil,
}, {
"stable umee borrower (borrow factor limit)",
stableUmeeBorrower,
coin.New(umeeDenom, 1_000000),
types.ErrUndercollaterized,
}, {
"max supply utilization",
borrower,
coin.New(umeeDenom, 10_000000),
coin.New(umeeDenom, 9_000000),
types.ErrMaxSupplyUtilization,
}, {
"atom borrow",
Expand Down Expand Up @@ -1457,6 +1469,13 @@ func (s *IntegrationTestSuite) TestMsgMaxBorrow() {
// collateral value is $50 (current) or $100 (historic)
// collateral weights are always 0.25 in testing

// create an UMEE borrower using STABLE collateral
stableUmeeBorrower := s.newAccount(coin.New(stableDenom, 100_000000))
s.supply(stableUmeeBorrower, coin.New(stableDenom, 100_000000))
s.collateralize(stableUmeeBorrower, coin.New("u/"+stableDenom, 100_000000))
s.borrow(stableUmeeBorrower, coin.New(umeeDenom, 30_000000))
// UMEE and STABLE have the same price but different collateral weights

tcs := []struct {
msg string
addr sdk.AccAddress
Expand Down Expand Up @@ -1498,6 +1517,11 @@ func (s *IntegrationTestSuite) TestMsgMaxBorrow() {
pumpborrower,
coin.New(pumpDenom, 6_250000),
nil,
}, {
"stable umee borrower",
stableUmeeBorrower,
coin.New(umeeDenom, 20_000000),
nil,
},
}

Expand Down

0 comments on commit 4104e6f

Please sign in to comment.