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

Feature/renzo #6

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/run-scenarios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
bases: [ development, mainnet, mainnet-weth, goerli, goerli-weth, sepolia-usdc, sepolia-weth, fuji, mumbai, polygon, arbitrum-usdc.e, arbitrum-usdc, arbitrum-goerli-usdc, arbitrum-goerli-usdc.e, base-usdbc, base-weth, base-usdc, base-goerli, base-goerli-weth, linea-goerli, scroll-goerli, scroll-usdc]
bases: [ development, mainnet, mainnet-weth, mainnet-weth-lrt, goerli, goerli-weth, sepolia-usdc, sepolia-weth, fuji, mumbai, polygon, arbitrum-usdc.e, arbitrum-usdc, arbitrum-goerli-usdc, arbitrum-goerli-usdc.e, base-usdbc, base-weth, base-usdc, base-goerli, base-goerli-weth, linea-goerli, scroll-goerli, scroll-usdc]
name: Run scenarios
env:
ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }}
Expand Down
39 changes: 39 additions & 0 deletions deployments/mainnet/weth-lrt/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "Compound WETH-LRT",
"symbol": "cWETH-LRTv3",
"baseToken": "WETH",
"baseTokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"borrowMin": "0.1e18",
"pauseGuardian": "0xbbf3f1421d886e9b2c5d716b5192ac998af2012c",
"storeFrontPriceFactor": 0.6,
"targetReserves": "10000e18",
"governor": "0x6d903f6003cca6255d85cca4d3b5e5146dc33925",
"rates": {
"supplyKink": 0.9,
"supplySlopeLow": 0.02,
"supplySlopeHigh": 1,
"supplyBase": 0,
"borrowKink": 0.9,
"borrowSlopeLow": 0.0235,
"borrowSlopeHigh": 1,
"borrowBase": 0.005
},
"tracking": {
"indexScale": "1e15",
"baseSupplySpeed": "0e15",
"baseBorrowSpeed": "0e15",
"baseMinForRewards": "1000e18"
},
"rewardTokenAddress": "0xc00e94cb662c3520282e6f5717214004a7f26888",
"assets": {
"ezETH": {
"address": "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
"decimals": "18",
"priceFeed": "0x636A000262F6aA9e1F094ABF0aD8f645C44f641C",
"borrowCF": 0.8,
"liquidateCF": 0.85,
"liquidationFactor": 0.9,
"supplyCap": "0e18"
}
}
}
46 changes: 46 additions & 0 deletions deployments/mainnet/weth-lrt/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Deployed, DeploymentManager } from '../../../plugins/deployment_manager';
import { DeploySpec, deployComet, exp } from '../../../src/deploy';

const MAINNET_TIMELOCK = '0x6d903f6003cca6255d85cca4d3b5e5146dc33925';

export default async function deploy(deploymentManager: DeploymentManager, deploySpec: DeploySpec): Promise<Deployed> {
const ezETH = await deploymentManager.existing('ezETH', '0xbf5495Efe5DB9ce00f80364C8B423567e58d2110');
const WETH = await deploymentManager.existing('WETH', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2');

const wethConstantPriceFeed = await deploymentManager.deploy(
'WETH:priceFeed',
'pricefeeds/ConstantPriceFeed.sol',
[
8, // decimals
exp(1, 8) // constantPrice
]
);

// Deploy scaling price feed for ezETH
const ezETHScalingPriceFeed = await deploymentManager.deploy(
'ezETH:priceFeed',
'pricefeeds/ScalingPriceFeed.sol',
[
'0x636A000262F6aA9e1F094ABF0aD8f645C44f641C', // ezETH / ETH price feed
8 // decimals
]
);

const cometAdmin = await deploymentManager.fromDep('cometAdmin', 'mainnet', 'usdc');
const cometFactory = await deploymentManager.fromDep('cometFactory', 'mainnet', 'usdc');
const $configuratorImpl = await deploymentManager.fromDep('configurator:implementation', 'mainnet', 'usdc');
const configurator = await deploymentManager.fromDep('configurator', 'mainnet', 'usdc');
const rewards = await deploymentManager.fromDep('rewards', 'mainnet', 'usdc');
const bulker = await deploymentManager.fromDep('bulker', 'mainnet', 'usdc'); // 0xa397a8C2086C554B531c02E29f3291c9704B00c7
const localTimelock = await deploymentManager.fromDep('timelock', 'mainnet', 'usdc');

await deploymentManager.hre.network.provider.request({
method: "hardhat_impersonateAccount",
params: [MAINNET_TIMELOCK],
});
const adminSigner = await deploymentManager.hre.ethers.getSigner(MAINNET_TIMELOCK);
// Deploy all Comet-related contracts
const deployed = await deployComet(deploymentManager, deploySpec, {}, adminSigner);

return { ...deployed, bulker };
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager';
import { migration } from '../../../../plugins/deployment_manager/Migration';

export default migration('1712610251_configurate_and_ens', {
prepare: async (deploymentManager: DeploymentManager) => {
return {};
},

enact: async (deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager) => {

},

async enacted(deploymentManager: DeploymentManager): Promise<boolean> {
return true;
},

async verify(deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager) {
}
});
16 changes: 16 additions & 0 deletions deployments/mainnet/weth-lrt/relations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { RelationConfigMap } from '../../../plugins/deployment_manager/RelationConfig';
import baseRelationConfig from '../../relations';

console.log("LRT")

export default {
...baseRelationConfig,
TransparentUpgradeableProxy: {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc',
}
}
}
};
1 change: 1 addition & 0 deletions deployments/mainnet/weth-lrt/roots.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
9 changes: 8 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import sepoliaWethRelationConfigMap from './deployments/sepolia/weth/relations';
import mumbaiRelationConfigMap from './deployments/mumbai/usdc/relations';
import mainnetRelationConfigMap from './deployments/mainnet/usdc/relations';
import mainnetWethRelationConfigMap from './deployments/mainnet/weth/relations';
import mainnetWethLrtRelationConfigMap from './deployments/mainnet/weth-lrt/relations';
import polygonRelationConfigMap from './deployments/polygon/usdc/relations';
import arbitrumBridgedUsdcRelationConfigMap from './deployments/arbitrum/usdc.e/relations';
import arbitrumNativeUsdcRelationConfigMap from './deployments/arbitrum/usdc/relations';
Expand Down Expand Up @@ -337,7 +338,8 @@ const config: HardhatUserConfig = {
},
mainnet: {
usdc: mainnetRelationConfigMap,
weth: mainnetWethRelationConfigMap
weth: mainnetWethRelationConfigMap,
'weth-lrt': mainnetWethLrtRelationConfigMap
},
polygon: {
usdc: polygonRelationConfigMap
Expand Down Expand Up @@ -384,6 +386,11 @@ const config: HardhatUserConfig = {
network: 'mainnet',
deployment: 'weth',
},
{
name: 'mainnet-weth-lrt',
network: 'mainnet',
deployment: 'weth-lrt',
},
{
name: 'development',
network: 'hardhat',
Expand Down
21 changes: 21 additions & 0 deletions plugins/import/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,30 @@ async function pullFirstTransactionForContract(network: string, address: string)
return contractCreationCode.slice(2);
}

async function scrapeContractCreationCodeFromEtherscanApi(network: string, address: string) {
const params = {
module: 'proxy',
action: 'eth_getCode',
address,
apikey: getEtherscanApiKey(network)
};
const url = `${getEtherscanApiUrl(network)}?${paramString(params)}`;
const debugUrl = `${getEtherscanApiUrl(network)}?${paramString({ ...params, ...{ apikey: '[API_KEY]'}})}`;

debug(`Attempting to pull Contract Creation code from API at ${debugUrl}`);
const result = await get(url, {});
const contractCreationCode = result.result;
if (!contractCreationCode) {
throw new Error(`Unable to find Contract Creation code from API at ${debugUrl}`);
}
debug(`Creation Code found in first tx at ${debugUrl}`);
return contractCreationCode.slice(2);
}

async function getContractCreationCode(network: string, address: string) {
const strategies = [
scrapeContractCreationCodeFromEtherscan,
scrapeContractCreationCodeFromEtherscanApi,
pullFirstTransactionForContract
];
let errors = [];
Expand Down
5 changes: 3 additions & 2 deletions scenario/BulkerScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { exp } from '../test/helpers';
scenario(
'Comet#bulker > (non-WETH base) all non-reward actions in one txn',
{
filter: async (ctx) => await isBulkerSupported(ctx) && !matchesDeployment(ctx, [{deployment: 'weth'}, {network: 'mumbai'}, { network: 'linea-goerli' }]),
filter: async (ctx) =>
await isBulkerSupported(ctx) && !matchesDeployment(ctx, [{deployment: 'weth'}, {network: 'mumbai'}, { network: 'linea-goerli' }, {deployment: 'weth-lrt', network: 'mainnet'}]),
supplyCaps: {
$asset0: 3000,
$asset1: 3000,
Expand Down Expand Up @@ -162,7 +163,7 @@ scenario(
scenario(
'Comet#bulker > (non-WETH base) all actions in one txn',
{
filter: async (ctx) => await isBulkerSupported(ctx) && await isRewardSupported(ctx) && !matchesDeployment(ctx, [{deployment: 'weth'}, { network: 'linea-goerli' }]),
filter: async (ctx) => await isBulkerSupported(ctx) && await isRewardSupported(ctx) && !matchesDeployment(ctx, [{deployment: 'weth'}, { network: 'linea-goerli' }, {deployment: 'weth-lrt', network: 'mainnet'}]),
supplyCaps: {
$asset0: 3000,
},
Expand Down
4 changes: 3 additions & 1 deletion scenario/LiquidationBotScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,13 +733,15 @@ scenario(
const baseTokenBalances = {
mainnet: {
usdc: 2250000,
weth: 20
weth: 20,
'weth-lrt': 1
},
};
const assetAmounts = {
mainnet: {
usdc: ' == 5000', // COMP
weth: ' == 10000', // CB_ETH
'weth-lrt': ' == 1' // EZ_ETH
},
};

Expand Down
15 changes: 14 additions & 1 deletion scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const addresses = {
WBTC: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
WETH9: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
CB_ETH: '0xBe9895146f7AF43049ca1c1AE358B0541Ea49704',
WST_ETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'
WST_ETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
EZ_ETH: '0xbf5495Efe5DB9ce00f80364C8B423567e58d2110'
},
goerli: {
WETH: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d'
Expand Down Expand Up @@ -87,6 +88,10 @@ export const flashLoanPools = {
weth: {
tokenAddress: addresses.mainnet.USDC,
poolFee: 500
},
'weth-lrt': {
tokenAddress: addresses.mainnet.WETH9,
poolFee: 500
}
},
goerli: {
Expand Down Expand Up @@ -177,6 +182,13 @@ export function getPoolConfig(tokenAddress: string) {
balancerPoolId: '0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080'
}
},
[addresses.mainnet.EZ_ETH.toLowerCase()]: {
...defaultPoolConfig,
...{
exchange: Exchange.Balancer,
balancerPoolId: '0x596192bb6e41802428ac943d2f1476c1af25cc0e000000000000000000000659'
}
},
[addresses.polygon.WMATIC.toLowerCase()]: {
...defaultPoolConfig,
...{
Expand Down Expand Up @@ -252,6 +264,7 @@ function getMaxAmountToPurchase(tokenAddress: string): bigint {
[addresses.mainnet.UNI.toLowerCase()]: exp(100_000, 18),
[addresses.mainnet.WBTC.toLowerCase()]: exp(120, 8),
[addresses.mainnet.WETH9.toLowerCase()]: exp(5000, 18),
[addresses.mainnet.EZ_ETH.toLowerCase()]: exp(5000, 18),
// Polygon
[addresses.polygon.WETH.toLowerCase()]: exp(400, 18),
[addresses.polygon.WBTC.toLowerCase()]: exp(20, 8),
Expand Down
14 changes: 10 additions & 4 deletions src/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ export type Proposal = [
// Ideally these wouldn't be hardcoded, but other solutions are much more complex, and slower
export const COMP_WHALES = {
mainnet: [
'0xea6c3db2e7fca00ea9d7211a03e83f568fc13bf7',
'0x61258f12c459984f32b83c86a6cc10aa339396de',
'0x9aa835bc7b8ce13b9b0c9764a52fbf71ac62ccf1',
'0x683a4f9915d6216f73d6df50151725036bd26c02'
'0x683a4f9915d6216f73d6df50151725036bd26c02',
'0x8169522c2C57883E8EF80C498aAB7820dA539806',
'0x8d07D225a769b7Af3A923481E1FdF49180e6A265',
'0x7d1a02C0ebcF06E1A36231A54951E061673ab27f',
'0x54A37d93E57c5DA659F508069Cf65A381b61E189'
],

testnet: ['0xbbfe34e868343e6f4f5e8b5308de980d7bd88c46']
Expand All @@ -84,9 +86,13 @@ export const WHALES = {
'0x0548f59fee79f8832c299e01dca5c76f034f558e',
'0x218b95be3ed99141b0144dba6ce88807c4ad7c09',
'0xf04a5cc80b1e94c69b48f5ee68a08cd2f09a7c3e',
'0x2F0b23f53734252Bda2277357e97e1517d6B042A',
'0x2775b1c75658be0f640272ccb8c72ac986009e38',
'0x1a9c8182c09f50c8318d769245bea52c32be35bc',
'0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b'
'0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b',
'0x22162DbBa43fE0477cdC5234E248264eC7C6EA7c', // ezETH
'0x267ed5f71EE47D3E45Bb1569Aa37889a2d10f91e', // ezETH
'0x3A0ee670EE34D889B52963bD20728dEcE4D9f8FE' // ezETH
],
polygon: [
'0x2093b4281990a568c9d588b8bce3bfd7a1557ebd', // WETH whale
Expand Down
Loading