{"id":20030783,"url":"https://github.com/generationsoftware/pt-v5-twab-delegator","last_synced_at":"2026-01-05T16:02:41.410Z","repository":{"id":190080081,"uuid":"681739369","full_name":"GenerationSoftware/pt-v5-twab-delegator","owner":"GenerationSoftware","description":"Contract to delegate chances of winning to multiple delegatees","archived":false,"fork":false,"pushed_at":"2024-07-16T16:09:08.000Z","size":110,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T03:36:31.642Z","etag":null,"topics":["pooltogether","solidity"],"latest_commit_sha":null,"homepage":"","language":"Solidity","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/GenerationSoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-08-22T16:48:04.000Z","updated_at":"2024-07-16T16:09:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"29cea27f-b5cf-467f-bac3-0980d77a5251","html_url":"https://github.com/GenerationSoftware/pt-v5-twab-delegator","commit_stats":null,"previous_names":["generationsoftware/pt-v5-twab-delegator"],"tags_count":5,"template":false,"template_full_name":"GenerationSoftware/foundry-template","purl":"pkg:github/GenerationSoftware/pt-v5-twab-delegator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenerationSoftware%2Fpt-v5-twab-delegator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenerationSoftware%2Fpt-v5-twab-delegator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenerationSoftware%2Fpt-v5-twab-delegator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenerationSoftware%2Fpt-v5-twab-delegator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GenerationSoftware","download_url":"https://codeload.github.com/GenerationSoftware/pt-v5-twab-delegator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenerationSoftware%2Fpt-v5-twab-delegator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28217522,"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":"2026-01-05T02:00:06.358Z","response_time":57,"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":["pooltogether","solidity"],"created_at":"2024-11-13T09:28:17.570Z","updated_at":"2026-01-05T16:02:41.394Z","avatar_url":"https://github.com/GenerationSoftware.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/pooltogether/pooltogether--brand-assets\"\u003e\n    \u003cimg src=\"https://github.com/pooltogether/pooltogether--brand-assets/blob/977e03604c49c63314450b5d432fe57d34747c66/logo/pooltogether-logo--purple-gradient.png?raw=true\" alt=\"PoolTogether Brand\" style=\"max-width:100%;\" width=\"200\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr /\u003e\n\n# PoolTogether TWAB Delegator\n\n![Tests](https://github.com/pooltogether/v4-twab-delegator/actions/workflows/main.yml/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/pooltogether/v4-twab-delegator/badge.svg?branch=master)](https://coveralls.io/github/pooltogether/v4-twab-delegator?branch=master)\n\nThe PoolTogether V4 TWAB Delegator contract allows accounts to easily delegate their chance of winning to other accounts. See the [PoolTogether V4 Docs](https://dev.pooltogether.com) for more details on chance and the TWAB.\n\nThere are three roles that relate to this contract:\n\n- Delegators\n- Delegatees\n- Representatives\n\n**Delegators**\n\nDelegators are accounts that want to delegate their chance to win to another account. They do so using delegation \"slots\". Each delegation slot corresponds to a smart contract deployed as a minimal proxy. This contract holds the tickets and delegates the chance of the held tickets to the delegatee.\n\n**Delegatees**\n\nDelegatees are those who have tickets delegated to them. The delegatee gets a higher chance to win thanks to the delegation, but they don't have access to the underlying funds.\n\n**Representatives**\n\nRepresentatives are accounts that can manage delegations for a delegator. They can create and update the delegations, but cannot withdraw any funds. This enables smart contracts to manage delegations, or even a human representative.\n\n# User Flow\n\nThe main user flow is that a delegator delegates tickets to a delegatee. The flow proceeds like so:\n\n1. Delegator creates a delegation for the given slot:\n\n```solidity\ncreateDelegation(address delegatorAddress, uint256 slotIndex, address delegatee, uint256 lockDuration)\n```\n\n2. Delegator funds the delegation (transfers tickets into the delegation)\n\n```solidity\nfundDelegation(address delegator, uint256 slotIndex, uint256 amount)\n```\n\nIf a delegator wishes a representative to manage their delegations for them, then the delegator can stake on the contract instead. The representative can use the stake to create delegations, but cannot withdraw the stake.\n\nThe staking and rep flow looks like so:\n\n1. Delegator stakes tickets into the contract:\n\n```solidity\nstake(address to, uint256 amount)\n```\n\n2. Delegator adds a rep:\n\n```solidity\nsetRepresentative(address rep, bool isRep)\n```\n\nThe representative would follow a similar flow to create a delegation, but would instead fund from the stake:\n\n1. Delegator creates a delegation for the given slot:\n\n```solidity\ncreateDelegation(address delegatorAddress, uint256 slotIndex, address delegatee, uint256 lockDuration)\n```\n\n2. Delegator funds the delegation (transfers tickets into the delegation)\n\n```solidity\nfundDelegationFromStake(address delegator, uint256 slotIndex, uint256 amount)\n```\n\n# Permit \u0026 Multicall\n\nThis contract implements the Multicall interface which allows EOAs to batch transactions together. It also implements a special `permitAndMulticall` function so that users can also approve the ticket contract before running transactions, allowing them to create a delegation in a single tx.\n\n# Development\n\n1. Clone this repo: `git clone git@github.com:pooltogether/pooltogether-contracts-template.git \u003cDESTINATION REPO\u003e`\n1. Create repo using Github GUI\n1. Set remote repo (`git remote add origin git@github.com:pooltogether/\u003cNAME_OF_NEW_REPO\u003e.git`),\n1. Checkout a new branch (`git checkout -b name_of_new_branch`)\n1. Begin implementing as appropriate.\n1. Update this README\n\nThis repo is setup to compile (`nvm use \u0026\u0026 yarn compile`) and successfully pass tests (`yarn test`)\n\n## Getting started\n\nThe easiest way to get started is by clicking the [Use this template](https://github.com/pooltogether/foundry-template/generate) button at the top right of this page.\n\nIf you prefer to go the CLI way:\n\n```\nforge init my-project --template https://github.com/pooltogether/foundry-template\n```\n\n## Development\n\n### Installation\n\nYou may have to install the following tools to use this repository:\n\n- [Foundry](https://github.com/foundry-rs/foundry) to compile and test contracts\n- [direnv](https://direnv.net/) to handle environment variables\n- [lcov](https://github.com/linux-test-project/lcov) to generate the code coverage report\n\nInstall dependencies:\n\n```\nnpm i\n```\n\n### Env\n\nCopy `.envrc.example` and write down the env variables needed to run this project.\n\n```\ncp .envrc.example .envrc\n```\n\nOnce your env variables are setup, load them with:\n\n```\ndirenv allow\n```\n\n### Compile\n\nRun the following command to compile the contracts:\n\n```\nnpm run compile\n```\n\n### Coverage\n\nForge is used for coverage, run it with:\n\n```\nnpm run coverage\n```\n\nYou can then consult the report by opening `coverage/index.html`:\n\n```\nopen coverage/index.html\n```\n\n### Code quality\n\n[Husky](https://typicode.github.io/husky/#/) is used to run [lint-staged](https://github.com/okonet/lint-staged) and tests when committing.\n\n[Prettier](https://prettier.io) is used to format TypeScript and Solidity code. Use it by running:\n\n```\nnpm run format\n```\n\n[Solhint](https://protofire.github.io/solhint/) is used to lint Solidity files. Run it with:\n\n```\nnpm run hint\n```\n\n### CI\n\nA default Github Actions workflow is setup to execute on push and pull request.\n\nIt will build the contracts and run the test coverage.\n\nYou can modify it here: [.github/workflows/coverage.yml](.github/workflows/coverage.yml)\n\nFor the coverage to work, you will need to setup the `MAINNET_RPC_URL` repository secret in the settings of your Github repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenerationsoftware%2Fpt-v5-twab-delegator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenerationsoftware%2Fpt-v5-twab-delegator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenerationsoftware%2Fpt-v5-twab-delegator/lists"}