MCDEXLemma
Smart contract wrapper for the MCDEX derivatives exchange
This contract interacts with the MCDEX derivatives exchange to open and close the short position. It implements the IPerpetualDexWrapper interface, which is a more general wrapper for all derivative dexes Lemma is integrated with.
Public Functions
getCollateralAmountGivenUnderlyingAssetAmount
Function purpose: given an amount of USDL to be minted or redeemed, returns how much WETH is required or that will be received.
amount
USDL amount to be minted or redeemed.
USD, 18 decimals
isShorting
True, if minting USDL. False, if redeeming USDL.
Boolean
collateralAmountRequired
Amount of WETH required to mint given USDL amount or WETH to be received when redeeming given amount of USDL.
WETH, 18 decimals
getFundingPNL
Function purpose: get total funding PnL for MCDEXLemma address from inception till now.
fundingPNL
Total funding PnL for MCDEXLemma address from inception till now.
WETH, 18 decimals
getAmountInCollateralDecimals
Function purpose: given an asset type (eg. WETH, WBTC...) and an 18 decimal amount, return the amount in the appropriate decimal amount for the asset type. Currently, this function is not useful since the only available collateral asset is WETH which is 18 decimals.
amount
Amount of asset type.
WETH, 18 decimals
roundUp
True, if you would like to round up upon conversion. False, if not.
Boolean
settle
Function purpose: if MCDEX ever executes a "forced settlement" of perpetuals, this function can be called by anyone to send all of the WETH used as collateral on the dex back to the MCDEXLemma contract.
sendMCBToTreasury
Function purpose: Sends all collected MCB tokens to the Lemma treasury.
USDLemma Restricted Functions
The restricted functions below can only be called by the USDLemma contract.
open
This function allows the USDLemma contract to deposit WETH collateral and open a corresponding short position on MCDEX.
close
This function allows the USDLemma contract to close a short position and withdraw the corresponding WETH collateral on MCDEX.
reBalance
This function allows the USDLemma contract to execute the rebalancing mechanism.
Owner Restricted Functions
The restricted functions below can only be called by owner of the contract, which will be a multi sig.
setUSDLemma
This function allows Lemma to set the USDLemma (core contract) address.
setReferrer
This function allows Lemma to set the referrer address. Referrers on MCDEX receive rebates and MCB tokens. It will be set to the Lemma treasury address.
setReBalancer
This function allows Lemma to whitelist an address to give them the permission to execute the rebalancing mechanism.
setMaxPosition
This function allows Lemma to set the max amount of USDL that can be minted on this derivative dex (ie. setting a debt ceiling).
depositKeeperGasReward
This function allows Lemma to transfer WETH from its treasury to MCDEX in order to reward keepers for certain actions (required by MCDEX).
Last updated