{"id":26054836,"url":"https://github.com/morpho-org/public-allocator-scripts","last_synced_at":"2025-07-03T02:05:15.295Z","repository":{"id":246062334,"uuid":"819988140","full_name":"morpho-org/public-allocator-scripts","owner":"morpho-org","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-03T16:19:54.000Z","size":431,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T10:02:41.005Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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-06-25T15:16:42.000Z","updated_at":"2025-03-03T16:19:58.000Z","dependencies_parsed_at":"2024-12-11T10:31:00.183Z","dependency_job_id":"0764acff-bbd1-44d7-af79-dc81e809dcd6","html_url":"https://github.com/morpho-org/public-allocator-scripts","commit_stats":null,"previous_names":["tomrpl/public-allocator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/morpho-org/public-allocator-scripts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpublic-allocator-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpublic-allocator-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpublic-allocator-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpublic-allocator-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/morpho-org","download_url":"https://codeload.github.com/morpho-org/public-allocator-scripts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/morpho-org%2Fpublic-allocator-scripts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263245241,"owners_count":23436510,"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":"2025-03-08T10:00:15.477Z","updated_at":"2025-07-03T02:05:15.063Z","avatar_url":"https://github.com/morpho-org.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Morpho Public Allocator - Bundler Implementation\n\nThis repository provides tools to fetch data from Morpho Blue markets and prepare reallocation transactions using the public allocator via the Bundler contract. The implementation supports Viem only for now.\n\n![Reallocation Flow](./scripts/image.png)\n\n## ⚠️ API - WIP Notice\n\nAn API (combined with RPC calls) version has been created to fetch data from the API and prepare reallocation transactions. It is automitically simulating the reallocation transaction and filtering with any potential error during atomic reallocation process.\nIt is currently in WIP.\n\n## ⚠️ SDK Versions Notice\n\nCurrent SDK versions are in pre-release. Use the following commands to install the latest next versions. Note the liquidity-sdk-viem is on version 1.1.0.\n\n### For Viem Implementation\n\n```bash\nyarn add @morpho-org/blue-sdk@next\nyarn add @morpho-org/blue-sdk-viem@next\nyarn add @morpho-org/morpho-blue-bundlers@latest\nyarn add @morpho-org/morpho-ts@next\nyarn add @morpho-org/simulation-sdk@next\nyarn add viem@^2.21.54\nyarn add dotenv\n```\n\nand also:\n\n```bash\nyarn add @morpho-org/liquidity-sdk-viem@1.1.0\n```\n\n\u003e **Note:** npm has potential issues parsing package names containing '@' symbols. We recommend using **yarn** or **pnpm** instead.  \n\u003e If one really needs to use **npm**, use exact versions in package.json:\n\n## Environment Setup\n\nCreate a `.env` file in the root directory with the following variables:\n\n```env\nRPC_URL_MAINNET=your_mainnet_rpc_url_here\nRPC_URL_BASE=your_base_rpc_url_here\n```\n\n## Performance Considerations\n\nThe script implements a two-step data fetching process for optimal performance:\n\n1. **Initial Quick Overview**: Uses the Morpho API to fetch basic liquidity data\n\n   - More efficient for initial checks\n   - May have a ~1 minute delay\n   - Suitable for UI displays and quick checks\n\n2. **Detailed RPC Data**: Only fetched when reallocation is needed\n   - More resource-intensive\n   - Provides real-time data\n   - Required for accurate transaction preparation\n\n## Stack Choice\n\nCurrently only viem is supported, given a version dependency.\n\n## Usage\n\n1. Update the market parameters in your script:\n\n```typescript\nconst chainId = 8453 as ChainId;\nconst marketId =\n  \"0x9103c3b4e834476c9a62ea009ba2c884ee42e94e6e314a26f04d312434191836\" as MarketId;\n\n// Example amounts: 20 USDC and 20M USDC\nconst examples = [\n  { amount: 20, label: \"20 USDC\" },\n  { amount: 20_000_000, label: \"20M USDC\" },\n];\n```\n\n2. Run the script:\n\n```bash\nnpx tsx scripts/sdks/viem/sdkBundler.ts\n```\n\nThe script will:\n\n1. Fetch initial market metrics from the GraphQL API\n2. Get current market data and liquidity state\n3. Calculate utilization and required reallocation\n4. Process withdrawals if needed\n5. Run market simulations for impact analysis\n6. Generate transaction data if reallocation is required\n7. Provide detailed results including:\n   - Current market liquidity\n   - API metrics\n   - Simulation results\n   - Reallocation details\n   - Transaction data (if applicable)\n   - Status messages\n\n## Reallocation Flow\n\n[Mermaid Link for preview](https://mermaid.live/view#pako:eNqNVVFP2zAQ_itWEBNIQQLKYM0DE4OxIUFV0e5hS_pwdS7EqmNnjqOuFP77HCdO0g6mtkp69n3f3fnz2V17VMboBV7C5ZKmoDSZfonERBvrILQ_s0NydHRJ7gTTDDh7xrAzyTVnKDT5QO4lxKhmkeg5K9oYFHCOfO0Mcouapq-RiAQxn3a6Al-N70LzBDWGPIBaoCYPqBWjxewNQo0IN-A3oGHmwptoprjGUzGugdOSg8awtcgj_i6ZwphcFQXqoiV3CMtMkS5-aMbX1Ys9g2ZSkEsyBfWE-nO7ov19MpJEoalS0hokEGMTPgedNpFdrCryy0i-kElJKRZFaKiPferIUpu1NyBbzlcRH4TmNTvsJd6gvpfuJxYvtcKP4-vQPE7vDXYjY0V3WJv3OxT3zOgVM71am0HHgjlH0vq2BeHO0aurH6tVYiTbuQ01NsM3pfXATpVe2rGSVi_1tiz_pLfKNKTQkfuqtE3Y-KqUE5bVDeUM127m9Gjsuql1t830AEbXdVfCbcn5ithZjDv9OmzXLalUOjF1hcZadqp0DtcxbmyzfkMx_ROaN6qqkKkCUQCtFjZ7J5lVxNIcwA7qhZdZBmoV3jIB3I3aTrWj7T2hHIriBhMSYwIl1yRhnAd7ybD6-oVWcoHB3mAw8KnkUgVzDnSxRWUiLx3xDIbHePoGcZkyjVvEvNm0mnqKlF6c7EiFnDW0wdnwUzzfkaZy2tCG84_D-fmONFrtgZPmhJ4dJztKU9QtVnV5zcbzCzz9jz49PrGXvW82q1a47zK3qN80tVGi73FXg98etZz2_e3N4_cPm9_rMrvYjTrcOelWEwnP9zJUGbDY_FetK3jk6RQzjLzAmLEpLvIi8WpwUGo5WQnqBVqV6HtKlk-pF5hDUJhRmccm9g2DJwWZg-QgfkmZNaDXv0uBZvo)\n\n## Note\n\n- API data has a potential 1-minute delay\n- Reallocatable liquidity calculations consider utilization caps (92% max)\n- For support, reach out on [Discord](https://discord.morpho.org)\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fpublic-allocator-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorpho-org%2Fpublic-allocator-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorpho-org%2Fpublic-allocator-scripts/lists"}