2.2 Closing Trade & Trade PnL
IVX Diem Contract
function closeTrade(uint256 _optionId, uint256 _amountContracts)
external function calculatePnl(Trade memory _trade, uint256 closedUnits, bool _isLiquidation)
public
view
returns (int256 PNL, uint premiumValue)IVX Portfolio =>
struct Trade {
bool closed;
uint256 timestamp; //last block.timestamp of a position trade
uint256 optionID;
uint256 contractsOpen; //number of contracts open
uint256 averageEntry; //average premium price paid on all contracts
uint256 totalUnits; //total number of contracts entered in the trade, only incremented never reduced
uint256 totalFee;
uint256 borrowedAmount; //amount of collateral borrowed, used to calculate borrowing fees only
}Last updated