{"id":17794303,"url":"https://github.com/pyk/llamalocker","last_synced_at":"2026-06-14T21:31:55.255Z","repository":{"id":210506329,"uuid":"726732544","full_name":"pyk/LlamaLocker","owner":"pyk","description":"Lock your LLAMAs to claim share of yields","archived":false,"fork":false,"pushed_at":"2024-11-29T10:34:09.000Z","size":1075,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-16T05:31:28.391Z","etag":null,"topics":["ethereum","nft"],"latest_commit_sha":null,"homepage":"https://www.thellamas.io/","language":"Solidity","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/pyk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":"audits/ottersec.pdf","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-03T08:14:40.000Z","updated_at":"2025-08-25T17:16:27.000Z","dependencies_parsed_at":"2024-01-04T13:24:22.112Z","dependency_job_id":"f36168c5-adb3-47b2-a831-934abecaa08d","html_url":"https://github.com/pyk/LlamaLocker","commit_stats":null,"previous_names":["pyk/sllama","pyk/llamalocker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pyk/LlamaLocker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyk%2FLlamaLocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyk%2FLlamaLocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyk%2FLlamaLocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyk%2FLlamaLocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyk","download_url":"https://codeload.github.com/pyk/LlamaLocker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyk%2FLlamaLocker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34339194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"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":["ethereum","nft"],"created_at":"2024-10-27T11:15:49.062Z","updated_at":"2026-06-14T21:31:55.239Z","avatar_url":"https://github.com/pyk.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Llama Locker\n\nLlama Locker allows users to lock their LLAMA tokens and earn a share of the\nyield generated by the treasury over time. It manages epochs, reward token\ndistribution, and token locking/unlocking, ensuring fair and transparent reward\ndistribution.\n\n## Lock Mechanism\n\n- Locked NFTs cannot be withdrawn for 4 epochs (4 weeks) and are eligible to\n  receive a proportionate share of yields during this period.\n- Unlike the CVX Lock style, which requires active kicking out of tokens after\n  the lock duration ends, LlamaLocker offers a more user-friendly approach.\n- NFT owners can withdraw their NFTs in the epoch after the lock duration ends.\n  If not withdrawn, the NFTs will automatically re-lock for the subsequent lock\n  duration, streamlining the process and saving users on gas costs.\n\n### Example of Lock Mechanism\n\n1. Alice locks Llama #1 on January 28, 2024, at 22:49:42 GMT.\n2. Llama #1 starts accruing yields from February 1, 2024, at 00:00:00 GMT (next epoch).\n3. Withdrawal of Llama #1 is possible anytime from February 29, 2024, at 00:00:00 GMT to March 7, 2024, at 00:00:00 GMT (one-week epoch).\n4. If Llama #1 remains unwithdrawn during this window, it will automatically re-lock starting March 7, 2024, at 00:00:00 GMT.\n\n## Getting Started\n\nEnsure you are using the latest version of Foundry:\n\n```shell\nfoundryup\n```\n\nInstall dependencies:\n\n```shell\nforge install\n```\n\nRun the tests:\n\n```shell\nforge test\n```\n\nExample output:\n\n```\n$ forge test\n[⠊] Compiling...\n[⠑] Compiling 1 files with Solc 0.8.23\n[⠘] Solc 0.8.23 finished in 1.71s\nCompiler run successful!\n\nRan 1 test for test/LlamaLocker.t.sol:LlamaLockerTest\n[PASS] test_renounceOwnership_InvalidAction() (gas: 13389)\nSuite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.44ms (93.38µs CPU time)\n\nRan 4 tests for test/AddRewardTokens.t.sol:AddRewardTokensTest\n[PASS] test_addRewardTokens_InvalidRewardToken() (gas: 92195)\n[PASS] test_addRewardTokens_InvalidRewardTokenCount() (gas: 13954)\n[PASS] test_addRewardTokens_Unauthorized() (gas: 14191)\n[PASS] test_addRewardTokens_Valid() (gas: 133255)\nSuite result: ok. 4 passed; 0 failed; 0 skipped; finished in 1.60ms (179.63µs CPU time)\n\nRan 8 tests for test/Whitelist.t.sol:RewardDistributionTest\n[PASS] test_disableWhitelist_InvalidAction() (gas: 20211)\n[PASS] test_disableWhitelist_Unauthorized() (gas: 13655)\n[PASS] test_disableWhitelist_Valid() (gas: 19409)\n[PASS] test_lock_InvalidAction() (gas: 115192)\n[PASS] test_lock_Valid() (gas: 225023)\n[PASS] test_setRoot_InvalidAction() (gas: 15583)\n[PASS] test_setRoot_Unauthorized() (gas: 13695)\n[PASS] test_setRoot_Valid() (gas: 19625)\nSuite result: ok. 8 passed; 0 failed; 0 skipped; finished in 1.65ms (751.29µs CPU time)\n\nRan 6 tests for test/LockMechanism.t.sol:LockMechanismTest\n[PASS] test_lock_InvalidTokenCount() (gas: 11454)\n[PASS] test_lock_Valid() (gas: 496076)\n[PASS] test_unlock_InvalidLockOwner() (gas: 225991)\n[PASS] test_unlock_InvalidTokenCount() (gas: 9265)\n[PASS] test_unlock_InvalidUnlockWindow() (gas: 246840)\n[PASS] test_unlock_ValidUnlockWindow() (gas: 222618)\nSuite result: ok. 6 passed; 0 failed; 0 skipped; finished in 1.71ms (784.38µs CPU time)\n\nRan 5 tests for test/RewardDistribution.t.sol:RewardDistributionTest\n[PASS] test_distributeRewardToken_Claimables() (gas: 1020171)\n[PASS] test_distributeRewardToken_InvalidRewardAmount() (gas: 134541)\n[PASS] test_distributeRewardToken_InvalidRewardToken() (gas: 17599)\n[PASS] test_distributeRewardToken_InvalidTotalShares() (gas: 136631)\n[PASS] test_distributeRewardToken_Unauthorized() (gas: 13900)\nSuite result: ok. 5 passed; 0 failed; 0 skipped; finished in 2.06ms (1.10ms CPU time)\n\nRan 1 test for test/OffchainQuery.sol:LockMechanismTest\n[PASS] test_getLocks() (gas: 11133290)\nSuite result: ok. 1 passed; 0 failed; 0 skipped; finished in 11.34ms (9.86ms CPU time)\n\nRan 6 test suites in 161.35ms (19.81ms CPU time): 25 tests passed, 0 failed, 0 skipped (25 total tests)\n```\n\n## Generate Merkle Tree\n\nInstall dependencies:\n\n```sh\npnpm install\n```\n\nUpdate the `whitelist.txt` file.\n\nThen get the merkle tree root and proofs via the following command:\n\n```sh\npnpm run gen:merkle\n```\n\nCheck the proof inside `merkle-proofs.json`.\n\n## Front End Integration\n\nThere are two main actions for users:\n\n1. **Lock NFT:** Users can lock their NFT via `lock(proofs, tokenIds)`\n   for whitelisted user and `lock(tokenIds)` for public.\n2. **Unlock NFT:** Users can unlock their NFT via `unlock`.\n\nAdditional information:\n\n- Claimable rewards are available via `claimables(account)`.\n- Claimed rewards are available via `getClaimedRewards(account)`.\n- Lock information can be retrieved via `locks(nftId)`.\n\nTo compute the next unlock for the specified NFT, use the following formula:\n\n```shell\nlockedDuration = currentTimestamp - lockedAt\nlockedDurationInEpoch = lockedDuration / EPOCH_DURATION\nmodulo = lockedDurationInEpoch % LOCK_DURATION_IN_EPOCH\nunlockNextEpoch = LOCK_DURATION_IN_EPOCH - modulo\nunlockStart = currentTimestamp + (unlockNextEpoch * EPOCH_DURATION)\nunlockEnd = unlockStart + EPOCH_DURATION\n```\n\n`unlockStart` and `unlockEnd` define a time window in Unix timestamp when users can unlock their locked NFTs.\n\nAdmin actions:\n\n- Admin can add a new reward token via `addRewardToken`.\n- Admin can distribute weekly rewards via `distributeRewardToken`.\n- Admin need to approve the LlamaLocker contract before executing `distributeRewardToken`.\n- Admin can set new merkle tree root via `setRoot(root)` (for rolling whitelist)\n- Admin can disable the whitelist via `disableWhitelist()` (for public launch)\n\n## Gas Report\n\n```\n| src/LlamaLocker.sol:LlamaLocker contract |                 |         |         |         |         |\n|------------------------------------------|-----------------|---------|---------|---------|---------|\n| Deployment Cost                          | Deployment Size |         |         |         |         |\n| 2020278                                  | 9131            |         |         |         |         |\n| Function Name                            | min             | avg     | median  | max     | # calls |\n| addRewardTokens                          | 24227           | 78136   | 84896   | 139290  | 10      |\n| claim                                    | 162883          | 162883  | 162883  | 162883  | 1       |\n| claimable                                | 2401            | 3067    | 2401    | 4401    | 12      |\n| disableWhitelist                         | 23478           | 28734   | 29335   | 29335   | 16      |\n| distributeRewardToken                    | 24051           | 45139   | 28627   | 81528   | 7       |\n| getLocks                                 | 8018452         | 8018452 | 8018452 | 8018452 | 1       |\n| getLocksByOwner                          | 1364152         | 1364152 | 1364152 | 1364152 | 2       |\n| getRewardTokenCount                      | 370             | 370     | 370     | 370     | 1       |\n| lock(bytes32[],uint256[])                | 26080           | 95257   | 95257   | 164435  | 2       |\n| lock(uint256[])                          | 24103           | 147342  | 160540  | 183588  | 12      |\n| renounceOwnership                        | 23504           | 23504   | 23504   | 23504   | 1       |\n| root                                     | 350             | 350     | 350     | 350     | 1       |\n| setRoot                                  | 24077           | 26788   | 26180   | 30107   | 3       |\n| unlock                                   | 21914           | 33682   | 28960   | 78956   | 9       |\n| whitelistDisabled                        | 378             | 378     | 378     | 378     | 1       |\n```\n\nAssuming gas fee is 10gwei:\n\n- Deployment: 0,00000001 * 2020278 = 0,02020278 ETH\n- `claim`: 0,00000001 * 162883 = 0,00162883 ETH\n- `lock(bytes32[],uint256[])` (lock for whitelisted addy): 0,00000001 * 95257 = 0,00095257 ETH\n- `lock(uint256[])`: 0,00000001 * 147342 = 0,00147342 ETH\n- `unlock`: 0,00000001 * 33682 = 0,00033682 ETH\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyk%2Fllamalocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyk%2Fllamalocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyk%2Fllamalocker/lists"}