Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Moved the price discovery docs and begin a rewrite
Browse files Browse the repository at this point in the history
Refs #254.
  • Loading branch information
mhluongo committed Sep 26, 2019
1 parent bc42eb1 commit 90dce02
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/bonding/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ between the signing bond collateral and BTC.

In concrete terms, that means the price of ETH to BTC. Due to only needing
prices for a single pair of assets, tBTC will initially use a simple
<<price-oracle/index.adoc#price-oracle,price oracle>>.
<<price-discovery/index.adoc#price-discovery,price oracle>>.

== Undercollateralization

Expand Down
2 changes: 1 addition & 1 deletion docs/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ include::deposits/index.adoc[leveloffset=+2]

include::bonding/index.adoc[leveloffset=+2]

include::price-oracle/index.adoc[leveloffset=+2]
include::price-discovery/index.adoc[leveloffset=+2]

include::minting/index.adoc[leveloffset=+2]

Expand Down
28 changes: 14 additions & 14 deletions docs/price-oracle/index.adoc → docs/price-discovery/index.adoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[env.theorem]
:toc: macro

[#price-oracle]
= Price Oracle
[#price-discovery]
= Price Discovery

ifndef::tbtc[toc::[]]

The price oracle is an integral part of the system, ensuring sufficient collateral backs all tBTC signers. We model the oracle after the https://developer.makerdao.com/feeds/[USD price feeds from MakerDAO], operated initially by a single trusted actor and later governed by the ecosystem.
The price oracle is an integral part of the system, ensuring sufficient collateral backs all tBTC signers. We model the oracle after the https://developer.makerdao.com/feeds/[USD price feeds from MakerDAO], operated initially by a single trusted actor and later governed by the ecosystem.

The minimal price feed design is specified completely by the interface below:

Expand All @@ -29,22 +29,22 @@ This mitigates unnecessary recomputations by maintainers for price changes below

== Price encoding

A bitcoin has 8 decimal places, the smallest unit being a satoshi, meaning 100 000 000 satoshis = 1 bitcoin.
An ether by contrast, has 18 decimal places, the smallest unit being a wei, meaning
1 000 000 000 000 000 000 wei = 1 ether.
A bitcoin has 8 decimal places, the smallest unit being a satoshi, meaning 100 000 000 satoshis = 1 bitcoin.
An ether by contrast, has 18 decimal places, the smallest unit being a wei, meaning
1 000 000 000 000 000 000 wei = 1 ether.

To express the price of bitcoin relative to ether, we must use a ratio of the number of wei to a satoshi.
A simple design is to use `x` wei : 1 satoshi. Hence, for a call to `getPrice` when 32.32 ETH : 1 BTC (Jun 2019),
the value 323 200 000 000 wei is returned.
To express the price of bitcoin relative to ether, we must use a ratio of the number of wei to a satoshi.
A simple design is to use `x` wei : 1 satoshi. Hence, for a call to `getPrice` when 32.32 ETH : 1 BTC (Jun 2019),
the value 323 200 000 000 wei is returned.

However, if 1 wei is worth more than 1 sat, then the price can no longer be accurately encoded. This scenario of a 'flippening',
when 1 ether becomes worth 10,000,000,000x as much as 1 bitcoin, we find unlikely in the very short-term.
Rather than prematurely optimize, incorporating a 2 integer ratio of `x` wei to `y` satoshi and changing the call semantics,
However, if 1 wei is worth more than 1 sat, then the price can no longer be accurately encoded. This scenario of a 'flippening',
when 1 ether becomes worth 10,000,000,000x as much as 1 bitcoin, we find unlikely in the very short-term.
Rather than prematurely optimize, incorporating a 2 integer ratio of `x` wei to `y` satoshi and changing the call semantics,
we leave this as a future exercise for governance.

== Future design

The price oracle is integral to tBTC's security and in the future, will be principally governed by
the tBTC ecosystem. The first upgrades will focus on incorporating a medianizer model from MakerDAO, where
the tBTC ecosystem. The first upgrades will focus on incorporating a medianizer model from MakerDAO, where
multiple price feeds are voted in and the median price is calculated from their reports. Other on-chain price signals like
decentralized exchanges (DEX's) and liquidity pools (Uniswap) are being considered.
decentralized exchanges (DEX's) and liquidity pools (Uniswap) are being considered.
56 changes: 56 additions & 0 deletions docs/price-discovery/on-price-feeds.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
= On price feeds

Price feeds are a difficult subject in decentralized systems.

Price isn't a global phenomenon -- it's local to a transaction's participants,
and stems from their subjective beliefs about the value of an asset and the
current and future conditions of a market.

At first glance, atop the fractured and subjective nature of price, we layer an
additional conundrum -- the long-discussed "oracle problem". How can a group of
pseudonymous actors be convinced to report the trust in a decentralized system,
when they have a strong incentive to lie?

Addressing these issues in the general case is far outside the scope of this
document. Instead, we can discuss a few common approaches and how they perform
in the context of a system like tBTC.

There are three common approaches to bringing price data onto a blockchain like
Ethereum

1. Trusted oracles. If an entity or fixed group of entities can be trusted,
publishing trusted price data is simple.
2. Schelling point games. These schemes make use of a large number of
participants with difficulty coordinating. Each participant submits their
version of the "truth", and those that differ significantly from the
plurality are punished, while those that reported with the herd are rewarded.
Truthcoin, Augur, Witnet, and UMA have all done interesting work in this
space; the Witnet team has written
https://medium.com/witnet/on-oracles-and-schelling-points-2a1807c29b73[an accessible primer].
3. Market-based schemes. One of the surest ways to make price data accessible
to a chain is to bring trade execution onto that chain, using schemes like
batched auctions.
In a system built to maintain a censorship-resistant supply peg, a trusted
oracle requirement is deeply dissatisfying. A system is only as decentralized as
it's most easily captured component; and a trusted price feed, even one that
mixes data from many

Schelling point games are an attractive alternative to trusted feeds. A
Schelling point price feed enables permissionless participation, can better
resist outside capture and censorship,

The downside of a Schelling game approach is what Paul Sztorc calls "parasitic
contracts". Expressive host chains enable "games outside the game" -- incentives
that can warp honest reporting in Schelling games. Growing the size and money at
risk of a reporter set can combat this issue; but when the security of an entire
peg is at stake, imagining a large enough financial interest in honest price
discovery is difficult.

The last approach, utilizing on-chain markets, can enable direct price data on
a smart contract chain. The devil, however, is in the details -- how does a
scheme prevent miner tampering? How about fake volume and wash trades meant to
manipulate a price? Market-based schemes need to be built to a particular use
case, and are only as resilient as the participation in the market.

0 comments on commit 90dce02

Please sign in to comment.