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

Better packing of struct AuctionData to save gas #32

Closed
code423n4 opened this issue Nov 27, 2021 · 2 comments
Closed

Better packing of struct AuctionData to save gas #32

code423n4 opened this issue Nov 27, 2021 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Handle

tabish

Vulnerability details

Impact

Detailed description of the impact of this finding.

Struct AuctionData https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/Auction.sol#L26 currently uses 16 slots + mapping size . It is pack it more efficiently to save gas.

Recommended Mitigation Steps

Change Struct AuctionData to:

struct AuctionData {
  // The full amount of commitments required to return to peg
  uint256 fullRequirement;
  // total maximum desired commitments to this auction
  uint256 maxCommitments;
  // Quantity of sale currency committed to this auction
  uint256 commitments;
  // Malt purchased and burned using current commitments
  uint256 maltPurchased;
  // Desired starting price for the auction
  uint256 startingPrice;
  // Desired lowest price for the arbitrage token
  uint256 endingPrice;
  // Price of arbitrage tokens at conclusion of auction. This is either
  // when the duration elapses or the maxCommitments is reached
  uint256 finalPrice;
  // The peg price for the liquidity pool
  uint256 pegPrice;
  // Time when auction started
  uint256 startingTime;
  uint256 endingTime;
  // The reserve ratio at the start of the auction
  uint256 preAuctionReserveRatio;
  // The amount of arb tokens that have been executed and are now claimable
  uint256 claimableTokens;
  // The finally calculated realBurnBudget
  uint256 finalBurnBudget;
  // The amount of Malt purchased with realBurnBudget
  uint256 finalPurchased;
  // Has this auction been finalized? Meaning any additional stabilizing
  // has been done
  bool finalized;
  // Is the auction currently accepting commitments?
  bool active;
  // A map of all commitments to this auction by specific accounts
  mapping(address => AccountCommitment) accountCommitments;
}
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Nov 27, 2021
code423n4 added a commit that referenced this issue Nov 27, 2021
@0xScotch 0xScotch added the duplicate This issue or pull request already exists label Dec 9, 2021
@0xScotch
Copy link
Collaborator

0xScotch commented Dec 9, 2021

#38

@0xScotch 0xScotch closed this as completed Dec 9, 2021
@GalloDaSballo
Copy link
Collaborator

Duplicate of #38

@GalloDaSballo GalloDaSballo marked this as a duplicate of #38 Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

3 participants