{"id":23392060,"url":"https://github.com/buildonpolygon/zkevm-dai","last_synced_at":"2025-04-11T10:20:53.579Z","repository":{"id":181305757,"uuid":"666361924","full_name":"BuildOnPolygon/zkevm-dai","owner":"BuildOnPolygon","description":"Polygon zkEVM's DAI Bridge","archived":false,"fork":false,"pushed_at":"2024-05-10T10:42:33.000Z","size":508,"stargazers_count":2,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-10T11:36:32.803Z","etag":null,"topics":["erc20","ethereum","polygon-zkevm","smart-contracts"],"latest_commit_sha":null,"homepage":"","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/BuildOnPolygon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":"audit/Polygon_Technology__Aug23Public.pdf","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-14T10:21:09.000Z","updated_at":"2024-05-10T11:36:37.182Z","dependencies_parsed_at":"2024-05-10T11:50:06.883Z","dependency_job_id":null,"html_url":"https://github.com/BuildOnPolygon/zkevm-dai","commit_stats":null,"previous_names":["pyk/zkevm-dai","buildonpolygon/zkevm-dai"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BuildOnPolygon%2Fzkevm-dai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BuildOnPolygon%2Fzkevm-dai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BuildOnPolygon%2Fzkevm-dai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BuildOnPolygon%2Fzkevm-dai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BuildOnPolygon","download_url":"https://codeload.github.com/BuildOnPolygon/zkevm-dai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230793617,"owners_count":18281092,"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":["erc20","ethereum","polygon-zkevm","smart-contracts"],"created_at":"2024-12-22T04:28:18.204Z","updated_at":"2024-12-22T04:28:18.612Z","avatar_url":"https://github.com/BuildOnPolygon.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Polygon zkEVM DAI Bridge\n\n### Introduction\n\nNative DAI implementation is consist of two smart contracts:\n\n1. **L1Escrow**: This contract is deployed on Ethereum mainnet and interact\n   directly with Spark protocol.\n2. **L2Dai**: This contract is deployed on Polygon zkEVM.\n\nWith Native DAI, user can do the following:\n\n1. Bridge DAI from Ethereum mainnet to Polygon zkEVM via `L1Escrow` contract.\n2. Bridge DAI from Polygon zkEVM to Ethereum mainnet via `L2Dai` contract.\n\n## Get started\n\n### Requirements\n\nThis repository is using foundry. You can install foundry via\n[foundryup](https://book.getfoundry.sh/getting-started/installation).\n\n### Setup\n\nClone the repository:\n\n```sh\ngit clone git@github.com:pyk/zkevm-dai.git\ncd zkevm-dai/\n```\n\nInstall the dependencies:\n\n```sh\nforge install\n```\n\n### Tests\n\nCreate `.env` with the following contents:\n\n```\nETH_RPC_URL=\"\"\nZKEVM_RPC_URL=\"https://zkevm-rpc.com\"\nETHERSCAN_API_KEY=\"\"\n```\n\nUse the following command to run the test:\n\n```sh\nforge test\n```\n\nYou can also run individual test using the following command:\n\n```sh\nforge test --fork-url $ETH_RPC_URL --match-test testSendExcessYield -vvvv\n\nforge test --fork-url \"https://zkevm-rpc.com\" --match-path test/L2Dai.t.sol --match-test testBridgeWithMockedBridge -vvvv\n```\n\n\u003e **Note**\n\u003e You can set `ETHERSCAN_API_KEY` to helps you debug the call trace.\n\n## Deployment\n\nUse the following command to deploy on Goerli:\n\n```sh\nforge script ...\n```\n\n## Contract addresses\n\n| Smart contract       | Network       | Address                                                                                                                        |\n| -------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------ |\n| DAI                  | Mainnet       | [0x6B175474E89094C44Da98b954EedeAC495271d0F](https://etherscan.io/address/0x6B175474E89094C44Da98b954EedeAC495271d0F)          |\n| sDAI                 | Mainnet       | [0x83f20f44975d03b1b09e64809b757c47f942beea](https://etherscan.io/token/0x83f20f44975d03b1b09e64809b757c47f942beea#code)       |\n| Polygon ZkEVM Bridge | Mainnet       | [0x2a3dd3eb832af982ec71669e178424b10dca2ede](https://etherscan.io/address/0x2a3dd3eb832af982ec71669e178424b10dca2ede)          |\n|                      | zkEVM Mainnet | [0x2a3dd3eb832af982ec71669e178424b10dca2ede](https://zkevm.polygonscan.com/address/0x2a3dd3eb832af982ec71669e178424b10dca2ede) |\n| L1Escrow             | Mainnet       | [0x4a27ac91c5cd3768f140ecabde3fc2b2d92edb98](https://etherscan.io/address/0x4a27ac91c5cd3768f140ecabde3fc2b2d92edb98)          |\n| L2Dai                | zkEVM Mainnet | [0x744c5860ba161b5316f7e80d9ec415e2727e5bd5](https://zkevm.polygonscan.com/address/0x744c5860ba161b5316f7e80d9ec415e2727e5bd5) |\n\n## Testnet Contract addresses\n\n| Smart contract       | Network       | Address                                                                                                                                     |\n| -------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |\n| DAI                  | Goerli        | [0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844](https://goerli.etherscan.io/address/0x11fE4B6AE13d2a6055C8D9cF65c55bac32B5d844)                |\n| sDAI                 | Goerli        | [0xD8134205b0328F5676aaeFb3B2a0DC15f4029d8C](https://goerli.etherscan.io/address/0xD8134205b0328F5676aaeFb3B2a0DC15f4029d8C)                |\n| Polygon ZkEVM Bridge | Goerli        | [0xF6BEEeBB578e214CA9E23B0e9683454Ff88Ed2A7](https://goerli.etherscan.io/address/0xF6BEEeBB578e214CA9E23B0e9683454Ff88Ed2A7)                |\n|                      | zkEVM Testnet | [0xF6BEEeBB578e214CA9E23B0e9683454Ff88Ed2A7](https://testnet-zkevm.polygonscan.com/address/0xF6BEEeBB578e214CA9E23B0e9683454Ff88Ed2A7)      |\n| L1Escrow             | Goerli        | [0x2929b2635E51f2dA1373A76F166A237322694fA6](https://goerli.etherscan.io/address/0x2929b2635E51f2dA1373A76F166A237322694fA6)                |\n| L2Dai                | zkEVM Testnet | [0x755CB8A808c99706afAA34547204f17cD33C6316](https://testnet-zkevm.polygonscan.com/address/0x755CB8A808c99706afAA34547204f17cD33C6316#code) |\n\n## Known Issues\n\n### Rounding Issue\n\nWhen we deposit `x` amount of DAI to sDAI, we will get `y` amount of sDAI based\non the current exchange rate `r`. Due to how `y` is rounded down by sDAI, there\nis possibility that when we redeem `y` amount of sDAI we will get `x' = x - 1`\namount of DAI.\n\nFor, example:\n\n```solidity\nuint256 x = 1000000000000000001;\nuint256 y = sdai.deposit(x);\nuint255 x_ = sdai.redeem(y); // x_ = 1000000000000000000\n```\n\n\u003e **Note**\n\u003e See [sDAI.t.sol](./test/sDAI.t.sol) for more details.\n\nOfcourse, `r` will be increased over time and this 1 wei will be covered.\n\nTo make sure that bridged DAI is always 1:1, it is advised to donate small\namount of DAI on `L1Escrow` on the first time it get deployed (e.g. 0.01 DAI).\n\n`sendExcessYield` will send excess yield if the total yield is more than\n0.05 DAI and will leave 0.01 DAI from the yield in L1Escrow.\n\n### Locked DAI in L1Escrow may greater than totalProtocolDAI\n\nCurrently there is no way to check the maximum deposit amount of sDAI.\n`sdai.maxDeposit(address)` is hardcoded to `type(uint256).max`.\n\n`sdai.deposit(amount, recipient)` may reverted and it is possible that total\namount of locked DAI in the `L1Escrow` is greater than the specified\n`totalProtocolDAI`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuildonpolygon%2Fzkevm-dai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuildonpolygon%2Fzkevm-dai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuildonpolygon%2Fzkevm-dai/lists"}