-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Bonded Fungible Tokens
---
eip: <to be assigned>
title: Bonded Fungible Tokens
author: lsaether <logan@convergent.cx>
discussions-to: <URL>
status: Draft
type: Standards Track
category: Interface
created: 2018-12-23
---
Simple Summary
A bonded fungible token is an ERC20 standard compliant token with a price and supply controlled by an automated market maker known as a bonding curve.
The bonding curve is a smart contract which holds a reserve
asset and increases or decreases the supply of a token, always determining the price based on the total supply and the amount held of the reserve asset.
From a user perspective, it is a method of buying or selling a token directly from a smart contract and which the price of purchase or reward for sells follows a pre-defined and determined price path.
Abstract
Although the concepts of an automated market maker and bonding curve to control the price and supply of tokens is not new, it has been used most notably in the Bancor protocol, it has yet to be given a standard interface that developers can follow in implementations.
Motivation
Bonding curves are a promising mechanism for the tokenized future. By standardizing the interface, we can begin to allow community tools such as Etherscan and other block explorers to integrate information about these tokens automatically. Since the token is traded through the contract, we should be able to pull details such as the market cap of the token or the current price to display on UIs. A standard interface will further allow developers to build bonding curve tokens into more complex systems such as nested curves.
Specification
pragma solidity ^0.4.24;
/**
* @title Bonded Fungible Token Interface
* @dev A bonded fungible token is a token "bonded" to a reserve asset and
* continuously generated or destroyed by staking or withdrawing this
* asset.
*/
interface IBondedFungibleToken {
// Logs when `purchaser` buys `amount` of tokens for `paid` in reserve asset.
event CurveBuy(uint256 amount, uint256 paid, address indexed purchaser);
// Logs when `seller` sells `amount` of tokens for `rewarded` in reserve asset.
event CurveSell(uint256 amount, uint256 rewarded, address indexed seller);
// Returns the price for buying `forTokens` amount of bonded tokens.
function price(uint256 forTokens) public view returns (uint256 thePrice);
// Returns the reward for selling `forTokens` amount of bonded tokens.
function reward(uint256 forTokens) public view returns (uint256 theReward);
// Buys `tokens` amount of bonded tokens and returns how much `paid` in reserve.
function buy(uint256 tokens) external returns (uint256 paid);
// Sells `tokens` amount of bonded tokens and returns how much `rewarded` in reserve.
function sell(uint256 tokens) external returns (uint256 rewarded);
// Returns the current price of the token. Mostly useful for reference.
function currentPrice() public view returns (uint256 theCurrentPrice);
// Returns the address of the asset smart contract or 0x0 for ether.
function reserveAsset() public view returns (address asset);
// Returns the amount of `reserveAsset` held in reserve in contract.
function reserve() public view returns (uint256 amount);
}
Rationale
Imagine using Dai as the reserve asset for an example bonded fungible token, EXP. Community tools such as block explorers could include the current price of EXP straight in their interface by keeping up to date with the return value of the currentPrice
function.
Besides front-end conveniences, there are also low-level interoperability constraints that we should keep in mind as more developers start to build systems which use bonded tokens and bonding curves.
Test Cases
Example source code and some test cases have been implemented in milky-way
Implementation
milky-way
Please suggest others.
Copyright
Copyright and related rights waived via CC0.