From 4cdbf01f48899b9690de51a4b0ddef9621e4fefc Mon Sep 17 00:00:00 2001 From: Thor Seldon Date: Tue, 2 Apr 2024 10:41:56 +0800 Subject: [PATCH] fix: Use safeApprove for usdt --- .openzeppelin/mainnet.json | 199 +++++++++++++++++++++++++++ .openzeppelin/unknown-11155111.json | 199 +++++++++++++++++++++++++++ contracts/adapters/BaseAdapterV2.sol | 4 +- 3 files changed, 400 insertions(+), 2 deletions(-) diff --git a/.openzeppelin/mainnet.json b/.openzeppelin/mainnet.json index b5c3aae..79b3e4e 100644 --- a/.openzeppelin/mainnet.json +++ b/.openzeppelin/mainnet.json @@ -4409,6 +4409,205 @@ } } } + }, + "0454ef68fa670501ef9c1672f041e720ac8100c3266a7cffe7148f5d81184efd": { + "address": "0xd440Cf55322bd68b60C388E2360318eFA0E30630", + "txHash": "0x445cbe12abe7a713f83fb327c3a7ddcb513cbcaa8db6204dbdb97ed1bc998fc7", + "layout": { + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:87" + }, + { + "label": "_paused", + "offset": 0, + "slot": "101", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:102" + }, + { + "label": "_status", + "offset": 0, + "slot": "151", + "type": "t_uint256", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:74" + }, + { + "label": "_HASHED_NAME", + "offset": 0, + "slot": "201", + "type": "t_bytes32", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol:32" + }, + { + "label": "_HASHED_VERSION", + "offset": 0, + "slot": "202", + "type": "t_bytes32", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol:33" + }, + { + "label": "__gap", + "offset": 0, + "slot": "203", + "type": "t_array(t_uint256)50_storage", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol:120" + }, + { + "label": "__gap", + "offset": 0, + "slot": "253", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC721HolderUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol:40" + }, + { + "label": "downpayment", + "offset": 0, + "slot": "303", + "type": "t_contract(IDownpayment)10552", + "contract": "BaseAdapterV2", + "src": "contracts/adapters/BaseAdapterV2.sol:41" + }, + { + "label": "WETH", + "offset": 0, + "slot": "304", + "type": "t_contract(IWETH)10895", + "contract": "BaseAdapterV2", + "src": "contracts/adapters/BaseAdapterV2.sol:42" + }, + { + "label": "__gap", + "offset": 0, + "slot": "305", + "type": "t_array(t_uint256)43_storage", + "contract": "BaseAdapterV2", + "src": "contracts/adapters/BaseAdapterV2.sol:43" + }, + { + "label": "bendExchange", + "offset": 0, + "slot": "348", + "type": "t_contract(IBendExchange)10355", + "contract": "BendExchangeAdapterV2", + "src": "contracts/adapters/BendExchangeAdapterV2.sol:17" + }, + { + "label": "proxy", + "offset": 0, + "slot": "349", + "type": "t_address", + "contract": "BendExchangeAdapterV2", + "src": "contracts/adapters/BendExchangeAdapterV2.sol:18" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)43_storage": { + "label": "uint256[43]", + "numberOfBytes": "1376" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IBendExchange)10355": { + "label": "contract IBendExchange", + "numberOfBytes": "20" + }, + "t_contract(IDownpayment)10552": { + "label": "contract IDownpayment", + "numberOfBytes": "20" + }, + "t_contract(IWETH)10895": { + "label": "contract IWETH", + "numberOfBytes": "20" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } } } } diff --git a/.openzeppelin/unknown-11155111.json b/.openzeppelin/unknown-11155111.json index 6f93fcb..633d18f 100644 --- a/.openzeppelin/unknown-11155111.json +++ b/.openzeppelin/unknown-11155111.json @@ -768,6 +768,205 @@ "contract": "ERC721HolderUpgradeable", "src": "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol:40" }, + { + "label": "downpayment", + "offset": 0, + "slot": "303", + "type": "t_contract(IDownpayment)3456", + "contract": "BaseAdapterV2", + "src": "contracts/adapters/BaseAdapterV2.sol:41" + }, + { + "label": "WETH", + "offset": 0, + "slot": "304", + "type": "t_contract(IWETH)3601", + "contract": "BaseAdapterV2", + "src": "contracts/adapters/BaseAdapterV2.sol:42" + }, + { + "label": "__gap", + "offset": 0, + "slot": "305", + "type": "t_array(t_uint256)43_storage", + "contract": "BaseAdapterV2", + "src": "contracts/adapters/BaseAdapterV2.sol:43" + }, + { + "label": "bendExchange", + "offset": 0, + "slot": "348", + "type": "t_contract(IBendExchange)3343", + "contract": "BendExchangeAdapterV2", + "src": "contracts/adapters/BendExchangeAdapterV2.sol:17" + }, + { + "label": "proxy", + "offset": 0, + "slot": "349", + "type": "t_address", + "contract": "BendExchangeAdapterV2", + "src": "contracts/adapters/BendExchangeAdapterV2.sol:18" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)43_storage": { + "label": "uint256[43]", + "numberOfBytes": "1376" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IBendExchange)3343": { + "label": "contract IBendExchange", + "numberOfBytes": "20" + }, + "t_contract(IDownpayment)3456": { + "label": "contract IDownpayment", + "numberOfBytes": "20" + }, + "t_contract(IWETH)3601": { + "label": "contract IWETH", + "numberOfBytes": "20" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + }, + "0454ef68fa670501ef9c1672f041e720ac8100c3266a7cffe7148f5d81184efd": { + "address": "0xff56C32de5BcE41D7c2200Dcf74eB3866c836c0F", + "txHash": "0x850cb16fbbc5f09e9027676a9a9c2dc5d027aee01cddf957d4d0a4f011bf2419", + "layout": { + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:87" + }, + { + "label": "_paused", + "offset": 0, + "slot": "101", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:102" + }, + { + "label": "_status", + "offset": 0, + "slot": "151", + "type": "t_uint256", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "152", + "type": "t_array(t_uint256)49_storage", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:74" + }, + { + "label": "_HASHED_NAME", + "offset": 0, + "slot": "201", + "type": "t_bytes32", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol:32" + }, + { + "label": "_HASHED_VERSION", + "offset": 0, + "slot": "202", + "type": "t_bytes32", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol:33" + }, + { + "label": "__gap", + "offset": 0, + "slot": "203", + "type": "t_array(t_uint256)50_storage", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol:120" + }, + { + "label": "__gap", + "offset": 0, + "slot": "253", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC721HolderUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol:40" + }, { "label": "downpayment", "offset": 0, diff --git a/contracts/adapters/BaseAdapterV2.sol b/contracts/adapters/BaseAdapterV2.sol index 9d632fb..36134ba 100644 --- a/contracts/adapters/BaseAdapterV2.sol +++ b/contracts/adapters/BaseAdapterV2.sol @@ -236,8 +236,8 @@ abstract contract BaseAdapterV2 is function _repayFlashLoan(IERC20Upgradeable currency_, uint256 flashLoanDebt_) internal { address aaveLendPool = address(downpayment.getAaveLendPool()); - currency_.approve(aaveLendPool, 0); - currency_.approve(aaveLendPool, flashLoanDebt_); + currency_.safeApprove(aaveLendPool, 0); + currency_.safeApprove(aaveLendPool, flashLoanDebt_); } function _checkSig(