{"id":19096853,"url":"https://github.com/makerdao/mkr-mcd-spec","last_synced_at":"2025-04-18T16:31:27.418Z","repository":{"id":41568343,"uuid":"199693364","full_name":"makerdao/mkr-mcd-spec","owner":"makerdao","description":"High level KSpecification for the MCD System by Runtime Verification and Maker Foundation","archived":true,"fork":false,"pushed_at":"2022-10-25T08:11:15.000Z","size":893,"stargazers_count":28,"open_issues_count":49,"forks_count":9,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-11T20:37:47.498Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-30T16:58:06.000Z","updated_at":"2024-06-29T02:21:32.000Z","dependencies_parsed_at":"2023-01-20T01:48:22.419Z","dependency_job_id":null,"html_url":"https://github.com/makerdao/mkr-mcd-spec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fmkr-mcd-spec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fmkr-mcd-spec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fmkr-mcd-spec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fmkr-mcd-spec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makerdao","download_url":"https://codeload.github.com/makerdao/mkr-mcd-spec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249517937,"owners_count":21284861,"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-11-09T03:37:59.394Z","updated_at":"2025-04-18T16:31:27.095Z","avatar_url":"https://github.com/makerdao.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"KMCD - Multi-Collateral Dai (MCD) KSpecification\n====================================================\n\nUseful Links\n------------\n\n-   K-DSS bytecode verification: [Reports](https://reports.makerfoundation.com/k-dss/) and [Repository](https://github.com/makerdao/k-dss)\n-   DSS solidity sources: \u003chttps://github.com/makerdao/dss\u003e\n-   Useful invariants: \u003chttps://hackmd.io/lWCjLs9NSiORaEzaWRJdsQ\u003e (note: `take` is out of date is currently represented in code as a Collateral's `spot` price)\n-   MCD Documentation: \u003chttps://docs.makerdao.com/\u003e\n-   MCD Wiki: \u003chttps://github.com/makerdao/dss/wiki\u003e\n\nStructure\n---------\n\nThe semantics is broken into several sub-modules.\n\n### Utility Files\n\n-   [kmcd-driver](kmcd-driver.md) - common functionality in all modules.\n-   [kmcd](kmcd.md) - union all sub-modules.\n-   [kmcd-props](kmcd-props.md) - statement of properties that we would like to hold for the model.\n-   [kmcd-prelude](kmcd-prelude.md) - random testing harness.\n\n### Accounting System\n\n-   [vat](vat.md) - tracks deposited collateral, open CDPs, and borrowed Dai.\n-   [pot](pot.md) - interest accumulation for saved Dai.\n-   [jug](jug.md) - stability fee collection.\n\n### Collateral\n\n-   [dai](dai.md) - Dai ERC20 token standard.\n-   [spot](spot.md) - price feed for collateral.\n-   [gem](gem.md) - abstract implementation of collateral.\n-   [join](join.md) - plug collateral into MCD system.\n\n### Liquidation/Auction Houses\n\n-   [cat](cat.md) - forcible liquidation of an over-leveraged CDP.\n-   [vow](vow.md) - manage and trigger liquidations.\n-   [flap](flap.md) - surplus auctions (Vat Dai for sale, bid increasing Gem MKR).\n-   [flop](flop.md) - deficit auctions (Gem MKR for sale, lot decreasing Vat Dai).\n-   [flip](flip.md) - general auction (Vat Gem for sale, bid increasing Vat Dai, lot decreasing Vat Dai).\n\n### Global Settlement\n\n-   [end](end.md) - close out all CDPs and auctions, attempt to re-distribute gems fairly according to internal accounting.\n\nBuilding\n--------\n\nAfter installing all the dependencies needed for [K Framework](https://github.com/kframework/k), you can run:\n\n```sh\nmake deps\nmake build -j4\n```\n\nIf you are on Arch Linux, add `K_BUILD_TYPE=Release` to `make deps`, as the `Debug` and `FastBuild` versions do not work.\n\nWhenever you update the K submodule (which happens regularly automatically on CI), you may need to do:\n\n```sh\nrm -rf deps\ngit submodule update --init --recursive\nmake deps\nmake build -j4\n```\n\nRunning Simple Tests\n--------------------\n\nIn directory `tests/`, we have some example runs of the system.\nYou can run on these simulations directly to get an idea of what the output of the system looks like.\n\n```sh\n./kmcd run --backend llvm tests/attacks/lucash-flip-end.mcd\n```\n\nIf you want to run all the attack tests (and check their output), run:\n\n```sh\nmake test-execution -j4\n```\n\nRunning Random Tester\n---------------------\n\n### Environment Setup\n\nMake sure that `pyk` library is on `PYTHONPATH`, and `krun` is on `PATH`:\n\n```sh\nexport PYTHONPATH=./deps/k/k-distribution/target/release/k/lib/kframework\nexport PATH=./deps/k/k-distribution/target/release/k/bin:$PATH\n```\n\n### `mcd-pyk.py` Usage\n\nYou can ask the random tester for help:\n\n```sh\n./mcd-pyk.py random-test --help\n```\n\nThen you can start the random tester running, with depth 100, up to 3000 times:\n\n```sh\n./mcd-pyk.py random-test 100 3000 \u0026\u003e random-test.out\n```\n\nThen you can watch `random-test.out` for assertion violations it finds (search for `Violation Found`).\n\nAdditionally, the option `--emit-solidity` is supported, which will make best-effort emissions of Solidity code:\n\n```sh\n./mcd-pyk.py random-test 100 3000 --emit-solidity \u0026\u003e random-test.out\n```\n\nThis emitted Solidity code can be used for conformance testing the Solidity implementation.\n\n### Speed up with `kserver`\n\nBy running KServer while working with `mcd-pyk.py`, you will see about 4x the throughput in simulations.\nThis basically keeps a \"warmed up\" JVM around, so that we don't have to start over each time.\n\nTo start the KServer run:\n\n```sh\nspawn-kserver kserver.log\n```\n\nAnd to stop the KServer, run:\n\n```sh\nstop-kserver\n```\n\nYou can make sure that the KServer is being used by running `tail -F kserver.log`.\nAs `mcd-pyk.py` is running, you should see entries like this being added:\n\n```kserver.log\nNGSession 10: org.kframework.main.Main exited with status 0\nNGSession 12: org.kframework.main.Main exited with status 0\nNGSession 14: org.kframework.main.Main exited with status 0\nNGSession 16: org.kframework.main.Main exited with status 0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakerdao%2Fmkr-mcd-spec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakerdao%2Fmkr-mcd-spec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakerdao%2Fmkr-mcd-spec/lists"}