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

feat: Upgrade to V4 #66

Merged
merged 12 commits into from
Aug 26, 2022
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
24 changes: 0 additions & 24 deletions .circleci/config.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/forge-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Forge Tests (PR)

on: [pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

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

- name: Checkout liquidations private submodule
env:
SSH_KEY_LIQUIDATIONS: ${{secrets.SSH_KEY_LIQUIDATIONS}}
shell: bash
run: |
mkdir $HOME/.ssh
echo "$SSH_KEY_LIQUIDATIONS" > $HOME/.ssh/id_rsa
chmod 600 $HOME/.ssh/id_rsa
git submodule update --init --recursive modules/liquidations

- name: Checkout loan private submodule
env:
SSH_KEY_LOAN: ${{secrets.SSH_KEY_LOAN}}
shell: bash
run: |
echo "$SSH_KEY_LOAN" > $HOME/.ssh/id_rsa
chmod 600 $HOME/.ssh/id_rsa
git submodule update --init --recursive modules/loan

- name: Checkout public submodules
run: |
git config --global url."https://github.com/".insteadOf "[email protected]:"
git submodule update --init --recursive

- name: Run Forge tests
run: ./scripts/test.sh -p deep
43 changes: 43 additions & 0 deletions .github/workflows/forge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Forge Tests

on:
push:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

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

- name: Checkout liquidations private submodule
env:
SSH_KEY_LIQUIDATIONS: ${{secrets.SSH_KEY_LIQUIDATIONS}}
shell: bash
run: |
mkdir $HOME/.ssh
echo "$SSH_KEY_LIQUIDATIONS" > $HOME/.ssh/id_rsa
chmod 600 $HOME/.ssh/id_rsa
git submodule update --init --recursive modules/liquidations

- name: Checkout loan private submodule
env:
SSH_KEY_LOAN: ${{secrets.SSH_KEY_LOAN}}
shell: bash
run: |
echo "$SSH_KEY_LOAN" > $HOME/.ssh/id_rsa
chmod 600 $HOME/.ssh/id_rsa
git submodule update --init --recursive modules/loan

- name: Checkout public submodules
run: |
git config --global url."https://github.com/".insteadOf "[email protected]:"
git submodule update --init --recursive

- name: Run Forge tests
run: ./scripts/test.sh -p super_deep
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ hevm*
artifacts/*
docs/*
metadata.json
cache
10 changes: 5 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[submodule "modules/erc20"]
path = modules/erc20
url = https://github.com/maple-labs/erc20.git
url = git@github.com:maple-labs/erc20.git
[submodule "modules/erc20-helper"]
path = modules/erc20-helper
url = https://github.com/maple-labs/erc20-helper.git
url = git@github.com:maple-labs/erc20-helper.git
[submodule "modules/contract-test-utils"]
path = modules/contract-test-utils
url = https://github.com/maple-labs/contract-test-utils.git
url = git@github.com:maple-labs/contract-test-utils.git
[submodule "modules/liquidations"]
path = modules/liquidations
url = https://github.com/maple-labs/liquidations
url = git@github.com:maple-labs/liquidations.git
[submodule "modules/maple-proxy-factory"]
path = modules/maple-proxy-factory
url = [email protected]:maple-labs/maple-proxy-factory.git
[submodule "modules/loan"]
path = modules/loan
url = https://github.com/maple-labs/loan
url = git@github.com:maple-labs/loan.git
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
prod :; ./build.sh -c ./config/prod.json
dev :; ./build.sh -c ./config/dev.json
ci :; ./build.sh -c ./config/ci.json
clean :; dapp clean
test :; ./test.sh
release :; ./release.sh
install:
@git submodule update --init --recursive

update:
@forge update

build:
@scripts/build.sh -p default

test:
@scripts/test.sh

clean:
@forge clean
18 changes: 0 additions & 18 deletions build.sh

This file was deleted.

36 changes: 0 additions & 36 deletions config/ci.json

This file was deleted.

38 changes: 0 additions & 38 deletions config/dev.json

This file was deleted.

37 changes: 0 additions & 37 deletions config/prod.json

This file was deleted.

5 changes: 1 addition & 4 deletions package.yaml → configs/package.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: debt-locker
version: 2.0.0
version: 4.0.0-alpha.0
source: contracts
packages:
- path: contracts/DebtLocker.sol
contractName: DebtLocker
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
10 changes: 10 additions & 0 deletions contracts/DebtLocker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ contract DebtLocker is IDebtLocker, DebtLockerStorage, MapleProxiedInternals {
emit FundsToCaptureSet(_fundsToCapture = amount_);
}

function setPendingLender(address newLender_) override external whenProtocolNotPaused {
require(msg.sender == _loanMigrator, "DL:SPL:NOT_MIGRATOR");

IMapleLoanLike(_loan).setPendingLender(newLender_);
}

function setMinRatio(uint256 minRatio_) external override whenProtocolNotPaused {
require(msg.sender == _getPoolDelegate(), "DL:SMR:NOT_PD");

Expand Down Expand Up @@ -280,6 +286,10 @@ contract DebtLocker is IDebtLocker, DebtLockerStorage, MapleProxiedInternals {
return _loan;
}

function loanMigrator() external view override returns (address loan_) {
return _loanMigrator;
}

function minRatio() external view override returns (uint256 minRatio_) {
return _minRatio;
}
Expand Down
1 change: 1 addition & 0 deletions contracts/DebtLockerStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ contract DebtLockerStorage {
uint256 internal _minRatio;
uint256 internal _principalRemainingAtLastClaim;

address internal _loanMigrator;
}
27 changes: 27 additions & 0 deletions contracts/DebtLockerV4Migrator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.7;

import { IDebtLockerV4Migrator } from "./interfaces/IDebtLockerV4Migrator.sol";

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

/// @title DebtLockerV4Migrator is intended to initialize the storage of a DebtLocker proxy.
contract DebtLockerV4Migrator is IDebtLockerV4Migrator, DebtLockerStorage {

function encodeArguments(address migrator_) external pure override returns (bytes memory encodedArguments_) {
return abi.encode(migrator_);
}

function decodeArguments(bytes calldata encodedArguments_) public pure override returns (address migrator_) {
( migrator_ ) = abi.decode(encodedArguments_, (address));
}

fallback() external {

// Taking the migrator_ address as argument for now, but ideally this would be hardcoded in the debtLocker migrator registered in the factory
( address migrator_ ) = decodeArguments(msg.data);

_loanMigrator = migrator_;
}

}
Loading