{"id":13795346,"url":"https://github.com/makerdao/sai","last_synced_at":"2025-05-12T22:30:42.959Z","repository":{"id":41211680,"uuid":"86626270","full_name":"makerdao/sai","owner":"makerdao","description":"Single Collateral Dai","archived":true,"fork":false,"pushed_at":"2022-03-12T13:23:09.000Z","size":676,"stargazers_count":162,"open_issues_count":5,"forks_count":69,"subscribers_count":30,"default_branch":"master","last_synced_at":"2024-11-18T09:33:37.775Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/makerdao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-29T20:26:37.000Z","updated_at":"2024-10-30T08:22:58.000Z","dependencies_parsed_at":"2022-09-06T14:01:35.499Z","dependency_job_id":null,"html_url":"https://github.com/makerdao/sai","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fsai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fsai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fsai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fsai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makerdao","download_url":"https://codeload.github.com/makerdao/sai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253833081,"owners_count":21971357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T23:00:54.903Z","updated_at":"2025-05-12T22:30:42.358Z","avatar_url":"https://github.com/makerdao.png","language":"Solidity","funding_links":[],"categories":["Projects","Projects Using Dapp","Developer Resources"],"sub_categories":["DappTools","Single-Collateral Dai"],"readme":"\n\n\n_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._\n\n\n`sai` is a simple single-collateral stablecoin that is dependent on a\ntrusted oracle address and has a kill-switch.\n\nSee the [developer documentation](DEVELOPING.md) for a more technical\noverview.\n\nThere are four tokens in the system:\n\n- `gem`: externally valuable token e.g. ETH\n- `gov`: governance token e.g. MKR\n- `skr`: a claim to locked `gem`s\n- `sai`: the stablecoin, a variable claim on some quantity of `gem`s\n\nCollateral holders deposit their collateral using `join` and receive\n`skr` tokens proportional to their deposit. `skr` can be redeemed for\ncollateral with `exit`. You will get more or less `gem` tokens for each\n`skr` depending whether the system made a profit or loss while you\nwere exposed.\n\nThe oracle updates the GEM:REF and GOV:REF price feeds. These are the\nonly external real-time input to the system.\n\n`skr` is used as the direct backing collateral for CDPs. A prospective\nissuer can `open` an empty position, `lock` some `skr` and then `draw`\nsome `sai`. Debt is covered with `wipe`. Collateral can be reclaimed\nwith `free` as long as the CDP remains \"safe\".\n\nIf the value of the collateral backing the CDP falls below the\nliquidation ratio `mat`, the CDP is vulnerable to liquidation via\n`bite`. On liquidation, the CDP `skr` collateral is sold off to cover\nthe `sai` debt.\n\nUnder-collateralized CDPs can be liquidated with `bite`. Liquidation is\nimmediate: backing `skr` is taken to cover the `sai` debt at the time of\n`bite`, plus a liquidation fee (`axe`); any excess remains in the CDP.\n\n`skr` seized from bad CDPs can be purchased with `bust`, in exchange for\n`sai` at the `s2s` price. This `sai` pays down the bad CDP debt.\n\nAny remaining Sai surplus (`joy`) can be purchased with `boom`, in\nexchange for `skr` at the `s2s` price. This `skr` is burned.\n\n\n### Fees\n\nStability fee is continuously charged on all open cups according to `tax`.\nIt makes their debt (`tab`) increase over time.\n\nGovernance fee is continuously charged on all open cups according to `fee`.\nIt makes their debt (`rap`) increase over time.\n\n### Settlement\n\n`sai` can be shut down at a given price with `cage`, after which `sai`\nand `skr` can be exchanged for `gems` via `cash`. All outstanding `cups`\nare liquidated and the *entire pool* of `gem` is tapped to redeem `sai`\nat their face value, as if the boom/bust trades were instantly settled\nat the cage price.  Any remaining `gems` are shared between `skr`\nholders.\n\nPractically this means that if the system is undercollateralized on\n`cage`, holders of free `skr` will have their `gem` share diluted as\nmuch as necessary to make `sai` whole. *In other words, `skr` is a\nrisk bearing token*.\n\nExcess collateral contained within a single `cup` can be reclaimed with\n`bite(cup)`.\n\n\n### `sai` glossary (`sai help`)\n```\nActions:\n\n   bite            initiate liquidation of an undercollateral cup\n   boom            buy some amount of sai to process joy (surplus)\n   bust            sell some amount of sai to process woe (bad debt)\n   cage            lock the system and initiate settlement\n   cash            cash in sai balance for gems after cage\n   cupi            get the last cup id\n   cups            list cups created by you\n   draw            issue the specified amount of sai stablecoins\n   drip            recalculate the internal debt price\n   exit            sell SKR for gems\n   free            remove excess SKR collateral from a cup\n   give            transfer ownership of a cup\n   heal            cancel debt\n   help            print help about sai(1) or one of its subcommands\n   join            buy SKR for gems\n   lock            post additional SKR collateral to a cup\n   open            create a new cup (collateralized debt position)\n   prod            recalculate the accrued holder fee (par)\n   safe            determine if a cup is safe\n   setAxe          update the liquidation penalty\n   setFee          update the governance fee\n   setCap          update the debt ceiling\n   setMat          update the liquidation ratio\n   setTapGap       update the spread on `boom` and `bust`\n   setTax          update the stability fee\n   setTubGap       update the spread on `join` and `exit`\n   setWay          update the holder fee (interest rate)\n   shut            close a cup\n   vent            process a caged tub\n   wipe            repay some portion of your existing sai debt\n   \nVars, Getters, Utils:\n\n   air             get the amount of backing collateral\n   axe             get the liquidation penalty\n   caged           get time of cage event (= 0 if system is not caged)\n   chi             get the internal debt price\n   cup             show the cup info\n   fee             get the governance fee\n   fit             get the gem per skr settlement price\n   fix             get the gem per sai settlement price\n   fog             get the amount of skr pending liquidation\n   gem             get the collateral token\n   gov             get the governance token\n   cap             get the debt ceiling\n   ice             get the good debt\n   ink             get the amount of skr collateral locked in a cup\n   joy             get the amount of surplus sai\n   lad             get the owner of a cup\n   mat             get the liquidation ratio\n   off             get the cage flag\n   out             get the post cage exit flag\n   par             get the accrued holder fee (ref per sai)\n   per             get the current entry price (gem per skr)\n   pie             get the amount of raw collateral\n   pep             get the gov price feed\n   pip             get the gem price feed\n   pit             get the liquidator vault\n   rap             get the amount of governance debt in a cup\n   ray             parse and display a 27-decimal fixed-point number\n   rho             get the time of last drip\n   rhi             get the internal debt price (governance included)\n   s2s             get the skr per sai rate (for boom and bust)\n   sai             get the sai token\n   sin             get the sin token\n   skr             get the skr token\n   tab             get the amount of debt in a cup\n   tag             get the reference price (ref per skr)\n   tapAsk          get the amount of skr in sai for bust\n   tapBid          get the amount of skr in sai for boom\n   tapGap          get the spread on `boom` and `bust`\n   tau             get the time of last prod\n   tax             get the stability fee\n   tubAsk          get the amount of skr in gem for join\n   tubBid          get the amount of skr in gem for exit\n   tubGap          get the spread on `join` and `exit`\n   vox             get the target price engine\n   wad             parse and display a 18-decimal fixed-point number\n   way             get the holder fee (interest rate)\n   woe             get the amount of bad debt\n\n\n```\n\n### Sample interaction using `sai`\n\n```bash\n$ export ETH_FROM=0x(...)\n$ export SAI_TUB=0x(...)\n\n# Give the system access to our GEM (W-ETH), SKR and SAI balances\n# so we can join()/exit() and also draw()/wipe() sai\n$ token approve $(sai gem) $(sai tub) $(seth --to-wei 1000000000 ETH)\n$ token approve $(sai skr) $(sai tub) $(seth --to-wei 1000000000 ETH)\n$ token approve $(sai sai) $(sai tub) $(seth --to-wei 1000000000 ETH)\n\n# If we also plan on using boom() and bust(), a different component\n# (called `tap`) will need to have access to our SKR and SAI balances\n$ token approve $(sai skr) $(sai tap) $(seth --to-wei 1000000000 ETH)\n$ token approve $(sai sai) $(sai tap) $(seth --to-wei 1000000000 ETH)\n\n# We need to have some GEM (W-ETH) balance to start with\n$ token balance $(sai gem) $ETH_FROM\n2.467935274974511817\n\n# Join the system by exchanging some GEM (W-ETH) to SKR\n$ sai join 2.2\nGenerating 2.200000000000000000 SKR depositing GEM...\n$ token balance $(sai gem) $ETH_FROM\n0.267935274974511817\n$ token balance $(sai skr) $ETH_FROM\n2.200000000000000000\n\n# Open a new cup\n$ sai open\nOpening cup...\nOpened cup 62\n\n# We can list our cups at all times\n$ sai cups\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\nCups created by you...\n62\n\n# Lock some SKR collateral in the cup and then draw some SAI from it\n$ sai --cup 62 lock 1.5\t\t\t\t\t\t\t\t\t\t\t\t\t\nLocking 1.500000000000000000 SKR in cup 62...\n$ sai --cup 62 draw 89.0\t\t\t\t\t\t\t\t\t\t\t\t\nDrawing 89.000000000000000000 SAI from cup 62...\n$ token balance $(sai skr) $ETH_FROM\n0.700000000000000000\n$ token balance $(sai sai) $ETH_FROM\n89.000000000000000000\n\n# We can examine the cup details, `tab` and `ink` representing\n# the amount of debt and the amount of collateral respectively\n$ sai --cup 62 cup\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ncup id 62...\nlad: 0x(...)\nink: 1.500000000000000000\ntab: 89.000000000000000000\nrap: 0.000000000000000000\n\n# We can check whether the cup is still safe\n# (ie. whether the value of collateral locked is high enough)\n$ sai --cup 62 safe\ntrue\n\n# At some point we will want to wipe our SAI debt\n# which means we can also free the SKR collateral\n$ sai --cup 62 wipe 59.0\t\t\t\t\t\t\t\t\t\t\t\t\nWiping 59.000000000000000000 SAI from cup 62...\n$ sai --cup 62 free 1.1\t\t\t\t\t\t\t\t\t\t\t\t\t\nFreeing 1.100000000000000000 SKR from cup 62...\n$ token balance $(sai skr) $ETH_FROM\n1.800000000000000000\n$ token balance $(sai sai) $ETH_FROM\n30.000000000000000000\n\n# The `tab` and `ink` values have changed\n$ sai --cup 62 cup\ncup id 62...\nlad: 0x(...)\nink: 0.400000000000000000\ntab: 30.000000000000000000\nrap: 0.000000000000000000\n\n# We can also `wipe` and `free` outstanding balances of SAI and SKR by calling `shut`\n$ sai --cup 62 shut\nClosing cup 62...\n\n$ sai --cup 62 cup\ncup id 62...\nlad: 0x0000000000000000000000000000000000000000\nink: 0.000000000000000000\ntab: 0.000000000000000000\nrap: 0.000000000000000000\n\n# Exit the system by exchanging SKR back to GEM (W-ETH)\n$ sai exit 2.2\nSending 2.200000000000000000 SKR to TUB...\n$ token balance $(sai gem) $ETH_FROM\n2.467935274974511817\n$ token balance $(sai skr) $ETH_FROM\n0.000000000000000000\n```\n\n### Dai v1 Current deployments\n\nNames for tokens:\n  - Dai: `SAI_SAI`\n  - MKR: `SAI_GOV`\n  - WETH: `SAI_GEM`\n  - PETH: `SAI_SKR`\n\nMainnet:\n\n```bash\n# sai deployment on ethlive from c2031c0f9f3a186e90b6a3c1905282f7cc58b9f5\n# Mon 18 Dec 03:12:57 GMT 2017\n# SAI_ADM updated 2019-06-11\n\nexport SAI_GEM=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\nexport SAI_GOV=0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2\nexport SAI_PIP=0x729D19f657BD0614b4985Cf1D82531c67569197B\nexport SAI_PEP=0x99041F808D598B782D5a3e498681C2452A31da08\nexport SAI_PIT=0x69076e44a9c70a67d5b79d95795aba299083c275\nexport SAI_ADM=0x9eF05f7F6deB616fd37aC3c959a2dDD25A54E4F5\nexport SAI_SAI=0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359\nexport SAI_SIN=0x79f6d0f646706e1261acf0b93dcb864f357d4680\nexport SAI_SKR=0xf53ad2c6851052a81b42133467480961b2321c09\nexport SAI_DAD=0x315cbb88168396d12e1a255f9cb935408fe80710\nexport SAI_MOM=0xf2c5369cffb8ea6284452b0326e326dbfdcb867c\nexport SAI_VOX=0x9b0f70df76165442ca6092939132bbaea77f2d7a\nexport SAI_TUB=0x448a5065aebb8e423f0896e6c5d525c040f59af3\nexport SAI_TAP=0xbda109309f9fafa6dd6a9cb9f1df4085b27ee8ef\nexport SAI_TOP=0x9b0ccf7c8994e19f39b2b4cf708e0a7df65fa8a3\n```\n\nKovan:\n\n```bash\n\n# sai deployment on kovan from 7d9c16c056c9fc99cdf2f17bc7958837cd17ee41\n# Wed Jan  3 16:06:26 -03 2018\n\nexport SAI_GEM=0xd0a1e359811322d97991e03f863a0c30c2cf029c\nexport SAI_GOV=0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd\nexport SAI_PIP=0xa944bd4b25c9f186a846fd5668941aa3d3b8425f\nexport SAI_PEP=0x02998f73fabb52282664094b0ff87741a1ce9030\nexport SAI_PIT=0xbd747742b0f1f9791d3e6b85f8797a0cf4fbf10b\nexport SAI_ADM=0x74d41fd874234d9bea31ff6b090ba1d0b9dc8785\nexport SAI_SAI=0xc4375b7de8af5a38a93548eb8453a498222c4ff2\nexport SAI_SIN=0xdcdca4371befceafa069ca1e2afd8b925b69e57b\nexport SAI_SKR=0xf4d791139ce033ad35db2b2201435fad668b1b64\nexport SAI_DAD=0x6a884c7af48e29a20be9ff04bdde112b5596fcee\nexport SAI_MOM=0x72ee9496b0867dfe5e8b280254da55e51e34d27b\nexport SAI_VOX=0xbb4339c0ab5b1d9f14bd6e3426444a1e9d86a1d9\nexport SAI_TUB=0xa71937147b55deb8a530c7229c442fd3f31b7db2\nexport SAI_TAP=0xc936749d2d0139174ee0271bd28325074fdbc654\nexport SAI_TOP=0x5f00393547561da3030ebf30e52f5dc0d5d3362c\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakerdao%2Fsai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakerdao%2Fsai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakerdao%2Fsai/lists"}