You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wrong period considered in Pool::transferReserveToAuction
Summary
The Pool::transferReserveToAuction function uses a wrong period to transfer the reserveToken amount to the auction. The proper period is the currentPeriod-1 while instead the function uses the currentPeriod.
The proper period to be used is the currentPeriod-1 because when creating an auction the current period in the bond contract increases by 1 cause of the function called BondToken::increaseIndexedAssetPeriod. So as it is every time the Pool::transferReserveToAuction function is called it will always get the address(0) as the auctions[currentPeriod].
function startAuction() externalwhenNotPaused() {
// Check if distribution period has passedrequire(lastDistribution + distributionPeriod <block.timestamp, DistributionPeriodNotPassed());
// Check if auction period hasn't passedrequire(lastDistribution + distributionPeriod + auctionPeriod >=block.timestamp, AuctionPeriodPassed());
// Check if auction for current period has already started
(uint256currentPeriod,) = bondToken.globalPool();
require(auctions[currentPeriod] ==address(0), AuctionAlreadyStarted());
uint8 bondDecimals = bondToken.decimals();
uint8 sharesDecimals = bondToken.SHARES_DECIMALS();
uint8 maxDecimals = bondDecimals > sharesDecimals ? bondDecimals : sharesDecimals;
uint256 normalizedTotalSupply = bondToken.totalSupply().normalizeAmount(bondDecimals, maxDecimals);
uint256 normalizedShares = sharesPerToken.normalizeAmount(sharesDecimals, maxDecimals);
// Calculate the coupon amount to distributeuint256 couponAmountToDistribute = (normalizedTotalSupply * normalizedShares)
.toBaseUnit(maxDecimals *2-IERC20(couponToken).safeDecimals());
auctions[currentPeriod] = Utils.deploy(
address(newAuction()),
abi.encodeWithSelector(
Auction.initialize.selector,
address(couponToken),
address(reserveToken),
couponAmountToDistribute,
block.timestamp+ auctionPeriod,
1000,
address(this),
poolSaleLimit
)
);
// Increase the bond token period
@> bondToken.increaseIndexedAssetPeriod(sharesPerToken);
// Update last distribution time
lastDistribution =block.timestamp;
}
An auction is created and ends with the sate SUCCEEDED.
External Pre-conditions
None.
Attack Path
The auction contract will try to call the Pool::transferReserveToAuction but it will not get the reserveToken amount because of the require. This because of the wrong period used in Pool::transferReserveToAuction.
Stable Brick Swan
High
Wrong period considered in
Pool::transferReserveToAuction
Summary
The
Pool::transferReserveToAuction
function uses a wrong period to transfer thereserveToken
amount to the auction. The proper period is thecurrentPeriod-1
while instead the function uses thecurrentPeriod
.Relevant GitHub Links
https://github.com/sherlock-audit/2024-12-plaza-finance/blob/main/plaza-evm/src/Pool.sol#L578-L579
https://github.com/sherlock-audit/2024-12-plaza-finance/blob/main/plaza-evm/src/BondToken.sol#L217-L229
https://github.com/sherlock-audit/2024-12-plaza-finance/blob/main/plaza-evm/src/Pool.sol#L567
Root Cause
The proper period to be used is the
currentPeriod-1
because when creating an auction the current period in the bond contract increases by 1 cause of the function calledBondToken::increaseIndexedAssetPeriod
. So as it is every time thePool::transferReserveToAuction
function is called it will always get theaddress(0)
as theauctions[currentPeriod]
.Internal Pre-conditions
An auction is created and ends with the sate
SUCCEEDED
.External Pre-conditions
None.
Attack Path
The
auction
contract will try to call thePool::transferReserveToAuction
but it will not get thereserveToken
amount because of therequire
. This because of the wrong period used inPool::transferReserveToAuction
.Impact
Every auction that ends with the state
SUCCEEDED
will not be able to get the amount of thereserveToken
it should.Mitigation
The text was updated successfully, but these errors were encountered: