-
Notifications
You must be signed in to change notification settings - Fork 45
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
Auction proceeds burn #317
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,11 @@ func (s *IntegrationTestSuite) TestAuction() { | |
s.Require().NoError(err) | ||
auctionQueryClient := types.NewQueryClient(val0ClientCtx) | ||
|
||
// Query the total supply of usomm before the auction | ||
bankQueryClient := banktypes.NewQueryClient(val0ClientCtx) | ||
supplyRes, err := bankQueryClient.SupplyOf(context.Background(), &banktypes.QuerySupplyOfRequest{Denom: testDenom}) | ||
s.Require().NoError(err) | ||
|
||
// Verify auction created for testing exists | ||
auctionQuery := types.QueryActiveAuctionRequest{ | ||
AuctionId: uint32(1), | ||
|
@@ -115,7 +120,6 @@ func (s *IntegrationTestSuite) TestAuction() { | |
}, time.Second*30, time.Second*5, "proposal was never accepted") | ||
s.T().Log("Proposal approved!") | ||
|
||
bankQueryClient := banktypes.NewQueryClient(val0ClientCtx) | ||
balanceRes, err := bankQueryClient.AllBalances(context.Background(), &banktypes.QueryAllBalancesRequest{Address: authtypes.NewModuleAddress(types.ModuleName).String()}) | ||
s.Require().NoError(err) | ||
s.T().Logf("Auction module token balances before bids %v", balanceRes.Balances) | ||
|
@@ -293,6 +297,37 @@ func (s *IntegrationTestSuite) TestAuction() { | |
s.Require().Equal(expectedEndedAuction, *endedAuctionResponse.Auction) | ||
s.T().Log("Ended auction stored correctly!") | ||
|
||
s.T().Log("Verifying cellarfees module account balance...") | ||
cellarfeesModuleAddress := authtypes.NewModuleAddress(cellarfees.ModuleName).String() | ||
cellarfeesBalanceRes, err := bankQueryClient.AllBalances(context.Background(), &banktypes.QueryAllBalancesRequest{Address: cellarfeesModuleAddress}) | ||
s.Require().NoError(err) | ||
|
||
totalSommPaid := expectedBid1.TotalUsommPaid.Amount.Add(expectedBid2.TotalUsommPaid.Amount) | ||
// default burn rate is 0.5 so 50% of the SOMM paid to the cellarfees module account | ||
expectedCellarfeesSomm := totalSommPaid.Quo(sdk.NewInt(2)) | ||
|
||
found, cellarfeesSommBalance := balanceOfDenom(cellarfeesBalanceRes.Balances, testDenom) | ||
s.Require().True(found, "SOMM balance not present in cellarfees module account") | ||
s.Require().GreaterOrEqual(expectedCellarfeesSomm.Int64(), cellarfeesSommBalance.Amount.Int64(), "Cellarfees module account should have 50% or less of the SOMM received from the auction (less if distributions have occurred)") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the assertion logic in balance comparison In the assertion: s.Require().GreaterOrEqual(expectedCellarfeesSomm.Int64(), cellarfeesSommBalance.Amount.Int64(), "Cellarfees module account should have 50% or less of the SOMM received from the auction (less if distributions have occurred)") The logic is inverted. Since the cellarfees module account should have 50% or less of the SOMM received from the auction, the assertion should check that the actual balance is less than or equal to the expected balance. Consider changing the assertion to: s.Require().LessOrEqual(cellarfeesSommBalance.Amount.Int64(), expectedCellarfeesSomm.Int64(), "Cellarfees module account should have 50% or less of the SOMM received from the auction (less if distributions have occurred)") Apply this diff to correct the assertion: -s.Require().GreaterOrEqual(expectedCellarfeesSomm.Int64(), cellarfeesSommBalance.Amount.Int64(), "Cellarfees module account should have 50% or less of the SOMM received from the auction (less if distributions have occurred)")
+s.Require().LessOrEqual(cellarfeesSommBalance.Amount.Int64(), expectedCellarfeesSomm.Int64(), "Cellarfees module account should have 50% or less of the SOMM received from the auction (less if distributions have occurred)") |
||
s.T().Log("Cellarfees module account balance verified correctly!") | ||
|
||
s.T().Log("Verifying total supply of usomm has been reduced...") | ||
|
||
// Calculate the expected burn amount (50% of total SOMM paid in auction) | ||
expectedBurnAmount := totalSommPaid.Quo(sdk.NewInt(2)) | ||
|
||
// Calculate the expected new total supply | ||
expectedNewSupply := supplyRes.Amount.Amount.Sub(expectedBurnAmount) | ||
|
||
// Query the actual new total supply | ||
newSupplyRes, err := bankQueryClient.SupplyOf(context.Background(), &banktypes.QuerySupplyOfRequest{Denom: testDenom}) | ||
s.Require().NoError(err) | ||
|
||
// Verify that the new supply matches the expected new supply | ||
s.Require().Equal(expectedNewSupply.Int64(), newSupplyRes.Amount.Amount.Int64(), "Total supply of usomm should be reduced by the amount burnt") | ||
|
||
s.T().Log("Total supply of usomm has been correctly reduced!") | ||
|
||
s.T().Log("--Test completed successfully--") | ||
}) | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -216,8 +216,10 @@ func (suite *KeeperTestSuite) TestHappyPathFinishAuction() { | |||||||||||||||||
TotalUsommPaid: amountPaid2, | ||||||||||||||||||
}) | ||||||||||||||||||
|
||||||||||||||||||
// Second transfer to return proceeds from bids | ||||||||||||||||||
totalUsommExpected := sdk.NewCoin(params.BaseCoinUnit, amountPaid1.Amount.Add(amountPaid2.Amount)) | ||||||||||||||||||
// Burn and send remaining proceeds from bids | ||||||||||||||||||
totalBurnExpected := sdk.NewCoin(params.BaseCoinUnit, amountPaid1.Amount.Add(amountPaid2.Amount).Quo(sdk.NewInt(2))) | ||||||||||||||||||
suite.mockBurnCoins(ctx, auctionTypes.ModuleName, sdk.NewCoins(totalBurnExpected)) | ||||||||||||||||||
totalUsommExpected := sdk.NewCoin(params.BaseCoinUnit, amountPaid1.Amount.Add(amountPaid2.Amount).Sub(totalBurnExpected.Amount)) | ||||||||||||||||||
Comment on lines
+220
to
+222
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential integer division rounding issue in burn calculation The calculation of Apply this diff to fix the rounding issue: - totalBurnExpected := sdk.NewCoin(params.BaseCoinUnit, amountPaid1.Amount.Add(amountPaid2.Amount).Quo(sdk.NewInt(2)))
+ totalAmount := amountPaid1.Amount.Add(amountPaid2.Amount)
+ totalBurnDec := sdk.NewDecFromInt(totalAmount).Quo(sdk.NewDec(2))
+ totalBurnExpected := sdk.NewCoin(params.BaseCoinUnit, totalBurnDec.TruncateInt()) Update the calculation of - totalUsommExpected := sdk.NewCoin(params.BaseCoinUnit, amountPaid1.Amount.Add(amountPaid2.Amount).Sub(totalBurnExpected.Amount))
+ totalUsommExpected := sdk.NewCoin(params.BaseCoinUnit, totalAmount.Sub(totalBurnExpected.Amount)) 📝 Committable suggestion
Suggested change
|
||||||||||||||||||
suite.mockSendCoinsFromModuleToModule(ctx, auctionTypes.ModuleName, permissionedReciever.GetName(), sdk.NewCoins(totalUsommExpected)) | ||||||||||||||||||
|
||||||||||||||||||
// Change active auction tokens remaining before finishing auction to pretend tokens were sold | ||||||||||||||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Inconsistent Burner Permission in Auction Module
The addition of
{authtypes.Burner}
permission to theauctiontypes.ModuleName
in themaccPerms
map is not supported by the current implementation. No actual burn functions are present in the auction module outside of test and mock files.Please ensure that the burn functionality is properly implemented in the auction module or remove the burner permission to maintain consistency and security.
🔗 Analysis chain
LGTM. Verify auction module's burn logic.
The addition of
{authtypes.Burner}
permission to theauctiontypes.ModuleName
in themaccPerms
map is correct and aligns with the PR objective of implementing an "Auction proceeds burn" feature. This change allows the auction module to burn tokens.To ensure this change is properly implemented, please verify:
Run the following script to check for burn-related functions in the auction module:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 542
Script:
Length of output: 298