-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e9eef8
commit fafea9d
Showing
24 changed files
with
8,680 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
archive/2024-09-13-DssSpell/dependencies/01-usds/UsdsInit.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// 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 { UsdsInstance } from "./UsdsInstance.sol"; | ||
|
||
interface UsdsLike { | ||
function rely(address) external; | ||
function version() external view returns (string memory); | ||
function getImplementation() external view returns (address); | ||
} | ||
|
||
interface UsdsJoinLike { | ||
function usds() external view returns (address); | ||
function vat() external view returns (address); | ||
} | ||
|
||
interface DaiUsdsLike { | ||
function daiJoin() external view returns (address); | ||
function usdsJoin() external view returns (address); | ||
} | ||
|
||
library UsdsInit { | ||
|
||
function init( | ||
DssInstance memory dss, | ||
UsdsInstance memory instance | ||
) internal { | ||
require(keccak256(bytes(UsdsLike(instance.usds).version())) == keccak256("1"), "UsdsInit/version-does-not-match"); | ||
require(UsdsLike(instance.usds).getImplementation() == instance.usdsImp, "UsdsInit/imp-does-not-match"); | ||
|
||
require(UsdsJoinLike(instance.usdsJoin).vat() == address(dss.vat), "UsdsInit/vat-does-not-match"); | ||
require(UsdsJoinLike(instance.usdsJoin).usds() == instance.usds, "UsdsInit/usds-does-not-match"); | ||
|
||
address daiJoin = dss.chainlog.getAddress("MCD_JOIN_DAI"); | ||
require(DaiUsdsLike(instance.daiUsds).daiJoin() == daiJoin, "UsdsInit/daiJoin-does-not-match"); | ||
require(DaiUsdsLike(instance.daiUsds).usdsJoin() == instance.usdsJoin, "UsdsInit/usdsJoin-does-not-match"); | ||
|
||
UsdsLike(instance.usds).rely(instance.usdsJoin); | ||
|
||
dss.chainlog.setAddress("USDS", instance.usds); | ||
dss.chainlog.setAddress("USDS_IMP", instance.usdsImp); | ||
dss.chainlog.setAddress("USDS_JOIN", instance.usdsJoin); | ||
dss.chainlog.setAddress("DAI_USDS", instance.daiUsds); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
archive/2024-09-13-DssSpell/dependencies/01-usds/UsdsInstance.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// 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; | ||
|
||
struct UsdsInstance { | ||
address usds; | ||
address usdsImp; | ||
address usdsJoin; | ||
address daiUsds; | ||
} |
71 changes: 71 additions & 0 deletions
71
archive/2024-09-13-DssSpell/dependencies/02-susds/SUsdsInit.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// 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 { SUsdsInstance } from "./SUsdsInstance.sol"; | ||
|
||
interface SUsdsLike { | ||
function version() external view returns (string memory); | ||
function getImplementation() external view returns (address); | ||
function usdsJoin() external view returns (address); | ||
function vat() external view returns (address); | ||
function usds() external view returns (address); | ||
function vow() external view returns (address); | ||
function file(bytes32, uint256) external; | ||
function drip() external returns (uint256); | ||
} | ||
|
||
interface UsdsJoinLike { | ||
function usds() external view returns (address); | ||
} | ||
|
||
struct SUsdsConfig { | ||
address usdsJoin; | ||
address usds; | ||
uint256 ssr; | ||
} | ||
|
||
library SUsdsInit { | ||
|
||
uint256 constant internal RAY = 10**27; | ||
uint256 constant internal RATES_ONE_HUNDRED_PCT = 1000000021979553151239153027; | ||
|
||
function init( | ||
DssInstance memory dss, | ||
SUsdsInstance memory instance, | ||
SUsdsConfig memory cfg | ||
) internal { | ||
require(keccak256(abi.encodePacked(SUsdsLike(instance.sUsds).version())) == keccak256(abi.encodePacked("1")), "SUsdsInit/version-does-not-match"); | ||
require(SUsdsLike(instance.sUsds).getImplementation() == instance.sUsdsImp, "SUsdsInit/imp-does-not-match"); | ||
|
||
require(SUsdsLike(instance.sUsds).vat() == address(dss.vat), "SUsdsInit/vat-does-not-match"); | ||
require(SUsdsLike(instance.sUsds).usdsJoin() == cfg.usdsJoin, "SUsdsInit/usdsJoin-does-not-match"); | ||
require(SUsdsLike(instance.sUsds).usds() == cfg.usds, "SUsdsInit/usds-does-not-match"); | ||
require(SUsdsLike(instance.sUsds).vow() == address(dss.vow), "SUsdsInit/vow-does-not-match"); | ||
|
||
require(cfg.ssr >= RAY && cfg.ssr <= RATES_ONE_HUNDRED_PCT, "SUsdsInit/ssr-out-of-boundaries"); | ||
|
||
dss.vat.rely(instance.sUsds); | ||
|
||
SUsdsLike(instance.sUsds).drip(); | ||
SUsdsLike(instance.sUsds).file("ssr", cfg.ssr); | ||
|
||
dss.chainlog.setAddress("SUSDS", instance.sUsds); | ||
dss.chainlog.setAddress("SUSDS_IMP", instance.sUsdsImp); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
archive/2024-09-13-DssSpell/dependencies/02-susds/SUsdsInstance.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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; | ||
|
||
struct SUsdsInstance { | ||
address sUsds; | ||
address sUsdsImp; | ||
} |
57 changes: 57 additions & 0 deletions
57
archive/2024-09-13-DssSpell/dependencies/03-sky/SkyInit.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// 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 { SkyInstance } from "./SkyInstance.sol"; | ||
|
||
interface SkyLike { | ||
function rely(address) external; | ||
} | ||
|
||
interface MkrSkyLike { | ||
function mkr() external view returns (address); | ||
function sky() external view returns (address); | ||
function rate() external view returns (uint256); | ||
} | ||
|
||
interface MkrLike { | ||
function authority() external view returns (address); | ||
} | ||
|
||
interface MkrAuthorityLike { | ||
function rely(address) external; | ||
} | ||
|
||
library SkyInit { | ||
function init( | ||
DssInstance memory dss, | ||
SkyInstance memory instance, | ||
uint256 rate | ||
) internal { | ||
address mkr = dss.chainlog.getAddress("MCD_GOV"); | ||
require(MkrSkyLike(instance.mkrSky).mkr() == mkr, "SkyInit/mkr-does-not-match"); | ||
require(MkrSkyLike(instance.mkrSky).sky() == instance.sky, "SkyInit/sky-does-not-match"); | ||
require(MkrSkyLike(instance.mkrSky).rate() == rate, "SkyInit/rate-does-not-match"); | ||
|
||
SkyLike(instance.sky).rely(instance.mkrSky); | ||
MkrAuthorityLike(MkrLike(mkr).authority()).rely(instance.mkrSky); | ||
|
||
dss.chainlog.setAddress("SKY", instance.sky); | ||
dss.chainlog.setAddress("MKR_SKY", instance.mkrSky); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
archive/2024-09-13-DssSpell/dependencies/03-sky/SkyInstance.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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; | ||
|
||
struct SkyInstance { | ||
address sky; | ||
address mkrSky; | ||
} |
97 changes: 97 additions & 0 deletions
97
archive/2024-09-13-DssSpell/dependencies/04-univ2-pool-migrator/UniV2PoolMigratorInit.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// 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"; | ||
|
||
interface GemLike { | ||
function balanceOf(address) external view returns (uint256); | ||
function totalSupply() external view returns (uint256); | ||
function approve(address, uint256) external; | ||
function transfer(address, uint256) external; | ||
} | ||
|
||
interface PoolLike { | ||
function mint(address) external; | ||
function burn(address) external; | ||
function getReserves() external view returns (uint112, uint112, uint32); | ||
} | ||
|
||
interface DaiUsdsLike { | ||
function daiToUsds(address, uint256) external; | ||
} | ||
|
||
interface MkrSkyLike { | ||
function mkrToSky(address, uint256) external; | ||
} | ||
|
||
interface PipLike { | ||
function read() external view returns (bytes32); | ||
function kiss(address) external; | ||
function diss(address) external; | ||
} | ||
|
||
library UniV2PoolMigratorInit { | ||
function init( | ||
DssInstance memory dss, | ||
address pairDaiMkr, | ||
address pairUsdsSky | ||
) internal { | ||
// Using pProxy instead of address(this) as otherwise won't work in tests, in real execution should be same address | ||
address pProxy = dss.chainlog.getAddress("MCD_PAUSE_PROXY"); | ||
|
||
require(GemLike(pairUsdsSky).totalSupply() == 0, "UniV2PoolMigratorInit/sanity-check-1-failed"); | ||
|
||
// Sanity check for Uniswap vs oracle price. This is completely unnecessary but acts as a separate safety layer. | ||
{ | ||
PipLike mkrPip = PipLike(dss.chainlog.getAddress("PIP_MKR")); | ||
mkrPip.kiss(pProxy); | ||
uint256 pipPrice = uint256(mkrPip.read()); // Assume par is 1 | ||
mkrPip.diss(pProxy); | ||
|
||
(uint256 daiReserve, uint256 mkrReserve, ) = PoolLike(pairDaiMkr).getReserves(); | ||
uint256 uniPrice = daiReserve * 1e18 / mkrReserve; | ||
|
||
require( | ||
uniPrice < pipPrice * 102 / 100 && uniPrice > pipPrice * 98 / 100, | ||
"UniV2PoolMigratorInit/sanity-check-2-failed" | ||
); | ||
} | ||
|
||
GemLike dai = GemLike(dss.chainlog.getAddress("MCD_DAI")); | ||
GemLike mkr = GemLike(dss.chainlog.getAddress("MCD_GOV")); | ||
|
||
uint256 daiAmtPrev = dai.balanceOf(pProxy); | ||
uint256 mkrAmtPrev = mkr.balanceOf(pProxy); | ||
|
||
GemLike(pairDaiMkr).transfer(pairDaiMkr, GemLike(pairDaiMkr).balanceOf(pProxy)); | ||
PoolLike(pairDaiMkr).burn(pProxy); | ||
|
||
DaiUsdsLike daiUsds = DaiUsdsLike(dss.chainlog.getAddress("DAI_USDS")); | ||
MkrSkyLike mkrSky = MkrSkyLike(dss.chainlog.getAddress("MKR_SKY")); | ||
|
||
uint256 daiAmt = dai.balanceOf(pProxy) - daiAmtPrev; | ||
uint256 mkrAmt = mkr.balanceOf(pProxy) - mkrAmtPrev; | ||
dai.approve(address(daiUsds), daiAmt); | ||
mkr.approve(address(mkrSky), mkrAmt); | ||
daiUsds.daiToUsds(pairUsdsSky, daiAmt); | ||
mkrSky.mkrToSky(pairUsdsSky, mkrAmt); | ||
PoolLike(pairUsdsSky).mint(pProxy); | ||
|
||
require(GemLike(pairUsdsSky).balanceOf(pProxy) > 0, "UniV2PoolMigratorInit/sanity-check-3-failed"); | ||
} | ||
} |
Oops, something went wrong.