Skip to content

gitofdeepanshu/RAI_UMA_Challenge

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

RAI_UMA_Challenge

Challenge

https://gitcoin.co/issue/reflexer-labs/geb/97/100024834

To build a synthetic asset tracking the Kovan RAI redemption rate movements using UMA.

Overview

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/

Solution

Pricing Model

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.

PriceFeed Implementation

Source of data :-

Code & Tests

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

Deployment and Testing

  1. RaiRedemptionPriceFeed code has been tested with unit tests in the fork repo.
  2. EMP UMA Contract (along with Synth Token) has been deployed to Kovan Testnet
  3. Default price-feed configuration for has been added for bots to work with minimal configuration - eacb633
  4. Uniswap Swap Pool (RAI-Synth) has been made to trade synths - here
  5. Deployed a Dapp to interact with EMP, manage position, deposit collateral, redeem synth and view positions or liquidations. (Fork from emp-tools) - Here

Setup & Configuration

Collateral Currency - RAI

Added buy UMA team to AddressWhitelist. through this transaction

Price Indentifier Name - RaiRedemptionRate

Added by UMA Team to IdentifierWhitelist through this transaction

Synth Token - RR-RAI-APR21

syntheticName: "RAI Redemption Rate [RR April 2021]", 
syntheticSymbol: 'RR-RAI-APR21', 

Token Deployed (by EMP) at https://kovan.etherscan.io/token/0xcac5b5ac9f4af1a4b73a12cd007a64ba4dfa07c2

EMP Parameteres

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

DApp

Deployed - https://emp-tools-2391flb9z-ashutoshvarma.vercel.app/

Source - https://github.com/ashutoshvarma/emp-tools

image

A Simple DApp to interact with EMP, manage position, deposit collateral, redeem synth and view positions or liquidations. (Fork from emp-tools)

Changes made to make it compatible with RAI EMP contract

  1. Disbale DevMining interfaces
  2. Replace Old EMP ABI methods with updated one.
  3. Add dummy price config for RR-RAI-APR21 synth.

Deployment Testing

Refrence

RAI

UMA

Setup and Minting a Synthetic token

Bots

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published