eUSD
Overview
The eUSD contract is an interest-bearing ERC20-like token designed for the Lybra protocol. It represents the holder's share in the total amount of Ether controlled by the protocol. The contract stores the sum of all shares to calculate each account's token balance, which is based on the account's shares and the total supply of eUSD.
Contract Details
Name: eUSD
Symbol: eUSD
Decimals: 18
Total Supply: The total supply of eUSD tokens is equal to the total amount of eUSD controlled by the protocol.
Balances: Balances are dynamic and are calculated based on the account's shares and the total supply of eUSD.
eUSD balances are dynamic and are calculated based on the accounts' shares and the total supply by the protocol. Account shares aren't normalized, so the contract also stores the sum of all shares to calculate each account's token balance, which equals to:
The _getTotalMintedEUSD()
function returns the total amount of eUSD tokens minted by the protocol. The _getTotalShares()
function returns the total amount of shares in existence.
For example, assume that we have:
_getTotalMintedEUSD()
-> 1000 eUSDsharesOf(user1)
-> 100sharesOf(user2)
-> 400
Therefore:
balanceOf(user1)
-> 2 tokens, which corresponds to 200 eUSDbalanceOf(user2)
-> 8 tokens, which corresponds to 800 eUSD
Function Documentation
name()
Returns the name of the token.
symbol()
Returns the symbol of the token.
decimals()
Returns the number of decimals for getting user representation of a token amount.
totalSupply()
Returns the total amount of eUSD in existence. This is always equal to the total minted eUSD since the token amount is pegged to the total amount of eUSD controlled by the protocol.
balanceOf(address _account)
Returns the amount of eUSD tokens owned by the _account
.
transfer(address _recipient, uint256 _amount)
Transfers _amount
eUSD tokens from the caller's account to the _recipient
account. Returns a boolean value indicating whether the transfer was successful.
allowance(address _owner, address _spender)
Returns the remaining number of tokens that _spender
is allowed to spend on behalf of _owner
through transferFrom
.
approve(address _spender, uint256 _amount)
Sets _amount
as the allowance of _spender
over the caller's tokens. Returns a boolean value indicating whether the approval was successful.
transferFrom(address _sender, address _recipient, uint256 _amount)
Moves _amount
eUSD tokens from _sender
to _recipient
using the allowance mechanism. Returns a boolean value indicating whether the transfer was successful.
increaseAllowance(address _spender, uint256 _addedValue)
Atomically increases the allowance granted to _spender
by the caller by _addedValue
. Returns a boolean value indicating whether the operation was successful.
decreaseAllowance(address _spender, uint256 _subtractedValue)
Atomically decreases the allowance granted to _spender
by the caller by _subtractedValue
. Returns a boolean value indicating whether the operation was successful.
getTotalShares()
Returns the total amount of shares in existence.
sharesOf(address _account)
Returns the amount of shares owned by the _account
.
getSharesByMintedEUSD(uint256 _EUSDAmount)
Returns the amount of shares that corresponds to the _EUSDAmount
of protocol-supplied eUSD.
getMintedEUSDByShares(uint256 _sharesAmount)
Returns the amount of eUSD that corresponds to the _sharesAmount
of token shares.
transferShares(address _recipient, uint256 _sharesAmount)
This function allows the caller to transfer a specified amount of token shares (_sharesAmount
) from their own account to the _recipient
account. It returns the amount of transferred tokens.
Requirements:
_recipient
cannot be the zero address.The caller must have at least
_sharesAmount
shares.
This function internally calls the _transferShares
function to perform the share transfer and emits the TransferShares
event to reflect the share transfer. Additionally, it calculates the corresponding token amount based on the transferred shares and emits a Transfer
event to reflect the token transfer.
mint(address _recipient, uint256 _mintAmount)
This function allows a designated mint pool to create and assign new shares to the specified _recipient
address. It increases the total amount of shares and the total supply of tokens.
Requirements:
_recipient
cannot be the zero address.The caller must be a designated mint pool.
Minting must not be paused for the calling pool.
This function internally calls the _totalShares
and _transferShares
functions to update the share balances and emits a Transfer
event to reflect the token transfer.
burn(address _account, uint256 _burnAmount)
This function allows a designated mint pool to destroy a specified amount of eUSD tokens (_burnAmount
) held by the _account
address. It decreases the total amount of shares and the total supply of tokens.
Requirements:
_account
cannot be the zero address.The caller must be a designated mint pool.
Burning must not be paused for the calling pool.
This function internally calls the _onlyBurnShares
function to update the share balances and emits a Transfer
event to reflect the token transfer.
burnShares(address _account, uint256 _sharesAmount)
This function allows a designated mint pool to destroy a specified amount of token shares (_sharesAmount
) held by the _account
address. It decreases the total amount of shares without affecting the total supply of tokens.
Requirements:
_account
cannot be the zero address.The caller must be a designated mint pool.
Burning must not be paused for the calling pool.
This function internally calls the _onlyBurnShares
function to update the share balances.
Last updated