Lemma
Search…
USDLemma
Token contract for USDL, the Lemma stablecoin

Contract

This is the main ERC20 token contract for USDL, the Lemma stablecoin. USDL is issued by depositing assets such as WETH. The deposited WETH is then moved to a decentralized derivative exchange and used as collateral to short itself with no leverage. Minting and redeeming USDL will open and close a short position on a given integrated dex.

Public Functions

deposit

function deposit(
uint256 amount,
uint256 perpetualDEXIndex,
uint256 maxCollateralAmountRequired,
IERC20Upgradeable collateral)
Function purpose: msg.sender mints USDL by depositing WETH.
Argument
Description
Attribute
amount
Amount of USDL to be minted.
USD, 18 decimals
perpetualDEXIndex
Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).
Integer
maxCollateralAmountRequired
Max amount of WETH to be deposited to mint the USDL amount above.
ETH, 18 decimals
collateral
Token address for collateral to be used.
ERC20 address, initially will be just WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1​

depositTo

function depositTo(
address to,
uint256 amount,
uint256 perpetualDEXIndex,
uint256 maxCollateralAmountRequired,
IERC20Upgradeable collateral)
Function purpose: msg.sender mints USDL to a given address by depositing WETH.
Argument
Description
Attribute
to
Wallet address where USDL will be minted.
Address
amount
Amount of USDL to be minted.
USD, 18 decimals
perpetualDEXIndex
Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).
Integer
maxCollateralAmountRequired
Max amount of WETH to be deposited to mint the USDL amount above.
ETH, 18 decimals
collateral
Token address for type of asset to be deposited.
ERC20 address, initially will be just WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1​

withdraw

function withdraw(
uint256 amount,
uint256 perpetualDEXIndex,
uint256 minCollateralAmountToGetBack,
IERC20Upgradeable collateral)
Function purpose: msg.sender redeems USDL for 1 USD worth of WETH.
Argument
Description
Attribute
amount
Amount of USDL to be redeemed.
USD, 18 decimals
perpetualDEXIndex
Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).
Integer
minCollateralAmountRequired
Minimum amount of WETH to be received when redeeming the USDL amount above.
ETH, 18 decimals
collateral
Token address for type of asset to be received.
ERC20 address, initially will be just WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1​

withdrawTo

function withdrawTo(
address to,
uint256 amount,
uint256 perpetualDEXIndex,
uint256 minCollateralAmountToGetBack,
IERC20Upgradeable collateral)
Function purpose: msg.sender redeems USDL to a given address for 1 USD worth of WETH.
Argument
Description
Attribute
to
Wallet address where redeemed assets will be sent.
Address
amount
Amount of USDL to be redeemed.
USD, 18 decimals
perpetualDEXIndex
Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).
Integer
minCollateralAmountRequired
Minimum amount of WETH to be received when redeeming the USDL amount above.
ETH, 18 decimals
collateral
Token address for type of asset to be received.
ERC20 address, initially will be just WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1​

Restricted Functions

Restricted functions can only be called by owner of contract, which will be a multi sig.

setStakingContractAddress

function setStakingContractAddress(address _stakingContractAddress)
This function allows Lemma to update the staking contract for xUSDL.

setLemmaTreasury

function setLemmaTreasury(address _lemmaTreasury)
This function allows Lemma to update the address that collects fees.

setFees

function setFees(uint256 _fees)
This function allows Lemma to update the percentage (in bps) of fees allocated to the treasury.

addPerpetualDEXWrapper

function addPerpetualDEXWrapper(
uint256 perpetualDEXIndex,
address collateralAddress,
address perpetualDEXWrapperAddress)
This function allows Lemma to add a new derivative dex or accepted collateral for minting & redeeming USDL.

reBalance

function reBalance(
uint256 perpetualDEXIndex,
IERC20Upgradeable collateral,
int256 amount,
bytes calldata data)
This function allows Lemma to:
  • Mint new USDL and increase our short position when a positive funding payment gives us new ETH.
  • Burn USDL and decrease our short position when a negative funding payment takes away some of our ETH collateral.
  • Can only be called by Lemma whitelisted accounts.