{"id":23099962,"url":"https://github.com/keep-network/coverage-pools","last_synced_at":"2025-08-16T13:32:13.364Z","repository":{"id":41833612,"uuid":"329002320","full_name":"keep-network/coverage-pools","owner":"keep-network","description":"A governable, fee-earning asset pool to cover low-likelihood on-chain events.","archived":false,"fork":false,"pushed_at":"2024-03-01T10:28:27.000Z","size":3367,"stargazers_count":11,"open_issues_count":9,"forks_count":16,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-11-17T10:44:45.958Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keep-network.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-01-12T13:53:10.000Z","updated_at":"2024-09-20T14:17:40.000Z","dependencies_parsed_at":"2023-02-09T15:46:35.179Z","dependency_job_id":"7b950908-1665-4c0b-ba2b-ea537321a902","html_url":"https://github.com/keep-network/coverage-pools","commit_stats":{"total_commits":935,"total_committers":8,"mean_commits":116.875,"dds":0.7732620320855614,"last_synced_commit":"71047ca0afab86884821b8f9b42e96d7634bd5ae"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keep-network%2Fcoverage-pools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keep-network%2Fcoverage-pools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keep-network%2Fcoverage-pools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keep-network%2Fcoverage-pools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keep-network","download_url":"https://codeload.github.com/keep-network/coverage-pools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230039795,"owners_count":18163465,"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-12-16T23:29:10.714Z","updated_at":"2024-12-16T23:29:14.605Z","avatar_url":"https://github.com/keep-network.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":":toc: macro\n\n= Coverage pool\n\nhttps://github.com/keep-network/coverage-pools/actions/workflows/contracts.yml[image:https://img.shields.io/github/actions/workflow/status/keep-network/coverage-pools/contracts.yml?branch=main\u0026event=push\u0026label=Coverage%20pool%20contracts%20build[Coverage pool contracts build status]]\n\nA governable, fee-earning asset pool to cover low-likelihood on-chain events.\n\ntoc::[]\n\n== What is it?\n\nA coverage pool is a flexible new money lego that can be used as a back-stop or\n\"buyer of last resort\" in on-chain financial systems.\n\nAcross DeFi, young systems are hiding and shuffling around risk for perceived\nsecurity. These risks are part of what drive yield; but stacked atop eachother,\nrisks are multiplied.\n\nCoverage pools can be used in these systems to offset risk, allowing human or\nalgorithmic governance to reward underwriters. They're designed as building\nblocks rather than a standalone product, allowing system designers and\ncommunities to tailor risk management to their circumstances.\n\n== Goals\n\n1. Pool assets to back risk denominated in a particular asset.\n2. Manage those assets without unnecessary reliance on oracles.\n3. Allow underwriters to choose the asset exposure that best fits their\n   portfolio, increasing capital participation.\n4. Share risks and rewards across all underwriters, subject to their asset\n   exposure.\n\nThe first iteration of the design focuses on backing a single system authority\nthan can file and approve its own claims against the pool, in the asset the\npool is configured to support. Governance and underwriters are expected to\nreview and judge the risk of that system authority, as it has the power to\nliquidate the pool.\n\nFuture iterations could introduce explicit synthetic asset minting for claim\nmanagement, though that functionality should be easy to build atop the initial\ndesign.\n\n== Questions\n\n\u003e Doesn't this already exist?\n\nProbably. The ideas behind coverage pools have been picked from a number of\nDeFi and TradFi systems. The sum of the parts— choose-your-own-asset pools with\nsocialized rewards and losses, without outside oracles — is what's interesting\nas a building block.\n\n\u003e Why shouldn't I just use Nexus Mutual, Opyn, or another risk management\n\u003e solution?\n\nYou should! Coverage pools are a component for new on-chain financial systems,\nnot a replacement for end user applications. If you need to cover a particular\nrisk of yours, there are a variety of centralized and decentralized options on\nthe market. If you need to cover risk in a new system... maybe because you're\nbuilding a synthetic asset exchange, or a lending platform — coverage pools\nmight be for you.\n\n== Getting started\n\n* Read the link:./docs/design.adoc[v1 design documentation].\n* For questions and support, join the #keep-protocol channel on\nhttps://discord.gg/4R6RGFf[Discord].\n\n== Build, test and deploy\n\nCoverage pool contracts use https://hardhat.org/[*Hardhat*] development\nenvironment. To build and deploy these contracts, please follow the instructions\npresented below.\n\n=== Prerequisites\n\nPlease make sure you have the following prerequisites installed on your machine:\n\n- https://nodejs.org[Node.js] \u003e12.22.1\n- https://yarnpkg.com[Yarn] \u003e1.22.10\n\n=== Build contracts\n\nTo build the smart contracts, install node packages first:\n```\nyarn install\n```\nOnce packages are installed, you can build the smart contracts using:\n```\nyarn build\n```\nCompiled contracts will land in the `build/` directory.\n\n*NOTE:* The `coverage-pools` package contains an indirect dependency to\n`@summa-tx/relay-sol@2.0.2` package, which downloads one of its sub-dependencies\nvia unathenticated `git://` protocol. That protocol is no longer supported by\nGitHub. This means that in certain situations installation of the package or\nupdate of its dependencies using Yarn may result in `The unauthenticated git\nprotocol on port 9418 is no longer supported` or `unable to connect to\ngithub.com` error. +\nAs a workaround, we advise changing Git configuration to use `https://` protocol\ninstead of `git://` by executing:\n```\ngit config --global url.\"https://\".insteadOf git://\n```\n\n=== Test contracts\n\nThere are multiple test scenarios living in the `test` directory.\nYou can run them by doing:\n```\nyarn test\n```\n\n=== Deploy contracts\n\nTo deploy all contracts on the given network, please run:\n```\nyarn deploy --network \u003cnetwork\u003e\n```\n\nIf contracts haven't been built yet or changes occurred, this task will build\nthe contracts before running the deployment script.\n\n==== Deployment artifacts\n\nOnce the deployment terminates, a new `deployments` directory containing all\ndeployment info will be created. It can be directly used by dApps or other client\ncode as it contains deployment details like chain ID, transaction hash, ABI or\naddress for each contract.\n\nThe `deployments/` directory contains a separate sub-directory for each network, e.g.\n`deployments/sepolia/`, `deployments/mainnet/`. For a convenient usage of the\npackage we publish the deployment artifacts in a separate package for every\nnetwork. The package contains deployment artifacts under `artifacts/` directory,\nwhich is a a copy of `deployments/\u003cnetwork\u003e/` directory.\n\n===== Export mode\n\nApart from deployments saved in the `deployments/` folder the details will be also\nstored in a lightweight file `export.json`, which contains a handy summary of the\ndeployment info for all contracts in one place. However, it doesn't contain the\ndeployment transaction hash making it inappropriate for some use cases relying on\nthis field.\n\nPlease note that it is also possible to export deployment details for all supported\nnetworks into a single file using `--export-all` option. This can be useful for\ndApps supporting multiple networks at once.\n\nFor more details see `hardhat-deploy` plugin https://github.com/wighawag/hardhat-deploy#exporting-deployments[documentation].\n\n==== Published package structure\n\nDeployed contracts are packaged and published to the NPM registry. \n\nSeparate packages for every network are created according to the rules described in\nhttps://github.com/keep-network/keep-core/blob/main/docs/rfc/rfc-18-release-management.adoc[RFC-18].\n\nA package follows a directory structure described in the \u003c\u003cpackage-structure-table, table\u003e\u003e.\n\n.Published package structure\n[[package-structure-table]]\n[%autowidth,cols=\"1,3\"]\n|===\n|Path|Description\n\n|`artifacts/`\n|Deployment artifacts for the given network, see \u003c\u003cDeployment artifacts\u003e\u003e\n\n|`build/contracts/`\n|Compiled contracts artifacts, see \u003c\u003cBuild contracts\u003e\u003e\n\n|`contracts/`\n|Contracts source code\n\n|`export.json`\n|Single-file deployment export, see \u003c\u003cExport mode\u003e\u003e\n|===\n\n\n==== Deployment parametrization\n\nThe deployment scripts parametrization is handled by environment variables.\n\nFollowing parameters are supported:\n\n[cols=\"1,2,1\"]\n|===\n|Variable|Description|Default\n\n|`INITIAL_SWAP_STRATEGY`\n|Initial swap strategy which will be used by the risk manager.\nThis should be the name of one of the `ISignerBondsSwapStrategy` implementations.\n|`SignerBondsManualSwap`\n|===\n\n==== External dependencies\n\nDeployment scripts require external contract dependencies. The scripts support\ndependencies as \u003c\u003cdependencies-packages,node packages pulled from the NPM registry\u003e\u003e\nor \u003c\u003cdependencies-predefined,predefined addresses\u003e\u003e stored in `external/\u003cnetwork\u003e/` directory.\n\nFor more details see `hardhat-deploy` plugin https://github.com/wighawag/hardhat-deploy#importing-deployment-from-other-projects-with-truffle-support[documentation].\n\n[[dependencies-packages]]\n===== Node packages\n\nTo add an external package dependency: \n\n1. Add a package dependency with `yarn add \u003cpackage\u003e`.\n+\nExample:\n+\n```sh\nyarn add @keep-network/keep-core@1.8.0-dev\n```\n\n2. Add an entry in `hardhat.config.ts` under `external` property.\n+\nExample:\n+\n```js\n  external: {\n    contracts: [\n      // ...\n      {\n        artifacts: \"node_modules/@keep-network/keep-core/artifacts\",\n      }\n    ],\n    deployments: {\n      // ...\n      sepolia: [\n         // ...\n        \"node_modules/@keep-network/keep-core/artifacts\",\n      ],\n    },\n  },\n```\n\nThis solution support both Hardhat and Truffle artifacts.\n\n[[dependencies-predefined]]\n===== Predefined artifacts\n\nTo add a predefined single contract dependency for a given network:\n\n1. Create a file under `external/\u003cnetwork\u003e/\u003ccontract_name\u003e.json`.\n+\nExample: `external/sepolia/UniswapV2Router.json`\n\n2. Save an address and optionally an ABI for the contract in the file.\n+\nExample:\n+\n```json\n{\n  \"address\": \"0xZZabcd0000000000000000000000000000000001\",\n  \"abi\": [\n     // ...\n  ]\n}\n```\n\n3. Make sure the directory path is listed in `hardhat.config.ts` under\n`external.deployments.\u003cnetwork\u003e` property.\n+\nExample:\n+\n```js\n  external: {\n    deployments: {\n      // ...\n      sepolia: [\n         // ...\n        \"./external/sepolia\",\n      ],\n    },\n  },\n```\n\n===== Usage in scripts\n\nExternal artifacts can be used in scripts with `deployments.get` or `deployments.getOrNull`\nfunctions.\n\nExample:\n```js\nconst KeepToken = await deployments.get(\"KeepToken\")\ndeployments.log(`using external KeepToken at ${KeepToken.address}`)\n```\n\n==== Deployment scripts structure and tags\n\nThe deployment script is divided into multiple sub-scripts placed in the\n`deploy` directory. It uses the\nhttps://github.com/wighawag/hardhat-deploy#deploy-scripts-tags-and-dependencies[tags and dependencies]\nsystem provided by the `hardhat-deploy` plugin. Such a structure allows to\nrun arbitrary parts of the entire deployment by using the tag mechanism. For\nexample, to deploy only the `AssetPool` contract (with their dependencies),\na following command can be used:\n```\nyarn deploy --network localhost --tags AssetPool\n```\nMultiple deployment sub-scripts also improves the readability and allows\nspecifying dependencies between components in an explicit way.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeep-network%2Fcoverage-pools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeep-network%2Fcoverage-pools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeep-network%2Fcoverage-pools/lists"}