Skip to content

Commit

Permalink
Merge pull request #534 from CosmosContracts/faddat/markdownlint
Browse files Browse the repository at this point in the history
chore: markdownlint . --fix
  • Loading branch information
faddat authored Jan 26, 2023
2 parents 63d2130 + 90e95c7 commit 72f1c8a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion contrib/devtools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Thanks to the entire Cosmos SDK team and the contributors who put their efforts into making simulation testing
easier to implement. 🤗

https://github.com/cosmos/cosmos-sdk/blob/master/contrib/devtools/Makefile
<https://github.com/cosmos/cosmos-sdk/blob/master/contrib/devtools/Makefile>
4 changes: 2 additions & 2 deletions price-feeder/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Oracle Price Feeder

This is Juno's version of [Umee's price feeder](https://github.com/umee-network/umee/tree/main/price-feeder), intended to work with SDK 0.45.11.

The `price-feeder` tool is an extension of Juno's `x/oracle` module, both of
Expand Down Expand Up @@ -51,7 +51,7 @@ More information on the keyring can be found [here](#keyring)
Please see the [example configuration](price-feeder.example.toml) for more details.

```shell
$ price-feeder /path/to/price_feeder_config.toml
price-feeder /path/to/price_feeder_config.toml
```

## Configuration
Expand Down
47 changes: 28 additions & 19 deletions price-feeder/price-feeder.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
# Price feeder documentation

## Description
A side-car process that Juno validators must run in order to provide Juno's on-chain price oracle with price information.

A side-car process that Juno validators must run in order to provide Juno's on-chain price oracle with price information.

The ```price-feeder``` tool are based on Terra's [x/oracle](https://github.com/terra-money/classic-core/tree/main/x/oracle) module and [oracle-feeder](https://github.com/terra-money/oracle-feeder).

## Overview:
## Overview

Juno ```price-feeder``` includes 2 components:

- PriceFeeder: responsible for obtaining price information from various reliable data sources, e.g. exchanges, and exposing this data via an API.
- PriceOracle: consumes this data and periodically submits vote and prevote messages following the oracle voting procedure.

When ``PriceOracle`` start, it loops a process called ``Tick`` with 1000 milisecond interval.
When ``PriceOracle`` start, it loops a process called ``Tick`` with 1000 milisecond interval.

## ```Tick``` process in detail

## ```Tick``` process in detail:
1. GetParamCache: Get the latest parameters in x/oracle
2. SetPrices: Retrieve all the prices and candles from our set of providers as determined in the config. Calculate TVWAP or VWAP prices, warns missing prices, and filters out any faulty providers.
2. SetPrices: Retrieve all the prices and candles from our set of providers as determined in the config. Calculate TVWAP or VWAP prices, warns missing prices, and filters out any faulty providers.
3. Vote/Prevote exchangeRate.

## ```SetPrices``` in detail:
## ```SetPrices``` in detail

1. Get all price providers
2. Collect prices from providers and set prices to local var.
3. Compute the prices and save it to ``oracle.prices``.
- Convert any non-USD denominated candles into USD
- Filter out any erroneous candles

- ComputeTvwapsByProvider and ComputeTVWAP.
- Check if tvwapPrices available, else use recent prices & VWAP instead.
- ConvertTickersToUSD and FilterTickerDeviations.
- ComputeVWAP.
- ComputeTvwapsByProvider and ComputeTVWAP.
- Check if tvwapPrices available, else use recent prices & VWAP instead.
- ConvertTickersToUSD and FilterTickerDeviations.
- ComputeVWAP.

### TVWAP calculate process

### TVWAP calculate process:
TVWAP is time volume weighted average price.
TVWAP is time volume weighted average price.

**Input**: Map(provider => Map(base => CandlePrice))

**Output**: Map(base => price)

**Process**:
**Process**:

For each candle within 5 timePeriod (5 mins), we calculate:

Expand All @@ -56,34 +61,38 @@ where:
Then use VWAP formula for `volumeSum` and `weightedPrices`

**VWAP formula**:
VWAP is volume weighted average price.
VWAP is volume weighted average price.

vwap[base] = weightedPrices[base] / volumeSum[base]

### Explain TVWAP

TWAP is the average price of a financial asset over a certain period of time. The time period is chosen by the trader based on the market analysis and trading strategy adopted. TWAPs are normally used to execute large-volume trades in smaller chunks without disturbing the market. Large-scale institutional traders track TWAP values and trade by dividing their orders into smaller parts to try and keep their orders as close to TWAP values as possible.

TWAP benefits:
TWAP benefits:

- Lower likelihood of causing asset price volatility when placing large orders
- Ability to hide your market strategy from other large-volume traders
- Good strategy for those who prefer trading by placing frequent daily orders
- Applicability to algorithmic trading strategies

TWAP limitations:
TWAP limitations:

- The TWAP formula concentrates on asset prices only and fails to take into account trading volumes.
- Limited applicability to the needs of smaller-scale traders

VWAP is a mechanism used to calculate the price of an asset by taking price data from multiple trading environments and weighting each price by the amount of volume on each liquid market an asset is trading on. The VWAP calculation methodology is also used more broadly across finance as a technical indicator for traders, an order option offered by brokers or exchanges, and a benchmark.
VWAP is a mechanism used to calculate the price of an asset by taking price data from multiple trading environments and weighting each price by the amount of volume on each liquid market an asset is trading on. The VWAP calculation methodology is also used more broadly across finance as a technical indicator for traders, an order option offered by brokers or exchanges, and a benchmark.

VWAP benefits:

- Market Coverage.
- Highly Accurate and Fresh Data
- Manipulation-Resistant

VWAP limitations:
VWAP limitations:

- inaccurate or misleading for large orders that require many days to fill.
- can be used to manipulate trading by placing trades only when market prices are at levels favorable with VWAP
- not account for opportunity cost.

TVWAP formula is a new mechanism used to weight volume based on timestamp within the 5 min period. It's a variant of VWAP formula. The main difference between TVWAP and VWAP is that TVWAP shrinks the volume based on candle's timestamp, the further the timestamp count, the more volume will be shrink. VWAP is a measurement that shows the average price of an asset in a period of time, while TVWAP is a measurement that shows the average price of an asset in a period of time with a favor based on timestamp of data.
TVWAP formula is a new mechanism used to weight volume based on timestamp within the 5 min period. It's a variant of VWAP formula. The main difference between TVWAP and VWAP is that TVWAP shrinks the volume based on candle's timestamp, the further the timestamp count, the more volume will be shrink. VWAP is a measurement that shows the average price of an asset in a period of time, while TVWAP is a measurement that shows the average price of an asset in a period of time with a favor based on timestamp of data.
9 changes: 5 additions & 4 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# End-to-end Tests

## Structure

### `e2e` Package
Expand All @@ -16,7 +17,7 @@ an upgrade height, ensures the upgrade happens at the desired height, and
then checks that operations that worked before still work as intended. If
testing a fork, the test suite instead starts the chain a few blocks before
the set fork height and ensures the chain continues after the fork triggers
the upgrade. Note that a regular upgrade and a fork upgrade are mutually exclusive.
the upgrade. Note that a regular upgrade and a fork upgrade are mutually exclusive.

The file e2e\_setup\_test.go defines the testing suite and contains the
core bootstrapping logic that creates a testing environment via Docker
Expand Down Expand Up @@ -72,9 +73,9 @@ Conceptually, we can split the e2e setup into 2 parts:
details of the configurer. More on this can be found
[here](https://www.tutorialspoint.com/design_pattern/factory_pattern.htm)

The rules for deciding on the configurer type
The rules for deciding on the configurer type
are as follows:

- If only `isIBCEnabled`, we want to have 2 chains initialized at the
current branch version of Juno codebase

Expand Down Expand Up @@ -208,4 +209,4 @@ This debug configuration helps to run e2e tests locally and skip the desired tes
Please note that if the tests are stopped mid-way, the e2e framework might fail to start again due to duplicated containers. Make sure that
containers are removed before running the tests again: `docker container rm -f $(docker container ls -a -q)`.
Additionally, Docker networks do not get auto-removed. Therefore, you can manually remove them by running `docker network prune`.
Additionally, Docker networks do not get auto-removed. Therefore, you can manually remove them by running `docker network prune`.
2 changes: 1 addition & 1 deletion tests/e2e/initialization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ make docker-build-e2e-init-node
```

This script will build a Docker image that runs a script in the `node` package
and initializes all data necessary for starting up a new node.
and initializes all data necessary for starting up a new node.

0 comments on commit 72f1c8a

Please sign in to comment.