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

Add aave pool adapter for usds #124

Merged
merged 16 commits into from
Aug 28, 2024
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
[submodule "lib/usds"]
path = lib/usds
url = https://github.com/makerdao/usds
3 changes: 1 addition & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[profile.default]
solc_version = '0.8.14'
verbosity = 3
solc_version = '0.8.21'
optimizer = true
optimizer_runs = 200

Expand Down
1 change: 1 addition & 0 deletions lib/usds
Submodule usds added at cfd4ac
10 changes: 10 additions & 0 deletions script/D3MDeploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ contract D3MDeployScript is Script {
address(dss.dai),
config.readAddress(".lendingPool")
);
} else if (poolType.eq("aave-v3-usds-no-supply-cap")) {
d3m.pool = D3MDeploy.deployAaveV3USDSNoSupplyCapTypePool(
msg.sender,
admin,
ilk,
hub,
config.readAddress(".usdsJoin"),
address(dss.daiJoin),
config.readAddress(".lendingPool")
);
} else if (poolType.eq("compound-v2")) {
d3m.pool = D3MDeploy.deployCompoundV2TypePool(
msg.sender,
Expand Down
17 changes: 17 additions & 0 deletions script/D3MInit.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ import {
D3MInstance,
D3MCommonConfig,
D3MAavePoolConfig,
D3MAaveUSDSPoolConfig,
D3MCompoundPoolConfig,
D3MAaveRateTargetPlanConfig,
D3MCompoundRateTargetPlanConfig,
D3MAavePoolLike,
D3MAaveUSDSPoolLike,
D3MAaveRateTargetPlanLike,
D3MAaveBufferPlanLike,
D3MAaveBufferPlanConfig,
Expand Down Expand Up @@ -110,6 +112,21 @@ contract D3MInitScript is Script {
cfg,
aaveCfg
);
} else if (poolType.eq("aave-v3-usds-no-supply-cap")) {
D3MAaveUSDSPoolConfig memory aaveCfg = D3MAaveUSDSPoolConfig({
king: config.readAddress(".king"),
ausds: D3MAaveUSDSPoolLike(d3m.pool).ausds(),
usdsJoin: D3MAaveUSDSPoolLike(d3m.pool).usdsJoin(),
usds: D3MAaveUSDSPoolLike(d3m.pool).usds(),
stableDebt: D3MAaveUSDSPoolLike(d3m.pool).stableDebt(),
variableDebt: D3MAaveUSDSPoolLike(d3m.pool).variableDebt()
});
D3MInit.initAaveUSDSPool(
dss,
d3m,
cfg,
aaveCfg
);
} else if (poolType.eq("compound-v2")) {
D3MCompoundPoolConfig memory compoundCfg = D3MCompoundPoolConfig({
king: config.readAddress(".king"),
Expand Down
15 changes: 15 additions & 0 deletions script/input/1/template-aave-v3-lido.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"chainlog": "0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F",
"admin": "0xBE8E3e3618f7474F8cB1d074A26afFef007E98FB",
"poolType": "aave-v3-usds-no-supply-cap",
"planType": "operator",
"ilk": "DIRECT-SPARK-AAVE-USDS",
"existingIlk": false,
"maxLine": 100000000,
"gap": 100000000,
"ttl": 86400,
"tau": 604800,
"lendingPool": "0x4e033931ad43597d96D6bcc25c280717730B58B1",
"king": "0xBE8E3e3618f7474F8cB1d074A26afFef007E98FB",
"operator": "0x298b375f24CeDb45e936D7e21d6Eb05e344adFb5"
}
15 changes: 15 additions & 0 deletions src/deploy/D3MDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { D3MAaveV2TypeRateTargetPlan } from "../plans/D3MAaveV2TypeRateTargetPla
import { D3MAaveTypeBufferPlan } from "../plans/D3MAaveTypeBufferPlan.sol";
import { D3MAaveV2TypePool } from "../pools/D3MAaveV2TypePool.sol";
import { D3MAaveV3NoSupplyCapTypePool } from "../pools/D3MAaveV3NoSupplyCapTypePool.sol";
import { D3MAaveV3USDSNoSupplyCapTypePool } from "../pools/D3MAaveV3USDSNoSupplyCapTypePool.sol";
import { D3MCompoundV2TypeRateTargetPlan } from "../plans/D3MCompoundV2TypeRateTargetPlan.sol";
import { D3MCompoundV2TypePool } from "../pools/D3MCompoundV2TypePool.sol";
import { D3M4626TypePool } from "../pools/D3M4626TypePool.sol";
Expand Down Expand Up @@ -86,6 +87,20 @@ library D3MDeploy {
ScriptTools.switchOwner(pool, deployer, owner);
}

function deployAaveV3USDSNoSupplyCapTypePool(
address deployer,
address owner,
bytes32 ilk,
address hub,
address usdsJoin,
address daiJoin,
address lendingPool
) internal returns (address pool) {
pool = address(new D3MAaveV3USDSNoSupplyCapTypePool(ilk, hub, usdsJoin, daiJoin, lendingPool));

ScriptTools.switchOwner(pool, deployer, owner);
}

function deployCompoundV2TypePool(
address deployer,
address owner,
Expand Down
46 changes: 46 additions & 0 deletions src/deploy/D3MInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ interface D3MAavePoolLike {
function variableDebt() external view returns (address);
}

interface D3MAaveUSDSPoolLike {
function hub() external view returns (address);
function dai() external view returns (address);
function ilk() external view returns (bytes32);
function vat() external view returns (address);
function file(bytes32, address) external;
function ausds() external view returns (address);
function usdsJoin() external view returns (address);
function usds() external view returns (address);
function daiJoin() external view returns (address);
function stableDebt() external view returns (address);
function variableDebt() external view returns (address);
}

interface D3MAaveRateTargetPlanLike {
function rely(address) external;
function file(bytes32, uint256) external;
Expand Down Expand Up @@ -132,6 +146,15 @@ struct D3MAavePoolConfig {
address variableDebt;
}

struct D3MAaveUSDSPoolConfig {
address king;
address ausds;
address usdsJoin;
address usds;
address stableDebt;
address variableDebt;
}

struct D3MAaveRateTargetPlanConfig {
uint256 bar;
address adai;
Expand Down Expand Up @@ -275,6 +298,29 @@ library D3MInit {
pool.file("king", aaveCfg.king);
}

function initAaveUSDSPool(
DssInstance memory dss,
D3MInstance memory d3m,
D3MCommonConfig memory cfg,
D3MAaveUSDSPoolConfig memory aaveCfg
) internal {
D3MAaveUSDSPoolLike pool = D3MAaveUSDSPoolLike(d3m.pool);

// Sanity checks
require(pool.hub() == cfg.hub, "Pool hub mismatch");
require(pool.ilk() == cfg.ilk, "Pool ilk mismatch");
require(pool.vat() == address(dss.vat), "Pool vat mismatch");
require(pool.usdsJoin() == aaveCfg.usdsJoin, "Pool usdsJoin mismatch");
require(pool.usds() == aaveCfg.usds, "Pool usds mismatch");
require(pool.daiJoin() == address(dss.daiJoin), "Pool daiJoin mismatch");
require(pool.dai() == address(dss.dai), "Pool dai mismatch");
require(pool.ausds() == aaveCfg.ausds, "Pool ausds mismatch");
require(pool.stableDebt() == aaveCfg.stableDebt, "Pool stableDebt mismatch");
require(pool.variableDebt() == aaveCfg.variableDebt, "Pool variableDebt mismatch");

pool.file("king", aaveCfg.king);
}

function initCompoundPool(
DssInstance memory dss,
D3MInstance memory d3m,
Expand Down
Loading
Loading