{"id":22873985,"url":"https://github.com/angleprotocol/borrow-contracts","last_synced_at":"2025-05-06T19:12:32.498Z","repository":{"id":65601371,"uuid":"454086323","full_name":"AngleProtocol/borrow-contracts","owner":"AngleProtocol","description":"🦾 Smart contracts for Angle Borrowing Module","archived":false,"fork":false,"pushed_at":"2024-11-27T11:39:50.000Z","size":5407,"stargazers_count":38,"open_issues_count":4,"forks_count":17,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-06T19:12:18.720Z","etag":null,"topics":["ethereum","foundry","hardhat","solidity"],"latest_commit_sha":null,"homepage":"https://angle.money","language":"TypeScript","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/AngleProtocol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":"audits/Chainsecurity - May 2022.pdf","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-31T16:40:00.000Z","updated_at":"2024-11-27T11:39:59.000Z","dependencies_parsed_at":"2023-10-11T20:35:32.849Z","dependency_job_id":"d02d21e3-acc6-4561-9f8d-9a6423cdda85","html_url":"https://github.com/AngleProtocol/borrow-contracts","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngleProtocol%2Fborrow-contracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngleProtocol%2Fborrow-contracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngleProtocol%2Fborrow-contracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngleProtocol%2Fborrow-contracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AngleProtocol","download_url":"https://codeload.github.com/AngleProtocol/borrow-contracts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252752060,"owners_count":21798723,"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":["ethereum","foundry","hardhat","solidity"],"created_at":"2024-12-13T14:32:11.776Z","updated_at":"2025-05-06T19:12:32.477Z","avatar_url":"https://github.com/AngleProtocol.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\".github/assets/logo.svg\" alt=\"Angle Borrowing Module\" height=\"40px\"\u003e Angle Borrowing Module\n\n[![CI](https://github.com/AngleProtocol/borrow-contracts/actions/workflows/ci.yml/badge.svg)](https://github.com/AngleProtocol/borrow-contracts/actions)\n[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.angle.money/angle-borrowing-module/borrowing-module)\n[![Developers](https://img.shields.io/badge/developers-%F0%9F%93%84-pink)](https://developers.angle.money/borrowing-module-contracts/architecture-overview)\n\n## Documentation\n\n### To Start With\n\nAngle is a decentralized stablecoin protocol, designed to be both over-collateralized and capital-efficient. For more information about the protocol, you can refer to [Angle Documentation](https://docs.angle.money).\n\nThe protocol is made of different modules, each with their own set of smart contracts. This repo contains the Borrowing module smart contracts.\n\nSmart contracts used to for yield-bearing tokens as collateral assets in the Borrowing module are in a different repository that you can find [here](https://github.com/AngleProtocol/borrow-lpTokens-contracts).\n\n### Resources\n\n- [Documentation](https://docs.angle.money) to understand Angle Protocol's Borrowing Module\n- [Developers doc](https://developers.angle.money/borrowing-module-contracts/architecture-overview) to understand how these smart contracts work together work together\n- [Whitepaper](https://docs.angle.money/overview/whitepapers) for the module\n- [Portal](https://linktr.ee/angleprotocol) of resources for more info about the protocol\n- [Angle Protocol related audits](https://docs.angle.money/resources/audits)\n\n![Angle Borrowing Module Architecture](AngleBorrowingArchitecture.png)\n\n### Further Information\n\nFor a broader overview of the protocol and its different modules, you can also check [this overview page](https://developers.angle.money) of our developers documentation.\n\nOther Angle-related smart contracts can be found in the following repositories:\n\n- [Angle Core module contracts](https://github.com/AngleProtocol/angle-core)\n- [Angle Strategies](https://github.com/AngleProtocol/angle-strategies)\n- [Angle Router contracts](https://github.com/AngleProtocol/angle-router)\n- [Angle Direct Deposit Modules (or Algorithmic market operations)](https://github.com/AngleProtocol/angle-amo)\n\n### Audits\n\nThe contracts of this module have been audited by [Chainsecurity](https://chainsecurity.com/security-audit/angle-protocol-borrowing-module/). The audit reports can be found in the `audits/` folder of this repo.\n\n### Bug Bounty\n\nAt Angle, we consider the security of our systems a top priority. But even putting top priority status and maximum effort, there is still possibility that vulnerabilities exist.\n\nWe have therefore setup a bug bounty program with the help of Immunefi. The Angle Protocol bug bounty program is focused around our smart contracts with a primary interest in the prevention of:\n\n- Thefts and freezing of principal of any amount\n- Thefts and freezing of unclaimed yield of any amount\n- Theft of governance funds\n- Governance activity disruption\n\nFor more details, please refer to the [official page of the bounty on Immunefi](https://immunefi.com/bounty/angleprotocol/).\n\n| Level    |                     |\n| :------- | :------------------ |\n| Critical | up to USD \\$500,000 |\n| High     | USD \\$20,000        |\n| Medium   | USD \\$2,500         |\n\nAll bug reports must include a Proof of Concept demonstrating how the vulnerability can be exploited to be eligible for a reward. This may be a smart contract itself or a transaction.\n\n### Remarks\n\n#### Cross-module Contracts\n\nSome smart contracts of the protocol are used across the different modules of Angle (like the `agToken` contract) and you'll sometimes see different versions across the different repositories of the protocol.\n\nHere are some cross-module contracts and the repos in which you should look for their correct and latest version:\n\n- [`angle-core`](https://github.com/AngleProtocol/angle-core): All DAO-related contracts (`ANGLE`, `veANGLE`, gauges, surplus distribution, ...), `AngleRouter` contract\n- [`borrow-contracts`](https://github.com/AngleProtocol/borrow-contracts): `agToken` contract\n- [`angle-strategies`](https://github.com/AngleProtocol/angle-strategies): Yield strategies of the protocol\n\n#### Undeployed Contracts\n\nSome smart contracts in this repo have been developed for research purposes, but have not been audited or deployed in production.\n\nThis is notably the case of the contracts in the `contracts/reactor/` folder which should be dismissed if you're auditing the protocol.\n\n#### Error Messages\n\nSome smart contracts use error messages that are encoded as numbers rather. Conversion from numbers to error messages can be found in `errorMessages.json`.\n\n## Setup\n\nTo install all the packages needed to run the tests and scripts, run:\n\n```shell\nyarn\nforge i\n```\n\n### Setup Foundry\n\nSome scripts and tests run on Foundry:\n\n```bash\ncurl -L https://foundry.paradigm.xyz | bash\nsource /root/.zshrc\n# or, if you're under bash: source /root/.bashrc\nfoundryup\n```\n\nTo install the standard library:\n\n```bash\nforge install foundry-rs/forge-std\n```\n\nTo update libraries:\n\n```bash\nforge update\n```\n\n**If you don’t want to install Rust and Foundry on your computer, you can use Docker**\nImage is available here [ghcr.io/foundry-rs/foundry](http://ghcr.io/foundry-rs/foundry).\n\n```bash\ndocker pull ghcr.io/foundry-rs/foundry\ndocker tag ghcr.io/foundry-rs/foundry:latest foundry:latest\n```\n\nTo run the container:\n\n```bash\ndocker run -it --rm -v $(pwd):/app -w /app foundry sh\n```\n\nThen you are inside the container and can run Foundry’s commands.\n\n### Setup environment\n\nCreate a `.env` file from the template file `.env.example`.\nIf you don't define URI and mnemonics, default mnemonic will be used with a brand new local hardhat node.\n\n## Contracts usage\n\n### Compilation\n\n```shell\nyarn hardhat:compile\n```\n\n### Testing\n\n**With Hardhat**:\n\n```shell\nyarn hardhat:test\n```\n\nDefaults with `hardhat` network, but another network can be specified with `--network NETWORK_NAME`.\n\nA single test file or a glob pattern can be appended to launch a reduced set of tests:\n\n```shell\nyarn hardhat:test tests/vaultManager/*\n```\n\n**With Foundry:**\n\nYou can run tests as follows:\n\n```bash\nforge test -vvvv --watch\nforge test -vvvv --match-path tests/foundry/vaultManager/VaultManager.t.sol\nforge test -vvvv --match-test \"testAbc*\"\n```\n\nYou can also list tests:\n\n```bash\nforge test --list\nforge test --list --json --match-test \"testXXX*\"\n```\n\n### Scripts\n\n`yarn hardhat run PATH_TO_SCRIPT`\n\nSome scripts require to fork mainnet. To do so, you must first ensure that the `ETH_NODE_URI_FORK` in `.env` is pointing to an archival node (note: Alchemy provides this functionnality for free but Infura doesn't).\n\nThen, uncomment `blockNumber` in the `hardhat` network definition inside `hardhat.config.ts` to boost node speed.\nThen run:\n\n```shell\nFORK=true yarn hardhat run PATH_TO_SCRIPT\n```\n\n### Coverage\n\nWe try to keep our contract's code coverage above 99%. All contract code additions should be covered by tests (locally and in mainnet-fork) before being merged and deployed on mainnet.\n\nTo run code coverage:\n\n**With Hardhat:**\n\n```shell\nyarn coverage\n```\n\nA subgroup of tests can be run by specifying `--testfiles \"path/to/tests/*.ts\"`.\n\nIf coverage runs out of memory, you can export this in your env and retry:\n\n```shell\nexport NODE_OPTIONS=--max_old_space_size=4096\n```\n\n**With Foundry:**\n\nWe recommend the use of this [vscode extension](ryanluker.vscode-coverage-gutters).\n\n```bash\nyarn foundry:coverage\n```\n\n### Troubleshooting\n\nIf you have issues running tests or scripts, you can try to regenerate contracts typescript bindings by running\n\n```shell\nyarn generate-types-from-abis\n```\n\nYou can also delete `node_modules`, `cache`, and then re-install dependancies with `yarn install --frozen-lockfile`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangleprotocol%2Fborrow-contracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangleprotocol%2Fborrow-contracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangleprotocol%2Fborrow-contracts/lists"}