The Swan protocol operates on a round-based system where each round has three phases: Sell, Buy, and Withdraw. During the Sell phase, sellers can list assets to buyer agents and pay royalty fees. The buyer agents can then purchase these assets during the Buy phase.
The timing of these phases is controlled by market parameters stored in the Swan contract, which can be updated over time. The BuyerAgent
contract tracks rounds and phases using the getRoundPhase()
function.
The getRoundPhase()
function in BuyerAgent
has a critical flaw in how it handles market parameter updates. When new market parameters are pushed to the Swan contract, all buyer agents effectively have their phases reset to the Sell phase, as the function treats this as the start of a new round based on the new market parameters' timestamp.
The root cause is in how the final phase calculation is done in getRoundPhase()
. When computing the current phase for the latest market parameters, it uses the timestamp difference from the new parameters, effectively resetting the phase timing:
This creates a scenario where sellers can pay royalty fees to list assets to a buyer agent during the Sell phase, but if market parameters are updated before the Buy phase begins, the round effectively ends prematurely. The buyer agent never gets the opportunity to purchase the listed assets, and the sellers lose their royalty fees without any possibility of a sale.
Medium. This issue directly causes financial loss to sellers who pay royalty fees but lose the opportunity to sell their assets due to the premature round termination. The impact is amplified because:
Sellers have no way to predict or prevent this situation
The lost royalty fees cannot be recovered
This affects all buyer agents system-wide when parameters are updated
Medium. While market parameter updates may not be frequent, when they do occur, this issue will affect all sellers who listed assets during the Sell phase immediately preceding the update. The likelihood increases with:
More frequent market parameter updates
Higher number of active buyer agents
Higher volume of listings near parameter update times
Alice lists an asset to BuyerAgent1 during Sell phase, paying 5% royalty fee
Before Buy phase begins, Swan admin updates market parameters
getRoundPhase()
treats this as a new round starting with Sell phase
BuyerAgent1 never enters Buy phase for the previous round
Alice's asset is never purchasable in the round associated and her royalty fee is lost
The protocol could implement a refund mechanism to reimburse sellers who lose royalty fees due to market parameter updates.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.