Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add minAverageSellPrice for LO #736

Merged
merged 10 commits into from
Oct 14, 2024
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With very high? (not "low")

_, 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
Loading