{"id":13759599,"url":"https://github.com/ScopeLift/l2-optimizoooors","last_synced_at":"2025-05-10T09:33:12.542Z","repository":{"id":58825009,"uuid":"532131935","full_name":"ScopeLift/l2-optimizoooors","owner":"ScopeLift","description":"Gas efficient routers for L2 applications","archived":false,"fork":false,"pushed_at":"2022-09-23T21:21:26.000Z","size":905,"stargazers_count":114,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-16T16:37:14.012Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ScopeLift.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}},"created_at":"2022-09-03T02:15:18.000Z","updated_at":"2024-11-13T06:50:01.000Z","dependencies_parsed_at":"2022-09-08T22:10:10.763Z","dependency_job_id":null,"html_url":"https://github.com/ScopeLift/l2-optimizoooors","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScopeLift%2Fl2-optimizoooors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScopeLift%2Fl2-optimizoooors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScopeLift%2Fl2-optimizoooors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScopeLift%2Fl2-optimizoooors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScopeLift","download_url":"https://codeload.github.com/ScopeLift/l2-optimizoooors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253397446,"owners_count":21902027,"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-08-03T13:00:56.022Z","updated_at":"2025-05-10T09:33:12.239Z","avatar_url":"https://github.com/ScopeLift.png","language":"Solidity","funding_links":[],"categories":["dApps directory"],"sub_categories":["Gas Tools"],"readme":"# L2 Optimizoooors\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"400\" src=\"./img/logo.png\" alt=\"L2 Optimizoooors Logo\"\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eContracts that use as little calldata as possible in order to save gas on L2s.\u003c/b\u003e\n\u003c/p\u003e\n\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"150\" src=\"./img/ethereum-badge-light.png\" alt=\"Umbra Logo\"\u003e\n\u003c/div\u003e\n\n- [Overview](#overview)\n- [Benchmarks](#benchmarks)\n- [Deployments](#deployments)\n  - [Aave](#aave)\n  - [Superfluid](#superfluid)\n  - [Connext](#connext)\n- [How it Works](#how-it-works)\n- [Get in Touch](#get-in-touch)\n\n## Overview\n\nLayer 2 networks share security with mainnet by posting transaction calldata to Layer 1.\nAs a result, Layer 2 users pay their portion of the mainnet gas costs when executing transactions.\nLayer 1 gas can be \u003e25,000x more expensive than Layer 2 gas, so paying for calldata dominates L2 transaction costs.\nWith custom contracts that use less calldata than standard methods we significantly reduce transaction costs for users.\n\nThe frontend for this project can be found [here](https://github.com/ScopeLift/l2-optimizoooors-frontend).\n\n## Benchmarks\n\nThis repo contains calldata-optimized routers for three protocols: Aave, Connext, and Superfluid.\nSavings for each are shown in the images below.\nThe same data can be found in [this spreadsheet](https://docs.google.com/spreadsheets/d/1Ix97LDMRnT-ENO5i_nCNk2lVcp6kzua9Mrh7Dk8038E/edit#gid=0).\n\n\u003cp float=\"left\"\u003e\n  \u003cimg src=\"./img/aave.png\" width=350\u003e\n  \u003cimg src=\"./img/connext.png\" width=350\u003e\n  \u003cimg src=\"./img/superfluid.png\" width=350\u003e\n\u003c/p\u003e\n\n## Deployments\n\nThe contracts in this repo are deployed to the following addresses and chains.\n\n### Aave\n\n| Contract             | Chain    | Address                                                                                                                          |\n| -------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |\n| Aave, Router Factory | Optimism | [0xc541372C68bcDBDF20561155AAfcEE400D8Bc053](https://optimistic.etherscan.io/address/0xc541372C68bcDBDF20561155AAfcEE400D8Bc053) |\n| Aave, Deposit ETH    | Optimism | [0x234B85b4C37760BC9C9B7545201edE4276dE6dF8](https://optimistic.etherscan.io/address/0x234B85b4C37760BC9C9B7545201edE4276dE6dF8) |\n| Aave, Withdraw ETH   | Optimism | [0x5F7ca09FD143e24e3AFbC90C842F0882c9ED7053](https://optimistic.etherscan.io/address/0x5F7ca09FD143e24e3AFbC90C842F0882c9ED7053) |\n| Aave, Deposit DAI    | Optimism | [0x0c370E22669c477391fC4a2F65f314270e16e131](https://optimistic.etherscan.io/address/0x0c370E22669c477391fC4a2F65f314270e16e131) |\n| Aave, Withdraw DAI   | Optimism | [0xd3077F0bbC9A9A0e63B56Fd0A7d98e5F5286c805](https://optimistic.etherscan.io/address/0xd3077F0bbC9A9A0e63B56Fd0A7d98e5F5286c805) |\n| Aave, Deposit USDC   | Optimism | [0x8cb9894F3F5fC6b2554553cb0F0ae40474A142dF](https://optimistic.etherscan.io/address/0x8cb9894F3F5fC6b2554553cb0F0ae40474A142dF) |\n| Aave, Withdraw USDC  | Optimism | [0xbD46B51e1Ebe7f61FBA5Ad5d4650F847f3F65bAD](https://optimistic.etherscan.io/address/0xbD46B51e1Ebe7f61FBA5Ad5d4650F847f3F65bAD) |\n\n\n## Superfluid\n\n| Contract                   | Chain          | Address                                                                                                                               |\n| -------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------- |\n| Superfluid, Router Factory | Optimism       | [0xE41A0678b7C07a92543Ca10927c568DBddca915d](https://optimistic.etherscan.io/address/0xE41A0678b7C07a92543Ca10927c568DBddca915d)      |\n| Superfluid, Wrap USDC      | Optimism       | [0xeD3d36dD725b6Eb4bd996b09ac1130E45a3360dD](https://optimistic.etherscan.io/address/0xeD3d36dD725b6Eb4bd996b09ac1130E45a3360dD)      |\n| Superfluid, Stream USDC    | Optimism       | [0x4055B2dd05E28399bd44fDe4dE6D64AF29c6F47f](https://optimistic.etherscan.io/address/0x4055B2dd05E28399bd44fDe4dE6D64AF29c6F47f)      |\n\n## Connext\n\nConnext v2 is not yet in production, which is why it's only deployed to Görli.\n\n| Contract                   | Chain          | Address                                                                                                                               |\n| -------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------- |\n| Connext, Router Factory    | Optimism Görli | [0xCdC50DB037373deaeBc004e7548FA233B3ABBa57](https://goerli-optimism.etherscan.io/address/0xCdC50DB037373deaeBc004e7548FA233B3ABBa57) |\n| Connext, Bridge Test Token | Optimism Görli | [0xa050e4F3B5f0cE4cfe519C5545E7AA73e1B6c323](https://goerli-optimism.etherscan.io/address/0xa050e4F3B5f0cE4cfe519C5545E7AA73e1B6c323) |\n\n\n## How it Works\n\nEvery protocol has a factory contract which deploys the calldata-optimized routers for that protocol.\nThe factory deploys a unique contract for every combination of methods and parameters that can be hardcoded\n\nFor example, with Aave:\n- Deposing ETH into Aave has a dedicated contract.\n- Withdrawing ETH from Aave has a dedicated contract.\n- Depositing USDC into Aave has a dedicated contract.\n- And so on.\n\nAnd similarly for Connext and Superfluid.\n\nThis means users don't need to specify a function selector, which saves 4 bytes of calldata.\nThis also means users don't need to specify a token address, saving another 32 bytes (20 bytes of non-zero calldata).\n\nAave lets you specify where to send the receipt tokens (on deposit) or the asset itself (on withdraw).\nSimilarly, Connext lets you specify where to send the asset once bridged.\nFor both of these we assume the user wants to send the asset to themselves so a recipient address is not required, which again saves 32 bytes (20 bytes of non-zero calldata).\n\nAave, Connext, and wrapping tokens in Superfluid require you to specify an amount of tokens.\nInstead of specifying exact amounts, users specify amounts as percentages of their balance.\nIf zero bytes of calldata are provided, the full user's balance is used.\nAny non-empty calldata provided is considered the numerator of a fraction, such that:\n\n- If one byte of calldata is provided the denominator is 255, which is the max value of a single byte.\n- If two bytes of calldata are provided the denominator is 65,535, which is the max value of two bytes.\n- And so on.\n\nFrom there, we compute the amount to use as `userBalance * calldata / denominator`.\nThis lets you specify nearly any amount of tokens with just a few bytes of calldata.\nThe tradeoff is precision: you may not be able to send *exactly* one token, and must tolerate a small deviation in the amount.\n\nSome protocols may deem this tradeoff unacceptable, and others require rates or other parameters that don't work with this pattern.\nOne such case is creating a flow on Superfluid, which requires specifying a flow rate.\nIn these cases, the user specifies the amount as normal, but with all zero-padding removed.\nIf you wanted to specify a value of 100e6 with this method, the calldata would be `0x05f5e100`.\nThis is just 4 bytes, instead of the standard 32 bytes used by ABI-encoding.\n\n## Get in Touch\n\nIf you are interested in having gas-optimized routers written for your protocol, please [reach out](https://www.scopelift.co/contact) to us!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FScopeLift%2Fl2-optimizoooors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FScopeLift%2Fl2-optimizoooors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FScopeLift%2Fl2-optimizoooors/lists"}