{"id":26054848,"url":"https://github.com/morpho-org/adaptive-curve-irm-py","last_synced_at":"2025-10-14T13:35:51.680Z","repository":{"id":259447860,"uuid":"869048196","full_name":"morpho-org/adaptive-curve-irm-py","owner":"morpho-org","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-24T11:48:03.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-03T17:59:41.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/morpho-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-07T16:20:51.000Z","updated_at":"2025-02-04T02:03:47.000Z","dependencies_parsed_at":"2024-10-25T14:26:15.554Z","dependency_job_id":null,"html_url":"https://github.com/morpho-org/adaptive-curve-irm-py","commit_stats":null,"previous_names":["morpho-org/adaptive-curve-irm-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/morpho-org/adaptive-curve-irm-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fadaptive-curve-irm-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fadaptive-curve-irm-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fadaptive-curve-irm-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fadaptive-curve-irm-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morpho-org","download_url":"https://codeload.github.com/morpho-org/adaptive-curve-irm-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fadaptive-curve-irm-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018707,"owners_count":26086609,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-03-08T10:00:23.476Z","updated_at":"2025-10-14T13:35:51.663Z","avatar_url":"https://github.com/morpho-org.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Adaptive Curve IRM Python Implementation\n\n## Overview\n\nThis repository contains a Python implementation of the Adaptive Curve Interest Rate Model (IRM) that performs exactly the same computations as its Solidity counterpart.\nThe main purpose of this project is to provide a Python-based tool for simulating and testing the Adaptive Curve IRM outside of the Ethereum blockchain environment.\n\n## Key Features\n\n1. **Identical Computation**: The Python implementation mirrors the Solidity version, ensuring that the interest rate calculations are consistent across both platforms.\n\n2. **AdaptiveCurveIrm Class**: The core functionality is encapsulated in the `AdaptiveCurveIrm` class, which includes all the necessary methods and constants for interest rate calculations.\n\n3. **MathLib Class**: Implementation of arithmetic operations that should behave similarly to the Solidity implementation.\n\n4. **Precision Handling**: The implementation uses integer arithmetic and scaling factors (WAD) to maintain the same level of precision as the Solidity version, avoiding floating-point discrepancies.\n\n5. **Key Methods**:\n   - `borrow_rate`: Calculates the borrow rate based on total borrow assets, total supply assets, and current time.\n   - `_curve`: Implements the interest rate curve calculation.\n   - `_new_rate_at_target`: Calculates the new rate at target utilization.\n   - `_w_exp`: A custom exponential function implementation for integer math.\n\n6. **Visualization**: Includes a method to plot borrow rates over time using matplotlib.\n\n7. **Test Suite**: Comprehensive test cases in `test_adaptive_curve_irm.py` to verify the correctness of the implementation.\n\n## Usage\n\nThe script can be run standalone to simulate interest rate behavior:\n```\npython adaptive_curve.py\n```\n\n\nThis will generate a series of random market states and calculate corresponding interest rates, then plot the results.\n\n## Testing\n\nTo run the test suite:\n\n```\npytest test_adaptive_curve_irm.py\n```\n\n\n## Dependencies\n\n- Python 3.x\n- matplotlib (for visualization)\n- pytest (for running tests)\n\n## Note\n\nThis Python implementation is designed for simulation and testing purposes.\nFor actual deployment of the Adaptive Curve IRM, please refer to the official Solidity implementation.\nDon't hesitate to raise an issue if you find any bug in this implementation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fadaptive-curve-irm-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorpho-org%2Fadaptive-curve-irm-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fadaptive-curve-irm-py/lists"}