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/nst"]
sunbreak1211 marked this conversation as resolved.
Show resolved Hide resolved
path = lib/nst
url = https://github.com/makerdao/nst
telome marked this conversation as resolved.
Show resolved Hide resolved
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/nst
Submodule nst added at 56e2dd
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-nst-no-supply-cap")) {
d3m.pool = D3MDeploy.deployAaveV3NSTNoSupplyCapTypePool(
msg.sender,
admin,
ilk,
hub,
config.readAddress(".nstJoin"),
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,
D3MAaveNSTPoolConfig,
D3MCompoundPoolConfig,
D3MAaveRateTargetPlanConfig,
D3MCompoundRateTargetPlanConfig,
D3MAavePoolLike,
D3MAaveNSTPoolLike,
D3MAaveRateTargetPlanLike,
D3MAaveBufferPlanLike,
D3MAaveBufferPlanConfig,
Expand Down Expand Up @@ -110,6 +112,21 @@ contract D3MInitScript is Script {
cfg,
aaveCfg
);
} else if (poolType.eq("aave-v3-nst-no-supply-cap")) {
D3MAaveNSTPoolConfig memory aaveCfg = D3MAaveNSTPoolConfig({
king: config.readAddress(".king"),
anst: D3MAaveNSTPoolLike(d3m.pool).anst(),
nstJoin: D3MAaveNSTPoolLike(d3m.pool).nstJoin(),
nst: D3MAaveNSTPoolLike(d3m.pool).nst(),
stableDebt: D3MAaveNSTPoolLike(d3m.pool).stableDebt(),
variableDebt: D3MAaveNSTPoolLike(d3m.pool).variableDebt()
});
D3MInit.initAaveNSTPool(
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-nst-no-supply-cap",
"planType": "operator",
"ilk": "DIRECT-SPARK-AAVE-NST",
"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 { D3MAaveV3NSTNoSupplyCapTypePool } from "../pools/D3MAaveV3NSTNoSupplyCapTypePool.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 deployAaveV3NSTNoSupplyCapTypePool(
address deployer,
address owner,
bytes32 ilk,
address hub,
address nstJoin,
address daiJoin,
address lendingPool
) internal returns (address pool) {
pool = address(new D3MAaveV3NSTNoSupplyCapTypePool(ilk, hub, nstJoin, 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 D3MAaveNSTPoolLike {
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 anst() external view returns (address);
function nstJoin() external view returns (address);
function nst() 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 D3MAaveNSTPoolConfig {
address king;
address anst;
address nstJoin;
address nst;
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 initAaveNSTPool(
DssInstance memory dss,
D3MInstance memory d3m,
D3MCommonConfig memory cfg,
D3MAaveNSTPoolConfig memory aaveCfg
) internal {
D3MAaveNSTPoolLike pool = D3MAaveNSTPoolLike(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.nstJoin() == aaveCfg.nstJoin, "Pool nstJoin mismatch");
require(pool.nst() == aaveCfg.nst, "Pool nst mismatch");
require(pool.daiJoin() == address(dss.daiJoin), "Pool daiJoin mismatch");
require(pool.dai() == address(dss.dai), "Pool dai mismatch");
require(pool.anst() == aaveCfg.anst, "Pool anst 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