Skip to content

Commit

Permalink
Gasless flow Permit2Proxy (v1.0.0) [Permit2Proxy v1.0.0] (#782)
Browse files Browse the repository at this point in the history
* Add Permit2Proxy

* Add Permit2Proxy

* forge install: Permit2

* Get basic test working...

* Add more basic tests

* Remove superfluous receiver param

* Add utility method for getting a valid and working msgHash to sign

* Change name to be more specific

* Add Permit "v1" functionality

* Add Permit "v1" tests

* Add missing comments

* Flesh out demo script

* Finish demo script

* Cleanup and comments

* Fix log

* Remove extra files

* Remove extra remapping

* Remove unneeded lib

* Add official Permit2 addresses

* Allow only signer to call using EIP2612

* Bind Permit2Proxy to a single diamond

* Update deploy script

* Implement non-gasless Permit2 flow

* Redeploy to staging and update demo script

* Update comments and remove unneeded events/errors

* Add utility methods for determining the next valid nonce

* Redeploy and update demo script

* Add documentation

* Fixes

* Change witness type to be consistent with the rest of the codebase

* Remove unneeded whitelist

* Fixes

* Fixes

* Boost test coverage

* More fixes

* More fixes

* removes unused imports (audit issue#2)

* adds WithdrawablePeriphery base contract to token withdrawals

* audit report added

* Update src/Periphery/Permit2Proxy.sol

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update src/Periphery/Permit2Proxy.sol

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* rename test file to match naming convention

* adds WithdrawablePeriphery base contract for token withdrawals

* fix test

* adds version tag to contract

* target state updated

* deploy script fixed

* deployed to PROD (arb, opt, pol)

* fix test

* Update Witness Type Hash to match convention

* Deploy update to staging

* update audit report (incl fixed typehash issue)

* Fix stype string as well

* Redeploy to staging

* Update Permit2Proxy.t.sol

* add demo for permit2 flow without witness

* clean permit2 generation

* simplify signature generation

* remove old openzeppelin lib

* forge install: openzeppelin-contracts

v4.9.2

* update audit log and report

* target state updated

* deployed to various PROD networks (excl zksync)

* verified Permit2Proxy on base

* deploy to zksync

* diamond logs updated

* bugfix in fixAuditLabel action

* fix logs

* fix test

---------

Co-authored-by: Daniel Bläcker <[email protected]>
Co-authored-by: Daniel <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Max Klenk <[email protected]>
  • Loading branch information
5 people authored Nov 28, 2024
1 parent 383a52e commit 7edab5f
Show file tree
Hide file tree
Showing 70 changed files with 2,254 additions and 308 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/Vectorized/solady
[submodule "lib/Permit2"]
path = lib/Permit2
url = https://github.com/Uniswap/Permit2
18 changes: 14 additions & 4 deletions audit/auditLog.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,29 @@
"auditorGitHandle": "sujithsomraaj",
"auditReportPath": "./audit/reports/2024.11.05_EmergencyPauseFacet_ReAudit.pdf",
"auditCommitHash": "da61880ba3847c07c35b64a78b957ff845ec18ac"
},
"audit20241122": {
"auditCompletedOn": "22.11.2024",
"auditedBy": "Sujith Somraaj (individual security researcher)",
"auditorGitHandle": "sujithsomraaj",
"auditReportPath": "./audit/reports/2024.11.22_Permit2Proxy.pdf",
"auditCommitHash": "0e3debb78abcdf9a9f934115338b611e16b039a0"
}
},
"auditedContracts": {
"EmergencyPauseFacet": {
"1.0.0": ["audit20240913"],
"1.0.1": ["audit20241105"]
},
"AcrossFacetV3": {
"1.0.0": ["audit20241007"]
},
"AcrossFacetPackedV3": {
"1.0.0": ["audit20241007"]
},
"EmergencyPauseFacet": {
"1.0.0": ["audit20240913"],
"1.0.1": ["audit20241105"]
},
"Permit2Proxy": {
"1.0.0": ["audit20241122"]
},
"ReceiverAcrossV3": {
"1.0.0": ["audit20241007"]
},
Expand Down
Binary file added audit/reports/2024.11.22_Permit2Proxy.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions config/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@
"explorerUrl": "https://blastscan.io",
"explorerApiUrl": "https://api.blastscan.io/api",
"multicallAddress": "0xcA11bde05977b3631167028862bE2a173976CA11",
"safeApiUrl": "https://transaction.blast-safe.io/api",
"safeApiUrl": "https://safe-transaction-blast.safe.global/api",
"safeAddress": "0xdf61270fDC1A892874Fd3C0143A0A4CBA74F4EF1",
"safeWebUrl": "https://blast-safe.io/transactions/queue?safe=blastmainnet:0xdf61270fDC1A892874Fd3C0143A0A4CBA74F4EF1",
"safeWebUrl": "https://app.safe.global/transactions/queue?safe=blast:0xdf61270fDC1A892874Fd3C0143A0A4CBA74F4EF1",
"gasZipChainId": 96
},
"boba": {
Expand Down
31 changes: 31 additions & 0 deletions config/permit2Proxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"mainnet": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"arbitrum": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"aurora": "",
"avalanche": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"base": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"blast": "0x000000000022d473030f116ddee9f6b43ac78ba3",
"boba": "",
"bsc": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"celo": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"fantom": "",
"fraxtal": "",
"fuse": "",
"gnosis": "",
"gravity": "",
"immutablezkevm": "",
"linea": "",
"mantle": "",
"metis": "",
"mode": "",
"moonbeam": "",
"moonriver": "",
"optimism": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"polygon": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"polygonzkevm": "",
"rootstock": "",
"scroll": "",
"sei": "",
"taiko": "",
"zksync": "0x0000000000225e31d15943971f47ad3022f714fa"
}
168 changes: 167 additions & 1 deletion deployments/_deployments_log_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -24602,5 +24602,171 @@
]
}
}
},
"Permit2Proxy": {
"arbitrum": {
"staging": {
"1.0.0": [
{
"ADDRESS": "0x6FC01BC9Ff6Cdab694Ec8Ca41B21a2F04C8c37E5",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-10-21 09:31:13",
"CONSTRUCTOR_ARGS": "0x000000000000000000000000d3b2b0ac0afdd0d166a495f5e9fca4ecc715a782000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000009e606d0d2bba344b911e2f4eab95d9235a83fe15",
"SALT": "",
"VERIFIED": "true"
}
]
},
"production": {
"1.0.0": [
{
"ADDRESS": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 11:24:27",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000009e606d0d2bba344b911e2f4eab95d9235a83fe15",
"SALT": "",
"VERIFIED": "true"
}
]
}
},
"polygon": {
"production": {
"1.0.0": [
{
"ADDRESS": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 11:26:53",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000008bcc385948c73736423d38cc567cfede0f1826a3",
"SALT": "",
"VERIFIED": "true"
}
]
},
"staging": {
"1.0.0": [
{
"ADDRESS": "0x6FC01BC9Ff6Cdab694Ec8Ca41B21a2F04C8c37E5",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-10-21 09:32:45",
"CONSTRUCTOR_ARGS": "0x000000000000000000000000d3b2b0ac0afdd0d166a495f5e9fca4ecc715a782000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000008bcc385948c73736423d38cc567cfede0f1826a3",
"SALT": "",
"VERIFIED": "true"
}
]
}
},
"optimism": {
"production": {
"1.0.0": [
{
"ADDRESS": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 11:25:40",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3000000000000000000000000a8892ea3fddef2aa8afb1e3643a3284f978a5114",
"SALT": "",
"VERIFIED": "true"
}
]
}
},
"mainnet": {
"production": {
"1.0.0": [
{
"ADDRESS": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 11:10:40",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba300000000000000000000000037347dd595c49212c5fc2d95ea10d1085896f51e",
"SALT": "",
"VERIFIED": "true"
}
]
}
},
"avalanche": {
"production": {
"1.0.0": [
{
"ADDRESS": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 12:15:16",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba300000000000000000000000027d4eb2854d93a1a7df8e2aed1a535b080a6f6e4",
"SALT": "",
"VERIFIED": "true"
}
]
}
},
"base": {
"production": {
"1.0.0": [
{
"ADDRESS": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 12:26:53",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba30000000000000000000000001f6974c11b833eb52ea07e0b442510165d87d82e",
"SALT": "",
"VERIFIED": "true"
}
]
}
},
"blast": {
"production": {
"1.0.0": [
{
"ADDRESS": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 12:38:05",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3000000000000000000000000df61270fdc1a892874fd3c0143a0a4cba74f4ef1",
"SALT": "",
"VERIFIED": "true"
}
]
}
},
"bsc": {
"production": {
"1.0.0": [
{
"ADDRESS": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 12:39:31",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba300000000000000000000000020b6b31d76e054c3e4de6154feca385ca58c7c15",
"SALT": "",
"VERIFIED": "true"
}
]
}
},
"celo": {
"production": {
"1.0.0": [
{
"ADDRESS": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 13:03:21",
"CONSTRUCTOR_ARGS": "0x0000000000000000000000001231deb6f5749ef6ce6943a275a1d3e7486f4eae000000000000000000000000000000000022d473030f116ddee9f6b43ac78ba3000000000000000000000000a89a87986e8ee1ac8fdacc5ac91627010ec9f772",
"SALT": "",
"VERIFIED": "true"
}
]
}
},
"zksync": {
"production": {
"1.0.0": [
{
"ADDRESS": "0x6275f6631c955DC5dA9fBe8Dc7f24a3A5919443A",
"OPTIMIZER_RUNS": "1000000",
"TIMESTAMP": "2024-11-25 13:42:32",
"CONSTRUCTOR_ARGS": "0x000000000000000000000000341e94069f53234fe6dabef707ad4248305257150000000000000000000000000000000000225e31d15943971f47ad3022f714fa00000000000000000000000002f1272aeacaf7bd8b30278bc2aa381cc623a744",
"SALT": "",
"VERIFIED": "true"
}
]
}
}
}
}
}
7 changes: 6 additions & 1 deletion deployments/arbitrum.diamond.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@
"0x6F2baA7cd5F156CA1B132F7FF11E0fa2aD775F61": {
"Name": "EmergencyPauseFacet",
"Version": "1.0.0"
},
"0xF5c923a087fb3c554579e2DD10AB6E37E0f6F849": {
"Name": "GasZipFacet",
"Version": "1.0.0"
}
},
"Periphery": {
Expand All @@ -152,11 +156,12 @@
"FeeCollector": "0xB0210dE78E28e2633Ca200609D9f528c13c26cD9",
"LiFiDEXAggregator": "0x6140b987d6B51Fd75b66C3B07733Beb5167c42fc",
"LiFuelFeeCollector": "0xc02FFcdD914DbA646704439c6090BAbaD521d04C",
"Permit2Proxy": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"Receiver": "0x050e198E36A73a1e32F15C3afC58C4506d82f657",
"ReceiverAcrossV3": "0xB9CEc304899037E661F49DdFa7f64943b5920072",
"ReceiverStargateV2": "0x1493e7B8d4DfADe0a178dAD9335470337A3a219A",
"RelayerCelerIM": "0x6a8b11bF29C0546991DEcD6E0Db8cC7Fda22bA97",
"TokenWrapper": "0x5215E9fd223BC909083fbdB2860213873046e45d"
}
}
}
}
3 changes: 2 additions & 1 deletion deployments/arbitrum.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
"StargateFacetV2": "0x6e378C84e657C57b2a8d183CFf30ee5CC8989b61",
"ReceiverStargateV2": "0x1493e7B8d4DfADe0a178dAD9335470337A3a219A",
"LiFiDEXAggregator": "0x6140b987d6B51Fd75b66C3B07733Beb5167c42fc",
"Permit2Proxy": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"EmergencyPauseFacet": "0x6F2baA7cd5F156CA1B132F7FF11E0fa2aD775F61",
"AcrossFacetV3": "0x6e00e0a7685Ca22c288d56D9E7924746B5043Ee7",
"ReceiverAcrossV3": "0xB9CEc304899037E661F49DdFa7f64943b5920072",
"AcrossFacetPackedV3": "0x20F3FFf5A89e988c4109A6e496a839480B1B558f"
}
}
1 change: 1 addition & 0 deletions deployments/arbitrum.staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"LiFuelFeeCollector": "0x94EA56D8049e93E0308B9c7d1418Baf6A7C68280",
"TokenWrapper": "0xF63b27AE2Dc887b88f82E2Cc597d07fBB2E78E70",
"EmergencyPauseFacet": "0x17Bb203F42d8e404ac7E8dB6ff972B7E8473850b",
"Permit2Proxy": "0x6FC01BC9Ff6Cdab694Ec8Ca41B21a2F04C8c37E5",
"AcrossFacetV3": "0x6124C65B6264bE13f059b7C3A891a5b77DA8Bd95",
"ReceiverAcrossV3": "0x3877f47B560819E96BBD7e7700a02dfACe36D696",
"AcrossFacetPackedV3": "0x4352459F6BE1C7D1278F8c34Bb598b0feeB50f8b"
Expand Down
19 changes: 12 additions & 7 deletions deployments/aurora.diamond.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,23 @@
"0x6e378C84e657C57b2a8d183CFf30ee5CC8989b61": {
"Name": "StargateFacetV2",
"Version": "1.0.1"
},
"0x6F2baA7cd5F156CA1B132F7FF11E0fa2aD775F61": {
"Name": "EmergencyPauseFacet",
"Version": "1.0.0"
}
},
"Periphery": {
"ERC20Proxy": "",
"Executor": "",
"ERC20Proxy": "0x5741A7FfE7c39Ca175546a54985fA79211290b51",
"Executor": "0x2dfaDAB8266483beD9Fd9A292Ce56596a2D1378D",
"FeeCollector": "0xB0210dE78E28e2633Ca200609D9f528c13c26cD9",
"LiFiDEXAggregator": "",
"LiFuelFeeCollector": "",
"Receiver": "0x5439f8ca43f832DD21a28C5BF038dad4c07ad02c",
"LiFiDEXAggregator": "0x6140b987d6B51Fd75b66C3B07733Beb5167c42fc",
"LiFuelFeeCollector": "0x8E92e662573CBC66B0AB6A93B5FE291925508085",
"Permit2Proxy": "",
"Receiver": "",
"ReceiverAcrossV3": "",
"ReceiverStargateV2": "",
"RelayerCelerIM": "",
"ReceiverStargateV2": "0x1493e7B8d4DfADe0a178dAD9335470337A3a219A",
"RelayerCelerIM": "0x6a8b11bF29C0546991DEcD6E0Db8cC7Fda22bA97",
"TokenWrapper": "0x5215E9fd223BC909083fbdB2860213873046e45d"
}
}
Expand Down
5 changes: 5 additions & 0 deletions deployments/avalanche.diamond.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@
"0x6F2baA7cd5F156CA1B132F7FF11E0fa2aD775F61": {
"Name": "EmergencyPauseFacet",
"Version": "1.0.0"
},
"0xF5c923a087fb3c554579e2DD10AB6E37E0f6F849": {
"Name": "",
"Version": ""
}
},
"Periphery": {
Expand All @@ -124,6 +128,7 @@
"FeeCollector": "0xB0210dE78E28e2633Ca200609D9f528c13c26cD9",
"LiFiDEXAggregator": "0x6140b987d6B51Fd75b66C3B07733Beb5167c42fc",
"LiFuelFeeCollector": "0xc02FFcdD914DbA646704439c6090BAbaD521d04C",
"Permit2Proxy": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"Receiver": "0x050e198E36A73a1e32F15C3afC58C4506d82f657",
"ReceiverAcrossV3": "",
"ReceiverStargateV2": "0x1493e7B8d4DfADe0a178dAD9335470337A3a219A",
Expand Down
3 changes: 2 additions & 1 deletion deployments/avalanche.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
"StargateFacetV2": "0x6e378C84e657C57b2a8d183CFf30ee5CC8989b61",
"ReceiverStargateV2": "0x1493e7B8d4DfADe0a178dAD9335470337A3a219A",
"LiFiDEXAggregator": "0x6140b987d6B51Fd75b66C3B07733Beb5167c42fc",
"EmergencyPauseFacet": "0x6F2baA7cd5F156CA1B132F7FF11E0fa2aD775F61"
"EmergencyPauseFacet": "0x6F2baA7cd5F156CA1B132F7FF11E0fa2aD775F61",
"Permit2Proxy": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9"
}
9 changes: 9 additions & 0 deletions deployments/base.diamond.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@
"0x6F2baA7cd5F156CA1B132F7FF11E0fa2aD775F61": {
"Name": "EmergencyPauseFacet",
"Version": "1.0.0"
},
"0xF5c923a087fb3c554579e2DD10AB6E37E0f6F849": {
"Name": "",
"Version": ""
},
"0x6e00e0a7685Ca22c288d56D9E7924746B5043Ee7": {
"Name": "AcrossFacetV3",
"Version": "1.0.0"
}
},
"Periphery": {
Expand All @@ -140,6 +148,7 @@
"FeeCollector": "0x0A6d96E7f4D7b96CFE42185DF61E64d255c12DFf",
"LiFiDEXAggregator": "0x6140b987d6B51Fd75b66C3B07733Beb5167c42fc",
"LiFuelFeeCollector": "0xc02FFcdD914DbA646704439c6090BAbaD521d04C",
"Permit2Proxy": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9",
"Receiver": "0xeC03B65CbDc5f8858b02F44EBa54C90664249fb1",
"ReceiverAcrossV3": "0xB9CEc304899037E661F49DdFa7f64943b5920072",
"ReceiverStargateV2": "0x1493e7B8d4DfADe0a178dAD9335470337A3a219A",
Expand Down
5 changes: 3 additions & 2 deletions deployments/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
"EmergencyPauseFacet": "0x6F2baA7cd5F156CA1B132F7FF11E0fa2aD775F61",
"AcrossFacetV3": "0x6e00e0a7685Ca22c288d56D9E7924746B5043Ee7",
"ReceiverAcrossV3": "0xB9CEc304899037E661F49DdFa7f64943b5920072",
"AcrossFacetPackedV3": "0x20F3FFf5A89e988c4109A6e496a839480B1B558f"
}
"AcrossFacetPackedV3": "0x20F3FFf5A89e988c4109A6e496a839480B1B558f",
"Permit2Proxy": "0x6307119078556Fc8aD77781DFC67df20d75FB4f9"
}
Loading

0 comments on commit 7edab5f

Please sign in to comment.