Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/beige-sails-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
56 changes: 32 additions & 24 deletions contracts/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ExaAccountFactoryTest:testFuzz_createAccount_EOAOwners(uint256,address[63]) (runs: 256, μ: 5856150, ~: 5360703)
ExaAccountFactoryTest:testFuzz_createAccount_EOAOwners(uint256,address[63]) (runs: 256, μ: 5887874, ~: 5393451)
ExaAccountFactoryTest:test_deploy_deploysToSameAddress() (gas: 15501257)
ExaPluginTest:testFork_claimAndVestEscrowedEXA_claimsAndVests() (gas: 38649064)
ExaPluginTest:testFork_collectCollateral_collects() (gas: 32148122)
ExaPluginTest:testFork_crossRepay_repays() (gas: 33970276)
ExaPluginTest:testFork_repay_whenFlashLoanerHasFees() (gas: 25585110)
ExaPluginTest:testFork_stakeEXA_stakes() (gas: 32727092)
ExaPluginTest:testFork_swap_swaps() (gas: 28088327)
ExaPluginTest:testFork_claimAndVestEscrowedEXA_claimsAndVests() (gas: 38666217)
ExaPluginTest:testFork_collectCollateral_collects() (gas: 32164167)
ExaPluginTest:testFork_crossRepay_repays() (gas: 33986321)
ExaPluginTest:testFork_repay_whenFlashLoanerHasFees() (gas: 25591707)
ExaPluginTest:testFork_stakeEXA_stakes() (gas: 32743609)
ExaPluginTest:testFork_swap_swaps() (gas: 28102911)
ExaPluginTest:test_allowPlugin_emitsPluginAllowed() (gas: 58464)
ExaPluginTest:test_allowPlugin_reverts_whenAddressZero() (gas: 32411)
ExaPluginTest:test_allowPlugin_reverts_whenNotAdmin() (gas: 40964)
Expand All @@ -32,12 +32,12 @@ ExaPluginTest:test_collectCredit_collects_whenHealthFactorHigherThanOne() (gas:
ExaPluginTest:test_collectCredit_collects_whenProposalCausesInsufficientLiquidity() (gas: 1064982)
ExaPluginTest:test_collectCredit_collects_whenProposalLeavesHealthFactorLowerThanOne() (gas: 1055379)
ExaPluginTest:test_collectCredit_collects_withEnoughSlippage() (gas: 782246)
ExaPluginTest:test_collectCredit_collects_withPrevIssuerSignature() (gas: 986741)
ExaPluginTest:test_collectCredit_collects_withPrevIssuerSignature() (gas: 987065)
ExaPluginTest:test_collectCredit_passes_whenProposalLeavesEnoughLiquidity() (gas: 1082579)
ExaPluginTest:test_collectCredit_reverts_asNotKeeper() (gas: 342148)
ExaPluginTest:test_collectCredit_reverts_whenDisagreement() (gas: 538817)
ExaPluginTest:test_collectCredit_reverts_whenExpired() (gas: 352767)
ExaPluginTest:test_collectCredit_reverts_whenPrevSignatureNotValidAnymore() (gas: 483654)
ExaPluginTest:test_collectCredit_reverts_whenPrevSignatureNotValidAnymore() (gas: 483978)
ExaPluginTest:test_collectCredit_reverts_whenReplay() (gas: 825827)
ExaPluginTest:test_collectCredit_reverts_whenTimelocked() (gas: 334568)
ExaPluginTest:test_collectCredit_toleratesTimeDrift() (gas: 798846)
Expand All @@ -58,7 +58,7 @@ ExaPluginTest:test_collectInstallments_reverts_whenTimelocked() (gas: 336703)
ExaPluginTest:test_collectInstallments_toleratesTimeDrift() (gas: 1161587)
ExaPluginTest:test_collect_collects_whenProposalsLeaveNoLiquidity() (gas: 1783636)
ExaPluginTest:test_collect_collects_whenTooMuchProposedDebt() (gas: 1923835)
ExaPluginTest:test_crossRepay_avoidsFrozenDeposit() (gas: 980825)
ExaPluginTest:test_crossRepay_avoidsFrozenDeposit() (gas: 981146)
ExaPluginTest:test_crossRepay_avoidsZeroSharesDeposit() (gas: 1392815)
ExaPluginTest:test_crossRepay_consumesProposal() (gas: 2204416)
ExaPluginTest:test_crossRepay_repays() (gas: 2268206)
Expand Down Expand Up @@ -202,6 +202,14 @@ ExaPreviewerTest:test_collect_reverts_whenProposalsLeaveNoLiquidity() (gas: 1437
ExaPreviewerTest:test_markets_returnsMarkets() (gas: 150447)
ExaPreviewerTest:test_pendingProposals_returnsPendingProposals() (gas: 1984093)
ExaPreviewerTest:test_utilizations_returns() (gas: 134922)
HypEXATest:test_handle_reverts_withoutBridgeRole() (gas: 136161)
HypEXATest:test_proposeBridgeRole_reverts_whenAlreadyGranted() (gas: 71218)
HypEXATest:test_proposeBridgeRole_reverts_whenRouterNotDeployed() (gas: 22344704)
HypEXATest:test_proposeBridgeRole_schedulesGrantOnTimelock() (gas: 1183670)
HypEXATest:test_roundTrip_opToBaseToOp() (gas: 1055313)
HypEXATest:test_roundTrip_opToPolygonToBaseToOp() (gas: 1562388)
HypEXATest:test_setupRouter_reverts_whenRouterNotDeployed() (gas: 22341787)
HypEXATest:test_transferRemote_reverts_withoutBridgeRole() (gas: 241639)
IssuerCheckerTest:test_setIssuer_emits_IssuerSet() (gas: 82935)
IssuerCheckerTest:test_setIssuer_reverts_whenNotAdmin() (gas: 43708)
IssuerCheckerTest:test_setIssuer_reverts_whenZeroAddress() (gas: 35130)
Expand All @@ -212,20 +220,20 @@ IssuerCheckerTest:test_setPrevIssuerWindow_emits_PrevIssuerWindowSet() (gas: 526
IssuerCheckerTest:test_setPrevIssuerWindow_reverts_whenNotAdmin() (gas: 45548)
MockSwapperTest:test_swapExactAmountIn_swaps() (gas: 269414)
MockSwapperTest:test_swapExactAmountOut_swaps() (gas: 269410)
RedeployerTest:test_deployEXA_deploysAtSameAddress_onBase() (gas: 54792391)
RedeployerTest:test_deployExaFactoryWithProxy_reverts_whenNotPrepared() (gas: 15868804)
RedeployerTest:test_deployExaFactoryWithProxy_succeeds_whenAlreadyUpgraded() (gas: 31111328)
RedeployerTest:test_deployExaFactory_deploysAtSameAddress_onEthereum() (gas: 260295770)
RedeployerTest:test_deployExaFactory_deploysAtSameAddress_onPolygon() (gas: 355860463)
RedeployerTest:test_deployExaFactory_deploysViaCreate3AtSameAddress_onPolygon() (gas: 34302845)
RedeployerTest:test_deployExaFactory_reverts_whenNotPrepared() (gas: 15892721)
RedeployerTest:test_deployExaFactory_succeeds_whenVersionAlreadyDeployed() (gas: 31658476)
RedeployerTest:test_prepare_reusesExistingDeps_onBase() (gas: 19385733)
RedeployerTest:test_prepare_reverts_whenAdminIsDeployer() (gas: 15897009)
RedeployerTest:test_prepare_succeeds_whenCalledTwice() (gas: 30601997)
RedeployerTest:test_recoversNativeETHOnPolygon() (gas: 34474337)
RedeployerTest:test_serialProxies_reverts_whenAttackerUpgradesProxy() (gas: 37486962)
RedeployerTest:test_serialProxies_reverts_whenTargetNonceTooLow() (gas: 43616725)
RedeployerTest:test_deployEXA_deploysAtSameAddress_onBase() (gas: 58860868)
RedeployerTest:test_deployExaFactoryWithProxy_reverts_whenNotPrepared() (gas: 19415727)
RedeployerTest:test_deployExaFactoryWithProxy_succeeds_whenAlreadyUpgraded() (gas: 34663902)
RedeployerTest:test_deployExaFactory_deploysAtSameAddress_onEthereum() (gas: 263843561)
RedeployerTest:test_deployExaFactory_deploysAtSameAddress_onPolygon() (gas: 359413573)
RedeployerTest:test_deployExaFactory_deploysViaCreate3AtSameAddress_onPolygon() (gas: 37855415)
RedeployerTest:test_deployExaFactory_reverts_whenNotPrepared() (gas: 19440012)
RedeployerTest:test_deployExaFactory_succeeds_whenVersionAlreadyDeployed() (gas: 35211436)
RedeployerTest:test_prepare_reusesExistingDeps_onBase() (gas: 22940779)
RedeployerTest:test_prepare_reverts_whenAdminIsDeployer() (gas: 19444569)
RedeployerTest:test_prepare_succeeds_whenCalledTwice() (gas: 34154925)
RedeployerTest:test_recoversNativeETHOnPolygon() (gas: 38027039)
RedeployerTest:test_serialProxies_reverts_whenAttackerUpgradesProxy() (gas: 42210375)
RedeployerTest:test_serialProxies_reverts_whenTargetNonceTooLow() (gas: 50708483)
RefunderTest:test_refund_refunds() (gas: 263363)
RefunderTest:test_refund_reverts_whenExpired() (gas: 88359)
RefunderTest:test_refund_reverts_whenNotKeeper() (gas: 68861)
Expand Down
9 changes: 9 additions & 0 deletions contracts/deploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"11155420": "0xDb90CDB64CfF03f254e4015C4F705C3F3C834400",
"default": "0xe61Bdef3FFF4C3CF7A07996DCB8802b5C85B665a"
},
"exactly": {
"10": "0xC0d6Bc5d052d1e74523AD79dD5A954276c9286D3",
"8453": "0x7A65824d74B0C20730B6eE4929ABcc41Cbe843Aa"
},
Comment thread
itofarina marked this conversation as resolved.
Comment thread
itofarina marked this conversation as resolved.
"keeper": {
"31337": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"84532": "0xEbFa3f3306B2F62400D644714A20F6eF32c63C6B",
Expand All @@ -34,6 +38,11 @@
"11155420": "0xe2D63e18Fb136ef84557f79052BFE8EFa90F69Bd",
"default": "0xe61Bdef3FFF4C3CF7A07996DCB8802b5C85B665a"
},
"mailbox": {
"10": "0xd4C1905BB1D26BC93DAC913e13CaCC278CdCC80D",
"137": "0x5d934f4e2f797775e53561bB72aca21ba36B96BB",
"8453": "0xeA87ae93Fa0019a82A727bfd3eBd1cFCa8f64f1D"
Comment thread
itofarina marked this conversation as resolved.
Comment thread
itofarina marked this conversation as resolved.
},
"swapper": {
"84532": "0xE4F8C9904a79EBd88Ff73ed3F86a3CFd1b489eDf",
"11155420": "0x3E2D4b69C52932CB5b2a9Ee744CB585bb201c771",
Expand Down
3 changes: 2 additions & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
"webauthn-sol": "base/webauthn-sol#v1.0.0"
},
"devDependencies": {
"@exactly/protocol": "^0.2.22",
"@exactly/protocol": "exactly/protocol#5833408",
"@openzeppelin/contracts-upgradeable-v4": "npm:@openzeppelin/contracts-upgradeable@^4.9.6",
"@openzeppelin/contracts-upgradeable": "^5.6.1",
"@openzeppelin/contracts-v4": "npm:@openzeppelin/contracts@^4.9.6",
"@hyperlane-xyz/core": "^11.0.0",
"account-abstraction": "eth-infinitism/account-abstraction#v0.6.0",
"forge-std": "foundry-rs/forge-std#v1.15.0",
"fresh-crypto-lib": "rdubois-crypto/FreshCryptoLib#fd2a0e6e64609ade0b0c165e4d66de8106a70db6",
Expand Down
2 changes: 2 additions & 0 deletions contracts/remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ webauthn-owner-plugin/=node_modules/webauthn-owner-plugin/src
webauthn-sol/=node_modules/webauthn-sol/src

@exactly/protocol/=node_modules/@exactly/protocol/contracts/
node_modules/@exactly/protocol/:@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/
@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable-v4/
@openzeppelin/contracts-upgradeable-v4/=node_modules/@openzeppelin/contracts-upgradeable-v4/
@openzeppelin/contracts-v4/=node_modules/@openzeppelin/contracts-v4/
@openzeppelin/contracts/=node_modules/@openzeppelin/contracts-v4/
@hyperlane-xyz/=node_modules/@hyperlane-xyz/
account-abstraction/=node_modules/account-abstraction/contracts/
forge-std/=node_modules/forge-std/src/
solmate/=node_modules/solmate/
Expand Down
57 changes: 57 additions & 0 deletions contracts/script/Redeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity ^0.8.0;
import {
TransparentUpgradeableProxy
} from "@openzeppelin/contracts-v4/proxy/transparent/TransparentUpgradeableProxy.sol";
import { IAccessControl } from "openzeppelin-contracts/contracts/access/IAccessControl.sol";
import { TimelockController } from "openzeppelin-contracts/contracts/governance/TimelockController.sol";
import { ERC1967Utils } from "openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol";
import { ProxyAdmin } from "openzeppelin-contracts/contracts/proxy/transparent/ProxyAdmin.sol";
import {
Expand All @@ -16,6 +18,9 @@ import { ACCOUNT_IMPL, ENTRYPOINT } from "webauthn-owner-plugin/../script/Factor

import { EXA } from "@exactly/protocol/periphery/EXA.sol";

import { HypERC20Collateral } from "@hyperlane-xyz/core/contracts/token/HypERC20Collateral.sol";
import { HypXERC20 } from "@hyperlane-xyz/core/contracts/token/extensions/HypXERC20.sol";

import { ExaAccountFactory } from "../src/ExaAccountFactory.sol";
import {
IAuditor,
Expand Down Expand Up @@ -191,9 +196,59 @@ contract Redeployer is BaseScript {
vm.startBroadcast(acct("admin"));
exa = EXA(CREATE3_FACTORY.deploy(keccak256(abi.encode("EXA")), vm.getCode("EXA.sol:EXA")));
proxyAdmin.upgradeAndCall(ITransparentUpgradeableProxy(proxy), address(exa), abi.encodeCall(EXA.initialize, ()));
proxyAdmin.upgradeAndCall(
ITransparentUpgradeableProxy(proxy), address(exa), abi.encodeCall(EXA.initialize2, (acct("exactly")))
);
Comment thread
itofarina marked this conversation as resolved.
vm.stopBroadcast();
}
Comment thread
itofarina marked this conversation as resolved.

/// @notice Deploys the latest EXA implementation via CREATE3.
function deployEXAImpl() external {
vm.broadcast(acct("admin"));
exa = EXA(CREATE3_FACTORY.deploy(keccak256(abi.encode("EXA")), vm.getCode("EXA.sol:EXA")));
}

function deployRouter(address token) external returns (HypXERC20 router) {
address admin = acct("admin");
router = HypXERC20(CREATE3_FACTORY.getDeployed(admin, keccak256(abi.encode("HypEXA"))));
if (address(router).code.length != 0) return router;
vm.startBroadcast(admin);
router = HypXERC20(
CREATE3_FACTORY.deploy(
keccak256(abi.encode("HypEXA")),
abi.encodePacked(
Comment thread
itofarina marked this conversation as resolved.
type(TransparentUpgradeableProxy).creationCode,
abi.encode(
address(new HypXERC20(token, 1, 1, acct("mailbox"))),
protocol("ProxyAdmin"),
Comment thread
itofarina marked this conversation as resolved.
Comment thread
itofarina marked this conversation as resolved.
Comment thread
itofarina marked this conversation as resolved.
abi.encodeCall(HypERC20Collateral.initialize, (address(0), address(0), admin))
Comment thread
itofarina marked this conversation as resolved.
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
)
)
);
router.transferOwnership(acct("exactly"));
vm.stopBroadcast();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

function setupRouter(uint32 remoteDomain) external {
address router = CREATE3_FACTORY.getDeployed(acct("admin"), keccak256(abi.encode("HypEXA")));
if (router.code.length == 0) revert RouterNotDeployed();
vm.broadcast(acct("exactly"));
Comment thread
itofarina marked this conversation as resolved.
HypXERC20(router).enrollRemoteRouter(remoteDomain, bytes32(uint256(uint160(router))));
Comment thread
itofarina marked this conversation as resolved.
}

function proposeBridgeRole(address token, bytes32 salt) external {
address router = CREATE3_FACTORY.getDeployed(acct("admin"), keccak256(abi.encode("HypEXA")));
if (router.code.length == 0) revert RouterNotDeployed();
if (IAccessControl(token).hasRole(keccak256("BRIDGE_ROLE"), router)) revert AlreadyGranted();
TimelockController timelock = TimelockController(payable(protocol("TimelockController")));
uint256 delay = timelock.getMinDelay();
vm.broadcast(acct("deployer"));
timelock.schedule(
token, 0, abi.encodeCall(IAccessControl.grantRole, (keccak256("BRIDGE_ROLE"), router)), bytes32(0), salt, delay
);
}
Comment thread
itofarina marked this conversation as resolved.

/// @notice Upgrades a proxy to the cached ExaAccountFactory implementation.
function deployExaFactory(address proxy) external {
if (address(factory).code.length == 0) revert NotPrepared();
Expand Down Expand Up @@ -281,10 +336,12 @@ contract Redeployer is BaseScript {
}

error AdminIsDeployer();
error AlreadyGranted();
error DummyNotDeployed();
error NonceNotFound();
error NotPrepared();
error ProxyAdminNotDeployed();
error RouterNotDeployed();
error TargetNonceTooLow();

contract Dummy { } // solhint-disable-line no-empty-blocks
Expand Down
Loading
Loading