{"id":19854124,"url":"https://github.com/depayfi/depay-evm-router","last_synced_at":"2025-05-02T01:30:30.411Z","repository":{"id":46574374,"uuid":"303141207","full_name":"DePayFi/depay-evm-router","owner":"DePayFi","description":"🛣 DePay's EVM Web3 Payment Router.","archived":false,"fork":false,"pushed_at":"2025-03-26T16:23:38.000Z","size":4953,"stargazers_count":20,"open_issues_count":0,"forks_count":19,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T20:25:34.311Z","etag":null,"topics":["cryptocurrency","evm","payments","protocol","router","smart-contracts","tokens","web3"],"latest_commit_sha":null,"homepage":"https://depay.com","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DePayFi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audits/v1/Audit1.md","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-11T14:38:18.000Z","updated_at":"2025-03-31T07:33:33.000Z","dependencies_parsed_at":"2025-03-14T10:40:23.207Z","dependency_job_id":null,"html_url":"https://github.com/DePayFi/depay-evm-router","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/DePayFi%2Fdepay-evm-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DePayFi%2Fdepay-evm-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DePayFi%2Fdepay-evm-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DePayFi%2Fdepay-evm-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DePayFi","download_url":"https://codeload.github.com/DePayFi/depay-evm-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251969239,"owners_count":21673180,"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":["cryptocurrency","evm","payments","protocol","router","smart-contracts","tokens","web3"],"created_at":"2024-11-12T14:08:36.450Z","updated_at":"2025-05-02T01:30:30.389Z","avatar_url":"https://github.com/DePayFi.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DePay's EVM Web3 Payment Router.\n\n## Deployments\n\nOptimization Level: 800,000\n\n### DePayRouterV3\n\nEnables Web3 Payments.\n\nEthereum:\n- [0x365f7B56D2fB16C8Af89D7d33b420E4e013461e8](https://etherscan.io/address/0x365f7B56D2fB16C8Af89D7d33b420E4e013461e8)\n\nBNB Smart Chain:\n- [0x5F565EDfB9C446976a9F9910631cfeDb6A87220c](https://bscscan.com/address/0x5F565EDfB9C446976a9F9910631cfeDb6A87220c)\n\nPolygon (POS):\n- [0xe04b08Dfc6CaA0F4Ec523a3Ae283Ece7efE00019](https://polygonscan.com/address/0xe04b08Dfc6CaA0F4Ec523a3Ae283Ece7efE00019)\n\nAvalanche:\n- [0x39E7C98BF4ac3E4C394dD600397f5f7Ee3779BE8](https://snowtrace.io/address/0x39E7C98BF4ac3E4C394dD600397f5f7Ee3779BE8)\n\nGnosis:\n- [0x328FE8bbd30487BB7b5A8eEb909f892E9E229271](https://gnosisscan.io/address/0x328FE8bbd30487BB7b5A8eEb909f892E9E229271)\n\nOptimism:\n- [0x558302715e3011Be6695605c11A65526D2ba2245](https://optimistic.etherscan.io/address/0x558302715e3011Be6695605c11A65526D2ba2245)\n\nArbitrum:\n- [0x328FE8bbd30487BB7b5A8eEb909f892E9E229271](https://arbiscan.io/address/0x328FE8bbd30487BB7b5A8eEb909f892E9E229271)\n\nBase:\n- [0x48825133EF08327535D0b24d73779E82BE6Ea4d9](https://basescan.org/address/0x48825133EF08327535D0b24d73779E82BE6Ea4d9)\n\nWorldchain:\n- [0x886eb82a7e5E7310F66A0E83748662A17E391eb0](https://worldscan.org/address/0x886eb82a7e5E7310F66A0E83748662A17E391eb0)\n\n### DePayForwarderV3\n\nAllows to pay into smart contracts.\n\nEthereum:\n- [0x61e1b824F97cDe70b73438481ECc8A5Ca380eB87](https://etherscan.io/address/0x61e1b824F97cDe70b73438481ECc8A5Ca380eB87)\n\nBNB Smart Chain:\n- [0x9D7B9B0F1f8b39d3667C2C8e6A391166F535a477](https://bscscan.com/address/0x9D7B9B0F1f8b39d3667C2C8e6A391166F535a477)\n\nPolygon (POS):\n- [0xA47D5E0e6684D3ad73F3b94d9DAf18a2f5F97688](https://polygonscan.com/address/0xA47D5E0e6684D3ad73F3b94d9DAf18a2f5F97688)\n\nAvalanche:\n- [0x376d6B0F8c9b829aAb0a7478952DEF1F8656D7c4](https://snowtrace.io/address/0x376d6B0F8c9b829aAb0a7478952DEF1F8656D7c4)\n\nGnosis:\n- [0xd3967a248Bd105CE5511FF5a8136548ADC78E64e](https://gnosisscan.io/address/0xd3967a248Bd105CE5511FF5a8136548ADC78E64e)\n\nOptimism: \n- [0x2fd0a07a4F73285d0eBa8176426BF9B8c0121206](https://optimistic.etherscan.io/address/0x2fd0a07a4F73285d0eBa8176426BF9B8c0121206)\n\nArbitrum:\n- [0xd3967a248Bd105CE5511FF5a8136548ADC78E64e](https://arbiscan.io/address/0xd3967a248Bd105CE5511FF5a8136548ADC78E64e)\n\nBase:\n- [0xc14318b5D57DB31491dc50295e581a79E56f8A7a](https://basescan.org/address/0xc14318b5D57DB31491dc50295e581a79E56f8A7a)\n\nWorldchain:\n- [0xFee05C41195985909DDfc9127Db1f94559c46db3](https://worldscan.org/address/0xFee05C41195985909DDfc9127Db1f94559c46db3)\n\n### DePayWETHExchangeV1\n\nDePayWETHExchangeV1 allows to swap WETH\u003c\u003eETH both ways when performing payments using the DePay Router.\n\nEthereum:\n- [0x298f4980525594b3b982779cf74ba76819708D43](https://etherscan.io/address/0x298f4980525594b3b982779cf74ba76819708D43)\n\nBNB Smart Chain:\n- [0xeEb80d14abfB058AA78DE38813fe705c3e3b243E](https://bscscan.com/address/0xeEb80d14abfB058AA78DE38813fe705c3e3b243E)\n\nPolygon (POS):\n- [0xaE59C9d3E055BdFAa583E169aA5Ebe395689476a](https://polygonscan.com/address/0xaE59C9d3E055BdFAa583E169aA5Ebe395689476a)\n\nAvalanche:\n- [0x2d0a6275eaDa0d03226919ce6D93661E589B2d59](https://snowtrace.io/address/0x2d0a6275eaDa0d03226919ce6D93661E589B2d59)\n\nGnosis:\n- [0x2d0a6275eaDa0d03226919ce6D93661E589B2d59](https://gnosisscan.io/address/0x2d0a6275eaDa0d03226919ce6D93661E589B2d59)\n\nOptimism: \n- [0x69594057e2C0224deb1180c7a5Df9ec9d5B611B5](https://optimistic.etherscan.io/address/0x69594057e2C0224deb1180c7a5Df9ec9d5B611B5)\n\nArbitrum:\n- [0x7E655088214d0657251A51aDccE9109CFd23B5B5](https://arbiscan.io/address/0x7E655088214d0657251A51aDccE9109CFd23B5B5)\n\nBase:\n- [0x8206ba765BDD4770B08B807a8819a66A9F035A08](https://basescan.org/address/0x8206ba765BDD4770B08B807a8819a66A9F035A08)\n\nWorldchain:\n- [0x2CA727BC33915823e3D05fe043d310B8c5b2dC5b](https://worldscan.org/address/0x2CA727BC33915823e3D05fe043d310B8c5b2dC5b)\n\n## Functionalities\n\n### pay\n\nThe DePay Router smart contract enables decentralized payments with auto-conversion, payment- and protocol-fees.\n\nThe main purpose of the DePay Router evolves around the `pay` function.\n\nThe DePay Router allows for the following payments:\n  \n  - NATIVE to NATIVE\n  - NATIVE to TOKEN\n  - TOKEN to NATIVE\n  - TOKEN to WRAPPED\n  - WRAPPED to NATIVE\n  - WRAPPED to TOKEN\n  - NATIVE to WRAPPED\n  - TOKEN_A to TOKEN_B\n\nThe DePay Router offers 3 different `pay` functions which are overloaded and to be differentiated by their method arguments.\n\nThe pay funciton of the DePay Router requires a `Payment` struct in order to process a payment. The struct is assembled as follows:\n\n```\nstruct Payment {\n  uint256 amountIn;\n  uint256 paymentAmount;\n  uint256 feeAmount;\n  uint256 feeAmount2;\n  uint256 protocolAmount;\n  uint256 deadline; // in milliseconds!\n  address tokenInAddress;\n  address exchangeAddress;\n  address tokenOutAddress;\n  address paymentReceiverAddress;\n  address feeReceiverAddress;\n  address feeReceiverAddress2;\n  uint8 exchangeType;\n  uint8 receiverType;\n  bool permit2;\n  bytes exchangeCallData;\n  bytes receiverCallData;\n}\n```\n\n#### pay - without any prior approval\n\nUsing a blockchains native currency to perform a payment using the DePay Router's `pay` function does not require any upfront approval.\n\nThis means payments from:\n\n- NATIVE to NATIVE\n- NATIVE to token\n- NATIVE to WRAPPED\n\ncan be performed without any prior approval or signature.\n\n```\nfunction pay(\n  Payment calldata payment\n) external payable returns(bool);\n```\n\n```\npay(\n  (uint256,uint256,uint256,uint256,uint256,uint256,address,address,address,address,address,address,uint8,uint8,bool,bytes,bytes)\n)\n```\n\n```javascript\nrouter.connect(senderWallet)[\n  \"pay((uint256,uint256,uint256,uint256,uint256,uint256,address,address,address,address,address,address,uint8,uint8,bool,bytes,bytes))\"\n]({\n  amountIn: \"1000000000\",\n  paymentAmount: \"1000000000\",\n  feeAmount: \"0\",\n  feeAmount2: \"0\",\n  protocolAmount: \"0\",\n  deadline: \"1727680659852\",\n  tokenInAddress: \"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\",\n  exchangeAddress: \"0x0000000000000000000000000000000000000000\",\n  tokenOutAddress: \"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE\",\n  paymentReceiverAddress: receiverWallet,\n  feeReceiverAddress: \"0x0000000000000000000000000000000000000000\",\n  feeReceiverAddress2: \"0x0000000000000000000000000000000000000000\",\n  exchangeType: 0,\n  receiverType: 0,\n  permit2: false,\n  exchangeCallData: \"0x\",\n  receiverCallData: \"0x\",\n}, { value: \"1000000000\" })\n```\n\n#### pay - with permit2 SignatureTransfer\n\nThe `pay` function in the DePay Router enables token-based payments, which can be enabled by upfront [permit2 SignatureTransfers](https://docs.uniswap.org/contracts/permit2/reference/signature-transfer).\n\nOnce the payment sender has allowed the permit2 contract as a spender for a given token and signed a permit2 SignatureTransfer for the DePay Router, the following payments can be performed:\n\n- TOKEN to NATIVE\n- TOKEN to WRAPPED\n- TOKEN_A to TOKEN_B\n- WRAPPED to NATIVE\n- WRAPPED to TOKEN\n\n```\nstruct TokenPermissions {\n  address token;\n  uint256 amount;\n}\n\nstruct PermitTransferFrom {\n  TokenPermissions permitted;\n  uint256 nonce;\n  uint256 deadline;\n}\n\nstruct PermitTransferFromAndSignature {\n  IPermit2.PermitTransferFrom permitTransferFrom;\n  bytes signature;\n}\n\nfunction pay(\n  IDePayRouterV3.Payment calldata payment,\n  PermitTransferFromAndSignature calldata permitTransferFromAndSignature\n) external payable returns(bool);\n```\n\n```\npay(\n  (uint256,uint256,uint256,uint256,uint256,uint256,address,address,address,address,address,address,uint8,uint8,bool,bytes,bytes),\n  (\n    (\n      (address,uint256),\n      uint256,\n      uint256\n    ),\n    bytes\n  )\n)\n```\n\n```javascript\nconst domain = {\n  chainId: \"10\", // e.g. optimism\n  name: \"Permit2\",\n  verifyingContract: permit2Contract.address\n}\n\nconst types = {\n  PermitTransferFrom: [\n    { name: \"permitted\", type: \"TokenPermissions\" },\n    { name: \"spender\", type: \"address\" },\n    { name: \"nonce\", type: \"uint256\" },\n    { name: \"deadline\", type: \"uint256\" }\n  ],\n  TokenPermissions: [\n    { name: \"token\", type: \"address\" },\n    { name: \"amount\", type: \"uint256\" },\n  ]\n}\n\nconst data = {\n  permitted: {\n    token: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n    amount: \"100000\",\n  },\n  spender: routerAddress,\n  nonce,\n  deadline\n}\n\nconst signature = await wallets[0]._signTypedData(domain, types, data)\n\nrouter.connect(senderWallet)[\n  \"pay((uint256,uint256,uint256,uint256,uint256,address,address,address,address,address,uint8,uint8,bool,bytes,bytes),(((address,uint256),uint256,uint256),bytes))\"\n](\n  { // payment\n    amountIn: \"100000\",\n    paymentAmount: \"100000\",\n    feeAmount: \"0\",\n    feeAmount2: \"0\",\n    protocolAmount: \"0\",\n    deadline: \"1727680659852\",\n    tokenInAddress: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n    exchangeAddress: \"0x0000000000000000000000000000000000000000\",\n    tokenOutAddress: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n    paymentReceiverAddress: receiverWallet,\n    feeReceiverAddress: \"0x0000000000000000000000000000000000000000\",\n    feeReceiverAddress2: \"0x0000000000000000000000000000000000000000\",\n    exchangeType: 0,\n    receiverType: 0,\n    permit2: true,\n    exchangeCallData: \"0x\",\n    receiverCallData: \"0x\",\n  },\n  { // PermitTransferFromAndSignature\n    permitTransferFrom: {\n       permitted: {\n        token: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n        amount: \"100000\",\n      },\n      nonce,\n      deadline\n    },\n    signature\n  },\n  { value: 0 }\n)\n```\n\n#### pay - with ERC-20 token approval\n\nThe `pay` function in the DePay Router enables token-based payments, which can be enabled by upfront [ERC-20 token approvals](https://docs.openzeppelin.com/contracts/2.x/api/token/erc20#IERC20-approve-address-uint256-).\n\nOnce the payment sender has allowed the DePay Router as a spender for a given token, the following payments can be performed:\n\n- TOKEN to NATIVE\n- TOKEN to WRAPPED\n- TOKEN_A to TOKEN_B\n- WRAPPED to NATIVE\n- WRAPPED to TOKEN\n\n```\nfunction pay(\n  Payment calldata payment\n) external payable returns(bool);\n```\n\n```\npay(\n  (uint256,uint256,uint256,uint256,uint256,uint256,address,address,address,address,address,address,uint8,uint8,bool,bytes,bytes)\n)\n```\n\n```javascript\nconst PAY = \"pay((uint256,uint256,uint256,uint256,uint256,uint256,address,address,address,address,address,address,uint8,uint8,bool,bytes,bytes))\"\n\nrouter.connect(senderWallet)[PAY]({\n  amountIn: \"100000\",\n  paymentAmount: \"100000\",\n  feeAmount: \"0\",\n  feeAmount2: \"0\",\n  protocolAmount: \"0\",\n  deadline: \"1727680659852\",\n  tokenInAddress: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n  exchangeAddress: \"0x0000000000000000000000000000000000000000\",\n  tokenOutAddress: \"0xdAC17F958D2ee523a2206206994597C13D831ec7\",\n  paymentReceiverAddress: receiverWallet,\n  feeReceiverAddress: \"0x0000000000000000000000000000000000000000\",\n  feeReceiverAddress2: \"0x0000000000000000000000000000000000000000\",\n  exchangeType: 0,\n  receiverType: 0,\n  permit2: false,\n  exchangeCallData: \"0x\",\n  receiverCallData: \"0x\",\n}, { value: 0 })\n```\n\n### Payment Event\n\nThe `DePayRouterV3` emits a `Payment` event for all payments:\n\n```\nevent Payment(\n  address indexed from,\n  address indexed to,\n  uint256 indexed deadline,\n  uint256 amountIn,\n  uint256 paymentAmount,\n  uint256 feeAmount,\n  uint256 feeAmount2,\n  uint256 protocolAmount,\n  uint256 slippageAmount,\n  address tokenInAddress,\n  address tokenOutAddress,\n  address feeReceiverAddress,\n  address feeReceiverAddress2,\n);\n```\n\n## Development\n\nCreate an `.env` file with the following content:\n```\nNODE_ENV=development\n\nMNEMONIC=\"shine romance erase resource daring bean talk right cupboard visa renew galaxy\"\n#(0) 0xdde3dc4308A7856D49D1d7303bB630Bccb45Caf9\n#(1) 0x26Fe22F655303151C2ef3b2D097F842ab27Ef940\n#(2) 0x877a79C20028F9ef81e956B43B917703cC22A07A\n#(3) 0x3a36b51c5125A9c064f4Cd2F492989618CF7660E\n\nARBITRUM_NOVA_RPC_URL=https://arbitrum-nova.blastapi.io/\u003cAPIKEY\u003e\nARBITRUM_ONE_RPC_URL=https://arbitrum-one.blastapi.io/\u003cAPIKEY\u003e\nAVALANCHE_RPC_URL=https://ava-mainnet.blastapi.io/\u003cAPIKEY\u003e/ext/bc/C/rpc\nBSC_RPC_URL=https://bsc-mainnet.blastapi.io/\u003cAPIKEY\u003e\nETHEREUM_RPC_URL=https://eth-mainnet.blastapi.io/\u003cAPIKEY\u003e\nGNOSIS_RPC_URL=https://gnosis-mainnet.blastapi.io/\u003cAPIKEY\u003e\nOPTIMISM_RPC_URL=https://optimism.blockpi.network/v1/rpc/public\nPOLYGON_RPC_URL=https://polygon-mainnet.blastapi.io/\u003cAPIKEY\u003e\nPOLYGON_ZKEVM_RPC_URL=https://polygon-zkevm-mainnet.blastapi.io/\u003cAPIKEY\u003e\nZKSYNC_ERA_RPC_URL=https://mainnet.era.zksync.io\n```\n\n### Quick Start\n\n```\nyarn install\nyarn test\n```\n\n### Testing\n\nTest on a specific chain:\n```\nyarn test:\u003cchain\u003e\n```\n\ne.g. `ethereum`, `bsc` etc.\n\nTest on all blockchains:\n\n```\nyarn test\n```\n\nTest single files:\n\n```\nnpx hardhat test test/optimism/pay_with_exchange_conversion.spec.ts --config hardhat.config.optimism.ts\n```\n\n### Deploy\n\n1. `yarn flatten`\n\n2. Deploy flatten contract\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepayfi%2Fdepay-evm-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdepayfi%2Fdepay-evm-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdepayfi%2Fdepay-evm-router/lists"}