Skip to content

Merge with kulapio/RTHB-ThaiBahtCoin #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4f1e1e5
move to smart contracts
totiz Nov 29, 2018
6eb9426
update gitignore
totiz Nov 29, 2018
682ac19
add iot code
totiz Nov 29, 2018
dd39379
move readme to root project
totiz Nov 29, 2018
db50064
move images to root project
totiz Nov 29, 2018
61d3503
update introduction o README
totiz Nov 29, 2018
7b09369
add how it works
totiz Nov 29, 2018
664c493
add scenario template
totiz Nov 29, 2018
a22ed2f
add to-do
totiz Nov 29, 2018
3aa20e8
fix typo
totiz Nov 29, 2018
3b386a4
update README.md
serial-coder Nov 29, 2018
cac16b7
update README.md
serial-coder Nov 29, 2018
4b80344
update README.md
serial-coder Nov 29, 2018
3871a5d
Correct publicTakeover calculationn
totiz Nov 29, 2018
71efb07
update README.md
serial-coder Nov 29, 2018
f7b5f67
update README.md
serial-coder Nov 30, 2018
c0c9678
fix some logical errors on claim() and publicTakeover()
serial-coder Nov 30, 2018
e45817c
add some comments
serial-coder Nov 30, 2018
fb8c34c
update README.md
serial-coder Nov 30, 2018
4bfeee4
update README.md
serial-coder Nov 30, 2018
8b8116c
update README.md
serial-coder Nov 30, 2018
1ca6c34
Add RTHB-Scenario-Price-Stable.png
totiz Dec 12, 2018
b5b19b5
Add files via upload
totiz Dec 12, 2018
6973ac2
Add files via upload
totiz Dec 12, 2018
e68f88c
Delete RTHB-Scenario-Price-Stable.png
totiz Dec 12, 2018
01f294d
Add files via upload
totiz Dec 12, 2018
dc798e1
reame file
totiz Dec 12, 2018
17e9569
update file
totiz Dec 12, 2018
5f43b04
finished description of scenanrio 1
totiz Dec 12, 2018
354bc4f
add drawio
totiz Dec 12, 2018
4193053
add more details
totiz Dec 12, 2018
cc500d0
add description of Scenario 2
totiz Dec 12, 2018
d578712
### Scenario 3 - RBTC price is decreasing
totiz Dec 12, 2018
24acfdd
add draw.ios
totiz Dec 12, 2018
dcf8382
add Features
totiz Dec 12, 2018
4711890
add front-end
Dec 12, 2018
4ca48ed
Merge pull request #2 from prin-r/master
totiz Dec 12, 2018
6e127e0
update README.md
serial-coder Dec 14, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store
build/
node_modules/
node_modules/
smart-contracts/build/
smart-contracts/node_modules/
55 changes: 53 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,55 @@
<p align="center"><a href="#" target="_blank" rel="noopener noreferrer"><img width="500" src="images/RTHB-icon.png"></a></p>

# BahtCoin
Thai Baht Stable Coin developed for running on RootStock (RSK) smart contract platform and also Ethereum platform
# Thai Baht Coin backed by BTC
This project is the proof of concept for securely issuing Thai Baht Stable Coin named RTHB, which is backed by Bitcoin (BTC).

## Introduction
In the fiat currency world, the unit of money is typically backed by gold. Meanwhile, Bitcoin is like a new gold standard in the cryptocurrency. That is why we decided to do this project in order to prove that we can issue a stable coin in the unit of Thai Baht (we call RTHB) which is backed by Bitcoin. This project is just a proof of concept. There are several issues we do not cover or prove in this demonstration such as regulation proofs or practical use scenario proofs.

## How it works?
In Bitcoin ecosystem, there is an interesting sidechain platform called [RSK project (rootstock)](https://www.rsk.co/). RSK platform enables us develop EVM(Ethereum Virtual Machine) based smart contract in order to interact with BTC (they call RBTC in RSK platform). With the smart contract feature enabled, we can put some special business logics against Bitcoin ecosystem easily.

Our RTHB is an ERC20-compatible token with extra following features.
1. Anyone can invoke the function **issue()** along with the collateral RBTC and then get RTHB back. By default, the amount of RTHB would be issued as the proportion 1:1.5 (~66.67%) of the collateralized RBTC (this proportion is adjustable).
2. RTHB holders can freely transfer any amount of RTHB to anyone.
3. An owner of RTHB contract, who did the transaction (1), can switch back his/her fund to RBTC by way of invoking the function **claim()** along with the same amount of RTHB as specified in the contract.
4. In case the RBTC price drops which makes RBTC price on a specific contract less than or equal to 130% of the collateralized RBTC, the contract is open for the public to take over. Thus, anyone can call to the function **publicTakeover()** together with the amount of RTHB calculated by the equation: RTHB >= targetContract.RBTC * currentRate, to take over the contract and take away the collateralized RBTC.

## Example scenarios of RTHB
### Scenario 1 - RBTC price is stable

<img width="500" src="images/RTHB-Scenario-Price-Stable3.png">

1) Alice sends 1 RBTC at a current rate 1,500 THB/BTC to RTHB Smart Contract (calling **issue()**).
2) Alice receives 1,000 RTHB back (at 1.5 RBTC:1 RTHB ratio).
3) Alice decides to return 1,000 RTHB to get her own RBTC back (calling **claim()**).
4) Fortunately the rate is still the same as when the RBTC was deposited, so the RTHB Smart Contract would return 1 RBTC back to Alice.

### Scenario 2 - RBTC price is increasing

<img width="500" src="images/RTHB-Scenario-Price-is-Increasing.png">

- This scenario is similar to the first scenario. Since RBTC price is increasing, Alice is able to return 1,000 RTHB to get her own RBTC back at the rate 2,500 THB/BTC.

### Scenario 3 - RBTC price is decreasing

<img width="500" src="images/RTHB-Scenario-Price-is-Decreasing.png">

1) Alice sends 1 RBTC at a current rate 1,500 THB/BTC to RTHB Smart Contract (calling **issue()**).
2) Alice receives 1,000 RTHB back (at 1.5 RBTC:1 RTHB ratio).

- A month later, RBTC price is dropping to 1,200 THB/BTC. Thus, RTHB Smart Contract forces sell of Alice contract in question (when the rate ratio is lower than 1.3 RBTC:1 RTHB).

3) Bob takes over Alice contract by providing 1,200 RTHB (with some discount*) (calling **publicTakeover()**).
4) Bob takes away 1 RBTC and Alice loses her contract. However, Alice still holds 1,000 RTHB.

discount*: the system can offer some discount for incentive purpose. For instance, when a rate is 1,200 THB/BTC, the system can offer a sale at 1,190 THB/BTC.

## Features
- Issuing new RTHB by providing RBTC (at 1.5 RBTC:1 RTHB ratio).
- Oracle price feeding.
- Force sell for unhealthy contracts (below 1.3 RBTC:1 RTHB ratio).
- List of all contracts.

## To-do
- Implement some missing ERC20 functions.
12 changes: 12 additions & 0 deletions front-end/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
["es2015", { "modules": false }],
"env",
"react"
],
"plugins":[
"transform-class-properties",
"transform-object-rest-spread",
"syntax-dynamic-import"
]
}
4 changes: 4 additions & 0 deletions front-end/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
.vscode/
dist/
.DS_Store
21 changes: 21 additions & 0 deletions front-end/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Jipyeongseon Geunyang Samgagbeob

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions front-end/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# stable-coin example on RSK chain front-end
59 changes: 59 additions & 0 deletions front-end/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "rskTHB",
"version": "2.1.0",
"main": "index.js",
"author": "Jipyeongseon",
"license": "MIT",
"scripts": {
"build-babel": "babel src/app.js --out-file=public/scripts/app.js --presets=env,react --watch",
"build:dev": "webpack --mode=development",
"build:prod": "webpack --mode=production -p --env production",
"dev-server": "webpack-dev-server --port 3000 --hot --host 0.0.0.0",
"test": "jest --config=jest.config.json",
"start": "node server/server.js"
},
"dependencies": {
"axios": "^0.18.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "7.1.2",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^1.0.1",
"express": "^4.16.4",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^2.0.0",
"js-sha3": "^0.8.0",
"numeral": "^2.0.6",
"raf": "^3.4.0",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-loadable": "^5.5.0",
"react-modal": "^3.6.1",
"react-redux": "^5.1.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-time": "^4.3.0",
"react-with-direction": "^1.3.0",
"recompose": "^0.30.0",
"redux": "^4.0.1",
"redux-logger": "^3.0.6",
"sass-loader": "^7.1.0",
"styled-components": "^4.0.3",
"validator": "^10.8.0",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2"
},
"devDependencies": {
"chalk": "^2.4.1",
"enzyme": "^3.7.0",
"enzyme-to-json": "^3.3.4",
"jest": "^23.6.0",
"react-test-renderer": "^16.6.0",
"webpack-dev-server": "^3.1.10"
}
}
Loading