Read Value of an IG Position
To check the state of your positions within a DVP, you can use PositionManager.positionDetail(tokenID) method for looking at the state of the position.
PositionManger is a ERC721Enumerable so you can easily retrieve your position.
// Instantiate the AddressProvider
AddressProvider addressProvider = AddressProvider(0x);
PositionManager posManager = PositionManager(addressProvider.positionManager());
// Get how many token you have.
uint256 balanceOfMyPosition = posManager.balanceOf(myAddress);
// Iterate through all your position and get the position details:
uint256 i = 0;
for (i = 0; i < balanceOfMyPosition; i++) {
uint256 tokenID = posManager.tokenOfOwnerByIndex(myAddress, i);
PositionDetail memory positionDetail = posManager.positionDetail(tokenID);
// The current value of the position (premium at which you can sell / payoff if rexpired). It returns also an estimation of the fee.
uint256 currentPayoff = dvp.payoff(positionDetail.expiry, positionDetail.strike, positionDetail.notionalUp, positionDetail.notionalDown)
}
/*
posManager.positionDetail(uint256) returns the following struct:
struct PositionDetail {
address dvpAddr; // DVP associated with the position
address baseToken; // BaseToken address
address sideToken; // SideToken address
uint256 dvpFreq; // DVP maturity frequency in seconds
bool dvpType; // At the moment only "Impermanent Gain" has been implemented, so it returns always IG
uint256 strike; // Strike of the position
uint256 expiry; // Time of expiry of the position
uint256 premium; // Premium paid including fees
uint256 leverage; // Leverage of the position
uint256 notionalUp; // Notional of the position, for Bull Impermanent Gain
uint256 notionalDown; // Notional of the position, for Bear Impermanent Gain
// Positions can have both notionalUp and notionalDown > 0 (Smile Impermanent Gain). Please note that only symmetrical positions are accepted
uint256 cumulatedPayoff; // Payoff already received due to previus reductions in the size of the position
}
*/
Last updated