Skip to content

Commit

Permalink
Merge pull request #5 from maple-labs/release
Browse files Browse the repository at this point in the history
Release v5.0.2
  • Loading branch information
JGcarv authored Dec 20, 2023
2 parents eb668ad + 544131b commit eb0ebf3
Show file tree
Hide file tree
Showing 24 changed files with 533 additions and 246 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/forge-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Forge Tests (PR)
on: [pull_request]

jobs:
run-ci:
test:
name: Test with "deep" profile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -39,11 +40,32 @@ jobs:
- name: Generate coverage report
run: |
forge coverage --report lcov
sudo apt-get install lcov
lcov --remove lcov.info -o lcov.info 'tests/*'
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v1
with:
coverage-files: lcov.info
minimum-coverage: 65
minimum-coverage: 90
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./

size_check:
name: Check contracts sizes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly

- name: Install submodules
run: |
git config --global url."https://github.com/".insteadOf "[email protected]:"
git submodule update --init --recursive
- name: Check contract sizes
run: ./scripts/check-sizes.sh
26 changes: 24 additions & 2 deletions .github/workflows/forge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ on:
- main

jobs:
run-ci:
test:
name: Test with "deep" profile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -42,11 +43,32 @@ jobs:
- name: Generate coverage report
run: |
forge coverage --report lcov
sudo apt-get install lcov
lcov --remove lcov.info -o lcov.info 'tests/*'
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v1
with:
coverage-files: lcov.info
minimum-coverage: 65
minimum-coverage: 90
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ./

size_check:
name: Check contracts sizes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Foundry
uses: onbjerg/foundry-toolchain@v1
with:
version: nightly

- name: Install submodules
run: |
git config --global url."https://github.com/".insteadOf "[email protected]:"
git submodule update --init --recursive
- name: Check contract sizes
run: ./scripts/check-sizes.sh
54 changes: 0 additions & 54 deletions .github/workflows/slither.yml

This file was deleted.

14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
install:
@git submodule update --init --recursive

update:
@forge update

build:
@scripts/build.sh -p default
@scripts/build.sh -p production

release:
@scripts/release.sh

size:
@scripts/check-sizes.sh

test:
@scripts/test.sh -p default

clean:
@forge clean
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ forge install
| v3.0.1 - v4.0.0 | Three Sigma | [`Three Sigma Report`](https://docs.google.com/viewer?url=https://github.com/maple-labs/maple-v2-audits/files/10223541/three-sigma_maple-finance_code-audit_v1.1.1.pdf) | 2022-10-24 |
| v5.0.0 - v5.0.1 | Spearbit Auditors via Cantina | [`2023-06-05 - Cantina Report`](https://docs.google.com/viewer?url=https://github.com/maple-labs/maple-v2-audits/files/11667848/cantina-maple.pdf) | 2023-06-05 |
| v5.0.0 - v5.0.1 | Three Sigma | [`2023-04-10 - Three Sigma Report`](https://docs.google.com/viewer?url=https://github.com/maple-labs/maple-v2-audits/files/11663546/maple-v2-audit_three-sigma_2023.pdf) | 2023-04-21 |
| Three Sigma | [`2023-11-06 - Three Sigma Report`](https://docs.google.com/viewer?url=https://github.com/maple-labs/maple-v2-audits/files/13707288/Maple-Q4-Three-Sigma-Audit.pdf) |
| 0xMacro | [`2023-11-27 - 0xMacro Report`](https://docs.google.com/viewer?url=https://github.com/maple-labs/maple-v2-audits/files/13707291/Maple-Q4-0xMacro-Audit.pdf) |

## Bug Bounty

Expand Down
4 changes: 1 addition & 3 deletions configs/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: fixed-term-loan
version: 5.0.1
version: 5.0.2
source: contracts
packages:
- path: contracts/MapleLoan.sol
Expand All @@ -10,8 +10,6 @@ packages:
contractName: MapleLoanFeeManager
- path: contracts/MapleLoanInitializer.sol
contractName: MapleLoanInitializer
- path: contracts/MapleLoanStorage.sol
contractName: MapleLoanStorage
- path: contracts/MapleLoanV5Migrator.sol
contractName: MapleLoanV5Migrator
- path: contracts/Refinancer.sol
Expand Down
18 changes: 14 additions & 4 deletions contracts/MapleLoanFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,31 @@ pragma solidity 0.8.7;
import { IMapleProxyFactory, MapleProxyFactory } from "../modules/maple-proxy-factory/contracts/MapleProxyFactory.sol";

import { IMapleLoanFactory } from "./interfaces/IMapleLoanFactory.sol";
import { IGlobalsLike } from "./interfaces/Interfaces.sol";

/// @title MapleLoanFactory deploys Loan instances.
contract MapleLoanFactory is IMapleLoanFactory, MapleProxyFactory {

mapping(address => bool) public override isLoan;
address public immutable override oldFactory;

/// @param mapleGlobals_ The address of a Maple Globals contract.
constructor(address mapleGlobals_) MapleProxyFactory(mapleGlobals_) {}
mapping(address => bool) internal _isLoan;

constructor(address mapleGlobals_, address oldFactory_) MapleProxyFactory(mapleGlobals_) {
oldFactory = oldFactory_;
}

function createInstance(bytes calldata arguments_, bytes32 salt_)
override(IMapleProxyFactory, MapleProxyFactory) public returns (
address instance_
)
{
isLoan[instance_ = super.createInstance(arguments_, salt_)] = true;
require(IGlobalsLike(mapleGlobals).canDeploy(msg.sender), "MLF:CI:CANNOT_DEPLOY");

_isLoan[instance_ = super.createInstance(arguments_, salt_)] = true;
}

function isLoan(address instance_) external view override returns (bool) {
return (_isLoan[instance_] || IMapleLoanFactory(oldFactory).isLoan(instance_));
}

}
1 change: 1 addition & 0 deletions contracts/MapleLoanFeeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IMapleLoanFeeManager } from "./interfaces/IMapleLoanFeeManager.sol";
██║ ╚═╝ ██║██║ ██║██║ ███████╗███████╗ ███████╗╚██████╔╝██║ ██║██║ ╚████║
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝
███████╗███████╗███████╗ ███╗ ███╗ █████╗ ███╗ ██╗ █████╗ ██████╗ ███████╗██████╗
██╔════╝██╔════╝██╔════╝ ████╗ ████║██╔══██╗████╗ ██║██╔══██╗██╔════╝ ██╔════╝██╔══██╗
█████╗ █████╗ █████╗ ██╔████╔██║███████║██╔██╗ ██║███████║██║ ███╗█████╗ ██████╔╝
Expand Down
25 changes: 25 additions & 0 deletions contracts/MapleLoanV502Migrator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.7;

import { ProxiedInternals } from "../modules/maple-proxy-factory/modules/proxy-factory/contracts/ProxiedInternals.sol";

import { IGlobalsLike, IMapleProxyFactoryLike } from "./interfaces/Interfaces.sol";

import { MapleLoanStorage } from "./MapleLoanStorage.sol";

/// @title MapleLoanV502Migrator is to update the factory address for each deployed loan.
contract MapleLoanV502Migrator is ProxiedInternals, MapleLoanStorage {

fallback() external {
( address newFactory_ ) = abi.decode(msg.data, (address));

require(_factory() != newFactory_, "MLV502M:INVALID_NO_OP");

address globals = IMapleProxyFactoryLike(_factory()).mapleGlobals();

require(IGlobalsLike(globals).isInstanceOf("FT_LOAN_FACTORY", newFactory_), "MLV502M:INVALID_FACTORY");

_setFactory(newFactory_);
}

}
18 changes: 9 additions & 9 deletions contracts/Refinancer.sol → contracts/MapleRefinancer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ pragma solidity 0.8.7;
import { IERC20 } from "../modules/erc20/contracts/interfaces/IERC20.sol";

import { IMapleLoanFeeManager } from "./interfaces/IMapleLoanFeeManager.sol";
import { IRefinancer } from "./interfaces/IRefinancer.sol";
import { IMapleRefinancer } from "./interfaces/IMapleRefinancer.sol";

import { MapleLoanStorage } from "./MapleLoanStorage.sol";

/*
██████╗ ███████╗███████╗██╗███╗ ██╗ █████╗ ███╗ ██╗ ██████╗███████╗██████╗
██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔══██╗████╗ ██║██╔════╝██╔════╝██╔══██╗
██████╔╝█████╗ █████╗ ██║██╔██╗ ██║███████║██╔██╗ ██║██║ █████╗ ██████╔╝
██╔══██╗██╔══╝ ██╔══╝ ██║██║╚██╗██║██╔══██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗
██║ ██║███████╗██║ ██║██║ ╚████║██║ ██║██║ ╚████║╚██████╗███████╗██║ ██║
╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═╝ ╚═╝
███╗ ███╗ █████╗ ██████╗ ██╗ ███████╗ ██████╗ ███████╗███████╗██╗███╗ ██╗ █████╗ ███╗ ██╗ ██████╗███████╗██████╗
████╗ ████║██╔══██╗██╔══██╗██║ ██╔════╝ ██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔══██╗████╗ ██║██╔════╝██╔════╝██╔══██╗
██╔████╔██║███████║██████╔╝██║ █████╗ ██████╔╝█████╗ █████╗ ██║██╔██╗ ██║███████║██╔██╗ ██║██║ █████╗ ██████╔╝
██║╚██╔╝██║██╔══██║██╔═══╝ ██║ ██╔══╝ ██╔══██╗██╔══╝ ██╔══╝ ██║██║╚██╗██║██╔══██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗
██║ ╚═╝ ██║██║ ██║██║ ███████╗███████╗ ██║ ██║███████╗██║ ██║██║ ╚████║██║ ██║██║ ╚████║╚██████╗███████╗██║ ██║
╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═╝ ╚═╝
*/

/// @title Refinancer uses storage from a MapleLoan defined by MapleLoanStorage.
contract Refinancer is IRefinancer, MapleLoanStorage {
/// @title MapleRefinancer uses storage from a MapleLoan defined by MapleLoanStorage.
contract MapleRefinancer is IMapleRefinancer, MapleLoanStorage {

function increasePrincipal(uint256 amount_) external override {
// Cannot under-fund the principal increase, but over-funding results in additional funds left unaccounted for.
Expand Down
8 changes: 7 additions & 1 deletion contracts/interfaces/IMapleLoanFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import { IMapleProxyFactory } from "../../modules/maple-proxy-factory/contracts/
interface IMapleLoanFactory is IMapleProxyFactory {

/**
* @dev Whether the proxy is a MapleLoan deployed by this factory.
* @dev Whether the proxy is a MapleLoan deployed by this factory or the old factory.
* @param proxy_ The address of the proxy contract.
* @return isLoan_ Whether the proxy is a MapleLoan deployed by this factory.
*/
function isLoan(address proxy_) external view returns (bool isLoan_);

/**
* @dev Returns the address of the old factory.
* @return oldFactory_ The address of the old factory.
*/
function oldFactory() external view returns (address oldFactory_);

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.7;

/// @title Refinancer uses storage from Maple Loan.
interface IRefinancer {
/// @title MapleRefinancer uses storage from Maple Loan.
interface IMapleRefinancer {

/**************************************************************************************************************************************/
/*** Events ***/
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/Interfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ interface IGlobalsLike {

function securityAdmin() external view returns (address securityAdmin_);

function canDeploy(address caller_) external view returns (bool canDeploy_);

}

interface ILenderLike {
Expand Down
10 changes: 5 additions & 5 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ contracts = 'contracts' # The contract directory
test = 'tests' # The test directory
libs = ['modules'] # A list of library directories
solc_version = '0.8.7' # Override for the solc version (setting this ignores `auto_detect_solc`)
optimizer = true # Enable or disable the solc optimizer
optimizer_runs = 200 # The number of optimizer runs
optimizer = false # Enable or disable the solc optimizer
verbosity = 3 # The verbosity of tests
block_timestamp = 1_622_400_000 # Timestamp for tests (non-zero)
fuzz_runs = 100 # Number of fuzz runs

[profile.deep]
fuzz_runs = 1000

[profile.super_deep]
fuzz_runs = 50000

[profile.release]
optimizer = true # Enable or disable the solc optimizer
optimizer_runs = 200 # The number of optimizer runs
[profile.production]
optimizer = true # Enable or disable the solc optimizer
optimizer_runs = 200 # The number of optimizer runs
33 changes: 33 additions & 0 deletions scripts/check-sizes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

while getopts p: flag
do
case "${flag}" in
p) profile=${OPTARG};;
esac
done

export FOUNDRY_PROFILE=production

sizes=$(forge build --sizes)

names=($(cat ./configs/package.yaml | grep " contractName:" | sed -r 's/.{18}//'))

fail=false

for i in "${!names[@]}"; do
line=$(echo "$sizes" | grep -w "${names[i]}")

if [[ $line == *"-"* ]]; then
echo "${names[i]} is too large"
fail=true
fi
done

if $fail
then
echo "Contract size check failed"
exit 1
else
echo "Contract size check passed"
fi
2 changes: 1 addition & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version=$(cat ./configs/package.yaml | grep "version: " | sed -r 's/.{9}//')
name=$(cat ./configs/package.yaml | grep "name: " | sed -r 's/.{6}//')
customDescription=$(cat ./configs/package.yaml | grep "customDescription: " | sed -r 's/.{19}//')

./scripts/build.sh -p release
./scripts/build.sh -p production

rm -rf ./package
mkdir -p package
Expand Down
Loading

0 comments on commit eb0ebf3

Please sign in to comment.