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

Mainnet spell 2024-10-17 #433

Merged
merged 44 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
27c0d46
cleanup
SidestreamColdMelon Oct 6, 2024
b0124eb
add spell content
SidestreamColdMelon Oct 12, 2024
6b04459
update tests
SidestreamColdMelon Oct 13, 2024
270e94e
improve rwa tests
SidestreamColdMelon Oct 14, 2024
00d15ed
enable testRemoveChainlogValues
SidestreamColdMelon Oct 14, 2024
7c8ff4d
update Flapper instruction to match the sheet
SidestreamColdMelon Oct 14, 2024
f9e9b95
enable testOSMs
SidestreamColdMelon Oct 14, 2024
0e29a00
add testNewAuthorizations
SidestreamColdMelon Oct 14, 2024
db4bf00
improve global line reduction
SidestreamColdMelon Oct 14, 2024
ec8b821
test values related to split.farm
SidestreamColdMelon Oct 14, 2024
57c1a1a
update registry name and symbol
SidestreamColdMelon Oct 14, 2024
f7ea69f
test engine_fee and engine_farms via base tests
SidestreamColdMelon Oct 14, 2024
66a8053
add new spark spell
SidestreamColdMelon Oct 14, 2024
94d6a0f
update instructions
SidestreamColdMelon Oct 14, 2024
5699e49
add reasoning and authority urls
SidestreamColdMelon Oct 14, 2024
46de779
add exec doc url and hash
SidestreamColdMelon Oct 15, 2024
a86811f
add comments to tests
SidestreamColdMelon Oct 15, 2024
5e0a542
improve testNewAuthorizations error
SidestreamColdMelon Oct 15, 2024
26c2b16
add initial testLockstakeIlkIntegration
SidestreamColdMelon Oct 15, 2024
f82802f
updated testLockstakeIlkIntegration
SidestreamColdMelon Oct 15, 2024
a1bffc3
small fixes
SidestreamColdMelon Oct 15, 2024
7380cbd
test lockstake locking, drawing, barking, taking
SidestreamColdMelon Oct 16, 2024
f5dc839
test _checkLockstakeTake with delegation
SidestreamColdMelon Oct 16, 2024
0781353
cleanup tests
SidestreamColdMelon Oct 16, 2024
8eedd4b
move fee and farm checks from config.sol into integration
SidestreamColdMelon Oct 16, 2024
6739b29
add more end-to-end lockstake tests
SidestreamColdMelon Oct 16, 2024
bf353a7
remove LockstakeIlkParams.gem
SidestreamColdMelon Oct 16, 2024
cc8e347
cleanup checkLockstakeIlkIntegration
SidestreamColdMelon Oct 16, 2024
a311fb0
check farm parameters
SidestreamColdMelon Oct 16, 2024
fddf115
test lockstake farming and getting a reward
SidestreamColdMelon Oct 16, 2024
625a240
update comment above chainlog version bump
SidestreamColdMelon Oct 16, 2024
94b6ff9
address nits and typos
SidestreamColdMelon Oct 16, 2024
b2a6033
nit: update contract declaration pattern in config
SidestreamColdMelon Oct 17, 2024
dd5fd3a
use ExecLib address helpers
SidestreamColdMelon Oct 17, 2024
7ad8e67
cleanup lockstake base test
SidestreamColdMelon Oct 17, 2024
f904bd6
make lockstake test more robust
SidestreamColdMelon Oct 17, 2024
40d5caa
drip before wiping
SidestreamColdMelon Oct 17, 2024
224f53f
enable testMedianReaders
SidestreamColdMelon Oct 17, 2024
b8443d6
add testNewOsmMomAddition
SidestreamColdMelon Oct 17, 2024
f534d3f
fix fragile freeSky test
SidestreamColdMelon Oct 17, 2024
6d74b2d
update exec doc url and hash
SidestreamColdMelon Oct 17, 2024
95c68b5
update instructions in the spell
SidestreamColdMelon Oct 17, 2024
e61feb4
add deployed spell info
SidestreamColdMelon Oct 17, 2024
9cc3369
archived spell
SidestreamColdMelon Oct 17, 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
552 changes: 330 additions & 222 deletions src/DssSpell.sol

Large diffs are not rendered by default.

389 changes: 387 additions & 2 deletions src/DssSpell.t.base.sol

Large diffs are not rendered by default.

565 changes: 162 additions & 403 deletions src/DssSpell.t.sol

Large diffs are not rendered by default.

420 changes: 0 additions & 420 deletions src/dependencies/dss-direct-deposit/D3MInit.sol

This file was deleted.

211 changes: 211 additions & 0 deletions src/dependencies/dss-flappers/FlapperInit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
// SPDX-FileCopyrightText: © 2023 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity >=0.8.0;

import { DssInstance } from "dss-test/MCD.sol";
import { SplitterInstance } from "./SplitterInstance.sol";

interface FlapperUniV2Like {
function pip() external view returns (address);
function spotter() external view returns (address);
function usds() external view returns (address);
function gem() external view returns (address);
function receiver() external view returns (address);
function pair() external view returns (address);
function rely(address) external;
function file(bytes32, uint256) external;
function file(bytes32, address) external;
}

interface SplitterMomLike {
function splitter() external view returns (address);
function setAuthority(address) external;
}

interface OracleWrapperLike {
function pip() external view returns (address);
function divisor() external view returns (uint256);
}

interface PipLike {
function kiss(address) external;
}

interface PairLike {
function token0() external view returns (address);
function token1() external view returns (address);
}

interface UsdsJoinLike {
function dai() external view returns (address); // TODO: Replace when new join is ready by the new getter
}

interface SplitterLike {
function live() external view returns (uint256);
function vat() external view returns (address);
function usdsJoin() external view returns (address);
function hop() external view returns (uint256);
function rely(address) external;
function file(bytes32, uint256) external;
function file(bytes32, address) external;
}

interface FarmLike {
function rewardsToken() external view returns (address);
function setRewardsDistribution(address) external;
function setRewardsDuration(uint256) external;
}

struct FlapperUniV2Config {
uint256 want;
address pip;
address pair;
address usds;
address splitter;
bytes32 prevChainlogKey;
bytes32 chainlogKey;
}

struct FarmConfig {
address splitter;
address usdsJoin;
uint256 hop;
bytes32 prevChainlogKey;
bytes32 chainlogKey;
}

struct SplitterConfig {
uint256 hump;
uint256 bump;
uint256 hop;
uint256 burn;
address usdsJoin;
bytes32 splitterChainlogKey;
bytes32 prevMomChainlogKey;
bytes32 momChainlogKey;
}

library FlapperInit {
uint256 constant WAD = 10 ** 18;
uint256 constant RAY = 10 ** 27;

function initFlapperUniV2(
DssInstance memory dss,
address flapper_,
FlapperUniV2Config memory cfg
) internal {
FlapperUniV2Like flapper = FlapperUniV2Like(flapper_);

// Sanity checks
require(flapper.spotter() == address(dss.spotter), "Flapper spotter mismatch");
require(flapper.usds() == cfg.usds, "Flapper usds mismatch");
require(flapper.pair() == cfg.pair, "Flapper pair mismatch");
require(flapper.receiver() == dss.chainlog.getAddress("MCD_PAUSE_PROXY"), "Flapper receiver mismatch");

PairLike pair = PairLike(flapper.pair());
(address pairUsds, address pairGem) = pair.token0() == cfg.usds ? (pair.token0(), pair.token1())
: (pair.token1(), pair.token0());
require(pairUsds == cfg.usds, "Usds mismatch");
require(pairGem == flapper.gem(), "Gem mismatch");

require(cfg.want >= WAD * 90 / 100, "want too low");

flapper.file("want", cfg.want);
flapper.file("pip", cfg.pip);
flapper.rely(cfg.splitter);

SplitterLike(cfg.splitter).file("flapper", flapper_);

if (cfg.prevChainlogKey != bytes32(0)) dss.chainlog.removeAddress(cfg.prevChainlogKey);
dss.chainlog.setAddress(cfg.chainlogKey, flapper_);
}

function initDirectOracle(address flapper) internal {
PipLike(FlapperUniV2Like(flapper).pip()).kiss(flapper);
}

function initOracleWrapper(
DssInstance memory dss,
address wrapper_,
uint256 divisor,
bytes32 clKey
) internal {
OracleWrapperLike wrapper = OracleWrapperLike(wrapper_);
require(wrapper.divisor() == divisor, "Wrapper divisor mismatch"); // Sanity check
PipLike(wrapper.pip()).kiss(wrapper_);
dss.chainlog.setAddress(clKey, wrapper_);
}

function setFarm(
DssInstance memory dss,
address farm_,
FarmConfig memory cfg
) internal {
FarmLike farm = FarmLike(farm_);
SplitterLike splitter = SplitterLike(cfg.splitter);

require(farm.rewardsToken() == UsdsJoinLike(cfg.usdsJoin).dai(), "Farm rewards not usds");
// Staking token is checked in the Lockstake script

// The following two checks enforce the initSplitter function has to be called first
require(cfg.hop >= 5 minutes, "hop too low");
require(cfg.hop == splitter.hop(), "hop mismatch");

splitter.file("farm", farm_);

farm.setRewardsDistribution(cfg.splitter);
farm.setRewardsDuration(cfg.hop);

if (cfg.prevChainlogKey != bytes32(0)) dss.chainlog.removeAddress(cfg.prevChainlogKey);
dss.chainlog.setAddress(cfg.chainlogKey, farm_);
}

function initSplitter(
DssInstance memory dss,
SplitterInstance memory splitterInstance,
SplitterConfig memory cfg
) internal {
SplitterLike splitter = SplitterLike(splitterInstance.splitter);
SplitterMomLike mom = SplitterMomLike(splitterInstance.mom);

// Sanity checks
require(splitter.live() == 1, "Splitter not live");
require(splitter.vat() == address(dss.vat), "Splitter vat mismatch");
require(splitter.usdsJoin() == cfg.usdsJoin, "Splitter usdsJoin mismatch");
require(mom.splitter() == splitterInstance.splitter, "Mom splitter mismatch");

require(cfg.hump > 0, "hump too low");
require(cfg.bump % RAY == 0, "bump not multiple of RAY");
require(cfg.hop >= 5 minutes, "hop too low");
require(cfg.burn <= WAD, "burn too high");

splitter.file("hop", cfg.hop);
splitter.file("burn", cfg.burn);
splitter.rely(address(mom));
splitter.rely(address(dss.vow));

dss.vow.file("flapper", splitterInstance.splitter);
dss.vow.file("hump", cfg.hump);
dss.vow.file("bump", cfg.bump);

mom.setAuthority(dss.chainlog.getAddress("MCD_ADM"));

dss.chainlog.setAddress(cfg.splitterChainlogKey, splitterInstance.splitter);
if (cfg.prevMomChainlogKey != bytes32(0)) dss.chainlog.removeAddress(cfg.prevMomChainlogKey);
dss.chainlog.setAddress(cfg.momChainlogKey, address(mom));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: © 2022 Dai Foundation <www.daifoundation.org>
// SPDX-FileCopyrightText: © 2023 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
Expand All @@ -16,7 +16,7 @@

pragma solidity >=0.8.0;

struct D3MCoreInstance {
address hub;
struct SplitterInstance {
address splitter;
address mom;
}
Loading
Loading