SyntheticId examples
function getExecutionPayout(Derivative memory _derivative, uint256 _result)
public
view
returns (uint256 buyerPayout, uint256 sellerPayout)
{
uint256 ppt;
uint256 strikePrice = _derivative.params[0];
if (_derivative.params.length == 2) {
ppt = _derivative.params[1];
} else {
ppt = BASE_PPT;
}
if (_result > strikePrice) {
uint256 profit = _result.sub(strikePrice);
profit = profit.mul(ppt).div(BASE_PPT);
if (profit < _derivative.margin) {
buyerPayout = profit;
sellerPayout = _derivative.margin.sub(profit);
} else {
buyerPayout = _derivative.margin;
sellerPayout = 0;
}
} else {
buyerPayout = 0;
sellerPayout = _derivative.margin;
}
}Last updated