How to Execute a Trade

Impermanent Gain positions can be minted or burnt through DVPs. For details on DVPs, please refers to the specific section:

For security reason, it is not possible to interact directly with DVPs, but instead users have to go through the Position Manager.

To retrive position manager address you can use the functionsetDvpPositionManager

Mint Impermanent Gain

To buy (mint) an Impermanent Gain position, you have to pass the compiled struct to the PositionManager.mint(struct params) function:

struct MintParams {
	uint256 tokenId; // 0 to open a new position, ID of the position to increase an existing position
	address dvpAddr; // Address of the DVP
	uint256 notionalUp; // Notional of the position, for Bull Impermanent Gain
	uint256 notionalDown; // Notional of the position, for Bear Impermanent Gain 
	/* NOTE: it is possible to mint positions with both notionalUp and notionalDown > 0, however only symmetrical positions are accepted (called in the frontend and the docs "Impermanent Gain Smile"). 
	It is not possible to mint asymmetrical Impermanent Gain positions */
	uint256 strike; // Current strike of the DVP. It can be retrieved by calling dvp.currentStrike();
	address recipient; // Trader address
	uint256 expectedPremium; // Expected premium to be paid to mint the position. It can be calculated calling dvp.premium(currentStrike, notionalUp, notionalDown); which also returns an estimation of the fees to mint
	uint256 maxSlippage; // Maximum slippage of the premium accepted (1e18 = 100%, 0.1e18 = 10%, …)
	uint256 nftAccessTokenId; // 0 if disabled, ID of the NFT that allows recipient to trade if enabled
}

notionalUp, notionalDown, strike and expectedPremium have the same decimals as the base token. For instance, if the base token is USDC, all the above-mentioned quantities have 6 decimals. Therefore to buy $ 10 000 of notional of Bull Impermament Gain, one has to input notionalUp = 10 000 * 10^6. Similarly, the expectedPremium for such amount of notional would be calculated as dvp.premium(strike, 10 000 * 10^6, 0).

Burn Impermanent Gain

To sell or close (burn) post expiry an Impermanent Gain position, you have to pass the compiled struct to the PositionManager.burn(struct params) function:

struct SellParams {
        uint256 tokenId; // ID of the position to be sold
        uint256 notionalUp; // Notional of the position, for Bull Impermanent Gain  
        uint256 notionalDown; // Notional of the position, for Bear Impermanent Gain
        /* NOTE: it is possible to burn all or a just a part of a position. For Smile Impermanent Gain (aka positions with both notionalUp and notionalDown) it is possible to burn only symmetrical amount of notionalUp and notionalDown */
        uint256 expectedMarketValue; // Epxected payoff received when burning the position. It can be calculated by calling dvp.payoff(expiryEpochOfThePosition, currentStrikeOfThePosition, notionalUp, notionalDown); which also returns an estimation of the fees to burn 
        uint256 maxSlippage; // Maximum slippage of the payoff accepted (1e18 = 100%, 0.1e18 = 10% …)
    }

Last updated