Skip to content

Commit

Permalink
feat: add withdraw-and-swap paraswap adapter and add base market
Browse files Browse the repository at this point in the history
* setup adapters

* swap adapters task

* feat: transfer ownership of withdraw swap adatper

* feat: bump periphery contracts package

* feat: updated deploy scripts for new adapter

* fix: revert peer dep change

* fix: revert script change

* fix: contract name

* fix: Update version paraswap adapters

* fix: updated comment

* fix: add base market and fix dependencies (#51)

* hardhat verify

* fix: Fix base market config

* fix: Remove unneeded hardhat dependencies

* fix: Remove deprecate OZ defender dependency

---------

Co-authored-by: miguelmtz <36620902+miguelmtzinf@users.noreply.github.com>

* fix: Remove ethereum fork test files

---------

Co-authored-by: Mark Hinschberger <foodaka@users.noreply.github.com>
Co-authored-by: miguelmtzinf <miguelmtz.mail@gmail.com>
Co-authored-by: miguelmtz <36620902+miguelmtzinf@users.noreply.github.com>
  • Loading branch information
4 people authored Feb 27, 2024
1 parent 5c95642 commit 954a60b
Show file tree
Hide file tree
Showing 17 changed files with 2,052 additions and 711 deletions.
12 changes: 9 additions & 3 deletions deploy/03_periphery_post/04_paraswap_adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { COMMON_DEPLOY_PARAMS } from "../../helpers/env";
import {
ConfigNames,
eNetwork,
GOVERNANCE_BRIDGE_EXECUTOR,
loadPoolConfig,
POOL_ADDRESSES_PROVIDER_ID,
POOL_ADMIN,
Expand All @@ -19,7 +20,6 @@ const func: DeployFunction = async function ({
}: HardhatRuntimeEnvironment) {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const network = (
process.env.FORK ? process.env.FORK : hre.network.name
) as eNetwork;
Expand All @@ -32,15 +32,15 @@ const func: DeployFunction = async function ({

if (!paraswapAugustusRegistry) {
console.log(
"[WARNING] Skipping the deployment of the Paraswap Liquidity Swap and Repay adapters due missing 'ParaswapRegistry' address at pool configuration."
"[WARNING] Skipping the deployment of the Paraswap adapters due missing 'ParaswapRegistry' address at pool configuration."
);
return;
}

const { address: addressesProvider } = await deployments.get(
POOL_ADDRESSES_PROVIDER_ID
);
const poolAdmin = POOL_ADMIN[network];
const poolAdmin = GOVERNANCE_BRIDGE_EXECUTOR[network] || POOL_ADMIN[network];

await deploy("ParaSwapLiquiditySwapAdapter", {
from: deployer,
Expand All @@ -54,6 +54,12 @@ const func: DeployFunction = async function ({
args: [addressesProvider, paraswapAugustusRegistry, poolAdmin],
});

await deploy("ParaSwapWithdrawSwapAdapter", {
from: deployer,
...COMMON_DEPLOY_PARAMS,
args: [addressesProvider, paraswapAugustusRegistry, poolAdmin],
});

return true;
};

Expand Down
21 changes: 19 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
eHarmonyNetwork,
eOptimismNetwork,
ePolygonNetwork,
eTenderly,
eBaseNetwork,
} from "./helpers/types";
import { DEFAULT_NAMED_ACCOUNTS } from "./helpers/constants";

Expand All @@ -23,6 +23,7 @@ import "hardhat-deploy";
import "hardhat-contract-sizer";
import "hardhat-dependency-compiler";
import "@nomicfoundation/hardhat-chai-matchers";
import "@nomiclabs/hardhat-etherscan";

const SKIP_LOAD = process.env.SKIP_LOAD === "true";
const TASK_FOLDERS = ["misc", "market-registry"];
Expand Down Expand Up @@ -65,7 +66,7 @@ export default {
url: "http://127.0.0.1:8545",
...hardhatNetworkSettings,
},
tenderly: getCommonNetworkConfig("tenderly", 3030),
tenderly: getCommonNetworkConfig("tenderly", 1),
main: getCommonNetworkConfig(eEthereumNetwork.main, 1),
kovan: getCommonNetworkConfig(eEthereumNetwork.kovan, 42),
rinkeby: getCommonNetworkConfig(eEthereumNetwork.rinkeby, 4),
Expand Down Expand Up @@ -121,6 +122,11 @@ export default {
eArbitrumNetwork.goerliNitro,
421613
),
[eBaseNetwork.base]: getCommonNetworkConfig(eBaseNetwork.base, 8453),
[eBaseNetwork.baseGoerli]: getCommonNetworkConfig(
eBaseNetwork.baseGoerli,
84531
),
},
namedAccounts: {
...DEFAULT_NAMED_ACCOUNTS,
Expand Down Expand Up @@ -191,6 +197,7 @@ export default {
"@aave/periphery-v3/contracts/treasury/AaveEcosystemReserveController.sol",
"@aave/periphery-v3/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol",
"@aave/periphery-v3/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol",
"@aave/periphery-v3/contracts/adapters/paraswap/ParaSwapWithdrawSwapAdapter.sol",
"@aave/safety-module/contracts/stake/StakedAave.sol",
"@aave/safety-module/contracts/stake/StakedAaveV2.sol",
"@aave/safety-module/contracts/proposals/extend-stkaave-distribution/StakedTokenV2Rev3.sol",
Expand All @@ -201,5 +208,15 @@ export default {
: undefined,
etherscan: {
apiKey: ETHERSCAN_KEY,
customChains: [
{
network: eBaseNetwork.base,
chainId: 8453,
urls: {
apiURL: "https://api.basescan.org/api",
browserURL: "https://basescan.org/",
},
},
],
},
};
7 changes: 7 additions & 0 deletions helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { parseEther, parseUnits } from "ethers/lib/utils";
import {
eArbitrumNetwork,
eAvalancheNetwork,
eBaseNetwork,
eEthereumNetwork,
eFantomNetwork,
eHarmonyNetwork,
Expand Down Expand Up @@ -75,6 +76,7 @@ export const MOCK_CHAINLINK_AGGREGATORS_PRICES: { [key: string]: string } = {
AGEUR: parseUnits("1.126", 8).toString(),
JEUR: parseUnits("1.126", 8).toString(),
DPI: parseUnits("149", 8).toString(),
CBETH: parseUnits("4000", 8).toString(),
};

export const chainlinkAggregatorProxy: Record<string, string> = {
Expand Down Expand Up @@ -137,6 +139,9 @@ export const POOL_ADMIN: Record<string, string> = {
[eOptimismNetwork.main]: "0xE50c8C619d05ff98b22Adf991F17602C774F785c",
[ePolygonNetwork.polygon]: "0xdc9A35B16DB4e126cFeDC41322b3a36454B1F772",
[eEthereumNetwork.main]: ETHEREUM_SHORT_EXECUTOR,
[eBaseNetwork.base]: "0xA9F30e6ED4098e9439B2ac8aEA2d3fc26BcEbb45",
[eBaseNetwork.baseGoerli]: "0xA9F30e6ED4098e9439B2ac8aEA2d3fc26BcEbb45",
[eEthereumNetwork.tenderly]: ETHEREUM_SHORT_EXECUTOR,
};

export const EMERGENCY_ADMIN: Record<string, string> = {
Expand Down Expand Up @@ -181,6 +186,8 @@ export const DEFAULT_NAMED_ACCOUNTS = {

export const GOVERNANCE_BRIDGE_EXECUTOR: { [key: string]: string } = {
[ePolygonNetwork.polygon]: "0xdc9A35B16DB4e126cFeDC41322b3a36454B1F772",
[eOptimismNetwork.main]: "0x7d9103572bE58FfE99dc390E8246f02dcAe6f611",
[eArbitrumNetwork.arbitrum]: "0x7d9103572bE58FfE99dc390E8246f02dcAe6f611",
};

export const MULTISIG_ADDRESS: { [key: string]: string } = {
Expand Down
9 changes: 9 additions & 0 deletions helpers/hardhat-config-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
eAvalancheNetwork,
eFantomNetwork,
eOptimismNetwork,
eBaseNetwork,
} from "./types";

require("dotenv").config();
Expand Down Expand Up @@ -47,6 +48,8 @@ export const getAlchemyKey = (net: eNetwork) => {
return process.env.GOERLI_ALCHEMY_KEY || ALCHEMY_KEY;
case eEthereumNetwork.sepolia:
return process.env.SEPOLIA_ALCHEMY_KEY || ALCHEMY_KEY;
case eBaseNetwork.base:
return process.env.BASE_ALCHEMY_KEY || ALCHEMY_KEY;
default:
return ALCHEMY_KEY;
}
Expand Down Expand Up @@ -91,6 +94,10 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
eEthereumNetwork.sepolia
)}`,
[eArbitrumNetwork.goerliNitro]: `https://goerli-rollup.arbitrum.io/rpc`,
[eBaseNetwork.baseGoerli]: `https://goerli.base.org`,
[eBaseNetwork.base]: `https://base-mainnet.g.alchemy.com/v2/${getAlchemyKey(
eBaseNetwork.base
)}`,
};

export const LIVE_NETWORKS: iParamsPerNetwork<boolean> = {
Expand All @@ -101,10 +108,12 @@ export const LIVE_NETWORKS: iParamsPerNetwork<boolean> = {
[eAvalancheNetwork.avalanche]: true,
[eFantomNetwork.main]: true,
[eOptimismNetwork.main]: true,
[eBaseNetwork.base]: true,
};

const GAS_PRICE_PER_NET: iParamsPerNetwork<string | number> = {
[eArbitrumNetwork.goerliNitro]: 100000001,
[eBaseNetwork.baseGoerli]: 8000000000,
};

export const buildForkConfig = ():
Expand Down
2 changes: 1 addition & 1 deletion helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export * from "./utilities/signer";
export * from "../markets/aave/commons";
export * from "../markets/aave/rateStrategies";
export * from "../markets/aave/reservesConfigs";
export * from "../tasks/market-registry/market-registry:add";
export * from "../tasks/market-registry/market-registry-add";
export * from "../tasks/misc/deploy-ui-helpers";
export * from "../tasks/misc/deploy-UiIncentiveDataProvider";
export * from "../tasks/misc/deploy-UiPoolDataProvider";
Expand Down
5 changes: 5 additions & 0 deletions helpers/market-config-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import FantomMarket from "../markets/fantom";
import PolygonMarket from "../markets/polygon";
import OptimisticConfig from "../markets/optimistic";
import ArbitrumConfig from "../markets/arbitrum";
import BaseConfig from "../markets/base";
import { isValidAddress } from "./utilities/utils";
import { AaveProtocolDataProvider } from "../typechain";
import {
Expand Down Expand Up @@ -49,6 +50,8 @@ export enum ConfigNames {
Optimistic = "Optimistic",
Arbitrum = "Arbitrum",
Ethereum = "Ethereum",
Base = "Base",
baseGoerli = "base-goerli",
}

export const getParamPerNetwork = <T>(
Expand Down Expand Up @@ -114,6 +117,8 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
return ArbitrumConfig;
case ConfigNames.Ethereum:
return EthereumV3Config;
case ConfigNames.Base:
return BaseConfig;
default:
throw new Error(
`Unsupported pool configuration: ${configName} is not one of the supported configs ${Object.values(
Expand Down
8 changes: 7 additions & 1 deletion helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export type eNetwork =
| eHarmonyNetwork
| eFantomNetwork
| eOptimismNetwork
| eTenderlyNetwork;
| eTenderlyNetwork
| eBaseNetwork;

type eTenderlyNetwork = "tenderly";

Expand All @@ -44,6 +45,11 @@ export enum eEthereumNetwork {
sepolia = "sepolia",
}

export enum eBaseNetwork {
base = "base",
baseGoerli = "base-goerli",
}

export enum ePolygonNetwork {
polygon = "polygon",
mumbai = "mumbai",
Expand Down
2 changes: 1 addition & 1 deletion helpers/utilities/defender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { formatEther } from "@ethersproject/units";
import {
DefenderRelaySigner,
DefenderRelayProvider,
} from "defender-relay-client/lib/ethers";
} from "@openzeppelin/defender-relay-client/lib/ethers";
import { Signer } from "ethers";
import { impersonateAddresses, usingTenderly } from "./fork";

Expand Down
7 changes: 7 additions & 0 deletions markets/aave/commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
eOptimismNetwork,
ePolygonNetwork,
TransferStrategy,
eBaseNetwork,
} from "./../../helpers/types";
import { ZERO_ADDRESS } from "../../helpers/constants";
import {
Expand Down Expand Up @@ -158,13 +159,19 @@ export const CommonsConfig: ICommonConfiguration = {
[eArbitrumNetwork.arbitrumTestnet]: true,
[eOptimismNetwork.main]: true,
[eOptimismNetwork.testnet]: true,
[eBaseNetwork.base]: true,
[eBaseNetwork.baseGoerli]: true,
},
ParaswapRegistry: {
[eEthereumNetwork.main]: "0xa68bEA62Dc4034A689AA0F58A76681433caCa663",
[ePolygonNetwork.polygon]: "0xca35a4866747Ff7A604EF7a2A7F246bb870f3ca1",
[eAvalancheNetwork.avalanche]: "0xfD1E5821F07F1aF812bB7F3102Bfd9fFb279513a",
[eFantomNetwork.main]: "0x161383b5dAFc1cc05Ec058e5B0b0703BA175bdA6",
[eArbitrumNetwork.arbitrum]: "0xdC6E2b14260F972ad4e5a31c68294Fba7E720701",
[eBaseNetwork.base]: "0x7e31b336f9e8ba52ba3c4ac861b033ba90900bb3",
[eBaseNetwork.baseGoerli]: "0x7e31b336f9e8ba52ba3c4ac861b033ba90900bb3",
[eEthereumNetwork.tenderly]: "0xa68bEA62Dc4034A689AA0F58A76681433caCa663",
[eOptimismNetwork.main]: "0x6e7bE86000dF697facF4396efD2aE2C322165dC3",
},
FlashLoanPremiums: {
total: 0.0005e4,
Expand Down
18 changes: 18 additions & 0 deletions markets/aave/reservesConfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ export const strategyWETH: IReserveParams = {
borrowableIsolation: false,
};

export const strategyCBETH: IReserveParams = {
strategy: rateStrategyVolatileOne,
baseLTVAsCollateral: "8000",
liquidationThreshold: "8250",
liquidationBonus: "10500",
liquidationProtocolFee: "1000",
borrowingEnabled: true,
stableBorrowRateEnabled: false,
flashLoanEnabled: true,
reserveDecimals: "18",
aTokenImpl: eContractid.AToken,
reserveFactor: "1000",
supplyCap: "0",
borrowCap: "0",
debtCeiling: "0",
borrowableIsolation: false,
};

export const strategyLINK: IReserveParams = {
strategy: rateStrategyVolatileOne,
baseLTVAsCollateral: "7000",
Expand Down
45 changes: 45 additions & 0 deletions markets/base/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { eBaseNetwork, IAaveConfiguration } from "./../../helpers/types";
import AaveMarket from "../aave";
import { ZERO_ADDRESS } from "../../helpers";
import {
strategyUSDC,
strategyWETH,
strategyCBETH,
} from "../aave/reservesConfigs";

export const BaseConfig: IAaveConfiguration = {
...AaveMarket,
MarketId: "Base Aave Market",
ATokenNamePrefix: "Base",
StableDebtTokenNamePrefix: "Base",
VariableDebtTokenNamePrefix: "Base",
SymbolPrefix: "Base",
ProviderId: 37,
ReservesConfig: {
USDC: strategyUSDC,
WETH: strategyWETH,
CBETH: strategyCBETH,
},
ReserveAssets: {
[eBaseNetwork.base]: {
USDC: "0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca", // usdbc
WETH: "0x4200000000000000000000000000000000000006",
CBETH: "0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22",
},
[eBaseNetwork.baseGoerli]: {
USDC: ZERO_ADDRESS,
WETH: ZERO_ADDRESS,
CBETH: ZERO_ADDRESS,
},
},
EModes: {},
ChainlinkAggregator: {
[eBaseNetwork.base]: {
USDC: "0x7e860098f58bbfc8648a4311b374b1d669a2bc6b",
WETH: "0x71041dddad3595f9ced3dccfbe3d1f4b0a16bb70",
CBETH: "0xd7818272b9e248357d13057aab0b417af31e817d",
},
},
};

export default BaseConfig;
Loading

0 comments on commit 954a60b

Please sign in to comment.