Skip to content
Business logic Audit finding Intermediate

Market expiry behaviour differs in implementation and documentation

The documentation stated that an unsettled market would automatically settle at the lower bound of its valuation range after expiry, but the smart contract ignored the expiry date and settled at a 1:1 ratio. Users who relied on the documentation could make trades expecting a different settlement, leading to unexpected swap fees and potential losses.

GreyArt Follow

Originally disclosed on Code4rena

Submitted by GreyArt, also found by leastwood and rayn

prePO Docs: Expiry PrePOMarket.sol#L145-L156

The docs say that “If a market has not settled by its expiry date, it will automatically settle at the lower bound of its Valuation Range.”

However, in the implementation, the expiry date is entirely ignored. The default settlement after expiry is a 1:1 ratio of long and short token for 1 collateral token.

Impact

Should users believe that the market will settle at the lower bound, they would swap and hold long for short tokens instead of at a 1:1 ratio upon expiry. Thereafter, they would incur swap fees from having to swap some short tokens back for long tokens for redemption. User funds are also affected should long tokens are repurchased at a higher price than when they were sold.

Recommended Mitigation Steps

If the market is to settle at the lower valuation after expiry, then the following logic should be added:

// market has expired
// settle at lower bound
if (block.timestamp > _expiryTime) {
	uint256 _shortPrice = MAX_PRICE - _floorLongPrice;
	_collateralOwed =
		(_floorLongPrice * _longAmount + _shortPrice * _shortAmount) /
		MAX_PRICE;
} else if (_finalLongPrice <= MAX_PRICE) {
	...
} else {
	...
}

Otherwise, the documentation should be updated to reflect the default behaviour of 1:1 redemption.

ramenforbreakfast (prePO) disagreed with Medium severity

ramenforbreakfast (prePO) agreed with Medium severity and commented:

This is a valid submission, no longer disagreeing with severity as we clearly stated that expiry should be enforceable.

This was a mistake on our part and I think we ended up not using expiryTime since the only thing that really mattered was if the finalLongPrice was set. We should decide whether to enforce it or remove it altogether.

gzeon (judge) commented:

Agree with sponsor.


The original report as published on Code4rena, by GreyArt. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the expiry time variable was not used in the settlement logic, so the contract defaulted to a 1:1 redemption instead of the documented lower-bound settlement.

Impact

Users who believed the market would settle at the lower bound could incur swap fees and lose funds from repurchasing long tokens at a higher price, as the actual settlement was 1:1.

What the attacker needed

Market reaches expiry without settlement; users rely on documented behaviour

The fix

The contract should be updated to enforce the expiry-based settlement at the lower bound, or the documentation should be corrected to describe the 1:1 default behaviour.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract is a program on a blockchain that runs automatically. This report says the written rules for a trading market said one thing would happen after a deadline, but the code did something else. People who trusted the written rules could lose money because the actual outcome was different.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by GreyArt

View all

12 more disclosed reports, best first.

More from prePO contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.