terra-revival / backtest

Python backtesting engine for USTC or any Terra Classic Stable Algos
Other
6 stars 2 forks source link

Divergence protocol initial implementation #4

Open faffyswap opened 1 year ago

faffyswap commented 1 year ago

Initial iteration for the divergence protocol

This will certainly lead to new issues and questions.

Scenario 1: Price is below Peg of $1USD (X>Y)

In this scenario the Seller creates a sell order of $1USTC for $0.95USD, the Buyer pays $0.95USD for the $1USTC, the Seller receives $0.90USD and the protocol receives $0.05USD in divergence fees.

X(Target Peg Price) – Y(Market Price) = T(Divergence Fee)

$1.00 - $0.95 = $0.05

Scenario 2: Price is above Peg of $1USD (X<Y)

(We will not see this activated in the protocol until we are actually at $1USD if at all, this will not feature in the initial stages of the incremental repeg plan)

In this scenario the Seller creates a sell order of $1USTC for $1.10USD, the Buyer pays $1.10USD for the $1UST, the Seller receives $1.00USD and the protocol receives $0.10USD in divergence fees.

Y(Market Price) – X(Target Peg Price) = T(Divergence Fee)

faffyswap commented 1 year ago

Blocked by #14