TokenizedDerivative

A synthetic token whose value tracks an arbitrary price feed.

Modifiers

onlyThis() modifier

constructor(struct TokenizedDerivativeParams.ConstructorParams params, string _name, string _symbol) public

createTokens(uint256 marginForPurchase, uint256 tokensToPurchase) external

Creates tokens with sent margin and sends the caller back any additional margin.

Parameters:

  • marginForPurchase: Maximum amount of margin currency to use to create tokens.

  • tokensToPurchase: Number of tokens to create.

depositAndCreateTokens(uint256 marginForPurchase, uint256 tokensToPurchase) external

Creates tokens with sent margin and deposits additional margin in short account.

Parameters:

  • marginForPurchase: Maximum amount of margin currency to use to create tokens.

  • tokensToPurchase: Number of tokens to create.

redeemTokens(uint256 tokensToRedeem) external

Redeems tokens for margin currency.

dispute(uint256 depositMargin) external

Triggers a price dispute for the most recent remargin time.

Parameters:

  • depositMargin: Must be at least disputeDeposit percent of the required margin.

withdraw(uint256 amount) external

Withdraws amount from short margin account.

remargin() external

Pays (Oracle and service) fees for the previous period, updates the contract NAV, moves margin between long and short accounts to reflect the new NAV, and checks if both accounts meet minimum requirements.

acceptPriceAndSettle() external

Forgo the Oracle verified price and settle the contract with last remargin price.

This method is only callable on contracts in the Defaulted state, and the default penalty is always transferred from the short to the long account.

setApDelegate(address apDelegate) external

Assigns an address to be the contract’s Delegate AP that can create and redeem.

Replaces previous value. Set to 0x0 to indicate there is no Delegate AP.

emergencyShutdown() external

Moves the contract into the Emergency state, where it waits on an Oracle price for the most recent remargin time.

settle() external

Performs a final remargin, assesses any penalties, and moves the contract into the Settled state. An Oracle price must be available.

deposit(uint256 amountToDeposit) external

Adds the margin to the short account.

For ETH-margined contracts, send ETH along with the call. In the case of an ERC20 margin currency, authorize before calling this method.

withdrawUnexpectedErc20(address erc20Address, uint256 amount) external

Withdraw any ERC20 balance that is not the margin token. Only callable by the sponsor.

burn(uint256 value) external

Destroys value tokens from the caller.

Only this contract or its libraries are allowed to burn tokens.

mint(address to, uint256 value) → bool external

Creates value tokens and assigns them to to, increasing the total supply.

Only this contract or its libraries are allowed to mint tokens.

calcNAV() → int256 navNew external

Returns the expected net asset value (NAV) of the contract using the latest available Price Feed price.

calcTokenValue() → int256 newTokenValue external

Returns the expected value of each the outstanding tokens of the contract using the latest available Price Feed price.

calcShortMarginBalance() → int256 newShortMarginBalance external

Returns the expected balance of the short margin account using the latest available Price Feed price.

calcExcessMargin() → int256 excessMargin external

Returns the expected short margin in excess of the margin requirement using the latest available Price Feed price.

Value will be negative if the short margin is expected to be below the margin requirement.

getCurrentRequiredMargin() → int256 requiredMargin external

Returns the required margin, as of the last remargin.

Note that calcExcessMargin uses updated values using the latest available Price Feed price.

canBeSettled() → bool canContractBeSettled external

Returns whether the contract can be settled, i.e., is it valid to call settle() now.

getUpdatedUnderlyingPrice() → int256 underlyingPrice, uint256 time external

Returns the updated underlying price that was used in the calc* methods above.

It will be a price feed price if the contract is Live and will remain Live, or an Oracle price if the contract is settled/about to be settled. Reverts if no Oracle price is available but an Oracle price is required.

totalSupply() → uint256 public

See {IERC20-totalSupply}.

balanceOf(address account) → uint256 public

See {IERC20-balanceOf}.

transfer(address recipient, uint256 amount) → bool public

See {IERC20-transfer}.

Requirements:

  • recipient cannot be the zero address.

  • the caller must have a balance of at least amount.

allowance(address owner, address spender) → uint256 public

See {IERC20-allowance}.

approve(address spender, uint256 amount) → bool public

See {IERC20-approve}.

Requirements:

  • spender cannot be the zero address.

transferFrom(address sender, address recipient, uint256 amount) → bool public

See {IERC20-transferFrom}.

Emits an {Approval} event indicating the updated allowance. This is not required by the EIP. See the note at the beginning of {ERC20};

Requirements: - sender and recipient cannot be the zero address. - sender must have a balance of at least amount. - the caller must have allowance for sender’s tokens of at least `amount.

increaseAllowance(address spender, uint256 addedValue) → bool public

Atomically increases the allowance granted to spender by the caller.

This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}.

Emits an {Approval} event indicating the updated allowance.

Requirements:

  • spender cannot be the zero address.

decreaseAllowance(address spender, uint256 subtractedValue) → bool public

Atomically decreases the allowance granted to spender by the caller.

This is an alternative to {approve} that can be used as a mitigation for problems described in {IERC20-approve}.

Emits an {Approval} event indicating the updated allowance.

Requirements:

  • spender cannot be the zero address.

  • spender must have allowance for the caller of at least subtractedValue.

_transfer(address sender, address recipient, uint256 amount) internal

Moves tokens amount from sender to recipient.

This is internal function is equivalent to {transfer}, and can be used to e.g. implement automatic token fees, slashing mechanisms, etc.

Emits a {Transfer} event.

Requirements:

  • sender cannot be the zero address.

  • recipient cannot be the zero address.

  • sender must have a balance of at least amount.

_mint(address account, uint256 amount) internal

Creates amount tokens and assigns them to account, increasing the total supply.

Emits a {Transfer} event with from set to the zero address.

Requirements

  • to cannot be the zero address.

_burn(address account, uint256 amount) internal

Destroys amount tokens from account, reducing the total supply.

Emits a {Transfer} event with to set to the zero address.

Requirements

  • account cannot be the zero address.

  • account must have at least amount tokens.

_approve(address owner, address spender, uint256 amount) internal

Sets amount as the allowance of spender over the `owner`s tokens.

This is internal function is equivalent to approve, and can be used to e.g. set automatic allowances for certain subsystems, etc.

Emits an {Approval} event.

Requirements:

  • owner cannot be the zero address.

  • spender cannot be the zero address.

_burnFrom(address account, uint256 amount) internal

Destroys amount tokens from account.amount is then deducted from the caller’s allowance.

See {_burn} and {_approve}.

_beforeTokenTransfer(address from, address to, uint256 amount) internal

Hook that is called before any transfer of tokens. This includes minting and burning.

Calling conditions:

  • when from and to are both non-zero, amount of from’s tokens will be to transferred to `to.

  • when from is zero, amount tokens will be minted for to.

  • when to is zero, amount of `from’s tokens will be burned.

  • from and to are never both zero.

To learn more about hooks, head to Using Hooks.

_msgSender() → address payable internal

_msgData() → bytes internal

NavUpdated(string symbol, int256 newNav, int256 newTokenPrice) event

Default(string symbol, uint256 defaultTime, int256 defaultNav) event

Settled(string symbol, uint256 settleTime, int256 finalNav) event

Expired(string symbol, uint256 expiryTime) event

Disputed(string symbol, uint256 timeDisputed, int256 navDisputed) event

EmergencyShutdownTransition(string symbol, uint256 shutdownTime) event

TokensCreated(string symbol, uint256 numTokensCreated) event

TokensRedeemed(string symbol, uint256 numTokensRedeemed) event

Deposited(string symbol, uint256 amount) event

Withdrawal(string symbol, uint256 amount) event

Transfer(address from, address to, uint256 value) event

Emitted when value tokens are moved from one account (from) to another (to).

Note that value may be zero.

Approval(address owner, address spender, uint256 value) event

Emitted when the allowance of a spender for an owner is set by a call to {approve}. value is the new allowance.

© UMA Project 2018-2019