From 875d84c29d7b8301e5713375ec17e72e5545bb88 Mon Sep 17 00:00:00 2001 From: Michael De Luca Date: Fri, 24 Dec 2021 09:24:54 -0500 Subject: [PATCH 1/2] chore: natspec, whitespace, checksums --- .circleci/config.yml | 38 +++++++++---------- .gitignore | 3 ++ contracts/DebtLocker.sol | 10 ++--- contracts/DebtLockerFactory.sol | 3 ++ contracts/DebtLockerInitializer.sol | 8 ++-- contracts/interfaces/IDebtLocker.sol | 7 ++-- contracts/interfaces/IDebtLockerFactory.sol | 5 ++- .../interfaces/IDebtLockerInitializer.sol | 11 ++++++ contracts/test/DebtLocker.t.sol | 2 +- contracts/test/accounts/PoolDelegate.sol | 2 +- contracts/test/mocks/Mocks.sol | 6 +-- modules/erc20 | 2 +- modules/erc20-helper | 2 +- modules/liquidations | 2 +- modules/loan | 2 +- modules/maple-proxy-factory | 2 +- package.yaml | 9 +++-- 17 files changed, 69 insertions(+), 45 deletions(-) create mode 100644 contracts/interfaces/IDebtLockerInitializer.sol diff --git a/.circleci/config.yml b/.circleci/config.yml index 8e4290c..69a9f44 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,24 +1,24 @@ version: 2.1 jobs: - dapp_test: - docker: - - image: bakii0499/dapptools:0.48.0-solc-0.8.7 - steps: - - run: - name: Checkout debt-locker - command: | - GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:maple-labs/debt-locker.git . - git checkout $CIRCLE_BRANCH - - run: - name: Build and test contracts - command: | - GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git submodule update --init --recursive - ./test.sh -c ./config/ci.json + dapp_test: + docker: + - image: bakii0499/dapptools:0.48.0-solc-0.8.7 + steps: + - run: + name: Checkout debt-locker + command: | + GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone git@github.com:maple-labs/debt-locker.git . + git checkout $CIRCLE_BRANCH + - run: + name: Build and test contracts + command: | + GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git submodule update --init --recursive + ./test.sh -c ./config/ci.json workflows: - version: 2 - test_all: - jobs: - - dapp_test: - context: seth + version: 2 + test_all: + jobs: + - dapp_test: + context: seth diff --git a/.gitignore b/.gitignore index 47b5a99..f1a8f62 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ hevm* .vscode/* /package +artifacts/* +docs/* +metadata.json diff --git a/contracts/DebtLocker.sol b/contracts/DebtLocker.sol index 729c073..7b13b2b 100644 --- a/contracts/DebtLocker.sol +++ b/contracts/DebtLocker.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: AGPL-3.0-or-later pragma solidity 0.8.7; -import { ERC20Helper } from "../modules/erc20-helper/src/ERC20Helper.sol"; -import { Liquidator } from "../modules/liquidations/contracts/Liquidator.sol"; -import { IMapleProxyFactory } from "../modules/maple-proxy-factory/contracts/interfaces/IMapleProxyFactory.sol"; -import { MapleProxied } from "../modules/maple-proxy-factory/contracts/MapleProxied.sol"; +import { ERC20Helper } from "../modules/erc20-helper/src/ERC20Helper.sol"; +import { Liquidator } from "../modules/liquidations/contracts/Liquidator.sol"; +import { IMapleProxyFactory } from "../modules/maple-proxy-factory/contracts/interfaces/IMapleProxyFactory.sol"; +import { MapleProxiedInternals } from "../modules/maple-proxy-factory/contracts/MapleProxiedInternals.sol"; import { IDebtLocker } from "./interfaces/IDebtLocker.sol"; import { IERC20Like, IMapleGlobalsLike, IMapleLoanLike, IPoolLike, IPoolFactoryLike } from "./interfaces/Interfaces.sol"; @@ -12,7 +12,7 @@ import { IERC20Like, IMapleGlobalsLike, IMapleLoanLike, IPoolLike, IPoolFactoryL import { DebtLockerStorage } from "./DebtLockerStorage.sol"; /// @title DebtLocker interacts with Loans on behalf of PoolV1. -contract DebtLocker is IDebtLocker, DebtLockerStorage, MapleProxied { +contract DebtLocker is IDebtLocker, DebtLockerStorage, MapleProxiedInternals { /*****************/ /*** Modifiers ***/ diff --git a/contracts/DebtLockerFactory.sol b/contracts/DebtLockerFactory.sol index fe546fc..9deff26 100644 --- a/contracts/DebtLockerFactory.sol +++ b/contracts/DebtLockerFactory.sol @@ -10,6 +10,7 @@ contract DebtLockerFactory is IDebtLockerFactory, MapleProxyFactory { uint8 public constant override factoryType = uint8(1); + /// @param mapleGlobals_ The address of a Maple Globals contract. constructor(address mapleGlobals_) MapleProxyFactory(mapleGlobals_) {} function newLocker(address loan_) external override returns (address debtLocker_) { @@ -22,10 +23,12 @@ contract DebtLockerFactory is IDebtLockerFactory, MapleProxyFactory { emit InstanceDeployed(defaultVersion, debtLocker_, arguments); } + /// @dev This function is disabled in favour of a PoolV1-compatible `newLocker` function. function createInstance(bytes calldata arguments_, bytes32 salt_) public override(IMapleProxyFactory, MapleProxyFactory) virtual returns (address instance_) {} + /// @dev This function is disabled in since the PoolV1-compatible `newLocker` function is used instead of `createInstance`. function getInstanceAddress(bytes calldata arguments_, bytes32 salt_) public view override(IMapleProxyFactory, MapleProxyFactory) virtual returns (address instanceAddress_) {} diff --git a/contracts/DebtLockerInitializer.sol b/contracts/DebtLockerInitializer.sol index 0a53b72..e7fa86e 100644 --- a/contracts/DebtLockerInitializer.sol +++ b/contracts/DebtLockerInitializer.sol @@ -3,16 +3,18 @@ pragma solidity 0.8.7; import { IMapleGlobalsLike, IMapleLoanLike, IPoolFactoryLike, IPoolLike } from "./interfaces/Interfaces.sol"; +import { IDebtLockerInitializer } from "./interfaces/IDebtLockerInitializer.sol"; + import { DebtLockerStorage } from "./DebtLockerStorage.sol"; /// @title DebtLockerInitializer is intended to initialize the storage of a DebtLocker proxy. -contract DebtLockerInitializer is DebtLockerStorage { +contract DebtLockerInitializer is IDebtLockerInitializer, DebtLockerStorage { - function encodeArguments(address loan_, address pool_) external pure returns (bytes memory encodedArguments_) { + function encodeArguments(address loan_, address pool_) external pure override returns (bytes memory encodedArguments_) { return abi.encode(loan_, pool_); } - function decodeArguments(bytes calldata encodedArguments_) public pure returns (address loan_, address pool_) { + function decodeArguments(bytes calldata encodedArguments_) public pure override returns (address loan_, address pool_) { ( loan_, pool_ ) = abi.decode(encodedArguments_, (address, address)); } diff --git a/contracts/interfaces/IDebtLocker.sol b/contracts/interfaces/IDebtLocker.sol index 29f9c8e..6e26d1c 100644 --- a/contracts/interfaces/IDebtLocker.sol +++ b/contracts/interfaces/IDebtLocker.sol @@ -53,7 +53,7 @@ interface IDebtLocker is IMapleProxied { /** * @dev Claims funds to send to Pool. Handles funds from payments and liquidations. - * @dev Only the Pool can call this function. + * Only the Pool can call this function. * @return details_ * [0] => Total Claimed. * [1] => Interest Claimed. @@ -66,7 +66,7 @@ interface IDebtLocker is IMapleProxied { function claim() external returns (uint256[7] memory details_); /** - * @dev Allows the poolDelegate to pull some funds from liquidator contract + * @dev Allows the poolDelegate to pull some funds from liquidator contract. * @param liquidator_ The liquidator to which pull funds from. * @param token_ The token address of the funds. * @param destination_ The destination address of captured funds. @@ -117,7 +117,8 @@ interface IDebtLocker is IMapleProxied { /** * @dev Called by the PoolDelegate in case of a DoS, where a user transfers small amounts of collateralAsset into the Liquidator - * @dev to make `_isLiquidationActive` remain true. + * to make `_isLiquidationActive` remain true. + * CALLING THIS MAY RESULT IN RECOGNIZED LOSSES IN POOL ACCOUNTING. CONSULT MAPLE TEAM FOR GUIDANCE. */ function stopLiquidation() external; diff --git a/contracts/interfaces/IDebtLockerFactory.sol b/contracts/interfaces/IDebtLockerFactory.sol index 50b3cea..9d6ce74 100644 --- a/contracts/interfaces/IDebtLockerFactory.sol +++ b/contracts/interfaces/IDebtLockerFactory.sol @@ -12,8 +12,9 @@ interface IDebtLockerFactory is IMapleProxyFactory { function factoryType() external view returns (uint8 factoryType_); /** - * @dev Deploys a new DebtLocker proxy instance. - * @param loan_ Loan contract that corresponds to DebtLocker. + * @dev Deploys a new DebtLocker proxy instance. + * @param loan_ Loan contract that corresponds to DebtLocker. + * @return debtLocker_ The address of the deployed DebtLocker proxy. */ function newLocker(address loan_) external returns (address debtLocker_); diff --git a/contracts/interfaces/IDebtLockerInitializer.sol b/contracts/interfaces/IDebtLockerInitializer.sol new file mode 100644 index 0000000..1fa7c1d --- /dev/null +++ b/contracts/interfaces/IDebtLockerInitializer.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +pragma solidity 0.8.7; + +/// @title DebtLockerInitializer is intended to initialize the storage of a DebtLocker proxy. +interface IDebtLockerInitializer { + + function encodeArguments(address loan_, address pool_) external pure returns (bytes memory encodedArguments_); + + function decodeArguments(bytes calldata encodedArguments_) external pure returns (address loan_, address pool_); + +} diff --git a/contracts/test/DebtLocker.t.sol b/contracts/test/DebtLocker.t.sol index 1798d98..b38ce90 100644 --- a/contracts/test/DebtLocker.t.sol +++ b/contracts/test/DebtLocker.t.sol @@ -546,7 +546,7 @@ contract DebtLockerTests is TestUtils { } function test_liquidation_pullFunds(uint256 principalRequested_, uint256 collateralRequired_) external { - + /**********************************/ /*** Create Loan and DebtLocker ***/ /**********************************/ diff --git a/contracts/test/accounts/PoolDelegate.sol b/contracts/test/accounts/PoolDelegate.sol index 4a6d648..925f41f 100644 --- a/contracts/test/accounts/PoolDelegate.sol +++ b/contracts/test/accounts/PoolDelegate.sol @@ -57,7 +57,7 @@ contract PoolDelegate is ProxyUser { } function try_debtLocker_pullFunds(address debtLocker_, address liquidator_, address token_, address destination_, uint256 amount_) external returns (bool ok_) { - ( ok_, ) = debtLocker_.call(abi.encodeWithSelector(IDebtLocker.pullFundsFromLiquidator.selector, liquidator_, token_, destination_, amount_)); + ( ok_, ) = debtLocker_.call(abi.encodeWithSelector(IDebtLocker.pullFundsFromLiquidator.selector, liquidator_, token_, destination_, amount_)); } function try_debtLocker_setAllowedSlippage(address debtLocker_, uint256 allowedSlippage_) external returns (bool ok_) { diff --git a/contracts/test/mocks/Mocks.sol b/contracts/test/mocks/Mocks.sol index 552a37c..d1938b1 100644 --- a/contracts/test/mocks/Mocks.sol +++ b/contracts/test/mocks/Mocks.sol @@ -69,7 +69,7 @@ contract MockLiquidationStrategy { } contract MockLoan { - + function principalRequested() external view returns (uint256 principalRequested_) { return 0; } @@ -77,7 +77,7 @@ contract MockLoan { function acceptNewTerms(address refinancer_, bytes[] calldata calls_, uint256 amount_) external { // Empty, just testing ACL } - + } contract MockGlobals { @@ -86,7 +86,7 @@ contract MockGlobals { mapping(address => bool) public isValidCollateralAsset; mapping(address => bool) public isValidLiquidityAsset; - + bool public protocolPaused; mapping(address => uint256) assetPrices; diff --git a/modules/erc20 b/modules/erc20 index 3e5f4f1..c3d599d 160000 --- a/modules/erc20 +++ b/modules/erc20 @@ -1 +1 @@ -Subproject commit 3e5f4f1c90d1f2c5520bf929c983323917581ca4 +Subproject commit c3d599d9976144f0c20d25a14126741fdd2edea2 diff --git a/modules/erc20-helper b/modules/erc20-helper index 1361ddf..5961b58 160000 --- a/modules/erc20-helper +++ b/modules/erc20-helper @@ -1 +1 @@ -Subproject commit 1361ddfc32d62e27e226732b1467eab4768adea5 +Subproject commit 5961b58b75004356da04ec2b5b70eff40a1827f3 diff --git a/modules/liquidations b/modules/liquidations index b3d1537..773f87b 160000 --- a/modules/liquidations +++ b/modules/liquidations @@ -1 +1 @@ -Subproject commit b3d153754d0cbe66890c3a36fe1c41ae722257eb +Subproject commit 773f87b4836dd48ba64d58270760538723a9a972 diff --git a/modules/loan b/modules/loan index 3e17bbf..89b57aa 160000 --- a/modules/loan +++ b/modules/loan @@ -1 +1 @@ -Subproject commit 3e17bbf33fb3d305f8d27433092bbcfd2dc6e22a +Subproject commit 89b57aa6b8eea75482978e13869467a46df352d3 diff --git a/modules/maple-proxy-factory b/modules/maple-proxy-factory index cc2e8d8..66d4178 160000 --- a/modules/maple-proxy-factory +++ b/modules/maple-proxy-factory @@ -1 +1 @@ -Subproject commit cc2e8d8208b1f4b598b18cb5a5b3574f4d732a89 +Subproject commit 66d4178050f7da5c91b822a9bd8fd4fc89ac4f1c diff --git a/package.yaml b/package.yaml index 2568c52..cd5e561 100644 --- a/package.yaml +++ b/package.yaml @@ -1,11 +1,14 @@ name: debt-locker -version: 2.0.0-beta.0 +version: 2.0.0 source: contracts packages: - path: contracts/DebtLocker.sol contractName: DebtLocker - - path: contracts/DebtLockerInitializer.sol - contractName: DebtLockerInitializer + customChecksum: 0x852d096582581e400aa000467ea9e59e7939c20e4cbbfe0c0f3d04ac4286f600 - path: contracts/DebtLockerFactory.sol contractName: DebtLockerFactory + customChecksum: 0x90aa9362f8cf6d72464bb112ecddba515337250c33bff5c86e55831f005776d3 + - path: contracts/DebtLockerInitializer.sol + contractName: DebtLockerInitializer + customChecksum: 0xc47b9628c0eaa75890eaced74c259ae3613b4cb0f5090a2925c2fae166f59486 customDescription: Maple Debt Locker Artifacts and ABIs From 807a9d75a7d18daa3ae741ab53f0bec75a4ca107 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 26 Dec 2021 10:38:09 -0500 Subject: [PATCH 2/2] chore: update submodules --- modules/loan | 2 +- modules/maple-proxy-factory | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/loan b/modules/loan index 89b57aa..21a6d7d 160000 --- a/modules/loan +++ b/modules/loan @@ -1 +1 @@ -Subproject commit 89b57aa6b8eea75482978e13869467a46df352d3 +Subproject commit 21a6d7d76e58b575aac21eb1cb8d1e7659b77758 diff --git a/modules/maple-proxy-factory b/modules/maple-proxy-factory index 66d4178..776de27 160000 --- a/modules/maple-proxy-factory +++ b/modules/maple-proxy-factory @@ -1 +1 @@ -Subproject commit 66d4178050f7da5c91b822a9bd8fd4fc89ac4f1c +Subproject commit 776de2796c8844339ed63caaa5b1650cb8e81310