peanuts
medium
The premium gets stuck in BufferBinaryOptions contract when the option closes OTM or ATM.
The first transfer of funds happens when user initiateTrade() and _openQueuedTrade is called().
tokenX.transfer(queuedTrade.targetContract, revisedFee);
The user's revised funds for the option is transferred to the targetContract, which is the BufferBinaryOptions contract and the remaining fund if transferred back to the user.
if (revisedFee < queuedTrade.totalFee) {
tokenX.transfer(
queuedTrade.user,
queuedTrade.totalFee - revisedFee
);
}
Now, the funds is in the targetContract. The targetContract transfers settlement fee to the config contract when createFromRouter() is called.
tokenX.transfer(config.settlementFeeDisbursalContract(), settlementFee);
The rest of the fees remain inside the targetContract until the option expires. If the option expires ATM or OTM, the remaining funds stays in the targetContract instead of being transferred to the BufferBinaryPool contract.
function _unlock(uint256 id) internal returns (uint256 premium) {
LockedLiquidity storage ll = lockedLiquidity[msg.sender][id];
require(ll.locked, "Pool: lockedAmount is already unlocked");
ll.locked = false;
lockedPremium = lockedPremium - ll.premium;
lockedAmount = lockedAmount - ll.amount;
premium = ll.premium;
}
BufferBinaryPool does not get its funds when option expires OTM or ATM. This is particularly important if the Pool contract is lacking funds to pay the winners.
Manual Review
Make sure that the remaining funds from targetContract is transferred to BufferBinaryPool.