{"id":18369106,"url":"https://github.com/bitfancy/solidity-renpool","last_synced_at":"2025-04-10T19:39:48.991Z","repository":{"id":237689810,"uuid":"760174643","full_name":"BitFancy/Solidity-Renpool","owner":"BitFancy","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-19T23:26:40.000Z","size":7055,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T20:54:18.833Z","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/BitFancy.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-02-19T23:22:00.000Z","updated_at":"2024-07-29T14:01:14.000Z","dependencies_parsed_at":"2024-05-03T01:21:27.836Z","dependency_job_id":null,"html_url":"https://github.com/BitFancy/Solidity-Renpool","commit_stats":null,"previous_names":["bitfancy/solidity-renpool"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitFancy%2FSolidity-Renpool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitFancy%2FSolidity-Renpool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitFancy%2FSolidity-Renpool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitFancy%2FSolidity-Renpool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BitFancy","download_url":"https://codeload.github.com/BitFancy/Solidity-Renpool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281424,"owners_count":21077423,"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-05T23:28:28.441Z","updated_at":"2025-04-10T19:39:48.969Z","avatar_url":"https://github.com/BitFancy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RenPool Project\n\n## Bringing community pools to the REN ecosystem\n\n### What is REN?\n\nRenVM is a permissionless and decentralized virtual machine protocol.\n\n\u003e _A secure network of virtual computers that power interoperability for decentralized applications, enabling cross-chain lending, exchanges, collateralization \u0026 more._\n\nThis document assumes a high-level understanding of the RenVM protocol.\nCheck \u003chttps://github.com/renproject/ren/wiki/\u003e to learn more about the inner workings of RenVM.\nMore information about Ren and the Ren project can be found in \u003chttps://renproject.io/renvm\u003e.\nVisit \u003chttps://github.com/renproject\u003e to explore their repos.\n\nIn other words, RenVM is a network of nodes, called _darknodes_, that perform Secure Multiparty Computation (SMPC) over Shamir Secret Shares, to control ECDSA Private Keys securely, and hence custody funds for cross-chain bridging.\n\nThese _darknodes_ earn fees for every transaction they process.\nIn order to power a _darknode_, you need to stake a utility token provided by RenVM.\nThis is the **REN** token, an [`ERC20` Ethereum token](https://ethereum.org/en/developers/docs/standards/tokens/erc-20/).\nThe amount you have to stake, known as _bond_, is `100,000 REN` (currently about `88,000 USD`).\n\n### What is the RenPool?\n\nThe RenPool project allows users to participate in **REN** staking pools,\nwhich are rewarded with a share of fees earned by the _Darknode_.\n\n\u003e **You can earn _Darknode_ rewards without having 100K REN nor operaing a _Darknode_**\n\n### RenPool Features\n\nRenPool allows any user to\n\n- create a new pool by becoming the node operator of a new _Darknode_.\n- deposit **REN**s into a pool and when it reaches 100K, the RenPool team will set up and manage a new _Darknode_.\n- **[TODO]** request a withdraw of a running pool. When another staker wants to take your place, they transfer the staked **REN**s to you, and they become part of the pool. However, keep in mind that you will lose your rewards for that epoch. Instead the new staker will receive it.\n- **[TODO]** automatically deregister a running node when more than 50% of the staked REN collectively requests to withdraw their share.\n\nMoreover, the RenPool team will **never** be in possession of your **REN** tokens nor your rewards.\n\n### **TODO**\n\n- We need to audit the smart contracts\n- What about slashing?\n- Ethereum gas?\n- Explain fees for owner and node operator and staker\n\n### How RenPool works\n\nAt its core, RenPool is powered by smart contracts that dictates how the pool rewards are distributed among its users.\n\n![RenPool Architecture](./RenPool-arch.drawio.svg)\n\nThere are three main actors when using a RenPool.\n\n- Owner\n- Node Operator\n- Stakers\n\nIn turn, the RenPool uses Ren smart contracts\n\u003chttps://renproject.github.io/ren-client-docs/contracts/\u003e\nto interact with the RenVM in a decentralized and permissionless manner.\nRen contract addresses are published\n\n- for `mainnet`. \u003chttps://renproject.github.io/contracts-ts/#/mainnet\u003e\n- for `testnet`. \u003chttps://renproject.github.io/contracts-ts/#/testnet\u003e\n\n### RenPool states\n\nThe following picture shows different states the RenPool can be in.\n\n![RenPool FSM](./RenPool-FSM.drawio.svg)\n\nWhen _unlocked_, stakers can either `deposit` or `withdraw` **REN** tokens as they see fit.\nHowever, when the pool collects the Ren Bond, currently 100K **REN** tokens, it becomes _locked_.\nOnce the pool is _locked_, the node operator can register a new darknode\n\u003chttps://docs.renproject.io/darknodes/getting-started/digital-ocean-or-how-to-setup-a-darknode/mac-os-and-linux\u003e.\n\n\u003e ***Please note that the REN tokens collected by the contract are never in possession of the node operator nor the owner.***\n\nAfter the darknode has been registered,\nit will start to earn fees.\nThe stakers can then withdraw their respective percentage of these fees.\n\n### Claiming Rewards\n\n![RenPool Claim Rewards Sequence](./RenPool-rewards.drawio.svg)\n\n## Getting started\n\nThe RenPool project uses the _Yarn_ package manager and the _Hardhat_ [https://hardhat.org/getting-started/](https://hardhat.org/getting-started/) development environment for Ethereum.\nWe use [Alchemy](https://www.alchemy.com/) JSON-RPC provider to fork Ethereum networks.\n\nYou can skip to the next section if you have a working _Yarn_ installation.\nIf not, here is how to install it.\n\n```sh\nnpm install -g yarn\n```\n\n### Install project\n\n```sh\nyarn install\n```\n\n### Create an `.env` file from `.env.template`\n\nThis file defines environment variables read by _Hardhat_.\n\n```sh\ncp .env.template .env\n```\n\nAdd your [Alchemy Key](https://docs.alchemy.com/alchemy/introduction/getting-started) to the newly created `.env` file\n\n```txt\nALCHEMY_KEY=\u003cyour Alchemy key here\u003e\n```\n\n### Init the _Hardhat_ console\n\nThis will create a local Blockchain plus 10 local `accounts` loaded with ETH.\n\n```sh\nyarn hardhat console\n```\n\nIf you want to use a `mainnet`-fork run\n\n```sh\nFORK=mainnet yarn hardhat console\n```\n\n### Deploy `RenPool` contract to the local network and mint an ERC20 token called REN\n\nYou will get a fresh instance every time you init the _Hardhat_ console.\n\n```js\n\u003e const { renPool, renToken, faucet } = await require('./scripts/deploy.js')()\n```\n\n`RenPool` and `RenToken` are contracts objects, while `faucet` is a function used to mint the REN token.\n\n### You can now interact with the `renPool` and `renToken` contracts\n\nTo interact with the contract you can use any of the signers provided by _Hardhat_.\n\nFirst, get some REN tokens from the faucet\n\n```js\n\u003e const [signer] = await ethers.getSigners()\n\u003e (await renToken.balanceOf(signer.address)).toString()\n'0'\n\u003e await faucet(renToken, signer)\n\u003e (await renToken.balanceOf(signer.address)).toString()\n'1000000000000000000000000'\n```\n\nDeposit REN tokens into the Ren Pool\n\n```js\n\u003e (await renPool.totalPooled()).toString()\n'0'\n\u003e await renToken.connect(signer).approve(renPool.address, 100)\n\u003e await renPool.connect(signer).deposit(100)\n```\n\nVerify that the Ren Pool balance has been increased\n\n```js\n\u003e (await renPool.totalPooled()).toString()\n'100'\n```\n\nWithdraw some REN tokens\n\n```js\n\u003e await renPool.connect(signer).withdraw(5)\n\u003e (await renPool.totalPooled()).toString()\n\u003e 95\n```\n\n## Deploying Smart Contract to a Live Network\n\nFirst you need to fund a wallet for the target network, _e.g., `kovan` or `mainnet`.\nThen add your private key and your Etherscan API key to the `.env` file.\nThe Etherscan API key is used in the deployment process to verify the smart contract.\nSee \u003chttps://etherscan.io/verifyContract\u003e for more information about smart contract verification on Etherscan.\nWe use the [`hardhat-etherscan`](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html#using-programmatically) plugin to verify the smart contract.\n\n```txt\nPRIVATE_KEY=\u003cyour private key here\u003e\nETHERSCAN_API_KEY=\u003cyour etherscan API key here\u003e\n```\n\nTo deploy the smart contract to `kovan` use\n\n```sh\nyarn deploy --network kovan\n```\n\nReplace `kovan` with the name of the network you wish you use, _e.g._, `mainnet`.\n\n## Running Tests and Code Coverage\n\nThe RenPool depends heavily on Ren smart contracts to interact with the RenVM.\nRen smart contracts have been deployed independently by the Ren team and their addresses can be found in\n\u003chttps://renproject.github.io/ren-client-docs/contracts/deployments/\u003e.\nThe `test/ren` folder contains checks to verify that these contract addresses.\n\nOur test suite is designed to run on local forks of networks where the Ren smart contracts have been already deployed.\nCurrently these networks are _mainnet_ and _kovan_.\nTo run the test suite against a _kovan_ fork.\n\n```sh\nyarn test\n```\n\nOn the other hand,\nif you want to run these tests against a _mainnet_ fork.\n\n```sh\nyarn test:mainnet\n```\n\nRuns the test suite and reports gas usage at then end.\n\n```sh\nyarn test:gas\n```\n\nRun test coverage.\nCoverage report is written to `coverage/index.html`.\n\n```sh\nyarn coverage\n```\n\nRun `solhint` (Solidity linter).\n\n```sh\nyarn lint\n```\n\n\u003e These `yarn` scripts are declared in `package.json`.\n\n## Running Static Analysis\n\nWe use the [Slither](https://github.com/crytic/slither) to run static analysis on the RenPool contract.\nSlither can run on a Hardhat application, so you only need to install Slither.\n\n```sh\npip3 install slither-analyzer\n```\n\nTo run it\n\n```sh\nslither .\n```\n\nSee \u003chttps://github.com/crytic/slither\u003e for more information.\n\nThe static analysis has been integrated into our pipeline with GitHub Actions.\nTo see the result of the analysis,\nsee \u003chttps://github.com/Ethernautas/renpool/actions/workflows/analysis.yaml\u003e.\n\n## Query and Send RenVM Transactions (WIP)\n\nUseful for claiming rewards.\nFull docs here \u003chttps://renproject.github.io/ren-client-docs/api/\u003e.\n\n### Endpoints\n\n- \u003chttps://explorer.renproject.io/\u003e\n- \u003chttps://lightnode-testnet.herokuapp.com\u003e\n- \u003chttps://lightnode-devnet.herokuapp.com\u003e\n\n### Examples\n\n```http\nPOST https://lightnode-testnet.herokuapp.com HTTP/1.1\nContent-Type: application/json\nAccept: application/json\n\n{\n  \"method\": \"ren_queryTxs\",\n  \"id\": 1,\n  \"jsonrpc\": \"2.0\",\n  \"params\": {\n    \"txStatus\": \"done\",\n    \"offset\": \"0\",\n    \"limit\": \"10\"\n  }\n}\n```\n\n```http\nPOST https://lightnode-testnet.herokuapp.com/ HTTP/1.1\nContent-Type: application/json\nAccept: application/json\n\n{\n  \"method\": \"ren_queryTx\",\n  \"id\": 1,\n  \"jsonrpc\": \"2.0\",\n  \"params\": {\n      \"txHash\": \"s8BZA6dhMRTOL6nOEo3yAlgdtNQfEdEF4VkVVcXeCcI\"\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfancy%2Fsolidity-renpool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfancy%2Fsolidity-renpool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfancy%2Fsolidity-renpool/lists"}