From 36ef530737fff4992f318ae67a107437d72a7963 Mon Sep 17 00:00:00 2001 From: Micah Zoltu Date: Sun, 17 Dec 2017 14:02:58 -0800 Subject: [PATCH] Renames SAI to DAI and SKR to PETH. --- DEVELOPING.md | 154 +-- README.md | 192 ++-- bin/dai | 3 + bin/deploy | 60 +- bin/deploy-pre | 34 +- bin/sai | 3 - libexec/{sai/sai => dai/dai} | 38 +- libexec/{sai/sai---help => dai/dai---help} | 2 +- libexec/dai/dai-air | 5 + libexec/dai/dai-axe | 5 + libexec/dai/dai-bite | 9 + libexec/dai/dai-boom | 9 + libexec/dai/dai-bust | 9 + libexec/{sai/sai-cage => dai/dai-cage} | 14 +- libexec/dai/dai-caged | 4 + libexec/dai/dai-cap | 5 + libexec/dai/dai-cash | 7 + libexec/dai/dai-chi | 5 + libexec/dai/dai-cup | 10 + libexec/{sai/sai-cupi => dai/dai-cupi} | 4 +- libexec/{sai/sai-cups => dai/dai-cups} | 4 +- libexec/dai/dai-dai | 5 + libexec/dai/dai-din | 5 + libexec/dai/dai-draw | 10 + libexec/dai/dai-drip | 4 + libexec/dai/dai-exit | 9 + libexec/dai/dai-fee | 5 + libexec/dai/dai-fit | 5 + libexec/dai/dai-fix | 5 + libexec/dai/dai-fog | 5 + libexec/dai/dai-free | 10 + libexec/{sai/sai-gem => dai/dai-gem} | 4 +- libexec/dai/dai-give | 8 + libexec/{sai/sai-gov => dai/dai-gov} | 4 +- libexec/dai/dai-heal | 4 + libexec/{sai/sai-help => dai/dai-help} | 10 +- libexec/dai/dai-ink | 7 + libexec/dai/dai-join | 9 + libexec/dai/dai-joy | 5 + libexec/dai/dai-lad | 7 + libexec/dai/dai-lock | 10 + libexec/dai/dai-mat | 5 + libexec/dai/dai-off | 4 + libexec/{sai/sai-open => dai/dai-open} | 6 +- libexec/dai/dai-out | 4 + libexec/{sai/sai-par => dai/dai-par} | 6 +- libexec/{sai/sai-pep => dai/dai-pep} | 4 +- libexec/dai/dai-per | 5 + libexec/dai/dai-peth | 5 + libexec/dai/dai-pie | 5 + libexec/{sai/sai-pip => dai/dai-pip} | 4 +- libexec/{sai/sai-pit => dai/dai-pit} | 4 +- libexec/{sai/sai-prod => dai/dai-prod} | 4 +- libexec/dai/dai-rap | 7 + libexec/{sai/sai-ray => dai/dai-ray} | 6 +- libexec/dai/dai-rhi | 5 + libexec/dai/dai-rho | 6 + libexec/dai/dai-s2s | 5 + libexec/dai/dai-safe | 7 + libexec/dai/dai-setAxe | 9 + libexec/dai/dai-setCap | 9 + libexec/dai/dai-setFee | 9 + libexec/dai/dai-setMat | 9 + libexec/dai/dai-setTapGap | 9 + libexec/dai/dai-setTax | 9 + libexec/dai/dai-setTubGap | 9 + libexec/dai/dai-setWay | 9 + libexec/dai/dai-shut | 7 + libexec/{sai/sai-sin => dai/dai-sin} | 4 +- libexec/dai/dai-tab | 7 + libexec/dai/dai-tag | 5 + libexec/dai/dai-tapAsk | 6 + libexec/dai/dai-tapBid | 6 + libexec/dai/dai-tapGap | 5 + libexec/{sai/sai-tau => dai/dai-tau} | 4 +- libexec/dai/dai-tax | 5 + libexec/dai/dai-tubAsk | 6 + libexec/dai/dai-tubBid | 6 + libexec/dai/dai-tubGap | 5 + libexec/dai/dai-vent | 4 + libexec/dai/dai-vox | 5 + libexec/{sai/sai-wad => dai/dai-wad} | 6 +- libexec/{sai/sai-way => dai/dai-way} | 6 +- libexec/dai/dai-wipe | 10 + libexec/dai/dai-woe | 5 + .../node_modules/bignumber.js/LICENCE | 0 .../node_modules/bignumber.js/README.md | 0 .../node_modules/bignumber.js/bignumber.js | 0 .../bignumber.js/bignumber.js.map | 0 .../bignumber.js/bignumber.min.js | 0 .../node_modules/bignumber.js/bower.json | 0 .../node_modules/bignumber.js/doc/API.html | 0 .../node_modules/bignumber.js/package.json | 0 libexec/sai/sai-air | 5 - libexec/sai/sai-axe | 5 - libexec/sai/sai-bite | 9 - libexec/sai/sai-boom | 9 - libexec/sai/sai-bust | 9 - libexec/sai/sai-caged | 4 - libexec/sai/sai-cap | 5 - libexec/sai/sai-cash | 7 - libexec/sai/sai-chi | 5 - libexec/sai/sai-cup | 10 - libexec/sai/sai-din | 5 - libexec/sai/sai-draw | 10 - libexec/sai/sai-drip | 4 - libexec/sai/sai-exit | 9 - libexec/sai/sai-fee | 5 - libexec/sai/sai-fit | 5 - libexec/sai/sai-fix | 5 - libexec/sai/sai-fog | 5 - libexec/sai/sai-free | 10 - libexec/sai/sai-give | 8 - libexec/sai/sai-heal | 4 - libexec/sai/sai-ink | 7 - libexec/sai/sai-join | 9 - libexec/sai/sai-joy | 5 - libexec/sai/sai-lad | 7 - libexec/sai/sai-lock | 10 - libexec/sai/sai-mat | 5 - libexec/sai/sai-off | 4 - libexec/sai/sai-out | 4 - libexec/sai/sai-per | 5 - libexec/sai/sai-pie | 5 - libexec/sai/sai-rap | 7 - libexec/sai/sai-rhi | 5 - libexec/sai/sai-rho | 6 - libexec/sai/sai-s2s | 5 - libexec/sai/sai-safe | 7 - libexec/sai/sai-sai | 5 - libexec/sai/sai-setAxe | 9 - libexec/sai/sai-setCap | 9 - libexec/sai/sai-setFee | 9 - libexec/sai/sai-setMat | 9 - libexec/sai/sai-setTapGap | 9 - libexec/sai/sai-setTax | 9 - libexec/sai/sai-setTubGap | 9 - libexec/sai/sai-setWay | 9 - libexec/sai/sai-shut | 7 - libexec/sai/sai-skr | 5 - libexec/sai/sai-tab | 7 - libexec/sai/sai-tag | 5 - libexec/sai/sai-tapAsk | 6 - libexec/sai/sai-tapBid | 6 - libexec/sai/sai-tapGap | 5 - libexec/sai/sai-tax | 5 - libexec/sai/sai-tubAsk | 6 - libexec/sai/sai-tubBid | 6 - libexec/sai/sai-tubGap | 5 - libexec/sai/sai-vent | 4 - libexec/sai/sai-vox | 5 - libexec/sai/sai-wipe | 10 - libexec/sai/sai-woe | 5 - src/{sai.t.sol => dai.t.sol} | 986 +++++++++--------- src/fab.sol | 68 +- src/mom.sol | 12 +- src/tap.sol | 50 +- src/top.sol | 40 +- src/tub.sol | 64 +- src/tub.t.sol | 48 +- src/vox.sol | 4 +- src/vox.t.sol | 4 +- 162 files changed, 1318 insertions(+), 1324 deletions(-) create mode 100644 bin/dai delete mode 100755 bin/sai rename libexec/{sai/sai => dai/dai} (68%) mode change 100755 => 100644 rename libexec/{sai/sai---help => dai/dai---help} (75%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-air create mode 100644 libexec/dai/dai-axe create mode 100644 libexec/dai/dai-bite create mode 100644 libexec/dai/dai-boom create mode 100644 libexec/dai/dai-bust rename libexec/{sai/sai-cage => dai/dai-cage} (50%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-caged create mode 100644 libexec/dai/dai-cap create mode 100644 libexec/dai/dai-cash create mode 100644 libexec/dai/dai-chi create mode 100644 libexec/dai/dai-cup rename libexec/{sai/sai-cupi => dai/dai-cupi} (52%) mode change 100755 => 100644 rename libexec/{sai/sai-cups => dai/dai-cups} (84%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-dai create mode 100644 libexec/dai/dai-din create mode 100644 libexec/dai/dai-draw create mode 100644 libexec/dai/dai-drip create mode 100644 libexec/dai/dai-exit create mode 100644 libexec/dai/dai-fee create mode 100644 libexec/dai/dai-fit create mode 100644 libexec/dai/dai-fix create mode 100644 libexec/dai/dai-fog create mode 100644 libexec/dai/dai-free rename libexec/{sai/sai-gem => dai/dai-gem} (50%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-give rename libexec/{sai/sai-gov => dai/dai-gov} (52%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-heal rename libexec/{sai/sai-help => dai/dai-help} (82%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-ink create mode 100644 libexec/dai/dai-join create mode 100644 libexec/dai/dai-joy create mode 100644 libexec/dai/dai-lad create mode 100644 libexec/dai/dai-lock create mode 100644 libexec/dai/dai-mat create mode 100644 libexec/dai/dai-off rename libexec/{sai/sai-open => dai/dai-open} (82%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-out rename libexec/{sai/sai-par => dai/dai-par} (52%) mode change 100755 => 100644 rename libexec/{sai/sai-pep => dai/dai-pep} (50%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-per create mode 100644 libexec/dai/dai-peth create mode 100644 libexec/dai/dai-pie rename libexec/{sai/sai-pip => dai/dai-pip} (50%) mode change 100755 => 100644 rename libexec/{sai/sai-pit => dai/dai-pit} (50%) mode change 100755 => 100644 rename libexec/{sai/sai-prod => dai/dai-prod} (57%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-rap rename libexec/{sai/sai-ray => dai/dai-ray} (81%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-rhi create mode 100644 libexec/dai/dai-rho create mode 100644 libexec/dai/dai-s2s create mode 100644 libexec/dai/dai-safe create mode 100644 libexec/dai/dai-setAxe create mode 100644 libexec/dai/dai-setCap create mode 100644 libexec/dai/dai-setFee create mode 100644 libexec/dai/dai-setMat create mode 100644 libexec/dai/dai-setTapGap create mode 100644 libexec/dai/dai-setTax create mode 100644 libexec/dai/dai-setTubGap create mode 100644 libexec/dai/dai-setWay create mode 100644 libexec/dai/dai-shut rename libexec/{sai/sai-sin => dai/dai-sin} (52%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-tab create mode 100644 libexec/dai/dai-tag create mode 100644 libexec/dai/dai-tapAsk create mode 100644 libexec/dai/dai-tapBid create mode 100644 libexec/dai/dai-tapGap rename libexec/{sai/sai-tau => dai/dai-tau} (69%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-tax create mode 100644 libexec/dai/dai-tubAsk create mode 100644 libexec/dai/dai-tubBid create mode 100644 libexec/dai/dai-tubGap create mode 100644 libexec/dai/dai-vent create mode 100644 libexec/dai/dai-vox rename libexec/{sai/sai-wad => dai/dai-wad} (81%) mode change 100755 => 100644 rename libexec/{sai/sai-way => dai/dai-way} (54%) mode change 100755 => 100644 create mode 100644 libexec/dai/dai-wipe create mode 100644 libexec/dai/dai-woe rename libexec/{sai => dai}/node_modules/bignumber.js/LICENCE (100%) rename libexec/{sai => dai}/node_modules/bignumber.js/README.md (100%) rename libexec/{sai => dai}/node_modules/bignumber.js/bignumber.js (100%) rename libexec/{sai => dai}/node_modules/bignumber.js/bignumber.js.map (100%) rename libexec/{sai => dai}/node_modules/bignumber.js/bignumber.min.js (100%) rename libexec/{sai => dai}/node_modules/bignumber.js/bower.json (100%) rename libexec/{sai => dai}/node_modules/bignumber.js/doc/API.html (100%) rename libexec/{sai => dai}/node_modules/bignumber.js/package.json (100%) delete mode 100755 libexec/sai/sai-air delete mode 100755 libexec/sai/sai-axe delete mode 100755 libexec/sai/sai-bite delete mode 100755 libexec/sai/sai-boom delete mode 100755 libexec/sai/sai-bust delete mode 100755 libexec/sai/sai-caged delete mode 100755 libexec/sai/sai-cap delete mode 100755 libexec/sai/sai-cash delete mode 100755 libexec/sai/sai-chi delete mode 100755 libexec/sai/sai-cup delete mode 100755 libexec/sai/sai-din delete mode 100755 libexec/sai/sai-draw delete mode 100755 libexec/sai/sai-drip delete mode 100755 libexec/sai/sai-exit delete mode 100755 libexec/sai/sai-fee delete mode 100755 libexec/sai/sai-fit delete mode 100755 libexec/sai/sai-fix delete mode 100755 libexec/sai/sai-fog delete mode 100755 libexec/sai/sai-free delete mode 100755 libexec/sai/sai-give delete mode 100755 libexec/sai/sai-heal delete mode 100755 libexec/sai/sai-ink delete mode 100755 libexec/sai/sai-join delete mode 100755 libexec/sai/sai-joy delete mode 100755 libexec/sai/sai-lad delete mode 100755 libexec/sai/sai-lock delete mode 100755 libexec/sai/sai-mat delete mode 100755 libexec/sai/sai-off delete mode 100755 libexec/sai/sai-out delete mode 100755 libexec/sai/sai-per delete mode 100755 libexec/sai/sai-pie delete mode 100755 libexec/sai/sai-rap delete mode 100755 libexec/sai/sai-rhi delete mode 100755 libexec/sai/sai-rho delete mode 100755 libexec/sai/sai-s2s delete mode 100755 libexec/sai/sai-safe delete mode 100755 libexec/sai/sai-sai delete mode 100755 libexec/sai/sai-setAxe delete mode 100755 libexec/sai/sai-setCap delete mode 100755 libexec/sai/sai-setFee delete mode 100755 libexec/sai/sai-setMat delete mode 100755 libexec/sai/sai-setTapGap delete mode 100755 libexec/sai/sai-setTax delete mode 100755 libexec/sai/sai-setTubGap delete mode 100755 libexec/sai/sai-setWay delete mode 100755 libexec/sai/sai-shut delete mode 100755 libexec/sai/sai-skr delete mode 100755 libexec/sai/sai-tab delete mode 100755 libexec/sai/sai-tag delete mode 100755 libexec/sai/sai-tapAsk delete mode 100755 libexec/sai/sai-tapBid delete mode 100755 libexec/sai/sai-tapGap delete mode 100755 libexec/sai/sai-tax delete mode 100755 libexec/sai/sai-tubAsk delete mode 100755 libexec/sai/sai-tubBid delete mode 100755 libexec/sai/sai-tubGap delete mode 100755 libexec/sai/sai-vent delete mode 100755 libexec/sai/sai-vox delete mode 100755 libexec/sai/sai-wipe delete mode 100755 libexec/sai/sai-woe rename src/{sai.t.sol => dai.t.sol} (70%) diff --git a/DEVELOPING.md b/DEVELOPING.md index e58b850..1f12066 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -1,13 +1,13 @@ -# Sai Developer Documentation +# Dai Developer Documentation -This is a developer level guide to the Sai source layout and how the +This is a developer level guide to the Dai source layout and how the different objects relate to each other. ## Introduction -Sai is Simple-Dai, a simplification of the Dai Stablecoin System -intended for field testing and refining Dai components. Sai has several +Dai is Simple-Dai, a simplification of the Dai Stablecoin System +intended for field testing and refining Dai components. Dai has several features that distinguish it from Dai: - trusted price feed @@ -15,7 +15,7 @@ features that distinguish it from Dai: - global settlement - liquidations at fixed price (rather than auctions) -This document is an introduction to Sai, aimed at those seeking an +This document is an introduction to Dai, aimed at those seeking an understanding of the Solidity implementation. We assume knowledge of the [white paper], a high level overview of Dai. A reading of the [purple paper], the (in progress) detailed Dai technical specification @@ -27,23 +27,23 @@ and reference implementation, is strongly encouraged but not required. ## Overview -Sai uses the following tokens: +Dai uses the following tokens: - `gem`: underlying collateral (wrapped ether, in practice) -- `skr`: abstracted collateral claim -- `sai`: stablecoin +- `peth`: abstracted collateral claim +- `dai`: stablecoin - `sin`: anticoin, created when the system takes on debt -Sai has the following core components: +Dai has the following core components: - `vox`: target price feed - `tub`: CDP record store - `tap`: liquidation mechanism - `top`: global settlement facilitator -Sai is configured by the following 'risk parameters': +Dai is configured by the following 'risk parameters': -- `way`: Sai reference price drift +- `way`: Dai reference price drift - `cap`: Debt ceiling - `mat`: Liquidation ratio - `tax`: Stability fee @@ -52,42 +52,42 @@ Sai is configured by the following 'risk parameters': -### `skr`: A Token Wrapper +### `peth`: A Token Wrapper -`skr` is a token wrapper. +`peth` is a token wrapper. -- `join`: deposit `gem` in return for `skr` -- `exit`: claim `gem` with their `skr`. +- `join`: deposit `gem` in return for `peth` +- `exit`: claim `gem` with their `peth`. ![Join-Exit](https://user-images.githubusercontent.com/5028/30517891-928dd4d8-9bc1-11e7-9398-639233d851ae.png) -`skr` is a simple proportional claim on a collateral pool, with the -initial `gem`<->`skr` exchange ratio being 1:1. The essential reason +`peth` is a simple proportional claim on a collateral pool, with the +initial `gem`<->`peth` exchange ratio being 1:1. The essential reason for this abstraction will be developed later, but for now it is -sufficient to see `skr` as a token with intrinsic value. +sufficient to see `peth` as a token with intrinsic value. -The `gem`/`skr` exchange rate is called `per`, and is calculated as the -total number of deposited `gem` divided by the total supply of SKR. +The `gem`/`peth` exchange rate is called `per`, and is calculated as the +total number of deposited `gem` divided by the total supply of PETH. The reference price of `gem` (in practice, ETHUSD) is provided by the `pip`, an external oracle. The `pip` is completely trusted. -The reference price of `skr` is then given by the dynamic `tag`, e.g. -the price of SKR in USD. +The reference price of `peth` is then given by the dynamic `tag`, e.g. +the price of PETH in USD. ### `vox`: Target Price Feed -The `vox` provides the Sai *target price*, given in terms of the +The `vox` provides the Dai *target price*, given in terms of the reference unit, by `par`. For example, `par == 2` with USD as the -reference unit implies a target price of 2 USD per Sai. +reference unit implies a target price of 2 USD per Dai. The target price can vary in time, at a rate given by `way`, which is the multiplicative rate of change per second. The `vox` is the same as that in Dai, but with the sensitivity, `how`, set to zero. Adjustments to the target price are made by adjusting the -rate of change, `way`, directly with `coax`. In future Sai iterations, +rate of change, `way`, directly with `coax`. In future Dai iterations, `how` may be non-zero and `way` adjustments will then follow automatically via the feedback mechanism. The `vox` component is subject to ongoing economic modelling research. @@ -99,7 +99,7 @@ The `tub` is the CDP record system. An individual CDP is called a `cup` (i.e. a small container), and has: - `lad`: an owner -- `ink`: locked SKR collateral +- `ink`: locked PETH collateral - `art`: debt It is crucial to know whether a CDP is well collateralised or not: @@ -122,15 +122,15 @@ to unsafe: ![Lock-Free](https://user-images.githubusercontent.com/5028/30517892-928e06ec-9bc1-11e7-91e8-6ae6caae8585.png) -- `lock`: deposit SKR collateral (increases `ink`) -- `free`: withdraw SKR collateral (decreases `ink`) +- `lock`: deposit PETH collateral (increases `ink`) +- `free`: withdraw PETH collateral (decreases `ink`) --- ![Draw | Wipe](https://user-images.githubusercontent.com/5028/30463893-97a6aef4-9a22-11e7-9a65-3055ad05b8d6.png) -- `draw`: create Sai (increases `art`, `rum`) -- `wipe`: return Sai (decreases `art`, `rum`) +- `draw`: create Dai (increases `art`, `rum`) +- `wipe`: return Dai (decreases `art`, `rum`) --- @@ -162,86 +162,86 @@ liquidator. The `tap` is a liquidator. It has three token balances that determine its allowed behaviour: -- `joy`: Sai balance, surplus transferred from `drip` +- `joy`: Dai balance, surplus transferred from `drip` - `woe`: Sin balance, bad debt transferred from `bite` -- `fog`: SKR balance, collateral pending liquidation +- `fog`: PETH balance, collateral pending liquidation -and one derived price, `s2s`, which is the price of SKR in Sai. The -`tap` seeks to minimise all of its token balances. Recall that Sai can +and one derived price, `s2s`, which is the price of PETH in Dai. The +`tap` seeks to minimise all of its token balances. Recall that Dai can be canceled out with Sin via `heal`. The `tap` has two acts: -- `boom`: sell Sai in return for SKR (decreases `joy` and `woe`, decreases SKR supply) -- `bust`: sell SKR in return for Sai (decreases `fog`, increases `joy` and `woe`, can increase SKR supply) +- `boom`: sell Dai in return for PETH (decreases `joy` and `woe`, decreases PETH supply) +- `bust`: sell PETH in return for Dai (decreases `fog`, increases `joy` and `woe`, can increase PETH supply) `boom` is the simpler function and can be thought of as buy and burn. -Given a net Sai balance, sell the Sai in return for SKR, which is +Given a net Dai balance, sell the Dai in return for PETH, which is burned. `bust` is really two functions in one: collateral sell off (aka `flip`), and inflate and sell (aka `flop`). When `fog` is non zero it is sold in -return for Sai, which is used to cancel out the bad debt, `woe`. If -`fog` is zero but the `tap` has a net Sin balance, then SKR is minted -and sold in return for Sai, up to the point that the net Sin balance is +return for Dai, which is used to cancel out the bad debt, `woe`. If +`fog` is zero but the `tap` has a net Sin balance, then PETH is minted +and sold in return for Dai, up to the point that the net Sin balance is zero. ![Bust](https://user-images.githubusercontent.com/5028/30517888-9287dd76-9bc1-11e7-8726-6b21843e27a5.png) Through `boom` and `bust` we close the feedback loop on the price of -SKR. When there is surplus Sai, SKR is burned, decreasing the SKR supply -and increasing `per`, giving SKR holders more GEM per SKR. When there is -surplus Woe, SKR is inflated, increasing the SKR supply and decreasing -`per`, giving SKR holders less GEM per SKR. +PETH. When there is surplus Dai, PETH is burned, decreasing the PETH supply +and increasing `per`, giving PETH holders more GEM per PETH. When there is +surplus Woe, PETH is inflated, increasing the PETH supply and decreasing +`per`, giving PETH holders less GEM per PETH. -The reason for wrapping GEM in SKR is now apparent: *it provides a way +The reason for wrapping GEM in PETH is now apparent: *it provides a way to socialise losses and gains incurred in the operation of the system.* Two features of this mechanism: -1. Whilst SKR can be inflated significantly, there is a finite limit on +1. Whilst PETH can be inflated significantly, there is a finite limit on the amount of bad debt the system can absorb - given by the value of the underlying GEM collateral. -2. There is a negative feedback between `bust` and `bite`: as SKR is +2. There is a negative feedback between `bust` and `bite`: as PETH is inflated it becomes less valuable, reducing the safety level of CDPs. Some CDPs will become unsafe and be vulnerable to liquidation, creating more bad debt. In an active market, CDP holders will have to - be vigilant about the potential for SKR inflation if they are holding + be vigilant about the potential for PETH inflation if they are holding tightly collateralised CDPs. ### `top`: Global Settlement Manager -A key feature of Sai is the possibility of `cage`: shutting down the -system and reimbursing Sai holders. This is provided for easy upgrades -between Sai iterations, and for security in case of implementation flaws +A key feature of Dai is the possibility of `cage`: shutting down the +system and reimbursing Dai holders. This is provided for easy upgrades +between Dai iterations, and for security in case of implementation flaws - both in the code and in the design. -An admin can use the `top` to `cage` the system at a specific price (sai +An admin can use the `top` to `cage` the system at a specific price (dai per gem), or by reading the last price from the price feed. -First, sufficient real `gem` collateral is taken such that Sai holders -can redeem their Sai at face value. The `gem` is moved from the `tub` to -the `tap` and the `tap.cash` function is unlocked for Sai holders to +First, sufficient real `gem` collateral is taken such that Dai holders +can redeem their Dai at face value. The `gem` is moved from the `tub` to +the `tap` and the `tap.cash` function is unlocked for Dai holders to call. ![Cash](https://user-images.githubusercontent.com/5028/30519070-6cc4fd6a-9be1-11e7-92d8-5d965721d8ef.png) -Any remaining `gem` remains in the `tub`. SKR holders can now `exit`. +Any remaining `gem` remains in the `tub`. PETH holders can now `exit`. CDP holders must first `bite` their CDPs (although anyone can do this) -and then `free` their SKR. +and then `free` their PETH. Some important features of `cage`: -- Sai holders are not guaranteed their face value, only preferential payout. -- *the full real collateral pool is tapped* to make Sai whole. SKR is a +- Dai holders are not guaranteed their face value, only preferential payout. +- *the full real collateral pool is tapped* to make Dai whole. PETH is a *risk-bearing* token. -- SKR holders will receive a poor rate if they try to `exit` before all +- PETH holders will receive a poor rate if they try to `exit` before all CDPs are processed by `bite`. To prevent accidental early `exit`, `top.flow` is provided, which will only enable `exit` after all CDPs are processed, or a timeout has expired. @@ -272,7 +272,7 @@ total unprocessed revenue, with varying `tax`, in constant time. ## Governance Fee -This version of Sai (aka Dai v1) is collectively governed by the holders of +This version of Dai (aka Dai v1) is collectively governed by the holders of a token, `gov`. The specifics of the governance mechanism are out of scope for this document. The `gov` token is also used to pay usage fees: the `fee` is similar to the `tax`, and causes the `rhi` accumulator to @@ -280,7 +280,7 @@ increase relative to `chi`. The difference between `rhi` and `chi` can be used to determine the total outstanding fee, the `rap`. Fees are paid on `wipe`, and the amount payable is scaled with the amount wiped. -Fees are paid in `gov`, but the outstanding fee is denominated in Sai. +Fees are paid in `gov`, but the outstanding fee is denominated in Dai. Therefore we need a price feed for `gov`: this is the `pep`. The mechanism in `wipe` is meant to be robust against failure of the `pep` feed. @@ -290,12 +290,12 @@ change in a future release). ## Auth setup -Sai is designed with two authorities, `dad` and `chief`. +Dai is designed with two authorities, `dad` and `chief`. - `dad` is a DSGuard, and is used for internal contract-contract - permissions, allowing e.g. the `tub` to `mint` and `burn` Sai. `dad` - is the authority of the `tub` and `tap`, and also `sai`, `sin` and - `skr`. + permissions, allowing e.g. the `tub` to `mint` and `burn` Dai. `dad` + is the authority of the `tub` and `tap`, and also `dai`, `sin` and + `peth`. - `chief` restricts access to `top` and `mom`, which are the admin interfaces to the system. `chief` is intended to be a DSRoles @@ -304,7 +304,7 @@ Sai is designed with two authorities, `dad` and `chief`. ## Deployment -Sai is a complex multi-contract system and has a slightly involved +Dai is a complex multi-contract system and has a slightly involved deployment process. The prerequisities to the deployment are: 1. `pip`, a collateral price feed @@ -316,7 +316,7 @@ deployment process. The prerequisities to the deployment are: For testing purposes, `bin/deploy` will create the prerequisites for you if you don't supply them. -In addition, Sai utilises on-chain deployers, called fabs, for creating +In addition, Dai utilises on-chain deployers, called fabs, for creating fresh basic components on chain. These are defined in `fab.sol`. The main contract deployment is defined in `DaiFab`, and requires @@ -336,12 +336,12 @@ bin/deploy ### Prices -- `per`: gem per skr -- `par`: ref per sai -- `tag`: ref per skr +- `per`: gem per peth +- `par`: ref per dai +- `tag`: ref per peth - `pip`: ref per gem -- `fix`: gem per sai after `cage` -- `fit`: ref per skr after `cage` +- `fix`: gem per dai after `cage` +- `fit`: ref per peth after `cage` ### Meme Mnemonics @@ -352,15 +352,15 @@ bin/deploy - `top`: top-level system manager - `way`: which way the target price is heading -- `cap`: upper limit of Sai issuance +- `cap`: upper limit of Dai issuance - `mat`: lower limit of collateralisation - `tax`: continually paid by CDP holders - `axe`: penalty applied to bad CDP holders - `gap`: gap between buy and sell -- `pie`: Real collateral that SKR holders share +- `pie`: Real collateral that PETH holders share - `air`: Abstracted Collateral backing CDPs - `ice`: Debt that is locked up with CDPs - `fog`: Murky liquidated `air`that we want to get rid of -- `joy`: SKR holders are happy about this Sai surplus -- `woe`: SKR holders are sad about this Sin debt +- `joy`: PETH holders are happy about this Dai surplus +- `woe`: PETH holders are sad about this Sin debt diff --git a/README.md b/README.md index 709601d..fd5dc58 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,4 @@ - - - -_Please note that this document temporarily refers to sai instead of dai and skr instead of peth. These are just different variable names and their functionality is identical to what is described in the latest Dai documentation._ - - -`sai` is a simple single-collateral stablecoin that is dependent on a +`dai` is a simple single-collateral stablecoin that is dependent on a trusted oracle address and has a kill-switch. See the [developer documentation](DEVELOPING.md) for a more technical @@ -14,37 +8,37 @@ There are four tokens in the system: - `gem`: externally valuable token e.g. ETH - `gov`: governance token e.g. MKR -- `skr`: a claim to locked `gem`s -- `sai`: the stablecoin, a variable claim on some quantity of `gem`s +- `peth`: a claim to locked `gem`s +- `dai`: the stablecoin, a variable claim on some quantity of `gem`s Collateral holders deposit their collateral using `join` and receive -`skr` tokens proportional to their deposit. `skr` can be redeemed for +`peth` tokens proportional to their deposit. `peth` can be redeemed for collateral with `exit`. You will get more or less `gem` tokens for each -`skr` depending whether the system made a profit or loss while you +`peth` depending whether the system made a profit or loss while you were exposed. The oracle updates the GEM:REF and GOV:REF price feeds. These are the only external real-time input to the system. -`skr` is used as the direct backing collateral for CDPs. A prospective -issuer can `open` an empty position, `lock` some `skr` and then `draw` -some `sai`. Debt is covered with `wipe`. Collateral can be reclaimed +`peth` is used as the direct backing collateral for CDPs. A prospective +issuer can `open` an empty position, `lock` some `peth` and then `draw` +some `dai`. Debt is covered with `wipe`. Collateral can be reclaimed with `free` as long as the CDP remains "safe". If the value of the collateral backing the CDP falls below the liquidation ratio `mat`, the CDP is vulnerable to liquidation via -`bite`. On liquidation, the CDP `skr` collateral is sold off to cover -the `sai` debt. +`bite`. On liquidation, the CDP `peth` collateral is sold off to cover +the `dai` debt. Under-collateralized CDPs can be liquidated with `bite`. Liquidation is -immediate: backing `skr` is taken to cover the `sai` debt at the time of +immediate: backing `peth` is taken to cover the `dai` debt at the time of `bite`, plus a liquidation fee (`axe`); any excess remains in the CDP. -`skr` seized from bad CDPs can be purchased with `bust`, in exchange for -`sai` at the `s2s` price. This `sai` pays down the bad CDP debt. +`peth` seized from bad CDPs can be purchased with `bust`, in exchange for +`dai` at the `s2s` price. This `dai` pays down the bad CDP debt. -Any remaining Sai surplus (`joy`) can be purchased with `boom`, in -exchange for `skr` at the `s2s` price. This `skr` is burned. +Any remaining Dai surplus (`joy`) can be purchased with `boom`, in +exchange for `peth` at the `s2s` price. This `peth` is burned. ### Fees @@ -57,42 +51,42 @@ It makes their debt (`rap`) increase over time. ### Settlement -`sai` can be shut down at a given price with `cage`, after which `sai` -and `skr` can be exchanged for `gems` via `cash`. All outstanding `cups` -are liquidated and the *entire pool* of `gem` is tapped to redeem `sai` +`dai` can be shut down at a given price with `cage`, after which `dai` +and `peth` can be exchanged for `gems` via `cash`. All outstanding `cups` +are liquidated and the *entire pool* of `gem` is tapped to redeem `dai` at their face value, as if the boom/bust trades were instantly settled -at the cage price. Any remaining `gems` are shared between `skr` +at the cage price. Any remaining `gems` are shared between `peth` holders. Practically this means that if the system is undercollateralized on -`cage`, holders of free `skr` will have their `gem` share diluted as -much as necessary to make `sai` whole. *In other words, `skr` is a +`cage`, holders of free `peth` will have their `gem` share diluted as +much as necessary to make `dai` whole. *In other words, `peth` is a risk bearing token*. Excess collateral contained within a single `cup` can be reclaimed with `bite(cup)`. -### `sai` glossary (`sai help`) +### `dai` glossary (`dai help`) ``` Actions: bite initiate liquidation of an undercollateral cup - boom buy some amount of sai to process joy (surplus) - bust sell some amount of sai to process woe (bad debt) + boom buy some amount of dai to process joy (surplus) + bust sell some amount of dai to process woe (bad debt) cage lock the system and initiate settlement - cash cash in sai balance for gems after cage + cash cash in dai balance for gems after cage cupi get the last cup id cups list cups created by you - draw issue the specified amount of sai stablecoins + draw issue the specified amount of dai stablecoins drip recalculate the internal debt price - exit sell SKR for gems - free remove excess SKR collateral from a cup + exit sell PETH for gems + free remove excess PETH collateral from a cup give transfer ownership of a cup heal cancel debt - help print help about sai(1) or one of its subcommands - join buy SKR for gems - lock post additional SKR collateral to a cup + help print help about dai(1) or one of its subcommands + join buy PETH for gems + lock post additional PETH collateral to a cup open create a new cup (collateralized debt position) prod recalculate the accrued holder fee (par) safe determine if a cup is safe @@ -106,7 +100,7 @@ Actions: setWay update the holder fee (interest rate) shut close a cup vent process a caged tub - wipe repay some portion of your existing sai debt + wipe repay some portion of your existing dai debt Vars, Getters, Utils: @@ -116,21 +110,21 @@ Vars, Getters, Utils: chi get the internal debt price cup show the cup info fee get the governance fee - fit get the gem per skr settlement price - fix get the gem per sai settlement price - fog get the amount of skr pending liquidation + fit get the gem per peth settlement price + fix get the gem per dai settlement price + fog get the amount of peth pending liquidation gem get the collateral token gov get the governance token cap get the debt ceiling ice get the good debt - ink get the amount of skr collateral locked in a cup - joy get the amount of surplus sai + ink get the amount of peth collateral locked in a cup + joy get the amount of surplus dai lad get the owner of a cup mat get the liquidation ratio off get the cage flag out get the post cage exit flag - par get the accrued holder fee (ref per sai) - per get the current entry price (gem per skr) + par get the accrued holder fee (ref per dai) + per get the current entry price (gem per peth) pie get the amount of raw collateral pep get the gov price feed pip get the gem price feed @@ -139,19 +133,19 @@ Vars, Getters, Utils: ray parse and display a 27-decimal fixed-point number rho get the time of last drip rhi get the internal debt price (governance included) - s2s get the skr per sai rate (for boom and bust) - sai get the sai token + s2s get the peth per dai rate (for boom and bust) + dai get the dai token sin get the sin token - skr get the skr token + peth get the peth token tab get the amount of debt in a cup - tag get the reference price (ref per skr) - tapAsk get the amount of skr in sai for bust - tapBid get the amount of skr in sai for boom + tag get the reference price (ref per peth) + tapAsk get the amount of peth in dai for bust + tapBid get the amount of peth in dai for boom tapGap get the spread on `boom` and `bust` tau get the time of last prod tax get the stability fee - tubAsk get the amount of skr in gem for join - tubBid get the amount of skr in gem for exit + tubAsk get the amount of peth in gem for join + tubBid get the amount of peth in gem for exit tubGap get the spread on `join` and `exit` vox get the target price engine wad parse and display a 18-decimal fixed-point number @@ -161,58 +155,58 @@ Vars, Getters, Utils: ``` -### Sample interaction using `sai` +### Sample interaction using `dai` ```bash $ export ETH_FROM=0x(...) -$ export SAI_TUB=0x(...) +$ export DAI_TUB=0x(...) -# Give the system access to our GEM (W-ETH), SKR and SAI balances -# so we can join()/exit() and also draw()/wipe() sai -$ token approve $(sai gem) $(sai tub) $(seth --to-wei 1000000000 ETH) -$ token approve $(sai skr) $(sai tub) $(seth --to-wei 1000000000 ETH) -$ token approve $(sai sai) $(sai tub) $(seth --to-wei 1000000000 ETH) +# Give the system access to our GEM (W-ETH), PETH and DAI balances +# so we can join()/exit() and also draw()/wipe() dai +$ token approve $(dai gem) $(dai tub) $(seth --to-wei 1000000000 ETH) +$ token approve $(dai peth) $(dai tub) $(seth --to-wei 1000000000 ETH) +$ token approve $(dai dai) $(dai tub) $(seth --to-wei 1000000000 ETH) # If we also plan on using boom() and bust(), a different component -# (called `tap`) will need to have access to our SKR and SAI balances -$ token approve $(sai skr) $(sai tap) $(seth --to-wei 1000000000 ETH) -$ token approve $(sai sai) $(sai tap) $(seth --to-wei 1000000000 ETH) +# (called `tap`) will need to have access to our PETH and DAI balances +$ token approve $(dai peth) $(dai tap) $(seth --to-wei 1000000000 ETH) +$ token approve $(dai dai) $(dai tap) $(seth --to-wei 1000000000 ETH) # We need to have some GEM (W-ETH) balance to start with -$ token balance $(sai gem) $ETH_FROM +$ token balance $(dai gem) $ETH_FROM 2.467935274974511817 -# Join the system by exchanging some GEM (W-ETH) to SKR -$ sai join 2.2 -Generating 2.200000000000000000 SKR depositing GEM... -$ token balance $(sai gem) $ETH_FROM +# Join the system by exchanging some GEM (W-ETH) to PETH +$ dai join 2.2 +Generating 2.200000000000000000 PETH depositing GEM... +$ token balance $(dai gem) $ETH_FROM 0.267935274974511817 -$ token balance $(sai skr) $ETH_FROM +$ token balance $(dai peth) $ETH_FROM 2.200000000000000000 # Open a new cup -$ sai open +$ dai open Opening cup... Opened cup 62 # We can list our cups at all times -$ sai cups +$ dai cups Cups created by you... 62 -# Lock some SKR collateral in the cup and then draw some SAI from it -$ sai --cup 62 lock 1.5 -Locking 1.500000000000000000 SKR in cup 62... -$ sai --cup 62 draw 89.0 -Drawing 89.000000000000000000 SAI from cup 62... -$ token balance $(sai skr) $ETH_FROM +# Lock some PETH collateral in the cup and then draw some DAI from it +$ dai --cup 62 lock 1.5 +Locking 1.500000000000000000 PETH in cup 62... +$ dai --cup 62 draw 89.0 +Drawing 89.000000000000000000 DAI from cup 62... +$ token balance $(dai peth) $ETH_FROM 0.700000000000000000 -$ token balance $(sai sai) $ETH_FROM +$ token balance $(dai dai) $ETH_FROM 89.000000000000000000 # We can examine the cup details, `tab` and `ink` representing # the amount of debt and the amount of collateral respectively -$ sai --cup 62 cup +$ dai --cup 62 cup cup id 62... lad: 0x(...) ink: 1.500000000000000000 @@ -221,45 +215,45 @@ rap: 0.000000000000000000 # We can check whether the cup is still safe # (ie. whether the value of collateral locked is high enough) -$ sai --cup 62 safe +$ dai --cup 62 safe true -# At some point we will want to wipe our SAI debt -# which means we can also free the SKR collateral -$ sai --cup 62 wipe 59.0 -Wiping 59.000000000000000000 SAI from cup 62... -$ sai --cup 62 free 1.1 -Freeing 1.100000000000000000 SKR from cup 62... -$ token balance $(sai skr) $ETH_FROM +# At some point we will want to wipe our DAI debt +# which means we can also free the PETH collateral +$ dai --cup 62 wipe 59.0 +Wiping 59.000000000000000000 DAI from cup 62... +$ dai --cup 62 free 1.1 +Freeing 1.100000000000000000 PETH from cup 62... +$ token balance $(dai peth) $ETH_FROM 1.800000000000000000 -$ token balance $(sai sai) $ETH_FROM +$ token balance $(dai dai) $ETH_FROM 30.000000000000000000 # The `tab` and `ink` values have changed -$ sai --cup 62 cup +$ dai --cup 62 cup cup id 62... lad: 0x(...) ink: 0.400000000000000000 tab: 30.000000000000000000 rap: 0.000000000000000000 -# We can also `wipe` and `free` outstanding balances of SAI and SKR by calling `shut` -$ sai --cup 62 shut +# We can also `wipe` and `free` outstanding balances of DAI and PETH by calling `shut` +$ dai --cup 62 shut Closing cup 62... -$ sai --cup 62 cup +$ dai --cup 62 cup cup id 62... lad: 0x0000000000000000000000000000000000000000 ink: 0.000000000000000000 tab: 0.000000000000000000 rap: 0.000000000000000000 -# Exit the system by exchanging SKR back to GEM (W-ETH) -$ sai exit 2.2 -Sending 2.200000000000000000 SKR to TUB... -$ token balance $(sai gem) $ETH_FROM +# Exit the system by exchanging PETH back to GEM (W-ETH) +$ dai exit 2.2 +Sending 2.200000000000000000 PETH to TUB... +$ token balance $(dai gem) $ETH_FROM 2.467935274974511817 -$ token balance $(sai skr) $ETH_FROM +$ token balance $(dai peth) $ETH_FROM 0.000000000000000000 ``` @@ -270,11 +264,11 @@ v3.0: ```bash # TODO: ADD NEW ADDRESSES (load-env) -export SAI_MULTISIG=0x2305576962e33102b01d8f3dfda2fa640137b15e +export DAI_MULTISIG=0x2305576962e33102b01d8f3dfda2fa640137b15e ``` ```bash # TODO: ADD NEW ADDRESSES (load-env) -export SAI_MULTISIG=0xf24888d405776cc56d29e70448172380708bb7a5 +export DAI_MULTISIG=0xf24888d405776cc56d29e70448172380708bb7a5 ``` diff --git a/bin/dai b/bin/dai new file mode 100644 index 0000000..ef995f6 --- /dev/null +++ b/bin/dai @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -e +PATH=${0%/*/*}/libexec/dai:$PATH dai "$@" diff --git a/bin/deploy b/bin/deploy index db2d4db..f04d306 100755 --- a/bin/deploy +++ b/bin/deploy @@ -10,51 +10,51 @@ dapp build (test -z $GEM_FAB || test -z $VOX_FAB || test -z $TUB_FAB || test -z $TAP_FAB || test -z $TOP_FAB || test -z $MOM_FAB || test -z $DAD_FAB) && exit 1 export SETH_ASYNC=yes -test -z $SAI_GEM && GEMtx=$(dapp create DSToken $(seth --to-bytes32 $(seth --from-ascii 'ETH'))) -test -z $SAI_GOV && GOVtx=$(dapp create DSToken $(seth --to-bytes32 $(seth --from-ascii 'GOV'))) -test -z $SAI_PIP && PIPtx=$(dapp create DSValue) -test -z $SAI_PEP && PEPtx=$(dapp create DSValue) +test -z $DAI_GEM && GEMtx=$(dapp create DSToken $(seth --to-bytes32 $(seth --from-ascii 'ETH'))) +test -z $DAI_GOV && GOVtx=$(dapp create DSToken $(seth --to-bytes32 $(seth --from-ascii 'GOV'))) +test -z $DAI_PIP && PIPtx=$(dapp create DSValue) +test -z $DAI_PEP && PEPtx=$(dapp create DSValue) export SETH_ASYNC=no -test -z $SAI_GEM && SAI_GEM=$(seth receipt $GEMtx contractAddress) -test -z $SAI_GOV && SAI_GOV=$(seth receipt $GOVtx contractAddress) -test -z $SAI_PIP && SAI_PIP=$(seth receipt $PIPtx contractAddress) -test -z $SAI_PEP && SAI_PEP=$(seth receipt $PEPtx contractAddress) -test -z $SAI_PIT && SAI_PIT="0x0000000000000000000000000000000000000123" +test -z $DAI_GEM && DAI_GEM=$(seth receipt $GEMtx contractAddress) +test -z $DAI_GOV && DAI_GOV=$(seth receipt $GOVtx contractAddress) +test -z $DAI_PIP && DAI_PIP=$(seth receipt $PIPtx contractAddress) +test -z $DAI_PEP && DAI_PEP=$(seth receipt $PEPtx contractAddress) +test -z $DAI_PIT && DAI_PIT="0x0000000000000000000000000000000000000123" DAI_FAB=$(dapp create DaiFab $GEM_FAB $VOX_FAB $TUB_FAB $TAP_FAB $TOP_FAB $MOM_FAB $DAD_FAB) -if [ -z $SAI_ADM ] +if [ -z $DAI_ADM ] then - SAI_ADM=$(dapp create DSRoles) - seth send $SAI_ADM 'setRootUser(address,bool)' $ETH_FROM true + DAI_ADM=$(dapp create DSRoles) + seth send $DAI_ADM 'setRootUser(address,bool)' $ETH_FROM true fi seth send $DAI_FAB 'makeTokens()' -seth send $DAI_FAB 'makeVoxTub(address,address,address,address,address)' $SAI_GEM $SAI_GOV $SAI_PIP $SAI_PEP $SAI_PIT +seth send $DAI_FAB 'makeVoxTub(address,address,address,address,address)' $DAI_GEM $DAI_GOV $DAI_PIP $DAI_PEP $DAI_PIT seth send $DAI_FAB 'makeTapTop()' seth send $DAI_FAB 'configParams()' seth send $DAI_FAB 'verifyParams()' -seth send $DAI_FAB 'configAuth(address)' $SAI_ADM +seth send $DAI_FAB 'configAuth(address)' $DAI_ADM cat > load-env-$(seth chain) << EOF #!/bin/bash -# sai deployment on $(seth chain) from $(git rev-parse HEAD) +# dai deployment on $(seth chain) from $(git rev-parse HEAD) # $(date) -export SAI_GEM=$SAI_GEM -export SAI_GOV=$SAI_GOV -export SAI_PIP=$SAI_PIP -export SAI_PEP=$SAI_PEP -export SAI_PIT=$SAI_PIT -export SAI_ADM=$SAI_ADM -export SAI_SAI=0x$(seth call $DAI_FAB 'sai()(address)') -export SAI_SIN=0x$(seth call $DAI_FAB 'sin()(address)') -export SAI_SKR=0x$(seth call $DAI_FAB 'skr()(address)') -export SAI_DAD=0x$(seth call $DAI_FAB 'dad()(address)') -export SAI_MOM=0x$(seth call $DAI_FAB 'mom()(address)') -export SAI_VOX=0x$(seth call $DAI_FAB 'vox()(address)') -export SAI_TUB=0x$(seth call $DAI_FAB 'tub()(address)') -export SAI_TAP=0x$(seth call $DAI_FAB 'tap()(address)') -export SAI_TOP=0x$(seth call $DAI_FAB 'top()(address)') +export DAI_GEM=$DAI_GEM +export DAI_GOV=$DAI_GOV +export DAI_PIP=$DAI_PIP +export DAI_PEP=$DAI_PEP +export DAI_PIT=$DAI_PIT +export DAI_ADM=$DAI_ADM +export DAI_DAI=0x$(seth call $DAI_FAB 'dai()(address)') +export DAI_SIN=0x$(seth call $DAI_FAB 'sin()(address)') +export DAI_PETH=0x$(seth call $DAI_FAB 'peth()(address)') +export DAI_DAD=0x$(seth call $DAI_FAB 'dad()(address)') +export DAI_MOM=0x$(seth call $DAI_FAB 'mom()(address)') +export DAI_VOX=0x$(seth call $DAI_FAB 'vox()(address)') +export DAI_TUB=0x$(seth call $DAI_FAB 'tub()(address)') +export DAI_TAP=0x$(seth call $DAI_FAB 'tap()(address)') +export DAI_TOP=0x$(seth call $DAI_FAB 'top()(address)') EOF diff --git a/bin/deploy-pre b/bin/deploy-pre index c101494..c116c6a 100755 --- a/bin/deploy-pre +++ b/bin/deploy-pre @@ -8,38 +8,38 @@ export ETH_FROM=${ETH_FROM:-$(seth rpc eth_coinbase)} dapp build # ETHUSD feed -export SAI_PIP='0x729D19f657BD0614b4985Cf1D82531c67569197B' +export DAI_PIP='0x729D19f657BD0614b4985Cf1D82531c67569197B' # MKRUSD feed -export SAI_PEP='0x99041F808D598B782D5a3e498681C2452A31da08' +export DAI_PEP='0x99041F808D598B782D5a3e498681C2452A31da08' # WETH9 -export SAI_GEM='0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' +export DAI_GEM='0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' # Token burner -export SAI_PIT=$(dapp create GemPit) +export DAI_PIT=$(dapp create GemPit) # MKR address -export SAI_GOV='0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2' +export DAI_GOV='0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2' # Chief ## Voting IOU -export SAI_IOU=$(dapp create DSToken $(seth --to-bytes32 $(seth --from-ascii 'IOU'))) -export SAI_ADM=$(dapp create DSChief $SAI_GOV $SAI_IOU 5) -seth send $SAI_IOU 'setOwner(address)' $SAI_ADM +export DAI_IOU=$(dapp create DSToken $(seth --to-bytes32 $(seth --from-ascii 'IOU'))) +export DAI_ADM=$(dapp create DSChief $DAI_GOV $DAI_IOU 5) +seth send $DAI_IOU 'setOwner(address)' $DAI_ADM cat > load-pre-$(seth chain) << EOF -test -z $SAI_GEM && GEMtx=$(dapp create DSToken $(seth --to-bytes32 $(seth --from-ascii 'ETH'))) +test -z $DAI_GEM && GEMtx=$(dapp create DSToken $(seth --to-bytes32 $(seth --from-ascii 'ETH'))) #!/bin/bash -# pre-sai deployment on $(seth chain) from $(git rev-parse HEAD) +# pre-dai deployment on $(seth chain) from $(git rev-parse HEAD) # $(date) -export SAI_GEM=$SAI_GEM -export SAI_GOV=$SAI_GOV -export SAI_PIP=$SAI_PIP -export SAI_PEP=$SAI_PEP -export SAI_PIT=$SAI_PIT -export SAI_ADM=$SAI_ADM -export SAI_IOU=$SAI_IOU +export DAI_GEM=$DAI_GEM +export DAI_GOV=$DAI_GOV +export DAI_PIP=$DAI_PIP +export DAI_PEP=$DAI_PEP +export DAI_PIT=$DAI_PIT +export DAI_ADM=$DAI_ADM +export DAI_IOU=$DAI_IOU EOF diff --git a/bin/sai b/bin/sai deleted file mode 100755 index 505aa19..0000000 --- a/bin/sai +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -set -e -PATH=${0%/*/*}/libexec/sai:$PATH sai "$@" diff --git a/libexec/sai/sai b/libexec/dai/dai old mode 100755 new mode 100644 similarity index 68% rename from libexec/sai/sai rename to libexec/dai/dai index de51e74..63f327e --- a/libexec/sai/sai +++ b/libexec/dai/dai @@ -1,21 +1,21 @@ #!/usr/bin/env bash -### sai -- command-line Ethereum RPC client -### Usage: sai [] [] -### or: sai --help +### dai -- command-line Ethereum RPC client +### Usage: dai [] [] +### or: dai --help ### -### Sai is a simple version of the diversely collateralized Dai stablecoin. +### Dai is a simple version of the diversely collateralized Dai stablecoin. ### ### In this model there is one type of underlying collateral (called gems). -### The SKR token represents claims on the system's excess gems, and is the -### only admissible type of collateral. Gems can be converted to/from SKR. +### The PETH token represents claims on the system's excess gems, and is the +### only admissible type of collateral. Gems can be converted to/from PETH. ### -### Any transfers of sai or SKR are done using the normal ERC20 interface; -### until settlement mode is triggered, sai users should only need ERC20. +### Any transfers of dai or PETH are done using the normal ERC20 interface; +### until settlement mode is triggered, dai users should only need ERC20. ### ### To conveniently perform ERC20 transfers, see the token(1) program ### available at . ### -### Sai options: +### Dai options: ### ### -C, --cup= ID of cup to perform operation on ### --tub=
address of Tub to perform operation on @@ -27,8 +27,8 @@ ### -F, --from= account from which to send transaction ### -G, --gas= amount of gas to provide with transaction -OPTS="sai [] [] -sai --help +OPTS="dai [] [] +dai --help -- Options C,cup=id ID of cup to perform operation on @@ -60,22 +60,22 @@ while [[ $1 ]]; do case $1 in --) shift; break;; - -C|--cup) shift; export SAI_CUP="$(seth --to-hexdata "$(seth --to-uint256 "$1")")";; - --tub) shift; export SAI_TUB=$1;; - --tap) shift; export SAI_TAP=$1;; - --top) shift; export SAI_TOP=$1;; + -C|--cup) shift; export DAI_CUP="$(seth --to-hexdata "$(seth --to-uint256 "$1")")";; + --tub) shift; export DAI_TUB=$1;; + --tap) shift; export DAI_TAP=$1;; + --top) shift; export DAI_TOP=$1;; -F|--from) shift; export ETH_FROM=$1;; -G|--gas) shift; export ETH_GAS=$1;; - -h) export SAI_HUMAN=1;; + -h) export DAI_HUMAN=1;; *) printf "${0##*/}: internal error: %q\n" "$1"; exit 1 esac; shift done -export SAI_TUB=${SAI_TUB:-@sai_tub} -export SAI_TAP=${SAI_TAP:-@sai_tap} -export SAI_TOP=${SAI_TOP:-@sai_top} +export DAI_TUB=${DAI_TUB:-@dai_tub} +export DAI_TAP=${DAI_TAP:-@dai_tap} +export DAI_TOP=${DAI_TOP:-@dai_top} "${0##*/}-${1-help}" "${@:2}" diff --git a/libexec/sai/sai---help b/libexec/dai/dai---help old mode 100755 new mode 100644 similarity index 75% rename from libexec/sai/sai---help rename to libexec/dai/dai---help index 1c025d6..4052f7e --- a/libexec/sai/sai---help +++ b/libexec/dai/dai---help @@ -1,3 +1,3 @@ #!/usr/bin/env bash set -e -sai help +dai help diff --git a/libexec/dai/dai-air b/libexec/dai/dai-air new file mode 100644 index 0000000..dbfee44 --- /dev/null +++ b/libexec/dai/dai-air @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-air -- get the amount of backing collateral +set -e +wad=$(seth call "${DAI_TUB?}" "air()") +dai wad -h "$wad" diff --git a/libexec/dai/dai-axe b/libexec/dai/dai-axe new file mode 100644 index 0000000..43ae4fb --- /dev/null +++ b/libexec/dai/dai-axe @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-axe -- get the liquidation penalty +set -e +ray=$(seth call "${DAI_TUB?}" "axe()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-bite b/libexec/dai/dai-bite new file mode 100644 index 0000000..e673d79 --- /dev/null +++ b/libexec/dai/dai-bite @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-bite -- initiate liquidation of an undercollateral cup +### Usage: dai --cup= bite +set -e +[ ! -z "$DAI_CUP" ] || dai bite --usage +echo >&2 "Attempting to bite cup id $((${DAI_CUP?}))..." +safe=$(dai safe) +[[ $safe = true ]] && { echo >&2 "${0##*/}: error: cup not unsafe"; exit 1; } +(set -x; seth send "${DAI_TUB?}" "bite(bytes32)" "$DAI_CUP") diff --git a/libexec/dai/dai-boom b/libexec/dai/dai-boom new file mode 100644 index 0000000..4f1fc58 --- /dev/null +++ b/libexec/dai/dai-boom @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-boom -- buy some amount of dai to process joy (surplus) +### Usage: dai boom +set -e +[ $# = 1 ] || dai boom --usage +wad=$(dai wad -h "$1") +echo >&2 "Buying $wad PETH-worth amount of DAI from the tub in order to process joy..." +wad=$(dai wad "$1") +(set -x; seth send "${DAI_TAP?}" "boom(uint256)" "$wad") diff --git a/libexec/dai/dai-bust b/libexec/dai/dai-bust new file mode 100644 index 0000000..4fad3fd --- /dev/null +++ b/libexec/dai/dai-bust @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-bust -- sell some amount of dai to process woe (bad debt) +### Usage: dai bust +set -e +[ $# = 1 ] || dai bust --usage +wad=$(dai wad -h "$1") +echo >&2 "Selling $wad PETH-worth amount of DAI to the tub in order to process woe..." +wad=$(dai wad "$1") +(set -x; seth send "${DAI_TAP?}" "bust(uint256)" "$wad") diff --git a/libexec/sai/sai-cage b/libexec/dai/dai-cage old mode 100755 new mode 100644 similarity index 50% rename from libexec/sai/sai-cage rename to libexec/dai/dai-cage index 50c5691..4c1282b --- a/libexec/sai/sai-cage +++ b/libexec/dai/dai-cage @@ -1,18 +1,18 @@ #!/usr/bin/env bash -### sai-cage -- lock the system and initiate settlement -### Usage: sai cage [] +### dai-cage -- lock the system and initiate settlement +### Usage: dai cage [] ### if is not specified, the last value from the feed will be used set -e if [ $# = 0 ] then echo >&2 "Caging the tub, using the final price from the feed" - (set -x; seth send "${SAI_TOP?}" "cage()") + (set -x; seth send "${DAI_TOP?}" "cage()") elif [ $# = 1 ] then - wad=$(sai wad -h "$1") + wad=$(dai wad -h "$1") echo >&2 "Caging the tub, final price $wad" - wad=$(sai wad "$1") - (set -x; seth send "${SAI_TOP?}" "cage(uint256)" "$wad") + wad=$(dai wad "$1") + (set -x; seth send "${DAI_TOP?}" "cage(uint256)" "$wad") else - sai cage --usage + dai cage --usage fi diff --git a/libexec/dai/dai-caged b/libexec/dai/dai-caged new file mode 100644 index 0000000..83a2df7 --- /dev/null +++ b/libexec/dai/dai-caged @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +### dai-caged -- get time of cage event (= 0 if system is not caged) +set -e +echo "$(seth --to-dec $(seth call "${DAI_TOP?}" 'caged()'))" diff --git a/libexec/dai/dai-cap b/libexec/dai/dai-cap new file mode 100644 index 0000000..e962b2e --- /dev/null +++ b/libexec/dai/dai-cap @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-cap -- get the debt ceiling +set -e +wad=$(seth call "${DAI_TUB?}" "cap()") +dai wad -h "$wad" diff --git a/libexec/dai/dai-cash b/libexec/dai/dai-cash new file mode 100644 index 0000000..defb954 --- /dev/null +++ b/libexec/dai/dai-cash @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +### dai-cash -- cash in dai balance for gems after cage +set -e +jam=$(token balance "$(dai dai)" "${ETH_FROM?}") +echo >&2 "Cashing in $jam DAI..." +wad=$(dai wad $jam) +(set -x; seth send "${DAI_TAP?}" "cash(uint256)" $wad ) diff --git a/libexec/dai/dai-chi b/libexec/dai/dai-chi new file mode 100644 index 0000000..3307075 --- /dev/null +++ b/libexec/dai/dai-chi @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-chi -- get the internal debt price +set -e +ray=$(seth call "${DAI_TUB?}" "chi()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-cup b/libexec/dai/dai-cup new file mode 100644 index 0000000..e775570 --- /dev/null +++ b/libexec/dai/dai-cup @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +### dai-cup -- show the cup info +### Usage: dai --cup= cup +set -e +[ ! -z "$DAI_CUP" ] || dai cup --usage +echo >&2 "cup id $((${DAI_CUP?}))..." +echo "lad: $(dai lad)" +echo "ink: $(dai ink)" +echo "tab: $(dai tab)" +echo "rap: $(dai rap)" diff --git a/libexec/sai/sai-cupi b/libexec/dai/dai-cupi old mode 100755 new mode 100644 similarity index 52% rename from libexec/sai/sai-cupi rename to libexec/dai/dai-cupi index a339b79..562137a --- a/libexec/sai/sai-cupi +++ b/libexec/dai/dai-cupi @@ -1,5 +1,5 @@ #!/usr/bin/env bash -### sai-cupi -- get the last cup id +### dai-cupi -- get the last cup id set -e -id=$(seth call "${SAI_TUB?}" "cupi()") +id=$(seth call "${DAI_TUB?}" "cupi()") seth --abi-decode 'f()(uint256)' "$id" | seth --to-dec diff --git a/libexec/sai/sai-cups b/libexec/dai/dai-cups old mode 100755 new mode 100644 similarity index 84% rename from libexec/sai/sai-cups rename to libexec/dai/dai-cups index f914756..8def3e3 --- a/libexec/sai/sai-cups +++ b/libexec/dai/dai-cups @@ -1,8 +1,8 @@ #!/usr/bin/env bash -### sai-cups -- list cups created by you +### dai-cups -- list cups created by you set -e echo >&2 "Cups created by you..." -seth rpc eth_getLogs -- -n {} -s "${SAI_TUB?}" -i address \ +seth rpc eth_getLogs -- -n {} -s "${DAI_TUB?}" -i address \ -s earliest -i fromBlock \ -n [] -s "$(seth keccak "$(seth --from-ascii 'LogNewCup(address,bytes32)')")" -i append \ -s "0x$(seth --to-uint256 "${ETH_FROM?}")" -i append \ diff --git a/libexec/dai/dai-dai b/libexec/dai/dai-dai new file mode 100644 index 0000000..a4f6721 --- /dev/null +++ b/libexec/dai/dai-dai @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-dai -- get the dai token +set -e +dai=$(seth call "${DAI_TUB?}" 'dai()') +echo "0x$(seth --abi-decode 'f()(address)' "$dai")" diff --git a/libexec/dai/dai-din b/libexec/dai/dai-din new file mode 100644 index 0000000..09a1f10 --- /dev/null +++ b/libexec/dai/dai-din @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-din -- get the debt backed by CDPs +set -e +wad=$(seth call "${DAI_TUB?}" "din()") +dai wad -h "$wad" diff --git a/libexec/dai/dai-draw b/libexec/dai/dai-draw new file mode 100644 index 0000000..6eccf3f --- /dev/null +++ b/libexec/dai/dai-draw @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +### dai-draw -- issue the specified amount of dai stablecoins +### Usage: dai --cup= draw +set -e +[ $# = 1 ] || dai draw --usage +[ ! -z "$DAI_CUP" ] || dai draw --usage +wad=$(dai wad -h "$1") +echo >&2 "Drawing $wad DAI from cup $((${DAI_CUP?}))..." +wad=$(dai wad "$1") +(set -x; seth send "${DAI_TUB?}" "draw(bytes32,uint256)" "$DAI_CUP" "$wad") diff --git a/libexec/dai/dai-drip b/libexec/dai/dai-drip new file mode 100644 index 0000000..2a44aed --- /dev/null +++ b/libexec/dai/dai-drip @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +### dai-drip -- recalculate the internal debt price +set -e +(set -x; seth send "${DAI_TUB?}" "drip()") diff --git a/libexec/dai/dai-exit b/libexec/dai/dai-exit new file mode 100644 index 0000000..f9aac0f --- /dev/null +++ b/libexec/dai/dai-exit @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-exit -- sell PETH for gems +### Usage: dai exit +set -e +[ $# = 1 ] || dai exit --usage +ink=$(dai wad -h "$1") +echo >&2 "Sending $ink PETH to TUB..." +ink=$(dai wad "$1") +(set -x; seth send "${DAI_TUB?}" "exit(uint256)" "$ink") diff --git a/libexec/dai/dai-fee b/libexec/dai/dai-fee new file mode 100644 index 0000000..4440d63 --- /dev/null +++ b/libexec/dai/dai-fee @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-fee -- get the governance fee +set -e +ray=$(seth call "${DAI_TUB?}" "fee()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-fit b/libexec/dai/dai-fit new file mode 100644 index 0000000..105456e --- /dev/null +++ b/libexec/dai/dai-fit @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-fit -- get the gem per peth settlement price +set -e +ray=$(seth call "${DAI_TUB?}" "fit()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-fix b/libexec/dai/dai-fix new file mode 100644 index 0000000..d988dc4 --- /dev/null +++ b/libexec/dai/dai-fix @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-fix -- get the gem per dai settlement price +set -e +ray=$(seth call "${DAI_TOP?}" "fix()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-fog b/libexec/dai/dai-fog new file mode 100644 index 0000000..5575b8c --- /dev/null +++ b/libexec/dai/dai-fog @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-fog -- get the amount of peth pending liquidation +set -e +wad=$(seth call "${DAI_TAP?}" "fog()") +dai wad -h "$wad" diff --git a/libexec/dai/dai-free b/libexec/dai/dai-free new file mode 100644 index 0000000..067979c --- /dev/null +++ b/libexec/dai/dai-free @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +### dai-free -- remove excess PETH collateral from a cup +### Usage: dai --cup= free +set -e +[ $# = 1 ] || dai free --usage +[ ! -z "$DAI_CUP" ] || dai free --usage +wad=$(dai wad -h "$1") +echo >&2 "Freeing $wad PETH from cup $((${DAI_CUP?}))..." +wad=$(dai wad "$1") +(set -x; seth send "${DAI_TUB?}" "free(bytes32,uint256)" "$DAI_CUP" "$wad") diff --git a/libexec/sai/sai-gem b/libexec/dai/dai-gem old mode 100755 new mode 100644 similarity index 50% rename from libexec/sai/sai-gem rename to libexec/dai/dai-gem index a9a4844..21c3228 --- a/libexec/sai/sai-gem +++ b/libexec/dai/dai-gem @@ -1,5 +1,5 @@ #!/usr/bin/env bash -### sai-gem -- get the collateral token +### dai-gem -- get the collateral token set -e -gem=$(seth call "${SAI_TUB?}" 'gem()') +gem=$(seth call "${DAI_TUB?}" 'gem()') echo "0x$(seth --abi-decode 'f()(address)' "$gem")" diff --git a/libexec/dai/dai-give b/libexec/dai/dai-give new file mode 100644 index 0000000..4e1d316 --- /dev/null +++ b/libexec/dai/dai-give @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +### dai-give -- transfer ownership of a cup +### Usage: dai --cup= give
+set -e +[ $# = 1 ] || dai give --usage +[ ! -z "$DAI_CUP" ] || dai give --usage +echo >&2 "Giving cup $((${DAI_CUP?})) to \"${1?}\"..." +(set -x; seth send "${DAI_TUB?}" "give(bytes32,address)" "$DAI_CUP" "$1") diff --git a/libexec/sai/sai-gov b/libexec/dai/dai-gov old mode 100755 new mode 100644 similarity index 52% rename from libexec/sai/sai-gov rename to libexec/dai/dai-gov index e86acd8..4debc74 --- a/libexec/sai/sai-gov +++ b/libexec/dai/dai-gov @@ -1,5 +1,5 @@ #!/usr/bin/env bash -### sai-gov -- get the gov token +### dai-gov -- get the gov token set -e -gov=$(seth call "${SAI_TUB?}" 'gov()') +gov=$(seth call "${DAI_TUB?}" 'gov()') echo "0x$(seth --abi-decode 'f()(address)' "$gov")" diff --git a/libexec/dai/dai-heal b/libexec/dai/dai-heal new file mode 100644 index 0000000..dc0c8f7 --- /dev/null +++ b/libexec/dai/dai-heal @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +### dai-heal -- cancel debt +set -e +(set -x; seth send "${DAI_TAP?}" "heal()") diff --git a/libexec/sai/sai-help b/libexec/dai/dai-help old mode 100755 new mode 100644 similarity index 82% rename from libexec/sai/sai-help rename to libexec/dai/dai-help index b8748aa..98b88c7 --- a/libexec/sai/sai-help +++ b/libexec/dai/dai-help @@ -1,11 +1,11 @@ #!/usr/bin/env bash -### sai-help -- print help about sai(1) or one of its subcommands -### Usage: sai help [] -### or: sai --help +### dai-help -- print help about dai(1) or one of its subcommands +### Usage: dai help [] +### or: dai --help -BUGS=https://github.com/makerdao/sai/issues/new +BUGS=https://github.com/makerdao/dai/issues/new -name=sai +name=dai file=${0%-*}${1+-$1} header=$(perl -ne 'print "$2\n" if /^(\S)\1\1(?: (.*))?/' "$file") diff --git a/libexec/dai/dai-ink b/libexec/dai/dai-ink new file mode 100644 index 0000000..3d5fb3f --- /dev/null +++ b/libexec/dai/dai-ink @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +### dai-ink -- get the amount of peth collateral locked in a cup +### Usage: dai --cup= ink +set -e +[ ! -z "$DAI_CUP" ] || dai ink --usage +wad=$(seth call "${DAI_TUB?}" "ink(bytes32)" "${DAI_CUP?}") +dai wad -h "$wad" diff --git a/libexec/dai/dai-join b/libexec/dai/dai-join new file mode 100644 index 0000000..85323a3 --- /dev/null +++ b/libexec/dai/dai-join @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-join -- buy PETH for gems +### Usage: dai join +set -e +[ $# = 1 ] || dai join --usage +jam=$(dai wad -h "$1") +echo >&2 "Generating $jam PETH depositing GEM..." +jam=$(dai wad "$1") +(set -x; seth send "${DAI_TUB?}" "join(uint256)" "$jam") diff --git a/libexec/dai/dai-joy b/libexec/dai/dai-joy new file mode 100644 index 0000000..5d1c5d2 --- /dev/null +++ b/libexec/dai/dai-joy @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-joy -- get the amount of surplus dai +set -e +wad=$(seth call "${DAI_TAP?}" "joy()") +dai wad -h "$wad" diff --git a/libexec/dai/dai-lad b/libexec/dai/dai-lad new file mode 100644 index 0000000..fcef894 --- /dev/null +++ b/libexec/dai/dai-lad @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +### dai-lad -- get the owner of a cup +### Usage: dai --cup= lad +set -e +[ ! -z "$DAI_CUP" ] || dai lad --usage +lad=$(seth call "${DAI_TUB?}" 'lad(bytes32)' "${DAI_CUP?}") +echo "0x$(seth --abi-decode 'f()(address)' "$lad")" diff --git a/libexec/dai/dai-lock b/libexec/dai/dai-lock new file mode 100644 index 0000000..e7f12e4 --- /dev/null +++ b/libexec/dai/dai-lock @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +### dai-lock -- post additional PETH collateral to a cup +### Usage: dai --cup= lock +set -e +[ $# = 1 ] || dai lock --usage +[ ! -z "$DAI_CUP" ] || dai lock --usage +wad=$(dai wad -h "$1") +echo >&2 "Locking $wad PETH in cup $((${DAI_CUP?}))..." +wad=$(dai wad "$1") +(set -x; seth send "${DAI_TUB?}" "lock(bytes32,uint256)" "$DAI_CUP" "$wad") diff --git a/libexec/dai/dai-mat b/libexec/dai/dai-mat new file mode 100644 index 0000000..2c5585a --- /dev/null +++ b/libexec/dai/dai-mat @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-mat -- get the liquidation ratio +set -e +ray=$(seth call "${DAI_TUB?}" "mat()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-off b/libexec/dai/dai-off new file mode 100644 index 0000000..959c24b --- /dev/null +++ b/libexec/dai/dai-off @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +### dai-off -- get the cage flag +set -e +seth call "${DAI_TUB?}" "off()(bool)" diff --git a/libexec/sai/sai-open b/libexec/dai/dai-open old mode 100755 new mode 100644 similarity index 82% rename from libexec/sai/sai-open rename to libexec/dai/dai-open index b3ac3dc..0529924 --- a/libexec/sai/sai-open +++ b/libexec/dai/dai-open @@ -1,14 +1,14 @@ #!/usr/bin/env bash -### sai-open -- create a new cup (collateralized debt position) +### dai-open -- create a new cup (collateralized debt position) set -e echo >&2 "Opening cup..." export SETH_ASYNC=yes -tx=$(set -x; seth send "${SAI_TUB?}" "open()(bytes32)") +tx=$(set -x; seth send "${DAI_TUB?}" "open()(bytes32)") export SETH_ASYNC=no echo >&2 -n "Waiting for transaction receipt..." number=$(SETH_TICK=true seth receipt "$tx" blockNumber) echo >&2 -seth rpc eth_getLogs -- -n {} -s "${SAI_TUB?}" -i address \ +seth rpc eth_getLogs -- -n {} -s "${DAI_TUB?}" -i address \ -s "$number" -i fromBlock \ -s "$number" -i toBlock \ -n [] -s "$(seth keccak "$(seth --from-ascii 'LogNewCup(address,bytes32)')")" -i append \ diff --git a/libexec/dai/dai-out b/libexec/dai/dai-out new file mode 100644 index 0000000..3c7644c --- /dev/null +++ b/libexec/dai/dai-out @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +### dai-out -- get the post cage exit flag +set -e +seth call "${DAI_TUB?}" "out()(bool)" diff --git a/libexec/sai/sai-par b/libexec/dai/dai-par old mode 100755 new mode 100644 similarity index 52% rename from libexec/sai/sai-par rename to libexec/dai/dai-par index 9bebb7a..e2d12db --- a/libexec/sai/sai-par +++ b/libexec/dai/dai-par @@ -1,7 +1,7 @@ #!/usr/bin/env bash -### sai-par -- get the accrued holder fee (ref per sai) +### dai-par -- get the accrued holder fee (ref per dai) set -e -vox=$(seth call "${SAI_TUB?}" 'vox()') +vox=$(seth call "${DAI_TUB?}" 'vox()') vox_address="0x$(seth --abi-decode 'f()(address)' "$vox")" ray=$(seth call "$vox_address" "par()") -sai ray -h "$ray" +dai ray -h "$ray" diff --git a/libexec/sai/sai-pep b/libexec/dai/dai-pep old mode 100755 new mode 100644 similarity index 50% rename from libexec/sai/sai-pep rename to libexec/dai/dai-pep index e2982eb..ec89c4c --- a/libexec/sai/sai-pep +++ b/libexec/dai/dai-pep @@ -1,5 +1,5 @@ #!/usr/bin/env bash -### sai-pep -- get the gov price feed +### dai-pep -- get the gov price feed set -e -pep=$(seth call "${SAI_TUB?}" 'pep()') +pep=$(seth call "${DAI_TUB?}" 'pep()') echo "0x$(seth --abi-decode 'f()(address)' "$pep")" diff --git a/libexec/dai/dai-per b/libexec/dai/dai-per new file mode 100644 index 0000000..21fc378 --- /dev/null +++ b/libexec/dai/dai-per @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-per -- get the current entry price (gem per peth) +set -e +ray=$(seth call "${DAI_TUB?}" "per()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-peth b/libexec/dai/dai-peth new file mode 100644 index 0000000..d2134f6 --- /dev/null +++ b/libexec/dai/dai-peth @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-peth -- get the peth token +set -e +peth=$(seth call "${DAI_TUB?}" 'peth()') +echo "0x$(seth --abi-decode 'f()(address)' "$peth")" diff --git a/libexec/dai/dai-pie b/libexec/dai/dai-pie new file mode 100644 index 0000000..63804bf --- /dev/null +++ b/libexec/dai/dai-pie @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-pie -- get the amount of raw collateral +set -e +wad=$(seth call "${DAI_TUB?}" "pie()") +dai wad -h "$wad" diff --git a/libexec/sai/sai-pip b/libexec/dai/dai-pip old mode 100755 new mode 100644 similarity index 50% rename from libexec/sai/sai-pip rename to libexec/dai/dai-pip index 58589f7..6307b7b --- a/libexec/sai/sai-pip +++ b/libexec/dai/dai-pip @@ -1,5 +1,5 @@ #!/usr/bin/env bash -### sai-pip -- get the gem price feed +### dai-pip -- get the gem price feed set -e -pip=$(seth call "${SAI_TUB?}" 'pip()') +pip=$(seth call "${DAI_TUB?}" 'pip()') echo "0x$(seth --abi-decode 'f()(address)' "$pip")" diff --git a/libexec/sai/sai-pit b/libexec/dai/dai-pit old mode 100755 new mode 100644 similarity index 50% rename from libexec/sai/sai-pit rename to libexec/dai/dai-pit index 0a8f106..13dcaa1 --- a/libexec/sai/sai-pit +++ b/libexec/dai/dai-pit @@ -1,5 +1,5 @@ #!/usr/bin/env bash -### sai-pit -- get the liquidator vault +### dai-pit -- get the liquidator vault set -e -pit=$(seth call "${SAI_TUB?}" 'pit()') +pit=$(seth call "${DAI_TUB?}" 'pit()') echo "0x$(seth --abi-decode 'f()(address)' "$pit")" diff --git a/libexec/sai/sai-prod b/libexec/dai/dai-prod old mode 100755 new mode 100644 similarity index 57% rename from libexec/sai/sai-prod rename to libexec/dai/dai-prod index 2d90a3b..372731c --- a/libexec/sai/sai-prod +++ b/libexec/dai/dai-prod @@ -1,6 +1,6 @@ #!/usr/bin/env bash -### sai-prod -- recalculate the accrued holder fee (par) +### dai-prod -- recalculate the accrued holder fee (par) set -e -vox=$(seth call "${SAI_TUB?}" 'vox()') +vox=$(seth call "${DAI_TUB?}" 'vox()') vox_address="0x$(seth --abi-decode 'f()(address)' "$vox")" (set -x; seth send "$vox_address" "prod()") diff --git a/libexec/dai/dai-rap b/libexec/dai/dai-rap new file mode 100644 index 0000000..287fb5b --- /dev/null +++ b/libexec/dai/dai-rap @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +### dai-rap -- get the amount of governance debt +### Usage: dai --cup= rap +set -e +[ ! -z "$DAI_CUP" ] || dai rap --usage +wad=$(seth call "${DAI_TUB?}" "rap(bytes32)" "${DAI_CUP?}") +dai wad -h "$wad" diff --git a/libexec/sai/sai-ray b/libexec/dai/dai-ray old mode 100755 new mode 100644 similarity index 81% rename from libexec/sai/sai-ray rename to libexec/dai/dai-ray index 9ecf533..9c0857c --- a/libexec/sai/sai-ray +++ b/libexec/dai/dai-ray @@ -1,5 +1,5 @@ #!/usr/bin/env node -/// sai-ray -- parse and display a 27-decimal fixed-point number +/// dai-ray -- parse and display a 27-decimal fixed-point number var BigNumber = require("bignumber.js") var ray = process.argv[2], match var rpad = (x, y, n) => x + repeat(y, n - x.length) @@ -13,11 +13,11 @@ if (match = ray.match(/^(\d+\.)(\d{1,27})$/)) { ray = lpad(new BigNumber(ray).toString(10), "0", 27) ray = ray.replace(/.{27}$/, ".$&").replace(/^\./, "0.") } else { - console.error("sai---ray: error: number must have decimal point") + console.error("dai---ray: error: number must have decimal point") process.exit(1) } -if (process.env.SAI_HUMAN) { +if (process.env.DAI_HUMAN) { console.log(ray) } else { console.log(`0x${lpad(toHex(ray), "0", 64)}`) diff --git a/libexec/dai/dai-rhi b/libexec/dai/dai-rhi new file mode 100644 index 0000000..006cdb1 --- /dev/null +++ b/libexec/dai/dai-rhi @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-rhi -- get the internal debt price including governance fee +set -e +ray=$(seth call "${DAI_TUB?}" "rhi()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-rho b/libexec/dai/dai-rho new file mode 100644 index 0000000..574c5cc --- /dev/null +++ b/libexec/dai/dai-rho @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +### dai-rho -- get the time of last drip +set -e +time=$(seth call "${DAI_TUB?}" "rho()") +time_unix=$(seth --to-dec "$time") +echo "$time_unix" diff --git a/libexec/dai/dai-s2s b/libexec/dai/dai-s2s new file mode 100644 index 0000000..5ea8bf5 --- /dev/null +++ b/libexec/dai/dai-s2s @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-s2s -- get the peth per dai rate (for boom and bust) +set -e +ray=$(seth call "${DAI_TAP?}" "s2s()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-safe b/libexec/dai/dai-safe new file mode 100644 index 0000000..ba179ac --- /dev/null +++ b/libexec/dai/dai-safe @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +### dai-safe -- determine if a cup is safe +### Usage: dai --cup= safe +set -e +[ ! -z "$DAI_CUP" ] || dai safe --usage +safe=$(seth call "${DAI_TUB?}" 'safe(bytes32)' "${DAI_CUP?}") +seth --abi-decode 'f(bytes32)(bool)' "$safe" diff --git a/libexec/dai/dai-setAxe b/libexec/dai/dai-setAxe new file mode 100644 index 0000000..83d1c7a --- /dev/null +++ b/libexec/dai/dai-setAxe @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-setAxe -- update the liquidation penalty +### Usage: dai setAxe +set -e +[ $# = 1 ] || dai setAxe --usage +ray=$(dai ray -h "$1") +echo >&2 "Setting axe to $ray..." +ray=$(dai ray "$1") +(set -x; seth send "${DAI_MOM?}" "setAxe(uint256)" "$ray") diff --git a/libexec/dai/dai-setCap b/libexec/dai/dai-setCap new file mode 100644 index 0000000..0b24fa0 --- /dev/null +++ b/libexec/dai/dai-setCap @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-setCap -- update the debt ceiling +### Usage: dai setCap +set -e +[ $# = 1 ] || dai setCap --usage +wad=$(dai wad -h "$1") +echo >&2 "Setting cap to $wad..." +wad=$(dai wad "$1") +(set -x; seth send "${DAI_MOM?}" "setCap(uint256)" "$wad") diff --git a/libexec/dai/dai-setFee b/libexec/dai/dai-setFee new file mode 100644 index 0000000..cc85c79 --- /dev/null +++ b/libexec/dai/dai-setFee @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-setFee -- update the stability fee +### Usage: dai setFee +set -e +[ $# = 1 ] || dai setFee --usage +ray=$(dai ray -h "$1") +echo >&2 "Setting fee to $ray..." +ray=$(dai ray "$1") +(set -x; seth send "${DAI_MOM?}" "setFee(uint256)" "$ray") diff --git a/libexec/dai/dai-setMat b/libexec/dai/dai-setMat new file mode 100644 index 0000000..3a87333 --- /dev/null +++ b/libexec/dai/dai-setMat @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-setMat -- update the liquidation ratio +### Usage: dai setMat +set -e +[ $# = 1 ] || dai setMat --usage +ray=$(dai ray -h "$1") +echo >&2 "Setting mat to $ray..." +ray=$(dai ray "$1") +(set -x; seth send "${DAI_MOM?}" "setMat(uint256)" "$ray") diff --git a/libexec/dai/dai-setTapGap b/libexec/dai/dai-setTapGap new file mode 100644 index 0000000..7804b05 --- /dev/null +++ b/libexec/dai/dai-setTapGap @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-setTapGap -- update the spread on `boom` and `bust` +### Usage: dai tapGap +set -e +[ $# = 1 ] || dai tap tapGap --usage +wad=$(dai wad -h "$1") +echo >&2 "Setting gap to $wad..." +wad=$(dai wad "$1") +(set -x; seth send "${DAI_MOM?}" "setTapGap(uint256)" "$wad") diff --git a/libexec/dai/dai-setTax b/libexec/dai/dai-setTax new file mode 100644 index 0000000..3a292f4 --- /dev/null +++ b/libexec/dai/dai-setTax @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-setTax -- update the stability fee +### Usage: dai setTax +set -e +[ $# = 1 ] || dai setTax --usage +ray=$(dai ray -h "$1") +echo >&2 "Setting tax to $ray..." +ray=$(dai ray "$1") +(set -x; seth send "${DAI_MOM?}" "setTax(uint256)" "$ray") diff --git a/libexec/dai/dai-setTubGap b/libexec/dai/dai-setTubGap new file mode 100644 index 0000000..9a07bd2 --- /dev/null +++ b/libexec/dai/dai-setTubGap @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-setTubGap -- update the spread on `join` and `exit` +### Usage: dai setTubGap +set -e +[ $# = 1 ] || dai setTubGap --usage +wad=$(dai wad -h "$1") +echo >&2 "Setting tubGap to $wad..." +wad=$(dai wad "$1") +(set -x; seth send "${DAI_MOM?}" "setTubGap(uint256)" "$wad") diff --git a/libexec/dai/dai-setWay b/libexec/dai/dai-setWay new file mode 100644 index 0000000..2e2c50d --- /dev/null +++ b/libexec/dai/dai-setWay @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +### dai-setWay -- update the holder fee (interest rate) +### Usage: dai setWay +set -e +[ $# = 1 ] || dai setWay --usage +ray=$(dai ray -h "$1") +echo >&2 "Setting way to $ray..." +ray=$(dai ray "$1") +(set -x; seth send "${DAI_MOM}" "setWay(uint256)" "$ray") diff --git a/libexec/dai/dai-shut b/libexec/dai/dai-shut new file mode 100644 index 0000000..6dd7540 --- /dev/null +++ b/libexec/dai/dai-shut @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +### dai-shut -- close a cup +### Usage: dai --cup= shut +set -e +[ ! -z "$DAI_CUP" ] || dai shut --usage +echo >&2 "Closing cup $((${DAI_CUP?}))..." +(set -x; seth send "${DAI_TUB?}" "shut(bytes32)" "$DAI_CUP") diff --git a/libexec/sai/sai-sin b/libexec/dai/dai-sin old mode 100755 new mode 100644 similarity index 52% rename from libexec/sai/sai-sin rename to libexec/dai/dai-sin index e6fb455..755447a --- a/libexec/sai/sai-sin +++ b/libexec/dai/dai-sin @@ -1,5 +1,5 @@ #!/usr/bin/env bash -### sai-sin -- get the sin token +### dai-sin -- get the sin token set -e -sin=$(seth call "${SAI_TUB?}" 'sin()') +sin=$(seth call "${DAI_TUB?}" 'sin()') echo "0x$(seth --abi-decode 'f()(address)' "$sin")" diff --git a/libexec/dai/dai-tab b/libexec/dai/dai-tab new file mode 100644 index 0000000..d3b9e89 --- /dev/null +++ b/libexec/dai/dai-tab @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +### dai-tab -- get the amount of debt in a cup +### Usage: dai --cup= tab +set -e +[ ! -z "$DAI_CUP" ] || dai tab --usage +wad=$(seth call "${DAI_TUB?}" "tab(bytes32)" "${DAI_CUP?}") +dai wad -h "$wad" diff --git a/libexec/dai/dai-tag b/libexec/dai/dai-tag new file mode 100644 index 0000000..5d64eb2 --- /dev/null +++ b/libexec/dai/dai-tag @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-tag -- get the reference price (ref per peth) +set -e +ray=$(seth call "${DAI_TUB?}" "tag()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-tapAsk b/libexec/dai/dai-tapAsk new file mode 100644 index 0000000..6921901 --- /dev/null +++ b/libexec/dai/dai-tapAsk @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +### dai-tapAsk -- get the amount of peth in dai for bust +set -e +[ $# = 1 ] || dai tapAsk --usage +wad=$(seth call "${DAI_TAP?}" "ask(uint256)" $(dai wad "$1")) +dai wad -h "$wad" diff --git a/libexec/dai/dai-tapBid b/libexec/dai/dai-tapBid new file mode 100644 index 0000000..a9e5b10 --- /dev/null +++ b/libexec/dai/dai-tapBid @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +### dai-tapBid -- get the amount of peth in dai for boom +set -e +[ $# = 1 ] || dai tapBid --usage +wad=$(seth call "${DAI_TAP?}" "bid(uint256)" $(dai wad "$1")) +dai wad -h "$wad" diff --git a/libexec/dai/dai-tapGap b/libexec/dai/dai-tapGap new file mode 100644 index 0000000..8acf4d1 --- /dev/null +++ b/libexec/dai/dai-tapGap @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-tapGap -- get the spread on `boom` and `bust` +set -e +wad=$(seth call "${DAI_TAP?}" "gap()") +dai wad -h "$wad" diff --git a/libexec/sai/sai-tau b/libexec/dai/dai-tau old mode 100755 new mode 100644 similarity index 69% rename from libexec/sai/sai-tau rename to libexec/dai/dai-tau index 692a880..a09ba58 --- a/libexec/sai/sai-tau +++ b/libexec/dai/dai-tau @@ -1,7 +1,7 @@ #!/usr/bin/env bash -### sai-tau -- get the time of last prod +### dai-tau -- get the time of last prod set -e -vox=$(seth call "${SAI_TUB?}" 'vox()') +vox=$(seth call "${DAI_TUB?}" 'vox()') vox_address="0x$(seth --abi-decode 'f()(address)' "$vox")" time=$(seth call "$vox_address" "tau()") time_unix=$(seth --to-dec "$time") diff --git a/libexec/dai/dai-tax b/libexec/dai/dai-tax new file mode 100644 index 0000000..ff42fd4 --- /dev/null +++ b/libexec/dai/dai-tax @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-tax -- get the stability fee +set -e +ray=$(seth call "${DAI_TUB?}" "tax()") +dai ray -h "$ray" diff --git a/libexec/dai/dai-tubAsk b/libexec/dai/dai-tubAsk new file mode 100644 index 0000000..0299d43 --- /dev/null +++ b/libexec/dai/dai-tubAsk @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +### dai-tubAsk -- get the amount of peth in gem for join +set -e +[ $# = 1 ] || dai tubAsk --usage +wad=$(seth call "${DAI_TUB?}" "ask(uint256)" $(dai wad "$1")) +dai wad -h "$wad" diff --git a/libexec/dai/dai-tubBid b/libexec/dai/dai-tubBid new file mode 100644 index 0000000..fd602ec --- /dev/null +++ b/libexec/dai/dai-tubBid @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +### dai-tubBid -- get the amount of peth in gem for exit +set -e +[ $# = 1 ] || dai tubBid --usage +wad=$(seth call "${DAI_TUB?}" "bid(uint256)" $(dai wad "$1")) +dai wad -h "$wad" diff --git a/libexec/dai/dai-tubGap b/libexec/dai/dai-tubGap new file mode 100644 index 0000000..bc8f44a --- /dev/null +++ b/libexec/dai/dai-tubGap @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-tubGap -- get the spread on `join` and `exit` +set -e +wad=$(seth call "$DAI_TUB" "gap()") +dai wad -h "$wad" diff --git a/libexec/dai/dai-vent b/libexec/dai/dai-vent new file mode 100644 index 0000000..46094ff --- /dev/null +++ b/libexec/dai/dai-vent @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +### dai-vent -- process a caged tub +set -e +(set -x; seth send "${DAI_TAP?}" "vent()") diff --git a/libexec/dai/dai-vox b/libexec/dai/dai-vox new file mode 100644 index 0000000..38f16de --- /dev/null +++ b/libexec/dai/dai-vox @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-vox -- get the target price engine +set -e +vox=$(seth call "${DAI_TUB?}" 'vox()') +echo "0x$(seth --abi-decode 'f()(address)' "$vox")" diff --git a/libexec/sai/sai-wad b/libexec/dai/dai-wad old mode 100755 new mode 100644 similarity index 81% rename from libexec/sai/sai-wad rename to libexec/dai/dai-wad index ced80e0..3de8140 --- a/libexec/sai/sai-wad +++ b/libexec/dai/dai-wad @@ -1,5 +1,5 @@ #!/usr/bin/env node -/// sai-wad -- parse and display a 18-decimal fixed-point number +/// dai-wad -- parse and display a 18-decimal fixed-point number var BigNumber = require("bignumber.js") var wad = process.argv[2], match var rpad = (x, y, n) => x + repeat(y, n - x.length) @@ -13,11 +13,11 @@ if (match = wad.match(/^(\d+\.)(\d{1,18})$/)) { wad = lpad(new BigNumber(wad).toString(10), "0", 18) wad = wad.replace(/.{18}$/, ".$&").replace(/^\./, "0.") } else { - console.error("sai---wad: error: number must have decimal point") + console.error("dai---wad: error: number must have decimal point") process.exit(1) } -if (process.env.SAI_HUMAN) { +if (process.env.DAI_HUMAN) { console.log(wad) } else { console.log(`0x${lpad(toHex(wad), "0", 64)}`) diff --git a/libexec/sai/sai-way b/libexec/dai/dai-way old mode 100755 new mode 100644 similarity index 54% rename from libexec/sai/sai-way rename to libexec/dai/dai-way index 9d673ed..77a3393 --- a/libexec/sai/sai-way +++ b/libexec/dai/dai-way @@ -1,7 +1,7 @@ #!/usr/bin/env bash -### sai-way -- get the holder fee (interest rate) +### dai-way -- get the holder fee (interest rate) set -e -vox=$(seth call "${SAI_TUB?}" 'vox()') +vox=$(seth call "${DAI_TUB?}" 'vox()') vox_address="0x$(seth --abi-decode 'f()(address)' "$vox")" ray=$(seth call "$vox_address" "way()") -sai ray -h "$ray" +dai ray -h "$ray" diff --git a/libexec/dai/dai-wipe b/libexec/dai/dai-wipe new file mode 100644 index 0000000..734624b --- /dev/null +++ b/libexec/dai/dai-wipe @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +### dai-wipe -- repay some portion of your existing dai debt +### Usage: dai --cup= wipe +set -e +[ $# = 1 ] || dai wipe --usage +[ ! -z "$DAI_CUP" ] || dai wipe --usage +wad=$(dai wad -h "$1") +echo >&2 "Wiping $wad DAI from cup $((${DAI_CUP?}))..." +wad=$(dai wad "$1") +(set -x; seth send "${DAI_TUB?}" "wipe(bytes32,uint256)" "$DAI_CUP" "$wad") diff --git a/libexec/dai/dai-woe b/libexec/dai/dai-woe new file mode 100644 index 0000000..b175d41 --- /dev/null +++ b/libexec/dai/dai-woe @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +### dai-woe -- get the amount of bad debt +set -e +wad=$(seth call "${DAI_TAP?}" "woe()") +dai wad -h "$wad" diff --git a/libexec/sai/node_modules/bignumber.js/LICENCE b/libexec/dai/node_modules/bignumber.js/LICENCE similarity index 100% rename from libexec/sai/node_modules/bignumber.js/LICENCE rename to libexec/dai/node_modules/bignumber.js/LICENCE diff --git a/libexec/sai/node_modules/bignumber.js/README.md b/libexec/dai/node_modules/bignumber.js/README.md similarity index 100% rename from libexec/sai/node_modules/bignumber.js/README.md rename to libexec/dai/node_modules/bignumber.js/README.md diff --git a/libexec/sai/node_modules/bignumber.js/bignumber.js b/libexec/dai/node_modules/bignumber.js/bignumber.js similarity index 100% rename from libexec/sai/node_modules/bignumber.js/bignumber.js rename to libexec/dai/node_modules/bignumber.js/bignumber.js diff --git a/libexec/sai/node_modules/bignumber.js/bignumber.js.map b/libexec/dai/node_modules/bignumber.js/bignumber.js.map similarity index 100% rename from libexec/sai/node_modules/bignumber.js/bignumber.js.map rename to libexec/dai/node_modules/bignumber.js/bignumber.js.map diff --git a/libexec/sai/node_modules/bignumber.js/bignumber.min.js b/libexec/dai/node_modules/bignumber.js/bignumber.min.js similarity index 100% rename from libexec/sai/node_modules/bignumber.js/bignumber.min.js rename to libexec/dai/node_modules/bignumber.js/bignumber.min.js diff --git a/libexec/sai/node_modules/bignumber.js/bower.json b/libexec/dai/node_modules/bignumber.js/bower.json similarity index 100% rename from libexec/sai/node_modules/bignumber.js/bower.json rename to libexec/dai/node_modules/bignumber.js/bower.json diff --git a/libexec/sai/node_modules/bignumber.js/doc/API.html b/libexec/dai/node_modules/bignumber.js/doc/API.html similarity index 100% rename from libexec/sai/node_modules/bignumber.js/doc/API.html rename to libexec/dai/node_modules/bignumber.js/doc/API.html diff --git a/libexec/sai/node_modules/bignumber.js/package.json b/libexec/dai/node_modules/bignumber.js/package.json similarity index 100% rename from libexec/sai/node_modules/bignumber.js/package.json rename to libexec/dai/node_modules/bignumber.js/package.json diff --git a/libexec/sai/sai-air b/libexec/sai/sai-air deleted file mode 100755 index 9267813..0000000 --- a/libexec/sai/sai-air +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-air -- get the amount of backing collateral -set -e -wad=$(seth call "${SAI_TUB?}" "air()") -sai wad -h "$wad" diff --git a/libexec/sai/sai-axe b/libexec/sai/sai-axe deleted file mode 100755 index 4113628..0000000 --- a/libexec/sai/sai-axe +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-axe -- get the liquidation penalty -set -e -ray=$(seth call "${SAI_TUB?}" "axe()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-bite b/libexec/sai/sai-bite deleted file mode 100755 index e670d75..0000000 --- a/libexec/sai/sai-bite +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-bite -- initiate liquidation of an undercollateral cup -### Usage: sai --cup= bite -set -e -[ ! -z "$SAI_CUP" ] || sai bite --usage -echo >&2 "Attempting to bite cup id $((${SAI_CUP?}))..." -safe=$(sai safe) -[[ $safe = true ]] && { echo >&2 "${0##*/}: error: cup not unsafe"; exit 1; } -(set -x; seth send "${SAI_TUB?}" "bite(bytes32)" "$SAI_CUP") diff --git a/libexec/sai/sai-boom b/libexec/sai/sai-boom deleted file mode 100755 index b4e3b0a..0000000 --- a/libexec/sai/sai-boom +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-boom -- buy some amount of sai to process joy (surplus) -### Usage: sai boom -set -e -[ $# = 1 ] || sai boom --usage -wad=$(sai wad -h "$1") -echo >&2 "Buying $wad SKR-worth amount of SAI from the tub in order to process joy..." -wad=$(sai wad "$1") -(set -x; seth send "${SAI_TAP?}" "boom(uint256)" "$wad") diff --git a/libexec/sai/sai-bust b/libexec/sai/sai-bust deleted file mode 100755 index a1f050c..0000000 --- a/libexec/sai/sai-bust +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-bust -- sell some amount of sai to process woe (bad debt) -### Usage: sai bust -set -e -[ $# = 1 ] || sai bust --usage -wad=$(sai wad -h "$1") -echo >&2 "Selling $wad SKR-worth amount of SAI to the tub in order to process woe..." -wad=$(sai wad "$1") -(set -x; seth send "${SAI_TAP?}" "bust(uint256)" "$wad") diff --git a/libexec/sai/sai-caged b/libexec/sai/sai-caged deleted file mode 100755 index 9d04323..0000000 --- a/libexec/sai/sai-caged +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -### sai-caged -- get time of cage event (= 0 if system is not caged) -set -e -echo "$(seth --to-dec $(seth call "${SAI_TOP?}" 'caged()'))" diff --git a/libexec/sai/sai-cap b/libexec/sai/sai-cap deleted file mode 100755 index b2ab5ec..0000000 --- a/libexec/sai/sai-cap +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-cap -- get the debt ceiling -set -e -wad=$(seth call "${SAI_TUB?}" "cap()") -sai wad -h "$wad" diff --git a/libexec/sai/sai-cash b/libexec/sai/sai-cash deleted file mode 100755 index 3135b59..0000000 --- a/libexec/sai/sai-cash +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -### sai-cash -- cash in sai balance for gems after cage -set -e -jam=$(token balance "$(sai sai)" "${ETH_FROM?}") -echo >&2 "Cashing in $jam SAI..." -wad=$(sai wad $jam) -(set -x; seth send "${SAI_TAP?}" "cash(uint256)" $wad ) diff --git a/libexec/sai/sai-chi b/libexec/sai/sai-chi deleted file mode 100755 index e3760dd..0000000 --- a/libexec/sai/sai-chi +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-chi -- get the internal debt price -set -e -ray=$(seth call "${SAI_TUB?}" "chi()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-cup b/libexec/sai/sai-cup deleted file mode 100755 index abe936a..0000000 --- a/libexec/sai/sai-cup +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -### sai-cup -- show the cup info -### Usage: sai --cup= cup -set -e -[ ! -z "$SAI_CUP" ] || sai cup --usage -echo >&2 "cup id $((${SAI_CUP?}))..." -echo "lad: $(sai lad)" -echo "ink: $(sai ink)" -echo "tab: $(sai tab)" -echo "rap: $(sai rap)" diff --git a/libexec/sai/sai-din b/libexec/sai/sai-din deleted file mode 100755 index 47cb3c0..0000000 --- a/libexec/sai/sai-din +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-din -- get the debt backed by CDPs -set -e -wad=$(seth call "${SAI_TUB?}" "din()") -sai wad -h "$wad" diff --git a/libexec/sai/sai-draw b/libexec/sai/sai-draw deleted file mode 100755 index de6589b..0000000 --- a/libexec/sai/sai-draw +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -### sai-draw -- issue the specified amount of sai stablecoins -### Usage: sai --cup= draw -set -e -[ $# = 1 ] || sai draw --usage -[ ! -z "$SAI_CUP" ] || sai draw --usage -wad=$(sai wad -h "$1") -echo >&2 "Drawing $wad SAI from cup $((${SAI_CUP?}))..." -wad=$(sai wad "$1") -(set -x; seth send "${SAI_TUB?}" "draw(bytes32,uint256)" "$SAI_CUP" "$wad") diff --git a/libexec/sai/sai-drip b/libexec/sai/sai-drip deleted file mode 100755 index 344eaa8..0000000 --- a/libexec/sai/sai-drip +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -### sai-drip -- recalculate the internal debt price -set -e -(set -x; seth send "${SAI_TUB?}" "drip()") diff --git a/libexec/sai/sai-exit b/libexec/sai/sai-exit deleted file mode 100755 index 8c93d15..0000000 --- a/libexec/sai/sai-exit +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-exit -- sell SKR for gems -### Usage: sai exit -set -e -[ $# = 1 ] || sai exit --usage -ink=$(sai wad -h "$1") -echo >&2 "Sending $ink SKR to TUB..." -ink=$(sai wad "$1") -(set -x; seth send "${SAI_TUB?}" "exit(uint256)" "$ink") diff --git a/libexec/sai/sai-fee b/libexec/sai/sai-fee deleted file mode 100755 index 56cdcf2..0000000 --- a/libexec/sai/sai-fee +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-fee -- get the governance fee -set -e -ray=$(seth call "${SAI_TUB?}" "fee()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-fit b/libexec/sai/sai-fit deleted file mode 100755 index 97c9b99..0000000 --- a/libexec/sai/sai-fit +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-fit -- get the gem per skr settlement price -set -e -ray=$(seth call "${SAI_TUB?}" "fit()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-fix b/libexec/sai/sai-fix deleted file mode 100755 index 619f869..0000000 --- a/libexec/sai/sai-fix +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-fix -- get the gem per sai settlement price -set -e -ray=$(seth call "${SAI_TOP?}" "fix()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-fog b/libexec/sai/sai-fog deleted file mode 100755 index 9bae86d..0000000 --- a/libexec/sai/sai-fog +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-fog -- get the amount of skr pending liquidation -set -e -wad=$(seth call "${SAI_TAP?}" "fog()") -sai wad -h "$wad" diff --git a/libexec/sai/sai-free b/libexec/sai/sai-free deleted file mode 100755 index 61ace41..0000000 --- a/libexec/sai/sai-free +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -### sai-free -- remove excess SKR collateral from a cup -### Usage: sai --cup= free -set -e -[ $# = 1 ] || sai free --usage -[ ! -z "$SAI_CUP" ] || sai free --usage -wad=$(sai wad -h "$1") -echo >&2 "Freeing $wad SKR from cup $((${SAI_CUP?}))..." -wad=$(sai wad "$1") -(set -x; seth send "${SAI_TUB?}" "free(bytes32,uint256)" "$SAI_CUP" "$wad") diff --git a/libexec/sai/sai-give b/libexec/sai/sai-give deleted file mode 100755 index 4293797..0000000 --- a/libexec/sai/sai-give +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -### sai-give -- transfer ownership of a cup -### Usage: sai --cup= give
-set -e -[ $# = 1 ] || sai give --usage -[ ! -z "$SAI_CUP" ] || sai give --usage -echo >&2 "Giving cup $((${SAI_CUP?})) to \"${1?}\"..." -(set -x; seth send "${SAI_TUB?}" "give(bytes32,address)" "$SAI_CUP" "$1") diff --git a/libexec/sai/sai-heal b/libexec/sai/sai-heal deleted file mode 100755 index 411696b..0000000 --- a/libexec/sai/sai-heal +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -### sai-heal -- cancel debt -set -e -(set -x; seth send "${SAI_TAP?}" "heal()") diff --git a/libexec/sai/sai-ink b/libexec/sai/sai-ink deleted file mode 100755 index c509149..0000000 --- a/libexec/sai/sai-ink +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -### sai-ink -- get the amount of skr collateral locked in a cup -### Usage: sai --cup= ink -set -e -[ ! -z "$SAI_CUP" ] || sai ink --usage -wad=$(seth call "${SAI_TUB?}" "ink(bytes32)" "${SAI_CUP?}") -sai wad -h "$wad" diff --git a/libexec/sai/sai-join b/libexec/sai/sai-join deleted file mode 100755 index a5e4d48..0000000 --- a/libexec/sai/sai-join +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-join -- buy SKR for gems -### Usage: sai join -set -e -[ $# = 1 ] || sai join --usage -jam=$(sai wad -h "$1") -echo >&2 "Generating $jam SKR depositing GEM..." -jam=$(sai wad "$1") -(set -x; seth send "${SAI_TUB?}" "join(uint256)" "$jam") diff --git a/libexec/sai/sai-joy b/libexec/sai/sai-joy deleted file mode 100755 index d19ac49..0000000 --- a/libexec/sai/sai-joy +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-joy -- get the amount of surplus sai -set -e -wad=$(seth call "${SAI_TAP?}" "joy()") -sai wad -h "$wad" diff --git a/libexec/sai/sai-lad b/libexec/sai/sai-lad deleted file mode 100755 index e981ccd..0000000 --- a/libexec/sai/sai-lad +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -### sai-lad -- get the owner of a cup -### Usage: sai --cup= lad -set -e -[ ! -z "$SAI_CUP" ] || sai lad --usage -lad=$(seth call "${SAI_TUB?}" 'lad(bytes32)' "${SAI_CUP?}") -echo "0x$(seth --abi-decode 'f()(address)' "$lad")" diff --git a/libexec/sai/sai-lock b/libexec/sai/sai-lock deleted file mode 100755 index adf61ba..0000000 --- a/libexec/sai/sai-lock +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -### sai-lock -- post additional SKR collateral to a cup -### Usage: sai --cup= lock -set -e -[ $# = 1 ] || sai lock --usage -[ ! -z "$SAI_CUP" ] || sai lock --usage -wad=$(sai wad -h "$1") -echo >&2 "Locking $wad SKR in cup $((${SAI_CUP?}))..." -wad=$(sai wad "$1") -(set -x; seth send "${SAI_TUB?}" "lock(bytes32,uint256)" "$SAI_CUP" "$wad") diff --git a/libexec/sai/sai-mat b/libexec/sai/sai-mat deleted file mode 100755 index 0ff366e..0000000 --- a/libexec/sai/sai-mat +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-mat -- get the liquidation ratio -set -e -ray=$(seth call "${SAI_TUB?}" "mat()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-off b/libexec/sai/sai-off deleted file mode 100755 index 0bcff4f..0000000 --- a/libexec/sai/sai-off +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -### sai-off -- get the cage flag -set -e -seth call "${SAI_TUB?}" "off()(bool)" diff --git a/libexec/sai/sai-out b/libexec/sai/sai-out deleted file mode 100755 index 45a72e0..0000000 --- a/libexec/sai/sai-out +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -### sai-out -- get the post cage exit flag -set -e -seth call "${SAI_TUB?}" "out()(bool)" diff --git a/libexec/sai/sai-per b/libexec/sai/sai-per deleted file mode 100755 index 30078ce..0000000 --- a/libexec/sai/sai-per +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-per -- get the current entry price (gem per skr) -set -e -ray=$(seth call "${SAI_TUB?}" "per()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-pie b/libexec/sai/sai-pie deleted file mode 100755 index 13a25e2..0000000 --- a/libexec/sai/sai-pie +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-pie -- get the amount of raw collateral -set -e -wad=$(seth call "${SAI_TUB?}" "pie()") -sai wad -h "$wad" diff --git a/libexec/sai/sai-rap b/libexec/sai/sai-rap deleted file mode 100755 index 495b929..0000000 --- a/libexec/sai/sai-rap +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -### sai-rap -- get the amount of governance debt -### Usage: sai --cup= rap -set -e -[ ! -z "$SAI_CUP" ] || sai rap --usage -wad=$(seth call "${SAI_TUB?}" "rap(bytes32)" "${SAI_CUP?}") -sai wad -h "$wad" diff --git a/libexec/sai/sai-rhi b/libexec/sai/sai-rhi deleted file mode 100755 index 7794ccd..0000000 --- a/libexec/sai/sai-rhi +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-rhi -- get the internal debt price including governance fee -set -e -ray=$(seth call "${SAI_TUB?}" "rhi()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-rho b/libexec/sai/sai-rho deleted file mode 100755 index 221675e..0000000 --- a/libexec/sai/sai-rho +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -### sai-rho -- get the time of last drip -set -e -time=$(seth call "${SAI_TUB?}" "rho()") -time_unix=$(seth --to-dec "$time") -echo "$time_unix" diff --git a/libexec/sai/sai-s2s b/libexec/sai/sai-s2s deleted file mode 100755 index 29d4b3c..0000000 --- a/libexec/sai/sai-s2s +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-s2s -- get the skr per sai rate (for boom and bust) -set -e -ray=$(seth call "${SAI_TAP?}" "s2s()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-safe b/libexec/sai/sai-safe deleted file mode 100755 index 72dbbda..0000000 --- a/libexec/sai/sai-safe +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -### sai-safe -- determine if a cup is safe -### Usage: sai --cup= safe -set -e -[ ! -z "$SAI_CUP" ] || sai safe --usage -safe=$(seth call "${SAI_TUB?}" 'safe(bytes32)' "${SAI_CUP?}") -seth --abi-decode 'f(bytes32)(bool)' "$safe" diff --git a/libexec/sai/sai-sai b/libexec/sai/sai-sai deleted file mode 100755 index fe02cfa..0000000 --- a/libexec/sai/sai-sai +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-sai -- get the sai token -set -e -sai=$(seth call "${SAI_TUB?}" 'sai()') -echo "0x$(seth --abi-decode 'f()(address)' "$sai")" diff --git a/libexec/sai/sai-setAxe b/libexec/sai/sai-setAxe deleted file mode 100755 index 2f1926f..0000000 --- a/libexec/sai/sai-setAxe +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-setAxe -- update the liquidation penalty -### Usage: sai setAxe -set -e -[ $# = 1 ] || sai setAxe --usage -ray=$(sai ray -h "$1") -echo >&2 "Setting axe to $ray..." -ray=$(sai ray "$1") -(set -x; seth send "${SAI_MOM?}" "setAxe(uint256)" "$ray") diff --git a/libexec/sai/sai-setCap b/libexec/sai/sai-setCap deleted file mode 100755 index c592213..0000000 --- a/libexec/sai/sai-setCap +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-setCap -- update the debt ceiling -### Usage: sai setCap -set -e -[ $# = 1 ] || sai setCap --usage -wad=$(sai wad -h "$1") -echo >&2 "Setting cap to $wad..." -wad=$(sai wad "$1") -(set -x; seth send "${SAI_MOM?}" "setCap(uint256)" "$wad") diff --git a/libexec/sai/sai-setFee b/libexec/sai/sai-setFee deleted file mode 100755 index 846554c..0000000 --- a/libexec/sai/sai-setFee +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-setFee -- update the stability fee -### Usage: sai setFee -set -e -[ $# = 1 ] || sai setFee --usage -ray=$(sai ray -h "$1") -echo >&2 "Setting fee to $ray..." -ray=$(sai ray "$1") -(set -x; seth send "${SAI_MOM?}" "setFee(uint256)" "$ray") diff --git a/libexec/sai/sai-setMat b/libexec/sai/sai-setMat deleted file mode 100755 index 4108799..0000000 --- a/libexec/sai/sai-setMat +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-setMat -- update the liquidation ratio -### Usage: sai setMat -set -e -[ $# = 1 ] || sai setMat --usage -ray=$(sai ray -h "$1") -echo >&2 "Setting mat to $ray..." -ray=$(sai ray "$1") -(set -x; seth send "${SAI_MOM?}" "setMat(uint256)" "$ray") diff --git a/libexec/sai/sai-setTapGap b/libexec/sai/sai-setTapGap deleted file mode 100755 index 5073aa1..0000000 --- a/libexec/sai/sai-setTapGap +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-setTapGap -- update the spread on `boom` and `bust` -### Usage: sai tapGap -set -e -[ $# = 1 ] || sai tap tapGap --usage -wad=$(sai wad -h "$1") -echo >&2 "Setting gap to $wad..." -wad=$(sai wad "$1") -(set -x; seth send "${SAI_MOM?}" "setTapGap(uint256)" "$wad") diff --git a/libexec/sai/sai-setTax b/libexec/sai/sai-setTax deleted file mode 100755 index b0f5254..0000000 --- a/libexec/sai/sai-setTax +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-setTax -- update the stability fee -### Usage: sai setTax -set -e -[ $# = 1 ] || sai setTax --usage -ray=$(sai ray -h "$1") -echo >&2 "Setting tax to $ray..." -ray=$(sai ray "$1") -(set -x; seth send "${SAI_MOM?}" "setTax(uint256)" "$ray") diff --git a/libexec/sai/sai-setTubGap b/libexec/sai/sai-setTubGap deleted file mode 100755 index 2edaccf..0000000 --- a/libexec/sai/sai-setTubGap +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-setTubGap -- update the spread on `join` and `exit` -### Usage: sai setTubGap -set -e -[ $# = 1 ] || sai setTubGap --usage -wad=$(sai wad -h "$1") -echo >&2 "Setting tubGap to $wad..." -wad=$(sai wad "$1") -(set -x; seth send "${SAI_MOM?}" "setTubGap(uint256)" "$wad") diff --git a/libexec/sai/sai-setWay b/libexec/sai/sai-setWay deleted file mode 100755 index abaed63..0000000 --- a/libexec/sai/sai-setWay +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -### sai-setWay -- update the holder fee (interest rate) -### Usage: sai setWay -set -e -[ $# = 1 ] || sai setWay --usage -ray=$(sai ray -h "$1") -echo >&2 "Setting way to $ray..." -ray=$(sai ray "$1") -(set -x; seth send "${SAI_MOM}" "setWay(uint256)" "$ray") diff --git a/libexec/sai/sai-shut b/libexec/sai/sai-shut deleted file mode 100755 index ea5f908..0000000 --- a/libexec/sai/sai-shut +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -### sai-shut -- close a cup -### Usage: sai --cup= shut -set -e -[ ! -z "$SAI_CUP" ] || sai shut --usage -echo >&2 "Closing cup $((${SAI_CUP?}))..." -(set -x; seth send "${SAI_TUB?}" "shut(bytes32)" "$SAI_CUP") diff --git a/libexec/sai/sai-skr b/libexec/sai/sai-skr deleted file mode 100755 index 823899f..0000000 --- a/libexec/sai/sai-skr +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-skr -- get the skr token -set -e -skr=$(seth call "${SAI_TUB?}" 'skr()') -echo "0x$(seth --abi-decode 'f()(address)' "$skr")" diff --git a/libexec/sai/sai-tab b/libexec/sai/sai-tab deleted file mode 100755 index 473f343..0000000 --- a/libexec/sai/sai-tab +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -### sai-tab -- get the amount of debt in a cup -### Usage: sai --cup= tab -set -e -[ ! -z "$SAI_CUP" ] || sai tab --usage -wad=$(seth call "${SAI_TUB?}" "tab(bytes32)" "${SAI_CUP?}") -sai wad -h "$wad" diff --git a/libexec/sai/sai-tag b/libexec/sai/sai-tag deleted file mode 100755 index de9eafc..0000000 --- a/libexec/sai/sai-tag +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-tag -- get the reference price (ref per skr) -set -e -ray=$(seth call "${SAI_TUB?}" "tag()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-tapAsk b/libexec/sai/sai-tapAsk deleted file mode 100755 index 9fec812..0000000 --- a/libexec/sai/sai-tapAsk +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -### sai-tapAsk -- get the amount of skr in sai for bust -set -e -[ $# = 1 ] || sai tapAsk --usage -wad=$(seth call "${SAI_TAP?}" "ask(uint256)" $(sai wad "$1")) -sai wad -h "$wad" diff --git a/libexec/sai/sai-tapBid b/libexec/sai/sai-tapBid deleted file mode 100755 index 0f05f70..0000000 --- a/libexec/sai/sai-tapBid +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -### sai-tapBid -- get the amount of skr in sai for boom -set -e -[ $# = 1 ] || sai tapBid --usage -wad=$(seth call "${SAI_TAP?}" "bid(uint256)" $(sai wad "$1")) -sai wad -h "$wad" diff --git a/libexec/sai/sai-tapGap b/libexec/sai/sai-tapGap deleted file mode 100755 index 9d17983..0000000 --- a/libexec/sai/sai-tapGap +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-tapGap -- get the spread on `boom` and `bust` -set -e -wad=$(seth call "${SAI_TAP?}" "gap()") -sai wad -h "$wad" diff --git a/libexec/sai/sai-tax b/libexec/sai/sai-tax deleted file mode 100755 index 18d24d5..0000000 --- a/libexec/sai/sai-tax +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-tax -- get the stability fee -set -e -ray=$(seth call "${SAI_TUB?}" "tax()") -sai ray -h "$ray" diff --git a/libexec/sai/sai-tubAsk b/libexec/sai/sai-tubAsk deleted file mode 100755 index 8774471..0000000 --- a/libexec/sai/sai-tubAsk +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -### sai-tubAsk -- get the amount of skr in gem for join -set -e -[ $# = 1 ] || sai tubAsk --usage -wad=$(seth call "${SAI_TUB?}" "ask(uint256)" $(sai wad "$1")) -sai wad -h "$wad" diff --git a/libexec/sai/sai-tubBid b/libexec/sai/sai-tubBid deleted file mode 100755 index 54ccce2..0000000 --- a/libexec/sai/sai-tubBid +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -### sai-tubBid -- get the amount of skr in gem for exit -set -e -[ $# = 1 ] || sai tubBid --usage -wad=$(seth call "${SAI_TUB?}" "bid(uint256)" $(sai wad "$1")) -sai wad -h "$wad" diff --git a/libexec/sai/sai-tubGap b/libexec/sai/sai-tubGap deleted file mode 100755 index bf4ab17..0000000 --- a/libexec/sai/sai-tubGap +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-tubGap -- get the spread on `join` and `exit` -set -e -wad=$(seth call "$SAI_TUB" "gap()") -sai wad -h "$wad" diff --git a/libexec/sai/sai-vent b/libexec/sai/sai-vent deleted file mode 100755 index f497c01..0000000 --- a/libexec/sai/sai-vent +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -### sai-vent -- process a caged tub -set -e -(set -x; seth send "${SAI_TAP?}" "vent()") diff --git a/libexec/sai/sai-vox b/libexec/sai/sai-vox deleted file mode 100755 index 1a93aa6..0000000 --- a/libexec/sai/sai-vox +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-vox -- get the target price engine -set -e -vox=$(seth call "${SAI_TUB?}" 'vox()') -echo "0x$(seth --abi-decode 'f()(address)' "$vox")" diff --git a/libexec/sai/sai-wipe b/libexec/sai/sai-wipe deleted file mode 100755 index b56c86f..0000000 --- a/libexec/sai/sai-wipe +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -### sai-wipe -- repay some portion of your existing sai debt -### Usage: sai --cup= wipe -set -e -[ $# = 1 ] || sai wipe --usage -[ ! -z "$SAI_CUP" ] || sai wipe --usage -wad=$(sai wad -h "$1") -echo >&2 "Wiping $wad SAI from cup $((${SAI_CUP?}))..." -wad=$(sai wad "$1") -(set -x; seth send "${SAI_TUB?}" "wipe(bytes32,uint256)" "$SAI_CUP" "$wad") diff --git a/libexec/sai/sai-woe b/libexec/sai/sai-woe deleted file mode 100755 index b64d04b..0000000 --- a/libexec/sai/sai-woe +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -### sai-woe -- get the amount of bad debt -set -e -wad=$(seth call "${SAI_TAP?}" "woe()") -sai wad -h "$wad" diff --git a/src/sai.t.sol b/src/dai.t.sol similarity index 70% rename from src/sai.t.sol rename to src/dai.t.sol index 948b926..ec15db2 100644 --- a/src/sai.t.sol +++ b/src/dai.t.sol @@ -30,27 +30,27 @@ contract TestWarp is DSNote { } } -contract DevTub is SaiTub, TestWarp { +contract DevTub is DaiTub, TestWarp { function DevTub( - DSToken sai_, + DSToken dai_, DSToken sin_, - DSToken skr_, + DSToken peth_, ERC20 gem_, DSToken gov_, DSValue pip_, DSValue pep_, - SaiVox vox_, + DaiVox vox_, address pit_ ) public - SaiTub(sai_, sin_, skr_, gem_, gov_, pip_, pep_, vox_, pit_) {} + DaiTub(dai_, sin_, peth_, gem_, gov_, pip_, pep_, vox_, pit_) {} } -contract DevTop is SaiTop, TestWarp { - function DevTop(SaiTub tub_, SaiTap tap_) public SaiTop(tub_, tap_) {} +contract DevTop is DaiTop, TestWarp { + function DevTop(DaiTub tub_, DaiTap tap_) public DaiTop(tub_, tap_) {} } -contract DevVox is SaiVox, TestWarp { - function DevVox(uint par_) SaiVox(par_) public {} +contract DevVox is DaiVox, TestWarp { + function DevVox(uint par_) DaiVox(par_) public {} } contract DevVoxFab { @@ -61,14 +61,14 @@ contract DevVoxFab { } contract DevTubFab { - function newTub(DSToken sai, DSToken sin, DSToken skr, DSToken gem, DSToken gov, DSValue pip, DSValue pep, SaiVox vox, address pit) public returns (DevTub tub) { - tub = new DevTub(sai, sin, skr, gem, gov, pip, pep, vox, pit); + function newTub(DSToken dai, DSToken sin, DSToken peth, DSToken gem, DSToken gov, DSValue pip, DSValue pep, DaiVox vox, address pit) public returns (DevTub tub) { + tub = new DevTub(dai, sin, peth, gem, gov, pip, pep, vox, pit); tub.setOwner(msg.sender); } } contract DevTopFab { - function newTop(DevTub tub, SaiTap tap) public returns (DevTop top) { + function newTop(DevTub tub, DaiTap tap) public returns (DevTop top) { top = new DevTop(tub, tap); top.setOwner(msg.sender); } @@ -78,49 +78,49 @@ contract DevDadFab { function newDad() public returns (DSGuard dad) { dad = new DSGuard(); // convenience in tests - dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).sai(), bytes4(keccak256('mint(uint256)'))); - dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).sai(), bytes4(keccak256('burn(uint256)'))); - dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).sai(), bytes4(keccak256('mint(address,uint256)'))); - dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).sai(), bytes4(keccak256('burn(address,uint256)'))); + dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).dai(), bytes4(keccak256('mint(uint256)'))); + dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).dai(), bytes4(keccak256('burn(uint256)'))); + dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).dai(), bytes4(keccak256('mint(address,uint256)'))); + dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).dai(), bytes4(keccak256('burn(address,uint256)'))); dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).sin(), bytes4(keccak256('mint(uint256)'))); dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).sin(), bytes4(keccak256('burn(uint256)'))); dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).sin(), bytes4(keccak256('mint(address,uint256)'))); dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).sin(), bytes4(keccak256('burn(address,uint256)'))); - dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).skr(), bytes4(keccak256('mint(uint256)'))); - dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).skr(), bytes4(keccak256('burn(uint256)'))); - dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).skr(), bytes4(keccak256('mint(address,uint256)'))); - dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).skr(), bytes4(keccak256('burn(address,uint256)'))); + dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).peth(), bytes4(keccak256('mint(uint256)'))); + dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).peth(), bytes4(keccak256('burn(uint256)'))); + dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).peth(), bytes4(keccak256('mint(address,uint256)'))); + dad.permit(DaiFab(msg.sender).owner(), DaiFab(msg.sender).peth(), bytes4(keccak256('burn(address,uint256)'))); dad.setOwner(msg.sender); } } contract FakePerson { - SaiTap public tap; - DSToken public sai; + DaiTap public tap; + DSToken public dai; - function FakePerson(SaiTap _tap) public { + function FakePerson(DaiTap _tap) public { tap = _tap; - sai = tap.sai(); - sai.approve(tap); + dai = tap.dai(); + dai.approve(tap); } function cash() public { - tap.cash(sai.balanceOf(this)); + tap.cash(dai.balanceOf(this)); } } -contract SaiTestBase is DSTest, DSMath { +contract DaiTestBase is DSTest, DSMath { DevVox vox; DevTub tub; DevTop top; - SaiTap tap; + DaiTap tap; - SaiMom mom; + DaiMom mom; WETH9 gem; - DSToken sai; + DSToken dai; DSToken sin; - DSToken skr; + DSToken peth; DSToken gov; GemPit pit; @@ -176,23 +176,23 @@ contract SaiTestBase is DSTest, DSMath { authority.setRootUser(this, true); daiFab.configAuth(authority); - sai = DSToken(daiFab.sai()); + dai = DSToken(daiFab.dai()); sin = DSToken(daiFab.sin()); - skr = DSToken(daiFab.skr()); + peth = DSToken(daiFab.peth()); vox = DevVox(daiFab.vox()); tub = DevTub(daiFab.tub()); - tap = SaiTap(daiFab.tap()); + tap = DaiTap(daiFab.tap()); top = DevTop(daiFab.top()); - mom = SaiMom(daiFab.mom()); + mom = DaiMom(daiFab.mom()); dad = DSRoles(daiFab.dad()); - sai.approve(tub); - skr.approve(tub); + dai.approve(tub); + peth.approve(tub); gem.approve(tub, uint(-1)); gov.approve(tub); - sai.approve(tap); - skr.approve(tap); + dai.approve(tap); + peth.approve(tap); mark(1 ether); mark(gov, 1 ether); @@ -207,10 +207,10 @@ contract SaiTestBase is DSTest, DSMath { } } -contract SaiTubTest is SaiTestBase { +contract DaiTubTest is DaiTestBase { function testBasic() public { - assertEq( skr.balanceOf(tub), 0 ether ); - assertEq( skr.balanceOf(this), 0 ether ); + assertEq( peth.balanceOf(tub), 0 ether ); + assertEq( peth.balanceOf(this), 0 ether ); assertEq( gem.balanceOf(tub), 0 ether ); // edge case @@ -218,36 +218,36 @@ contract SaiTubTest is SaiTestBase { tub.join(10 ether); assertEq( uint256(tub.per()), ray(1 ether) ); - assertEq( skr.balanceOf(this), 10 ether ); + assertEq( peth.balanceOf(this), 10 ether ); assertEq( gem.balanceOf(tub), 10 ether ); // price formula tub.join(10 ether); assertEq( uint256(tub.per()), ray(1 ether) ); - assertEq( skr.balanceOf(this), 20 ether ); + assertEq( peth.balanceOf(this), 20 ether ); assertEq( gem.balanceOf(tub), 20 ether ); var cup = tub.open(); - assertEq( skr.balanceOf(this), 20 ether ); - assertEq( skr.balanceOf(tub), 0 ether ); - tub.lock(cup, 10 ether); // lock skr token - assertEq( skr.balanceOf(this), 10 ether ); - assertEq( skr.balanceOf(tub), 10 ether ); + assertEq( peth.balanceOf(this), 20 ether ); + assertEq( peth.balanceOf(tub), 0 ether ); + tub.lock(cup, 10 ether); // lock peth token + assertEq( peth.balanceOf(this), 10 ether ); + assertEq( peth.balanceOf(tub), 10 ether ); - assertEq( sai.balanceOf(this), 0 ether); + assertEq( dai.balanceOf(this), 0 ether); tub.draw(cup, 5 ether); - assertEq( sai.balanceOf(this), 5 ether); + assertEq( dai.balanceOf(this), 5 ether); - assertEq( sai.balanceOf(this), 5 ether); + assertEq( dai.balanceOf(this), 5 ether); tub.wipe(cup, 2 ether); - assertEq( sai.balanceOf(this), 3 ether); + assertEq( dai.balanceOf(this), 3 ether); - assertEq( sai.balanceOf(this), 3 ether); - assertEq( skr.balanceOf(this), 10 ether ); + assertEq( dai.balanceOf(this), 3 ether); + assertEq( peth.balanceOf(this), 10 ether ); tub.shut(cup); - assertEq( sai.balanceOf(this), 0 ether); - assertEq( skr.balanceOf(this), 20 ether ); + assertEq( dai.balanceOf(this), 0 ether); + assertEq( peth.balanceOf(this), 20 ether ); } function testGive() public { var cup = tub.open(); @@ -299,34 +299,34 @@ contract SaiTubTest is SaiTestBase { assertTrue(tub.vox() == address(0x3)); } function testJoinInitial() public { - assertEq(skr.totalSupply(), 0 ether); - assertEq(skr.balanceOf(this), 0 ether); + assertEq(peth.totalSupply(), 0 ether); + assertEq(peth.balanceOf(this), 0 ether); assertEq(gem.balanceOf(this), 100 ether); tub.join(10 ether); - assertEq(skr.balanceOf(this), 10 ether); + assertEq(peth.balanceOf(this), 10 ether); assertEq(gem.balanceOf(this), 90 ether); assertEq(gem.balanceOf(tub), 10 ether); } function testJoinExit() public { - assertEq(skr.balanceOf(this), 0 ether); + assertEq(peth.balanceOf(this), 0 ether); assertEq(gem.balanceOf(this), 100 ether); tub.join(10 ether); - assertEq(skr.balanceOf(this), 10 ether); + assertEq(peth.balanceOf(this), 10 ether); assertEq(gem.balanceOf(this), 90 ether); assertEq(gem.balanceOf(tub), 10 ether); tub.exit(5 ether); - assertEq(skr.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 5 ether); assertEq(gem.balanceOf(this), 95 ether); assertEq(gem.balanceOf(tub), 5 ether); tub.join(2 ether); - assertEq(skr.balanceOf(this), 7 ether); + assertEq(peth.balanceOf(this), 7 ether); assertEq(gem.balanceOf(this), 93 ether); assertEq(gem.balanceOf(tub), 7 ether); tub.exit(1 ether); - assertEq(skr.balanceOf(this), 6 ether); + assertEq(peth.balanceOf(this), 6 ether); assertEq(gem.balanceOf(this), 94 ether); assertEq(gem.balanceOf(tub), 6 ether); } @@ -352,9 +352,9 @@ contract SaiTubTest is SaiTestBase { var cup = tub.open(); tub.lock(cup, 10 ether); - assertEq(sai.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(this), 0 ether); tub.draw(cup, 10 ether); - assertEq(sai.balanceOf(this), 10 ether); + assertEq(dai.balanceOf(this), 10 ether); } function testWipe() public { mom.setMat(ray(1 ether)); @@ -363,9 +363,9 @@ contract SaiTubTest is SaiTestBase { tub.lock(cup, 10 ether); tub.draw(cup, 10 ether); - assertEq(sai.balanceOf(this), 10 ether); + assertEq(dai.balanceOf(this), 10 ether); tub.wipe(cup, 5 ether); - assertEq(sai.balanceOf(this), 5 ether); + assertEq(dai.balanceOf(this), 5 ether); } function testUnsafe() public { tub.join(10 ether); @@ -410,18 +410,18 @@ contract SaiTubTest is SaiTestBase { assertEq(tap.fog(), 8 ether); assertEq(tap.woe(), 4 ether); - // cdp should now be safe with 0 sai debt and 2 skr remaining - var skr_before = skr.balanceOf(this); + // cdp should now be safe with 0 dai debt and 2 peth remaining + var peth_before = peth.balanceOf(this); tub.free(cup, 1 ether); - assertEq(skr.balanceOf(this) - skr_before, 1 ether); + assertEq(peth.balanceOf(this) - peth_before, 1 ether); } function testLock() public { tub.join(10 ether); var cup = tub.open(); - assertEq(skr.balanceOf(tub), 0 ether); + assertEq(peth.balanceOf(tub), 0 ether); tub.lock(cup, 10 ether); - assertEq(skr.balanceOf(tub), 10 ether); + assertEq(peth.balanceOf(tub), 10 ether); } function testFree() public { mom.setMat(ray(2 ether)); // require 200% collateralisation @@ -430,9 +430,9 @@ contract SaiTubTest is SaiTestBase { tub.lock(cup, 10 ether); tub.draw(cup, 4 ether); // 250% collateralisation - var skr_before = skr.balanceOf(this); + var peth_before = peth.balanceOf(this); tub.free(cup, 2 ether); // 225% - assertEq(skr.balanceOf(this) - skr_before, 2 ether); + assertEq(peth.balanceOf(this) - peth_before, 2 ether); } function testFailFreeToUnderCollat() public { mom.setMat(ray(2 ether)); // require 200% collateralisation @@ -468,15 +468,15 @@ contract SaiTubTest is SaiTestBase { assertEq(tap.fog(), uint(10 ether)); tub.join(10 ether); - // skr hasn't been diluted yet so still 1:1 skr:gem - assertEq(skr.balanceOf(this), 10 ether); + // peth hasn't been diluted yet so still 1:1 peth:gem + assertEq(peth.balanceOf(this), 10 ether); } } -contract CageTest is SaiTestBase { +contract CageTest is DaiTestBase { // ensure cage sets the settle prices right function cageSetup() public returns (bytes32) { - mom.setCap(5 ether); // 5 sai debt ceiling + mom.setCap(5 ether); // 5 dai debt ceiling mark(1 ether); // price 1:1 gem:ref mom.setMat(ray(2 ether)); // require 200% collat tub.join(10 ether); @@ -494,16 +494,16 @@ contract CageTest is SaiTestBase { assertEq(tap.woe(), 0); // no bad debt assertEq(tub.pie(), 10 ether); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth mark(1 ether); top.cage(); assertEq(tub.din(), 5 ether); // debt remains in tub - assertEq(wad(top.fix()), 1 ether); // sai redeems 1:1 with gem - assertEq(wad(tub.fit()), 1 ether); // skr redeems 1:1 with gem just before pushing gem to tub + assertEq(wad(top.fix()), 1 ether); // dai redeems 1:1 with gem + assertEq(wad(tub.fit()), 1 ether); // peth redeems 1:1 with gem just before pushing gem to tub - assertEq(gem.balanceOf(tap), 5 ether); // saved for sai - assertEq(gem.balanceOf(tub), 25 ether); // saved for skr + assertEq(gem.balanceOf(tap), 5 ether); // saved for dai + assertEq(gem.balanceOf(tub), 25 ether); // saved for peth } function testCageUnsafeOverCollat() public { cageSetup(); @@ -512,18 +512,18 @@ contract CageTest is SaiTestBase { assertEq(tub.fit(), 0); assertEq(tub.per(), ray(1 ether)); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth var price = wdiv(3 ether, 4 ether); mark(price); top.cage(); // 150% collat - assertEq(top.fix(), rdiv(1 ether, price)); // sai redeems 4:3 with gem - assertEq(tub.fit(), ray(price)); // skr redeems 1:1 with gem just before pushing gem to tub + assertEq(top.fix(), rdiv(1 ether, price)); // dai redeems 4:3 with gem + assertEq(tub.fit(), ray(price)); // peth redeems 1:1 with gem just before pushing gem to tub - // gem needed for sai is 5 * 4 / 3 + // gem needed for dai is 5 * 4 / 3 var saved = rmul(5 ether, rdiv(WAD, price)); - assertEq(gem.balanceOf(tap), saved); // saved for sai - assertEq(gem.balanceOf(tub), 30 ether - saved); // saved for skr + assertEq(gem.balanceOf(tap), saved); // saved for dai + assertEq(gem.balanceOf(tub), 30 ether - saved); // saved for peth } function testCageAtCollat() public { cageSetup(); @@ -536,23 +536,23 @@ contract CageTest is SaiTestBase { mark(price); top.cage(); - assertEq(top.fix(), ray(2 ether)); // sai redeems 1:2 with gem, 1:1 with ref - assertEq(tub.per(), 0); // skr redeems 1:0 with gem after cage + assertEq(top.fix(), ray(2 ether)); // dai redeems 1:2 with gem, 1:1 with ref + assertEq(tub.per(), 0); // peth redeems 1:0 with gem after cage } - function testCageAtCollatFreeSkr() public { + function testCageAtCollatFreePeth() public { cageSetup(); assertEq(top.fix(), 0); assertEq(tub.fit(), 0); assertEq(tub.per(), ray(1 ether)); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth var price = wdiv(1 ether, 2 ether); // 100% collat mark(price); top.cage(); - assertEq(top.fix(), ray(2 ether)); // sai redeems 1:2 with gem, 1:1 with ref - assertEq(tub.fit(), ray(price)); // skr redeems 1:1 with gem just before pushing gem to tub + assertEq(top.fix(), ray(2 ether)); // dai redeems 1:2 with gem, 1:1 with ref + assertEq(tub.fit(), ray(price)); // peth redeems 1:1 with gem just before pushing gem to tub } function testCageUnderCollat() public { cageSetup(); @@ -565,30 +565,30 @@ contract CageTest is SaiTestBase { mark(price); top.cage(); - assertEq(2 * sai.totalSupply(), gem.balanceOf(tap)); - assertEq(top.fix(), ray(2 ether)); // sai redeems 1:2 with gem, 2:1 with ref - assertEq(tub.per(), 0); // skr redeems 1:0 with gem after cage + assertEq(2 * dai.totalSupply(), gem.balanceOf(tap)); + assertEq(top.fix(), ray(2 ether)); // dai redeems 1:2 with gem, 2:1 with ref + assertEq(tub.per(), 0); // peth redeems 1:0 with gem after cage } - function testCageUnderCollatFreeSkr() public { + function testCageUnderCollatFreePeth() public { cageSetup(); assertEq(top.fix(), 0); assertEq(tub.fit(), 0); assertEq(tub.per(), ray(1 ether)); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth var price = wdiv(1 ether, 4 ether); // 50% collat mark(price); top.cage(); - assertEq(4 * sai.totalSupply(), gem.balanceOf(tap)); - assertEq(top.fix(), ray(4 ether)); // sai redeems 1:4 with gem, 1:1 with ref + assertEq(4 * dai.totalSupply(), gem.balanceOf(tap)); + assertEq(top.fix(), ray(4 ether)); // dai redeems 1:4 with gem, 1:1 with ref } - function testCageNoSai() public { + function testCageNoDai() public { var cup = cageSetup(); tub.wipe(cup, 5 ether); - assertEq(sai.totalSupply(), 0); + assertEq(dai.totalSupply(), 0); top.cage(); assertEq(top.fix(), ray(1 ether)); @@ -600,20 +600,20 @@ contract CageTest is SaiTestBase { gem.deposit.value(1000 ether)(); gem.approve(tap, uint(-1)); tap.mock(1000 ether); - assertEq(sai.balanceOf(this), 1005 ether); + assertEq(dai.balanceOf(this), 1005 ether); assertEq(gem.balanceOf(tap), 1005 ether); } - function testMockNoSai() public { + function testMockNoDai() public { var cup = cageSetup(); tub.wipe(cup, 5 ether); - assertEq(sai.totalSupply(), 0); + assertEq(dai.totalSupply(), 0); top.cage(); gem.deposit.value(1000 ether)(); gem.approve(tap, uint(-1)); tap.mock(1000 ether); - assertEq(sai.balanceOf(this), 1000 ether); + assertEq(dai.balanceOf(this), 1000 ether); assertEq(gem.balanceOf(tap), 1000 ether); } @@ -623,15 +623,15 @@ contract CageTest is SaiTestBase { mark(1 ether); top.cage(); - assertEq(sai.balanceOf(this), 5 ether); - assertEq(skr.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 0 ether); assertEq(gem.balanceOf(this), 90 ether); assertEq(gem.balanceOf(tub), 5 ether); assertEq(gem.balanceOf(tap), 5 ether); - tap.cash(sai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); - assertEq(skr.balanceOf(this), 0 ether); + tap.cash(dai.balanceOf(this)); + assertEq(dai.balanceOf(this), 0 ether); + assertEq(peth.balanceOf(this), 0 ether); assertEq(gem.balanceOf(this), 95 ether); assertEq(gem.balanceOf(tub), 5 ether); @@ -639,23 +639,23 @@ contract CageTest is SaiTestBase { tub.bite(cup); assertEq(tub.ink(cup), 5 ether); tub.free(cup, tub.ink(cup)); - assertEq(skr.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 5 ether); tap.vent(); top.flow(); - tub.exit(uint256(skr.balanceOf(this))); + tub.exit(uint256(peth.balanceOf(this))); assertEq(gem.balanceOf(this), 100 ether); assertEq(gem.balanceOf(tub), 0 ether); - assertEq(skr.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } - function testCashSafeOverCollatWithFreeSkr() public { + function testCashSafeOverCollatWithFreePeth() public { var cup = cageSetup(); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth mark(1 ether); top.cage(); - assertEq(sai.balanceOf(this), 5 ether); - assertEq(skr.balanceOf(this), 20 ether); + assertEq(dai.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 20 ether); assertEq(gem.balanceOf(this), 70 ether); assertEq(gem.balanceOf(tub), 25 ether); assertEq(gem.balanceOf(tap), 5 ether); @@ -664,70 +664,70 @@ contract CageTest is SaiTestBase { tub.free(cup, tub.ink(cup)); tap.vent(); top.flow(); - assertEq(skr.balanceOf(this), 25 ether); - tap.cash(sai.balanceOf(this)); - tub.exit(uint256(skr.balanceOf(this))); + assertEq(peth.balanceOf(this), 25 ether); + tap.cash(dai.balanceOf(this)); + tub.exit(uint256(peth.balanceOf(this))); assertEq(gem.balanceOf(this), 100 ether); - assertEq(sai.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(this), 0 ether); assertEq(gem.balanceOf(tub), 0 ether); tap.vent(); - assertEq(sai.totalSupply(), 0); - assertEq(skr.totalSupply(), 0); + assertEq(dai.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } - function testFailCashSafeOverCollatWithFreeSkrExitBeforeBail() public { + function testFailCashSafeOverCollatWithFreePethExitBeforeBail() public { // fails because exit is before bail var cup = cageSetup(); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth mark(1 ether); top.cage(); - tap.cash(sai.balanceOf(this)); - tub.exit(uint256(skr.balanceOf(this))); - assertEq(skr.balanceOf(this), 0 ether); - uint256 gemBySAI = 5 ether; // Adding 5 gem from 5 sai - uint256 gemBySKR = wdiv(wmul(20 ether, 30 ether - gemBySAI), 30 ether); - assertEq(gem.balanceOf(this), 70 ether + gemBySAI + gemBySKR); + tap.cash(dai.balanceOf(this)); + tub.exit(uint256(peth.balanceOf(this))); + assertEq(peth.balanceOf(this), 0 ether); + uint256 gemByDAI = 5 ether; // Adding 5 gem from 5 dai + uint256 gemByPETH = wdiv(wmul(20 ether, 30 ether - gemByDAI), 30 ether); + assertEq(gem.balanceOf(this), 70 ether + gemByDAI + gemByPETH); - assertEq(sai.balanceOf(this), 0); - assertEq(sai.totalSupply(), 0); + assertEq(dai.balanceOf(this), 0); + assertEq(dai.totalSupply(), 0); assertEq(sin.totalSupply(), 0); tub.bite(cup); tub.free(cup, tub.ink(cup)); tap.vent(); top.flow(); - assertEq(skr.balanceOf(this), 5 ether); // skr retrieved by bail(cup) + assertEq(peth.balanceOf(this), 5 ether); // peth retrieved by bail(cup) - tub.exit(uint256(skr.balanceOf(this))); + tub.exit(uint256(peth.balanceOf(this))); assertEq(gem.balanceOf(this), 100 ether); - assertEq(sai.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(this), 0 ether); assertEq(gem.balanceOf(tub), 0 ether); - assertEq(sai.totalSupply(), 0); + assertEq(dai.totalSupply(), 0); assertEq(sin.totalSupply(), 0); - assertEq(skr.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } function testCashUnsafeOverCollat() public { var cup = cageSetup(); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth var price = wdiv(3 ether, 4 ether); mark(price); top.cage(); // 150% collat - assertEq(sai.balanceOf(this), 5 ether); - assertEq(skr.balanceOf(this), 20 ether); + assertEq(dai.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 20 ether); assertEq(gem.balanceOf(this), 70 ether); - tap.cash(sai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); - assertEq(skr.balanceOf(this), 20 ether); + tap.cash(dai.balanceOf(this)); + assertEq(dai.balanceOf(this), 0 ether); + assertEq(peth.balanceOf(this), 20 ether); - uint256 gemBySAI = wdiv(wmul(5 ether, 4 ether), 3 ether); - uint256 gemBySKR = 0; + uint256 gemByDAI = wdiv(wmul(5 ether, 4 ether), 3 ether); + uint256 gemByPETH = 0; - assertEq(gem.balanceOf(this), 70 ether + gemBySAI + gemBySKR); - assertEq(gem.balanceOf(tub), 30 ether - gemBySAI - gemBySKR); + assertEq(gem.balanceOf(this), 70 ether + gemByDAI + gemByPETH); + assertEq(gem.balanceOf(tub), 30 ether - gemByDAI - gemByPETH); // how much gem should be returned? // there were 10 gems initially, of which 5 were 100% collat @@ -736,22 +736,22 @@ contract CageTest is SaiTestBase { // this should all be returned var ink = tub.ink(cup); var tab = tub.tab(cup); - var skrToRecover = sub(ink, wdiv(tab, price)); + var pethToRecover = sub(ink, wdiv(tab, price)); tub.bite(cup); tub.free(cup, tub.ink(cup)); - assertEq(skr.balanceOf(this), 20 ether + skrToRecover); - assertEq(skr.balanceOf(tub), 0 ether); + assertEq(peth.balanceOf(this), 20 ether + pethToRecover); + assertEq(peth.balanceOf(tub), 0 ether); tap.vent(); top.flow(); - tub.exit(uint256(skr.balanceOf(this))); + tub.exit(uint256(peth.balanceOf(this))); assertEq(gem.balanceOf(this), 100 ether); assertEq(gem.balanceOf(tub), 0 ether); tap.vent(); - assertEq(skr.totalSupply(), 0); - assertEq(sai.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); + assertEq(dai.totalSupply(), 0); } function testCashAtCollat() public { var cup = cageSetup(); @@ -759,12 +759,12 @@ contract CageTest is SaiTestBase { mark(price); top.cage(); - assertEq(sai.balanceOf(this), 5 ether); - assertEq(skr.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 0 ether); assertEq(gem.balanceOf(this), 90 ether); - tap.cash(sai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); - assertEq(skr.balanceOf(this), 0 ether); + tap.cash(dai.balanceOf(this)); + assertEq(dai.balanceOf(this), 0 ether); + assertEq(peth.balanceOf(this), 0 ether); var saved = rmul(5 ether, rdiv(WAD, price)); @@ -781,69 +781,69 @@ contract CageTest is SaiTestBase { assertEq(gem.balanceOf(tub), 0 ether); tap.vent(); - assertEq(skr.totalSupply(), 0); - assertEq(sai.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); + assertEq(dai.totalSupply(), 0); } - function testCashAtCollatFreeSkr() public { + function testCashAtCollatFreePeth() public { var cup = cageSetup(); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth var price = wdiv(1 ether, 2 ether); // 100% collat mark(price); top.cage(); - assertEq(sai.balanceOf(this), 5 ether); - assertEq(skr.balanceOf(this), 20 ether); + assertEq(dai.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 20 ether); assertEq(gem.balanceOf(this), 70 ether); - tap.cash(sai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); + tap.cash(dai.balanceOf(this)); + assertEq(dai.balanceOf(this), 0 ether); tub.bite(cup); tub.free(cup, tub.ink(cup)); tap.vent(); top.flow(); - tub.exit(uint256(skr.balanceOf(this))); + tub.exit(uint256(peth.balanceOf(this))); assertEq(gem.balanceOf(this), 100 ether); assertEq(gem.balanceOf(tub), 0 ether); - assertEq(skr.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } - function testFailCashAtCollatFreeSkrExitBeforeBail() public { + function testFailCashAtCollatFreePethExitBeforeBail() public { var cup = cageSetup(); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth var price = wdiv(1 ether, 2 ether); // 100% collat mark(price); top.cage(); - assertEq(sai.balanceOf(this), 5 ether); - assertEq(skr.balanceOf(this), 20 ether); + assertEq(dai.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 20 ether); assertEq(gem.balanceOf(this), 70 ether); - tap.cash(sai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); - tub.exit(uint256(skr.balanceOf(this))); - assertEq(skr.balanceOf(this), 0 ether); + tap.cash(dai.balanceOf(this)); + assertEq(dai.balanceOf(this), 0 ether); + tub.exit(uint256(peth.balanceOf(this))); + assertEq(peth.balanceOf(this), 0 ether); - var gemBySAI = wmul(5 ether, 2 ether); - var gemBySKR = wdiv(wmul(20 ether, 30 ether - gemBySAI), 30 ether); + var gemByDAI = wmul(5 ether, 2 ether); + var gemByPETH = wdiv(wmul(20 ether, 30 ether - gemByDAI), 30 ether); - assertEq(gem.balanceOf(this), 70 ether + gemBySAI + gemBySKR); - assertEq(gem.balanceOf(tub), 30 ether - gemBySAI - gemBySKR); + assertEq(gem.balanceOf(this), 70 ether + gemByDAI + gemByPETH); + assertEq(gem.balanceOf(tub), 30 ether - gemByDAI - gemByPETH); - assertEq(sai.totalSupply(), 0); + assertEq(dai.totalSupply(), 0); assertEq(sin.totalSupply(), 0); tub.bite(cup); tub.free(cup, tub.ink(cup)); tap.vent(); - tub.exit(uint256(skr.balanceOf(this))); + tub.exit(uint256(peth.balanceOf(this))); - // Cup did not have skr to free, then the ramaining gem in tub can not be shared as there is not more skr to exit - assertEq(gem.balanceOf(this), 70 ether + gemBySAI + gemBySKR); - assertEq(gem.balanceOf(tub), 30 ether - gemBySAI - gemBySKR); + // Cup did not have peth to free, then the ramaining gem in tub can not be shared as there is not more peth to exit + assertEq(gem.balanceOf(this), 70 ether + gemByDAI + gemByPETH); + assertEq(gem.balanceOf(tub), 30 ether - gemByDAI - gemByPETH); - assertEq(skr.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } function testCashUnderCollat() public { var cup = cageSetup(); @@ -851,15 +851,15 @@ contract CageTest is SaiTestBase { mark(price); top.cage(); - assertEq(sai.balanceOf(this), 5 ether); - assertEq(skr.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 0 ether); assertEq(gem.balanceOf(this), 90 ether); - tap.cash(sai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); - assertEq(skr.balanceOf(this), 0 ether); + tap.cash(dai.balanceOf(this)); + assertEq(dai.balanceOf(this), 0 ether); + assertEq(peth.balanceOf(this), 0 ether); // get back all 10 gems, which are now only worth 2.5 ref - // so you've lost 50% on you sai + // so you've lost 50% on you dai assertEq(gem.balanceOf(this), 100 ether); assertEq(gem.balanceOf(tub), 0 ether); @@ -873,67 +873,67 @@ contract CageTest is SaiTestBase { assertEq(gem.balanceOf(tub), 0 ether); tap.vent(); - assertEq(skr.totalSupply(), 0); - assertEq(sai.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); + assertEq(dai.totalSupply(), 0); } - function testCashUnderCollatFreeSkr() public { + function testCashUnderCollatFreePeth() public { var cup = cageSetup(); - tub.join(20 ether); // give us some more skr + tub.join(20 ether); // give us some more peth var price = wdiv(1 ether, 4 ether); // 50% collat mark(price); top.cage(); - assertEq(sai.balanceOf(this), 5 ether); + assertEq(dai.balanceOf(this), 5 ether); assertEq(gem.balanceOf(this), 70 ether); - tap.cash(sai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); - // returns 20 gems, taken from the free skr, - // sai is made whole + tap.cash(dai.balanceOf(this)); + assertEq(dai.balanceOf(this), 0 ether); + // returns 20 gems, taken from the free peth, + // dai is made whole assertEq(gem.balanceOf(this), 90 ether); - assertEq(skr.balanceOf(this), 20 ether); + assertEq(peth.balanceOf(this), 20 ether); tub.bite(cup); tub.free(cup, tub.ink(cup)); tap.vent(); top.flow(); - tub.exit(uint256(skr.balanceOf(this))); - assertEq(skr.balanceOf(this), 0 ether); - // the skr has taken a 50% loss - 10 gems returned from 20 put in + tub.exit(uint256(peth.balanceOf(this))); + assertEq(peth.balanceOf(this), 0 ether); + // the peth has taken a 50% loss - 10 gems returned from 20 put in assertEq(gem.balanceOf(this), 100 ether); assertEq(gem.balanceOf(tub), 0 ether); - assertEq(sai.totalSupply(), 0); - assertEq(skr.totalSupply(), 0); + assertEq(dai.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } function testCashSafeOverCollatAndMock() public { testCashSafeOverCollat(); gem.approve(tap, uint(-1)); tap.mock(5 ether); - assertEq(sai.balanceOf(this), 5 ether); + assertEq(dai.balanceOf(this), 5 ether); assertEq(gem.balanceOf(this), 95 ether); assertEq(gem.balanceOf(tap), 5 ether); } - function testCashSafeOverCollatWithFreeSkrAndMock() public { - testCashSafeOverCollatWithFreeSkr(); + function testCashSafeOverCollatWithFreePethAndMock() public { + testCashSafeOverCollatWithFreePeth(); gem.approve(tap, uint(-1)); tap.mock(5 ether); - assertEq(sai.balanceOf(this), 5 ether); + assertEq(dai.balanceOf(this), 5 ether); assertEq(gem.balanceOf(this), 95 ether); assertEq(gem.balanceOf(tap), 5 ether); } - function testFailCashSafeOverCollatWithFreeSkrExitBeforeBailAndMock() public { - testFailCashSafeOverCollatWithFreeSkrExitBeforeBail(); + function testFailCashSafeOverCollatWithFreePethExitBeforeBailAndMock() public { + testFailCashSafeOverCollatWithFreePethExitBeforeBail(); gem.approve(tap, uint(-1)); tap.mock(5 ether); - assertEq(sai.balanceOf(this), 5 ether); + assertEq(dai.balanceOf(this), 5 ether); assertEq(gem.balanceOf(this), 95 ether); assertEq(gem.balanceOf(tap), 5 ether); } function testThreeCupsOverCollat() public { var cup = cageSetup(); - tub.join(90 ether); // give us some more skr + tub.join(90 ether); // give us some more peth var cup2 = tub.open(); // open a new cup tub.lock(cup2, 20 ether); // lock collateral but not draw DAI var cup3 = tub.open(); // open a new cup @@ -942,51 +942,51 @@ contract CageTest is SaiTestBase { assertEq(gem.balanceOf(tap), 0); assertEq(gem.balanceOf(tub), 100 ether); assertEq(gem.balanceOf(this), 0); - assertEq(skr.balanceOf(this), 50 ether); // free skr - assertEq(skr.balanceOf(tub), 50 ether); // locked skr + assertEq(peth.balanceOf(this), 50 ether); // free peth + assertEq(peth.balanceOf(tub), 50 ether); // locked peth uint256 price = 1 ether; mark(price); top.cage(); - assertEq(gem.balanceOf(tap), 5 ether); // Needed to payout 5 sai + assertEq(gem.balanceOf(tap), 5 ether); // Needed to payout 5 dai assertEq(gem.balanceOf(tub), 95 ether); tub.bite(cup); - tub.free(cup, tub.ink(cup)); // 5 skr recovered, and 5 skr burnt + tub.free(cup, tub.ink(cup)); // 5 peth recovered, and 5 peth burnt - assertEq(skr.balanceOf(this), 55 ether); // free skr - assertEq(skr.balanceOf(tub), 40 ether); // locked skr + assertEq(peth.balanceOf(this), 55 ether); // free peth + assertEq(peth.balanceOf(tub), 40 ether); // locked peth tub.bite(cup2); - tub.free(cup2, tub.ink(cup2)); // 20 skr recovered + tub.free(cup2, tub.ink(cup2)); // 20 peth recovered - assertEq(skr.balanceOf(this), 75 ether); // free skr - assertEq(skr.balanceOf(tub), 20 ether); // locked skr + assertEq(peth.balanceOf(this), 75 ether); // free peth + assertEq(peth.balanceOf(tub), 20 ether); // locked peth tub.bite(cup3); - tub.free(cup3, tub.ink(cup3)); // 20 skr recovered + tub.free(cup3, tub.ink(cup3)); // 20 peth recovered - assertEq(skr.balanceOf(this), 95 ether); // free skr - assertEq(skr.balanceOf(tub), 0); // locked skr + assertEq(peth.balanceOf(this), 95 ether); // free peth + assertEq(peth.balanceOf(tub), 0); // locked peth - tap.cash(sai.balanceOf(this)); + tap.cash(dai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0); + assertEq(dai.balanceOf(this), 0); assertEq(gem.balanceOf(this), 5 ether); tap.vent(); top.flow(); - tub.exit(uint256(skr.balanceOf(this))); // exit 95 skr at price 95/95 + tub.exit(uint256(peth.balanceOf(this))); // exit 95 peth at price 95/95 assertEq(gem.balanceOf(tub), 0); assertEq(gem.balanceOf(tap), 0); assertEq(gem.balanceOf(this), 100 ether); - assertEq(skr.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } function testThreeCupsAtCollat() public { var cup = cageSetup(); - tub.join(90 ether); // give us some more skr + tub.join(90 ether); // give us some more peth var cup2 = tub.open(); // open a new cup tub.lock(cup2, 20 ether); // lock collateral but not draw DAI var cup3 = tub.open(); // open a new cup @@ -995,51 +995,51 @@ contract CageTest is SaiTestBase { assertEq(gem.balanceOf(tap), 0); assertEq(gem.balanceOf(tub), 100 ether); assertEq(gem.balanceOf(this), 0); - assertEq(skr.balanceOf(this), 50 ether); // free skr - assertEq(skr.balanceOf(tub), 50 ether); // locked skr + assertEq(peth.balanceOf(this), 50 ether); // free peth + assertEq(peth.balanceOf(tub), 50 ether); // locked peth var price = wdiv(1 ether, 2 ether); mark(price); top.cage(); - assertEq(gem.balanceOf(tap), 10 ether); // Needed to payout 10 sai + assertEq(gem.balanceOf(tap), 10 ether); // Needed to payout 10 dai assertEq(gem.balanceOf(tub), 90 ether); tub.bite(cup); - tub.free(cup, tub.ink(cup)); // 10 skr burnt + tub.free(cup, tub.ink(cup)); // 10 peth burnt - assertEq(skr.balanceOf(this), 50 ether); // free skr - assertEq(skr.balanceOf(tub), 40 ether); // locked skr + assertEq(peth.balanceOf(this), 50 ether); // free peth + assertEq(peth.balanceOf(tub), 40 ether); // locked peth tub.bite(cup2); - tub.free(cup2, tub.ink(cup2)); // 20 skr recovered + tub.free(cup2, tub.ink(cup2)); // 20 peth recovered - assertEq(skr.balanceOf(this), 70 ether); // free skr - assertEq(skr.balanceOf(tub), 20 ether); // locked skr + assertEq(peth.balanceOf(this), 70 ether); // free peth + assertEq(peth.balanceOf(tub), 20 ether); // locked peth tub.bite(cup3); - tub.free(cup3, tub.ink(cup3)); // 20 skr recovered + tub.free(cup3, tub.ink(cup3)); // 20 peth recovered - assertEq(skr.balanceOf(this), 90 ether); // free skr - assertEq(skr.balanceOf(tub), 0); // locked skr + assertEq(peth.balanceOf(this), 90 ether); // free peth + assertEq(peth.balanceOf(tub), 0); // locked peth - tap.cash(sai.balanceOf(this)); + tap.cash(dai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0); + assertEq(dai.balanceOf(this), 0); assertEq(gem.balanceOf(this), 10 ether); tap.vent(); top.flow(); - tub.exit(uint256(skr.balanceOf(this))); // exit 90 skr at price 90/90 + tub.exit(uint256(peth.balanceOf(this))); // exit 90 peth at price 90/90 assertEq(gem.balanceOf(tub), 0); assertEq(gem.balanceOf(tap), 0); assertEq(gem.balanceOf(this), 100 ether); - assertEq(skr.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } function testThreeCupsUnderCollat() public { var cup = cageSetup(); - tub.join(90 ether); // give us some more skr + tub.join(90 ether); // give us some more peth var cup2 = tub.open(); // open a new cup tub.lock(cup2, 20 ether); // lock collateral but not draw DAI var cup3 = tub.open(); // open a new cup @@ -1048,51 +1048,51 @@ contract CageTest is SaiTestBase { assertEq(gem.balanceOf(tap), 0); assertEq(gem.balanceOf(tub), 100 ether); assertEq(gem.balanceOf(this), 0); - assertEq(skr.balanceOf(this), 50 ether); // free skr - assertEq(skr.balanceOf(tub), 50 ether); // locked skr + assertEq(peth.balanceOf(this), 50 ether); // free peth + assertEq(peth.balanceOf(tub), 50 ether); // locked peth var price = wdiv(1 ether, 4 ether); mark(price); top.cage(); - assertEq(gem.balanceOf(tap), 20 ether); // Needed to payout 5 sai + assertEq(gem.balanceOf(tap), 20 ether); // Needed to payout 5 dai assertEq(gem.balanceOf(tub), 80 ether); tub.bite(cup); - tub.free(cup, tub.ink(cup)); // No skr is retrieved as the cup doesn't even cover the debt. 10 locked skr in cup are burnt from tub + tub.free(cup, tub.ink(cup)); // No peth is retrieved as the cup doesn't even cover the debt. 10 locked peth in cup are burnt from tub - assertEq(skr.balanceOf(this), 50 ether); // free skr - assertEq(skr.balanceOf(tub), 40 ether); // locked skr + assertEq(peth.balanceOf(this), 50 ether); // free peth + assertEq(peth.balanceOf(tub), 40 ether); // locked peth tub.bite(cup2); - tub.free(cup2, tub.ink(cup2)); // 20 skr recovered + tub.free(cup2, tub.ink(cup2)); // 20 peth recovered - assertEq(skr.balanceOf(this), 70 ether); // free skr - assertEq(skr.balanceOf(tub), 20 ether); // locked skr + assertEq(peth.balanceOf(this), 70 ether); // free peth + assertEq(peth.balanceOf(tub), 20 ether); // locked peth tub.bite(cup3); - tub.free(cup3, tub.ink(cup3)); // 20 skr recovered + tub.free(cup3, tub.ink(cup3)); // 20 peth recovered - assertEq(skr.balanceOf(this), 90 ether); // free skr - assertEq(skr.balanceOf(tub), 0); // locked skr + assertEq(peth.balanceOf(this), 90 ether); // free peth + assertEq(peth.balanceOf(tub), 0); // locked peth - tap.cash(sai.balanceOf(this)); + tap.cash(dai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0); + assertEq(dai.balanceOf(this), 0); assertEq(gem.balanceOf(this), 20 ether); tap.vent(); top.flow(); - tub.exit(uint256(skr.balanceOf(this))); // exit 90 skr at price 80/90 + tub.exit(uint256(peth.balanceOf(this))); // exit 90 peth at price 80/90 assertEq(gem.balanceOf(tub), 0); assertEq(gem.balanceOf(tap), 0); assertEq(gem.balanceOf(this), 100 ether); - assertEq(skr.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } - function testThreeCupsSKRZeroValue() public { + function testThreeCupsPETHZeroValue() public { var cup = cageSetup(); - tub.join(90 ether); // give us some more skr + tub.join(90 ether); // give us some more peth var cup2 = tub.open(); // open a new cup tub.lock(cup2, 20 ether); // lock collateral but not draw DAI var cup3 = tub.open(); // open a new cup @@ -1101,47 +1101,47 @@ contract CageTest is SaiTestBase { assertEq(gem.balanceOf(tap), 0); assertEq(gem.balanceOf(tub), 100 ether); assertEq(gem.balanceOf(this), 0); - assertEq(skr.balanceOf(this), 50 ether); // free skr - assertEq(skr.balanceOf(tub), 50 ether); // locked skr + assertEq(peth.balanceOf(this), 50 ether); // free peth + assertEq(peth.balanceOf(tub), 50 ether); // locked peth var price = wdiv(1 ether, 20 ether); mark(price); top.cage(); - assertEq(gem.balanceOf(tap), 100 ether); // Needed to payout 5 sai + assertEq(gem.balanceOf(tap), 100 ether); // Needed to payout 5 dai assertEq(gem.balanceOf(tub), 0 ether); tub.bite(cup); - tub.free(cup, tub.ink(cup)); // No skr is retrieved as the cup doesn't even cover the debt. 10 locked skr in cup are burnt from tub + tub.free(cup, tub.ink(cup)); // No peth is retrieved as the cup doesn't even cover the debt. 10 locked peth in cup are burnt from tub - assertEq(skr.balanceOf(this), 50 ether); // free skr - assertEq(skr.balanceOf(tub), 40 ether); // locked skr + assertEq(peth.balanceOf(this), 50 ether); // free peth + assertEq(peth.balanceOf(tub), 40 ether); // locked peth tub.bite(cup2); - tub.free(cup2, tub.ink(cup2)); // 20 skr recovered + tub.free(cup2, tub.ink(cup2)); // 20 peth recovered - assertEq(skr.balanceOf(this), 70 ether); // free skr - assertEq(skr.balanceOf(tub), 20 ether); // locked skr + assertEq(peth.balanceOf(this), 70 ether); // free peth + assertEq(peth.balanceOf(tub), 20 ether); // locked peth tub.bite(cup3); - tub.free(cup3, tub.ink(cup3)); // 20 skr recovered + tub.free(cup3, tub.ink(cup3)); // 20 peth recovered - assertEq(skr.balanceOf(this), 90 ether); // free skr - assertEq(skr.balanceOf(tub), 0); // locked skr + assertEq(peth.balanceOf(this), 90 ether); // free peth + assertEq(peth.balanceOf(tub), 0); // locked peth - tap.cash(sai.balanceOf(this)); + tap.cash(dai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0); + assertEq(dai.balanceOf(this), 0); assertEq(gem.balanceOf(this), 100 ether); tap.vent(); top.flow(); - tub.exit(uint256(skr.balanceOf(this))); // exit 90 skr at price 0/90 + tub.exit(uint256(peth.balanceOf(this))); // exit 90 peth at price 0/90 assertEq(gem.balanceOf(tub), 0); assertEq(gem.balanceOf(tap), 0); assertEq(gem.balanceOf(this), 100 ether); - assertEq(skr.totalSupply(), 0); + assertEq(peth.totalSupply(), 0); } function testPeriodicFixValue() public { @@ -1150,23 +1150,23 @@ contract CageTest is SaiTestBase { assertEq(gem.balanceOf(tap), 0); assertEq(gem.balanceOf(tub), 10 ether); assertEq(gem.balanceOf(this), 90 ether); - assertEq(skr.balanceOf(this), 0 ether); // free skr - assertEq(skr.balanceOf(tub), 10 ether); // locked skr + assertEq(peth.balanceOf(this), 0 ether); // free peth + assertEq(peth.balanceOf(tub), 10 ether); // locked peth FakePerson person = new FakePerson(tap); - sai.transfer(person, 2.5 ether); // Transfer half of SAI balance to the other user + dai.transfer(person, 2.5 ether); // Transfer half of DAI balance to the other user var price = rdiv(9 ether, 8 ether); mark(price); top.cage(); - assertEq(gem.balanceOf(tap), rmul(5 ether, top.fix())); // Needed to payout 5 sai + assertEq(gem.balanceOf(tap), rmul(5 ether, top.fix())); // Needed to payout 5 dai assertEq(gem.balanceOf(tub), sub(10 ether, rmul(5 ether, top.fix()))); - tap.cash(sai.balanceOf(this)); + tap.cash(dai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); - assertEq(sai.balanceOf(person), 2.5 ether); + assertEq(dai.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(person), 2.5 ether); assertEq(gem.balanceOf(this), add(90 ether, rmul(2.5 ether, top.fix()))); person.cash(); @@ -1190,20 +1190,20 @@ contract CageTest is SaiTestBase { warp(1 seconds); top.flow(); - assertEq(skr.balanceOf(this), 5 ether); + assertEq(peth.balanceOf(this), 5 ether); assertEq(gem.balanceOf(this), 90 ether); assertTrue(tub.call(bytes4(keccak256('exit(uint256)')), 4 ether)); - assertEq(skr.balanceOf(this), 1 ether); - // n.b. we don't get back 4 as there is still skr in the cup + assertEq(peth.balanceOf(this), 1 ether); + // n.b. we don't get back 4 as there is still peth in the cup assertEq(gem.balanceOf(this), 92 ether); - // now we can cash in our sai - assertEq(sai.balanceOf(this), 5 ether); - tap.cash(sai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); + // now we can cash in our dai + assertEq(dai.balanceOf(this), 5 ether); + tap.cash(dai.balanceOf(this)); + assertEq(dai.balanceOf(this), 0 ether); assertEq(gem.balanceOf(this), 97 ether); - // the remaining gem can be claimed only if the cup skr is burned + // the remaining gem can be claimed only if the cup peth is burned assertEq(tub.air(), 5 ether); assertEq(tap.fog(), 0 ether); assertEq(tub.din(), 5 ether); @@ -1217,12 +1217,12 @@ contract CageTest is SaiTestBase { tap.vent(); assertEq(tap.fog(), 0 ether); - // now this remaining 1 skr will claim all the remaining 3 ether. + // now this remaining 1 peth will claim all the remaining 3 ether. // this is why exiting early is bad if you want to maximise returns. - // if we had exited with all the skr earlier, there would be 2.5 gem + // if we had exited with all the peth earlier, there would be 2.5 gem // trapped in the tub. tub.exit(1 ether); - assertEq(skr.balanceOf(this), 0 ether); + assertEq(peth.balanceOf(this), 0 ether); assertEq(gem.balanceOf(this), 100 ether); } @@ -1236,7 +1236,7 @@ contract CageTest is SaiTestBase { } } -contract LiquidationTest is SaiTestBase { +contract LiquidationTest is DaiTestBase { function liq(bytes32 cup) internal returns (uint256) { // compute the liquidation price of a cup var jam = rmul(tub.ink(cup), tub.per()); // this many eth @@ -1320,37 +1320,37 @@ contract LiquidationTest is SaiTestBase { assertTrue(!tub.safe(cup)); tub.bite(cup); - // 20 ref of gem on 16 ref of sai + // 20 ref of gem on 16 ref of dai // 125% // 100% = 16ref of gem == 8 gem assertEq(tap.fog(), 8 ether); - // 8 skr for sale + // 8 peth for sale assertEq(tub.per(), ray(1 ether)); - // get 2 skr, pay 4 sai (25% of the debt) - var sai_before = sai.balanceOf(this); - var skr_before = skr.balanceOf(this); - assertEq(sai_before, 16 ether); + // get 2 peth, pay 4 dai (25% of the debt) + var dai_before = dai.balanceOf(this); + var peth_before = peth.balanceOf(this); + assertEq(dai_before, 16 ether); tap.bust(2 ether); - var sai_after = sai.balanceOf(this); - var skr_after = skr.balanceOf(this); - assertEq(sai_before - sai_after, 4 ether); - assertEq(skr_after - skr_before, 2 ether); + var dai_after = dai.balanceOf(this); + var peth_after = peth.balanceOf(this); + assertEq(dai_before - dai_after, 4 ether); + assertEq(peth_after - peth_before, 2 ether); - // price drop. now remaining 6 skr cannot cover bad debt (12 sai) + // price drop. now remaining 6 peth cannot cover bad debt (12 dai) mark(1 ether); - // get 6 skr, pay 6 sai + // get 6 peth, pay 6 dai tap.bust(6 ether); - // no more skr remaining to sell + // no more peth remaining to sell assertEq(tap.fog(), 0); - // but skr supply unchanged - assertEq(skr.totalSupply(), 10 ether); + // but peth supply unchanged + assertEq(peth.totalSupply(), 10 ether); - // now skr will be minted + // now peth will be minted tap.bust(2 ether); - assertEq(skr.totalSupply(), 12 ether); + assertEq(peth.totalSupply(), 12 ether); } function testBustNoMint() public { mom.setCap(1000 ether); @@ -1374,18 +1374,18 @@ contract LiquidationTest is SaiTestBase { assertEq(tap.fog(), 10 ether); assertEq(tap.woe(), 100 ether); - // the fog is worth 150 sai and the woe is worth 100 sai. - // If all the fog is sold, there will be a sai surplus. + // the fog is worth 150 dai and the woe is worth 100 dai. + // If all the fog is sold, there will be a dai surplus. - // get some more sai to buy with + // get some more dai to buy with tub.join(10 ether); var mug = tub.open(); tub.lock(mug, 10 ether); tub.draw(mug, 50 ether); tap.bust(10 ether); - assertEq(sai.balanceOf(this), 0 ether); - assertEq(skr.balanceOf(this), 10 ether); + assertEq(dai.balanceOf(this), 0 ether); + assertEq(peth.balanceOf(this), 10 ether); assertEq(tap.fog(), 0 ether); assertEq(tap.woe(), 0 ether); assertEq(tap.joy(), 50 ether); @@ -1393,51 +1393,51 @@ contract LiquidationTest is SaiTestBase { // joy is available through boom assertEq(tap.bid(1 ether), 15 ether); tap.boom(2 ether); - assertEq(sai.balanceOf(this), 30 ether); - assertEq(skr.balanceOf(this), 8 ether); + assertEq(dai.balanceOf(this), 30 ether); + assertEq(peth.balanceOf(this), 8 ether); assertEq(tap.fog(), 0 ether); assertEq(tap.woe(), 0 ether); assertEq(tap.joy(), 20 ether); } } -contract TapTest is SaiTestBase { +contract TapTest is DaiTestBase { function testTapSetup() public { - assertEq(sai.balanceOf(tap), tap.joy()); + assertEq(dai.balanceOf(tap), tap.joy()); assertEq(sin.balanceOf(tap), tap.woe()); - assertEq(skr.balanceOf(tap), tap.fog()); + assertEq(peth.balanceOf(tap), tap.fog()); assertEq(tap.joy(), 0); assertEq(tap.woe(), 0); assertEq(tap.fog(), 0); - sai.mint(tap, 3); + dai.mint(tap, 3); sin.mint(tap, 4); - skr.mint(tap, 5); + peth.mint(tap, 5); assertEq(tap.joy(), 3); assertEq(tap.woe(), 4); assertEq(tap.fog(), 5); } - // boom (flap) is surplus sale (sai for skr->burn) + // boom (flap) is surplus sale (dai for peth->burn) function testTapBoom() public { - sai.mint(tap, 50 ether); + dai.mint(tap, 50 ether); tub.join(60 ether); - assertEq(sai.balanceOf(this), 0 ether); - assertEq(skr.balanceOf(this), 60 ether); + assertEq(dai.balanceOf(this), 0 ether); + assertEq(peth.balanceOf(this), 60 ether); tap.boom(50 ether); - assertEq(sai.balanceOf(this), 50 ether); - assertEq(skr.balanceOf(this), 10 ether); + assertEq(dai.balanceOf(this), 50 ether); + assertEq(peth.balanceOf(this), 10 ether); assertEq(tap.joy(), 0); } function testFailTapBoomOverJoy() public { - sai.mint(tap, 50 ether); + dai.mint(tap, 50 ether); tub.join(60 ether); tap.boom(51 ether); } function testTapBoomHeals() public { - sai.mint(tap, 60 ether); + dai.mint(tap, 60 ether); sin.mint(tap, 50 ether); tub.join(10 ether); @@ -1445,21 +1445,21 @@ contract TapTest is SaiTestBase { assertEq(tap.joy(), 10 ether); } function testFailTapBoomNetWoe() public { - sai.mint(tap, 50 ether); + dai.mint(tap, 50 ether); sin.mint(tap, 60 ether); tub.join(10 ether); tap.boom(1 ether); } - function testTapBoomBurnsSkr() public { - sai.mint(tap, 50 ether); + function testTapBoomBurnsPeth() public { + dai.mint(tap, 50 ether); tub.join(60 ether); - assertEq(skr.totalSupply(), 60 ether); + assertEq(peth.totalSupply(), 60 ether); tap.boom(20 ether); - assertEq(skr.totalSupply(), 40 ether); + assertEq(peth.totalSupply(), 40 ether); } function testTapBoomIncreasesPer() public { - sai.mint(tap, 50 ether); + dai.mint(tap, 50 ether); tub.join(60 ether); assertEq(tub.per(), ray(1 ether)); @@ -1467,103 +1467,103 @@ contract TapTest is SaiTestBase { assertEq(tub.per(), ray(2 ether)); } function testTapBoomMarkDep() public { - sai.mint(tap, 50 ether); + dai.mint(tap, 50 ether); tub.join(50 ether); mark(2 ether); tap.boom(10 ether); - assertEq(sai.balanceOf(this), 20 ether); - assertEq(sai.balanceOf(tap), 30 ether); - assertEq(skr.balanceOf(this), 40 ether); + assertEq(dai.balanceOf(this), 20 ether); + assertEq(dai.balanceOf(tap), 30 ether); + assertEq(peth.balanceOf(this), 40 ether); } function testTapBoomPerDep() public { - sai.mint(tap, 50 ether); + dai.mint(tap, 50 ether); tub.join(50 ether); assertEq(tub.per(), ray(1 ether)); - skr.mint(50 ether); // halves per + peth.mint(50 ether); // halves per assertEq(tub.per(), ray(.5 ether)); tap.boom(10 ether); - assertEq(sai.balanceOf(this), 5 ether); - assertEq(sai.balanceOf(tap), 45 ether); - assertEq(skr.balanceOf(this), 90 ether); + assertEq(dai.balanceOf(this), 5 ether); + assertEq(dai.balanceOf(tap), 45 ether); + assertEq(peth.balanceOf(this), 90 ether); } - // flip is collateral sale (skr for sai) + // flip is collateral sale (peth for dai) function testTapBustFlip() public { - sai.mint(50 ether); + dai.mint(50 ether); tub.join(50 ether); - skr.push(tap, 50 ether); + peth.push(tap, 50 ether); assertEq(tap.fog(), 50 ether); - assertEq(skr.balanceOf(this), 0 ether); - assertEq(sai.balanceOf(this), 50 ether); + assertEq(peth.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(this), 50 ether); tap.bust(30 ether); - assertEq(skr.balanceOf(this), 30 ether); - assertEq(sai.balanceOf(this), 20 ether); + assertEq(peth.balanceOf(this), 30 ether); + assertEq(dai.balanceOf(this), 20 ether); } function testFailTapBustFlipOverFog() public { // FAIL - sai.mint(50 ether); + dai.mint(50 ether); tub.join(50 ether); - skr.push(tap, 50 ether); + peth.push(tap, 50 ether); tap.bust(51 ether); } function testTapBustFlipHealsNetJoy() public { - sai.mint(tap, 10 ether); + dai.mint(tap, 10 ether); sin.mint(tap, 20 ether); tub.join(50 ether); - skr.push(tap, 50 ether); + peth.push(tap, 50 ether); - sai.mint(15 ether); + dai.mint(15 ether); tap.bust(15 ether); assertEq(tap.joy(), 5 ether); assertEq(tap.woe(), 0 ether); } function testTapBustFlipHealsNetWoe() public { - sai.mint(tap, 10 ether); + dai.mint(tap, 10 ether); sin.mint(tap, 20 ether); tub.join(50 ether); - skr.push(tap, 50 ether); + peth.push(tap, 50 ether); - sai.mint(5 ether); + dai.mint(5 ether); tap.bust(5 ether); assertEq(tap.joy(), 0 ether); assertEq(tap.woe(), 5 ether); } - // flop is debt sale (woe->skr for sai) + // flop is debt sale (woe->peth for dai) function testTapBustFlop() public { tub.join(50 ether); // avoid per=1 init case - sai.mint(100 ether); + dai.mint(100 ether); sin.mint(tap, 50 ether); assertEq(tap.woe(), 50 ether); - assertEq(skr.balanceOf(this), 50 ether); - assertEq(sai.balanceOf(this), 100 ether); + assertEq(peth.balanceOf(this), 50 ether); + assertEq(dai.balanceOf(this), 100 ether); tap.bust(50 ether); - assertEq(skr.balanceOf(this), 100 ether); - assertEq(sai.balanceOf(this), 75 ether); + assertEq(peth.balanceOf(this), 100 ether); + assertEq(dai.balanceOf(this), 75 ether); } function testFailTapBustFlopNetJoy() public { tub.join(50 ether); // avoid per=1 init case - sai.mint(100 ether); + dai.mint(100 ether); sin.mint(tap, 50 ether); - sai.mint(tap, 100 ether); + dai.mint(tap, 100 ether); tap.bust(1); // anything but zero should fail } - function testTapBustFlopMintsSkr() public { + function testTapBustFlopMintsPeth() public { tub.join(50 ether); // avoid per=1 init case - sai.mint(100 ether); + dai.mint(100 ether); sin.mint(tap, 50 ether); - assertEq(skr.totalSupply(), 50 ether); + assertEq(peth.totalSupply(), 50 ether); tap.bust(20 ether); - assertEq(skr.totalSupply(), 70 ether); + assertEq(peth.totalSupply(), 70 ether); } function testTapBustFlopDecreasesPer() public { tub.join(50 ether); // avoid per=1 init case - sai.mint(100 ether); + dai.mint(100 ether); sin.mint(tap, 50 ether); assertEq(tub.per(), ray(1 ether)); @@ -1575,43 +1575,43 @@ contract TapTest is SaiTestBase { tub.join(50 ether); assertEq(tap.ask(50 ether), 50 ether); - skr.mint(50 ether); + peth.mint(50 ether); assertEq(tap.ask(50 ether), 25 ether); - skr.mint(100 ether); + peth.mint(100 ether); assertEq(tap.ask(50 ether), 12.5 ether); - skr.burn(175 ether); + peth.burn(175 ether); assertEq(tap.ask(50 ether), 100 ether); - skr.mint(25 ether); + peth.mint(25 ether); assertEq(tap.ask(50 ether), 50 ether); - skr.mint(10 ether); + peth.mint(10 ether); // per = 5 / 6 assertEq(tap.ask(60 ether), 50 ether); - skr.mint(30 ether); + peth.mint(30 ether); // per = 5 / 9 assertEq(tap.ask(90 ether), 50 ether); - skr.mint(10 ether); + peth.mint(10 ether); // per = 1 / 2 assertEq(tap.ask(100 ether), 50 ether); } // flipflop is debt sale when collateral present function testTapBustFlipFlopRounding() public { tub.join(50 ether); // avoid per=1 init case - sai.mint(100 ether); + dai.mint(100 ether); sin.mint(tap, 100 ether); - skr.push(tap, 50 ether); + peth.push(tap, 50 ether); assertEq(tap.joy(), 0 ether); assertEq(tap.woe(), 100 ether); assertEq(tap.fog(), 50 ether); - assertEq(skr.balanceOf(this), 0 ether); - assertEq(sai.balanceOf(this), 100 ether); - assertEq(skr.totalSupply(), 50 ether); + assertEq(peth.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(this), 100 ether); + assertEq(peth.totalSupply(), 50 ether); assertEq(tub.per(), ray(1 ether)); assertEq(tap.s2s(), ray(1 ether)); @@ -1623,34 +1623,34 @@ contract TapTest is SaiTestBase { assertEq(tub.tag(), rdiv(5, 6)); // non ray prices would give small rounding error because wad math assertEq(tap.ask(60 ether), 50 ether); - assertEq(skr.totalSupply(), 60 ether); + assertEq(peth.totalSupply(), 60 ether); assertEq(tap.fog(), 0 ether); - assertEq(skr.balanceOf(this), 60 ether); - assertEq(sai.balanceOf(this), 50 ether); + assertEq(peth.balanceOf(this), 60 ether); + assertEq(dai.balanceOf(this), 50 ether); } function testTapBustFlipFlop() public { tub.join(50 ether); // avoid per=1 init case - sai.mint(100 ether); + dai.mint(100 ether); sin.mint(tap, 100 ether); - skr.push(tap, 50 ether); + peth.push(tap, 50 ether); assertEq(tap.joy(), 0 ether); assertEq(tap.woe(), 100 ether); assertEq(tap.fog(), 50 ether); - assertEq(skr.balanceOf(this), 0 ether); - assertEq(sai.balanceOf(this), 100 ether); - assertEq(skr.totalSupply(), 50 ether); + assertEq(peth.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(this), 100 ether); + assertEq(peth.totalSupply(), 50 ether); assertEq(tub.per(), ray(1 ether)); tap.bust(80 ether); assertEq(tub.per(), rdiv(5, 8)); - assertEq(skr.totalSupply(), 80 ether); + assertEq(peth.totalSupply(), 80 ether); assertEq(tap.fog(), 0 ether); - assertEq(skr.balanceOf(this), 80 ether); - assertEq(sai.balanceOf(this), 50 ether); // expected 50, actual 50 ether + 2???!!! + assertEq(peth.balanceOf(this), 80 ether); + assertEq(dai.balanceOf(this), 50 ether); // expected 50, actual 50 ether + 2???!!! } } -contract TaxTest is SaiTestBase { +contract TaxTest is DaiTestBase { function testEraInit() public { assertEq(uint(vox.era()), now); } @@ -1693,7 +1693,7 @@ contract TaxTest is SaiTestBase { tub.drip(); assertEq(tub.din(), 105 ether); } - // Tax accumulates as sai surplus, and CDP debt + // Tax accumulates as dai surplus, and CDP debt function testTaxJoy() public { var cup = taxSetup(); assertEq(tub.tab(cup), 100 ether); @@ -1778,20 +1778,20 @@ contract TaxTest is SaiTestBase { function testTaxBoom() public { taxSetup(); warp(1 days); - // should have 5 sai available == 0.5 skr - tub.join(0.5 ether); // get some unlocked skr + // should have 5 dai available == 0.5 peth + tub.join(0.5 ether); // get some unlocked peth - assertEq(skr.totalSupply(), 100.5 ether); - assertEq(sai.balanceOf(tap), 0 ether); + assertEq(peth.totalSupply(), 100.5 ether); + assertEq(dai.balanceOf(tap), 0 ether); assertEq(sin.balanceOf(tap), 0 ether); - assertEq(sai.balanceOf(this), 100 ether); + assertEq(dai.balanceOf(this), 100 ether); tub.drip(); - assertEq(sai.balanceOf(tap), 5 ether); + assertEq(dai.balanceOf(tap), 5 ether); tap.boom(0.5 ether); - assertEq(skr.totalSupply(), 100 ether); - assertEq(sai.balanceOf(tap), 0 ether); + assertEq(peth.totalSupply(), 100 ether); + assertEq(dai.balanceOf(tap), 0 ether); assertEq(sin.balanceOf(tap), 0 ether); - assertEq(sai.balanceOf(this), 105 ether); + assertEq(dai.balanceOf(this), 105 ether); } // Tax can flip a cup to unsafe function testTaxSafe() public { @@ -1839,27 +1839,27 @@ contract TaxTest is SaiTestBase { warp(1 days); // should have no effect tub.drip(); - assertEq(skr.balanceOf(this), 0 ether); - assertEq(skr.balanceOf(tub), 100 ether); + assertEq(peth.balanceOf(this), 0 ether); + assertEq(peth.balanceOf(tub), 100 ether); tub.bite(cup); tub.free(cup, tub.ink(cup)); - assertEq(skr.balanceOf(this), 89.5 ether); - assertEq(skr.balanceOf(tub), 0 ether); + assertEq(peth.balanceOf(this), 89.5 ether); + assertEq(peth.balanceOf(tub), 0 ether); - assertEq(sai.balanceOf(this), 100 ether); + assertEq(dai.balanceOf(this), 100 ether); assertEq(gem.balanceOf(this), 1000 ether); - tap.cash(sai.balanceOf(this)); - assertEq(sai.balanceOf(this), 0 ether); + tap.cash(dai.balanceOf(this)); + assertEq(dai.balanceOf(this), 0 ether); assertEq(gem.balanceOf(this), 1010 ether); } function testTaxCage() public { - // after cage, un-distributed tax revenue remains as joy - sai + // after cage, un-distributed tax revenue remains as joy - dai // surplus in the tap. The remaining joy, plus all outstanding - // sai, balances the sin debt in the tub, plus any debt (woe) in + // dai, balances the sin debt in the tub, plus any debt (woe) in // the tap. // The effect of this is that joy remaining in tap is - // effectively distributed to all skr holders. + // effectively distributed to all peth holders. var cup = taxSetup(); warp(1 days); mark(10 ether); @@ -1881,7 +1881,7 @@ contract TaxTest is SaiTestBase { } } -contract WayTest is SaiTestBase { +contract WayTest is DaiTestBase { function waySetup() public returns (bytes32 cup) { mark(10 ether); gem.deposit.value(1000 ether)(); @@ -1894,16 +1894,16 @@ contract WayTest is SaiTestBase { tub.draw(cup, 100 ether); } // what does way actually do? - // it changes the value of sai relative to ref - // way > 1 -> par increasing, more ref per sai - // way < 1 -> par decreasing, less ref per sai + // it changes the value of dai relative to ref + // way > 1 -> par increasing, more ref per dai + // way < 1 -> par decreasing, less ref per dai // this changes the safety level of cups, // affecting `draw`, `wipe`, `free` and `bite` // if way < 1, par is decreasing and the con (in ref) // of a cup is decreasing, so cup holders need - // less ref to wipe (but the same sai) + // less ref to wipe (but the same dai) // This makes cups *more* collateralised with time. function testTau() public { assertEq(uint(vox.era()), now); @@ -1930,33 +1930,33 @@ contract WayTest is SaiTestBase { assertTrue(tub.safe(cup)); } // `cage` is slightly affected: the cage price is - // now in *sai per gem*, where before ref per gem + // now in *dai per gem*, where before ref per gem // was equivalent. - // `bail` is unaffected, as all values are in sai. + // `bail` is unaffected, as all values are in dai. function testWayCage() public { waySetup(); mom.setWay(1000000021979553151239153027); // 200% / year warp(1 years); // par now 2 - // we have 100 sai + // we have 100 dai // gem is worth 10 ref - // sai is worth 2 ref + // dai is worth 2 ref // we should get back 100 / (10 / 2) = 20 gem top.cage(); assertEq(gem.balanceOf(this), 1000 ether); - assertEq(sai.balanceOf(this), 100 ether); - assertEq(sai.balanceOf(tap), 0 ether); - tap.cash(sai.balanceOf(this)); + assertEq(dai.balanceOf(this), 100 ether); + assertEq(dai.balanceOf(tap), 0 ether); + tap.cash(dai.balanceOf(this)); assertEq(gem.balanceOf(this), 1020 ether); - assertEq(sai.balanceOf(this), 0 ether); - assertEq(sai.balanceOf(tap), 0 ether); + assertEq(dai.balanceOf(this), 0 ether); + assertEq(dai.balanceOf(tap), 0 ether); } // `boom` and `bust` as par is now needed to determine - // the skr / sai price. + // the peth / dai price. function testWayBust() public { var cup = waySetup(); mark(0.5 ether); @@ -1965,28 +1965,28 @@ contract WayTest is SaiTestBase { assertEq(tap.joy(), 0 ether); assertEq(tap.woe(), 100 ether); assertEq(tap.fog(), 100 ether); - assertEq(sai.balanceOf(this), 100 ether); + assertEq(dai.balanceOf(this), 100 ether); tap.bust(50 ether); assertEq(tap.fog(), 50 ether); assertEq(tap.woe(), 75 ether); - assertEq(sai.balanceOf(this), 75 ether); + assertEq(dai.balanceOf(this), 75 ether); mom.setWay(999999978020447331861593082); // -50% / year warp(1 years); assertEq(wad(vox.par()), 0.5 ether); - // sai now worth half as much, so we cover twice as much debt - // for the same skr + // dai now worth half as much, so we cover twice as much debt + // for the same peth tap.bust(50 ether); assertEq(tap.fog(), 0 ether); assertEq(tap.woe(), 25 ether); - assertEq(sai.balanceOf(this), 25 ether); + assertEq(dai.balanceOf(this), 25 ether); } } -contract GapTest is SaiTestBase { +contract GapTest is DaiTestBase { // boom and bust have a spread parameter function setUp() public { super.setUp(); @@ -1994,19 +1994,19 @@ contract GapTest is SaiTestBase { gem.deposit.value(500 ether)(); tub.join(500 ether); - sai.mint(500 ether); + dai.mint(500 ether); sin.mint(500 ether); - mark(2 ether); // 2 ref per eth => 2 sai per skr + mark(2 ether); // 2 ref per eth => 2 dai per peth } - function testGapSaiTapBid() public { + function testGapDaiTapBid() public { mark(1 ether); mom.setTapGap(1.01 ether); // 1% spread assertEq(tap.bid(1 ether), 0.99 ether); mark(2 ether); assertEq(tap.bid(1 ether), 1.98 ether); } - function testGapSaiTapAsk() public { + function testGapDaiTapAsk() public { mark(1 ether); mom.setTapGap(1.01 ether); // 1% spread assertEq(tap.ask(1 ether), 1.01 ether); @@ -2014,34 +2014,34 @@ contract GapTest is SaiTestBase { assertEq(tap.ask(1 ether), 2.02 ether); } function testGapBoom() public { - sai.push(tap, 198 ether); + dai.push(tap, 198 ether); assertEq(tap.joy(), 198 ether); mom.setTapGap(1.01 ether); // 1% spread - var sai_before = sai.balanceOf(this); - var skr_before = skr.balanceOf(this); + var dai_before = dai.balanceOf(this); + var peth_before = peth.balanceOf(this); tap.boom(50 ether); - var sai_after = sai.balanceOf(this); - var skr_after = skr.balanceOf(this); - assertEq(sai_after - sai_before, 99 ether); - assertEq(skr_before - skr_after, 50 ether); + var dai_after = dai.balanceOf(this); + var peth_after = peth.balanceOf(this); + assertEq(dai_after - dai_before, 99 ether); + assertEq(peth_before - peth_after, 50 ether); } function testGapBust() public { - skr.push(tap, 100 ether); + peth.push(tap, 100 ether); sin.push(tap, 200 ether); assertEq(tap.fog(), 100 ether); assertEq(tap.woe(), 200 ether); mom.setTapGap(1.01 ether); - var sai_before = sai.balanceOf(this); - var skr_before = skr.balanceOf(this); + var dai_before = dai.balanceOf(this); + var peth_before = peth.balanceOf(this); tap.bust(50 ether); - var sai_after = sai.balanceOf(this); - var skr_after = skr.balanceOf(this); - assertEq(skr_after - skr_before, 50 ether); - assertEq(sai_before - sai_after, 101 ether); + var dai_after = dai.balanceOf(this); + var peth_after = peth.balanceOf(this); + assertEq(peth_after - peth_before, 50 ether); + assertEq(dai_before - dai_after, 101 ether); } function testGapLimits() public { uint256 legal = 1.04 ether; @@ -2066,9 +2066,9 @@ contract GapTest is SaiTestBase { assertEq(tub.bid(1 ether), 0.99 ether); assertEq(tub.ask(1 ether), 1.01 ether); - assertEq(skr.balanceOf(this), 500 ether); - assertEq(skr.totalSupply(), 500 ether); - skr.burn(250 ether); + assertEq(peth.balanceOf(this), 500 ether); + assertEq(peth.totalSupply(), 500 ether); + peth.burn(250 ether); assertEq(tub.per(), ray(2 ether)); assertEq(tub.bid(1 ether), 1.98 ether); @@ -2078,13 +2078,13 @@ contract GapTest is SaiTestBase { gem.deposit.value(100 ether)(); mom.setTubGap(1.05 ether); - var skr_before = skr.balanceOf(this); + var peth_before = peth.balanceOf(this); var gem_before = gem.balanceOf(this); tub.join(100 ether); - var skr_after = skr.balanceOf(this); + var peth_after = peth.balanceOf(this); var gem_after = gem.balanceOf(this); - assertEq(skr_after - skr_before, 100 ether); + assertEq(peth_after - peth_before, 100 ether); assertEq(gem_before - gem_after, 105 ether); } function testGapExit() public { @@ -2092,18 +2092,18 @@ contract GapTest is SaiTestBase { tub.join(100 ether); mom.setTubGap(1.05 ether); - var skr_before = skr.balanceOf(this); + var peth_before = peth.balanceOf(this); var gem_before = gem.balanceOf(this); tub.exit(100 ether); - var skr_after = skr.balanceOf(this); + var peth_after = peth.balanceOf(this); var gem_after = gem.balanceOf(this); assertEq(gem_after - gem_before, 95 ether); - assertEq(skr_before - skr_after, 100 ether); + assertEq(peth_before - peth_after, 100 ether); } } -contract GasTest is SaiTestBase { +contract GasTest is DaiTestBase { bytes32 cup; function setUp() public { super.setUp(); @@ -2168,20 +2168,20 @@ contract GasTest is SaiTestBase { function testGasBoom() public { warp(tic); tub.join(10 ether); - sai.mint(100 ether); - sai.push(tap, 100 ether); - skr.approve(tap, uint(-1)); + dai.mint(100 ether); + dai.push(tap, 100 ether); + peth.approve(tap, uint(-1)); doBoom(1 ether); // assertTrue(false); } function testGasBoomHeal() public { warp(tic); tub.join(10 ether); - sai.mint(100 ether); + dai.mint(100 ether); sin.mint(100 ether); - sai.push(tap, 100 ether); + dai.push(tap, 100 ether); sin.push(tap, 50 ether); - skr.approve(tap, uint(-1)); + peth.approve(tap, uint(-1)); doBoom(1 ether); // assertTrue(false); } @@ -2207,7 +2207,7 @@ contract GasTest is SaiTestBase { } } -contract FeeTest is SaiTestBase { +contract FeeTest is DaiTestBase { function feeSetup() public returns (bytes32 cup) { mark(10 ether); mark(gov, 1 ether / 2); @@ -2354,7 +2354,7 @@ contract FeeTest is SaiTestBase { } } -contract PitTest is SaiTestBase { +contract PitTest is DaiTestBase { function testPitBurns() public { gov.mint(1 ether); assertEq(gov.balanceOf(pit), 0 ether); @@ -2371,7 +2371,7 @@ contract PitTest is SaiTestBase { } } -contract FeeTaxTest is SaiTestBase { +contract FeeTaxTest is DaiTestBase { function feeSetup() public returns (bytes32 cup) { mark(10 ether); mark(gov, 1 ether / 2); @@ -2444,7 +2444,7 @@ contract FeeTaxTest is SaiTestBase { assertEq(rdiv(wad, tub.chi()), art); assertEq(rdiv(add(wad, owe), tub.rhi()), ire); - sai.mint(5 ether); // need to magic up some extra sai to pay tax + dai.mint(5 ether); // need to magic up some extra dai to pay tax assertEq(tub.rap(cup), 5.25 ether); assertEq(gov.balanceOf(this), 100 ether); @@ -2454,7 +2454,7 @@ contract FeeTaxTest is SaiTestBase { } } -contract AxeTest is SaiTestBase { +contract AxeTest is DaiTestBase { function axeSetup() public returns (bytes32) { mom.setCap(1000 ether); mark(1 ether); @@ -2532,7 +2532,7 @@ contract AxeTest is SaiTestBase { } } -contract DustTest is SaiTestBase { +contract DustTest is DaiTestBase { function testFailLockUnderDust() public { tub.join(1 ether); var cup = tub.open(); diff --git a/src/fab.sol b/src/fab.sol index da8e234..a9f08a8 100644 --- a/src/fab.sol +++ b/src/fab.sol @@ -16,36 +16,36 @@ contract GemFab { } contract VoxFab { - function newVox() public returns (SaiVox vox) { - vox = new SaiVox(10 ** 27); + function newVox() public returns (DaiVox vox) { + vox = new DaiVox(10 ** 27); vox.setOwner(msg.sender); } } contract TubFab { - function newTub(DSToken sai, DSToken sin, DSToken skr, ERC20 gem, DSToken gov, DSValue pip, DSValue pep, SaiVox vox, address pit) public returns (SaiTub tub) { - tub = new SaiTub(sai, sin, skr, gem, gov, pip, pep, vox, pit); + function newTub(DSToken dai, DSToken sin, DSToken peth, ERC20 gem, DSToken gov, DSValue pip, DSValue pep, DaiVox vox, address pit) public returns (DaiTub tub) { + tub = new DaiTub(dai, sin, peth, gem, gov, pip, pep, vox, pit); tub.setOwner(msg.sender); } } contract TapFab { - function newTap(SaiTub tub) public returns (SaiTap tap) { - tap = new SaiTap(tub); + function newTap(DaiTub tub) public returns (DaiTap tap) { + tap = new DaiTap(tub); tap.setOwner(msg.sender); } } contract TopFab { - function newTop(SaiTub tub, SaiTap tap) public returns (SaiTop top) { - top = new SaiTop(tub, tap); + function newTop(DaiTub tub, DaiTap tap) public returns (DaiTop top) { + top = new DaiTop(tub, tap); top.setOwner(msg.sender); } } contract MomFab { - function newMom(SaiTub tub, SaiTap tap, SaiVox vox) public returns (SaiMom mom) { - mom = new SaiMom(tub, tap, vox); + function newMom(DaiTub tub, DaiTap tap, DaiVox vox) public returns (DaiMom mom) { + mom = new DaiMom(tub, tap, vox); mom.setOwner(msg.sender); } } @@ -66,16 +66,16 @@ contract DaiFab is DSAuth { MomFab public momFab; DadFab public dadFab; - DSToken public sai; + DSToken public dai; DSToken public sin; - DSToken public skr; + DSToken public peth; - SaiVox public vox; - SaiTub public tub; - SaiTap public tap; - SaiTop public top; + DaiVox public vox; + DaiTub public tub; + DaiTap public tap; + DaiTop public top; - SaiMom public mom; + DaiMom public mom; DSGuard public dad; uint8 public step = 0; @@ -92,9 +92,9 @@ contract DaiFab is DSAuth { function makeTokens() public auth { require(step == 0); - sai = gemFab.newTok('DAI'); + dai = gemFab.newTok('DAI'); sin = gemFab.newTok('SIN'); - skr = gemFab.newTok('PETH'); + peth = gemFab.newTok('PETH'); step += 1; } @@ -106,7 +106,7 @@ contract DaiFab is DSAuth { require(address(pep) != 0x0); require(pit != 0x0); vox = voxFab.newVox(); - tub = tubFab.newTub(sai, sin, skr, gem, gov, pip, pep, vox, pit); + tub = tubFab.newTub(dai, sin, peth, gem, gov, pip, pep, vox, pit); step += 1; } @@ -179,12 +179,12 @@ contract DaiFab is DSAuth { tub.setOwner(0); tap.setAuthority(dad); tap.setOwner(0); - sai.setAuthority(dad); - sai.setOwner(0); + dai.setAuthority(dad); + dai.setOwner(0); sin.setAuthority(dad); sin.setOwner(0); - skr.setAuthority(dad); - skr.setOwner(0); + peth.setAuthority(dad); + peth.setOwner(0); top.setAuthority(authority); top.setOwner(0); @@ -195,22 +195,22 @@ contract DaiFab is DSAuth { dad.permit(top, tub, S("flow()")); dad.permit(top, tap, S("cage(uint256)")); - dad.permit(tub, skr, S('mint(address,uint256)')); - dad.permit(tub, skr, S('burn(address,uint256)')); + dad.permit(tub, peth, S('mint(address,uint256)')); + dad.permit(tub, peth, S('burn(address,uint256)')); - dad.permit(tub, sai, S('mint(address,uint256)')); - dad.permit(tub, sai, S('burn(address,uint256)')); + dad.permit(tub, dai, S('mint(address,uint256)')); + dad.permit(tub, dai, S('burn(address,uint256)')); dad.permit(tub, sin, S('mint(address,uint256)')); - dad.permit(tap, sai, S('mint(address,uint256)')); - dad.permit(tap, sai, S('burn(address,uint256)')); - dad.permit(tap, sai, S('burn(uint256)')); + dad.permit(tap, dai, S('mint(address,uint256)')); + dad.permit(tap, dai, S('burn(address,uint256)')); + dad.permit(tap, dai, S('burn(uint256)')); dad.permit(tap, sin, S('burn(uint256)')); - dad.permit(tap, skr, S('mint(uint256)')); - dad.permit(tap, skr, S('burn(uint256)')); - dad.permit(tap, skr, S('burn(address,uint256)')); + dad.permit(tap, peth, S('mint(uint256)')); + dad.permit(tap, peth, S('burn(uint256)')); + dad.permit(tap, peth, S('burn(address,uint256)')); dad.permit(mom, vox, S("mold(bytes32,uint256)")); dad.permit(mom, vox, S("tune(uint256)")); diff --git a/src/mom.sol b/src/mom.sol index ada492e..e32964a 100644 --- a/src/mom.sol +++ b/src/mom.sol @@ -24,12 +24,12 @@ import './tub.sol'; import './top.sol'; import './tap.sol'; -contract SaiMom is DSThing { - SaiTub public tub; - SaiTap public tap; - SaiVox public vox; +contract DaiMom is DSThing { + DaiTub public tub; + DaiTap public tap; + DaiVox public vox; - function SaiMom(SaiTub tub_, SaiTap tap_, SaiVox vox_) public { + function DaiMom(DaiTub tub_, DaiTap tap_, DaiVox vox_) public { tub = tub_; tap = tap_; vox = vox_; @@ -79,7 +79,7 @@ contract SaiMom is DSThing { tub.setPep(pep_); } // TRFM - function setVox(SaiVox vox_) public note auth { + function setVox(DaiVox vox_) public note auth { tub.setVox(vox_); } // Boom/Bust Spread diff --git a/src/tap.sol b/src/tap.sol index 8f312fd..37ba892 100644 --- a/src/tap.sol +++ b/src/tap.sol @@ -21,13 +21,13 @@ pragma solidity ^0.4.18; import "./tub.sol"; -contract SaiTap is DSThing { - DSToken public sai; +contract DaiTap is DSThing { + DSToken public dai; DSToken public sin; - DSToken public skr; + DSToken public peth; - SaiVox public vox; - SaiTub public tub; + DaiVox public vox; + DaiTub public tub; uint256 public gap; // Boom-Bust Spread bool public off; // Cage flag @@ -35,7 +35,7 @@ contract SaiTap is DSThing { // Surplus function joy() public view returns (uint) { - return sai.balanceOf(this); + return dai.balanceOf(this); } // Bad debt function woe() public view returns (uint) { @@ -43,16 +43,16 @@ contract SaiTap is DSThing { } // Collateral pending liquidation function fog() public view returns (uint) { - return skr.balanceOf(this); + return peth.balanceOf(this); } - function SaiTap(SaiTub tub_) public { + function DaiTap(DaiTub tub_) public { tub = tub_; - sai = tub.sai(); + dai = tub.dai(); sin = tub.sin(); - skr = tub.skr(); + peth = tub.peth(); vox = tub.vox(); @@ -67,39 +67,39 @@ contract SaiTap is DSThing { function heal() public note { if (joy() == 0 || woe() == 0) return; // optimised var wad = min(joy(), woe()); - sai.burn(wad); + dai.burn(wad); sin.burn(wad); } - // Feed price (sai per skr) + // Feed price (dai per peth) function s2s() public returns (uint) { - var tag = tub.tag(); // ref per skr - var par = vox.par(); // ref per sai - return rdiv(tag, par); // sai per skr + var tag = tub.tag(); // ref per peth + var par = vox.par(); // ref per dai + return rdiv(tag, par); // dai per peth } - // Boom price (sai per skr) + // Boom price (dai per peth) function bid(uint wad) public returns (uint) { return rmul(wad, wmul(s2s(), sub(2 * WAD, gap))); } - // Bust price (sai per skr) + // Bust price (dai per peth) function ask(uint wad) public returns (uint) { return rmul(wad, wmul(s2s(), gap)); } function flip(uint wad) internal { require(ask(wad) > 0); - skr.push(msg.sender, wad); - sai.pull(msg.sender, ask(wad)); + peth.push(msg.sender, wad); + dai.pull(msg.sender, ask(wad)); heal(); } function flop(uint wad) internal { - skr.mint(sub(wad, fog())); + peth.mint(sub(wad, fog())); flip(wad); require(joy() == 0); // can't flop into surplus } function flap(uint wad) internal { heal(); - sai.push(msg.sender, bid(wad)); - skr.burn(msg.sender, wad); + dai.push(msg.sender, bid(wad)); + peth.burn(msg.sender, wad); } function bust(uint wad) public note { require(!off); @@ -120,16 +120,16 @@ contract SaiTap is DSThing { } function cash(uint wad) public note { require(off); - sai.burn(msg.sender, wad); + dai.burn(msg.sender, wad); require(tub.gem().transfer(msg.sender, rmul(wad, fix))); } function mock(uint wad) public note { require(off); - sai.mint(msg.sender, wad); + dai.mint(msg.sender, wad); require(tub.gem().transferFrom(msg.sender, this, rmul(wad, fix))); } function vent() public note { require(off); - skr.burn(fog()); + peth.burn(fog()); } } diff --git a/src/top.sol b/src/top.sol index 2216e1e..ddafed0 100644 --- a/src/top.sol +++ b/src/top.sol @@ -22,30 +22,30 @@ pragma solidity ^0.4.18; import "./tub.sol"; import "./tap.sol"; -contract SaiTop is DSThing { - SaiVox public vox; - SaiTub public tub; - SaiTap public tap; +contract DaiTop is DSThing { + DaiVox public vox; + DaiTub public tub; + DaiTap public tap; - DSToken public sai; + DSToken public dai; DSToken public sin; - DSToken public skr; + DSToken public peth; ERC20 public gem; - uint256 public fix; // sai cage price (gem per sai) - uint256 public fit; // skr cage price (ref per skr) + uint256 public fix; // dai cage price (gem per dai) + uint256 public fit; // peth cage price (ref per peth) uint256 public caged; uint256 public cooldown = 6 hours; - function SaiTop(SaiTub tub_, SaiTap tap_) public { + function DaiTop(DaiTub tub_, DaiTap tap_) public { tub = tub_; tap = tap_; vox = tub.vox(); - sai = tub.sai(); + dai = tub.dai(); sin = tub.sin(); - skr = tub.skr(); + peth = tub.peth(); gem = tub.gem(); } @@ -53,10 +53,10 @@ contract SaiTop is DSThing { return block.timestamp; } - // force settlement of the system at a given price (sai per gem). + // force settlement of the system at a given price (dai per gem). // This is nearly the equivalent of biting all cups at once. - // Important consideration: the gems associated with free skr can - // be tapped to make sai whole. + // Important consideration: the gems associated with free peth can + // be tapped to make dai whole. function cage(uint price) internal { require(!tub.off() && price != 0); caged = era(); @@ -65,18 +65,18 @@ contract SaiTop is DSThing { tap.heal(); // absorb any pending fees fit = rmul(wmul(price, vox.par()), tub.per()); - // Most gems we can get per sai is the full balance of the tub. - // If there is no sai issued, we should still be able to cage. - if (sai.totalSupply() == 0) { + // Most gems we can get per dai is the full balance of the tub. + // If there is no dai issued, we should still be able to cage. + if (dai.totalSupply() == 0) { fix = rdiv(WAD, price); } else { - fix = min(rdiv(WAD, price), rdiv(tub.pie(), sai.totalSupply())); + fix = min(rdiv(WAD, price), rdiv(tub.pie(), dai.totalSupply())); } - tub.cage(fit, rmul(fix, sai.totalSupply())); + tub.cage(fit, rmul(fix, dai.totalSupply())); tap.cage(fix); - tap.vent(); // burn pending sale skr + tap.vent(); // burn pending sale peth } // cage by reading the last value from the feed for the price function cage() public note auth { diff --git a/src/tub.sol b/src/tub.sol index fa9ebd3..e2a5f2c 100644 --- a/src/tub.sol +++ b/src/tub.sol @@ -25,20 +25,20 @@ import "ds-value/value.sol"; import "./vox.sol"; -contract SaiTubEvents { +contract DaiTubEvents { event LogNewCup(address indexed lad, bytes32 cup); } -contract SaiTub is DSThing, SaiTubEvents { - DSToken public sai; // Stablecoin - DSToken public sin; // Debt (negative sai) +contract DaiTub is DSThing, DaiTubEvents { + DSToken public dai; // Stablecoin + DSToken public sin; // Debt (negative dai) - DSToken public skr; // Abstracted collateral + DSToken public peth; // Abstracted collateral ERC20 public gem; // Underlying collateral DSToken public gov; // Governance token - SaiVox public vox; // Target price feed + DaiVox public vox; // Target price feed DSValue public pip; // Reference price feed DSValue public pep; // Governance price feed @@ -55,7 +55,7 @@ contract SaiTub is DSThing, SaiTubEvents { bool public off; // Cage flag bool public out; // Post cage exit - uint256 public fit; // REF per SKR (just before settlement) + uint256 public fit; // REF per PETH (just before settlement) uint256 public rho; // Time of last drip uint256 _chi; // Accumulated Tax Rates @@ -67,7 +67,7 @@ contract SaiTub is DSThing, SaiTubEvents { struct Cup { address lad; // CDP owner - uint256 ink; // Locked collateral (in SKR) + uint256 ink; // Locked collateral (in PETH) uint256 art; // Outstanding normalised debt (tax only) uint256 ire; // Outstanding normalised debt } @@ -91,7 +91,7 @@ contract SaiTub is DSThing, SaiTubEvents { } // Backing collateral function air() public view returns (uint) { - return skr.balanceOf(this); + return peth.balanceOf(this); } // Raw collateral function pie() public view returns (uint) { @@ -100,21 +100,21 @@ contract SaiTub is DSThing, SaiTubEvents { //------------------------------------------------------------------ - function SaiTub( - DSToken sai_, + function DaiTub( + DSToken dai_, DSToken sin_, - DSToken skr_, + DSToken peth_, ERC20 gem_, DSToken gov_, DSValue pip_, DSValue pep_, - SaiVox vox_, + DaiVox vox_, address pit_ ) public { gem = gem_; - skr = skr_; + peth = peth_; - sai = sai_; + dai = dai_; sin = sin_; gov = gov_; @@ -160,7 +160,7 @@ contract SaiTub is DSThing, SaiTubEvents { function setPep(DSValue pep_) public note auth { pep = pep_; } - function setVox(SaiVox vox_) public note auth { + function setVox(DaiVox vox_) public note auth { vox = vox_; } @@ -173,15 +173,15 @@ contract SaiTub is DSThing, SaiTubEvents { //--Collateral-wrapper---------------------------------------------- - // Wrapper ratio (gem per skr) + // Wrapper ratio (gem per peth) function per() public view returns (uint ray) { - return skr.totalSupply() == 0 ? RAY : rdiv(pie(), skr.totalSupply()); + return peth.totalSupply() == 0 ? RAY : rdiv(pie(), peth.totalSupply()); } - // Join price (gem per skr) + // Join price (gem per peth) function ask(uint wad) public view returns (uint) { return rmul(wad, wmul(per(), gap)); } - // Exit price (gem per skr) + // Exit price (gem per peth) function bid(uint wad) public view returns (uint) { return rmul(wad, wmul(per(), sub(2 * WAD, gap))); } @@ -189,12 +189,12 @@ contract SaiTub is DSThing, SaiTubEvents { require(!off); require(ask(wad) > 0); require(gem.transferFrom(msg.sender, this, ask(wad))); - skr.mint(msg.sender, wad); + peth.mint(msg.sender, wad); } function exit(uint wad) public note { require(!off || out); require(gem.transfer(msg.sender, bid(wad))); - skr.burn(msg.sender, wad); + peth.burn(msg.sender, wad); } //--Stability-fee-accumulation-------------------------------------- @@ -222,7 +222,7 @@ contract SaiTub is DSThing, SaiTubEvents { var _chi_ = _chi; inc = rpow(tax, age); _chi = rmul(_chi, inc); - sai.mint(tap, rmul(sub(_chi, _chi_), rum)); + dai.mint(tap, rmul(sub(_chi, _chi_), rum)); } // optimised @@ -233,7 +233,7 @@ contract SaiTub is DSThing, SaiTubEvents { //--CDP-risk-indicator---------------------------------------------- - // Abstracted collateral price (ref per skr) + // Abstracted collateral price (ref per peth) function tag() public view returns (uint wad) { return off ? fit : wmul(per(), uint(pip.read())); } @@ -264,13 +264,13 @@ contract SaiTub is DSThing, SaiTubEvents { function lock(bytes32 cup, uint wad) public note { require(!off); cups[cup].ink = add(cups[cup].ink, wad); - skr.pull(msg.sender, wad); + peth.pull(msg.sender, wad); require(cups[cup].ink == 0 || cups[cup].ink > 0.005 ether); } function free(bytes32 cup, uint wad) public note { require(msg.sender == cups[cup].lad); cups[cup].ink = sub(cups[cup].ink, wad); - skr.push(msg.sender, wad); + peth.push(msg.sender, wad); require(safe(cup)); require(cups[cup].ink == 0 || cups[cup].ink > 0.005 ether); } @@ -284,10 +284,10 @@ contract SaiTub is DSThing, SaiTubEvents { rum = add(rum, rdiv(wad, chi())); cups[cup].ire = add(cups[cup].ire, rdiv(wad, rhi())); - sai.mint(cups[cup].lad, wad); + dai.mint(cups[cup].lad, wad); require(safe(cup)); - require(sai.totalSupply() <= cap); + require(dai.totalSupply() <= cap); } function wipe(bytes32 cup, uint wad) public note { require(!off); @@ -298,7 +298,7 @@ contract SaiTub is DSThing, SaiTubEvents { rum = sub(rum, rdiv(wad, chi())); cups[cup].ire = sub(cups[cup].ire, rdiv(add(wad, owe), rhi())); - sai.burn(msg.sender, wad); + dai.burn(msg.sender, wad); var (val, ok) = pep.peek(); if (ok && val != 0) gov.move(msg.sender, pit, wdiv(owe, uint(val))); @@ -322,14 +322,14 @@ contract SaiTub is DSThing, SaiTubEvents { cups[cup].art = 0; cups[cup].ire = 0; - // Amount owed in SKR, including liquidation penalty + // Amount owed in PETH, including liquidation penalty var owe = rdiv(rmul(rmul(rue, axe), vox.par()), tag()); if (owe > cups[cup].ink) { owe = cups[cup].ink; } - skr.push(tap, owe); + peth.push(tap, owe); cups[cup].ink = sub(cups[cup].ink, owe); } @@ -340,7 +340,7 @@ contract SaiTub is DSThing, SaiTubEvents { off = true; axe = RAY; gap = WAD; - fit = fit_; // ref per skr + fit = fit_; // ref per peth require(gem.transfer(tap, jam)); } function flow() public note auth { diff --git a/src/tub.t.sol b/src/tub.t.sol index ce97002..b867a0f 100644 --- a/src/tub.t.sol +++ b/src/tub.t.sol @@ -9,52 +9,52 @@ import "ds-test/test.sol"; contract TubTest is DSTest, DSThing { address tap; - SaiTub tub; - SaiVox vox; + DaiTub tub; + DaiVox vox; DSGuard dad; DSValue pip; DSValue pep; - DSToken sai; + DSToken dai; DSToken sin; - DSToken skr; + DSToken peth; DSToken gem; DSToken gov; function setUp() public { - sai = new DSToken("SAI"); + dai = new DSToken("DAI"); sin = new DSToken("SIN"); - skr = new DSToken("SKR"); + peth = new DSToken("PETH"); gem = new DSToken("GEM"); gov = new DSToken("GOV"); pip = new DSValue(); pep = new DSValue(); dad = new DSGuard(); - vox = new SaiVox(RAY); - tub = new SaiTub(sai, sin, skr, gem, gov, pip, pep, vox, 0x123); + vox = new DaiVox(RAY); + tub = new DaiTub(dai, sin, peth, gem, gov, pip, pep, vox, 0x123); tap = 0x456; tub.turn(tap); //Set whitelist authority - skr.setAuthority(dad); + peth.setAuthority(dad); - //Permit tub to 'mint' and 'burn' SKR - dad.permit(tub, skr, bytes4(keccak256('mint(address,uint256)'))); - dad.permit(tub, skr, bytes4(keccak256('burn(address,uint256)'))); + //Permit tub to 'mint' and 'burn' PETH + dad.permit(tub, peth, bytes4(keccak256('mint(address,uint256)'))); + dad.permit(tub, peth, bytes4(keccak256('burn(address,uint256)'))); - //Allow tub to mint, burn, and transfer gem/skr without approval + //Allow tub to mint, burn, and transfer gem/peth without approval gem.approve(tub); - skr.approve(tub); - sai.approve(tub); + peth.approve(tub); + dai.approve(tub); gem.mint(6 ether); //Verify initial token balances assertEq(gem.balanceOf(this), 6 ether); assertEq(gem.balanceOf(tub), 0 ether); - assertEq(skr.totalSupply(), 0 ether); + assertEq(peth.totalSupply(), 0 ether); assert(!tub.off()); } @@ -74,7 +74,7 @@ contract TubTest is DSTest, DSThing { function testPer() public { tub.join(5 ether); - assertEq(skr.totalSupply(), 5 ether); + assertEq(peth.totalSupply(), 5 ether); assertEq(tub.per(), rdiv(5 ether, 5 ether)); } @@ -111,11 +111,11 @@ contract TubTest is DSTest, DSThing { tub.join(3 ether); assertEq(gem.balanceOf(this), 3 ether); assertEq(gem.balanceOf(tub), 3 ether); - assertEq(skr.totalSupply(), 3 ether); + assertEq(peth.totalSupply(), 3 ether); tub.join(1 ether); assertEq(gem.balanceOf(this), 2 ether); assertEq(gem.balanceOf(tub), 4 ether); - assertEq(skr.totalSupply(), 4 ether); + assertEq(peth.totalSupply(), 4 ether); } function testExit() public { @@ -125,30 +125,30 @@ contract TubTest is DSTest, DSThing { tub.join(12 ether); assertEq(gem.balanceOf(tub), 12 ether); assertEq(gem.balanceOf(this), 4 ether); - assertEq(skr.totalSupply(), 12 ether); + assertEq(peth.totalSupply(), 12 ether); tub.exit(3 ether); assertEq(gem.balanceOf(tub), 9 ether); assertEq(gem.balanceOf(this), 7 ether); - assertEq(skr.totalSupply(), 9 ether); + assertEq(peth.totalSupply(), 9 ether); tub.exit(7 ether); assertEq(gem.balanceOf(tub), 2 ether); assertEq(gem.balanceOf(this), 14 ether); - assertEq(skr.totalSupply(), 2 ether); + assertEq(peth.totalSupply(), 2 ether); } function testCage() public { tub.join(5 ether); assertEq(gem.balanceOf(tub), 5 ether); assertEq(gem.balanceOf(this), 1 ether); - assertEq(skr.totalSupply(), 5 ether); + assertEq(peth.totalSupply(), 5 ether); assert(!tub.off()); tub.cage(tub.per(), 5 ether); assertEq(gem.balanceOf(tub), 0 ether); assertEq(gem.balanceOf(tap), 5 ether); - assertEq(skr.totalSupply(), 5 ether); + assertEq(peth.totalSupply(), 5 ether); assert(tub.off()); } diff --git a/src/vox.sol b/src/vox.sol index fb033c6..4bd1d3b 100644 --- a/src/vox.sol +++ b/src/vox.sol @@ -21,7 +21,7 @@ pragma solidity ^0.4.18; import "ds-thing/thing.sol"; -contract SaiVox is DSThing { +contract DaiVox is DSThing { uint256 _par; uint256 _way; @@ -29,7 +29,7 @@ contract SaiVox is DSThing { uint256 public how; uint256 public tau; - function SaiVox(uint par_) public { + function DaiVox(uint par_) public { _par = fix = par_; _way = RAY; tau = era(); diff --git a/src/vox.t.sol b/src/vox.t.sol index 07a0128..5ceb509 100644 --- a/src/vox.t.sol +++ b/src/vox.t.sol @@ -21,8 +21,8 @@ contract TestWarp is DSNote { } } -contract DevVox is SaiVox, TestWarp { - function DevVox(uint par_) SaiVox(par_) public {} +contract DevVox is DaiVox, TestWarp { + function DevVox(uint par_) DaiVox(par_) public {} } contract VoxTest is DSTest, DSMath {