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: Refactor to integration testing setup (SC-567) #7

Merged
merged 26 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ba8c2ac
feat: restructure dirs
lucas-manuel Aug 8, 2024
45b1544
feat: rm all unneeded setup logic
lucas-manuel Aug 8, 2024
0b2f1a9
fix: rename dir
lucas-manuel Aug 8, 2024
bf71a9c
chore: rm unused subs
lucas-manuel Aug 8, 2024
f43b5c5
feat: update sub to get deploy scripts
lucas-manuel Aug 8, 2024
4727a28
feat: get shared allocation system instance deployed
lucas-manuel Aug 8, 2024
7bad38e
forge install: nst
lucas-manuel Aug 8, 2024
9b5a71d
feat: add initial deployment scripts
lucas-manuel Aug 8, 2024
b8ae233
feat: add initial deployment scripts
lucas-manuel Aug 8, 2024
8c62bf1
feat: ilk init working
lucas-manuel Aug 8, 2024
f215ddb
feat: start to add rest of system
lucas-manuel Aug 8, 2024
e0e09af
forge install: sdai
lucas-manuel Aug 8, 2024
599b669
feat: full deployment working
lucas-manuel Aug 8, 2024
85f49ae
feat: working tests for draw
lucas-manuel Aug 8, 2024
bb5ef47
feat: burn working
lucas-manuel Aug 8, 2024
2757ec6
feat: psm calls working
lucas-manuel Aug 8, 2024
fcac05f
feat: update to work, swapping DAI instead of NST
lucas-manuel Aug 8, 2024
aecfadd
feat: comment out tests for swaps
lucas-manuel Aug 8, 2024
2127857
Merge branch 'master' into sc-567-refactor-to-integration
lucas-manuel Aug 8, 2024
78d2e6c
fix: update per merge
lucas-manuel Aug 8, 2024
7c027a6
feat: update to add back tests
lucas-manuel Aug 8, 2024
79036b8
feat: make first round of changes
lucas-manuel Aug 12, 2024
a289a1b
feat: tests passing with dainst
lucas-manuel Aug 12, 2024
bdb886e
formatting: reorder variables
lucas-manuel Aug 12, 2024
b01e344
fix: update per review
lucas-manuel Aug 12, 2024
4a4a60a
fix: update with changes
lucas-manuel Aug 12, 2024
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
12 changes: 3 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@
[submodule "lib/dss-allocator"]
path = lib/dss-allocator
url = https://github.com/makerdao/dss-allocator
[submodule "lib/nst"]
path = lib/nst
url = https://github.com/makerdao/nst
[submodule "lib/erc20-helpers"]
path = lib/erc20-helpers
url = https://github.com/marsfoundation/erc20-helpers
[submodule "lib/dss"]
path = lib/dss
url = https://github.com/marsfoundation/dss
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "lib/nst"]
path = lib/nst
url = https://github.com/makerdao/nst
[submodule "lib/sdai"]
path = lib/sdai
url = https://github.com/makerdao/sdai
[submodule "lib/dss-lite-psm"]
path = lib/dss-lite-psm
url = https://github.com/makerdao/dss-lite-psm
27 changes: 2 additions & 25 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,9 @@ solc_version = '0.8.21'
optimizer = true
optimizer_runs = 200
remappings = [
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"upgradeable-proxy/=lib/upgradeable-proxy/src/",
"forge-std/=lib/forge-std/src/",
"@openzeppelin/contracts-upgradeable/=lib/sdai/lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"ds-auth/=lib/dss/lib/ds-token/lib/ds-auth/src/",
"ds-math/=lib/dss/lib/ds-token/lib/ds-math/src/",
"ds-note/=lib/dss/lib/ds-value/lib/ds-thing/lib/ds-note/src/",
"ds-test/=lib/dss/lib/ds-test/src/",
"ds-thing/=lib/dss/lib/ds-value/lib/ds-thing/src/",
"ds-token/=lib/dss/lib/ds-token/src/",
"ds-value/=lib/dss/lib/ds-value/src/",
"dss-allocator/=lib/dss-allocator/",
"dss-interfaces/=lib/sdai/lib/dss-test/lib/dss-interfaces/src/",
"dss-test/=lib/sdai/lib/dss-test/src/",
"dss/=lib/dss/src/",
"erc20-helpers/=lib/erc20-helpers/src/",
"erc4626-tests/=lib/sdai/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"dss-test/=lib/dss-allocator/lib/dss-test/src/",
"nst/=lib/nst/",
"openzeppelin-contracts-upgradeable/=lib/sdai/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin-foundry-upgrades/=lib/sdai/lib/openzeppelin-foundry-upgrades/src/",
"sdai/=lib/sdai/",
"solidity-stringutils/=lib/sdai/lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/",
"token-tests/=lib/sdai/lib/token-tests/src/"
"sdai/=lib/sdai/"
]

[fuzz]
Expand Down
1 change: 0 additions & 1 deletion lib/dss
Submodule dss deleted from 9f21a8
1 change: 0 additions & 1 deletion lib/dss-lite-psm
Submodule dss-lite-psm deleted from 2598e2
71 changes: 55 additions & 16 deletions src/EthereumController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import { AccessControl } from "openzeppelin-contracts/contracts/access/AccessCon

import { IALMProxy } from "src/interfaces/IALMProxy.sol";

interface IDaiNstLike {
function dai() external view returns(address);
function daiToNst(address usr, uint256 wad) external;
function nstToDai(address usr, uint256 wad) external;
}

interface ISNSTLike {
function deposit(uint256 assets, address receiver) external;
function nst() external view returns(address);
Expand Down Expand Up @@ -38,12 +44,15 @@ contract EthereumController is AccessControl {

address public immutable buffer;

IALMProxy public immutable proxy;
IVaultLike public immutable vault;
ISNSTLike public immutable snst;
IPSMLike public immutable psm;
IERC20 public immutable nst;
IERC20 public immutable usdc;
IALMProxy public immutable proxy;
IDaiNstLike public immutable daiNst;
IPSMLike public immutable psm;
IVaultLike public immutable vault;

IERC20 public immutable dai;
IERC20 public immutable nst;
IERC20 public immutable usdc;
ISNSTLike public immutable snst;

bool public active;

Expand All @@ -56,18 +65,22 @@ contract EthereumController is AccessControl {
address proxy_,
address vault_,
address buffer_,
address snst_,
address psm_
address psm_,
address daiNst_,
address snst_
) {
_grantRole(DEFAULT_ADMIN_ROLE, admin_);

buffer = buffer_;
proxy = IALMProxy(proxy_);
vault = IVaultLike(vault_);
snst = ISNSTLike(snst_);
buffer = buffer_;
psm = IPSMLike(psm_);
usdc = IERC20(psm.gem());
nst = IERC20(snst.nst());
daiNst = IDaiNstLike(daiNst_);

snst = ISNSTLike(snst_);
dai = IERC20(daiNst.dai());
usdc = IERC20(psm.gem());
nst = IERC20(snst.nst());

active = true;
}
Expand Down Expand Up @@ -156,12 +169,24 @@ contract EthereumController is AccessControl {
/**********************************************************************************************/

function swapNSTToUSDC(uint256 usdcAmount) external onlyRole(RELAYER) isActive {
uint256 conversionFactor = psm.to18ConversionFactor();
uint256 nstAmount = usdcAmount * psm.to18ConversionFactor();

// Approve NST to PSM from the proxy (assumes the proxy has enough NST)
// Approve NST to DaiNst migrator from the proxy (assumes the proxy has enough NST)
proxy.doCall(
address(nst),
abi.encodeCall(nst.approve, (address(psm), usdcAmount * conversionFactor))
abi.encodeCall(nst.approve, (address(daiNst), nstAmount))
);

// Swap NST to DAI 1:1
proxy.doCall(
address(daiNst),
abi.encodeCall(daiNst.nstToDai, (address(proxy), nstAmount))
);

// Approve DAI to PSM from the proxy (assumes the proxy has enough DAI)
proxy.doCall(
address(dai),
abi.encodeCall(dai.approve, (address(psm), nstAmount))
);

// Swap NST to USDC through the PSM
Expand All @@ -172,17 +197,31 @@ contract EthereumController is AccessControl {
}

function swapUSDCToNST(uint256 usdcAmount) external onlyRole(RELAYER) isActive {
uint256 nstAmount = usdcAmount * psm.to18ConversionFactor();

// Approve USDC to PSM from the proxy (assumes the proxy has enough USDC)
proxy.doCall(
address(usdc),
abi.encodeCall(usdc.approve, (address(psm), usdcAmount))
);

// Swap USDC to NST through the PSM
// Swap USDC to DAI through the PSM
proxy.doCall(
address(psm),
abi.encodeCall(psm.sellGemNoFee, (address(proxy), usdcAmount))
);

// Approve DAI to DaiNst migrator from the proxy (assumes the proxy has enough DAI)
proxy.doCall(
address(dai),
abi.encodeCall(dai.approve, (address(daiNst), nstAmount))
);

// Swap DAI to NST 1:1
proxy.doCall(
address(daiNst),
abi.encodeCall(daiNst.daiToNst, (address(proxy), nstAmount))
);
}

}
Expand Down
136 changes: 0 additions & 136 deletions test/UnitTestBase.t.sol

This file was deleted.

31 changes: 0 additions & 31 deletions test/controller/Constructor.t.sol

This file was deleted.

Loading
Loading