CoveredCallLongShortPairFinancialProductLibrary
CoveredCallLongShortPairFinancialProductLibrary
#
Adds settlement logic to create covered call LSPs. The contract will payout a scaled amount of collateral depending on where the settlement price lands relative to the call's strike price. If the settlement is below the strike price then longs expire worthless. If the settlement is above the strike then the payout is the fraction above the strike defined by (expiryPrice - strikePrice) / expiryPrice. For example, consider a covered call option collateralized in ETH, with a strike a price of 3000.
- If the price is less than 3000 then the each long is worth 0 and each short is worth collateralPerPair.
- If the price is more than 3000 then each long is worth the fraction of collateralPerPair that was in the money and each short is worth the remaining collateralPerPair.
- Say settlement price is 3500. Then expiryPercentLong = (3500 - 3000) / 3500 = 0.143. The value of this 0.143 ETH is worth 0.143*3500=500 which is the percentage of the collateralPerPair that was above the strike price.
#
FunctionssetLongShortPairParameters(address longShortPair, uint256 strikePrice) (public)
Enables any address to set the strike price for an associated LSP.
Note: a) Any address can set the initial strike price b) A strike price cannot be 0. c) A strike price can only be set once to prevent the deployer from changing the strike after the fact. d) For safety, a strike price should be set before depositing any synthetic tokens in a liquidity pool. e) longShortPair must expose an expirationTimestamp method to validate it is correctly deployed.
#
Parameters:- longShortPair: address of the LSP.
- strikePrice: the strike price for the covered call for the associated LSP.
percentageLongCollateralAtExpiry(int256 expiryPrice) → uint256 (public)
Returns a number between 0 and 1e18 to indicate how much collateral each long and short token are entitled to per collateralPerPair.
#
Parameters:- expiryPrice: price from the optimistic oracle for the LSP price identifier.
_preEntranceCheck() (internal)
_preEntranceSet() (internal)
_postEntranceReset() (internal)
_startReentrantGuardDisabled() (internal)
_endReentrantGuardDisabled() (internal)
#
ModifiersnonReentrant()
Prevents a contract from calling itself, directly or indirectly.
Calling a nonReentrant
function from another nonReentrant
function is not supported. It is possible to
prevent this from happening by making the nonReentrant
function external, and making it call a private
function that does the actual state modification.
nonReentrantView()
Designed to prevent a view-only method from being re-entered during a call to a nonReentrant()
state-changing method.