Skip to content

Instantly share code, notes, and snippets.

@HCharlanes
Created September 12, 2016 02:20
Show Gist options
  • Save HCharlanes/54e775ffcffbc0fc618e652a7554b84d to your computer and use it in GitHub Desktop.
Save HCharlanes/54e775ffcffbc0fc618e652a7554b84d to your computer and use it in GitHub Desktop.
/// @title Stablecoin Token API. Extension of the Token standard (https://github.com/ethereum/EIPs/issues/20)
/// @author Hadrien Charlanes - <hadrien.charlanes@consensys.net>
contract StablecoinTokenAPI {
/// @dev Getters of the conversion rates between USDcents and Wei
function getUSDcentstoWEIPrice(uint amountInUSDCents) constant returns (uint purchasePricesInWei);
function getWEItoUSDCentsPrice(uint amountinWei) constant returns (uint purchasePriceinUSDCents);
///@dev Return if a convertion ETH -> USD will be successful
///@param amountInWei WEI amount willing to be converted
function convertibleInUSD (uint amountInWei) constant public returns (bool);
//Extra Stablecoin Token functions
/// @dev Purchase Stablecoins with ETH. This converts an ETH stable value into a USD stable value.
function convertToUSD() returns (uint amountInUSDCents);
/// @dev Withdraw stablecoins for ETH. This converts back an USD stable value into a ETH stable value.
/// @param amountInUSDCents amount of stablecoins withdrawn & deleted.
function convertToETH (uint amountInUSDCents) returns (uint amountinWei);
// Conversion events.
event Purchase(address indexed from, uint256 value);
event Withdraw(address indexed from, uint256 value);
//Events and public variables that keep track of your service status
//Public bool and event shot when the service has been stopped.
bool public serviceStopped;
uint public price100kETHUSDAtStop;
event Stopped();
//Public bool and event shot when the service has been stopped to prevent the system from collapsing.
bool public servicePrevStopped;
event PreventiveStop(uint stopTime);
//Public bool and event shot when the service has refunded.
bool public serviceRefunded;
event Refunded ();
//creator of the stablecoin service
address public creator;
//Standard Token functions.
function totalSupply() constant returns (uint256 supply);
//Note: balanceOf(address(this)) is the equivalent of this.balance.
function balanceOf(address owner) constant returns (uint256 balance);
function transfer(address to, uint256 value) returns (bool success);
function transferFrom(address from, address to, uint256 value) returns (bool success);
function approve(address spender, uint256 value) returns (bool success);
function allowance(address owner, address spender) constant returns (uint256 remaining);
//Standard Token Events
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment