An ERC-20 token which wraps ETH, potentially with a 1 day lockup period.
FETH is an ERC-20 token modeled after WETH9. It has the added ability to lockup tokens for 24-25 hours - during this time they may not be transferred or withdrawn, except by our market contract which requested the lockup in the first place.
Locked balances are rounded up to the next hour. They are grouped by the expiration time of the lockup into what we refer to as a lockup "bucket". At any time there may be up to 25 buckets but never more than that which prevents loops from exhausting gas limits.
function allowance(address account, address operator) external view returns (uint256 amount)
Returns the amount which a spender is still allowed to transact from the account
's balance.
Name | Type | Description |
---|---|---|
account | address | The owner of the funds. |
operator | address | The address with approval to spend from the account 's balance. |
Name | Type | Description |
---|---|---|
amount | uint256 | The number of tokens the operator is still allowed to transact with. |
function approve(address spender, uint256 amount) external nonpayable returns (bool success)
Approves a spender
as an operator with permissions to transfer from your account.
Name | Type | Description |
---|---|---|
spender | address | The address of the operator account that has approval to spend funds from the msg.sender 's account. |
amount | uint256 | The max number of FETH tokens from msg.sender 's account that this spender is allowed to transact with. |
Name | Type | Description |
---|---|---|
success | bool | Always true. |
function balanceOf(address account) external view returns (uint256 balance)
Returns the balance of an account which is available to transfer or withdraw.
This will automatically increase as soon as locked tokens reach their expiry date.
Name | Type | Description |
---|---|---|
account | address | The account to query the available balance of. |
Name | Type | Description |
---|---|---|
balance | uint256 | The available balance of the account. |
function decimals() external view returns (uint8)
The number of decimals the token uses.
This method can be used to improve usability when displaying token amounts, but all interactions with this contract use whole amounts not considering decimals.
Name | Type | Description |
---|---|---|
_0 | uint8 | 18 |
function deposit() external payable
Deposit ETH (via msg.value
) and receive the equivalent amount in FETH tokens. These tokens are not subject to any lockup period.
function depositFor(address account) external payable
Deposit ETH (via msg.value
) and credit the account
provided with the equivalent amount in FETH tokens. These tokens are not subject to any lockup period.
This may be used by the Foundation market to credit a user's account with FETH tokens.
Name | Type | Description |
---|---|---|
account | address | The account to credit with FETH tokens. |
function getFoundationMarket() external view returns (address market)
Gets the Foundation market address which has permissions to manage lockups.
Name | Type | Description |
---|---|---|
market | address | The Foundation market contract address. |
function getLockups(address account) external view returns (uint256[] expiries, uint256[] amounts)
Returns the balance and each outstanding (unexpired) lockup bucket for an account, grouped by expiry.
expires.length
== amounts.length
and amounts[i]
is the number of tokens which will expire at expires[i]
. The results returned are sorted by expiry, with the earliest expiry date first.
Name | Type | Description |
---|---|---|
account | address | The account to query the locked balance of. |
Name | Type | Description |
---|---|---|
expiries | uint256[] | The time at which each outstanding lockup bucket expires. |
amounts | uint256[] | The number of FETH tokens which will expire for each outstanding lockup bucket. |
function marketChangeLockup(address unlockFrom, uint256 unlockExpiration, uint256 unlockAmount, address lockupFor, uint256 lockupAmount) external payable returns (uint256 expiration)
Used by the market contract only: Remove an account's lockup and then create a new lockup, potentially for a different account.
Used by the market when an offer for an NFT is increased. This may be for a single account (increasing their offer) or two different accounts (outbidding someone elses offer).
Name | Type | Description |
---|---|---|
unlockFrom | address | The account whose lockup is to be removed. |
unlockExpiration | uint256 | The original lockup expiration for the tokens to be unlocked. This will revert if the lockup has already expired. |
unlockAmount | uint256 | The number of tokens to be unlocked from unlockFrom 's account. This will revert if the tokens were previously unlocked. |
lockupFor | address | The account to which the funds are to be deposited for (via the msg.value ) and tokens locked up. |
lockupAmount | uint256 | The number of tokens to be locked up for the lockupFor 's account. msg.value must be <= lockupAmount and any delta will be taken from the account's available FETH balance. |
Name | Type | Description |
---|---|---|
expiration | uint256 | The expiration timestamp for the FETH tokens that were locked. |
function marketLockupFor(address account, uint256 amount) external payable returns (uint256 expiration)
Used by the market contract only: Lockup an account's FETH tokens for 24-25 hours.
Used by the market when a new offer for an NFT is made.
Name | Type | Description |
---|---|---|
account | address | The account to which the funds are to be deposited for (via the msg.value ) and tokens locked up. |
amount | uint256 | The number of tokens to be locked up for the lockupFor 's account. msg.value must be <= amount and any delta will be taken from the account's available FETH balance. |
Name | Type | Description |
---|---|---|
expiration | uint256 | The expiration timestamp for the FETH tokens that were locked. |
function marketUnlockFor(address account, uint256 expiration, uint256 amount) external nonpayable
Used by the market contract only: Remove an account's lockup, making the FETH tokens available for transfer or withdrawal.
Used by the market when an offer is invalidated, which occurs when an auction for the same NFT receives its first bid or the buyer purchased the NFT another way, such as with buy
.
Name | Type | Description |
---|---|---|
account | address | The account whose lockup is to be unlocked. |
expiration | uint256 | The original lockup expiration for the tokens to be unlocked unlocked. This will revert if the lockup has already expired. |
amount | uint256 | The number of tokens to be unlocked from account . This will revert if the tokens were previously unlocked. |
function marketWithdrawFrom(address from, uint256 amount) external nonpayable
Used by the market contract only: Removes tokens from the user's available balance and returns ETH to the caller.
Used by the market when a user's available FETH balance is used to make a purchase including accepting a buy price or a private sale, or placing a bid in an auction.
Name | Type | Description |
---|---|---|
from | address | The account whose available balance is to be withdrawn from. |
amount | uint256 | The number of tokens to be deducted from unlockFrom 's available balance and transferred as ETH. This will revert if the tokens were previously unlocked. |
function marketWithdrawLocked(address account, uint256 expiration, uint256 amount) external nonpayable
Used by the market contract only: Removes a lockup from the user's account and then returns ETH to the caller.
Used by the market to extract unexpired funds as ETH to distribute for a sale when the user's offer is accepted.
Name | Type | Description |
---|---|---|
account | address | The account whose lockup is to be removed. |
expiration | uint256 | The original lockup expiration for the tokens to be unlocked. This will revert if the lockup has already expired. |
amount | uint256 | The number of tokens to be unlocked and withdrawn as ETH. |
function name() external view returns (string)
The name of the token.
Name | Type | Description |
---|---|---|
_0 | string | Foundation Wrapped Ether |
function symbol() external view returns (string)
The symbol of the token.
Name | Type | Description |
---|---|---|
_0 | string | FETH |
function totalBalanceOf(address account) external view returns (uint256 balance)
Returns the total balance of an account, including locked FETH tokens.
Use balanceOf
to get the number of tokens available for transfer or withdrawal.
Name | Type | Description |
---|---|---|
account | address | The account to query the total balance of. |
Name | Type | Description |
---|---|---|
balance | uint256 | The total FETH balance tracked for this account. |
function totalSupply() external view returns (uint256 supply)
Returns the total amount of ETH locked in this contract.
Name | Type | Description |
---|---|---|
supply | uint256 | The total amount of ETH locked in this contract. |
function transfer(address to, uint256 amount) external nonpayable returns (bool success)
Transfers an amount from your account.
Name | Type | Description |
---|---|---|
to | address | The address of the account which the tokens are transferred from. |
amount | uint256 | The number of FETH tokens to be transferred. |
Name | Type | Description |
---|---|---|
success | bool | Always true (reverts if insufficient funds). |
function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool success)
Transfers an amount from the account specified if the msg.sender
has approval.
Name | Type | Description |
---|---|---|
from | address | The address from which the available tokens are transferred from. |
to | address | The address to which the tokens are to be transferred. |
amount | uint256 | The number of FETH tokens to be transferred. |
Name | Type | Description |
---|---|---|
success | bool | Always true (reverts if insufficient funds or not approved). |
function withdrawAvailableBalance() external nonpayable
Withdraw all tokens available in your account and receive ETH.
function withdrawFrom(address from, address payable to, uint256 amount) external nonpayable
Withdraw the specified number of tokens from the from
accounts available balance and send ETH to the destination address, if the msg.sender
has approval.
Name | Type | Description |
---|---|---|
from | address | The address from which the available funds are to be withdrawn. |
to | address payable | The destination address for the ETH to be transferred to. |
amount | uint256 | The number of tokens to be withdrawn and transferred as ETH. |
event Approval(address indexed from, address indexed spender, uint256 amount)
Emitted when the allowance for a spender account is updated.
Name | Type | Description |
---|---|---|
from indexed |
address | The account the spender is authorized to transact for. |
spender indexed |
address | The account with permissions to manage FETH tokens for the from account. |
amount | uint256 | The max amount of tokens which can be spent by the spender account. |
event BalanceLocked(address indexed account, uint256 indexed expiration, uint256 amount, uint256 valueDeposited)
Emitted when FETH tokens are locked up by the Foundation market for 24-25 hours and may include newly deposited ETH which is added to the account's total FETH balance.
Name | Type | Description |
---|---|---|
account indexed |
address | The account which has access to the FETH after the expiration . |
expiration indexed |
uint256 | The time at which the from account will have access to the locked FETH. |
amount | uint256 | The number of FETH tokens which where locked up. |
valueDeposited | uint256 | The amount of ETH added to their account's total FETH balance, this may be lower than amount if available FETH was leveraged. |
event BalanceUnlocked(address indexed account, uint256 indexed expiration, uint256 amount)
Emitted when FETH tokens are unlocked by the Foundation market.
This event will not be emitted when lockups expire, it's only for tokens which are unlocked before their expiry.
Name | Type | Description |
---|---|---|
account indexed |
address | The account which had locked FETH freed before expiration. |
expiration indexed |
uint256 | The time this balance was originally scheduled to be unlocked. |
amount | uint256 | The number of FETH tokens which were unlocked. |
event ETHWithdrawn(address indexed from, address indexed to, uint256 amount)
Emitted when ETH is withdrawn from a user's account.
This may be triggered by the user, an approved operator, or the Foundation market.
Name | Type | Description |
---|---|---|
from indexed |
address | The account from which FETH was deducted in order to send the ETH. |
to indexed |
address | The address the ETH was sent to. |
amount | uint256 | The number of tokens which were deducted from the user's FETH balance and transferred as ETH. |
event Transfer(address indexed from, address indexed to, uint256 amount)
Emitted when a transfer of FETH tokens is made from one account to another.
Name | Type | Description |
---|---|---|
from indexed |
address | The account which is sending FETH tokens. |
to indexed |
address | The account which is receiving FETH tokens. |
amount | uint256 | The number of FETH tokens which were sent. |
error FETH_Cannot_Deposit_For_Lockup_With_Address_Zero()
error FETH_Escrow_Expired()
error FETH_Escrow_Not_Found()
error FETH_Expiration_Too_Far_In_Future()
error FETH_Insufficient_Allowance(uint256 amount)
Name | Type | Description |
---|---|---|
amount | uint256 | The current allowed amount the spender is authorized to transact for this account. |
error FETH_Insufficient_Available_Funds(uint256 amount)
Name | Type | Description |
---|---|---|
amount | uint256 | The current available (unlocked) token count of this account. |
error FETH_Insufficient_Escrow(uint256 amount)
Name | Type | Description |
---|---|---|
amount | uint256 | The current number of tokens this account has for the given lockup expiry bucket. |
error FETH_Invalid_Lockup_Duration()
error FETH_Market_Must_Be_A_Contract()
error FETH_Must_Deposit_Non_Zero_Amount()
error FETH_Must_Lockup_Non_Zero_Amount()
error FETH_No_Funds_To_Withdraw()
error FETH_Only_FND_Market_Allowed()
error FETH_Too_Much_ETH_Provided()
error FETH_Transfer_To_Burn_Not_Allowed()
error FETH_Transfer_To_FETH_Not_Allowed()