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

Allocator Vault Support #104

Open
wants to merge 62 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5857fa1
starting on alm controller
hexonaut Mar 17, 2023
91e0349
added outline of swap pool and alm controller
hexonaut Mar 17, 2023
b916210
ordering
hexonaut Mar 17, 2023
07c8919
copyright year
hexonaut Mar 17, 2023
2891e16
remove swap
hexonaut Mar 17, 2023
b7843ba
putting together the scaffolding for alm controller v1
hexonaut Apr 6, 2023
f421f89
continuing to work on alm controller
hexonaut Apr 6, 2023
4f2088d
remove fees and simplify
hexonaut Apr 6, 2023
a74d930
alm controller now purely delegate to allow allocator custom logic
hexonaut Apr 7, 2023
e636fc8
add 2 swap pool variants
hexonaut Apr 12, 2023
ca0af6e
adding some helper functions for the trust
hexonaut Apr 12, 2023
1875b86
finish initial version of swap pools and update tests to new interfac…
hexonaut Apr 13, 2023
1d47811
building out unit tests for linear fee swap pool
hexonaut Apr 13, 2023
c76e99a
adding preview tests
hexonaut Apr 13, 2023
6f79da1
increased precision of tin/touts to wads; fixed tests
hexonaut Apr 14, 2023
00ecae0
add a bunch more cases in linear fee swap pool tests
hexonaut Apr 15, 2023
fc89e47
inline more variables and reduce unnecessary operations
hexonaut Apr 15, 2023
9639429
started adding unit tests for whitelisted swap pool
hexonaut Apr 16, 2023
bdcdee9
add asset balance test
hexonaut Apr 16, 2023
ffeece6
add preview buy and sell gem tests
hexonaut Apr 17, 2023
643ffe4
adding more test functions
hexonaut Apr 17, 2023
35a35dd
add push/pull tests
hexonaut Apr 18, 2023
d3e9ea1
add tests to pendingDeposits() and fix a bug
hexonaut Apr 18, 2023
b9375b0
add tests for pending withdrawals and fix math
hexonaut Apr 18, 2023
bf53156
starting to add unit tests to alm delegate controller; add/remove to …
hexonaut Apr 19, 2023
fbf86fd
refactoring to how max and delegates work; more unit tests added for …
hexonaut Apr 19, 2023
68ca54d
add tests for setAllocation and change getter to "totalAllocated"
hexonaut Apr 19, 2023
e336ec9
add getTargetAssets test
hexonaut Apr 19, 2023
1a313d5
started adding linear fee swap integration test
hexonaut Apr 20, 2023
3b29ca5
refactor hub fees and added a default one to forward to vow
hexonaut Apr 21, 2023
99a5594
working to get tests fixed
hexonaut Apr 21, 2023
105f958
fairly large refactor of the integration base to simplify and general…
hexonaut Apr 22, 2023
8629c72
got integration tests compiling
hexonaut Apr 22, 2023
dd3398f
linear fee swap integration base tests passing
hexonaut Apr 22, 2023
c642362
fix all tests
hexonaut Apr 22, 2023
640c0ed
add actual idleLiquidity calcs to aave/compound pool adapters
hexonaut Apr 23, 2023
6bdb473
use swaps for liquidity controls; add sellGem/buyGem in integration test
hexonaut Apr 23, 2023
154e0e2
rename buyGem/sellGem to swapDaiForGem and swapGemForDai respectively…
hexonaut Apr 23, 2023
64fc8d2
add gusd and usdp integration tests
hexonaut Apr 23, 2023
a866142
add integration test for backed finance IB01
hexonaut Apr 23, 2023
09d1f75
disable the cage exit test because its currently broken
hexonaut Apr 23, 2023
310ec05
rename whitelisted to offchain and start scoffolding integration test…
hexonaut Apr 23, 2023
ce6acd5
fetch the plan from the hub every swap
hexonaut Apr 23, 2023
f305cf1
fix integration tests for offchain swap
hexonaut Apr 23, 2023
4ba1381
allow adjusting the gemsOutstanding to accrue interest/losses; some t…
hexonaut Apr 24, 2023
889141a
add idle and available liquidity tests to swap pools
hexonaut Apr 24, 2023
3ca7dd6
add liquidity available test to aave v3 test
hexonaut Apr 24, 2023
8a32bdd
adding idleLiquidity test and fixing some mocks
hexonaut Apr 24, 2023
4ddfd6e
uncomment div0 branch
hexonaut Apr 24, 2023
74a021b
reintroduce multi cage exit test
hexonaut Apr 26, 2023
3cfd1bc
merge offchain and linear fee swap integration tests to a shared base…
hexonaut Apr 26, 2023
e9b52a0
almost done adding an in-depth test for off-chain investment
hexonaut Apr 26, 2023
80045ef
finish full offchain example
hexonaut Apr 26, 2023
12c4af3
add an explicit note about why we allow 2-way negative fees and why i…
hexonaut Apr 26, 2023
b9ce532
update readme
hexonaut Apr 27, 2023
1e6bc1d
updating certora
hexonaut Apr 27, 2023
c2c0d2b
fix typo
hexonaut Apr 28, 2023
f15ce5e
more fixes for certora spec
hexonaut Apr 28, 2023
49e1ad2
split gated and gated offchain into two separate pools
hexonaut May 11, 2023
80e4700
tests are failing, but adding integration tests for Arrakis LP tokens
hexonaut May 11, 2023
17d0044
fix tests
hexonaut May 12, 2023
dc5cef3
relax the abs checks
hexonaut May 12, 2023
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
all :; FOUNDRY_OPTIMIZER=true FOUNDRY_OPTIMIZER_RUNS=200 forge build --use solc:0.8.14
clean :; forge clean
certora-hub :; PATH=~/.solc-select/artifacts/solc-0.8.14:~/.solc-select/artifacts/solc-0.5.12:~/.solc-select/artifacts:${PATH} certoraRun --solc_map D3MHub=solc-0.8.14,Vat=solc-0.5.12,DaiJoin=solc-0.5.12,Dai=solc-0.5.12,End=solc-0.5.12,D3MTestPlan=solc-0.8.14,D3MTestPool=solc-0.8.14,TokenMock=solc-0.8.14 --optimize_map D3MHub=200,Vat=0,DaiJoin=0,Dai=0,End=0,D3MTestPlan=200,D3MTestPool=200,TokenMock=200 --rule_sanity basic src/D3MHub.sol certora/dss/Vat.sol certora/dss/DaiJoin.sol certora/dss/Dai.sol certora/dss/End.sol certora/d3m/D3MTestPlan.sol certora/d3m/D3MTestPool.sol src/tests/mocks/TokenMock.sol --link D3MHub:vat=Vat D3MHub:daiJoin=DaiJoin D3MHub:end=End DaiJoin:vat=Vat DaiJoin:dai=Dai End:vat=Vat D3MTestPlan:dai=Dai D3MTestPool:hub=D3MHub D3MTestPool:vat=Vat D3MTestPool:dai=Dai D3MTestPool:share=TokenMock --verify D3MHub:certora/D3MHub.spec --settings -mediumTimeout=1200,-solver=z3,-adaptiveSolverConfig=false,-smt_nonLinearArithmetic=true$(if $(short), --short_output,)$(if $(rule), --rule $(rule),)$(if $(multi), --multi_assert_check,)
certora-hub :; PATH=~/.solc-select/artifacts/solc-0.8.14:~/.solc-select/artifacts/solc-0.5.12:~/.solc-select/artifacts:${PATH} certoraRun --solc_map D3MHub=solc-0.8.14,Vat=solc-0.5.12,DaiJoin=solc-0.5.12,Dai=solc-0.5.12,End=solc-0.5.12,D3MTestPlan=solc-0.8.14,D3MTestPool=solc-0.8.14,TokenMock=solc-0.8.14,D3MForwardFees=solc-0.8.14 --optimize_map D3MHub=200,Vat=0,DaiJoin=0,Dai=0,End=0,D3MTestPlan=200,D3MTestPool=200,TokenMock=200,D3MForwardFees=200 --rule_sanity basic src/D3MHub.sol certora/dss/Vat.sol certora/dss/DaiJoin.sol certora/dss/Dai.sol certora/dss/End.sol certora/d3m/D3MTestPlan.sol certora/d3m/D3MTestPool.sol src/tests/mocks/TokenMock.sol src/fees/D3MForwardFees.sol --link D3MHub:vat=Vat D3MHub:daiJoin=DaiJoin D3MHub:end=End DaiJoin:vat=Vat DaiJoin:dai=Dai End:vat=Vat D3MTestPlan:dai=Dai D3MTestPool:hub=D3MHub D3MTestPool:vat=Vat D3MTestPool:dai=Dai D3MTestPool:share=TokenMock D3MForwardFees:vat=Vat --verify D3MHub:certora/D3MHub.spec --settings -mediumTimeout=1200,-solver=z3,-adaptiveSolverConfig=false,-smt_nonLinearArithmetic=true$(if $(short), --short_output,)$(if $(rule), --rule $(rule),)$(if $(multi), --multi_assert_check,)
deploy :; ./deploy.sh config="$(config)"
deploy-core :; ./deploy-core.sh
26 changes: 6 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The Dai Direct Deposit Module (D3M) is a tool for directly injecting DAI into th

As seen in the image above, external protocols are viewed under the simplified ERC-4626-like interface. Pool adapters are used to convert protocol complexity into simplified concepts of Excess Capacity + DAI liquidity + DAI outstanding. How DAI is converted between these states is completely protocol-specific and mostly irrelevant to the D3M.

The D3M is made of 3 components on the Maker side:
The D3M is made of 4 components on the Maker side:

### D3MHub

Expand All @@ -23,6 +23,10 @@ A "dumb" adapter which is responsible for depositing or withdrawing DAI from the

The D3MPlan can be viewed as the targeting logic for D3M instances. The plan is responsible for reading all relevant information from its state (i.e. the target rate) and possibly from the external protocol (i.e. current balance of supply and borrowing in the market) and condensing this down to a debt target. This desired target debt is forwarded to the Hub to take action to reach this target debt level asap.

### D3MFees

D3MFees is a contract to deal with revenue coming in from a protocol. Default implementation `D3MForwardFees` with the target set to the `vow` will just send all revenue to the surplus buffer.

### General Configuration

The below parameter exists for each D3M implementation:
Expand All @@ -31,25 +35,7 @@ The below parameter exists for each D3M implementation:

# Specific Implementations

## Aave D3M

### Configuration

Below is a configurable parameter for the Aave DAI D3M:

- `bar` [ray] - The target borrow rate on Aave for the DAI market. This module will aim to enforce that borrow limit.

Any stkAave that is accured can be permissionlessly collected into the pause proxy by calling `collect()`.

## Compound D3M

### Configuration

Below is a configurable parameter for the Compound DAI D3M:

- `barb` [wad] - The target borrow rate per block on Compound for the DAI market. This module will aim to enforce that borrow limit.

Any Comp that is accured can be permissionlessly collected into the pause proxy by calling `collect()`.
There are many pool/plan/fee combinations. Please review the specific contract and configurations to set all the appropriate parameters.

### Setup and Testing

Expand Down
39 changes: 29 additions & 10 deletions certora/D3MHub.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ using DaiJoin as daiJoin
using End as end
using D3MTestPool as pool
using D3MTestPlan as plan
using D3MForwardFees as fees
using TokenMock as share

methods {
vat() returns (address) envfree
daiJoin() returns (address) envfree
vow() returns (address) envfree
end() returns (address) envfree
ilks(bytes32) returns (address, address, uint256, uint256, uint256) envfree
ilks(bytes32) returns (address, address, address, uint256, uint256, uint256) envfree
locked() returns (uint256) envfree
plan(bytes32) returns (address) envfree => DISPATCHER(true)
pool(bytes32) returns (address) envfree => DISPATCHER(true)
fees(bytes32) returns (address) envfree => DISPATCHER(true)
tic(bytes32) returns (uint256) envfree
tau(bytes32) returns (uint256) envfree
culled(bytes32) returns (uint256) envfree
Expand Down Expand Up @@ -52,10 +54,11 @@ methods {
share.balanceOf(address) returns (uint256) envfree
share.totalSupply() returns (uint256) envfree
share.wards(address) returns (uint256) envfree
fees.target() returns (address) envfree
debt() returns (uint256) => DISPATCHER(true)
skim(bytes32, address) => DISPATCHER(true)
active() returns (bool) => DISPATCHER(true)
getTargetAssets(uint256) returns (uint256) => DISPATCHER(true)
getTargetAssets(bytes32,uint256) returns (uint256) => DISPATCHER(true)
assetBalance() returns (uint256) => DISPATCHER(true)
maxDeposit() returns (uint256) => DISPATCHER(true)
maxWithdraw() returns (uint256) => DISPATCHER(true)
Expand All @@ -67,6 +70,7 @@ methods {
balanceOf(address) returns (uint256) => DISPATCHER(true)
burn(address, uint256) => DISPATCHER(true)
mint(address, uint256) => DISPATCHER(true)
feesCollected(bytes32, uint256) => DISPATCHER(true)
}

definition WAD() returns uint256 = 10^18;
Expand Down Expand Up @@ -172,6 +176,7 @@ rule file_ilk_address(bytes32 ilk, bytes32 what, address data) {

assert(what == 0x706f6f6c00000000000000000000000000000000000000000000000000000000 => pool(ilk) == data, "file did not set pool as expected");
assert(what == 0x706c616e00000000000000000000000000000000000000000000000000000000 => plan(ilk) == data, "file did not set plan as expected");
assert(what == 0x6665657300000000000000000000000000000000000000000000000000000000 => fees(ilk) == data, "file did not set fees as expected");
}

rule file_ilk_address_revert(bytes32 ilk, bytes32 what, address data) {
Expand All @@ -187,7 +192,9 @@ rule file_ilk_address_revert(bytes32 ilk, bytes32 what, address data) {
bool revert2 = ward != 1;
bool revert3 = vatLive != 1;
bool revert4 = tic != 0;
bool revert5 = what != 0x706f6f6c00000000000000000000000000000000000000000000000000000000 && what != 0x706c616e00000000000000000000000000000000000000000000000000000000;
bool revert5 = what != 0x706f6f6c00000000000000000000000000000000000000000000000000000000 &&
what != 0x706c616e00000000000000000000000000000000000000000000000000000000 &&
what != 0x6665657300000000000000000000000000000000000000000000000000000000;

assert(revert1 => lastReverted, "revert1 failed");
assert(revert2 => lastReverted, "revert2 failed");
Expand All @@ -201,10 +208,11 @@ rule file_ilk_address_revert(bytes32 ilk, bytes32 what, address data) {

rule ilk_getters() {
bytes32 ilk;
address pool_; address plan_; uint256 tau; uint256 culled; uint256 tic;
pool_, plan_, tau, culled, tic = ilks(ilk);
address pool_; address plan_; address fees_; uint256 tau; uint256 culled; uint256 tic;
pool_, plan_, fees_, tau, culled, tic = ilks(ilk);
assert(pool_ == pool(ilk), "pool getter did not return ilk.pool");
assert(plan_ == plan(ilk), "plan getter did not return ilk.plan");
assert(fees_ == fees(ilk), "fees getter did not return ilk.fees");
assert(tau == tau(ilk), "tau getter did not return ilk.tau");
assert(culled == culled(ilk), "culled getter did not return ilk.culled");
assert(tic == tic(ilk), "tic getter did not return ilk.tic");
Expand All @@ -219,13 +227,16 @@ rule exec_normal(bytes32 ilk) {
require(daiJoin() == daiJoin);
require(plan(ilk) == plan);
require(pool(ilk) == pool);
require(fees(ilk) == fees);
require(vow != daiJoin);
require(daiJoin.dai() == dai);
require(daiJoin.vat() == vat);
require(plan.dai() == dai);
require(pool.hub() == currentContract);
require(pool.vat() == vat);
require(pool.dai() == dai);
require(fees.target() == vow);
require(vat.dai(fees) == 0);

uint256 tic = tic(ilk);
uint256 culled = culled(ilk);
Expand All @@ -246,7 +257,7 @@ rule exec_normal(bytes32 ilk) {
uint256 maxDeposit = pool.maxDeposit(e);
mathint maxWithdraw = min(to_mathint(pool.maxWithdraw(e)), safe_max());
uint256 assetsBefore = pool.assetBalance(e);
uint256 targetAssets = plan.getTargetAssets(e, assetsBefore);
uint256 targetAssets = plan.getTargetAssets(e, ilk, assetsBefore);
uint256 vatDaiVowBefore = vat.dai(vow);

require(vat.live() == 1);
Expand Down Expand Up @@ -511,6 +522,7 @@ rule exec_normal_revert(bytes32 ilk) {
require(daiJoin() == daiJoin);
require(plan(ilk) == plan);
require(pool(ilk) == pool);
require(fees(ilk) == fees);
require(vow != currentContract);
require(vow != daiJoin);
require(daiJoin.dai() == dai);
Expand All @@ -519,6 +531,8 @@ rule exec_normal_revert(bytes32 ilk) {
require(pool.hub() == currentContract);
require(pool.vat() == vat);
require(pool.dai() == dai);
require(fees.target() == vow);
require(vat.dai(fees) == 0);

uint256 locked = locked();
uint256 Line = vat.Line();
Expand Down Expand Up @@ -561,7 +575,7 @@ rule exec_normal_revert(bytes32 ilk) {
uint256 tic = tic(ilk);
bool active = plan.active(e);

uint256 targetAssets = plan.getTargetAssets(e, assets);
uint256 targetAssets = plan.getTargetAssets(e, ilk, assets);

mathint toUnwindAux = max(
max(
Expand Down Expand Up @@ -729,6 +743,7 @@ rule exec_ilk_culled(bytes32 ilk) {
require(daiJoin() == daiJoin);
require(plan(ilk) == plan);
require(pool(ilk) == pool);
require(fees(ilk) == fees);
require(vow != daiJoin);
require(daiJoin.dai() == dai);
require(daiJoin.vat() == vat);
Expand All @@ -751,7 +766,7 @@ rule exec_ilk_culled(bytes32 ilk) {

uint256 maxWithdraw = pool.maxWithdraw(e);
uint256 assetsBefore = pool.assetBalance(e);
uint256 targetAssets = plan.getTargetAssets(e, assetsBefore);
uint256 targetAssets = plan.getTargetAssets(e, ilk, assetsBefore);

require(vat.live() == 1);
require(inkBefore >= artBefore);
Expand Down Expand Up @@ -801,6 +816,7 @@ rule exec_ilk_culled_revert(bytes32 ilk) {
require(daiJoin() == daiJoin);
require(plan(ilk) == plan);
require(pool(ilk) == pool);
require(fees(ilk) == fees);
require(vow != daiJoin);
require(daiJoin.dai() == dai);
require(daiJoin.vat() == vat);
Expand Down Expand Up @@ -896,6 +912,7 @@ rule exec_vat_caged(bytes32 ilk) {
require(end() == end);
require(plan(ilk) == plan);
require(pool(ilk) == pool);
require(fees(ilk) == fees);
require(vow != daiJoin);
require(daiJoin.dai() == dai);
require(daiJoin.vat() == vat);
Expand All @@ -919,7 +936,7 @@ rule exec_vat_caged(bytes32 ilk) {

uint256 maxWithdraw = pool.maxWithdraw(e);
uint256 assetsBefore = pool.assetBalance(e);
uint256 targetAssets = plan.getTargetAssets(e, assetsBefore);
uint256 targetAssets = plan.getTargetAssets(e, ilk, assetsBefore);

require(vat.live() == 0);
require(end.tag(ilk) == RAY());
Expand Down Expand Up @@ -972,6 +989,7 @@ rule exec_vat_caged_revert(bytes32 ilk) {
require(end() == end);
require(plan(ilk) == plan);
require(pool(ilk) == pool);
require(fees(ilk) == fees);
require(vow != daiJoin);
require(daiJoin.dai() == dai);
require(daiJoin.vat() == vat);
Expand Down Expand Up @@ -1104,6 +1122,7 @@ rule exec_exec(bytes32 ilk) {
require(daiJoin() == daiJoin);
require(plan(ilk) == plan);
require(pool(ilk) == pool);
require(fees(ilk) == fees);
require(daiJoin.dai() == dai);
require(daiJoin.vat() == vat);
require(plan.dai() == dai);
Expand All @@ -1113,7 +1132,7 @@ rule exec_exec(bytes32 ilk) {

uint256 maxDeposit = pool.maxDeposit(e);
uint256 assetsBefore = pool.assetBalance(e);
uint256 targetAssets = plan.getTargetAssets(e, assetsBefore);
uint256 targetAssets = plan.getTargetAssets(e, ilk, assetsBefore);

require(maxDeposit > targetAssets - assetsBefore);
require(assetsBefore <= safe_max());
Expand Down
2 changes: 1 addition & 1 deletion certora/d3m/D3MTestPlan.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ contract D3MTestPlan is ID3MPlan {
return maxBar_;
}

function getTargetAssets(uint256 currentAssets) external override view returns (uint256) {
function getTargetAssets(bytes32, uint256 currentAssets) external override view returns (uint256) {
currentAssets;

return bar > 0 ? targetAssets : 0;
Expand Down
8 changes: 8 additions & 0 deletions certora/d3m/D3MTestPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ contract D3MTestPool is ID3MPool {
return _min(TokenMock(dai).balanceOf(share), assetBalance());
}

function liquidityAvailable() external view override returns (uint256) {
return TokenMock(dai).balanceOf(share);
}

function idleLiquidity() external view override returns (uint256) {
return TokenMock(dai).balanceOf(share);
}

function shareBalance() public view returns (uint256) {
return TokenMock(share).balanceOf(address(this));
}
Expand Down
13 changes: 7 additions & 6 deletions script/D3MCoreDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { MCD, DssInstance } from "dss-test/MCD.sol";
import { ScriptTools } from "dss-test/ScriptTools.sol";

import {
D3MDeploy,
D3MCoreInstance
D3MDeploy
} from "../src/deploy/D3MDeploy.sol";

contract D3MCoreDeployScript is Script {
Expand All @@ -37,7 +36,6 @@ contract D3MCoreDeployScript is Script {
DssInstance dss;

address admin;
D3MCoreInstance d3mCore;

function run() external {
config = ScriptTools.loadConfig(NAME);
Expand All @@ -46,15 +44,18 @@ contract D3MCoreDeployScript is Script {
admin = config.readAddress(".admin");

vm.startBroadcast();
d3mCore = D3MDeploy.deployCore(
address hub = D3MDeploy.deployHub(
msg.sender,
admin,
address(dss.daiJoin)
);
address mom = D3MDeploy.deployMom(
admin
);
vm.stopBroadcast();

ScriptTools.exportContract(NAME, "hub", d3mCore.hub);
ScriptTools.exportContract(NAME, "mom", d3mCore.mom);
ScriptTools.exportContract(NAME, "hub", hub);
ScriptTools.exportContract(NAME, "mom", mom);
}

}
18 changes: 7 additions & 11 deletions script/D3MCoreInit.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import { MCD, DssInstance } from "dss-test/MCD.sol";
import { ScriptTools } from "dss-test/ScriptTools.sol";

import {
D3MInit,
D3MCoreInstance
D3MInit
} from "../src/deploy/D3MInit.sol";

contract D3MCoreInitScript is Script {
Expand All @@ -37,22 +36,19 @@ contract D3MCoreInitScript is Script {
string dependencies;
DssInstance dss;

D3MCoreInstance d3mCore;

function run() external {
config = ScriptTools.loadConfig(NAME);
dependencies = ScriptTools.loadDependencies(NAME);
dss = MCD.loadFromChainlog(config.readAddress(".chainlog"));

d3mCore = D3MCoreInstance({
hub: dependencies.readAddress(".hub"),
mom: dependencies.readAddress(".mom")
});

vm.startBroadcast();
D3MInit.initCore(
D3MInit.initHub(
dss,
dependencies.readAddress(".hub")
);
D3MInit.initMom(
dss,
d3mCore
dependencies.readAddress(".mom")
);
vm.stopBroadcast();
}
Expand Down
14 changes: 14 additions & 0 deletions script/D3MDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ contract D3MDeployScript is Script {

string poolType;
string planType;
string feesType;
address admin;
address hub;
bytes32 ilk;
Expand All @@ -62,6 +63,7 @@ contract D3MDeployScript is Script {

poolType = config.readString(".poolType");
planType = config.readString(".planType");
feesType = config.readString(".feesType");
admin = config.readAddress(".admin");
hub = dependencies.eq("") ? dss.chainlog.getAddress("DIRECT_HUB") : dependencies.readAddress(".hub");
ilk = config.readString(".ilk").stringToBytes32();
Expand Down Expand Up @@ -138,10 +140,22 @@ contract D3MDeployScript is Script {
} else {
revert("Unknown plan type");
}

// Fees
if (planType.eq("forward")) {
d3m.fees = D3MDeploy.deployForwardFees(
address(dss.vat),
config.readAddress(".feesForwardTo")
);
} else {
revert("Unknown fee type");
}

vm.stopBroadcast();

ScriptTools.exportContract("pool", d3m.pool);
ScriptTools.exportContract("plan", d3m.plan);
ScriptTools.exportContract("fees", d3m.fees);
ScriptTools.exportContract("oracle", d3m.oracle);
}

Expand Down
1 change: 1 addition & 0 deletions script/D3MInit.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ contract D3MInitScript is Script {
d3m = D3MInstance({
pool: dependencies.readAddress(".pool"),
plan: dependencies.readAddress(".plan"),
fees: dependencies.readAddress(".fees"),
oracle: dependencies.readAddress(".oracle")
});
cfg = D3MCommonConfig({
Expand Down
Loading