Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
80 changes: 80 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"extends": ["airbnb"],
"parser": "babel-eslint",
"plugins": ["jest"],
"settings": {
"import/resolver": {
"webpack": {
"config": "webpack.dev.config.js"
}
},
"import/extensions": [".js", ".jsx"],
"import/ignore": ["\\.(s?css|less|styl|svg|json)$"]
},
"rules": {
"import/no-unresolved": [
2,
{
"commonjs": true,
"amd": true,
"caseSensitive": true
}
],
"import/named": 2,
"import/default": 2,
"import/namespace": 2,
"react/jsx-filename-extension": [
1,
{
"extensions": [".js", ".jsx"]
}
],
"react/forbid-prop-types": [
1,
{
"forbid": ["object", "any"]
}
],
"class-methods-use-this": 0,
"one-var": 0,
"one-var-declaration-per-line": 0,
"no-nested-ternary": 0,
"no-await-in-loop": 0,
"no-multi-assign": 0,
"object-curly-newline": 0,
"no-param-reassign": 0,
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true,
"optionalDependencies": false,
"peerDependencies": false
}
],
"semi": ["error", "never"],
"max-len": [
"error",
120,
2,
{
"ignoreUrls": true,
"ignoreComments": false,
"ignoreRegExpLiterals": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}
],
"no-restricted-syntax": ["error", "WithStatement"]
},
"env": {
"jest/globals": true,
"browser": true,
"mocha": true
},
"globals": {
"assert": true,
"contract": true,
"artifacts": true,
"web3": true
}
}
29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true
},
extends: "eslint:recommended",
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 2018
},
plugins: ["react"],
rules: {
indent: ["error", 2],
"linebreak-style": ["error", "unix"],
quotes: ["error", "double"],
semi: ["error", "never"],
"prefer-const": ["error"],
"no-var": ["error"]
},
globals: {
artifacts: false,
contract: false,
assert: false,
web3: false
}
};
15 changes: 15 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always"
}
}
]
}
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,18 @@ Each creator of new yTokens for a series has an associated "Repo" that records t
Any user may create yTokens of a particular series provided she deposits the appropriate amount of collateral.

1. Deposit ETH into the Treasurer
The user may deposit ETH by paying a desired amount of ETH when calling the `join()` function.
The user may deposit ETH by paying a desired amount of ETH when calling the `topUpCollateral()` function.
2. Make the desired yToken amount
The user may make the desired yToken by calling `make(uint series, uint made, uint paid)` and specifying the series (`series`) desired, the amount of yToken to make (`made`), and the amount of collateral to lock up (`paid`). The amount paid must be greater than the minimum collateral which equals the amount of yTokens made multiplied by the Collateralization Ratio.

The user may issueYToken the desired yToken by calling `issueYToken(uint series, uint made, uint paid)` and specifying the series (`series`) desired, the amount of yToken to issueYToken (`made`), and the amount of collateral to lock up (`paid`). The amount paid must be greater than the minimum collateral which equals the amount of yTokens made multiplied by the Collateralization Ratio.

### Redeeming a yToken

The holder of a Repo may wipe yToken debt in her repo by sending yToken back to the Treasurer. This is accomplished by calling `wipe(uint series, uint credit, uint released)` and specifying the series of the yToken, the amount of yToken debt to wipe (`credit`), and the amount of Ether collateral to be released (`released`). The caller must have sufficient yTokens to satisfy the credit or else the call will fail. Also, the call will fail if the user attempts to release more Ether collateral than the minimum collateral required for the remaining yToken debt.


### Settlement

After the maturity date for a series is reached, the yTokens for that series may be settled. Settlement is achieved by fixing a Dai price in Ether that will be used to determine how much Ether collateral each yToken holder is permitted to withdraw as payment for her matured yToken. To initiate settlement after the maturity date, any user may call `settlement(uint series)` and specify the series (`series`) to be settled. After the settlement function is called, users may retrieve their funds. A user who holds yTokens to maturity may call `withdraw(uint series, uint256 amount)` specifying the series of the yToken, and the amount of yToken to settle and retrieve the associated Ether. Likewise, a repo holder may close her repo and retrieve the associated Ether by calling `close(uint series)` specifying the series of the yToken.
After the maturity date for a series is reached, the yTokens for that series may be settled. Settlement is achieved by fixing a Dai price in Ether that will be used to determine how much Ether collateral each yToken holder is permitted to withdraw as payment for her matured yToken. To initiate settlement after the maturity date, any user may call `settlement(uint series)` and specify the series (`series`) to be settled. After the settlement function is called, users may retrieve their funds. A user who holds yTokens to maturity may call `withdraw(uint series, uint256 amount)` specifying the series of the yToken, and the amount of yToken to settle and retrieve the associated Ether. Likewise, a repo holder may close her repo and retrieve the associated Ether by calling `close(uint series)` specifying the series of the yToken.

### Liquidation

In order to maintain sufficient collateralization for a repo, when a repo becomes close to becoming undercollateralized, any holder of yTokens of the appropriate series may tender the yTokens and liquidate some or all of the nearly-undercollateralized repo. A repo becomes available for liquidation when the amount of collateral drops below a minimum collateralization ratio. A holder of yToken may liquidate some or all of a repo by calling `liquidate(uint series, address bum, uint256 amount)` specifying a series of the yTokens to be liquidated, the address of the holder of the repo to be liquidated (the `bum`), and the amount of yTokens to contribute to the liquidation.
In order to maintain sufficient collateralization for a repo, when a repo becomes close to becoming undercollateralized, any holder of yTokens of the appropriate series may tender the yTokens and liquidate some or all of the nearly-undercollateralized repo. A repo becomes available for liquidation when the amount of collateral drops below a minimum collateralization ratio. A holder of yToken may liquidate some or all of a repo by calling `liquidate(uint series, address bum, uint256 amount)` specifying a series of the yTokens to be liquidated, the address of the holder of the repo to be liquidated (the `bum`), and the amount of yTokens to contribute to the liquidation.
30 changes: 15 additions & 15 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
pragma solidity >=0.4.21 <0.6.0;

contract Migrations {
address public owner;
uint public last_completed_migration;
address public owner;
uint256 public last_completed_migration;

constructor() public {
owner = msg.sender;
}
constructor() public {
owner = msg.sender;
}

modifier restricted() {
if (msg.sender == owner) _;
}
modifier restricted() {
if (msg.sender == owner) _;
}

function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
function setCompleted(uint256 completed) public restricted {
last_completed_migration = completed;
}

function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
21 changes: 0 additions & 21 deletions contracts/Oracle.sol

This file was deleted.

Loading