From 0e6705ff7834df73dfa4eeb325a334cb77363eb0 Mon Sep 17 00:00:00 2001 From: just-a-node Date: Wed, 6 Mar 2024 16:31:08 -0700 Subject: [PATCH 1/2] feat: linea lockbox adapter --- .../59144/run-latest.json | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 broadcast/DeployLockboxAdapter.s.sol/59144/run-latest.json diff --git a/broadcast/DeployLockboxAdapter.s.sol/59144/run-latest.json b/broadcast/DeployLockboxAdapter.s.sol/59144/run-latest.json new file mode 100644 index 0000000..32d50bc --- /dev/null +++ b/broadcast/DeployLockboxAdapter.s.sol/59144/run-latest.json @@ -0,0 +1,51 @@ +{ + "transactions": [ + { + "hash": "0xc667ac81fc3a42bc73cc50fbcee32a0ecb38922db7c14bb96539aa1672f75867", + "transactionType": "CREATE", + "contractName": "LockboxAdapter", + "contractAddress": "0x4895AA5d666c81a04Ebcc7A9aa47f249B1c46aA6", + "function": null, + "arguments": [ + "0xa05eF29e9aC8C75c530c2795Fa6A800e188dE0a9", + "0x11984dc4465481512eb5b777E44061C158CF2259" + ], + "transaction": { + "type": "0x02", + "from": "0xade09131c6f43fe22c2cbabb759636c43cfc181e", + "gas": "0x106c6d", + "value": "0x0", + "data": "0x60c03461009557601f610ebe38819003918201601f19168301916001600160401b0383118484101761009a57808492604094855283398101031261009557610052602061004b836100b0565b92016100b0565b9060805260a052604051610df990816100c5823960805181818160e7015281816104ab015261059a015260a051818181610376015281816103d301526108b90152f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036100955756fe608080604052600436101561001d575b50361561001b57600080fd5b005b600090813560e01c908163479d955714610867575080638aac16ba146102c45763fd614f410361000f57346102c15760c03660031901126102c157602490813590610066610b15565b61006e610b2b565b5060843563ffffffff8116036102bc5760a43567ffffffffffffffff918282116102b857366023830112156102b8578160040135946100ac86610b77565b926100ba6040519485610b55565b86845260209687850191368a83830101116102b4578188928b8b93018537860101526001600160a01b03937f00000000000000000000000000000000000000000000000000000000000000008516330361029d57808891518101031261029957519280841680940361029957303b15610299579086916040519363479d955760e01b85528260048601521692838982015284604482015286808260648183305af1918261027e575b5050610275576101ac92610174610c0a565b60405163a9059cbb60e01b81526001600160a01b03909616600487015260248601929092529093928391908290889082906044820190565b03925af1801561026a57916101f5917fc800e8ca4bda8128731e0444109da53d19286048d068614656da8edcfc0f1d489361023d575b5060405191829187835287830190610b93565b0390a15b604051938385019182118583101761022957506040528252610225604051928284938452830190610b93565b0390f35b634e487b7160e01b60009081526041600452fd5b61025c90873d8911610263575b6102548183610b55565b810190610bf2565b50386101e2565b503d61024a565b6040513d86823e3d90fd5b505050506101f9565b61028b9192939450610b41565b610299579086918638610162565b8580fd5b60405163241314cd60e01b81523360048201528990fd5b8780fd5b8380fd5b600080fd5b80fd5b5060e03660031901126102c15760043563ffffffff811681036102bc576102e9610aff565b6102f1610b15565b916102fa610b2b565b9267ffffffffffffffff60c435116108635736602360c4350112156108635767ffffffffffffffff60c43560040135116108635736602460c4356004013560c43501011161086357608435156108515760405163476a536360e11b81526001600160a01b038281166004830152909490602090869060249082907f0000000000000000000000000000000000000000000000000000000000000000165afa948515610846578695610825575b5060405163eec9567960e01b81526001600160a01b038681166004830152909290602090849060249082907f0000000000000000000000000000000000000000000000000000000000000000165afa92831561063f5787936107f4575b506040516323ce9cbb60e11b81526020816004816001600160a01b0388165afa9081156107e95788916107ca575b50156106925750608435341061067257608435340334811161065e579186906001600160a01b0381163b1561060b57604051636db5a92360e11b815290829082906004908290608435906001600160a01b03165af180156106175761064a575b50505b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166004820152608435602482015294602086806044810103818a6001600160a01b0386165af194851561063f5763ffffffff96602096610622575b506040519687956345560b5d60e11b875216600486015260018060a01b0316602485015260018060a01b0316604484015260018060a01b03166064830152608435608483015260a43560a483015260e060c483015260c4356004013560e48301528161010460c43560040135602460c4350182840137600460c43501358281018201889052601f01601f1916820182900301917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19081156106175782916105dd575b602082604051908152f35b90506020813d60201161060f575b816105f860209383610b55565b8101031261060b576020915051386105d2565b5080fd5b3d91506105eb565b6040513d84823e3d90fd5b61063890873d8911610263576102548183610b55565b5038610505565b6040513d89823e3d90fd5b61065390610b41565b610299578538610491565b634e487b7160e01b87526011600452602487fd5b604051635bc10dc760e01b81523460048201526084356024820152604490fd5b6040516323b872dd60e01b60208201523360248201523060448201526084356064820152606481528060a081011067ffffffffffffffff60a0830111176107b45760a081016040526106ed906001600160a01b038316610c3a565b60405163095ea7b360e01b81526001600160a01b03848116600483015260843560248301529091602091839160449183918c91165af1801561063f57610795575b50349186906001600160a01b0381163b1561060b5760405163b6b55f2560e01b815260843560048201529082908290602490829084906001600160a01b03165af1801561061757610781575b5050610494565b61078a90610b41565b61029957853861077a565b6107ad9060203d602011610263576102548183610b55565b503861072e565b634e487b7160e01b600052604160045260246000fd5b6107e3915060203d602011610263576102548183610b55565b38610431565b6040513d8a823e3d90fd5b61081791935060203d60201161081e575b61080f8183610b55565b810190610bd3565b9138610403565b503d610805565b61083f91955060203d60201161081e5761080f8183610b55565b93386103a6565b6040513d88823e3d90fd5b60405163820bf1e560e01b8152600490fd5b8480fd5b82346102c15760603660031901126102c157600435610884610aff565b61088c610b15565b303303610aea5760405163eec9567960e01b81526001600160a01b039283166004820181905294955085947f00000000000000000000000000000000000000000000000000000000000000008416916020918282602481875afa9182156107e95760249484918a94610acb575b5060405195868092634e0dc55760e01b82528560048301525afa9384156107e9578894610aac575b506040516323ce9cbb60e11b815290828716908483600481855afa928315610aa15785918a918c95610a7e575b5060405163095ea7b360e01b81526001600160a01b0390961660048701526024860191909152929391928290818c81604481015b03925af18015610a7357610a56575b50803b156102b45787906024604051809b8193632e1a7d4d60e01b83528b60048401525af1801561063f57610a42575b8697506000146109f9575050839283928392165af16109de610c0a565b50156109e75780f35b60405163250c731360e11b8152600490fd5b60405163a9059cbb60e01b918101919091526001600160a01b03929092166024830152604480830194909452928152610a3f935091610a39606484610b55565b16610c3a565b80f35b959096610a4e90610b41565b9486906109c1565b610a6c90843d8611610263576102548183610b55565b5089610991565b6040513d8b823e3d90fd5b610982949550610a9a90843d8611610263576102548183610b55565b949361094e565b6040513d8c823e3d90fd5b610ac4919450833d851161081e5761080f8183610b55565b9289610921565b610ae3919450823d841161081e5761080f8183610b55565b928b6108f9565b630173cb6760e51b8552336004860152602485fd5b602435906001600160a01b03821682036102bc57565b604435906001600160a01b03821682036102bc57565b606435906001600160a01b03821682036102bc57565b67ffffffffffffffff81116107b457604052565b90601f8019910116810190811067ffffffffffffffff8211176107b457604052565b67ffffffffffffffff81116107b457601f01601f191660200190565b919082519283825260005b848110610bbf575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201610b9e565b908160209103126102bc57516001600160a01b03811681036102bc5790565b908160209103126102bc575180151581036102bc5790565b3d15610c35573d90610c1b82610b77565b91610c296040519384610b55565b82523d6000602084013e565b606090565b60408051908101916001600160a01b031667ffffffffffffffff8311828410176107b457610caa926040526000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af1610ca4610c0a565b91610d26565b80519081610cb757505050565b8280610cc7938301019101610bf2565b15610ccf5750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b91929015610d885750815115610d3a575090565b3b15610d435790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b825190915015610d9b5750805190602001fd5b60405162461bcd60e51b815260206004820152908190610dbf906024830190610b93565b0390fdfea26469706673582212202b1b9516411eb8de83068e58191f07b143e93f75a5cb7ff9fb5c87c7b34fcad864736f6c63430008140033000000000000000000000000a05ef29e9ac8c75c530c2795fa6a800e188de0a900000000000000000000000011984dc4465481512eb5b777e44061c158cf2259", + "nonce": "0xfd", + "accessList": [] + }, + "additionalContracts": [], + "isFixedGasLimit": false + } + ], + "receipts": [ + { + "transactionHash": "0xc667ac81fc3a42bc73cc50fbcee32a0ecb38922db7c14bb96539aa1672f75867", + "transactionIndex": "0xb", + "blockHash": "0xc637a131b6c5f2e7d08c67ac455b37444abfd43788defc56cb78c391ca9ec610", + "blockNumber": "0x1287d3", + "from": "0xade09131C6f43fe22C2CbABb759636C43cFc181e", + "to": null, + "cumulativeGasUsed": "0x1b2688", + "gasUsed": "0xca22d", + "contractAddress": "0x4895AA5d666c81a04Ebcc7A9aa47f249B1c46aA6", + "logs": [], + "status": "0x1", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "type": "0x2", + "effectiveGasPrice": "0xb2d05e07" + } + ], + "libraries": [], + "pending": [], + "returns": {}, + "timestamp": 1702596283, + "chain": 59144, + "multi": false, + "commit": "c427219" +} \ No newline at end of file From c073733e6827c736d16080884d5d27b64d6eddcc Mon Sep 17 00:00:00 2001 From: just-a-node Date: Fri, 15 Mar 2024 11:13:31 -0700 Subject: [PATCH 2/2] feat: lockbox adapter for Blast standard bridge --- .../59144/run-latest.json | 51 -------------- contracts/integration/LockboxAdapterBlast.sol | 70 +++++++++++++++++++ script/DeployLockboxAdapterBlast.s.sol | 18 +++++ 3 files changed, 88 insertions(+), 51 deletions(-) delete mode 100644 broadcast/DeployLockboxAdapter.s.sol/59144/run-latest.json create mode 100644 contracts/integration/LockboxAdapterBlast.sol create mode 100644 script/DeployLockboxAdapterBlast.s.sol diff --git a/broadcast/DeployLockboxAdapter.s.sol/59144/run-latest.json b/broadcast/DeployLockboxAdapter.s.sol/59144/run-latest.json deleted file mode 100644 index 32d50bc..0000000 --- a/broadcast/DeployLockboxAdapter.s.sol/59144/run-latest.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "transactions": [ - { - "hash": "0xc667ac81fc3a42bc73cc50fbcee32a0ecb38922db7c14bb96539aa1672f75867", - "transactionType": "CREATE", - "contractName": "LockboxAdapter", - "contractAddress": "0x4895AA5d666c81a04Ebcc7A9aa47f249B1c46aA6", - "function": null, - "arguments": [ - "0xa05eF29e9aC8C75c530c2795Fa6A800e188dE0a9", - "0x11984dc4465481512eb5b777E44061C158CF2259" - ], - "transaction": { - "type": "0x02", - "from": "0xade09131c6f43fe22c2cbabb759636c43cfc181e", - "gas": "0x106c6d", - "value": "0x0", - "data": "0x60c03461009557601f610ebe38819003918201601f19168301916001600160401b0383118484101761009a57808492604094855283398101031261009557610052602061004b836100b0565b92016100b0565b9060805260a052604051610df990816100c5823960805181818160e7015281816104ab015261059a015260a051818181610376015281816103d301526108b90152f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036100955756fe608080604052600436101561001d575b50361561001b57600080fd5b005b600090813560e01c908163479d955714610867575080638aac16ba146102c45763fd614f410361000f57346102c15760c03660031901126102c157602490813590610066610b15565b61006e610b2b565b5060843563ffffffff8116036102bc5760a43567ffffffffffffffff918282116102b857366023830112156102b8578160040135946100ac86610b77565b926100ba6040519485610b55565b86845260209687850191368a83830101116102b4578188928b8b93018537860101526001600160a01b03937f00000000000000000000000000000000000000000000000000000000000000008516330361029d57808891518101031261029957519280841680940361029957303b15610299579086916040519363479d955760e01b85528260048601521692838982015284604482015286808260648183305af1918261027e575b5050610275576101ac92610174610c0a565b60405163a9059cbb60e01b81526001600160a01b03909616600487015260248601929092529093928391908290889082906044820190565b03925af1801561026a57916101f5917fc800e8ca4bda8128731e0444109da53d19286048d068614656da8edcfc0f1d489361023d575b5060405191829187835287830190610b93565b0390a15b604051938385019182118583101761022957506040528252610225604051928284938452830190610b93565b0390f35b634e487b7160e01b60009081526041600452fd5b61025c90873d8911610263575b6102548183610b55565b810190610bf2565b50386101e2565b503d61024a565b6040513d86823e3d90fd5b505050506101f9565b61028b9192939450610b41565b610299579086918638610162565b8580fd5b60405163241314cd60e01b81523360048201528990fd5b8780fd5b8380fd5b600080fd5b80fd5b5060e03660031901126102c15760043563ffffffff811681036102bc576102e9610aff565b6102f1610b15565b916102fa610b2b565b9267ffffffffffffffff60c435116108635736602360c4350112156108635767ffffffffffffffff60c43560040135116108635736602460c4356004013560c43501011161086357608435156108515760405163476a536360e11b81526001600160a01b038281166004830152909490602090869060249082907f0000000000000000000000000000000000000000000000000000000000000000165afa948515610846578695610825575b5060405163eec9567960e01b81526001600160a01b038681166004830152909290602090849060249082907f0000000000000000000000000000000000000000000000000000000000000000165afa92831561063f5787936107f4575b506040516323ce9cbb60e11b81526020816004816001600160a01b0388165afa9081156107e95788916107ca575b50156106925750608435341061067257608435340334811161065e579186906001600160a01b0381163b1561060b57604051636db5a92360e11b815290829082906004908290608435906001600160a01b03165af180156106175761064a575b50505b60405163095ea7b360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166004820152608435602482015294602086806044810103818a6001600160a01b0386165af194851561063f5763ffffffff96602096610622575b506040519687956345560b5d60e11b875216600486015260018060a01b0316602485015260018060a01b0316604484015260018060a01b03166064830152608435608483015260a43560a483015260e060c483015260c4356004013560e48301528161010460c43560040135602460c4350182840137600460c43501358281018201889052601f01601f1916820182900301917f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af19081156106175782916105dd575b602082604051908152f35b90506020813d60201161060f575b816105f860209383610b55565b8101031261060b576020915051386105d2565b5080fd5b3d91506105eb565b6040513d84823e3d90fd5b61063890873d8911610263576102548183610b55565b5038610505565b6040513d89823e3d90fd5b61065390610b41565b610299578538610491565b634e487b7160e01b87526011600452602487fd5b604051635bc10dc760e01b81523460048201526084356024820152604490fd5b6040516323b872dd60e01b60208201523360248201523060448201526084356064820152606481528060a081011067ffffffffffffffff60a0830111176107b45760a081016040526106ed906001600160a01b038316610c3a565b60405163095ea7b360e01b81526001600160a01b03848116600483015260843560248301529091602091839160449183918c91165af1801561063f57610795575b50349186906001600160a01b0381163b1561060b5760405163b6b55f2560e01b815260843560048201529082908290602490829084906001600160a01b03165af1801561061757610781575b5050610494565b61078a90610b41565b61029957853861077a565b6107ad9060203d602011610263576102548183610b55565b503861072e565b634e487b7160e01b600052604160045260246000fd5b6107e3915060203d602011610263576102548183610b55565b38610431565b6040513d8a823e3d90fd5b61081791935060203d60201161081e575b61080f8183610b55565b810190610bd3565b9138610403565b503d610805565b61083f91955060203d60201161081e5761080f8183610b55565b93386103a6565b6040513d88823e3d90fd5b60405163820bf1e560e01b8152600490fd5b8480fd5b82346102c15760603660031901126102c157600435610884610aff565b61088c610b15565b303303610aea5760405163eec9567960e01b81526001600160a01b039283166004820181905294955085947f00000000000000000000000000000000000000000000000000000000000000008416916020918282602481875afa9182156107e95760249484918a94610acb575b5060405195868092634e0dc55760e01b82528560048301525afa9384156107e9578894610aac575b506040516323ce9cbb60e11b815290828716908483600481855afa928315610aa15785918a918c95610a7e575b5060405163095ea7b360e01b81526001600160a01b0390961660048701526024860191909152929391928290818c81604481015b03925af18015610a7357610a56575b50803b156102b45787906024604051809b8193632e1a7d4d60e01b83528b60048401525af1801561063f57610a42575b8697506000146109f9575050839283928392165af16109de610c0a565b50156109e75780f35b60405163250c731360e11b8152600490fd5b60405163a9059cbb60e01b918101919091526001600160a01b03929092166024830152604480830194909452928152610a3f935091610a39606484610b55565b16610c3a565b80f35b959096610a4e90610b41565b9486906109c1565b610a6c90843d8611610263576102548183610b55565b5089610991565b6040513d8b823e3d90fd5b610982949550610a9a90843d8611610263576102548183610b55565b949361094e565b6040513d8c823e3d90fd5b610ac4919450833d851161081e5761080f8183610b55565b9289610921565b610ae3919450823d841161081e5761080f8183610b55565b928b6108f9565b630173cb6760e51b8552336004860152602485fd5b602435906001600160a01b03821682036102bc57565b604435906001600160a01b03821682036102bc57565b606435906001600160a01b03821682036102bc57565b67ffffffffffffffff81116107b457604052565b90601f8019910116810190811067ffffffffffffffff8211176107b457604052565b67ffffffffffffffff81116107b457601f01601f191660200190565b919082519283825260005b848110610bbf575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201610b9e565b908160209103126102bc57516001600160a01b03811681036102bc5790565b908160209103126102bc575180151581036102bc5790565b3d15610c35573d90610c1b82610b77565b91610c296040519384610b55565b82523d6000602084013e565b606090565b60408051908101916001600160a01b031667ffffffffffffffff8311828410176107b457610caa926040526000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af1610ca4610c0a565b91610d26565b80519081610cb757505050565b8280610cc7938301019101610bf2565b15610ccf5750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b91929015610d885750815115610d3a575090565b3b15610d435790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b825190915015610d9b5750805190602001fd5b60405162461bcd60e51b815260206004820152908190610dbf906024830190610b93565b0390fdfea26469706673582212202b1b9516411eb8de83068e58191f07b143e93f75a5cb7ff9fb5c87c7b34fcad864736f6c63430008140033000000000000000000000000a05ef29e9ac8c75c530c2795fa6a800e188de0a900000000000000000000000011984dc4465481512eb5b777e44061c158cf2259", - "nonce": "0xfd", - "accessList": [] - }, - "additionalContracts": [], - "isFixedGasLimit": false - } - ], - "receipts": [ - { - "transactionHash": "0xc667ac81fc3a42bc73cc50fbcee32a0ecb38922db7c14bb96539aa1672f75867", - "transactionIndex": "0xb", - "blockHash": "0xc637a131b6c5f2e7d08c67ac455b37444abfd43788defc56cb78c391ca9ec610", - "blockNumber": "0x1287d3", - "from": "0xade09131C6f43fe22C2CbABb759636C43cFc181e", - "to": null, - "cumulativeGasUsed": "0x1b2688", - "gasUsed": "0xca22d", - "contractAddress": "0x4895AA5d666c81a04Ebcc7A9aa47f249B1c46aA6", - "logs": [], - "status": "0x1", - "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "type": "0x2", - "effectiveGasPrice": "0xb2d05e07" - } - ], - "libraries": [], - "pending": [], - "returns": {}, - "timestamp": 1702596283, - "chain": 59144, - "multi": false, - "commit": "c427219" -} \ No newline at end of file diff --git a/contracts/integration/LockboxAdapterBlast.sol b/contracts/integration/LockboxAdapterBlast.sol new file mode 100644 index 0000000..eac0f9e --- /dev/null +++ b/contracts/integration/LockboxAdapterBlast.sol @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {IXERC20} from "../shared/IXERC20/IXERC20.sol"; +import {IXERC20Lockbox} from "../shared/IXERC20/IXERC20Lockbox.sol"; + +interface IXERC20Registry { + function getXERC20(address erc20) external view returns (address xerc20); + + function getERC20(address xerc20) external view returns (address erc20); + + function getLockbox(address erc20) external view returns (address xerc20); +} + +interface L1StandardBridge { + function bridgeERC20To( + address _localToken, + address _remoteToken, + address _to, + uint256 _amount, + uint32 _minGasLimit, + bytes calldata _extraData + ) external; +} + +/// @notice This adapter is only used for sending assets from Ethereum mainnet to Blast. +/// @dev Combines Lockbox deposit and Blast bridge's BridgeERC20 call. +contract LockboxAdapterBlast { + address immutable blastStandardBridge; + address immutable registry; + + // ERRORS + error AmountLessThanZero(); + + constructor(address _blastStandardBridge, address _registry) { + blastStandardBridge = _blastStandardBridge; + registry = _registry; + } + + /// @dev Combines Lockbox deposit and Blast bridge's BridgeERC20To call. + /// @param _to The recipient or contract address on destination. + /// @param _erc20 The address of the adopted ERC20 on the origin chain. + /// @param _remoteToken The address of the asset to be received on the destination chain. + /// @param _amount The amount of asset to bridge. + /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with. + /// @param _extraData Extra data to be sent with the transaction. + function bridgeTo( + address _to, + address _erc20, + address _remoteToken, + uint256 _amount, + uint32 _minGasLimit, + bytes calldata _extraData + ) external { + if (_amount <= 0) { + revert AmountLessThanZero(); + } + + address xerc20 = IXERC20Registry(registry).getXERC20(_erc20); + address lockbox = IXERC20Registry(registry).getLockbox(xerc20); + + SafeERC20.safeTransferFrom(IERC20(_erc20), msg.sender, address(this), _amount); + IERC20(_erc20).approve(lockbox, _amount); + IXERC20Lockbox(lockbox).deposit(_amount); + IERC20(xerc20).approve(blastStandardBridge, _amount); + L1StandardBridge(blastStandardBridge).bridgeERC20To(xerc20, _remoteToken, _to, _amount, _minGasLimit, _extraData); + } +} diff --git a/script/DeployLockboxAdapterBlast.s.sol b/script/DeployLockboxAdapterBlast.s.sol new file mode 100644 index 0000000..76a34a9 --- /dev/null +++ b/script/DeployLockboxAdapterBlast.s.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "forge-std/Script.sol"; +import {LockboxAdapterBlast} from "../contracts/integration/LockboxAdapterBlast.sol"; + +contract DeployLockboxAdapterBlast is Script { + function run() public { + vm.startBroadcast(); + + new LockboxAdapterBlast( + address(0x697402166Fbf2F22E970df8a6486Ef171dbfc524), // blastStandardBridge + address(0xBf29A2D67eFb6766E44c163B19C6F4118b164702) // registry + ); + + vm.stopBroadcast(); + } +}