Skip to content

Commit

Permalink
✨ contracts: use oz force-approve
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed Jan 7, 2025
1 parent 1d2e9b4 commit 8b358da
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 69 deletions.
132 changes: 66 additions & 66 deletions contracts/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
ExaAccountFactoryTest:testFuzz_createAccount_EOAOwners(uint256,address[63]) (runs: 256, μ: 3607899, ~: 3475100)
ExaAccountFactoryTest:test_deploy_deploysToSameAddress() (gas: 25534258)
ExaPluginTest:testFork_crossRepay_repays() (gas: 14869137)
ExaPluginTest:testFork_debitCollateral_collects() (gas: 14957889)
ExaPluginTest:testFork_swap_swaps() (gas: 12139134)
ExaPluginTest:test_borrowAtMaturity_reverts_withUnauthorized_whenReceiverNotCollector() (gas: 408716)
ExaPluginTest:test_borrow_reverts_withUnauthorized_whenReceiverNotCollector() (gas: 408272)
ExaPluginTest:test_collectCredit_collects() (gas: 918453)
ExaPluginTest:test_collectCredit_collects_whenHealthFactorHigherThanOne() (gas: 799082)
ExaPluginTest:test_collectCredit_collects_withEnoughSlippage() (gas: 797751)
ExaPluginTest:test_collectCredit_collects_withPrevIssuerSignature() (gas: 994291)
ExaPluginTest:test_collectCredit_passes_whenProposalLeavesEnoughLiquidity() (gas: 1007401)
ExaPluginTest:test_collectCredit_reverts_asNotKeeper() (gas: 362431)
ExaPluginTest:test_collectCredit_reverts_whenDisagreement() (gas: 555816)
ExaPluginTest:test_collectCredit_reverts_whenExpired() (gas: 358489)
ExaPluginTest:test_collectCredit_reverts_whenHealthFactorLowerThanOne() (gas: 997649)
ExaPluginTest:test_collectCredit_reverts_whenPrevSignatureNotValidAnymore() (gas: 461254)
ExaPluginTest:test_collectCredit_reverts_whenProposalCausesInsufficientLiquidity() (gas: 1007555)
ExaPluginTest:test_collectCredit_reverts_whenReplay() (gas: 840584)
ExaPluginTest:test_collectCredit_reverts_whenTimelocked() (gas: 354657)
ExaPluginTest:test_collectCredit_toleratesTimeDrift() (gas: 801096)
ExaPluginTest:test_collectDebit_collects() (gas: 651318)
ExaPluginTest:test_collectDebit_collects_whenProposalLeavesEnoughLiquidity() (gas: 854629)
ExaPluginTest:test_collectDebit_reverts_asNotKeeper() (gas: 362242)
ExaPluginTest:test_collectDebit_reverts_whenExpired() (gas: 358206)
ExaPluginTest:test_collectDebit_reverts_whenProposalCausesInsufficientLiquidity() (gas: 851517)
ExaPluginTest:test_collectDebit_reverts_whenReplay() (gas: 690626)
ExaPluginTest:test_collectDebit_reverts_whenTimelocked() (gas: 354487)
ExaPluginTest:test_collectDebit_toleratesTimeDrift() (gas: 651414)
ExaPluginTest:test_collectInstallments_collects() (gas: 1336195)
ExaPluginTest:test_collectInstallments_revertsWhenNoSlippage() (gas: 1202614)
ExaPluginTest:test_collectInstallments_reverts_asNotKeeper() (gas: 363283)
ExaPluginTest:test_collectInstallments_reverts_whenExpired() (gas: 360539)
ExaPluginTest:test_collectInstallments_reverts_whenReplay() (gas: 1068024)
ExaPluginTest:test_collectInstallments_reverts_whenTimelocked() (gas: 356828)
ExaPluginTest:test_collectInstallments_toleratesTimeDrift() (gas: 1192813)
ExaPluginTest:test_crossRepay_repays() (gas: 1461226)
ExaPluginTest:test_crossRepay_repays_whenKeeper() (gas: 1458005)
ExaPluginTest:test_crossRepay_reverts_whenDisagreement() (gas: 1571655)
ExaPluginTest:test_crossRepay_reverts_whenNotKeeper() (gas: 958262)
ExaPluginTest:test_debitCollateral_collects() (gas: 773890)
ExaPluginTest:test_exitMarket_reverts() (gas: 388890)
ExaPluginTest:test_marketWithdraw_transfersAsset_asOwner() (gas: 818571)
ExaAccountFactoryTest:testFuzz_createAccount_EOAOwners(uint256,address[63]) (runs: 256, μ: 3622088, ~: 3517377)
ExaAccountFactoryTest:test_deploy_deploysToSameAddress() (gas: 25497599)
ExaPluginTest:testFork_crossRepay_repays() (gas: 14850557)
ExaPluginTest:testFork_debitCollateral_collects() (gas: 14939416)
ExaPluginTest:testFork_swap_swaps() (gas: 12120371)
ExaPluginTest:test_borrowAtMaturity_reverts_withUnauthorized_whenReceiverNotCollector() (gas: 408851)
ExaPluginTest:test_borrow_reverts_withUnauthorized_whenReceiverNotCollector() (gas: 408407)
ExaPluginTest:test_collectCredit_collects() (gas: 918642)
ExaPluginTest:test_collectCredit_collects_whenHealthFactorHigherThanOne() (gas: 799244)
ExaPluginTest:test_collectCredit_collects_withEnoughSlippage() (gas: 797913)
ExaPluginTest:test_collectCredit_collects_withPrevIssuerSignature() (gas: 994480)
ExaPluginTest:test_collectCredit_passes_whenProposalLeavesEnoughLiquidity() (gas: 1007617)
ExaPluginTest:test_collectCredit_reverts_asNotKeeper() (gas: 362539)
ExaPluginTest:test_collectCredit_reverts_whenDisagreement() (gas: 555951)
ExaPluginTest:test_collectCredit_reverts_whenExpired() (gas: 358597)
ExaPluginTest:test_collectCredit_reverts_whenHealthFactorLowerThanOne() (gas: 997865)
ExaPluginTest:test_collectCredit_reverts_whenPrevSignatureNotValidAnymore() (gas: 461362)
ExaPluginTest:test_collectCredit_reverts_whenProposalCausesInsufficientLiquidity() (gas: 1007771)
ExaPluginTest:test_collectCredit_reverts_whenReplay() (gas: 840746)
ExaPluginTest:test_collectCredit_reverts_whenTimelocked() (gas: 354765)
ExaPluginTest:test_collectCredit_toleratesTimeDrift() (gas: 801258)
ExaPluginTest:test_collectDebit_collects() (gas: 651480)
ExaPluginTest:test_collectDebit_collects_whenProposalLeavesEnoughLiquidity() (gas: 854845)
ExaPluginTest:test_collectDebit_reverts_asNotKeeper() (gas: 362350)
ExaPluginTest:test_collectDebit_reverts_whenExpired() (gas: 358314)
ExaPluginTest:test_collectDebit_reverts_whenProposalCausesInsufficientLiquidity() (gas: 851733)
ExaPluginTest:test_collectDebit_reverts_whenReplay() (gas: 690788)
ExaPluginTest:test_collectDebit_reverts_whenTimelocked() (gas: 354595)
ExaPluginTest:test_collectDebit_toleratesTimeDrift() (gas: 651576)
ExaPluginTest:test_collectInstallments_collects() (gas: 1336411)
ExaPluginTest:test_collectInstallments_revertsWhenNoSlippage() (gas: 1202776)
ExaPluginTest:test_collectInstallments_reverts_asNotKeeper() (gas: 363391)
ExaPluginTest:test_collectInstallments_reverts_whenExpired() (gas: 360647)
ExaPluginTest:test_collectInstallments_reverts_whenReplay() (gas: 1068213)
ExaPluginTest:test_collectInstallments_reverts_whenTimelocked() (gas: 356936)
ExaPluginTest:test_collectInstallments_toleratesTimeDrift() (gas: 1193002)
ExaPluginTest:test_crossRepay_repays() (gas: 1461705)
ExaPluginTest:test_crossRepay_repays_whenKeeper() (gas: 1458484)
ExaPluginTest:test_crossRepay_reverts_whenDisagreement() (gas: 1571938)
ExaPluginTest:test_crossRepay_reverts_whenNotKeeper() (gas: 958451)
ExaPluginTest:test_debitCollateral_collects() (gas: 774260)
ExaPluginTest:test_exitMarket_reverts() (gas: 388998)
ExaPluginTest:test_marketWithdraw_transfersAsset_asOwner() (gas: 818760)
ExaPluginTest:test_onUninstall_uninstalls() (gas: 284188)
ExaPluginTest:test_poke() (gas: 315735)
ExaPluginTest:test_pokeETH_deposits() (gas: 377705)
ExaPluginTest:test_propose_emitsProposed() (gas: 218574)
ExaPluginTest:test_poke() (gas: 315843)
ExaPluginTest:test_pokeETH_deposits() (gas: 377813)
ExaPluginTest:test_propose_emitsProposed() (gas: 218628)
ExaPluginTest:test_refund_refunds() (gas: 361573)
ExaPluginTest:test_repay_partiallyRepays() (gas: 1243834)
ExaPluginTest:test_repay_partiallyRepays_whenKeeper() (gas: 1186021)
ExaPluginTest:test_repay_repays() (gas: 1162182)
ExaPluginTest:test_repay_repays_whenKeeper() (gas: 1104863)
ExaPluginTest:test_rollDebt_rolls() (gas: 1231245)
ExaPluginTest:test_rollDebt_rolls_asKeeper() (gas: 1230937)
ExaPluginTest:test_repay_partiallyRepays() (gas: 1244077)
ExaPluginTest:test_repay_partiallyRepays_whenKeeper() (gas: 1186237)
ExaPluginTest:test_repay_repays() (gas: 1162425)
ExaPluginTest:test_repay_repays_whenKeeper() (gas: 1105079)
ExaPluginTest:test_rollDebt_rolls() (gas: 1231461)
ExaPluginTest:test_rollDebt_rolls_asKeeper() (gas: 1231153)
ExaPluginTest:test_setCollector_emitsCollectorSet() (gas: 40494)
ExaPluginTest:test_setCollector_reverts_whenAddressZero() (gas: 32289)
ExaPluginTest:test_setCollector_reverts_whenNotAdmin() (gas: 33750)
ExaPluginTest:test_setCollector_sets_whenAdmin() (gas: 39884)
ExaPluginTest:test_swap_reverts_withDisagreement() (gas: 288696)
ExaPluginTest:test_swap_swaps() (gas: 268369)
ExaPluginTest:test_withdrawWETH_transfersETH() (gas: 849037)
ExaPluginTest:test_withdraw_reverts_whenNoProposal() (gas: 414784)
ExaPluginTest:test_withdraw_reverts_whenNoProposalKeeper() (gas: 357689)
ExaPluginTest:test_withdraw_reverts_whenNotKeeper() (gas: 354771)
ExaPluginTest:test_withdraw_reverts_whenReceiverIsContractAndMarketNotWETH() (gas: 620994)
ExaPluginTest:test_withdraw_reverts_whenTimelocked() (gas: 307253)
ExaPluginTest:test_withdraw_reverts_whenTimelockedKeeper() (gas: 309011)
ExaPluginTest:test_withdraw_reverts_whenWrongAmount() (gas: 308673)
ExaPluginTest:test_withdraw_reverts_whenWrongMarket() (gas: 308843)
ExaPluginTest:test_withdraw_reverts_whenWrongReceiver() (gas: 308277)
ExaPluginTest:test_withdraw_transfersAsset_asKeeper() (gas: 819874)
ExaPluginTest:test_withdraw_withdrawsProposed() (gas: 810620)
ExaPluginTest:test_swap_reverts_withDisagreement() (gas: 288750)
ExaPluginTest:test_swap_swaps() (gas: 268450)
ExaPluginTest:test_withdrawWETH_transfersETH() (gas: 849226)
ExaPluginTest:test_withdraw_reverts_whenNoProposal() (gas: 414919)
ExaPluginTest:test_withdraw_reverts_whenNoProposalKeeper() (gas: 357797)
ExaPluginTest:test_withdraw_reverts_whenNotKeeper() (gas: 354879)
ExaPluginTest:test_withdraw_reverts_whenReceiverIsContractAndMarketNotWETH() (gas: 621183)
ExaPluginTest:test_withdraw_reverts_whenTimelocked() (gas: 307334)
ExaPluginTest:test_withdraw_reverts_whenTimelockedKeeper() (gas: 309092)
ExaPluginTest:test_withdraw_reverts_whenWrongAmount() (gas: 308754)
ExaPluginTest:test_withdraw_reverts_whenWrongMarket() (gas: 308924)
ExaPluginTest:test_withdraw_reverts_whenWrongReceiver() (gas: 308358)
ExaPluginTest:test_withdraw_transfersAsset_asKeeper() (gas: 820063)
ExaPluginTest:test_withdraw_withdrawsProposed() (gas: 810809)
InstallmentsPreviewerTest:test_preview_returns() (gas: 135598)
IssuerCheckerTest:test_setIssuer_emits_IssuerSet() (gas: 70861)
IssuerCheckerTest:test_setIssuer_reverts_whenNotAdmin() (gas: 37272)
Expand Down
6 changes: 3 additions & 3 deletions contracts/src/ExaPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ contract ExaPlugin is AccessControl, BasePlugin, IExaAccount {

function _depositUnspent(IMarket market, uint256 unspent, address receiver) internal {
if (unspent != 0) {
IERC20(market.asset()).approve(address(market), unspent);
IERC20(market.asset()).forceApprove(address(market), unspent);
market.deposit(unspent, receiver);
}
}
Expand Down Expand Up @@ -687,13 +687,13 @@ contract ExaPlugin is AccessControl, BasePlugin, IExaAccount {
uint256 balanceIn = assetIn.balanceOf(address(this));
uint256 balanceOut = assetOut.balanceOf(address(this));

assetIn.approve(SWAPPER, maxAmountIn);
assetIn.forceApprove(SWAPPER, maxAmountIn);
SWAPPER.functionCall(route);

amountOut = assetOut.balanceOf(address(this)) - balanceOut;
if (minAmountOut > amountOut) revert Disagreement();

assetIn.approve(SWAPPER, 0);
assetIn.forceApprove(SWAPPER, 0);
amountIn = balanceIn - assetIn.balanceOf(address(this));
}

Expand Down

0 comments on commit 8b358da

Please sign in to comment.