The price struct stores asset prices in the BitShares system.
A price is defined as a ratio between two assets, and represents a possible exchange rate between those two assets. prices are generally not stored in any simplified form, i.e. a price of (1000 CORE)/(20 USD) is perfectly normal.
The assets within a price are labeled base and quote. Throughout the BitShares code base, the convention used is that the base asset is the asset being sold, and the quote asset is the asset being purchased, where the price is represented as base/quote, so in the example price above the seller is looking to sell CORE asset and get USD in return.
Definition at line 108 of file asset.hpp.
price graphene::protocol::price::call_price |
( |
const asset & |
debt, |
|
|
const asset & |
collateral, |
|
|
uint16_t |
collateral_ratio |
|
) |
| |
|
static |
The black swan price is defined as debt/collateral, we want to perform a margin call before debt == collateral. Given a debt/collateral ratio of 1 USD / CORE and a maintenance collateral requirement of 2x we can define the call price to be 2 USD / CORE.
This method divides the collateral by the maintenance collateral ratio to derive a call price for the given black swan ratio.
There exists some cases where the debt and collateral values are so small that dividing by the collateral ratio will result in a 0 price or really poor rounding errors. No matter what the collateral part of the price ratio can never go to 0 and the debt can never go more than GRAPHENE_MAX_SHARE_SUPPLY
CR * DEBT/COLLAT or DEBT/(COLLAT/CR)
Note: this function is only used before core-1270 hard fork.
Definition at line 216 of file asset.cpp.