https://gitcoin.co/issue/reflexer-labs/geb/97/100024834
To build a synthetic asset tracking the Kovan RAI redemption rate movements using UMA.
UMA is a fast, flexible and secure way to create synthetic assets on Ethereum. UMA has defined a novel architecture that enables anyone to create a synth asset that can track virtually anything from stock markets in Iran to gas fees on Ethereum safely and securely.
In this challenge I created a synth asset RR-RAI-APR21
tracking RAI redemption rate.
Also a DApp(fork of UMAProtocol/emp-tools) to interact with my EMP and manage/create their positions. https://emp-tools-2391flb9z-ashutoshvarma.vercel.app/
Redemption_Rate
is the rate at which RAI is being devalued or revalued, it can therefore be negative as well. It is stored as redemptionRate
in OracleRelayer
relayer contract. Mathematically,
redemptionRate = Redemption_Rate + 1
Therefore redemptionRate
is bound in (0,2) which makes it a sensible candiadate to track our synthetic asset. But redemptionRate
changes very slowly and is almost constant upto few decimals. For example, these are some consecutive value for redemptionRate
:-
0.99999999984948877039244582
0.999999999848547411861463422, // Starting 10 decimals are almost consatnt
0.999999999848547690004497233.
To mitigate this for somme extent we can use annualizedRate
which is scaled version of redemptionRate.
annualizedRate = (redemptionRate) ^ (365 * 12 * 30 * 24 * 3600)
Lastly, to prevent market manuplation due to flash loans and other factors which can make Redemption_Rate
volatile for very short period (which can casue sudden liquidations) we will take Time Weighted Average Price (TWAP) of annualizedRate
.
Source of data :-
- https://subgraph-kovan.reflexer.finance/subgraphs/name/reflexer-labs/rai/
UpdateRedemptionRate
Event fromRateSetter
contract
The full implementation of price feed with unit tests is contained in UMA protocol repo's fork. https://github.com/ashutoshvarma/protocol
RaiRedemptionPriceFeed - here
Unit tests - here
UMA's Networker
class does not support sending POST requests which was nesseary in order to query subgraphs. To add support for POST requests I made few small changes to it. Here is the PR UMAprotocol/protocol#2691
RaiRedemptionPriceFeed
code has been tested with unit tests in the fork repo.- EMP UMA Contract (along with Synth Token) has been deployed to Kovan Testnet
- Default price-feed configuration for has been added for bots to work with minimal configuration - eacb633
- Uniswap Swap Pool (RAI-Synth) has been made to trade synths - here
- Deployed a Dapp to interact with EMP, manage position, deposit collateral, redeem synth and view positions or liquidations. (Fork from emp-tools) - Here
Added buy UMA team to AddressWhitelist
. through this transaction
Added by UMA Team to IdentifierWhitelist
through this transaction
syntheticName: "RAI Redemption Rate [RR April 2021]",
syntheticSymbol: 'RR-RAI-APR21',
Token Deployed (by EMP) at https://kovan.etherscan.io/token/0xcac5b5ac9f4af1a4b73a12cd007a64ba4dfa07c2
Expiry date: 30/04/2021, 16:30:00 UTC
Price identifier: RaiRedemptionRate
Collateral requirement: 1.25
Unique sponsors: 1
Minimum sponsor tokens: 100.0 RR-RAI-APR21
EMP Contract Deployed to Kovan using launch-emp scipts provided by UMA at https://kovan.etherscan.io/address/0x08eA186755Ad743897c00AAfaEF7Fb9A7EcE8cf3
Deployed - https://emp-tools-2391flb9z-ashutoshvarma.vercel.app/
Source - https://github.com/ashutoshvarma/emp-tools
A Simple DApp to interact with EMP, manage position, deposit collateral, redeem synth and view positions or liquidations. (Fork from emp-tools)
- Disbale DevMining interfaces
- Replace Old EMP ABI methods with updated one.
- Add dummy price config for
RR-RAI-APR21
synth.
- Setup https://docs.umaproject.org/developers/setup
- Local install https://docs.umaproject.org/build-walkthrough/mint-locally
- EMP on net https://docs.umaproject.org/developers/emp-deployment
- Kovan addresses https://github.com/UMAprotocol/protocol/blob/master/packages/core/networks/42.json
- Bot parametrization https://docs.umaproject.org/developers/bot-param