Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: natspec, whitespace, checksums [Wait for deps] #57

Merged
merged 2 commits into from
Dec 26, 2021
Merged
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
38 changes: 19 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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 [email protected]: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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
hevm*
.vscode/*
/package
artifacts/*
docs/*
metadata.json
10 changes: 5 additions & 5 deletions contracts/DebtLocker.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// 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";

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 ***/
Expand Down
3 changes: 3 additions & 0 deletions contracts/DebtLockerFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand All @@ -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_)
{}
Expand Down
8 changes: 5 additions & 3 deletions contracts/DebtLockerInitializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
7 changes: 4 additions & 3 deletions contracts/interfaces/IDebtLocker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions contracts/interfaces/IDebtLockerFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_);

Expand Down
11 changes: 11 additions & 0 deletions contracts/interfaces/IDebtLockerInitializer.sol
Original file line number Diff line number Diff line change
@@ -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_);

}
2 changes: 1 addition & 1 deletion contracts/test/DebtLocker.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ contract DebtLockerTests is TestUtils {
}

function test_liquidation_pullFunds(uint256 principalRequested_, uint256 collateralRequired_) external {

/**********************************/
/*** Create Loan and DebtLocker ***/
/**********************************/
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/accounts/PoolDelegate.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/mocks/Mocks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ contract MockLiquidationStrategy {
}

contract MockLoan {

function principalRequested() external view returns (uint256 principalRequested_) {
return 0;
}

function acceptNewTerms(address refinancer_, bytes[] calldata calls_, uint256 amount_) external {
// Empty, just testing ACL
}

}

contract MockGlobals {
Expand All @@ -86,7 +86,7 @@ contract MockGlobals {

mapping(address => bool) public isValidCollateralAsset;
mapping(address => bool) public isValidLiquidityAsset;

bool public protocolPaused;

mapping(address => uint256) assetPrices;
Expand Down
2 changes: 1 addition & 1 deletion modules/erc20
2 changes: 1 addition & 1 deletion modules/erc20-helper
2 changes: 1 addition & 1 deletion modules/loan
Submodule loan updated from 3e17bb to 21a6d7
9 changes: 6 additions & 3 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -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