Skip to content

Commit

Permalink
Add additional test for MinAveragePrice > LimitSellPrice
Browse files Browse the repository at this point in the history
  • Loading branch information
jcompagni10 committed Oct 11, 2024
1 parent 78730d7 commit 4fbfc01
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions x/dex/keeper/integration_placelimitorder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,48 @@ func (s *DexTestSuite) TestPlaceLimitOrderIOCWithDustMinAvgPrice() {
s.NoError(err)
}

func (s *DexTestSuite) TestPlaceLimitOrderIOCMinAvgPriceGTSellPriceFails() {
s.fundAliceBalances(40, 0)
s.fundBobBalances(0, 40)
// GIVEN LP liq between taker price .995 and .992
s.bobDeposits(
NewDeposit(0, 10, 50, 1),
NewDeposit(0, 10, 60, 1),
NewDeposit(0, 10, 70, 1),
NewDeposit(0, 10, 80, 1),
)
// THEN alice places IOC limitOrder with very low MinAveragePrice Fails
_, err := s.aliceLimitSellsWithMinAvgPrice(
"TokenA",
math_utils.MustNewPrecDecFromStr("0.99"),
40,
math_utils.MustNewPrecDecFromStr("0.995"),
types.LimitOrderType_IMMEDIATE_OR_CANCEL,
)
s.ErrorIs(err, types.ErrLimitPriceNotSatisfied)
}

func (s *DexTestSuite) TestPlaceLimitOrderIOCMinAvgPriceGTSellPrice() {
s.fundAliceBalances(40, 0)
s.fundBobBalances(0, 40)
// GIVEN LP liq between taker price .995 and .992
s.bobDeposits(
NewDeposit(0, 10, 50, 1),
NewDeposit(0, 10, 60, 1),
NewDeposit(0, 10, 70, 1),
NewDeposit(0, 10, 80, 1),
)
// THEN alice places IOC limitOrder with an achievable MinAveragePrice
_, err := s.aliceLimitSellsWithMinAvgPrice(
"TokenA",
math_utils.MustNewPrecDecFromStr("0.99"),
40,
math_utils.MustNewPrecDecFromStr("0.993"),
types.LimitOrderType_IMMEDIATE_OR_CANCEL,
)
s.NoError(err)
}

func (s *DexTestSuite) TestPlaceLimitOrderWithDust() {
s.fundAliceBalances(1, 0)
s.fundBobBalances(0, 1)
Expand Down

0 comments on commit 4fbfc01

Please sign in to comment.